Exemplo n.º 1
0
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	NewtonBody* floorBody;
	NewtonCollision* shape;

	// initialize the camera
	InitCamera (dVector (-15.0f, 5.0f, 0.0f, 0.0f), dVector (1.0f, 0.0f, 0.0f));

	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();
	floor->LoadMesh ("FloorBox.dat");

	// add static floor Physics
	shape = CreateNewtonBox (world, floor, 0);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonDestroyCollision(shape);

	// set the Transformation Matrix for this rigid body
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);


	// find the floor base, and add some distance up;
	dFloat floorY = FindFloor (world, 0.0f, 0.0f) + 2.0f;

	// this is the width of the Box;
	dFloat boxWidth = 0.42f;

	// Make a small pyramid of Boxes
	for (int i = 0; i < PYRAMID_BASE + 1; i ++) {
		for (int j = 0; j < PYRAMID_BASE - i; j ++) {
			Entity* smilly;
			NewtonBody* smillyBody;

			// crate a visual Box and place in a pyramid formation above the floor
			smilly = sceneManager->CreateEntity();
			smilly->LoadMesh ("Smilly.dat");
			smilly->m_curPosition.m_x = 0.0f;
			smilly->m_curPosition.m_z = dFloat (j) * boxWidth + dFloat (i) * (boxWidth * 0.5f);
			smilly->m_curPosition.m_y = floorY + dFloat (i) * boxWidth;
			smilly->m_prevPosition = smilly->m_curPosition;

			// add a body with a box shape
			shape = CreateNewtonBox (world, smilly, 0);
			smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
			NewtonDestroyCollision(shape);

			// we want some nice object placement, with zero penetration and and zero jitter
			// therefore we are going use use a Convex Cast function to snap the Box to the closest contact surface
			ConvexCastPlacement (smillyBody);
		}
	}
}
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	NewtonCollision* shape;
	NewtonBody* floorBody;
	void* materialManager;
	SoundManager* sndManager;
	PhysicsMaterialInteration matInterations;
	
	sndManager = sceneManager->GetSoundManager();

	// Create the material for this scene, and attach it to the Newton World
	materialManager = CreateMaterialManager (world, sndManager);

	// add the Material table
	matInterations.m_restitution = 0.6f;
	matInterations.m_staticFriction = 0.6f;
	matInterations.m_kineticFriction = 0.3f;
	matInterations.m_scrapingSound = NULL;

	matInterations.m_impactSound = sndManager->LoadSound ("metalMetal.wav");
	AddMaterilInteraction (materialManager, m_metal, m_metal, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("boxBox.wav");
	AddMaterilInteraction (materialManager, m_wood, m_wood, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("metalBox.wav");
	AddMaterilInteraction (materialManager, m_metal, m_wood, &matInterations);
	
	matInterations.m_impactSound = sndManager->LoadSound ("grass0.wav");
	AddMaterilInteraction (materialManager, m_wood, m_grass, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("boxHit.wav");
	AddMaterilInteraction (materialManager, m_wood, m_bricks, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("grass1.wav");
	AddMaterilInteraction (materialManager, m_metal, m_grass, &matInterations);
	AddMaterilInteraction (materialManager, m_grass, m_bricks, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("metal.wav");
	AddMaterilInteraction (materialManager, m_metal, m_bricks, &matInterations);
	AddMaterilInteraction (materialManager, m_grass, m_grass, &matInterations);
	
	

	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();
	floor->LoadMesh ("LevelMesh.dat");

	// add static floor Physics
	int materialMap[] = {m_bricks, m_grass, m_wood,	m_metal};
	shape = CreateMeshCollision (world, floor, materialMap);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonReleaseCollision (world, shape);


	// set the Transformation Matrix for this rigid body
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);

	// now we will use the properties of this body to set a proper world size.
	dVector minBox;
	dVector maxBox;
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &minBox[0], &maxBox[0]);

	// add some extra padding
	minBox.m_x -=  50.0f;
	minBox.m_y -= 500.0f;
	minBox.m_z -=  50.0f;

	maxBox.m_x +=  50.0f;
	maxBox.m_y += 500.0f;
	maxBox.m_z +=  50.0f;

	// set the new world size
	NewtonSetWorldSize (world, &minBox[0], &maxBox[0]);

	// add some visual entities.
	dFloat y0 = FindFloor (world, 0.0f, 0.0f) + 10.0f;
	for (int i = 0; i < 5; i ++) {
		Entity* smilly;
		NewtonBody* smillyBody;
		smilly = sceneManager->CreateEntity();
		smilly->LoadMesh ("Smilly.dat");
		smilly->m_curPosition.m_y = y0;
		y0 += 2.0f;
		smilly->m_prevPosition = smilly->m_curPosition;

		// add a body with a box shape
		shape = CreateNewtonBox (world, smilly, m_metal);
		smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
		NewtonReleaseCollision (world, shape);
	}

	// add some visual entities.
	y0 = FindFloor (world, 0.0f, 0.4f) + 10.5f;
	for (int i = 0; i < 5; i ++) {
		Entity* frowny;
		NewtonBody* frownyBody;
		frowny = sceneManager->CreateEntity();
		frowny->LoadMesh ("Frowny.dat");
		frowny->m_curPosition.m_z = 0.4f;
		frowny->m_curPosition.m_y = y0;
		y0 += 2.0f;
		frowny->m_prevPosition = frowny->m_curPosition;

		// add a body with a Convex hull shape
		shape = CreateNewtonConvex (world, frowny, m_wood);
		frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
		NewtonReleaseCollision (world, shape);
	}

	y0 = FindFloor (world, 0.0f, 2.0f) + 10.5f;
	for (int i = 0; i < 5; i ++) {
		Entity* frowny;
		NewtonBody* frownyBody;

		frowny = sceneManager->CreateEntity();
		frowny->LoadMesh ("dumb.dat");
		frowny->m_curPosition.m_z = 2.0f;
		frowny->m_curPosition.m_y = y0;
		y0 += 2.0f;
		frowny->m_prevPosition = frowny->m_curPosition;

		// add a body with a Convex hull shape
		int materialMap[] = {m_grass, m_wood, m_metal, m_metal};
		shape = CreateNewtonCompoundFromEntitySubmesh (world, frowny, materialMap);
		frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
		NewtonReleaseCollision (world, shape);
	}


	// set the Camera EyePoint close to the scene action
	InitCamera (dVector (-15.0f, FindFloor (world, -15.0f, 0.0f) + 5.0f, 0.0f), dVector (1.0f, 0.0f, 0.0f));
}
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	Entity* smilly;
	Entity* frowny;
	NewtonBody* floorBody;
	NewtonBody* smillyBody;
	NewtonBody* frownyBody;
	NewtonCollision* shape;

	// Create the material for this scene
	CreateMateials (world, sceneManager);

	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();

	// add scene collision from a level mesh
	shape = CreateHeightFieldCollision (world, "h2.raw", 0);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonReleaseCollision (world, shape);

	// make a visual mesh for the collision data
	CreateHeightFieldMesh (shape, floor);

	// set the matrix at the origin
	dVector boxP0; 
	dVector boxP1; 
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); 

	// place the origin of the visual mesh at the center of the height field
	matrix.m_posit = (boxP0 + boxP1).Scale (-0.5f);
	matrix.m_posit.m_w = 1.0f;
	floor->m_curPosition = matrix.m_posit;
	floor->m_prevPosition = matrix.m_posit;

	// relocate the body;
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);

	// now we will use the properties of this body to set a proper world size.
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); 

	// add some extra padding
	boxP0.m_x -=  50.0f;
	boxP0.m_y -= 500.0f;
	boxP0.m_z -=  50.0f;

	boxP1.m_x +=  50.0f;
	boxP1.m_y += 500.0f;
	boxP1.m_z +=  50.0f;

	// set the new world size
	NewtonSetWorldSize (world, &boxP0[0], &boxP1[0]);


	// assign an Material ID to this body
	NewtonBodySetMaterialGroupID (floorBody, g_floorMaterial);


	// add some visual entities.
	dFloat y0 = FindFloor (world, 0.0f, 0.0f) + 10.0f;
	for (int i = 0; i < 5; i ++) {
		smilly = sceneManager->CreateEntity();
		smilly->LoadMesh ("Smilly.dat");
		smilly->m_curPosition.m_y = y0;
		y0 += 2.0f;
		smilly->m_prevPosition = smilly->m_curPosition;

		// add a body with a box shape
		shape = CreateNewtonBox (world, smilly, 0);
		smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
		NewtonReleaseCollision (world, shape);

		// assign an Material ID to this body
		NewtonBodySetMaterialGroupID (smillyBody, g_metalMaterial);
	}


	// add some visual entities.
	y0 = FindFloor (world, 0.0f, 0.4f) + 10.5f;
	for (int i = 0; i < 5; i ++) {
		frowny = sceneManager->CreateEntity();
		frowny->LoadMesh ("Frowny.dat");
		frowny->m_curPosition.m_z = 0.4f;
		frowny->m_curPosition.m_y = y0;
		y0 += 2.0f;
		frowny->m_prevPosition = frowny->m_curPosition;

		// add a body with a Convex hull shape
		shape = CreateNewtonConvex (world, frowny, 0);
		frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
		NewtonReleaseCollision (world, shape);

		// assign an Material ID to this body
		NewtonBodySetMaterialGroupID (frownyBody, g_woodMaterial);
	}

	// set the Camera EyePoint close to the scene action
	InitCamera (dVector (-15.0f, FindFloor (world, -15.0f, 0.0f) + 5.0f, 0.0f), dVector (1.0f, 0.0f, 0.0f));
}
Exemplo n.º 4
0
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	Entity* smilly;
	Entity* frowny;
	NewtonBody* floorBody;
	NewtonBody* smillyBody;
	NewtonBody* frownyBody;
	NewtonCollision* shape;



