smooth normals

JeDi

23-03-2006 10:45:25

Hi,

I was browsing your cvs code to find some hints on how to create a collision shape from StaticGeometry, when I stumbled upon a section in your meshShape::generateTriangleMesh function. There's a section in comments about smooth normals and crashing badly, which is quite normal looking at the commented code:


NxVec3* mMeshVertices_Smoothed;
if (smooth) {
mMeshVertices_Smoothed = new NxVec3[mVertexCount];
NxBuildSmoothNormals(mIndexCount, mVertexCount, mMeshVertices, mMeshFaces, NULL, mMeshVertices_Smoothed, true);
}

//...

if (smooth)
mTriangleMeshDescription.points = mMeshVertices;
else
mTriangleMeshDescription.points = mMeshVertices_Smoothed;


The problem is in the last lines of code. you should swap the mMeshVertices and mMeshVertices_Smoothed, because it's 0 there (at least, it seems to me like that :) ).

So anyway, does it make a lot of difference using smoothed normals? In what situations are (were) you using it?

And another question: If you could give me any directions on how to create a collision shape from StaticGeometry, that would be great!

Greetz,
JeDi

betajaen

23-03-2006 14:18:51

When I was writing the heightmesh shape, I noticed if I smoothed the normals the collision between the heightmesh shape and anything hit was completely and totally solid (meaning nothing would fall though it) which wasn't the case when I started writing the code.

The meshShape is a little like that, some things will unfortunately miss the collision and fall though. As meshShapes and collisionShapes are more or less the same thing, naturally I though smoothing the normals on the meshShape would produce a better effect, however that isn't the case. But I left the code in anyway and then commented it out when it wasn't totally stable.

Thanks for the heads up anyway, I'll have a fiddle when I get the PC sorted out.


As for creating a collisionShape from a static geometry do you mean scenes nodes that are assigned static?

JeDi

23-03-2006 21:19:38

I'm trying to generate a meshshape from already built static geometry in Ogre. I'm thinking it isn't the way to do it anyway. I'll have to build some sort of callback system that informs my physics plugin after the mesh is loaded, but before the static geometry is built from it.

I was just trying to create static and dynamic physics objects as general as possible, from any loaded Ogre scene.

Thanks!
Greetz,
JeDi

betajaen

23-03-2006 21:32:56

I agree, I think the callback is the way to go, unless you want to do it through NxScene but you'd have to modify it slighty for the static geometry.