…
i have a problem with the outline of cell shading
i use the exemple code
TestVertexProgramState of jme
But using the model in a viewport fenggui
I miss you he does not value that will show my outline corectly
my paint method :
public void paint(Graphics g, int viewPortWidth, int viewPortHeight)
{
GL11.glClear( GL11.GL_DEPTH_BUFFER_BIT);
GL11.glEnable (GL11.GL_DEPTH_TEST);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluPerspective(45, (float)viewPortWidth/(float)viewPortHeight, 1, 100);
GL11.glHint (GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); // Use The Good Calculations
GL11.glEnable (GL11.GL_LINE_SMOOTH);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
GLU.gluLookAt(10, 6, 8, 0, 0, 0, 0, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);// Enables Smooth Color Shading
GL11.glPolygonMode (GL11.GL_BACK, GL11.GL_LINE); // Draw Backfacing Polygons As Wireframes
GL11.glLineWidth (2); // Set The Line Width
GL11.glCullFace (GL11.GL_FRONT); // Don't Draw Any Front-Facing Polygons
renderer.draw(rootNode);
}
and the cel shading function it's a jme function
private Torus createShadedTorus() {
//Load the vertex program from a file and bind it to a render state
VertexProgramState vp = renderer.createVertexProgramState();
vp.setParameter(lightPosition, 8);
vp.load(TestVertexProgramState.class.getClassLoader().getResource(
"jmetest/data/images/celshaderARB.vp"));
vp.setEnabled(true);
//Bind a 1-dimensional luminance texture for use by the vertex program
TextureState ts = renderer.createTextureState();
ts.setEnabled(true);
ts.setTexture(TextureManager.loadTexture(
TestVertexProgramState.class.getClassLoader().getResource(
"shading/shader.png"), Texture.MM_NEAREST,
Texture.FM_NEAREST));
//Generate the torus
Torus torus = new Torus("shadedTorus", 20, 8, 1.0f, 2.0f);
torus.setDefaultColor(ColorRGBA.orange.clone());
torus.setRenderState(vp);
torus.setRenderState(ts);
return torus;
}
private Torus createOutlineTorus() {
CullState cs = renderer.createCullState();
cs.setCullMode(CullState.CS_FRONT);
cs.setEnabled(true);
WireframeState ws = renderer.createWireframeState();
ws.setLineWidth(20.0f);
ws.setFace(WireframeState.WS_FRONT);
ws.setEnabled(true);
Torus torus = new Torus("outlineTorus", 20, 8, 1.0f, 2.0f);
torus.setDefaultColor(ColorRGBA.black.clone());
torus.setRenderState(cs);
torus.setRenderState(ws);
// .updateGeometricState(0.0f, true);
return torus;
}