wxpython, pyode and k3d

View: New views
10 Messages — Rating Filter:   Alert me  

wxpython, pyode and k3d

by Paulo Teotonio Sobrinho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi

I finally had some time to play with pyode and k3d to make some
animations. You can take a look at my initial attempts here:
http://fma.if.usp.br/~teotonio/temp/ode_test.avi
They are very simple and only uses collision detection. I need to work out
examples that make use of other things like joints for example.

I would like to make some comments about k3d based on this experience:

1) Setting up a simulation is a very interactive process. In order to make
things practical I had to write a python class for each ode basic element,
such as mass, body and geometry for collision detection, binding ode data
and k3d nodes. In doing so I'm able to edit the relevant parameters and
try variations of the same simulation.

2) Combining theses classes into a coherent simulation was a slow process.
The simulation was done inside a NullOutputScript that had a number of
"if" statements to perform actions such as creating the simulation
objects, setting up initial simulation states (positions and velocities),
setting parameters (friction, bounce), starting the simulation loop,
resetting the simulation and so on.

After some time I realized what I was trying to do: a kind of event driven
mini application running inside k3d. That was never my intention but that
was how it came out to be.  The next natural step would be to give
the "mini application" its own GUI. For my surprise, that is actually
possible.

Consider any instance of python running in k3d. It can be a scripted node,
a stand alone script or even the interactive python shell. I was able to
a) Import gtk or wxpython. Create windows, menus, buttons or any other
widget you like. b)Set up gtk (or wxpython) call back functions to perform
actions on my k3d document. As far as I know, the GUI events are handled
correctly and I had added a new GUI window to the existing k3d window.
The original k3d and my home made python GUI run simultaneously. Note: I
don't need to call the usual GUI main loop function on my python code! The
main loop of gtk controlling k3d takes care of the events (button press,
mouse click, etc) on my wx window. It worked perfectly on all examples I
looked at.

These idea can be expanded and may be used to bring new functionality to
k3d using pure python. As of now, a scripted plugin can create new nodes
but can not pass on its current scope's local variables. That forced me to
run the simulation in a single scripted node and insert as many "if"
statements as I needed. But it does not look natural to me. When writing a
plugin, I think one should be able to do something like this

plugin_context=locals()
my_node=Document.new_node("NullOutputScript", plugin_context)

and have plugin_context exposed to my_node, at least for  plugins that are
executing within a document context.

If one adds some pygtk or wxpython widgets, such a plugin becomes a sort
of user made application with its own states, GUI and nodes. To have a
python plugin like this acting upon a k3d document may turn out to be
useful. In any case, that is the kind of structure that I'm running into.

Cheers
  Paulo

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Timothy M. Shead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paulo Teotonio Sobrinho wrote:

> Hi
>
> I finally had some time to play with pyode and k3d to make some
> animations. You can take a look at my initial attempts here:
> http://fma.if.usp.br/~teotonio/temp/ode_test.avi
> They are very simple and only uses collision detection. I need to work out
> examples that make use of other things like joints for example.
>
> I would like to make some comments about k3d based on this experience:
>
> 1) Setting up a simulation is a very interactive process. In order to make
> things practical I had to write a python class for each ode basic element,
> such as mass, body and geometry for collision detection, binding ode data
> and k3d nodes. In doing so I'm able to edit the relevant parameters and
> try variations of the same simulation.
>
> 2) Combining theses classes into a coherent simulation was a slow process.
> The simulation was done inside a NullOutputScript that had a number of
> "if" statements to perform actions such as creating the simulation
> objects, setting up initial simulation states (positions and velocities),
> setting parameters (friction, bounce), starting the simulation loop,
> resetting the simulation and so on.
>
> After some time I realized what I was trying to do: a kind of event driven
> mini application running inside k3d. That was never my intention but that
> was how it came out to be.  The next natural step would be to give
> the "mini application" its own GUI. For my surprise, that is actually
> possible.
>
> Consider any instance of python running in k3d. It can be a scripted node,
> a stand alone script or even the interactive python shell. I was able to
> a) Import gtk or wxpython. Create windows, menus, buttons or any other
> widget you like. b)Set up gtk (or wxpython) call back functions to perform
> actions on my k3d document. As far as I know, the GUI events are handled
> correctly and I had added a new GUI window to the existing k3d window.
> The original k3d and my home made python GUI run simultaneously. Note: I
> don't need to call the usual GUI main loop function on my python code! The
> main loop of gtk controlling k3d takes care of the events (button press,
> mouse click, etc) on my wx window. It worked perfectly on all examples I
> looked at.
>
> These idea can be expanded and may be used to bring new functionality to
> k3d using pure python. As of now, a scripted plugin can create new nodes
> but can not pass on its current scope's local variables. That forced me to
> run the simulation in a single scripted node and insert as many "if"
> statements as I needed. But it does not look natural to me. When writing a
> plugin, I think one should be able to do something like this
>
> plugin_context=locals()
> my_node=Document.new_node("NullOutputScript", plugin_context)
>
> and have plugin_context exposed to my_node, at least for  plugins that are
> executing within a document context.
>
> If one adds some pygtk or wxpython widgets, such a plugin becomes a sort
> of user made application with its own states, GUI and nodes. To have a
> python plugin like this acting upon a k3d document may turn out to be
> useful. In any case, that is the kind of structure that I'm running into.
Paulo:

