No success… Here are my results…
2 cubes, one back face culled the other front face culled, with normal lines…
code…
public class sBox2 extends Node
{
private static final float[] GEOMETRY_NORMALS_DATA = {
// front
0, 0, -1, 0, 0, -1, 0, 0, -1,
0, 0, -1, 0, 0, -1, 0, 0, -1,
// back
0, 0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 1, 0, 0, 1, 0, 0, 1,
// top
0, 1, 0, 0, 1, 0, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 1, 0,
// bottom
0, -1, 0, 0, -1, 0, 0, -1, 0,
0, -1, 0, 0, -1, 0, 0, -1, 0,
// right
-1, 0, 0, -1, 0, 0, -1, 0, 0,
-1, 0, 0, -1, 0, 0, -1, 0, 0,
// left
1, 0, 0, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, 1, 0, 0
};
public enum Face {OUTSIDE,INSIDE};
public sBox2(Vector3f _center,float _w,float _h,float _d,MyColor _c,Face _f)
{
Geometry g=new Geometry("Box");
Material m=new Material(Eo.getAssetManager(),"Common/MatDefs/Light/Lighting.j3md");
m.setBoolean("UseMaterialColors",true);
m.setColor("Diffuse",_c.asJmeColor());
if(_c.getAlpha()<1f)
{
m.setTransparent(true);
m.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
g.setQueueBucket(Bucket.Transparent);
}
if(_f==Face.OUTSIDE)
{
m.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Back);
}else{
m.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Front);
}
Mesh mesh=createMesh(_w,_h,_d);
g.setMesh(mesh);
g.setMaterial(m);
attachChild(g);
TangentBinormalGenerator.generate(g);
setLocalTranslation(_center);
Geometry g2=new Geometry("Normals");
g2.setMesh(TangentBinormalGenerator.genNormalLines(mesh,1f));
Material m2=new Material(Eo.getAssetManager(),"Asset/material/Basic.j3md");
m2.setColor("Color",MyColor.BLUE.asJmeColor());
g2.setMaterial(m2);
attachChild(g2);
}
private Mesh createMesh(float _w,float _h,float _d)
{
float hw=_w/2;
float hh=_h/2;
float hd=_d/2;
Mesh m=new Mesh();
m.setMode(Mesh.Mode.Triangles);
m.setBuffer(VertexBuffer.Type.Normal,3,GEOMETRY_NORMALS_DATA);
m.setBuffer(VertexBuffer.Type.Position,3,new float[]{
-hw,-hh,-hd,
+hw,+hh,-hd,
+hw,-hh,-hd,
-hw,-hh,-hd,
-hw,+hh,-hd,
+hw,+hh,-hd,
-hw,-hh,+hd,
+hw,-hh,+hd,
+hw,+hh,+hd,
-hw,-hh,+hd,
+hw,+hh,+hd,
-hw,+hh,+hd,
-hw,+hh,-hd,
+hw,+hh,+hd,
+hw,+hh,-hd,
-hw,+hh,-hd,
-hw,+hh,+hd,
+hw,+hh,+hd,
-hw,-hh,-hd,
+hw,-hh,-hd,
+hw,-hh,+hd,
-hw,-hh,-hd,
+hw,-hh,+hd,
-hw,-hh,+hd,
-hw,+hh,-hd,
-hw,-hh,-hd,
-hw,-hh,+hd,
-hw,+hh,-hd,
-hw,-hh,+hd,
-hw,+hh,+hd,
+hw,+hh,-hd,
+hw,-hh,+hd,
+hw,-hh,-hd,
+hw,+hh,-hd,
+hw,+hh,+hd,
+hw,-hh,+hd});
return m;
}
//################################################################################
// end
//################################################################################
}