Hello,
how can I control vehicle in Newton 2.33. I have noticed that functions like NewtonVehicleSetTireSteerAngle are not present in new versions of NGE. How can I steer the car and accelerate?
Thanks!
Moderators: Sascha Willems, walaber
void TireTransformCallback (iNewtonUserJoint *car);
struct iNewtonUserJoint* CreateRayCastCast (iNewtonBody* body, SceneManager* sceneManager, float tirePosit[4][3]);
void AddTire (iNewtonUserJoint* joint, const char* fileName, struct dVector position, SceneManager* sceneManager);
void TireTransformCallback (iNewtonUserJoint *car)
{
int count;
iNewton* world;
world = GetWorld();
// the tire geometry is not aligned with the collision shape,
// we can use a local rotation matrix to algn the tires correctly.
struct dMatrix tireYawMatrix =dYawMatrix(3.1416f * 0.5f);
// iterate over all tire and calculate the location of the Visual Matrix
count = [world DGRaycastVehicleGetTiresCount:car];
for (int i = 0; i < count; i ++) {
Entity* tireEnt;
struct dMatrix tireMatrix;
// get THe tie entity.
tireEnt = (Entity*) [world DGRaycastVehicleGetTiresUserData:car :i];
// Get the tire matrix form the joint and calculate the final visual matrix
[world DGRaycastVehicleGetTireMatrix:car :i :&tireMatrix.m_front.m_x];
tireMatrix = MultiplyMatrix(&tireYawMatrix , &tireMatrix);
// we need to convert the matrix into a quaternion rotation because our entity used quaternion to express rotations
struct dQuaternion rotation = QuaternionFromMatrix(tireMatrix);//Vprasljiva pretvorba!!!!!!
struct dQuaternion m_curRotation = tireEnt.m_curRotation;
// make sure the rotation spinning tire around the shortest path.
if (dQuatDotProduct(&rotation, &m_curRotation) < 0.0f) {
dQuatScale(&rotation, -1.0f);
}
// move current rotation and position to previews rotation and position, and save the New rotation and position
tireEnt.m_prevRotation = tireEnt.m_curRotation;
tireEnt.m_curRotation = rotation;
tireEnt.m_prevPosition = tireEnt.m_curPosition;
tireEnt.m_curPosition = tireMatrix.m_posit;
}
}
Users browsing this forum: No registered users and 1 guest