Historique des modifications - Message

Message #9388

Sujet: Système de collisions de type RPG


Type Date Auteur Contenu
Création du message 20-01-2011 12:40:13 tmyke
en fait ce sont les callbacks qui sont passés dans les fonctions NewtonBodySetForceAndTorqueCallback et NewtonBodySetTransformCallback
et qui pourraient ressembler à cela:

Code c++ :


// set the transformation of a rigid body
void bodyPhysicsSetTransform(const NewtonBody* body, const dFloat* matrix, int threadIndex)
{
	// get the graphic object form the rigid body
	IBodySceneNode* eBody= (IBodySceneNode*) NewtonBodyGetUserData(body);
	// set the transformation matrix for this rigid body
	core::matrix4 irr_mat;
	memcpy( irr_mat.pointer() , matrix, sizeof(float)*16);

	eBody->body_mesh->setPosition(irr_mat.getTranslation());
	eBody->body_mesh->setRotation(irr_mat.getRotationDegrees());
    	// set node rotation
	eBody->body_mesh->updateAbsolutePosition();
}


et

Code c++ :


// add force and torque to rigid body
void  bodyPhysicsApplyForceAndTorque (const NewtonBody* body, dFloat timestep, int threadIndex)
{
	dFloat Ixx;
	dFloat Iyy;
	dFloat Izz;
	dFloat mass;

	NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
	core::vector3df force(0.0f, -mass * 10.0f, 0.0f);
	//FORCE
	NewtonBodySetForce(body, &total_force.X);
}

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
151 invités en ligne
membre en ligne: -
RSS Feed