Mesh Question

mrtm3050

03-03-2012 21:14:09

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

03-03-2012 22:45:44

Hey All,

This is the code segment I tried to no avail:



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

03-03-2012 22:46:03

Hey All,

This is the code segment I tried to no avail:



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

03-03-2012 22:48:14

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

03-03-2012 23:02:31

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.x, vertices.y, vertices.z);
}
for(unsigned int i = 0; i < index_count; ++i)
{
manualMesh.index(indices);
}
delete[] vertices;
delete[] indices;
NxOgre::Mesh *mesh = manualMesh.end();

Just wanted to correctly assume that this is an issue the number of meshes.

mrtm3050

05-03-2012 23:37:35

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?

betajaen

06-03-2012 19:55:16

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).

mrtm3050

07-03-2012 00:01:09

Hey betajaen,

Were you referring to this:

# define NxOgreSixteenBytesRestriction(CLASS) extern char NxOgreCompileAssert;
# define NxOgreFourBytesRestriction(CLASS) extern char NxOgreCompileAssert;

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

07-03-2012 01:08:05

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.

betajaen

08-03-2012 11:44:04

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?