How to properly model expelling objects

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

How to properly model expelling objects

Postby Andazeus » Tue May 08, 2012 9:38 am

Hello there, once again!

This time, I have a question on how to properly model objects being expelled from a container. In this example, I want some cubes to permanently leave a sphere (tree collision object) through a hole.

To explain things easier, I made a simple drawing: https://docs.google.com/drawings/pub?id ... =960&h=720

The blue cubes are inside the body, the red ones are outside. The blue arrows visualize the force, that is supposed to drive the cubes towards the exit, with the small blue dot being the origin of the force.
The white box at the exit is supposed to be a virtual contact body, meaning it should detect when a cube touches it (so I know a cube has left the sphere), but should not provide any collision whatsoever.
Cubes that touch the virtual contact body have their ForceCallback changed to the red version, meaning they should be repelled by the red dot, resulting in velocities as roughly indicated by the red arrows.

My problem: while this solution, theoretically, sounds doable, I am not sure, whether this is a very elegant way of doing things. Do you have any suggestions on how improve my model? Am I doing things complicated or outright wrong? Or am I just paranoid?

Thanks everybody!
Andazeus
 
Posts: 11
Joined: Tue Mar 20, 2012 11:19 am

Re: How to properly model expelling objects

Postby Julio Jerez » Tue May 08, 2012 10:12 am

if you are using C++ the onle way you can do it is by makin a complex force call back, or by do some complex managemen when eact body have a containe with an array of objects tha are simpel call back.
I never like this extra work you hae to do in C++ to do sime as simpe as setting a funtion pointer with a context data. like you can do in C;

if you are using Newton interface you can have several static functions call back, and when the body passes through the opening you simple change the callback function.

you can also have cllkack chains, thsi si the basic call back is gravury with ad gravity.
any oteh call back call the basic callback, adn teh add teh extra force, that way you can design you system modular

ex:

Code: Select all
void ApplyGravity(...)
{
//  add gravity force:
}

void ApplyPreasure(...)
{
   ApplyGravity(...)
   // add teh presure
}

...
..



this is objects oriented code in much simple way and much more poweful than wat can be done in C++;
I sue thsi trick a lot in boyancy, and object picking demos.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: How to properly model expelling objects

Postby Andazeus » Tue May 08, 2012 11:15 am

Handling object containers in C++ is not a problem. In fact, I already created these for my project anyway and I can easily expand on them. I originally needed them for my Ogre scenenodes and I realized I could easily reuse them for Newton bodies, which is working fine so far.

From what I see, my general plan seems to be ok, which is great.

I love the idea about the callback chains. Since the software will need quite a few once it's ready, this should be very helpful! Thank you!

Modifying the standard callback is giving me a general direction for the objects to move towards. But is it also possible to have them move towards a specific point within 3d space?

Thanks!
Andazeus
 
Posts: 11
Joined: Tue Mar 20, 2012 11:19 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron