コード例 #1
0
static void DebugShowBodyCollision (const NewtonBody* const body, DEBUG_DRAW_MODE mode)
{
	switch (NewtonBodyGetType(body)) 
	{
		case NEWTON_DYNAMIC_BODY:
		{
			int sleepState = NewtonBodyGetSleepState(body);
			if (sleepState == 1) {
				// indicate when body is sleeping 
				glColor3f(0.42f, 0.73f, 0.98f);
			} else {
				// body is active
				glColor3f(1.0f, 1.0f, 1.0f);
			}
			break;
		}

		case NEWTON_KINEMATIC_BODY:
			glColor3f(1.0f, 1.0f, 0.0f);
			break;

		case NEWTON_DEFORMABLE_BODY:
			glColor3f (0.0f, 1.0f, 1.0f);
			break;
	}
	dMatrix matrix;
	NewtonBodyGetMatrix(body, &matrix[0][0]);



	NewtonCollisionForEachPolygonDo (NewtonBodyGetCollision(body), &matrix[0][0], DebugShowGeometryCollision, (void*) mode);
}
コード例 #2
0
	virtual void SimulationPreListener(DemoEntityManager* const scene, DemoEntityManager::dListNode* const mynode, dFloat timestep)
	{
//		UpdateStuff(scene);
		int sleepState = NewtonBodyGetSleepState(m_puckBody);
		if (sleepState)
		{
			LaunchPuck();
		}
	}
コード例 #3
0
CustomKinematicController::CustomKinematicController(NewtonBody* const body, const dVector& handleInGlobalSpace)
	:CustomJoint(6, body, NULL)
{
	dMatrix matrix;

	// get the initial position and orientation
	NewtonBodyGetMatrix (body, &matrix[0][0]);

	m_autoSlepState = NewtonBodyGetSleepState (body);
	NewtonBodySetAutoSleep (body, 0);

	m_localHandle = matrix.UntransformVector (handleInGlobalSpace);
	matrix.m_posit = handleInGlobalSpace;

	SetPickMode (1);
	SetTargetMatrix (matrix);
	SetMaxLinearFriction(1.0f); 
	SetMaxAngularFriction(1.0f); 
}
コード例 #4
0
ファイル: EffectsGame.cpp プロジェクト: rein4ce/VoidEngine
void CarBoxCallback(const NewtonBody* body, float timestep, int threadIndex)
{
	float mass, ix, iy, iz;

	NewtonBodyGetMassMatrix(body, &mass, &ix, &iy, &iz);
	Vector4 gravityForce = Vector4(0.0f, mass * GRAVITY, 0.0f, 1.0f);

	// set gravity as a force
	//NewtonBodySetForce(body, (float*)&gravityForce);

	CMesh *object = (CMesh*)NewtonBodyGetUserData(body);
	Vector3 force;

	if (Keydown('w')) force = object->forward;
	if (Keydown('s')) force = -object->forward;

	//if (Keydown('a')) force -= object->right;
	//if (Keydown('d')) force += object->right;

	force *= cv_speed.GetFloat();	// speed

	//force.y = GRAVITY;
	force *= mass;

	
	/*float f[3];
	NewtonBodyGetForce(body, &f[0]);
	Debug("BODY:     %f %f %f", f[0], f[1], f[2]);
	
	Debug("FORCE:    %f %f %f", force.x, force.y, force.z);
*/
	NewtonBodySetForce(body, &force[0]);	
	//NewtonBodyAddImpulse(body, &force[0], &object->GetWorldPosition()[0]);
	//NewtonBodySetVelocity(body, &force[0]);

	float torqueForce = cv_rspeed.GetFloat();
	Vector3 torque;
	if (Keydown('a')) torque.y -= torqueForce;
	if (Keydown('d')) torque.y += torqueForce;

	// Damping has no effect at all
/*	static float damp = 0.5f;
	if (KeyPressed('p')) damp += 0.1f;
	if (KeyPressed('o')) damp -= 0.1f;
	Vector3 damping = Vector3(damp,damp,damp);
	damping *= damp;
	NewtonBodySetAngularDamping(body, &damping[0]);
	*/

	
	
	NewtonBodySetOmega(body, &torque[0]);
	
	//torque *= mass;	
	//NewtonBodyAddTorque(body, &torque[0]);

	
	int sleep = NewtonBodyGetSleepState(body);
	object->color = sleep == 1 ? GREEN : RED;

	//Vector3 speed;
	//NewtonBodyGetVelocity(body, &speed[0]);
}
コード例 #5
0
ファイル: PhysObject.cpp プロジェクト: BigFax/NazaraEngine
bool NzPhysObject::IsSleeping() const
{
	return NewtonBodyGetSleepState(m_body) != 0;
}
コード例 #6
0
bool dNewtonBody::GetSleepState() const
{
	return NewtonBodyGetSleepState(m_body) ? true : false;
}