A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by sfx81 » Mon May 04, 2009 7:32 am
Hi. I am newbie to newton.
I created the floor at (0.0f, -5.0f, 0.0f ), and a box at (0.0f, 5.0f, 0.0f ) , kind of second tutorial, and works fine.
Now I want to reset the box back to (0.0f, 5.0f, 0.0f ) by pressing space key, and start over. Here is code
if ( dGetKeyState( ' ' ) & 0x8000 )
{
dMatrix mtx;
NewtonBodyGetMatrix( gboxPhy, &mtx[0][0] );
mtx.m_posit = dVector( 0.0f, 5.0f, 0.0f );
NewtonBodySetMatrix( gboxPhy, &mtx[0][0] );
}
This just puts the box at start position, but does not do any simulation.
Any help will be appreciated.
Cheers
kazz
-
sfx81
-
- Posts: 4
- Joined: Fri Nov 28, 2008 8:32 pm
by Virginie » Mon May 04, 2009 9:23 am
I use newton only for collision but are you doing NewtonUpdate?
-
Virginie
-
- Posts: 32
- Joined: Tue Mar 31, 2009 4:29 am
by JernejL » Mon May 04, 2009 9:25 am
You are supposed to do movement by using the forcetorque callback, not by setting matrixes directly outside the newtonupdate loop.
-
JernejL
-
- Posts: 1578
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by agi_shi » Mon May 04, 2009 5:27 pm
Delfi wrote:You are supposed to do movement by using the forcetorque callback, not by setting matrixes directly outside the newtonupdate loop.
No, what he's doing is "resetting" the box position.
@ OP: As the box rested on the ground, it probably fell asleep. You need to use NewtonBodySetFreezeState() (IIRC... the name could be different, check the header)to "unfreeze" the body when you move it.
-
agi_shi
-
- Posts: 263
- Joined: Fri Aug 17, 2007 6:54 pm
by sfx81 » Tue May 05, 2009 4:11 pm
agi_shi wrote:Delfi wrote:You are supposed to do movement by using the forcetorque callback, not by setting matrixes directly outside the newtonupdate loop.
No, what he's doing is "resetting" the box position.
@ OP: As the box rested on the ground, it probably fell asleep. You need to use NewtonBodySetFreezeState() (IIRC... the name could be different, check the header)to "unfreeze" the body when you move it.
Thank you all of you. It was
NewtonWorldUnfreezeBody( NewtonWorld, NewtonBody );
-
sfx81
-
- Posts: 4
- Joined: Fri Nov 28, 2008 8:32 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 22 guests