////////////////////////////////////////////////////////////////////////////////
// STATIC BODY 1 - FLOOR 
////////////////////////////////////////////////////////////////////////////////

	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();
	floor->LoadMesh ("FloorBox.dat");
 
	// add static floor Physics
	shape = CreateNewtonBox (world, floor, 0);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonReleaseCollision (world, shape);
 
	// set the Transformation Matrix for this rigid body
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);
 
	// now we will use the properties of this body to set a proper world size.
	dVector minBox;
	dVector maxBox;
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &minBox[0], &maxBox[0]);
 
	// add some extra padding
	minBox.m_x -=  50.0f;
	minBox.m_y -= 500.0f;
	minBox.m_z -=  50.0f;
 
	maxBox.m_x +=  50.0f;
	maxBox.m_y += 500.0f;
	maxBox.m_z +=  50.0f;
 
	// set the new world size
	NewtonSetWorldSize (world, &minBox[0], &maxBox[0]);


////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////




 
////////////////////////////////////////////////////////////////////////////////
// DYNAMIC BODY 1
////////////////////////////////////////////////////////////////////////////////
 
	// add some visual entities.
	smilly = sceneManager->CreateEntity();
	smilly->LoadMesh ("Smilly.dat");
	smilly->m_curPosition.m_y = 10.0f;
	smilly->m_prevPosition = smilly->m_curPosition;
 
	// add a body with a box shape
	shape = CreateNewtonBox (world, smilly, 0);
	smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
	NewtonReleaseCollision (world, shape);
 
 
