Hi Everybody!
First I created Geometry with QuadArray, which worked fine, but now I want
to shade it, and tried to use GeometryInfo with the NormalGenerator,
I did set
ginfo[l] = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
ginfo[l].recomputeIndices();
ginfo[l].setStripCounts(strip[l]);
norm.setCreaseAngle(0); (I want to see my edges)
In running my application I'll get:
GeometryInfo must have primitve type POLYGON_ARRAY
when I use POLYGON_ARRAY I'll get my shape3d but without shading!
Any ideas?
Thanks for any help!
Desiree
Here is a part of my sourcecode:
float[] x, y;
QuadArray[] quad;
int[][] strip;
GeometryInfo[] ginfo;
// Quad stores geometry of side
// I have got several objects to create in the same way
quad = new QuadArray[sp.getNrOfBoundaries()];
// Coordseite stores coordinates in the way quad needs them
coordseite = new Point3f[sp.getNrOfBoundaries()][];
strip = new int[sp.getNrOfBoundaries()][];
ginfo = new GeometryInfo[sp.getNrOfBoundaries()];
shape = new Shape3D[sp.getNrOfBoundaries()];
for(int l=0;l<sp.getNrOfBoundaries();l++) {
quad[l]=new
QuadArray(baseArea.getCoordinates()[l].length*4*2,QuadArray.COORDINATES);
coordseite[l] = new
Point3f[(baseArea.getCoordinates()[l].length)*4*2];
Vector3f[(baseArea.getCoordinates()[l].length)*4*2];
strip[l] = new int[baseArea.getCoordinates()[l].length*2];
for(int m=0;m<baseArea.getCoordinates()[l].length*2;m++)
strip[l][m]=4;
float k=0;
for(inti=0;i<=((baseArea.getCoordinates()[l].length)*4*2)-1;i=i+4) {
k=k+0.5f;
if (((int)k)>=baseArea.getCoordinates()[l].length) {
k=baseArea.getCoordinates()[l].length-2;
}
if ((((int)k)+1)>=baseArea.getCoordinates()[l].length) {
k=baseArea.getCoordinates()[l].length-2;
}
if((i)<=coordseite[l].length-1) {
coordseite[l][i]= new
Point3f(baseAreaunten.getCoordinates()[l][(int)k]);
}
if((i+1)<=coordseite[l].length-1) {
coordseite[l][i+1]= new
Point3f(baseAreaunten.getCoordinates()[l][((int)k)+1]);
}
if((i+2)<=coordseite[l].length-1) {
coordseite[l][i+2]= new
Point3f(baseArea.getCoordinates()[l][((int)k)+1]);
}
if((i+3)<=coordseite[l].length-1) {
coordseite[l][i+3]= new
Point3f(baseArea.getCoordinates()[l][(int)k]);
}
}
quad[l].setCoordinates(0,coordseite[l]);
// GeometryInfo
ginfo[l] = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
// exception with
//ginfo[l] = new GeometryInfo(GeometryInfo.QUAD_ARRAY);
ginfo[l].setCoordinates(coordseite[l]);
ginfo[l].setStripCounts(strip[l]);
ginfo[l].recomputeIndices();
// Triangulator devides the polygon in triangles
Triangulator tr = new Triangulator();
tr.triangulate(ginfo[l]);
NormalGenerator norm = new NormalGenerator();
norm.generateNormals(ginfo[l]);
norm.setCreaseAngle(0);
Stripifier st = new Stripifier();
st.stripify(ginfo[l]);
// Set Appearance
// Colors are from 2D objects
GraphicsContext gc = sp.getGraphicsContext();
Color c = gc.getForegroundColor();
float red = (float)c.getRed()/255f;
float green = (float)c.getGreen()/255f;
float blue = (float)c.getBlue()/255f;
Color3f fc = new Color3f(red,green,blue);
Appearance app = new Appearance();
//LIGHT
Material material = new Material(fc,black,black,black,20f);
material.setCapability(Material.ALLOW_COMPONENT_READ);
material.setCapability(Material.ALLOW_COMPONENT_WRITE);
app.setMaterial(material);
app.setCapability(Appearance.ALLOW_MATERIAL_WRITE);
app.setCapability(Appearance.ALLOW_MATERIAL_READ);
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);
app.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
PolygonAttributes polyattr = new PolygonAttributes();
polyattr.setCullFace(PolygonAttributes.CULL_NONE);
ColoringAttributes colatt = new
ColoringAttributes(fc,ColoringAttributes.SHADE_GOURAUD);
colatt.setCapability(ColoringAttributes.ALLOW_COLOR_READ);
colatt.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
app.setColoringAttributes(colatt);
app.setPolygonAttributes(polyattr);
// Create Shape3D
shape[l] = new Shape3D();
shape[l].setCapability(Shape3D.ALLOW_APPEARANCE_READ);
shape[l].setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
shape[l].setAppearance(app);
shape[l].setGeometry(ginfo[l].getGeometryArray());
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".