convex mesh moving through triangle geometry

klarax

19-11-2009 02:26:19

Hi,

I have just setup things in my demo and the convex meshes are moving through the triangle geometry:

The code im using is:

//Setup Meshes
m_pBallsRoomMesh = NxOgre::MeshManager::getSingleton()->load("media:ballsroom.nxs");
m_pBallRoomGeometry = new NxOgre::TriangleGeometry(m_pBallsRoomMesh);
m_pScene->createSceneGeometry(m_pBallRoomGeometry, NxOgre::Matrix44(NxOgre::Vec3(0, 5, 0)));
m_pRoom = m_pSceneManager->createEntity("ballsRoom", "ballsroom.mesh");
m_pRoom->setMaterialName("ballsRoom");
m_pRoom->setQueryFlags(CANT_BE_CLICKED); // set flag to "not clickable"
m_pRoomNode = m_pSceneManager->getRootSceneNode()->createChildSceneNode("ballsRoomNode");
m_pRoomNode->attachObject(m_pRoom);
m_pRoomNode->setScale(Ogre::Vector3(2.0, 2.0, 2.0)); // scale the node and thus, the room mesh
m_pRoomNode->setPosition(Ogre::Vector3(820.0, -120.0, 270.0));

convexMesh = NxOgre::MeshManager::getSingleton()->load("media:target.nxs");
convex = new NxOgre::Convex(convexMesh);

int targetMovement = 0;
for(int i = 0 ; i < 7 ; i++)
{
m_pTargetBody[i] = m_pRenderSystem->createBody(convex, NxOgre::Vec3((900.0f - targetMovement), 0.0f, 270.0f), "target.mesh");
m_pTargetBody[i]->getEntity()->setMaterialName("target");
m_pTargetBody[i]->setGlobalOrientation(NxOgre::Matrix33(NxOgre::Real4(0, 5, 0, 0)));
targetMovement += 10;
}


The convex meshes interact with one and other, but not the triangle geometry.

I have also tried removing the scale in the triangle geometry and making it bigger inside 3d max, but still same thing happens.

Any ideas? It driving me crazy :P

Klarax

The only thing i can think of is that the

deshan

19-11-2009 03:16:53

Hi
Doesn't you need to set the m_pRoomNode position to Vec3(0, 5, 0)

m_pRoomNode->setPosition(NxOgre::Vec3(0, 5, 0));

look at this code http://www.ogre3d.org/wiki/index.php/Bl ... l_7_Source
// Create the SceneGeometry
mScene->createSceneGeometry(triangleGeometry, NxOgre::Matrix44(NxOgre::Vec3(0, 5, 0)));

// Create the Entity and Scenenode to visualize the SceneGeometry
Ogre::Entity* triangleEntity = mSceneMgr->createEntity("triangleEntity", "Stairs.mesh");
Ogre::SceneNode* triangleNode = mSceneMgr->getRootSceneNode()->createChildSceneNode();
triangleNode->attachObject(triangleEntity);
triangleNode->setPosition(Vector3(0, 5, 0));


The positions are equal

klarax

19-11-2009 05:51:18

Thanks for the reply man, but I dont think so... and after setting them to the create to the same position as the node as seen below still dont work:

//Setup Meshes
m_pBallsRoomMesh = NxOgre::MeshManager::getSingleton()->load("media:ballsroom.nxs");
m_pBallRoomGeometry = new NxOgre::TriangleGeometry(m_pBallsRoomMesh);
m_pScene->createSceneGeometry(m_pBallRoomGeometry, NxOgre::Matrix44(NxOgre::Vec3(820.0, -120.0, 270.0))); //CHANGED TO BE THE SAME AS NODE POSTION
m_pRoom = m_pSceneManager->createEntity("ballsRoom", "ballsroom.mesh");
m_pRoom->setMaterialName("ballsRoom");
//m_pRoom->setQueryFlags(CANT_BE_CLICKED); // set flag to "not clickable"
m_pRoomNode = m_pSceneManager->getRootSceneNode()->createChildSceneNode("ballsRoomNode");
m_pRoomNode->attachObject(m_pRoom);
m_pRoomNode->setScale(Ogre::Vector3(2.0, 2.0, 2.0)); // scale the node and thus, the room mesh
m_pRoomNode->setPosition(Ogre::Vector3(820.0, -120.0, 270.0));

convexMesh = NxOgre::MeshManager::getSingleton()->load("media:target.nxs");
convex = new NxOgre::Convex(convexMesh);

int targetMovement = 0;
for(int i = 0 ; i < 7 ; i++)
{
m_pTargetBody[i] = m_pRenderSystem->createBody(convex, NxOgre::Vec3((900.0f - targetMovement), 0.0f, 270.0f), "target.mesh");
m_pTargetBody[i]->getEntity()->setMaterialName("target");
m_pTargetBody[i]->setGlobalOrientation(NxOgre::Matrix33(NxOgre::Real4(0, 5, 0, 0)));
targetMovement += 10;
}


I honestly dont know why this is happening, i thought it was sometihng to do with the scale, but tested that...

klarax

19-11-2009 06:00:17

OK, so i got it working to a degree, whats happening is scaling the node makes the meh biger (obviously) but this does not scale the bounding box created using flour.

Is there a way to scale the bounding area in nxs fil, using ogre::mesh or the triangleGeometry pointer?

hope that makes sense

thanks

klarax

deshan

19-11-2009 06:08:49

Hi
Then some expert have to answer this question.

This is how I make the nxs.
I am using 3dmax.
Before export the model to 3ds, first I group the model and position it at the centre of the viewport. Thereafter export and convert it to mesh and generate nxs. Don't know whether grouping and positioning the group at the centre make an effect. You can try this for your ballsroom model until someone put the proper answer here.

EDIT: use ur modeling software to group and scale the model and regenerate the nxs. That is waht i know. Ther should be a answer with nxogre as well.