Hi
Could somebody take a quick look at the code below and explain how I
generate the normals - so that I can light these walls that im creating.
I used to generate geomtery differently and then use a normal
generator...but I don't know how to apply that to a quad array etc
Any help would be appreciated,
Thanks...
public void buildWall(int from, int to) {
QuadArray plane = new QuadArray(4, GeometryArray.COORDINATES
|
GeometryArray.TEXTURE_COORDINATE_2);
Point3f[] pts = new Point3f[4];
plane.setCoordinate(0, gridPoints[from]);
plane.setCoordinate(1, gridPoints[to]);
float x1 = gridPoints[to].x;
float y1 = gridPoints[to].y;
float z1 = gridPoints[to].z;
plane.setCoordinate(2, new Point3f(x1, y1 + height, z1));
float x = gridPoints[from].x;
float y = gridPoints[from].y;
float z = gridPoints[from].z;
plane.setCoordinate(3, new Point3f(x, y + height, z));
TexCoord2f q = new TexCoord2f();
q.set(0.0f, 0.0f);
plane.setTextureCoordinate(0, 0, q);
q.set(1.0f, 0.0f);
plane.setTextureCoordinate(0, 1, q);
q.set(1.0f, 1.0f);
plane.setTextureCoordinate(0, 2, q);
q.set(0.0f, 1.0f);
plane.setTextureCoordinate(0, 3, q);
Shape3D wall = new Shape3D();
wall.setGeometry(plane);
Appearance appear = new Appearance();
appear.setMaterial(new Material());
//NormalGenerator ng = new NormalGenerator();
//ColoringAttributes redColoring = new ColoringAttributes(red,
ColoringAttributes.SHADE_FLAT);
//appear.setColoringAttributes(redColoring);
appear.setPolygonAttributes(poly);
TextureLoader texLoader = new TextureLoader("bricks.jpg", null);
Texture2D texture = (Texture2D) texLoader.getTexture();
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE);
//appear.setTexture(texture);
//appear.setTextureAttributes(texAttr);
wall.setAppearance(appear);
wallGroup.addChild(wall);
}
********************************************
Ben Logan - Graduate Software Engineer
RCID
Stephenson Building
Newcastle Upon Tyne
NE1 7RU
www.rcid.ncl.ac.uk
********************************************
===========================================================================
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".