////////////////////////////////////////////////////////////////////////////////
// DYNAMIC BODY 2
////////////////////////////////////////////////////////////////////////////////
 
	// add some visual entities.
	frowny = sceneManager->CreateEntity();
	frowny->LoadMesh ("Frowny.dat");
	frowny->m_curPosition.m_z = 0.4f;
	frowny->m_curPosition.m_y = 10.0f + 0.4f;
	frowny->m_prevPosition = frowny->m_curPosition;
 
	// add a body with a Convex hull shape
	shape = CreateNewtonConvex (world, frowny, 0);
	frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
	NewtonReleaseCollision (world, shape);
}
Exemplo n.º 5
0
The second part uses the bounding Box of the collision mesh to set the final size of the physics world. This is also an important step because in the Newton world the size of the world is finite. The consequence of not doing this is that when a body move to a position the is outside the default world size the physics silently stop working on that body.


The final line of function CreateScene, just repeat the same process of adding more physics bodies to the scene

*/

	// add some visual entities.
	smilly = sceneManager->CreateEntity();
	smilly->LoadMesh ("Smilly.dat");
	smilly->m_curPosition.m_y = 10.0f;
	smilly->m_prevPosition = smilly->m_curPosition;
 
	// add a body with a box shape
	shape = CreateNewtonBox (world, smilly, 0);
	smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
	NewtonReleaseCollision (world, shape);
 
 
	// add some visual entities.
	frowny = sceneManager->CreateEntity();
	frowny->LoadMesh ("Frowny.dat");
	frowny->m_curPosition.m_z = 0.4f;
	frowny->m_curPosition.m_y = 10.0f + 0.4f;
	frowny->m_prevPosition = frowny->m_curPosition;
 
	// add a body with a Convex hull shape
	shape = CreateNewtonConvex (world, frowny, 0);
	frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
	NewtonReleaseCollision (world, shape);
