Hi all,
Im new enough to java 3d and could do with any help! Anyone have any ideas bout making a wall/room in java 3d. Have tried this code but it wont work properly. Any help is gratefully accepted, Thanks.
Code:
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()); appear.setPolygonAttributes(poly);
TextureLoader texLoader = new TextureLoader("bricks.jpg", null); Texture2D texture = (Texture2D) texLoader.getTexture();
TextureAttributes texAttr = new TextureAttributes();
texAttr.setTextureMode(TextureAttributes.MODULATE); wall.setAppearance(appear);
wallGroup.addChild(wall);
=========================================================================== 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".
You could create a room in a 3D modeling program such as Maya and export it to a file (such as VRML) and use jX3D to load it into memory. If you don't have money to buy such a program, you may want to download Blender, a fairly decent freeware modeling program.
Or you could create a Box object and scale it to an appropriate size.
Creating geometry by typing in a lot of datapoints is very painful and I would not recommend it.
Mark McKay -- http://www.kitfox.com
=========================================================================== 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".