- Code: Select all
///////////////////////////////////////////////////////////
{
NewtonCollision* collision[2];
D3DXMATRIX location;
D3DXMatrixIdentity(&location);
//
D3DXMatrixRotationYawPitchRoll(&mat0,0,0,0);
D3DXMatrixTranslation(&mat1,0/10,2.42f/10,0/10);
mat0*=mat1;
collision[0] = NewtonCreateBox (nWorld, 2.23f/10,4.93f/10,0.4f/10, &mat0._11);
//
D3DXMatrixRotationYawPitchRoll(&mat0,0,0,0);
D3DXMatrixTranslation(&mat1,0/10,5.31f/10,0/10);
mat0*=mat1;
collision[1] = NewtonCreateBox (nWorld, 7.28f/10,0.87f/10,0.92f/10, &mat0._11);
NewtonCollision* collcompoud=NewtonCreateCompoundCollision(nWorld,2,collision);
Guidon.body = NewtonCreateBody (nWorld, collcompoud);
NewtonReleaseCollision (nWorld, collision[0]);
NewtonReleaseCollision (nWorld, collision[1]);
NewtonReleaseCollision (nWorld, collcompoud);
// * * * * * *
BODYUSERDATA* BUD=new BODYUSERDATA;
BUD->Moto=this;
BUD->notype=2;
BUD->noclass=no;
NewtonBodySetUserData (Guidon.body, BUD);
NewtonBodySetTransformCallback (Guidon.body, PhysicsSetTransform);
NewtonBodySetForceAndTorqueCallback (Guidon.body, PhysicsApplyForceAndTorque);
V=D3DXVECTOR3(6.0f/10,4.93f/10,0.9f/10);
mass = 5;
Ixx = 0.7f * mass * (V.y * V.y + V.z * V.z) / 12.0f;
Iyy = 0.7f * mass * (V.x * V.x + V.z * V.z) / 12.0f;
Izz = 0.7f * mass * (V.x * V.x + V.y * V.y) / 12.0f;
NewtonBodySetMassMatrix (Guidon.body, mass, Ixx, Iyy, Izz);
NewtonBodySetMatrix (Guidon.body, &location._11);
PhysicsSetTransform (Guidon.body, &location._11);
}
///////////////////////////////////////////////////////////
{
NewtonCollision* collision;
D3DXMATRIX location; D3DXMatrixIdentity(&location);
//
D3DXMatrixRotationYawPitchRoll(&mat0,0,0,0);
D3DXMatrixTranslation(&mat1,0/10,-2.31f/10,0/10);
mat0*=mat1;
collision = NewtonCreateBox (nWorld, 2.34f/10,4.48f/10,1/10, &mat0._11);
Suspension.body = NewtonCreateBody (nWorld, collision);
NewtonReleaseCollision (nWorld, collision);
// * * * * * *
BODYUSERDATA* BUD=new BODYUSERDATA;
BUD->Moto=this;
BUD->notype=3;
BUD->noclass=no;
NewtonBodySetUserData (Suspension.body, BUD);
NewtonBodySetTransformCallback (Suspension.body, PhysicsSetTransform);
NewtonBodySetForceAndTorqueCallback (Suspension.body, PhysicsApplyForceAndTorque);
V=D3DXVECTOR3(2.34f/10,4.48f/10,1/10);
mass = 5;
Ixx = 0.7f * mass * (V.y * V.y + V.z * V.z) / 12.0f;
Iyy = 0.7f * mass * (V.x * V.x + V.z * V.z) / 12.0f;
Izz = 0.7f * mass * (V.x * V.x + V.y * V.y) / 12.0f;
NewtonBodySetMassMatrix (Suspension.body, mass, Ixx, Iyy, Izz);
NewtonBodySetMatrix (Suspension.body, &location._11);
PhysicsSetTransform (Suspension.body, &location._11);
}
///////////////////////////////////////////////////////////
{
NewtonCollision* collision;
D3DXMATRIX location; D3DXMatrixIdentity(&location);
//
D3DXMatrixRotationYawPitchRoll(&mat0,0,0,0);
D3DXMatrixTranslation(&mat1,0,0,0);
mat0*=mat1;
collision = NewtonCreateChamferCylinder (nWorld, 8.59f/2/10, 0.96f/10, &mat0._11);
RAvant.body = NewtonCreateBody (nWorld, collision);
NewtonReleaseCollision (nWorld, collision);
// * * * * * *
BODYUSERDATA* BUD=new BODYUSERDATA;
BUD->Moto=this;
BUD->notype=4;
BUD->noclass=no;
NewtonBodySetUserData (RAvant.body, BUD);
NewtonBodySetTransformCallback (RAvant.body, PhysicsSetTransform);
NewtonBodySetForceAndTorqueCallback (RAvant.body, PhysicsApplyForceAndTorque);
V=D3DXVECTOR3(0.96f/10,8.59f/2/10,8.59f/2/10);
mass = 5;
Ixx = 0.7f * mass * (V.y * V.y + V.z * V.z) / 12.0f;
Iyy = 0.7f * mass * (V.x * V.x + V.z * V.z) / 12.0f;
Izz = 0.7f * mass * (V.x * V.x + V.y * V.y) / 12.0f;
NewtonBodySetMassMatrix (RAvant.body, mass, Ixx, Iyy, Izz);
NewtonBodySetMatrix (RAvant.body, &location._11);
PhysicsSetTransform (RAvant.body, &location._11);
}
///////////////////////////////////////////////////////////
{
NewtonCollision* collision;
D3DXMATRIX location; D3DXMatrixIdentity(&location);
//
D3DXMatrixRotationYawPitchRoll(&mat0,0,0.17f,0);
D3DXMatrixTranslation(&mat1,0/10,-0.28f/10,2.63f/10);
mat0*=mat1;
collision = NewtonCreateBox (nWorld, 2.21f/10,1/10,6.21f/10, &mat0._11);
BrasO.body = NewtonCreateBody (nWorld, collision);
NewtonReleaseCollision (nWorld, collision);
// * * * * * *
BODYUSERDATA* BUD=new BODYUSERDATA;
BUD->Moto=this;
BUD->notype=5;
BUD->noclass=no;
NewtonBodySetUserData (BrasO.body, BUD);
NewtonBodySetTransformCallback (BrasO.body, PhysicsSetTransform);
NewtonBodySetForceAndTorqueCallback (BrasO.body, PhysicsApplyForceAndTorque);
V=D3DXVECTOR3(2.21f/10,1/10,6.21f/10);
mass = 2;
Ixx = 0.7f * mass * (V.y * V.y + V.z * V.z) / 12.0f;
Iyy = 0.7f * mass * (V.x * V.x + V.z * V.z) / 12.0f;
Izz = 0.7f * mass * (V.x * V.x + V.y * V.y) / 12.0f;
NewtonBodySetMassMatrix (BrasO.body, mass, Ixx, Iyy, Izz);
NewtonBodySetMatrix (BrasO.body, &location._11);
PhysicsSetTransform (BrasO.body, &location._11);
}
///////////////////////////////////////////////////////////
The error:
- Code: Select all
Exception non gérée à 0x7c812afb dans LandWar.exe : Exception Microsoft C++ : std::bad_alloc à l'emplacement mémoire 0x0012e36c..
(this error occurs in operator new)
Note than I use directx but it's quite the same, I didn't put all the code hopping someone of you will immediatly see a big mistake in this code in witch the error occurs.
Another thing is than I'm french then please tell me if you don't understand something I wrote, I really need help.
Thanks in advance.