com.sygem.jazz3d3.primitive
Class Freeform3d

java.lang.Object
  extended bycom.sygem.jazz3d3.Object3d
      extended bycom.sygem.jazz3d3.primitive.Freeform3d

public class Freeform3d
extends Object3d

Allows you to create any object you can think of. It uses a simple approach - you add the points which make up the object, then add the faces which connect those points.

For example:

Freeform3d obj = new Freeform3d(0,0,8);
// Now we can add points - 8 points for a cube...
obj.addPoint(-0.5,-0.5,-0.5);
obj.addPoint(0.5,-0.5,-0.5);
obj.addPoint(0.5,0.5,-0.5);
obj.addPoint(-0.5,0.5,-0.5);
obj.addPoint(-0.5,-0.5,0.5);
obj.addPoint(0.5,-0.5,0.5);
obj.addPoint(0.5,0.5,0.5);
obj.addPoint(-0.5,0.5,0.5);

// And 6 faces in a cube...
obj.addFace(0,1,2,3,255,255,255,false);
obj.addFace(4,5,6,7,255,255,255,false);
obj.addFace(2,6,5,1,255,255,255,false);
obj.addFace(7,3,0,4,255,255,255,false);
obj.addFace(0,1,5,4,255,255,255,false);
obj.addFace(7,6,2,3,255,255,255,false);

// And finally, we need to call prep()...
obj.prep();

Version:
3.0a
See Also:
Object3d

Field Summary
 
Fields inherited from class com.sygem.jazz3d3.Object3d
USE_ONE_RENDERER, WRAP_FRONT, WRAP_TOP
 
Constructor Summary
Freeform3d(double x, double y, double z)
          Default constructor.
 
Method Summary
 void addFace(int p1, int p2, int p3, int r, int g, int b, boolean doublesided)
          Adds a trianglular face to the object.
 void addFace(int p1, int p2, int p3, int p4, int r, int g, int b, boolean doublesided)
          Adds a quadrilateral face to the object.
 void addPoint(double x, double y, double z)
          Add a point to the object.
 void addPoint(double x, double y, double z, double u, double v)
          Add a point to the object.
 void prep()
          Finalizes the object creation process.
 
Methods inherited from class com.sygem.jazz3d3.Object3d
addChild, addQuad, addTriangle, addVertex, applyFaceChanges, cleanUp, culled, getCenter, getChildObjects, getCollidable, getCulling, getFace, getFaceColour, getID, getName, getNumberOfFaces, getNumberOfSubFaces, getNumberOfSubVertices, getNumberOfVertices, getOrientationMatrix, getRenderer, getRotationMatrix, getShapeArray, getUseVertexUVCoords, getVertex, getVertexArray, getVisible, getWorldVertex, init, pick, pickClosest, pickFace, prepForDisplay, recreateVertexNormals, rotateLocal, rotateLocal, rotateWorld, rotateWorld, scaleObject, setAllTextures, setAmbientColour, setCollidable, setColour, setCulling, setFaceColour, setFaceColourQuick, setID, setName, setPosition, setRenderer, setShapeArray, setTexture, setTexture, setUseVertexUVCoords, setVertexArray, setVertexTexture, setVisible, toString, translateLocal, translateWorld, visible, wrapUV
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Freeform3d

public Freeform3d(double x,
                  double y,
                  double z)
Default constructor.

Parameters:
x - The x position of the center of the object
y - The y position of the center of the object
z - The z position of the center of the object
Method Detail

addFace

public final void addFace(int p1,
                          int p2,
                          int p3,
                          int r,
                          int g,
                          int b,
                          boolean doublesided)
Adds a trianglular face to the object. Note that point numbers start from zero - zero being the first point you added to the object.

Parameters:
p1 - The first point of the triangle.
p2 - The second point of the triangle.
p3 - The third point of the triangle.
r - The red value of the colour. Ranges from 0 to 255.
g - The green value of the colour. Ranges from 0 to 255.
b - The blue value of the colour. Ranges from 0 to 255.
doublesided - True if the face should be double-sided, false if not

addFace

public final void addFace(int p1,
                          int p2,
                          int p3,
                          int p4,
                          int r,
                          int g,
                          int b,
                          boolean doublesided)
Adds a quadrilateral face to the object. Note that point numbers start from zero - zero being the first point you added to the object.

Parameters:
p1 - The first point of the quad.
p2 - The second point of the quad.
p3 - The third point of the quad.
p4 - The fourth point of the quad.
r - The red value of the colour. Ranges from 0 to 255.
g - The green value of the colour. Ranges from 0 to 255.
b - The blue value of the colour. Ranges from 0 to 255.
doublesided - True if the face should be double-sided, false if not

addPoint

public final void addPoint(double x,
                           double y,
                           double z)
Add a point to the object.

Parameters:
x - The x position of the point
y - The y position of the point
z - The z position of the point

addPoint

public final void addPoint(double x,
                           double y,
                           double z,
                           double u,
                           double v)
Add a point to the object. Also allows you to specify the UV coordinates used at this point.

Parameters:
x - The x position of the point
y - The y position of the point
z - The z position of the point
u - The U coordinate of the point
v - The V coordinate of the point

prep

public final void prep()
Finalizes the object creation process.

NOTE: If this is not called, the object will not render correctly...



Copyright © 1999-2006 SyGem Software. All Rights Reserved.