|
Post by kjelle69 on Jan 18, 2005 19:49:20 GMT 1
I am working with some nice updates ;D One of the most important ones is to get some new functions in the vehiclejoint. However, one strange thing I spotted is that the graphical presentation of the tires seem to lag comparing to the newton world. Any ideas Walaber ?
|
|
|
Post by Kjelle69 on Jan 19, 2005 0:27:57 GMT 1
I noticed that too... if I remember correctly, setting the MinimumFramerate to a higher value fixed the problem...
it could be a problem with the wrapper though... not sure why that would happen..
it seems like the tires are 1 frame behind the debug data...
p.s. with a car shape like that, a convex hull would probably work great!
|
|
|
Post by kjelle69 on Feb 11, 2005 9:29:11 GMT 1
I've seen some discussion about the tire lag in the Newton forum : newtondynamics.com/forum/viewtopic.php?t=1074But is it really this way in the wrapper ? That the matrix of the car is updated then newtonupdate called and then tires ? Dont think so .
|
|
|
Post by Kjelle69 on Feb 11, 2005 9:54:55 GMT 1
I think it's possible that it's a problem with the wrapper...
i saw that same post... and it reminded me that the wrapper still has this problem.
I'll ask how the user solved the problem in that post.
|
|
|
Post by kjelle69 on Feb 11, 2005 11:40:30 GMT 1
Yes i am going through your code right now, trying to get a grip over the callbacks. Can it somehow be the order in which the objects are updated through the callbacks ? This code is done in the tirecallback // update visual object of the tire! NewtonVehicleGetTireMatrix( vehicle, tyreId, &matrix.m_front.m_x );
if (thetire->DB_ObjNum == 0) continue;
NewtonGetEulerAngle( &matrix.m_front.m_x, &rot.m_x );
rot.m_x *= (180.0f / 3.14159f); rot.m_y *= (180.0f / 3.14159f); rot.m_z *= (180.0f / 3.14159f); DBPro::PositionObject( thetire->DB_ObjNum, matrix.m_posit.m_x, matrix.m_posit.m_y, matrix.m_posit.m_z ); DBPro::RotateObject( thetire->DB_ObjNum, rot.m_x, rot.m_y, rot.m_z ); But Where is the Body of the Car updated ? And in which orders are the callbacks executed ?
|
|
|
Post by kjelle69 on Feb 11, 2005 12:11:35 GMT 1
Working through the code a bit more, and the only occurence of DBPro::PositionObject is with the tire positioning in the tireupdatecallback. Now I must admit I am a bit confused, where and how are all the other objects updated and positioned ? The position and rotation of all meshes must somehow get sent back to DBPro right ?Ok, understand, this function is called to position things... Like in Tutorial_02_usingCallbacks, same syntax, but with specific DBPro transformation due to flipped Z-Axis right? PhysicsSetTransform( const NewtonBody* body, const float* tmatrix ) Question is, in what order is this function called compared to the tireupdate... hmmm.. Could a solution be to put this code inside the PhysicSetTranform funciton instead, then they would be updated at the same time as the rest of the objects in the scene. DBPro::PositionObject( thetire->DB_ObjNum, matrix.m_posit.m_x, matrix.m_posit.m_y, matrix.m_posit.m_z ); DBPro::RotateObject( thetire->DB_ObjNum, rot.m_x, rot.m_y, rot.m_z );
|
|
|
Post by Kjelle69 on Feb 12, 2005 11:23:33 GMT 1
yeah, that would work... but you need a way to determine which body is the vehicle body, because that callback gets called for EVERY moving body in the Newton World...
if I had made a better class to hole the NewtonBody's, it could be done... but with the current implementation it'd be difficult..
|
|
|
Post by kjelle69 on Feb 12, 2005 16:02:12 GMT 1
But is the PhysicSetTransform callback called more often than the tireupdatecallback?
And where is the vehicles body position updated? In the physicsettransform or somewhere else?
It must be able to work around the Tire Lag. Otherwise the whole vehicle system gets a little bit to ugly to use in fast vehicles.
Is it possible to Force a transformcallback from the tireupdate or vice versa ?
|
|
|
Post by Kjelle69 on Feb 14, 2005 4:10:09 GMT 1
the PhysicsTransformCallback is called for every Rigid Body in the system that has moved since the last update.
this included the car body, because it's just a rigid body.
the tires are special, however, and so you must update their location manually. apparently the vehiclecallback is called BEFORE all of the update is completed, so the basic rigid bodies (including the vehicle body) get updated, but the tires stay "one frame behind" the action.
I think the easiest solution for the wrapper, would be this:
remove the positioning of the tire objects from the vehicle callback.
add a new section to the NDB_NewtonUpdate command. after calling NewtonUpdate(), loop through all of the vehicles in the system, updating the tires location.
that should fix it.
or you could add a user-command called "UpdateTireLocations" for a specific vehicle, and let the user call that function AFTER calling NDB_NewtonUpdate.
that might be the best solution actually...
|
|
|
Post by kjelle69 on Feb 15, 2005 1:10:51 GMT 1
If I make a new function for forced wheelupdates, lets say : NDB_NewtonUpdateTires(Vehiclejoint)
I call this function once every loop, after the newtonupdatefunction if vehicles are used in the scene.
Well, If I add this function, wont the original tireupdatecallback do its stuff every cycle also ?
One solution would maybe be to let the tireupdatecallback do the input to the tires, then the newtonupdatetires would become a mandatory function to update position of wheels if vehiclejoints are used in DBPro code.
Or, let both functions exist, ofcourse then the tires graphic representation would be updated twice every cycle.
|
|
|
Post by kjelle69 on Feb 15, 2005 2:24:19 GMT 1
...And Many hours later....
|
|
|
Post by Kjelle69 on Feb 15, 2005 3:58:39 GMT 1
;D ;D ;D
|
|