Problem where two surfaces meet
If ya run the attached code/demo, you will notice that the edge where blue and green/white surfaces meet is flickering... it is not solid as I would expect it to be and this my concern since it is a lot more noticable in my program. I am not sure how to get around with this and would appreciate any suggestions.
Thanx All,
import java.awt.*;
import javax.vecmath.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
public class TestFrame extends java.awt.Frame {
public TestFrame() {
Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());
add(canvas3D);
SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(createBranchGroup());
}
protected BranchGroup createBranchGroup(){
BranchGroup branchGroup = new BranchGroup();
Transform3D transform = new Transform3D();
transform.set(new Vector3f(-3, 2, -20));
TransformGroup group = new TransformGroup(transform);
TransformGroup rotGroup = new TransformGroup();
rotGroup.addChild(new Shape());
rotGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
group.addChild(rotGroup);
RotationInterpolator interpolator = new RotationInterpolator(new Alpha(-1, 10000), rotGroup);
interpolator.setSchedulingBounds(new BoundingSphere());
group.addChild(interpolator);
branchGroup.addChild(group);
return branchGroup;
}
public static void main(String[] arg){
TestFrame frame = new TestFrame();
frame.setSize(300,300);
frame.setVisible(true);
}
class Shape extends Shape3D {
float [][] vertices = {
{-1.6667603f, -5.0f, 3.535534f}, {-1.6667603f, -5.0f, -3.535534f},
{-1.6667603f, -3.0f, -3.535534f}, {-1.6667603f, 5.0f, -3.535534f},
{-1.0893776f, 3.267949f, -2.7190602f} };
int [][] triangles = {{0, 1, 2}, {0, 2, 1}, {1, 4, 3}, {1, 3, 4}};
Color[] colors = {Color.red, Color.blue, Color.green, Color.white};
Shape(){
int format = TriangleArray.COORDINATES | TriangleArray.COLOR_3;// | GeometryArray.TEXTURE_COORDINATE_2;
for(int i = 0; i < triangles.length; i++){
TriangleArray triangle = new TriangleArray(3, format);
for(int k = 0; k < 3; k++) {
triangle.setCoordinates(k, vertices[triangles[k]]);
triangle.setColor(k, new Color3f(colors));
}
addGeometry(triangle);
}
}
}
}

