nxogre 1.5.5 bug ?

titanhope

19-10-2009 10:09:33

i'm use NxOgre::ManualMesh create NxOgre::Mesh .

NxOgre::ManualMesh* man_mesh = NxOgre_New(NxOgre::ManualMesh)();
man_mesh->begin(NxOgre::Enums::MeshType_Triangle);
...
NxOgre::Mesh* nxs_mesh = man_mesh->end();

but nxogre.log show is err

From: e:\work\ogreproject\tank_3d\sdk\nxogre.1.5.5.bloodymess.unstable\build\source\nxogremesh.cpp(99)
Resource 'memory: is not a PhysX NXS mesh file.

why???

betajaen

19-10-2009 10:17:36

Can I see your entire code ManualMesh code? That error is indicative of the mesh vertices or triangles being incorrect.

titanhope

19-10-2009 10:26:32

my code:

NxOgre::Mesh *createTriangleMesh(Ogre::SceneManager *sm, const Ogre::String &meshName, const Ogre::Vector3 &scale)
{
Ogre::Entity* ent = sm->createEntity(meshName);
if (ent == 0)
{
printf("Mesh could not be loaded.\n");
return 0;
}
Ogre::Mesh* mesh = ent->getMesh().getPointer();

NxOgre::ManualMesh* man_mesh = NxOgre_New(NxOgre::ManualMesh)();
man_mesh->begin(NxOgre::Enums::MeshType_Triangle);

bool added_shared = false, use32bitindexes = false;
unsigned int current_offset = 0, shared_offset = 0, next_offset = 0, index_offset = 0;

for (unsigned short i=0; i < mesh->getNumSubMeshes();i++) {

Ogre::SubMesh* submesh = mesh->getSubMesh(i);
Ogre::VertexData* vertex_data = submesh->useSharedVertices ? mesh->sharedVertexData : submesh->vertexData;

/// \todo MaterialAlias goes here.

if((!submesh->useSharedVertices)||(submesh->useSharedVertices && !added_shared)) {

if(submesh->useSharedVertices) {
added_shared = true;
shared_offset = current_offset;
}

const Ogre::VertexElement* posElem = vertex_data->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
Ogre::HardwareVertexBufferSharedPtr vbuf = vertex_data->vertexBufferBinding->getBuffer(posElem->getSource());
unsigned char* vertex = static_cast<unsigned char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));

Ogre::Real* pReal;

for( size_t j = 0; j < vertex_data->vertexCount; ++j, vertex += vbuf->getVertexSize()) {
posElem->baseVertexPointerToElement(vertex, &pReal);
man_mesh->vertex(pReal[0], pReal[1], pReal[2]);
}

vbuf->unlock();
next_offset += vertex_data->vertexCount;
}

Ogre::IndexData* index_data = submesh->indexData;

size_t numTris = index_data->indexCount / 3;
Ogre::HardwareIndexBufferSharedPtr ibuf = index_data->indexBuffer;

use32bitindexes = (ibuf->getType() == Ogre::HardwareIndexBuffer::IT_32BIT);


if ( use32bitindexes ) {
unsigned int* pInt = static_cast<unsigned int*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = (submesh->useSharedVertices)? shared_offset : current_offset;

for (size_t k = 0; k < numTris*3; ++k) {
man_mesh->index(pInt[k] + static_cast<unsigned int>(offset));
/// \todo MaterialAlias NxMaterialIndex get's thrown in here to man_mesh->material(x);
}
}
else {

unsigned short* pShort = reinterpret_cast<unsigned short*>(ibuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
size_t offset = (submesh->useSharedVertices)? shared_offset : current_offset;

for ( size_t k = 0; k < numTris*3; ++k) {
man_mesh->index(static_cast<unsigned int>(pShort[k]) + static_cast<unsigned int>(offset));
/// \todo MaterialAlias NxMaterialIndex get's thrown in here to man_mesh->material(x);
}

}

ibuf->unlock();
current_offset = next_offset;
}

NxOgre::Mesh* nxs_mesh = man_mesh->end();
NxOgre_Delete(man_mesh);
sm->destroyEntity(ent);

return nxs_mesh;
}



NxOgre::Mesh* mm = trip::createTriangleMesh(GetSceneManager(),meshname,Ogre::Vector3(1,1,1));
NxOgre::TriangleGeometry* tri = new NxOgre::TriangleGeometry(mm);
NxOgre::Shapes pShapes;
pShapes.insert(tri);
GetOGRE3DScene()->createSceneGeometry(tri, Matrix44_Identity);

betajaen

19-10-2009 10:32:43

Alright. I'll paste that into Cake later in the day and see if I can replicate the bug.

For the record; You don't need to recreate the same mesh over and over again, you can share Meshes between Actors.

titanhope

19-10-2009 10:40:28

thank's :D

XpLoDWilD

12-03-2010 19:52:36

Sorry for resurrecting this pretty old post, but I'm running onto the same problem.

Have you got a fix for it?

XpLoDWilD

27-03-2010 08:37:57

I'm bumping it. My deadline is approaching and I really need a fix for it. Thanks