com.threed.jpct.util
Class ExtendedPrimitives

java.lang.Object
  extended by com.threed.jpct.util.ExtendedPrimitives

public class ExtendedPrimitives
extends java.lang.Object

This class provides some methods to create basic 3d objects that can be used within a jPCT world. All objects have usable uv-coordinates and methods for default values (especially to create objects that fit into a 1*1*1 cube). After creation don't forget to add the object to your world, otherwise you won't see it.


Constructor Summary
ExtendedPrimitives()
           
 
Method Summary
static Object3D createBox(SimpleVector size)
          Creates a cuboid with width, height and depth given as components of a SimpleVector.
static Object3D createCog(int teeth)
          Creates a cog that fits into a 1*1*1 cube.
static Object3D createCog(int teeth, float holeRadius, float innerRadius, float outerRadius, float innerSpace, float outerSpace, float outerMovement, float height)
          Creates a cog.
static Object3D createCone(float radius, float height, int faces, boolean cap)
          Creates a cone which would perfectly fit into a 1*1*1 cube.
static Object3D createCone(int faces)
          Creates a cone which would perfeclty fit into a 1*1*1 cube.
static Object3D createCube()
          Creates a cube with an edge length of 1.
static Object3D createCube(float size)
          Creates a cube with a given edge length.
static Object3D createCylinder(float radius, float height, int quads, boolean caps)
          Creates a cylinder with specific radius and height.
static Object3D createCylinder(int quads)
          Creates a cylinder which would perfectly fit into a 1*1*1 cube.
static Object3D createDisc(float xradius, float yradius, int vertices)
          Creates a disc with a specific radius in X and in Y direction.
static Object3D createDisc(float radius, int vertices)
          Creates a disc with a specific radius.
static Object3D createDisc(int vertices)
          Creates a disc with a size of 1*1 (so it has radius 0.5).
static Object3D createEllipsoid(SimpleVector size, int quads)
          Creates an ellipsoid with given width, height and depth.
static Object3D createEllipsoid(SimpleVector size, int quads, float uScale, float vScale)
          Creates an ellipsoid with given width, height and depth.
static Object3D createPivot()
          A pivot object is just another name for a dummy object that can be used to position objects by setting the pivot as parent.
static Object3D createPlane(float size, int quads)
          Creates a plane.
static Object3D createPlane(int quads)
          Creates a plane.
static Object3D createPyramid()
          Creates a pyramid that would perfectly fit into a 1*1*1 cube.
static Object3D createPyramid(float size)
          Creates a pyramid that would perfectly fit into a specific cube.
static Object3D createPyramid(float size, float height)
          Creates a pyramid with a specific ground size and height.
static Object3D createSphere(float radius, int quads)
          Creates a sphere with a specific radius.
static Object3D createSphere(int quads)
          Creates a sphere with a radius of 0.5 (so it would perfectly fit into a 1*1*1 cube).
static Object3D createSprite()
          Creates a sprite of size 1*1.
static Object3D createSprite(float size)
          Creates a sprite of a specific size.
static Object3D createSprite(float width, float height)
          Creates a sprite of a specific size.
static Object3D createTorus(float radius, float pipeRadius, int lengthQuads, int pipeQuads)
          Creates a torus (also known as donut) around the Y-Axis.
static Object3D createTorus(int lengthQuads, int pipeQuads)
          Creates a torus (also known as donut) around the Y-Axis.
static Object3D createTube(float innerRadius, float outerRadius, float height, int quads)
          Creates a tube along the Y-Axis.
static Object3D createTube(int quads)
          Creates a tube along the Y-Axis.
static void transformUVCoords(Object3D obj, float uMove1, float vMove1, float uScale, float vScale, float uMove2, float vMove2)
          Moves, scales and again moves uv coords on an Object3D object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedPrimitives

public ExtendedPrimitives()
Method Detail

createPivot

public static Object3D createPivot()
A pivot object is just another name for a dummy object that can be used to position objects by setting the pivot as parent. A pivot will never be drawn and so you also shouldn't add it to a World.

Returns:
the pivot object

createCube

public static Object3D createCube()
Creates a cube with an edge length of 1.

Returns:
a cube object

createCube

public static Object3D createCube(float size)
Creates a cube with a given edge length.

Parameters:
size - length of each edge
Returns:
a cube object

createBox

public static Object3D createBox(SimpleVector size)
Creates a cuboid with width, height and depth given as components of a SimpleVector.

Parameters:
size - width, height and depth for the cubiod that should be created
Returns:
the created cuboid

createCylinder

