Invisible Plane?
I found something very wierd... i have a program that calculates a polynomical function from some points and draws it. It should represent a dome and i rotate it. But it looks like if there was a black plane at z=-20 and parallel with both x and y. When the dome rotates behind this plane the part of it dissapears. I didnt add this plane anywhere!!! Where did it come from.
Image of problem http://img523.imageshack.us/img523/8202/invisibleif6.png
class DomeUniverseextends JFrame{
privateclass Archextends Shape3D{
private BranchGroup arch;
public Arch( ArrayList def,int height){
arch =new BranchGroup();
//Set the overall appearance
Appearance app =new Appearance();
PolygonAttributes poly =new PolygonAttributes();
poly.setCullFace(PolygonAttributes.CULL_NONE);
app.setPolygonAttributes(poly);
app.setLineAttributes(new LineAttributes( 2.0f, LineAttributes.PATTERN_SOLID,false));
app.setColoringAttributes(new ColoringAttributes(new Color3f(1.0f,0.0f,0.0f), ColoringAttributes.SHADE_GOURAUD));
// rotate object has composited transformation matrix
Transform3D rotate =new Transform3D();
Transform3D translate =new Transform3D();
translate.set(new Vector3f(0.1f, 0.0f, 0.0f));
TransformGroup archTGT1 =new TransformGroup(translate);
arch.addChild(archTGT1);
rotate.rotZ(Math.PI/2.0d);
TransformGroup archTGR1 =new TransformGroup(rotate);
//help variables
double r = (Math.tan(Math.PI/2-Math.atan(height/1500.0))*1500+1000)/2;
double terciarWidth = Math.sqrt(r*r-(height/3+r-height)*(height/3+r-height));
double sekTerciarWidth = Math.sqrt(r*r-(height*2/3+r-height)*(height*2/3+r-height));
double sekundarHeight = Math.sqrt(r*r-3000.0*3000.0/16.0)-r+height;
//The default values of the dome
double[] xs ={0,1500-terciarWidth,1500-sekTerciarWidth,750,1500,2250,1500+sekTerciarWidth,1500+terciarWidth,3000};
double[] fs ={0,height/3,height*2/3,sekundarHeight,height,sekundarHeight,height*2/3,height/3,0};
//These x values and y values will be further edited. Only testing version.
double[] xs1 ={0,xs[1]+C,xs[2]+D,xs[3] ,xs[4] ,xs[5] ,xs[6]-E,xs[7]-F,3000};
double[] fs1 ={0,fs[1] ,fs[2] ,fs[3]+J,fs[4]+K,fs[5]+L,fs[6] ,fs[7] ,0};
double[] xs2 ={0,xs[1]+C,xs[2]+B,xs[3] ,xs[4] ,xs[5] ,xs[6]-A,xs[7] ,3000};
double[] fs2 ={0,fs[1] ,fs[2] ,fs[3]+I,fs[4]+H,fs[5]+G,fs[6] ,fs[7]-F,0};
//In these variables there are stored the last y values.
float lastY1 = 0;
float lastY2 = 0;
for(float x = BLEND; x <= 3000; x+=BLEND){
float y1 = 0.0f;
float y2 = 0.0f;
//polynomical function
for(int i = 0; i < xs.length; i++){
double li1 = 1.0;
double li2 = 1.0;
for(int j = 0; j < xs.length; j++){
if( j != i){
li1 *= (x - xs1[j])/( xs1[i]-xs1[j]);
li2 *= (x - xs2[j])/( xs2[i]-xs2[j]);
}
}
y1+=li1*fs1[i];
y2+=li2*fs2[i];
}
//polygon down
TriangleArray archPolygon1 =new TriangleArray(3, QuadArray.COORDINATES|QuadArray.COLOR_3);
archPolygon1.setCoordinate(0,new Point3f( lastY1*4/300,-(x-BLEND)*4/300+20,-10.0f));
archPolygon1.setCoordinate(1,new Point3f( lastY2*4/300,-(x-BLEND)*4/300+20,10.0f));
archPolygon1.setCoordinate(2,new Point3f( y2*4/300,-x*4/300+20,10.0f));
archPolygon1.setColor(0, yellow);
archPolygon1.setColor(1, green);
archPolygon1.setColor(2, blue);
Shape3D archP =new Shape3D( archPolygon1);
archP.setAppearance(app);
archTGR1.addChild(archP);
//polygon up
TriangleArray archPolygon2 =new TriangleArray(3, QuadArray.COORDINATES|QuadArray.COLOR_3);
archPolygon2.setCoordinate(0,new Point3f( lastY1*4/300,-(x-BLEND)*4/300+20,-10.0f));
archPolygon2.setCoordinate(1,new Point3f( y1*4/300,-x*4/300+20,-10.0f));
archPolygon2.setCoordinate(2,new Point3f( y2*4/300,-x*4/300+20,10.0f));
archPolygon2.setColor(0, yellow);
archPolygon2.setColor(1, red);
archPolygon2.setColor(2, blue);
Shape3D archP2 =new Shape3D( archPolygon2);
archP2.setAppearance(app);
archTGR1.addChild(archP2);
lastY1 = y1;
lastY2 = y2;
}
//Add it all
archTGT1.addChild(zs);
archTGT1.addChild(ys);
archTGT1.addChild(xos);
archTGT1.addChild(archTGR1);
}
public BranchGroup getArch(){
return arch;
}
}
public ArchUniverse( Main main,boolean animate, String[] startStrength, String[] endStrength,int height){
//....... deleted code for better preview
Canvas3D canvas3D =new Canvas3D(SimpleUniverse.getPreferredConfiguration());
add("Center", canvas3D);
BranchGroup scene = createSceneGraph();
SimpleUniverse simpleU =new SimpleUniverse(canvas3D);
Transform3D tr =new Transform3D();
tr.setTranslation(new Vector3d(0,0,50));
simpleU.getViewingPlatform().getViewPlatformTransform().setTransform(tr);
simpleU.addBranchGraph(scene);
}
public BranchGroup createSceneGraph(){
BranchGroup objRoot =new BranchGroup();
TransformGroup objSpin =new TransformGroup();
objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
objRoot.addChild(objSpin);
objSpin.addChild(new Arch(main.getDeformation(startStrength[0].substring(0,startStrength[0].indexOf(" kN")), Integer.parseInt(startStrength[1]), main.getCP()), height).getArch());
Alpha rotationAlpha =new Alpha(-1, 10000);
RotationInterpolator rotator =
new RotationInterpolator(rotationAlpha, objSpin);
// isnt this it? some sphere? does it exist real or only imaginar
BoundingSphere bounds =
new BoundingSphere(new Point3d(0.0,0.0,0.0), 1.0);
rotator.setSchedulingBounds(bounds);
objSpin.addChild(rotator);
objRoot.compile();
return objRoot;
}
}

