A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Xycaleth » Mon Jan 18, 2010 5:21 am
Hi everyone,
I've been trying to get an elevator to work in my game by following this topic:
viewtopic.php?p=35089However, the NewtonBodySetSleepState function doesn't exist anymore. So is this method still possible? Or is there a different way of going about it now?
Thanks in advance

Alex
-
Xycaleth
-
- Posts: 13
- Joined: Mon Jun 29, 2009 6:41 am
by PJani » Mon Jan 18, 2010 5:35 am
One option is you can use CustomKinematicController from JointLibrary. Second option is you can set mass of object to 0 and then move it by setting its position...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
-

PJani
-
- Posts: 448
- Joined: Mon Feb 02, 2009 7:18 pm
- Location: Slovenia
by Xycaleth » Mon Jan 18, 2010 5:47 am
I have the elevator as a rigid body of mass 0 which I'm moving using NewtonBodySetMatrix, however when I move it upwards, anything on top of the elevator seems to just fall straight through.
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()
That's the specific post I was going through, and as it says in the 3rd step, I need to wake up the objects within the moving body's AABB, but I can't do that because there is no NewtonBodySetSleepState function.
-
Xycaleth
-
- Posts: 13
- Joined: Mon Jun 29, 2009 6:41 am
by JernejL » Mon Jan 18, 2010 6:08 am
I think in newton 2.0 it is the NewtonBodySetFreezeState function.
-

JernejL
-
- Posts: 1588
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by Xycaleth » Mon Jan 18, 2010 6:18 am
I've tried with, and without NewtonBodySetFreezeState, but it doesn't seem to help. Here's a video I made, of the problem occuring:
http://tinypic.com/m/726f5g/2I'm actually making a game mod for Star Wars: Jedi Knight: Jedi Academy (Q3 engine game). And here's the code which I call every frame:
- Code: Select all
void BG_MoveRigidBodyTo ( int entityId, const vec3_t newPosition, const vec3_t velocity )
{
LevelEntitiesMap::iterator ent = mapEntities.find (entityId);
if ( ent == mapEntities.end() )
{
return;
}
dMatrix matrix;
vec3_t scaledVelocity;
BG_QuakeToSIUnits (velocity, scaledVelocity);
NewtonBodySetVelocity (ent->second, &scaledVelocity[0]);
NewtonBodyGetMatrix (ent->second, &matrix[0][0]);
BG_QuakeToSIUnits2 (newPosition, matrix.m_posit);
NewtonBodySetMatrix (ent->second, &matrix[0][0]);
//NewtonBodySetFreezeState (ent->second, 0); // tried with and without, doesn't make any difference.
}
I know the velocity will be set to 0 when the elevator reaches the top and bottom, so I can (hopefully) have the NewtonBodySetVelocity function there.
-
Xycaleth
-
- Posts: 13
- Joined: Mon Jun 29, 2009 6:41 am
by Xycaleth » Tue Jan 19, 2010 1:18 pm
Does nobody have any idea?
-
Xycaleth
-
- Posts: 13
- Joined: Mon Jun 29, 2009 6:41 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 6 guests