public static Object3D createCylinder(int quads)
Creates a cylinder which would perfectly fit into a 1*1*1 cube. It points towards the Y-Axis.

Parameters:
quads - The number of quads that should be used for the cylinder. Don't use more quads than you need!
Returns:
the created cylinder

createCylinder

public static Object3D createCylinder(float radius,
                                      float height,
                                      int quads,
                                      boolean caps)
Creates a cylinder with specific radius and height. It points towards the Y-Axis.

Parameters:
radius - of the cylinder
height - of the cylinder along Y-Axis
quads - The number of quads that should be used for the cylinder. Don't use more quads than you need!
caps - if false the cylinder won't have caps an the ends
Returns:
the created cylinder

createCone

public static Object3D createCone(int faces)
Creates a cone which would perfeclty fit into a 1*1*1 cube. The top points towards the negative Y-Axis.

Parameters:
faces - Number of faces that should be used. Don't use more faces than you need!
Returns:
the created cone

createCone

public static Object3D createCone(float radius,
                                  float height,
                                  int faces,
                                  boolean cap)
Creates a cone which would perfectly fit into a 1*1*1 cube. The top points towards the negative Y-Axis.

Parameters:
radius - of the cone
height - of the cone along the Y-Axis
faces - Number of faces that should be used. Don't use more faces than you need!
cap - If false the cone won't have a ground.
Returns:

createSprite

public static Object3D createSprite()
Creates a sprite of size 1*1. A sprite is just a surface of two triangles that will always point towards the camera. Sprites are especially used for particle effect. If you don't want the sprite pointing towards the camera you can disable it by using the setBillboarding method.

Returns:
created sprite

createSprite

public static Object3D createSprite(float size)
Creates a sprite of a specific size. A sprite is just a surface of two triangles that will always point towards the camera. Sprites are especially used for particle effect. If you don't want the sprite pointing towards the camera you can disable it by using the setBillboarding method.

Parameters:
size - of the sprite
Returns:
created sprite

createSprite

public static Object3D createSprite(float width,
                                    float height)
Creates a sprite of a specific size. A sprite is just a surface of two triangles that will always point towards the camera. Sprites are especially used for particle effect. If you don't want the sprite pointing towards the camera you can disable it by using the setBillboarding method.

Parameters:
width - of the sprite
height - of the sprite
Returns:
created sprite

createPlane

public static Object3D createPlane(int quads)
Creates a plane. A plane is a flat rectangle consisting of quads (smaller rectangles). By default each quad has a size of 1.

Parameters:
quads - Number of quads at each edge.
Returns:
the created plane

createPlane

public static Object3D createPlane(float size,
                                   int quads)
Creates a plane. A plane is a flat rectangle consisting of quads (smaller rectangles).

Parameters:
size - of the quads
quads - Number of quads at each edge.
Returns:
the created plane

createTorus

public static Object3D createTorus(int lengthQuads,
                                   int pipeQuads)
Creates a torus (also known as donut) around the Y-Axis. This default torus would perfectly fit into a 1*1*1 cube.

Parameters:
lengthQuads - Number of quads that should be used along the pipe.
pipeQuads - Number of quads that should be used the pipe round.
Returns:
the created torus

createTorus

public static Object3D createTorus(float radius,
                                   float pipeRadius,
                                   int lengthQuads,
                                   int pipeQuads)
Creates a torus (also known as donut) around the Y-Axis.

Parameters:
radius - Radius of a imaginary circle the torus should contain.
pipeRadius - Radius of the pipe.
lengthQuads - Number of quads that should be used along the pipe.
pipeQuads - Number of quads that should be used the pipe round.
Returns:
the created torus

createPyramid

public static Object3D createPyramid()
Creates a pyramid that would perfectly fit into a 1*1*1 cube. The top points towards the negative Y-Axis.

Returns:
the created pyramid

createPyramid

public static Object3D createPyramid(float size)
Creates a pyramid that would perfectly fit into a specific cube. The top points towards the negative Y-Axis.

Parameters:
size - of the cube in which the pyramid should perfectly fit in
Returns:
the created pyramid

createPyramid

public static Object3D createPyramid(float size,
                                     float height)
Creates a pyramid with a specific ground size and height. The top points towards the negative Y-Axis.

Parameters:
size - of the ground of the pyramid
height - of the pyramid
Returns:
the created pyramid

createSphere

public static Object3D createSphere(int quads)
Creates a sphere with a radius of 0.5 (so it would perfectly fit into a 1*1*1 cube).

Parameters:
quads - Number of quads that should be used for the sphere. You should seriously not use more quads than you need!
Returns:
the created sphere