Plenty of food for thought here, really enjoyed the video, I'd really
like to experiment with this myself - could you post your scripts or a
sample document somewhere?

Cheers,
Tim

[tshead.vcf]

begin:vcard
fn:Timothy Shead
n:Shead;Timothy
org:www.k-3d.org
email;internet:tshead@...
title:Founder
x-mozilla-html:FALSE
version:2.1
end:vcard



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Paulo Teotonio Sobrinho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Wed, 2 Sep 2009, Timothy M. Shead wrote:

>
> Paulo:
>
> Plenty of food for thought here, really enjoyed the video, I'd really like to
> experiment with this myself - could you post your scripts or a sample
> document somewhere?
>
> Cheers,
> Timmessy
>

I can do that if you don't mind looking at messy scripts with strange
variable naming. Please go to http://fma.if.usp.br/~teotonio/temp/Samples
There is a Readme to tel what the files are

Cheers,
Paulo

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by bART Janssens-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Sep 2, 2009 at 10:28 PM, Paulo Teotonio
Sobrinho<teotonio@...> wrote:
> I finally had some time to play with pyode and k3d to make some
> animations. You can take a look at my initial attempts here:
> http://fma.if.usp.br/~teotonio/temp/ode_test.avi
> They are very simple and only uses collision detection. I need to work out
> examples that make use of other things like joints for example.

This looks very impressive already!

Regards,

--
Bart

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Timothy M. Shead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paulo Teotonio Sobrinho wrote:

> On Wed, 2 Sep 2009, Timothy M. Shead wrote:
>> Paulo:
>>
>> Plenty of food for thought here, really enjoyed the video, I'd really like to
>> experiment with this myself - could you post your scripts or a sample
>> document somewhere?
>>
>> Cheers,
>> Timmessy
>>
>
> I can do that if you don't mind looking at messy scripts with strange
> variable naming. Please go to http://fma.if.usp.br/~teotonio/temp/Samples
> There is a Readme to tel what the files are
Paulo:

I have to be honest, I wasn't able to reproduce any of your results.  As
a general observation, I want to caution you against putting too much
effort into what should be a prototype capability.  In particular, I
encourage you to assume that UI support will be written to make things
easy, and that you needn't work-around the complexity using a scripted UI.

I've distilled your scripts down into a much simpler sample document
that captures what I think are the essential features of a usable
capability.  See my writeup at

http://www.k-3d.org/wiki/Open_Dynamics_Engine_Integration

... which I encourage you to use to capture your notes.

Cheers,
Tim


[tshead.vcf]

begin:vcard
fn:Timothy Shead
n:Shead;Timothy
org:www.k-3d.org
email;internet:tshead@...
title:Founder
x-mozilla-html:FALSE
version:2.1
end:vcard



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Paulo Teotonio Sobrinho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




On Sat, 5 Sep 2009, Timothy M. Shead wrote:

> Paulo Teotonio Sobrinho wrote:
>> On Wed, 2 Sep 2009, Timothy M. Shead wrote:
>>> Paulo:
>>>
>>> Plenty of food for thought here, really enjoyed the video, I'd really like
>>> to experiment with this myself - could you post your scripts or a sample
>>> document somewhere?
>>>
>>> Cheers,
>>> Timmessy
>>>
>>
>> I can do that if you don't mind looking at messy scripts with strange
>> variable naming. Please go to http://fma.if.usp.br/~teotonio/temp/Samples
>> There is a Readme to tel what the files are
>
> Paulo:
>
> I have to be honest, I wasn't able to reproduce any of your results.  As a
> general observation, I want to caution you against putting too much effort
> into what should be a prototype capability.  In particular, I encourage you
> to assume that UI support will be written to make things easy, and that you
> needn't work-around the complexity using a scripted UI.
>
> I've distilled your scripts down into a much simpler sample document that
> captures what I think are the essential features of a usable capability.  See
> my writeup at
>
> http://www.k-3d.org/wiki/Open_Dynamics_Engine_Integration
>
> ... which I encourage you to use to capture your notes.
>
> Cheers,
> Tim
>
>

