Hi Everbody,
I tried to render a very large Polygon in GK-coordintes, with
the GeometryInfo and Trinagulate clases.
The Polygon has about 1800 Points.
I think I'm looking at the right place in my universum, because
I can see a LineArray wich have drawn in the place, where the polygon
should be.
And I set new bounds for setFrontClipDistance and setBackClipDistance.
But I still cannot see my polygon.
What I am doing wrong?
A part of the source-code is included as attachment!
Thanks for your help in advance!
Yours Desiree
float xu,yu,zu;
double front,back;
Vector shapevector;
shapevector= new Vector(1);
Shape3D shape = new Shape3D();
xu=0.0f;
yu=0.0f;
zu=0.0f;
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
tab.add("3DView", c);
BranchGroup scene = new BranchGroup();
Transform3D trans = new Transform3D();
TransformGroup mytrans = new TransformGroup(trans);
//scene.compile();
u = new SimpleUniverse(c);
ViewingPlatform viewingpfm = u.getViewingPlatform();
TransformGroup viewTransGp = viewingpfm.getViewPlatformTransform();
Transform3D translation = new Transform3D();
Viewer viewer = u.getViewer();
View view = viewer.getView();
view.setFrontClipDistance(400.0d);
view.setBackClipDistance(1000000.0d);
translation.set(new Vector3d(3423509.0d,5398395.0d,1000000.0d));
viewTransGp.setTransform(translation);
try {
FeatureLayer fl = (FeatureLayer) g.getFocusLayer();
if (fl == null) {
System.out.println("GIS3DService: Kein Layer fokusiert");
return;
}
float[] x, y;
int dim;
Object o;
Enumeration enum;
ShapeFeatureProxy sp;
int count;
count=0;
for (enum = fl.getFeatures(); enum.hasMoreElements();) {
o = enum.nextElement();
count++;
if (o instanceof ShapeFeatureProxy) {
sp = (ShapeFeatureProxy) o;
if (sp.getShapeType() == ArcEntity.POLYGON) {
x = sp.getOuterBoundaryX();
y = sp.getOuterBoundaryY();
System.out.println("Polygon ");
System.out.println("x= ");
zu=x[0]-y[0];
for (int i=0; i<x.length; i++) {
if(x[i]<xu) xu=x[i];
if(y[i]<yu) yu=y[i];
System.out.println("p[" + i + "] = " + x[i]
+ "," + y[i]);
}
int strip[]={x.length};
Point3f coords[] = new Point3f[x.length];
// The testpolygon has about 1800 points with values around
// x=3423509.0 y=5398395.0
// x=3506159.0 y=5298568.0
// I tried both for loops!
/*for(int i=0;i<x.length;i++){
coords[i]= new Point3f(x[i],y[i],0);
System.out.println(coords[i]);
}
*/
for(int i=x.length-1;i>=0;i--) {
coords[i]= new Point3f(x[i],y[i],0);
System.out.println(coords[i]);
}
GeometryInfo ginfo = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
ginfo.setCoordinates(coords);
ginfo.setStripCounts(strip);
Triangulator tr = new Triangulator();
tr.triangulate(ginfo);
NormalGenerator norm = new NormalGenerator();
norm.generateNormals(ginfo);
Stripifier st = new Stripifier();
st.stripify(ginfo);
System.out.println("count:"+count);
mytrans.addChild(shape);
LineArray xc = new LineArray(2,LineArray.COORDINATES);
xc.setCoordinate(0,new Point3f(3423509.0f,5398395.0f,0.0f));
xc.setCoordinate(1,new Point3f(3506159.0f,5298568.0f,0.0f));
Shape3D s = new Shape3D();
Appearance app = new Appearance();
s.setGeometry(xc);
s.setAppearance(app);
mytrans.addChild(s);
scene.addChild(mytrans);
}
}
}
} catch (Exception ex) {
System.out.println("GIS3DService ERROR: " + ex.getMessage());
}
u.addBranchGraph(scene);