createSphere

public static Object3D createSphere(float radius,
                                    int quads)
Creates a sphere with a specific radius.

Parameters:
radius - of the sphere
quads - Number of quads that should be used for the sphere. You should seriously not use more quads than you need!
Returns:
the created sphere

createEllipsoid

public static Object3D createEllipsoid(SimpleVector size,
                                       int quads)
Creates an ellipsoid with given width, height and depth.

Parameters:
size - Vector that contains width, height and depth
quads - Number of quads that should be used for the sphere. You should seriously not use more quads than you need!
Returns:
the created ellipsoid

createEllipsoid

public static Object3D createEllipsoid(SimpleVector size,
                                       int quads,
                                       float uScale,
                                       float vScale)
Creates an ellipsoid with given width, height and depth.

Parameters:
size - Vector that contains width, height and depth
quads - Number of quads that should be used for the sphere. You should seriously not use more quads than you need!
uScale - texture u scale, default is 2f
vScale - texture v scale, default is 1f
Returns:
the created ellipsoid

createDisc

public static Object3D createDisc(int vertices)
Creates a disc with a size of 1*1 (so it has radius 0.5). A disk is flat an can only seen from one side. The disk is created along the Z-Axis and should be visible from the negative Z-Axis.

Parameters:
vertices - Number of vertices that should be used.
Returns:
the created disk

createDisc

public static Object3D createDisc(float radius,
                                  int vertices)
Creates a disc with a specific radius. A disk is flat an can only seen from one side. The disk is created along the Z-Axis and should be visible from the negative Z-Axis.

Parameters:
radius - of the disk
vertices - Number of vertices that should be used.
Returns:
the created disk

createDisc

public static Object3D createDisc(float xradius,
                                  float yradius,
                                  int vertices)
Creates a disc with a specific radius in X and in Y direction. A disk is flat an can only seen from one side. The disk is created along the Z-Axis and should be visible from the negative Z-Axis.

Parameters:
xradius - Radius along the X-Axis.
yradius - Radius along the Y-Axis.
vertices - Number of vertices that should be used.
Returns:
the created disk

createCog

public static Object3D createCog(int teeth)
Creates a cog that fits into a 1*1*1 cube. A cog is created so that it would turn around the Y-Axis.

Parameters:
teeth - Number of teeth.
Returns:
the created cog

createCog

public static Object3D createCog(int teeth,
                                 float holeRadius,
                                 float innerRadius,
                                 float outerRadius,
                                 float innerSpace,
                                 float outerSpace,
                                 float outerMovement,
                                 float height)
Creates a cog. A cog is created so that it would turn around the Y-Axis.

Parameters:
teeth - Number of teeth
holeRadius - Radius of the hole within the cog.
innerRadius - Radius without the theeth.
outerRadius - Radius with the teeth.
innerSpace - Factor of the size between teeth. Default is 1.
outerSpace - Factor of the size of teeth. Default is 1.
outerMovement - Turning of the teeth in radian. Default is 0.
height - Heihgt of the cog.
Returns:
the created cog

createTube

public static Object3D createTube(int quads)
Creates a tube along the Y-Axis. A tube is nothing else than a cylinder with an hole in it. This default tube has a innerRadius of 0.3, outer radius of 0.5 and a height of 1 (so wow, it would fit into a 1*1*1 cube).

Parameters:
quads - Number of quads that should be used. Don't use more than you need!
Returns:
the created cube

createTube

public static Object3D createTube(float innerRadius,
                                  float outerRadius,
                                  float height,
                                  int quads)
Creates a tube along the Y-Axis. A tube is nothing else than a cylinder with an hole in it.

Parameters:
innerRadius - Radius of the cylinder.
outerRadius - Radius of the hole.
height - Heihgt of the cylinder.
quads - Number of quads that should be used. Don't use more than you need!
Returns:
the created cube.

transformUVCoords

public static void transformUVCoords(Object3D obj,
                                     float uMove1,
                                     float vMove1,
                                     float uScale,
                                     float vScale,
                                     float uMove2,
                                     float vMove2)
Moves, scales and again moves uv coords on an Object3D object. To let this method work properly you have to follow these rules:
1. Never call strip() before
2. Use build(false) instead of build() method (you have to call it manually)
3. Call touch() on object to apply changes

Parameters:
obj - object whom uv coords should be scaled
uMove1 - u movement before scaling
vMove1 - v movement before scaling
uScale - scale factor for u coords
vScale - scale factor for v coords
uMove2 - u movement after scaling
vMove2 - v movement after scaling