Tim:

When you say you were not able to reproduce my results, do you mean that
my scripts did not work? Or do you mean that the animations did not
resemble the ones I posted in my web-page? If it is the second case, I
must tell you that I experimented with many initial conditions but only
recorded the ones that would catch the eye. Unfortunately I don't have the
initial position and velocity of each component used in the simulations...
As soon as I can, I'll try to generate similar animations and this time,
give the initial data as well. I also want to try your script.

I was not aware that people have given a lot of thought on the integration
of ode and k3d, as pointed in
http://www.k-3d.org/wiki/Open_Dynamics_Engine_Integration
I can see that from a developer's point of view it is a tricky business
and one should proceed with great care. My point of view is (or was) of a
user trying to get interesting simulations up and running no matter what.

Cheers,
Paulo



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Timothy M. Shead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Paulo Teotonio Sobrinho wrote:

> When you say you were not able to reproduce my results, do you mean that
> my scripts did not work? Or do you mean that the animations did not
> resemble the ones I posted in my web-page?

I'm sure everything works fine, I just wasn't clear on how to use the
scripts.

> I was not aware that people have given a lot of thought on the integration
> of ode and k3d, as pointed in
> http://www.k-3d.org/wiki/Open_Dynamics_Engine_Integration
> I can see that from a developer's point of view it is a tricky business
> and one should proceed with great care. My point of view is (or was) of a
> user trying to get interesting simulations up and running no matter what.

That's great!  I wasn't sure whether you were planning a full-fledged
new capability, or just hacking some stuff together for fun.  I always
look at things with a strategic perspective (that's my job), but not
everything has to be coded for the ages, and I don't want to discourage
people from having a good time.  I for one have benefited from your
scripts.

Cheers,
Tim


[tshead.vcf]

begin:vcard
fn:Timothy Shead
n:Shead;Timothy
org:www.k-3d.org
email;internet:tshead@...
title:Founder
x-mozilla-html:FALSE
version:2.1
end:vcard



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Timothy M. Shead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Timothy M. Shead wrote:

I had some idle time on a plane, so I created an ODE plugin that builds
on the Python prototypes.  You can see some videos at

http://www.youtube.com/watch?v=_JGuzQQz2PU
http://www.youtube.com/watch?v=552zZrJPN8Y

Cheers,
Tim

[tshead.vcf]

begin:vcard
fn:Timothy Shead
n:Shead;Timothy
org:www.k-3d.org
email;internet:tshead@...
title:Founder
x-mozilla-html:FALSE
version:2.1
end:vcard



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by bART Janssens-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Sep 18, 2009 at 8:20 AM, Timothy M. Shead <tshead@...> wrote:
> Timothy M. Shead wrote:
>
> I had some idle time on a plane, so I created an ODE plugin that builds on
> the Python prototypes.  You can see some videos at
>
> http://www.youtube.com/watch?v=_JGuzQQz2PU
> http://www.youtube.com/watch?v=552zZrJPN8Y

Cool! I did get a crash when trying this myself using ODE 0.11.1.
Adding dInitODE(); in the simulation constructor fixed this.

Cheers,

--
Bart

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

Re: wxpython, pyode and k3d

by Timothy M. Shead :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bart Janssens wrote:

> On Fri, Sep 18, 2009 at 8:20 AM, Timothy M. Shead <tshead@...> wrote:
>> Timothy M. Shead wrote:
>>
>> I had some idle time on a plane, so I created an ODE plugin that builds on
>> the Python prototypes.  You can see some videos at
>>
>> http://www.youtube.com/watch?v=_JGuzQQz2PU
>> http://www.youtube.com/watch?v=552zZrJPN8Y
>
> Cool! I did get a crash when trying this myself using ODE 0.11.1.
> Adding dInitODE(); in the simulation constructor fixed this.
Interesting, the version I'm using in Ubuntu is 2.0 ... a lot of water
under the bridge ;)  I've added the call to dInitODE(), interestingly it
isn't documented for later versions, so I'm guessing that it's a no-op
retained for API compatibility.

Cheers,
Tim

[tshead.vcf]

begin:vcard
fn:Timothy Shead
n:Shead;Timothy
org:www.k-3d.org
email;internet:tshead@...
title:Founder
x-mozilla-html:FALSE
version:2.1
end:vcard



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development