virtual void Render(dFloat timeStep, DemoEntityManager* const scene) const { // save the model matrix before changing it Matrix glPushMatrix(); // Set The matrix for this entity Node glMultMatrix(&m_matrix[0][0]); // Render mesh if there is one for (void* proxyNode = NewtonSceneCollisionGetFirstNode(m_sceneCollision); proxyNode; proxyNode = NewtonSceneCollisionGetNextNode(m_sceneCollision, proxyNode)) { dMatrix matrix; NewtonCollision* const collision = NewtonSceneCollisionGetCollisionFromNode (m_sceneCollision, proxyNode); DemoMesh* const mesh = (DemoMesh*) NewtonCollisionGetUserData(collision); glPushMatrix(); NewtonCollisionGetMatrix (collision, &matrix[0][0]); glMultMatrix(&matrix[0][0]); mesh->Render(scene); glPopMatrix(); } // restore the matrix before leaving glPopMatrix(); }
static NewtonBody* CreatePlaneCollision (DemoEntityManager* const scene, const dVector& planeEquation) { NewtonCollision* const planeCollision = CreateInfinitePlane (scene->GetNewton(), planeEquation); // create the the rigid body for dMatrix matrix (dGetIdentityMatrix()); NewtonBody* const body = NewtonCreateDynamicBody(scene->GetNewton(), planeCollision, &matrix[0][0]); // create a visual mesh DemoMesh* const mesh = CreateVisualPlaneMesh (planeEquation, scene); DemoEntity* const entity = new DemoEntity(matrix, NULL); NewtonCollisionGetMatrix(planeCollision, &matrix[0][0]); scene->Append (entity); entity->SetMesh(mesh, matrix); mesh->Release(); // save the pointer to the graphic object with the body. NewtonBodySetUserData (body, entity); // destroy the collision shape NewtonDestroyCollision (planeCollision); return body; }