Amnuriak
19-03-2010 14:10:31
Hi there,
I'm working on a conversion module for meshes. It shall read STL files and convert the data found into NxOgre style meshes. Unfortunately I have to use STL so using a different format is out of the question, at least for now.
STL allows for the same vertex to be specified more then once -> first problem: PhysXs only allows one vertex at any one position in space, not two. This is a matter of parsing all the vertices and eliminating the duplicate ones while not breaking the triangles. Allthough pretty troublesome, I have an idea how to do this.
Second problem: I guess NxOgre::ManualMesh::normal() is used on a per-vertex level as opposed to normal-per-triangle STL style. I don't know the vertex normals and computing them manually is just nasty. Is there a way to supply the triangle normals (or rather have them computed based on the order of insertion of the vertices) and use those to compute the vertex normals ?
Third problem: I can't find any tutorial on how to use ManualMesh. Could somone please hint me to a short tutorial where I can see the construction of some easy body ? Something like a simple cube or a tetrahedron would do nicely. I just gave it a shot and tried to construct a simple cube but I failed miserably
This code results in an exception thrown NxOgreRigidBody.cpp::102 "mActor = mScene->getScene()->createActor(actor_description);" so I guess my mesh construction is just wrong.
I'd be glad for some advice,
Amnu
I'm working on a conversion module for meshes. It shall read STL files and convert the data found into NxOgre style meshes. Unfortunately I have to use STL so using a different format is out of the question, at least for now.
STL allows for the same vertex to be specified more then once -> first problem: PhysXs only allows one vertex at any one position in space, not two. This is a matter of parsing all the vertices and eliminating the duplicate ones while not breaking the triangles. Allthough pretty troublesome, I have an idea how to do this.
Second problem: I guess NxOgre::ManualMesh::normal() is used on a per-vertex level as opposed to normal-per-triangle STL style. I don't know the vertex normals and computing them manually is just nasty. Is there a way to supply the triangle normals (or rather have them computed based on the order of insertion of the vertices) and use those to compute the vertex normals ?
Third problem: I can't find any tutorial on how to use ManualMesh. Could somone please hint me to a short tutorial where I can see the construction of some easy body ? Something like a simple cube or a tetrahedron would do nicely. I just gave it a shot and tried to construct a simple cube but I failed miserably
NxOgre::ManualMesh manual;
manual.begin(NxOgre::Enums::MeshType_Triangle, 4);
manual.vertex(NxOgre::Vec3(0, 0, 0));
manual.index(0);
manual.normal(-1, -1, -1);
manual.vertex(NxOgre::Vec3(1, 0, 0));
manual.index(1);
manual.normal(1, -1, -1);
manual.vertex(NxOgre::Vec3(0, 0, 1));
manual.index(2);
manual.normal(-1, -1, 1);
manual.vertex(NxOgre::Vec3(1, 0, 1));
manual.index(3);
manual.normal(1, -1, -1);
manual.vertex(NxOgre::Vec3(0, 1, 0));
manual.index(4);
manual.normal(-1, 1, -1);
manual.vertex(NxOgre::Vec3(0, 1, 1));
manual.index(5);
manual.normal(-1, 1, 1);
manual.vertex(NxOgre::Vec3(1, 1, 1));
manual.index(6);
manual.normal(1, 1, 1);
manual.vertex(NxOgre::Vec3(1, 1, 0));
manual.index(7);
manual.normal(1, 1, -1);
NxOgre::Mesh* pMesh = manual.end();
NxOgre::ConvexDescription convDesc(pMesh);
pNxOgreScene->createActor(convDesc);
This code results in an exception thrown NxOgreRigidBody.cpp::102 "mActor = mScene->getScene()->createActor(actor_description);" so I guess my mesh construction is just wrong.
I'd be glad for some advice,
Amnu