Moving TreeCollision Body

deadvirus

01-04-2009 18:22:58

Hello,
I have a body made of a TreeCollision, and I need to move it sometimes.
I've read on the Newton Wiki that you can move it with the NewtonBodySetMatrix (setPositionOrientation in OgreNewt) using Newton 2.0.
But I've done that and the body does not move! I'm using Newton 1.53. Does it only work on Newton 2.0?

Thank you.

Zero23

01-04-2009 19:03:39

"setPositionOrientation" Does not work with newton 2.0 hmm I dont think^^ Show pls some code.

Zero

deadvirus

01-04-2009 19:25:22

Thanks for your reply.

I'm just doing some tests, so the code is not well organized.
The setPositionOrientation is done inside the Picking class I've found on the wiki (http://www.ogre3d.org/wiki/index.php/OgreNewt_Picking) changing the body->addGlobalForce(dragForce, dragPos); line to body->setPositionOrientation(cursorPos,Ogre::Quaternion::IDENTITY);

The code that creates the body is:

size = Ogre::Vector3( 1.0, 0.8, 0.8 );
node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
ent = mSceneMgr->createEntity("cone_body", "cone.mesh" );
ent->setCastShadows(true);
node->attachObject( ent );
node->setScale( size );

// rigid body.
col = new OgreNewt::CollisionPrimitives::TreeCollision(mWorld,node,false);
bod = new OgreNewt::Body( mWorld, col );
bod->attachToNode( node );

// initial position
bod->setPositionOrientation( Ogre::Vector3(-2,3,2), Ogre::Quaternion::IDENTITY );
delete col;



As I've said, this is just for testing purposes, so don't flame me :oops:

EDIT: I forgot to say that other bodies that are not TreeCollision, move correctly with the setPositionOrientation.

Thanks.

Zero23

01-04-2009 20:49:13

Hmm but that have to work .. Does only the mesh not move? Do you tried if may only the collisions was moved?

deadvirus

01-04-2009 21:12:54

Hmm but that have to work .. Does only the mesh not move? Do you tried if may only the collisions was moved?

The collisions do not move too... Have you tried to do it? I can set the initial position with setPositionOrientation... but in runtime, it does not move. :cry:

deadvirus

03-04-2009 20:42:49

No one?

melven

04-04-2009 12:59:43

The setPositionOrientation-functions are intended for setting the initial position and orientation. I don't know if it is possible to reset the position, if you want to know if that's a limitation of newton try doing that in the newton-demos or ask in the newton forum.
But it should be no problem to create a new body with the new position using the same collision and destroying the old one...

deadvirus

04-04-2009 16:24:31

The setPositionOrientation-functions are intended for setting the initial position and orientation. I don't know if it is possible to reset the position, if you want to know if that's a limitation of newton try doing that in the newton-demos or ask in the newton forum.
But it should be no problem to create a new body with the new position using the same collision and destroying the old one...


Thanks.
I needed it to keep moving and still colide... like what says where (sort of): http://www.newtondynamics.com/wiki/index.php5?title=Can_i_dynamicly_move_a_TriMesh%3F

But I don't need that anymore... thank you :)