[Help] How to use Manual mesh correctly

tomneo2000

11-01-2010 04:26:01

Hi, guys i have a problem when i am doing manual mesh, so i think if anyone can help me. I was trying to use manual mesh to create a triangle geometry for collision, but it jump out an access violation reading error message during run time, seems mScene->createSceneGeometry(new NxOgre::TriangleGeometry(mmsh), Matrix44_Identity); create faild. Does anyone use manual mesh? How can i use it correctly?

Here is my code

NxOgre::ManualMesh manual;
manual.begin(NxOgre::Enums::MeshType_Triangle, 3);
manual.vertex(NxOgre::Vec3(-2, 0, -2));
manual.vertex(NxOgre::Vec3(2, 0, -2));
manual.vertex(NxOgre::Vec3(-2, 0, 2));
NxOgre::Mesh* mmsh=manual.end();

mScene->createSceneGeometry(new NxOgre::TriangleGeometry(mmsh), Matrix44_Identity);


Violation reading message

tomneo2000

13-01-2010 05:12:32

No one? I have seen the content of the mesh triangle i created, i found the content seems filled with 0x000000, for example when i manual create triangle i give NxOgre::Enums::MeshType_Triangle for mesh type, but the result become MeshType_Unknow and some content are 0x000000, so i guess this is the reason cause it fail to create scene geometry. Why? Is manual mesh not implement yet? Anyone has the problem like this?

betajaen

13-01-2010 09:31:42

You need some indicies.


Some normals would be good too.

tomneo2000

14-01-2010 10:27:06

You need some indicies.


Some normals would be good too.


what index can you make example please?i am actually making triangle collision mesh for my terrain
,that's why I need to use manual mesh.

betajaen

14-01-2010 11:26:15

Your just giving PhysX a bunch of vertices. How is it supposed to know what your mesh looks like?

Give it some indicies/indexes for the triangles, and some normals to tell PhysX which way the triangles face.

tomneo2000

15-01-2010 12:51:44

Your just giving PhysX a bunch of vertices. How is it supposed to know what your mesh looks like?

Give it some indicies/indexes for the triangles, and some normals to tell PhysX which way the triangles face.


I tried but still have same problem

betajaen

15-01-2010 14:12:22

Let's have a look at your code then.

tomneo2000

16-01-2010 14:36:51

Let's have a look at your code then.


NxOgre::ManualMesh manual;
manual.begin(NxOgre::Enums::MeshType_Triangle, 3);
manual.vertex(NxOgre::Vec3(-2, 0, -2));
manual.index(0);
manual.normal(0.0f, 1.0f, 0.0f);
manual.vertex(NxOgre::Vec3(2, 0, -2));
manual.index(1);
manual.normal(0.0f, 1.0f, 0.0f);
manual.vertex(NxOgre::Vec3(-2, 0, 2));
manual.index(2);
manual.normal(0.0f, 1.0f, 0.0f);
NxOgre::Mesh* mmsh=manual.end();

NxOgre::TriangleGeometry* tri=new NxOgre::TriangleGeometry(mmsh);

mScene->createSceneGeometry(new NxOgre::TriangleGeometry(mmsh), Matrix44_Identity);

betajaen

16-01-2010 15:23:36

I would estimate you would need more than one triangle.

tomneo2000

17-01-2010 08:26:33

I would estimate you would need more than one triangle.

Why need more than one triangle, can't i just create only one triangle for collision?