## Set Position?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

### Set Position?

Is there a function to set the position of a body? Or do you have to delete the old one and make a new one in the new position

EDIT: Never mind, I found it in one example, NewtonSetMatrix
Mag-got

Posts: 4
Joined: Tue Nov 20, 2007 12:13 pm

### Re: Set Position?

You can just get the Matrix from the body you want to move with GetBodyMatrix, Then simple translate that m->Translate( x, y, z ) to the new position, the you set the new matrix for the body with SetBodyMatrix.

Thats how I do it.
while(your_engine > my_engine)
my_engine++;
socom

Posts: 6
Joined: Fri Dec 03, 2004 10:53 am

### Re: Set Position?

I was wondering how you can get other objects that are in contact with this body to move?

For example, i have a box sitting on top of another box. I move the box at the bottom. How do i get the top box to fall?
I figured something like unfreeze may work (if i can get a list of bodies in contact with the bottom one, which i assume is somehow possible?), but it appears this function is removed in 2.0?

I'm applying gravity to the top box with a callback, like in tutorial02. The bottom box is mass=0, i don't know if that is my issue somehow.
Interface

Posts: 4
Joined: Fri Jan 09, 2009 12:06 am

### Re: Set Position?

If you want to move an immobile object (mass = 0), then you need to:

1) set it's velocity using NewtonBodySetVelocity()
2) every frame, manually use NewtonBodySetMatrix() to move the body's position according to its velocity
3) every frame, wake up all objects within this body's AABB using NewtonWorldForEachBodyInAABBDo() and NewtonBodySetSleepState()

Now dynamic objects will react properly to any immobile mesh that is 'manually' moving (even if its a tree collision).

If it's not an immobile object, just use NewtonBodySetVelocity() or NewtonBodyAddImpulse()
agi_shi

Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

### Re: Set Position?

Thanks for the tip, i added it to newton wiki: http://newtondynamics.com/wiki/index.ph ... TriMesh%3F
Help improving the Newton Game Dynamics WIKI

JernejL

Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia