Ejemplo n.º 1
0
void RigidBodyMotionSimulation::CreateObjects()
{
	RigidBodyPtr body(new RigidBody());
	body->SetMass(1);
//	Point3 newPos(0,20,30);
	Point3 newPos(0,0,-80);
	body->SetPos(newPos);

	Matrix3 inertiaTensor;
	inertiaTensor.SetBlockInertiaTensor(Vector3(1,1,1), 1);
	body->SetInertiaTensor(inertiaTensor);

	//matrix3 orientation = body->getorientation();
	//orientation.createrotationmatrixaboutxaxis(45, &orientation);
	//body->setorientation(orientation);
	
	Quaternion orientation;
	Vector3 rotationVec(1,1,1);
	orientation.RotateByVector(rotationVec);
	body->SetOrientation(orientation);
	/*
	//orientation.createrotationmatrixaboutxaxis(45, &orientation);
	//body->setorientation(orientation);
	Vector3 testVel(0,10,0);
	body->SetLinearVel(testVel);
	Vector3 testAngularVel(1.1,1.1,1.1);
	body->SetAngularVel(testAngularVel);
	*/

	body->CalculateInternals();

	body->AddForceAtBodyPoint(Vector3(0,-9,0),Point3(0,0,0));

	//body->CalculateInternals();
	m_RigidBodies.push_back(body);
}
Ejemplo n.º 2
0
void RigidBodyMotionSimulation::CreateObjects()
{
	for(int i = 0 ; i < 0 ; i++)
	{
		RigidBodyPtr body(new RigidBody());
		body->SetMass(1);
	//	Point3 newPos(0,20,30);
	
		Point3 newPos(30,10,0);
		body->SetPos(newPos);

		Matrix3 inertiaTensor;
		inertiaTensor.SetBlockInertiaTensor(Vector3(1,1,1), 1);
		body->SetInertiaTensor(inertiaTensor);

//		body->LoadModel("../../media/models/torus.obj");
		body->LoadModel("../../media/models/cube.obj");

		//matrix3 orientation = body->getorientation();
		//orientation.createrotationmatrixaboutxaxis(45, &orientation);
		//body->setorientation(orientation);
		
		Quaternion orientation;
		Vector3 rotationVec(1,1,1);
		orientation.RotateByVector(rotationVec);
		body->SetOrientation(orientation);


		body->CalculateInternals();

		//m_CollisionDetector->AddAABB(body->GetAABB());

		/*
		if(i==0)
		{
			body->AddForceAtBodyPoint(Vector3(10,10, 0),Point3(0,0,0));
		}
		else
		{
			body->AddForceAtBodyPoint(Vector3(-10,-10, 0),Point3(0,0,0));
		}
		*/
		body->AddForceAtBodyPoint(Vector3(0,-90,0),Point3(0,0,0));

		//body->CalculateInternals();
		m_RigidBodies.push_back(body);
	}

	m_Plane = new CollisionPlane();
	m_Plane->SetPoint(Point3(0,0,0));
	m_Plane->SetNormal(Vector3(0,1,0));

	m_Particle = new Particle();
	m_Particle->SetPos(Point3(0,10,1));
	m_Particle->SetVel(Vector3(0,-10,0));

	/*
	m_Triangle_0->SetPoint( Point3(1.0f,3.0f,0.0f), 0 );
	m_Triangle_0->SetPoint( Point3(2.0f,1.0f,0.0f), 1 );
	m_Triangle_0->SetPoint( Point3(2.0f,2.0f,0.0f), 2 );
	*/

	m_Triangle_0->SetPoint( Point3(0.3f,0.3f,0.0f), 0 );
	m_Triangle_0->SetPoint( Point3(1.3f,1.3f,0.0f), 1 );
	m_Triangle_0->SetPoint( Point3(2.3f,0.3f,0.0f), 2 );
	m_Triangle_0->CreateEdges();

//	m_Contact = new Contact();
}