Problems with Normals

Please take a look at this:

You’ll notice in the highlight that the normals must be switched since I can see right through the side… can’t figure out why though.

Here’s how I compute my normals.

      Vector3f m1 = v1.subtract( v2);
      Vector3f m2 = v2.subtract( v3);
      Vector3f cross = m1.cross( m2);
      v1 = v1.add( cross);
      v2 = v2.add( cross);
      v3 = v3.add( cross);

Just wondering if theres a way to make sure the normals are pointing upward as opposed to downward?

Ok, I was just looking at the code in Terrain code. Specifically the normal generation. I notice that it seems that you are not averaging the normals over the faces that a specific vertex may be part of, is that true?

normals are definitely calculated roughly, but they are crossed in such a way as to assure they will point the correct way out. The order you cross in will determine the direction it points, iirc. We may revisit normal calculation in the future if the rough calculation doesn’t do it for people.

I’m really at whit’s end on this. I think I have all my normals the right direction. Even when I turn on back culling… nothing disappears, except from underneath. So I think that I can be sure my normals are in the right direction.

FYI we resolved this on IM. It was due to no ZBufferState being set.

Thanks again mojo!

I added this into my code, pretty much a cut and paste from SimpleGame.

ZBufferState buf = display.getRenderer().getZBufferState();
_rootNode.setRenderState( buf);

Ah, good catch.