Historique des modifications - Message

Message #8153

Sujet: Problème avec newton.


Type Date Auteur Contenu
Création du message 29-03-2010 16:58:39 Kit-fisto24
J'ai encore un problème, c'est quand je fais NewtonBodySetForceAndTorqueCallback(body1, ApplyForceAndTorqueEvent); dans une fonction (et donc pas dans main), cela m'affiche une erreur: error C2664: 'NewtonBodySetForceAndTorqueCallback' : impossible de convertir le paramètre 2 de 'void' en 'NewtonApplyForceAndTorque'. Alors que si j'appellerai cette fonction dans main ça marcherai.

Voici mon code:

void Physique::CreationBodyMobile(core::vector3df position, scene::ISceneManager* smgr, video::IVideoDriver* driver)
{
	// Créer le corp1 // ------------------
		NewtonBody*body1 ;
		scene::ISceneNode*cube1 = smgr->addCubeSceneNode(64);
		cube1->setPosition(core::vector3df(2124,600,1152));
		cube1->setMaterialTexture(0, driver->getTexture("metal.jpg"));
		cube1->setMaterialFlag(video::EMF_LIGHTING, false);
		// On Initialise le corp1 // ----------
		NewtonCollision* colision=  NewtonCreateBox(m_world,64,64,64,0,0);
		body1 = NewtonCreateBody(m_world,colision) ;

		// On lui assigne une matrice // -----
		core::matrix4 mat1 ;
		mat1.setTranslation(core::vector3df(position.X,position.Y,position.Z));
		NewtonBodySetMatrix(body1,mat1.pointer());
		// Configurer la mass et l'inertie //-
        float inertieX = 0.7f * 50 * (64 * 64 + 64 * 64) / 12;
        float inertieY = 0.7f * 50 * (64 * 64 + 64 * 64) / 12;
        float inertieZ = 0.7f * 50 * (64 * 64 + 64 * 64) / 12;
 
		NewtonBodySetMassMatrix(body1,50,inertieX,inertieY,inertieZ);
		// Force de gravité // -----------------
		 NewtonBodySetTransformCallback(body1, SetMeshTransformEvent);
		NewtonBodySetForceAndTorqueCallback(body1, ApplyForceAndTorqueEvent);
}


void _cdecl SetMeshTransformEvent(const NewtonBody* body, const float* matrix,int)
{
    // copy the matrix into an irrlicht matrix4
	core::matrix4 mat;
    memcpy(mat.pointer(), matrix, sizeof(float)*16);

    // Retreive the user data attached to the newton body
	scene::ISceneNode *tmp = (scene::ISceneNode *)NewtonBodyGetUserData(body);
    if (tmp)
    {
        // Position the node
        tmp->setPosition(mat.getTranslation());        // set position
        tmp->setRotation(mat.getRotationDegrees());    // and rotation
    }
}

void _cdecl ApplyForceAndTorqueEvent (const NewtonBody* body,float timestep, int threadindex)
{
   float mass;
   float Ixx;
   float Iyy;
   float Izz;
   float force[3];
   float torque[3];

   NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);

   force[0] = 0.0f;
   force[1] = -mass * 90000;
   force[2] = -mass * 90000;

   torque[0] = 0.0f;
   torque[1] = 0.0f;
   torque[2] = 0.0f;

   NewtonBodyAddForce (body, force);
   NewtonBodyAddTorque (body, torque);
}

Vous savez pourquoi ça ne marche pas quand c'est dans une autre fonction?

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
527 invités en ligne
membre en ligne: -
RSS Feed