Problem with loading / converting a triangle mesh.

Deji

03-03-2009 14:31:01

So far NxOgre has been a huge step forward for our project, however I have been having problems trying to apply a trianglemesh from a loaded nxs file.
The .nxs is created with flour and stored in our models directory. Plan is to use this for a large static object in our scene. (Using NxOgre 1.0(Bleeding))

The following is part of a function to replace the default BodyShape with a triangle mesh. For example m_Robot->setNewTriangleMesh("file://../../media/models/robot.nxs","Robot")

void WorldEntity::setNewTriangleMesh(string _filelocation,string _name){
//Name the mesh ie RobotMesh
string meshName;
meshName = (_name+"Mesh");

NxOgre::Resources::ResourceSystem* rSystem = NxOgre::Resources::ResourceSystem::getSingleton();

//Add the mesh from provided file location
rSystem->addMeshAs((NxOgre::Resources::ResourceIdentifier)_filelocation,meshName);

//Get a pointer to the mesh by name and create a new TriangleMesh
NxOgre::Resources::Mesh* tempMesh = rSystem->getMesh(meshName);
NxOgre::TriangleMesh* newShape = new NxOgre::TriangleMesh(tempMesh);

//Add the new shape in place of the base shape
setNewBodyShape(newShape);
}

Just for completeness;

void WorldEntity::setNewBodyShape(NxOgre::Shape * _Shape){
//HM - need to perform actions in this order (physX gets upset if a body has no shapes)
m_Body->addShape(_Shape);
m_Body->removeShape(m_BaseShape);
m_BaseShape = _Shape;
}


It just doesn't seem to load any mesh data (I may be doing something wrong :oops: ) however I also get a couple of warnings converting the ogre mesh into a nxs. This is using flour 0.3.2. It does however produce a 5.8Kb .nxs file from the ogre Robot.

PhysX ERROR! NXE_DB_WARNING (f:/file path..../RegistryHardwareSelection.cpp:71) CUDA not available


Any comments / abuse about my code would be great at this point :mrgreen: Thanks

Deji

04-03-2009 12:03:23

Seems we may have been missing a fix to the mesh loading :oops:

Deji

04-03-2009 18:01:34

We have managed to get loading a mesh to work however we don't seem to be able to add it to the body.


NxOgre::Resources::ResourceSystem* rSystem = NxOgre::Resources::ResourceSystem::getSingleton();

//Add the mesh from provided file location
rSystem->addMeshAs(_filelocation,meshName);

//Test the mesh has loaded into the resource system.
if(rSystem->hasMesh(meshName)){
//true we have the mesh
}else{
//false we dont
MessageBox(NULL, "AAAAH MODEL DOESN'T EXIST", "error", MB_OK);
}

//Create a new triangleMesh from resource.
NxOgre::TriangleMesh* newShape = new NxOgre::TriangleMesh(meshName);

//Add the new shape in place of the base shape
m_Body->addShape(newShape);
m_Body->removeShape(m_BaseShape);
m_BaseShape= newShape;


Stepping through the code the mesh seems to load in and can be accessed through the resource system, But when using the addShape method it does not attach to the Body / Actor.
We are left with the previous shape (m_BaseShape a default cube).

Any advice would be great, thanks a lot :mrgreen:

nargil

04-03-2009 18:50:54

try

NxOgre::Mesh* meshPtr = NxOgre::Resources::ResourceSystem::getSingleton()->getMesh(meshName);
NxOgre::TriangleMesh* newShape = new NxOgre::TriangleMesh(meshPtr);

Deji

11-03-2009 11:29:15

try

NxOgre::Mesh* meshPtr = NxOgre::Resources::ResourceSystem::getSingleton()->getMesh(meshName);
NxOgre::TriangleMesh* newShape = new NxOgre::TriangleMesh(meshPtr);


Thanks for the suggestion

No luck I'm afraid it seems the methods for getting the shape work however I'm not convinced that addShape(newShape) where newShape is a trianlge mesh functions correctly.

Going to spend some time on it this morning will post again if I make any progress. Any further suggestions would be great :)

[edit]
Small update been using the physx remote debugger.


TriangleMesh is loaded into memory correctly.


However the object it is being added to remains unchanged. Looks like an issue with addShape?

Any recommendations?