Google

Mesh Question

Discussion related to the PhysX OGRE binding.

Moderators: OGRE Team, NxOgre Moderators

Mesh Question

Postby mrtm3050 » Sat Mar 03, 2012 10:14 pm

Hi All,

I have a mesh that is quite large. It's on the order of 200,000 vertices. I was wondering if it's possible to load this in with the Manual Mesh NxOgre functionality.

I have read through various forums that say there is a triangle limit. This mesh would be static scene geometry that acts as a "terrain" but needs to be created dynamically in the program (so I don't load anything from a file).

Thanks
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Sat Mar 03, 2012 11:45 pm

Hey All,

This is the code segment I tried to no avail:

Code: Select all

   Ogre::Entity* myMesh = mSceneMgr->createEntity("myMesh", "myMesh.mesh");
   Ogre::SceneNode* sceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0));
   sceneNode->attachObject(myMesh);
   
   NxOgre::MeshData* mesh_data = Critter::MeshFunctions::read(myMesh->getMesh());
   mesh_data->mType = NxOgre::Enums::MeshType_Triangle;
   mesh_data->cook("file://my_mesh.nxs");
   delete mesh_data;

   NxOgre::Mesh *mesh = NxOgre::MeshManager::getSingleton()->load("file://my_mesh.nxs", "myMesh");
   mScene->createSceneGeometry(NxOgre::TriangleGeometryDescription(mesh), NxOgre::Vec3::ZERO);



The mesh that I am loading is one that I would be created dynamically. MyMesh was just one I am testing (200,000 vertices).

This is the error I get: "Resource is not a PhysX NXS or NxOgre X mesh file."
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Sat Mar 03, 2012 11:46 pm

Hey All,

This is the code segment I tried to no avail:

Code: Select all

   Ogre::Entity* myMesh = mSceneMgr->createEntity("myMesh", "myMesh.mesh");
   Ogre::SceneNode* sceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0));
   sceneNode->attachObject(myMesh);
   
   NxOgre::MeshData* mesh_data = Critter::MeshFunctions::read(myMesh->getMesh());
   mesh_data->mType = NxOgre::Enums::MeshType_Triangle;
   mesh_data->cook("file://my_mesh.nxs");
   delete mesh_data;

   NxOgre::Mesh *mesh = NxOgre::MeshManager::getSingleton()->load("file://my_mesh.nxs", "myMesh");
   mScene->createSceneGeometry(NxOgre::TriangleGeometryDescription(mesh), NxOgre::Vec3::ZERO);



The mesh that I am loading is one that I would be created dynamically. MyMesh was just one I am testing (200,000 vertices).

This is the error I get: "Resource is not a PhysX NXS or NxOgre X mesh file."
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Sat Mar 03, 2012 11:48 pm

This is the code I tried:

Ogre::Entity* myMesh = mSceneMgr->createEntity("myMesh", "myMesh.mesh");
Ogre::SceneNode* sceneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,0,0));
sceneNode->attachObject(myMesh);

NxOgre::MeshData* mesh_data = Critter::MeshFunctions::read(myMesh->getMesh());
mesh_data->mType = NxOgre::Enums::MeshType_Triangle;
mesh_data->cook("file://my_mesh.nxs");
delete mesh_data;

NxOgre::Mesh *mesh = NxOgre::MeshManager::getSingleton()->load("file://my_mesh.nxs", "myMesh");
mScene->createSceneGeometry(NxOgre::TriangleGeometryDescription(mesh), NxOgre::Vec3::ZERO);

This is the error I am getting: "Resource is not a PhysX NXS or NxOgre X mesh file."

I am loading in a mesh that I would normally create dynamically, on the order of 200,000 vertices.

Thanks for any help.
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Sun Mar 04, 2012 12:02 am

Trying this segment of code, where I create a manualMesh also gives me an error on manualMesh.end();:

size_t vertex_count, index_count;
Ogre::Vector3 *vertices;
unsigned* indices;
GetMeshInformation(myMesh->getMesh().getPointer(), vertex_count, vertices, index_count, indices);
NxOgre::ManualMesh manualMesh;
manualMesh.begin(NxOgre::Enums::MeshType_Triangle, vertex_count, index_count);
for(unsigned int i = 0; i < vertex_count; ++i)
{
manualMesh.vertex(vertices[i].x, vertices[i].y, vertices[i].z);
}
for(unsigned int i = 0; i < index_count; ++i)
{
manualMesh.index(indices[i]);
}
delete[] vertices;
delete[] indices;
NxOgre::Mesh *mesh = manualMesh.end();

Just wanted to correctly assume that this is an issue the number of meshes.
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Tue Mar 06, 2012 12:37 am

Anyone have any thoughts on this issue? I would just like to know if it's size issue and if so, what is the limit on the number of vertices and triangles?
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby betajaen » Tue Mar 06, 2012 8:55 pm

The only thing I can think of, if it doesn't work. Is to check to see if ManualMesh has 16-bit vertices on (which limits the vertex count to ~32k).
User avatar
betajaen
Old One
 
Posts: 6002
Kudos: 24
Joined: 08 Mar 2006
Location: Wales, UK

Re: Mesh Question

Postby mrtm3050 » Wed Mar 07, 2012 1:01 am

Hey betajaen,

Were you referring to this:

# define NxOgreSixteenBytesRestriction(CLASS) extern char NxOgreCompileAssert[size_t(sizeof(CLASS) == 16? 1 : -1)];
# define NxOgreFourBytesRestriction(CLASS) extern char NxOgreCompileAssert[size_t(sizeof(CLASS) == 4? 1 : -1)];

in NxOgreStable.h. I coudn't find it in the ManualMesh headers.

I tried to comment the lines out, and played with adding in additional defines. How would I go about turning off the 16 check.

Thanks a lot for your help.
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby mrtm3050 » Wed Mar 07, 2012 2:08 am

Just running some experiments, it looks like the maximum number of vertices is around: 206k, at least that's where I stop getting physX cooking errors. It seems to crash at some other point in the code.
mrtm3050
Gnoblar
 
Posts: 8
Kudos: 0
Joined: 03 Mar 2012

Re: Mesh Question

Postby betajaen » Thu Mar 08, 2012 12:44 pm

No, that's completely unrelated code.

The only thing I can think of is that 206k is way to high for PhysX to use. In any case, 206k triangles is a very large mesh to check collisions against. May I suggest reducing it down to a 1/10 of it's original size, or try splitting it up?

I assume other meshes of yours cook okay?
User avatar
betajaen
Old One
 
Posts: 6002
Kudos: 24
Joined: 08 Mar 2006
Location: Wales, UK


Return to NxOgre

Who is online

Users browsing this forum: No registered users and 1 guest