Exemplo n.º 6
0
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	NewtonBody* floorBody;
	NewtonCollision* shape;
	void* materialManager;
	SoundManager* sndManager;
	PhysicsMaterialInteration matInterations;

	sndManager = sceneManager->GetSoundManager();

	// Create the material for this scene, and attach it to the Newton World
	materialManager = CreateMaterialManager (world, sndManager);

	// add the Material table
	matInterations.m_restitution = 0.6f;
	matInterations.m_staticFriction = 0.6f;
	matInterations.m_kineticFriction = 0.3f;
	matInterations.m_scrapingSound = NULL;

	matInterations.m_impactSound = sndManager->LoadSound ("metalMetal.wav");
	AddMaterilInteraction (materialManager, m_metal, m_metal, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("boxBox.wav");
	AddMaterilInteraction (materialManager, m_wood, m_wood, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("metalBox.wav");
	AddMaterilInteraction (materialManager, m_metal, m_wood, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("grass0.wav");
	AddMaterilInteraction (materialManager, m_wood, m_grass, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("boxHit.wav");
	AddMaterilInteraction (materialManager, m_wood, m_bricks, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("grass1.wav");
	AddMaterilInteraction (materialManager, m_metal, m_grass, &matInterations);

	matInterations.m_impactSound = sndManager->LoadSound ("metal.wav");
	AddMaterilInteraction (materialManager, m_metal, m_bricks, &matInterations);


	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();

	// add scene collision from a level mesh
	int materialMap[] = {m_bricks, m_grass, m_wood,	m_metal};
	shape = CreateHeightFieldCollision (world, "h2.raw", materialMap);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonDestroyCollision(shape);

	// make a visual mesh for the collision data
	CreateHeightFieldMesh (shape, floor);

	// set the matrix at the origin
	dVector boxP0; 
	dVector boxP1; 
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); 

	// place the origin of the visual mesh at the center of the height field
	matrix.m_posit = (boxP0 + boxP1).Scale (-0.5f);
	matrix.m_posit.m_w = 1.0f;
	floor->m_curPosition = matrix.m_posit;
	floor->m_prevPosition = matrix.m_posit;

	// relocate the body;
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);

	// now we will use the properties of this body to set a proper world size.
	NewtonCollisionCalculateAABB (shape, &matrix[0][0], &boxP0.m_x, &boxP1.m_x); 

	// add some extra padding
	boxP0.m_x -=  50.0f;
	boxP0.m_y -= 500.0f;
	boxP0.m_z -=  50.0f;

	boxP1.m_x +=  50.0f;
	boxP1.m_y += 500.0f;
	boxP1.m_z +=  50.0f;

	// set the new world size
	NewtonSetWorldSize (world, &boxP0[0], &boxP1[0]);


	// add some visual entities.
	dFloat y0 = FindFloor (world, 0.0f, 0.0f) + 2.0f;
	for (int i = 0; i < 1; i ++) {
		Entity* carEnt;
		NewtonBody* carBody;
		NewtonUserJoint* carController;

		carEnt = sceneManager->CreateEntity();
		carEnt->LoadMesh ("porche.dat");
		carEnt->m_curPosition.m_y = y0;
		y0 += 2.0f;
		carEnt->m_prevPosition = carEnt->m_curPosition;

		// add a body with a box shape
		shape = CreateNewtonBox (world, carEnt, m_metal);
		// the mass is the Car weight divide by the Gravity 
		carBody = CreateRigidBody (world, carEnt, shape, CAR_WEIGHT / 10.0f);
		NewtonDestroyCollision(shape);

		// Now create a RayCast Car for to control this body
		carController = CreateRayCastCast (carBody, sceneManager, porcheTirePositions);
	}


	y0 = FindFloor (world, 4.0f, 0.0f) + 2.0f;
	for (int i = 0; i < 1; i ++) {
		Entity* carEnt;
		NewtonBody* carBody;
		NewtonUserJoint* carController;

		carEnt = sceneManager->CreateEntity();
		carEnt->LoadMesh ("cadillac.dat");
		carEnt->m_curPosition.m_z = 4.0f;
		carEnt->m_curPosition.m_y = y0;
		y0 += 2.0f;
		carEnt->m_prevPosition = carEnt->m_curPosition;

		// add a body with a box shape
		shape = CreateNewtonBox (world, carEnt, m_metal);
		// the mass is the Car weight divide by the Gravity 
		carBody = CreateRigidBody (world, carEnt, shape, CAR_WEIGHT / 10.0f);
		NewtonDestroyCollision(shape);

		// Now create a RayCast Car for to control this body
		carController = CreateRayCastCast (carBody, sceneManager, cadillackirePositions);
	}

	// initialize the camera
	InitCamera (dVector (-15.0f, FindFloor (world, -15.0f, 0.0f) + 5.0f, 0.0f), dVector (1.0f, 0.0f, 0.0f));
}
Exemplo n.º 7
0
void CreateScene (NewtonWorld* world, SceneManager* sceneManager)
{
	Entity* floor;
	Entity* smilly;
	Entity* frowny;
	NewtonBody* floorBody;
	NewtonBody* smillyBody;
	NewtonBody* frownyBody;
	NewtonCollision* shape;

	// initialize the camera
	InitCamera (dVector (-15.0f, 5.0f, 0.0f, 0.0f), dVector (1.0f, 0.0f, 0.0f));


	// Create a large body to be the floor
	floor = sceneManager->CreateEntity();
	floor->LoadMesh ("FloorBox.dat");

	// add static floor Physics
	shape = CreateNewtonBox (world, floor, 0);
	floorBody = CreateRigidBody (world, floor, shape, 0.0f);
	NewtonDestroyCollision(shape);

	// set the Transformation Matrix for this rigid body
	dMatrix matrix (floor->m_curRotation, floor->m_curPosition);
	NewtonBodySetMatrix (floorBody, &matrix[0][0]);

	// add some visual entities.
	smilly = sceneManager->CreateEntity();
	smilly->LoadMesh ("Smilly.dat");
	smilly->m_curPosition.m_y = 10.0f;
	smilly->m_prevPosition = smilly->m_curPosition;

	// add a body with a box shape
	shape = CreateNewtonBox (world, smilly, 0);
	smillyBody = CreateRigidBody (world, smilly, shape, 10.0f);
	NewtonDestroyCollision(shape);


	// add some visual entities.
	frowny = sceneManager->CreateEntity();
	frowny->LoadMesh ("Frowny.dat");
	frowny->m_curPosition.m_z = 0.4f;
	frowny->m_curPosition.m_y = 10.0f + 0.4f;
	frowny->m_prevPosition = frowny->m_curPosition;

	// add a body with a Convex hull shape
	shape = CreateNewtonConvex (world, frowny, 0);
	frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
	NewtonDestroyCollision(shape);

	
	// we will Link the Frowny Body to the world with Hinge regenerated from a Generic 6DOF joint.
	 matrix = GetIdentityMatrix();
	 matrix.m_posit = frowny->m_curPosition;
	 matrix.m_posit.m_z += 0.2f;
	 matrix.m_posit.m_y += 0.4f;

	 // specify the limits for defining a Hinge around the x axis
	 dVector minLinearLimits (0.0f, 0.0f, 0.0f, 0.0f);
	 dVector maxLinearLimits (0.0f, 0.0f, 0.0f, 0.0f);

	 dVector minAngulaLimits (-0.5f * 3.1416f, 0.0f, 0.0f, 0.0f);
	 dVector maxAngulaLimits ( 0.5f * 3.1416f, 0.0f, 0.0f, 0.0f);

	 NewtonUserJoint* frownyHinge;
	 // Create a 6DOF joint 
	 frownyHinge = CreateCustomJoint6DOF (&matrix[0][0], &matrix[0][0], frownyBody, NULL);

	 // set the hinge Limits
 	 CustomJoint6DOF_SetLinearLimits (frownyHinge, &minLinearLimits[0], &maxLinearLimits[0]);
 	 CustomJoint6DOF_SetAngularLimits (frownyHinge, &minAngulaLimits[0], &maxAngulaLimits[0]);

	
	// now we will link the body of Smilly and Frowny with a specialize Hinge Joint 
	 NewtonUserJoint* smillyFrownyHinge;
	 matrix.m_posit = smilly->m_curPosition;
	 matrix.m_posit.m_z += 0.2f;
	 matrix.m_posit.m_y += 0.4f;

	 smillyFrownyHinge = CreateCustomHinge (&matrix[0][0], smillyBody, frownyBody);
	 HingeEnableLimits (smillyFrownyHinge, 1);
	 HingeSetLimits (smillyFrownyHinge, -0.5f * 3.1416f, 0.5f * 3.1416f);

//	 smillyFrownyHinge = CreateCustomBallAndSocket (&matrix[0][0], smillyBody, frownyBody);
//	 BallAndSocketSetConeAngle (smillyFrownyHinge, 0.5f * 3.1416f);
//	 BallAndSocketSetTwistAngle (smillyFrownyHinge, -0.5f * 3.1416f, 0.5f * 3.1416f);

//	 smillyFrownyHinge = CreateCustomSlider (&matrix[0][0], smillyBody, frownyBody);
//	 SliderEnableLimits (smillyFrownyHinge, 1);
//	 SliderSetLimis (smillyFrownyHinge, -0.5f * 3.1416f, 0.5f * 3.1416f);

	 {
		// adding two Kinematic controlled object
		frowny = sceneManager->CreateEntity();
		frowny->LoadMesh ("Frowny.dat");
		frowny->m_curPosition.m_z = 4.0f;
		frowny->m_curPosition.m_y = 7.0f;
		frowny->m_prevPosition = frowny->m_curPosition;
		shape = CreateNewtonConvex (world, frowny, 0);
		frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
		NewtonDestroyCollision(shape);
		 
		 
		FollowPath* path;
		NewtonUserJoint* g_pathFollow;

		path = (FollowPath*) malloc (sizeof (FollowPath));

		NewtonBodyGetMatrix (frownyBody, &matrix[0][0]);
		path->m_origin = matrix.m_posit;
		path->m_angle = 0.0f;
		path->radius = 3.0f;

		g_pathFollow = CreateCustomKinematicController (frownyBody, &matrix.m_posit[0]);
		CustomKinematicControllerSetPickMode (g_pathFollow, 1);
		CustomKinematicControllerSetMaxAngularFriction (g_pathFollow, 200.0f);
		CustomKinematicControllerSetMaxLinearFriction (g_pathFollow, 1000.0f);
		CustomSetUserData(g_pathFollow, path);
		CustomSetDestructorCallback(g_pathFollow, FollowPath::Destroy);
		CustomSetSubmitContraintCallback (g_pathFollow, FollowPath::EvaluatePath);

		matrix = path->BuildMatrix (0.0f);
		NewtonBodySetMatrix(frownyBody, &matrix[0][0]);
	 }

	 {
		// adding two Kinematic controlled object
		frowny = sceneManager->CreateEntity();
		frowny->LoadMesh ("Frowny.dat");
		frowny->m_curPosition.m_z = -4.0f;
		frowny->m_curPosition.m_y =  6.0f;
		frowny->m_prevPosition = frowny->m_curPosition;
		shape = CreateNewtonConvex (world, frowny, 0);
		frownyBody = CreateRigidBody (world, frowny, shape, 10.0f);
		NewtonDestroyCollision(shape);


		FollowPath* path;
		NewtonUserJoint* g_pathFollow;

		path = (FollowPath*) malloc (sizeof (FollowPath));

		NewtonBodyGetMatrix (frownyBody, &matrix[0][0]);
		path->m_origin = matrix.m_posit;
		path->m_angle = 3.1416f;
		path->radius = 3.0f;

		g_pathFollow = CreateCustomKinematicController (frownyBody, &matrix.m_posit[0]);
		CustomKinematicControllerSetPickMode (g_pathFollow, 1);
		CustomKinematicControllerSetMaxAngularFriction (g_pathFollow, 200.0f);
		CustomKinematicControllerSetMaxLinearFriction (g_pathFollow, 1000.0f);
		CustomSetUserData(g_pathFollow, path);
		CustomSetDestructorCallback(g_pathFollow, FollowPath::Destroy);
		CustomSetSubmitContraintCallback (g_pathFollow, FollowPath::EvaluatePath);

		matrix = path->BuildMatrix (0.0f);
		NewtonBodySetMatrix(frownyBody, &matrix[0][0]);
	 }
}