Jazz3D API


com.sygem.jazz3d3.primitive
Class Freeform3d

java.lang.Object
  |
  +--com.sygem.jazz3d3.Object3d
        |
        +--com.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
Author:
SyGem Software
See Also:
Object3d

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, getCenter, getChildObjects, getCollidable, getCulling, getFace, getFaceColour, getID, getName, getNumberOfFaces, getNumberOfSubFaces, getNumberOfSubVertices, getNumberOfVertices, getRenderer, getShapeArray, getUseVertexUVCoords, getVertex, getVertexArray, getVisible, getWorldVertex, pick, pickClosest, pickFace, prepForDisplay, recreateVertexNormals, rotateLocal, rotateLocal, rotateWorld, rotateWorld, scaleObject, setAllTextures, setAmbientColour, setCollidable, setColour, setCulling, setFaceColour, setFaceColourQuick, setName, setPosition, setRenderer, setShapeArray, setTexture, setTexture, setUseVertexUVCoords, setVertexArray, setVertexTexture, setVisible, translateLocal, translateWorld
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, 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

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

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

prep

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

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


©2001 SyGem Software