It is currently May 21st, 2013, 11:17 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Controllers, physics and collisions
PostPosted: April 12th, 2010, 3:39 pm 
Offline
3D Simulation Rookie
3D Simulation Rookie
User avatar

Joined: March 30th, 2010, 2:16 pm
Posts: 14
Location: Nice
Hi,

I actually got some problems to understand clearly the controller system :

To have physics interaction , an actor (static or dynamic) have to have the world physics controller attached
Code:
node.AttachController(_world.AddActor(actorDesc));


But when there is an actor attached, it's not possible to move it manually (i.e with a RelativeTranslation on the node).

So here is the question, if I need to have a static actor like a SimplyCube, that interact physically and can also be moved manually, what is the best methods ?

I've looked for the way it's done in the NanoConcept source, but I haven't succeeded at loading a simple xnb object.

I'm also looking at the simplest way to raise en event when a specified physical object is touched by any other object. There is plenty of methods intersects but that are much more complicated to use. Will a simple event be available for the release ?

Best Regards,
Thomas B.


Top
 Profile  
 
 Post subject: Re: Controllers, physics and collisions
PostPosted: April 12th, 2010, 11:01 pm 
Offline
SimplySim Team
SimplySim Team
User avatar

Joined: December 11th, 2008, 7:39 pm
Posts: 118
Hello,

Thomas Barthélémy wrote:
But when there is an actor attached, it's not possible to move it manually (i.e with a RelativeTranslation on the node).So here is the question, if I need to have a static actor like a SimplyCube, that interact physically and can also be moved manually, what is the best methods ?


When a PhysicsActor is attached to a node, it overrides at each update the node pose. The best way to move "manually" an actor for now it's to apply force (keep a reference to PhysicsActor.Base and cast to IDynamicActor).

We are looking for a better solution to provide some kind of "static" actor (a controllable physics shape) in the release version.

Thomas Barthélémy wrote:
I've looked for the way it's done in the NanoConcept source, but I haven't succeeded at loading a simple xnb object.


If you have encountered problems with NanoConcept, please feel free to make a specific post, we may help you (and maybe correct some problems).

Thomas Barthélémy wrote:
I'm also looking at the simplest way to raise en event when a specified physical object is touched by any other object. There is plenty of methods intersects but that are much more complicated to use. Will a simple event be available for the release ?


There is an "filtered event" on PhysicsWorld class to get collision notifications between two actors. You can also use physics raycast to easily pick an actor in the physics world. The NanoConcept demo 2 that is coming soon will demonstrate these methods.

Regards

_________________
Vincent Maurin
CTO
SimplySim


Top
 Profile  
 
 Post subject: Re: Controllers, physics and collisions
PostPosted: April 13th, 2010, 12:38 pm 
Offline
3D Simulation Rookie
3D Simulation Rookie
User avatar

Joined: March 30th, 2010, 2:16 pm
Posts: 14
Location: Nice
Quote:
There is an "filtered event" on PhysicsWorld class to get collision notifications between two actors.


Thanks, works perfectly.

Quote:
The best way to move "manually" an actor for now it's to apply force (keep a reference to PhysicsActor.Base and cast to IDynamicActor).


Still got some problems with that,
I first tried to keep the PhysicsActor sent by the World.AddActor methods,
then casted the PhysicsActor.Actor to a IDynamicActor but the Actor seems to be null.

I also tried the World.Base.AddActor that actually give me a usable Actor but not a PhysicsActor that I need
as a node Controller.
I probably missed something, thanks for your help.

Regards,
Thomas B.


Top
 Profile  
 
 Post subject: Re: Controllers, physics and collisions
PostPosted: April 13th, 2010, 2:10 pm 
Offline
SimplySim Team
SimplySim Team
User avatar

Joined: December 11th, 2008, 7:39 pm
Posts: 118
Thomas Barthélémy wrote:
Still got some problems with that,
I first tried to keep the PhysicsActor sent by the World.AddActor methods,
then casted the PhysicsActor.Actor to a IDynamicActor but the Actor seems to be null.


It's the good way but there are some "hidden" behaviors that could make the problem complicated. PhysicsActor is the class that bind the physics actor to a SceneNode. Basically, it's an INodeController that gets the actor position in the physics world to update the node position in the graphical world.
As we want the physics actor to be initialized with the node position, we create it on the node first update. The algorithm is :
- node is created with a position
- PhysicsActor is created and attached to the node
- First Update : underlying actor is created in the node position
- Other updates : node position is overridden by the actor position

So to apply force on the underlying actor, you must wait the actor creation. There is a bool properties "IsActorCreated" that keeps the creation status, so if you keep a reference to the PhysicsActor, you should be able to add force as soon as this property is true.

An other approach (which could be "cleaner"), is to subscribe to the filtered event ActorAddedFiltered on the PhysicsWorld that will be raised when the actor is created.

In the release version, there will be a third way with an "ActorCreated" event directly on the PhysicsActor class (it's hidden in the beta).

Regards

_________________
Vincent Maurin
CTO
SimplySim


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group. Color scheme by ColorizeIt!