com.threed.jpct
Class Object3D

java.lang.Object
  extended by com.threed.jpct.Object3D
All Implemented Interfaces:
java.io.Serializable

public class Object3D
extends java.lang.Object
implements java.io.Serializable

Object3D is a class for 3-dimensional objects. Don't let yourself fool by the similarity of the name to java.lang.Object. A 3-dimensional object as constructed by this class is usually added to an instance of World for rendering. One object should be added to only one instance of World at a time. Objects may be connected by defining them as childs/parents to build hierarchies among them. Dummy objects are also possible. They are usually not added to a World instance but binded to other objects (dummy or none-dummy). Some methods in this class require the instance to be added to an instance of World (using World.addObject()).

See Also:
World, Serialized Form

Field Summary
static boolean BILLBOARDING_DISABLED
          The object won't use billboarding (default)
static boolean BILLBOARDING_ENABLED
          The object will use billboarding (i.e. it always faces the camera)
static int COLLISION_CHECK_NONE
          Don't perform any kind of collision detection for this object
static int COLLISION_CHECK_OTHERS
          Other Object3Ds/rays/spheres/ellipsoids may collide with this object
static int COLLISION_CHECK_SELF
          This Object3D may collide with other objects
static boolean COLLISION_DETECTION_NOT_OPTIMIZED
          Disables (default) an automated optimization for collision detection in case of problems with this optimization.
static boolean COLLISION_DETECTION_OPTIMIZED
          Enables an automated optimization for speeding up collision detection in some case.
static float COLLISION_NONE
          Signals that no collision has been detected for this object
static boolean CULLING_DISABLED
          Backface culling won't be applied to this object
static boolean CULLING_ENABLED
          Backface culling will be applied to this object before rendering
static int ELLIPSOID_ALIGNED
          The object's ellipsoid won't be transformed when performing collision detection (default).
static int ELLIPSOID_TRANSFORMED
          The object's ellipsoid will be transformed when performing collision detection.
static boolean ENVMAP_DISABLED
          Environment mapping is disabled
static boolean ENVMAP_ENABLED
          Environment mapping is enabled
static int LIGHTING_ALL_ENABLED
          Indicates that all kinds of light (lightsources, ambient and additional color) will be used on this object.
static int LIGHTING_NO_LIGHTS
          Indicates that no lightsources will be taken into account to calculate an object's lighting.
static int NO_OBJECT
          The "ID" of an Object3D that doesn't exist.
static boolean OBJ_INVISIBLE
          The object is invisible and won't be processed, rendered...nothing...
static boolean OBJ_VISIBLE
          The object is visible
static float RAY_MISSES_BOX
          Signals that a ray/box-intersection test has failed (the ray doesn't intersect with the box)
static int SHADING_FAKED_FLAT
          Indicates that (faked) flat shading should be used.
static int SHADING_GOURAUD
          Indicates that gouraud shading should be used (default)
static boolean SPECULAR_DISABLED
          Specular highLights won't be calculated
static boolean SPECULAR_ENABLED
          Specular highLights will be calculated
static int TRANSPARENCY_MODE_ADD
          An alternative transparency mode for additive blending.
static int TRANSPARENCY_MODE_DEFAULT
          The default transparency mode.
static int UNKNOWN_OBJECTSIZE
          The object is empty
 
Constructor Summary
Object3D(float[] coordinates, float[] normals, float[] uvs, int[] indices, int textureId)
          Constructor for creating an Object3D out of indexed geometry in bulk form.
Object3D(float[] coordinates, float[] uvs, int[] indices, int textureId)
          Constructor for creating an Object3D out of indexed geometry in bulk form.
Object3D(int maxTriangles)
          Creates a new instance of Object3D.
Object3D(Object3D obj)
          This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class.
Object3D(Object3D obj, boolean reuseMesh)
          This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class.
 
Method Summary
 void addChild(Object3D obj)
          Defines an object as a child of this.
 void addCollisionListener(CollisionListener listener)
          Adds a collision listener to this object.
 void addParent(Object3D obj)
          Defines an object as a parent of this. this will inherit all transformations from its parent and no other attributes.
 int addTriangle(SimpleVector vert1, float u, float v, SimpleVector vert2, float u2, float v2, SimpleVector vert3, float u3, float v3)
          Adds a triangle to the object.
 int addTriangle(SimpleVector vert1, float u, float v, SimpleVector vert2, float u2, float v2, SimpleVector vert3, float u3, float v3, int textureID)
          Adds a triangle to the object.
 int addTriangle(SimpleVector vert1, float u, float v, SimpleVector vert2, float u2, float v2, SimpleVector vert3, float u3, float v3, int textureID, int sec)
          Adds a triangle to the object.
 int addTriangle(SimpleVector vert1, SimpleVector vert2, SimpleVector vert3)
          Adds a triangle to the object.
 int addTriangle(SimpleVector vert1, SimpleVector vert2, SimpleVector vert3, TextureInfo tInf)
          Adds a triangle to the object.
 void align(Camera camera)
          Aligns this object with a Camera using the camera's backbuffer matrix.
 void align(Object3D object)
          Aligns this object with another Object3D.
 void animate(float index)
          Calculates a new mesh for this object based on the keyframes of its animation sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last.
 void animate(float index, int seq)
          Calculates a new mesh for this object based on the keyframes of its animation sub-sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last (of the sub-sequence).
 void build()
          Initializes some basic object properties that are needed for almost all further processing. build() has to be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set, animations and vertex controllers assigned).
 void build(boolean staticUV)
          Initializes some basic object properties that are needed for almost all further processing. build() has to be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set, animations and vertex controllers assigned).
 void calcBoundingBox()
          Calculates an AABB (Axis Aligned Bounding Box) for this object in object-space.
 void calcCenter()
          Tries to calculate the center of the object using its mesh data.
 float calcMinDistance(SimpleVector org, SimpleVector dr)
          Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction.
 float calcMinDistance(SimpleVector org, SimpleVector dr, float ignoreIfLarger)
          Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction.
 void calcNormals()
          Calculates the object's vertex normals by calculating the face normals of the adjacent polygons of each vertex and averaging them.
 void calcTangentVectors()
          Tangent vectors are needed for some calculation in shaders.
 void calcTextureWrap()
          "Wraps" a texture around the object.
 void calcTextureWrapSpherical()
          "Wraps" a texture around the object in a spherical way.
 int checkForCollision(SimpleVector dirVec, float step)
          Checks if the current object collides with something when moving into a particular direction.
 SimpleVector checkForCollisionEllipsoid(SimpleVector translation, SimpleVector ellipsoid, int recursionDepth)
          Checks if the current object collides with something when moving into a particular direction.
 SimpleVector checkForCollisionSpherical(SimpleVector translation, float radius)
          Checks if the current object collides with something when moving into a particular direction.
 void clearAdditionalColor()
          Removes additional color information form the object.
 void clearAnimation()
          Clears the animation for this object.
 void clearObject()
          Clears the object by removing all vertex/mesh information from it.
 void clearRotation()
          Resets the current rotation to the initial value, i.e. no rotation at all.
 void clearShader()
          Removes a shader and reverts to the default shader set.
 void clearTranslation()
          Resets the current translation to the initial value, i.e. no translation at all.
 Object3D cloneObject()
          Clones the current object.
 void compile()
          Mainly needed to ease porting from the desktop version of jPCT.
 void compile(boolean dynamic)
          Mainly needed to ease porting from the desktop version of jPCT.
 void compile(boolean dynamic, boolean staticUV)
          Mainly needed to ease porting from the desktop version of jPCT.
static Object3D createDummyObj()
          Static method that creates a dummy Object3D.
 boolean cullingIsInverted()
          Returns true, if inverted culling is used on this object.
 void decoupleMesh()
          Decouples the current mesh from the object.
 void disableCollisionListeners()
          Disables all collision listeners of this object, so that none of them will be notified in case of a collision.
 void disableLazyTransformations()
          Disables "lazy transformations".
 void disableVertexSharing()
          Disables the automatic vertex sharing that jPCT does for triangles added by addTriangle.
 boolean ellipsoidIntersectsAABB(float orgx, float orgy, float orgz, SimpleVector ellipsoid)
           
 boolean ellipsoidIntersectsAABB(SimpleVector org, SimpleVector ellipsoid)
          Checks if a given ellipsoid intersects the axis aligned bounding box (in object-space) of this object.
 void enableCollisionListeners()
          (Re-)enables all collision listerner of this object.
 void enableLazyTransformations()
          Enables "lazy transformations".
 void forceGeometryIndices(boolean force)
          Forces the object to be compiled to indexed geometry no matter what.
 RGBColor getAdditionalColor()
          Returns the additional color.
 Animation getAnimationSequence()
          Returns the animation sequence.
 SimpleVector getCenter()
          Returns the center of the object (in object-space, i.e. unaffected by any transformation).
 java.util.Iterator<CollisionListener> getCollisionListeners()
          Returns the collision listeners of this object as an Iterator.
 boolean getCulling()
          Returns the current culling mode.
 int getEllipsoidMode()
          Returns the current ellipsoid mode.
 int getID()
          Returns the object's ID.
 Matrix getInverseWorldTransformation()
           
 Matrix getInverseWorldTransformation(Matrix mat)
           
 int getLightCount()
          Returns the number of lights that have an influence on this object.
 int getLighting()
          Gets the lighting mode.
 int getMaxLights()
          Returns the maximum number of lights that should have an influence on this object.
 Mesh getMesh()
          Returns the current mesh of the object.
 java.lang.String getName()
          Returns the name of the object.
static int getNextID()
          Static method that returns the ID the next object will get.
 OcTree getOcTree()
          Returns the OcTree assigned to this object or null, if none has been assigned.
 SimpleVector getOrigin()
          Returns the origin of the object (as set by setOrigin()).
 Matrix getOriginMatrix()
          Returns the object's origin-translation matrix.
 Object3D[] getParents()
          Returns all parents of this Object3D in an array.
 PolygonManager getPolygonManager()
          Returns the PolygonManager for this object.
 IRenderHook getRenderHook()
          Returns the render hook or null, if none has been set.
 Matrix getRotationMatrix()
          Returns the object's current rotation matrix.
 SimpleVector getRotationPivot()
          Returns the rotation pivot of the object
 float getScale()
          Returns the cumulated scale value for this object.
 GLSLShader getShader()
          Returns the shader, if another one than the default shader is set.
 boolean getSpecularLighting()
          Returns the state of specular lighting.
 Matrix getTextureMatrix()
          Returns the current texture matrix of null if none is set.
 SimpleVector getTransformedCenter()
          Returns the center of the object in worldspace, i.e. after the object's current transformations have been applied to it.
 SimpleVector getTransformedCenter(SimpleVector toFill)
          Returns the center of the object in worldspace, i.e. after the object's current transformations have been applied to it.
 SimpleVector getTranslation()
          Returns the translation of the object (from its origin to its current position)
 SimpleVector getTranslation(SimpleVector trns)
          Returns the translation of the object.
 Matrix getTranslationMatrix()
          Returns the object's current translation matrix.
 int getTransparency()
          Returns the current tranparency setting.
 int getTransparencyMode()
          Returns the current transparency mode.
 java.lang.Object getUserObject()
          Return the user defined object.
 Virtualizer getVirtualizer()
          Returns the current Virtualizer.
 boolean getVisibility()
          Returns the current visibility state of the object.
 Matrix getWorldTransformation()
          Returns the transformation matrix used to transform the object from objectspace into worldspace.
 Matrix getWorldTransformation(Matrix mat)
          Variant of getWorldTransformation() to avoid the creation of an additional matrix where not needed.
 SimpleVector getXAxis()
          Returns the x-axis of the object.
 SimpleVector getXAxis(SimpleVector toFill)
          Returns the x-axis of the object.
 SimpleVector getYAxis()
          Returns the y-axis of the object.
 SimpleVector getYAxis(SimpleVector toFill)
          Returns the y-axis of the object.
 SimpleVector getZAxis()
          Returns the z-axis of the object.
 SimpleVector getZAxis(SimpleVector toFill)
          Returns the z-axis of the object.
 boolean hasChild(Object3D obj)
          Tests an object for being a child object of the current object.
 boolean hasParent(Object3D obj)
          Tests an object for being a parent object of the current object.
 boolean hasVertexAlpha()
          Returns true, if this object uses vertex alpha values.
 void invert()
          Physically "inverts" the object, which means that the backface culling works the other way round.
 void invertCulling(boolean inv)
          Inverts culling order if set to true.
 boolean isAlphaWrites()
          Should alpha writes be used?
 boolean isEnvmapped()
          Returns if environment mapping is used or not.
 boolean isTransparent()
          Returns if the object is transparent of not.
static Object3D mergeAll(Object3D... objs)
          Merges all objects in the array into one large object.
static Object3D mergeObjects(Object3D first, Object3D second)
          Static method that merges two objects into a third one.
 float rayIntersectsAABB(SimpleVector org, SimpleVector dr)
          Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object.
 float rayIntersectsAABB(SimpleVector org, SimpleVector dr, boolean isNormalized)
          Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object.
 void removeChild(Object3D obj)
          Removes an object from the child-collection of this.
 void removeCollisionListener(CollisionListener listener)
          Removes a collision listener from the list of listeners.
 void removeParent(Object3D obj)
          Removes an object from the parent-collection of this.
 void resetCollisionStatus()
          Sets the indicator that the object was a target of the last collision detection to false, i.e. the object won't be recognized any longer as part of the collision.
static void resetNextID()
          Resets the internal object-counter.
 void rotateAxis(SimpleVector axis, float angle)
          Rotates the object's rotation matrix around an arbitrary axis.
 void rotateMesh()
          Rotates the raw mesh data using the rotation matrix specified for this object.
 void rotateX(float w)
          Rotates the object's rotation matrix around the x-axis by the given angle w (radian, counter clockwise for positive values).
 void rotateY(float w)
          Rotates the object's rotation matrix around the y-axis by the given angle w (radian, clockwise for positive values).
 void rotateZ(float w)
          Rotates the object's rotation matrix around the z-axis by the given angle w (radian, counter clockwise for positive values).
 void scale(float scale)
          Scales the object.
 void setAdditionalColor(int red, int green, int blue)
          Sets the additional color for this object.
 void setAdditionalColor(RGBColor col)
          Sets the additional color for this object.
 void setAlphaWrites(boolean alphaWrites)
          Enabled/Disables alpha writes by this object into the framebuffer.
 void setAnimationSequence(Animation anim)
          Sets the keyframe animation sequence that should be used for this object.
 void setBillboarding(boolean mode)
          Enables/disables billboarding for this object.
 void setBoundingBox(float minx, float maxx, float miny, float maxy, float minz, float maxz)
          Sets a new AABB for the object.
 void setCenter(SimpleVector center)
          Sets the center of the object (in object-space).
 void setCollisionMode(int mode)
          Sets if and how the object will respond to collisions.
 void setCollisionOptimization(boolean optimized)
          Sets an optimization for collision detection to be used/not used.
 void setCulling(boolean mode)
          Enables/Disables backface culling for the current object.
 void setEllipsoidMode(int mode)
          When doing ellipsoid collision detection with this object, the ellipsoid can be transformed according to the objects's transformation and in the source's object space or it remains static in the target's object space (i.e.
 void setEnvmapped(boolean mode)
          Enables/Disables environment mapping for the object.
 void setFixedPointMode(boolean useFixedPoint)
          If set to true, some operations will be using fixed point instead of floating point.
 void setLighting(int mode)
          Sets the lighting mode.
 void setMaxLights(int lightCount)
          Sets the maximum number of lights that should have an influence on this object.
 void setMesh(Mesh mesh)
          Sets an object's mesh to another one.
 void setName(java.lang.String n)
          Sets the name of the object to a name other than the default one.
static void setNextID(int next)
          Sets the ID the next object will get.
 void setOcTree(OcTree ocTree)
          Assigns an octree to the object.
 void setOrientation(SimpleVector dir, SimpleVector up)
          Sets the orientation of this object by giving a direction and an up-vector.
 void setOrigin(SimpleVector origin)
          Sets the origin of the object.
 void setRenderHook(IRenderHook hook)
          Sets a new hook into the rendering pipeline.
 void setRotationMatrix(Matrix mat)
          Sets the rotation matrix for the object.
 void setRotationPivot(SimpleVector pivot)
          Sets the rotation pivot of the object.
 void setScale(float absScale)
          Sets an absolute value for the object's scaling.
 void setShader(GLSLShader shader)
          Sets a shader other than the default shader set.
 void setShadingMode(int mode)
          jPCT always uses gouraud shading and that can't be disabled.
 void setSortOffset(float offset)
          Sets on offset for the z-Sorting.
 void setSpecularLighting(boolean mode)
          Enables/Disables specular lighting for the object.
 void setTexture(java.lang.String texname)
          Sets the texture for the object.
 void setTexture(TextureInfo tInf)
          Sets the texture for the object via an instance of TextureInfo.
 void setTextureMatrix(Matrix mat)
          Sets a matrix that is applied to transform the texture in stage 0.
 void setTranslationMatrix(Matrix mat)
          Sets the translation matrix for the object.
 void setTransparency(int trans)
          Sets the object to be transparent using the given level of transparency.
 void setTransparencyMode(int mode)
          Sets the transparency (blending) mode.
 void setUserObject(java.lang.Object obj)
          This method is a "workaround" in case you want to give additional information to an Object3D but don't want to (or can't) extend Object3D itself.
 void setVirtualizer(Virtualizer virtualizer)
          Sets a virtualizer for this object's geometry.
 void setVisibility(boolean mode)
          Sets the object to visible/invisible.
 void shareCompiledData(Object3D withObj)
          Enables a compiled object to share data with another compiled one.
 void shareTextureData(Object3D source)
          In addition to sharing the actual mesh data, you can also make objects share the same texturing information (the actual textures, not the uv-coordinates).
 boolean sphereIntersectsAABB(SimpleVector org, float radius)
          Checks if a given sphere intersects the axis aligned bounding box (in object-space) of this object.
 void strip()
          Frees some memory by stripping some data that isn't needed anymore unless you want to modify the object afterwards by using a PolygonManager.
 void touch()
          Touches an object.
 void translate(float x, float y, float z)
          Translates ("moves") the object in worldspace by modifying the translation matrix.
 void translate(SimpleVector trans)
          Translates ("moves") the object in worldspace by modifying the translation matrix.
 void translateMesh()
          Translates the raw mesh data using the translation and the origin matrix of this object.
 boolean wasTargetOfLastCollision()
          True, if this object was a target of the last collision detection that took place (regardless of what kind it was).
 boolean wasVisible()
          Returns if the object was visible (or at least supposed to be) in the last frame.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENVMAP_ENABLED

public static final boolean ENVMAP_ENABLED
Environment mapping is enabled

See Also:
Constant Field Values

ENVMAP_DISABLED

public static final boolean ENVMAP_DISABLED
Environment mapping is disabled

See Also:
Constant Field Values

TRANSPARENCY_MODE_DEFAULT

public static final int TRANSPARENCY_MODE_DEFAULT
The default transparency mode.

See Also:
Constant Field Values

TRANSPARENCY_MODE_ADD

public static final int TRANSPARENCY_MODE_ADD
An alternative transparency mode for additive blending.

See Also:
Constant Field Values

BILLBOARDING_ENABLED

public static final boolean BILLBOARDING_ENABLED
The object will use billboarding (i.e. it always faces the camera)

See Also:
Constant Field Values

BILLBOARDING_DISABLED

public static final boolean BILLBOARDING_DISABLED
The object won't use billboarding (default)

See Also:
Constant Field Values

CULLING_ENABLED

public static final boolean CULLING_ENABLED
Backface culling will be applied to this object before rendering

See Also:
Constant Field Values

CULLING_DISABLED

public static final boolean CULLING_DISABLED
Backface culling won't be applied to this object

See Also:
Constant Field Values

SPECULAR_ENABLED

public static final boolean SPECULAR_ENABLED
Specular highLights will be calculated

See Also:
Constant Field Values

SPECULAR_DISABLED

public static final boolean SPECULAR_DISABLED
Specular highLights won't be calculated

See Also:
Constant Field Values

OBJ_VISIBLE

public static final boolean OBJ_VISIBLE
The object is visible

See Also:
Constant Field Values

OBJ_INVISIBLE

public static final boolean OBJ_INVISIBLE
The object is invisible and won't be processed, rendered...nothing...

See Also:
Constant Field Values

COLLISION_CHECK_NONE

public static final int COLLISION_CHECK_NONE
Don't perform any kind of collision detection for this object

See Also:
Constant Field Values

COLLISION_CHECK_OTHERS

public static final int COLLISION_CHECK_OTHERS
Other Object3Ds/rays/spheres/ellipsoids may collide with this object

See Also:
Constant Field Values

COLLISION_CHECK_SELF

public static final int COLLISION_CHECK_SELF
This Object3D may collide with other objects

See Also:
Constant Field Values

COLLISION_NONE

public static final float COLLISION_NONE
Signals that no collision has been detected for this object

See Also:
Constant Field Values

RAY_MISSES_BOX

public static final float RAY_MISSES_BOX
Signals that a ray/box-intersection test has failed (the ray doesn't intersect with the box)

See Also:
Constant Field Values

COLLISION_DETECTION_OPTIMIZED

public static final boolean COLLISION_DETECTION_OPTIMIZED
Enables an automated optimization for speeding up collision detection in some case. May cause problems on dynamically changing geometry.

See Also:
Constant Field Values

COLLISION_DETECTION_NOT_OPTIMIZED

public static final boolean COLLISION_DETECTION_NOT_OPTIMIZED
Disables (default) an automated optimization for collision detection in case of problems with this optimization.

See Also:
Constant Field Values

SHADING_GOURAUD

public static final int SHADING_GOURAUD
Indicates that gouraud shading should be used (default)

See Also:
Constant Field Values

SHADING_FAKED_FLAT

public static final int SHADING_FAKED_FLAT
Indicates that (faked) flat shading should be used. Faked, because it sits on top of gouraud, i.e. it's not faster than using gouraud shading. In fact it may be slower because it hinders the usage of triangle strips.

See Also:
Constant Field Values

LIGHTING_ALL_ENABLED

public static final int LIGHTING_ALL_ENABLED
Indicates that all kinds of light (lightsources, ambient and additional color) will be used on this object. This is default.

See Also:
Constant Field Values

LIGHTING_NO_LIGHTS

public static final int LIGHTING_NO_LIGHTS
Indicates that no lightsources will be taken into account to calculate an object's lighting. Ambient light and the additional color will be used.

See Also:
Constant Field Values

ELLIPSOID_ALIGNED

public static final int ELLIPSOID_ALIGNED
The object's ellipsoid won't be transformed when performing collision detection (default).

See Also:
Constant Field Values

ELLIPSOID_TRANSFORMED

public static final int ELLIPSOID_TRANSFORMED
The object's ellipsoid will be transformed when performing collision detection.

See Also:
Constant Field Values

UNKNOWN_OBJECTSIZE

public static final int UNKNOWN_OBJECTSIZE
The object is empty

See Also:
Constant Field Values

NO_OBJECT

public static final int NO_OBJECT
The "ID" of an Object3D that doesn't exist. If a method that usually returns an Object-ID returns this value, no appropiate Object3D has been found.

See Also:
Constant Field Values
Constructor Detail

Object3D

public Object3D(float[] coordinates,
                float[] uvs,
                int[] indices,
                int textureId)
Constructor for creating an Object3D out of indexed geometry in bulk form. This can be useful to create an Object3D at once from data loaded by one's own file loader.

Parameters:
coordinates - the coordinates [x1,y1,z1,x2,y2,z2,...]
uvs - the texture coordinates [u1,v1,u2,v2,...]
indices - the indices indexing the tuples/triples in the coordinate arrays
textureId - the texture id. If not known, just use TextureManager.TEXTURE_NOTFOUND

Object3D

public Object3D(float[] coordinates,
                float[] normals,
                float[] uvs,
                int[] indices,
                int textureId)
Constructor for creating an Object3D out of indexed geometry in bulk form. This can be useful to create an Object3D at once from data loaded by one's own file loader.

Parameters:
coordinates - the coordinates [x1,y1,z1,x2,y2,z2,...]
normals - the vertex normals [nx1,ny1,nz1,nx2,ny2,nz2,...]
uvs - the texture coordinates [u1,v1,u2,v2,...]
indices - the indices indexing the tuples/triples in the coordinate arrays
textureId - the texture id. If not known, just use TextureManager.TEXTURE_NOTFOUND

Object3D

public Object3D(int maxTriangles)
Creates a new instance of Object3D. Usually, an object is created to be added to some instance of World. You may also create dummy objects, that are just "lending" there transformations to their child-objects, but this should be done by using createDummyObj().

Parameters:
maxTriangles - the maximum number of triangles for this object.
See Also:
createDummyObj()

Object3D

public Object3D(Object3D obj)
This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class. Consider this to be a kind of "workaround" for the fact that you can't extend a loaded (by Loader) or created (by Primitives) Object3D directly. Please note that this doesn't work on stripped objects until you set their meshes to locked.

Parameters:
obj - the Object3D to construct this Object3D from

Object3D

public Object3D(Object3D obj,
                boolean reuseMesh)
This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class. Consider this to be a kind of "workaround" for the fact that you can't extend a loaded (by Loader) or created (by Primitives) Object3D directly.Please note that this doesn't work on stripped objects until you set their meshes to locked.

Parameters:
obj - the Object3D to construct this Object3D from
reuseMesh - if true, the new object will use the same mesh
Method Detail

createDummyObj

public static Object3D createDummyObj()
Static method that creates a dummy Object3D. This dummy object is basically a normal but empty object. This method should be used to create an object that won't be added to the world but linked to another object as a child object. This could be useful to enhance the flexiblity of the object bindings (like a moon spinning around a planet...it may be useful to link the moon to the planet via a dummy object placed in the planet's center. This enables the moon not only to inherit the transformations of the planet but also the transformations of the dummy object). There is no need nor any sense in adding a dummy object directly to the world.

Returns:
a dummy Object3D
See Also:
World.addObject(com.threed.jpct.Object3D)

setVirtualizer

public void setVirtualizer(Virtualizer virtualizer)
Sets a virtualizer for this object's geometry. By default, none is set.

Parameters:
virtualizer - the virtualizer

getVirtualizer

public Virtualizer getVirtualizer()
Returns the current Virtualizer. By default, none is set.

Returns:
the virtualizer or null

setUserObject

public void setUserObject(java.lang.Object obj)
This method is a "workaround" in case you want to give additional information to an Object3D but don't want to (or can't) extend Object3D itself.

Parameters:
obj - Object whatever you like...

getUserObject

public java.lang.Object getUserObject()
Return the user defined object.

Returns:
Object the Object

setSortOffset

public void setSortOffset(float offset)
Sets on offset for the z-Sorting. Usually this is not needed, but it could be helpful for transparent objects that are sorted incorrectly otherwise.

Parameters:
offset - the offset

mergeObjects

public static Object3D mergeObjects(Object3D first,
                                    Object3D second)
Static method that merges two objects into a third one. This should be done before calling build() on any of these objects and it does not copy other properties of the object (like rendering modes etc...).
Merging objects is quite expensive in terms of memory usage. Merged objects are not compressed by default.

Parameters:
first - the first object to merge
second - the second object to merge
Returns:
the merged object

mergeAll

public static Object3D mergeAll(Object3D... objs)
Merges all objects in the array into one large object. The array will be empty afterwards.

Parameters:
objs - the objects
Returns:
the merged result

resetNextID

public static void resetNextID()
Resets the internal object-counter.


getNextID

public static int getNextID()
Static method that returns the ID the next object will get. This is useful to know if (and only if) you want to serialize your world, because this value isn't serialized by default.

Returns:
the ID

setNextID

public static void setNextID(int next)
Sets the ID the next object will get. It has to be higher than the current one. This method can be used to deserialize a world. Be careful when using this method, because screwing up the IDs will most likely screw up everything else.

Parameters:
next - the next ID

compile

public void compile()
Mainly needed to ease porting from the desktop version of jPCT. By default, jPCT-AE does this call automatically, so usually there's no need to call this method directly.


compile

public void compile(boolean dynamic)
Mainly needed to ease porting from the desktop version of jPCT. By default, jPCT-AE does this call automatically, so usually there's no need to call this method directly.

Parameters:
dynamic - if the mesh dynamic?

compile

public void compile(boolean dynamic,
                    boolean staticUV)
Mainly needed to ease porting from the desktop version of jPCT. By default, jPCT-AE does this call automatically, so usually there's no need to call this method directly.

Parameters:
dynamic - if the mesh dynamic?
staticUV - does it use static uv-coordinates

shareCompiledData

public void shareCompiledData(Object3D withObj)
Enables a compiled object to share data with another compiled one. This helps to save system or GPU memory, depending on the used mode for compilation.
The object you would like to share data with must not share data itself with some other, it must not use an octree. Furthermore, both objects have to use the same mesh (not just the same data but the exact same instance), this object must not share data with some other.
This object will inherit all texture coordinates and vertex alpha values from the source object no matter what may have been assigned to it.

Parameters:
withObj - the object to share data with

touch

public void touch()
Touches an object. This has a meaning for dynamically compiled objects and for objects that use lazy transformations. If touched, changes in vertices (and u/v-coordinates if supported) will be retransfered to the graphics card and the transformation matrices of objects using lazy transformations will be recalculated.


strip

public void strip()
Frees some memory by stripping some data that isn't needed anymore unless you want to modify the object afterwards by using a PolygonManager.


forceGeometryIndices

public void forceGeometryIndices(boolean force)
Forces the object to be compiled to indexed geometry no matter what. Default is false and jPCT will try to figure out, what is best for an object. If this is true, it will override this detection. Compiling to indexed geometry is more expensive, the result might be smaller in memory and depending on the device, it will be rendered faster or slower...
This has to be set before calling build() to have an effect.

Parameters:
force - should we?

setAnimationSequence

public void setAnimationSequence(Animation anim)
Sets the keyframe animation sequence that should be used for this object. It is required that the object is already initialized with a frame (usually the first) of the animation including texture-coords, -data and mesh information. The keyframes of an animation only contain the raw mesh data (like getMesh() would return it). Everything else needs to be taken from the object itself.

Parameters:
anim - the animation sequence
See Also:
Animation, getMesh()

clearAnimation

public void clearAnimation()
Clears the animation for this object. The object ist no longer animated. Its mesh data will be that of the last frame interpolation.


getAnimationSequence

public Animation getAnimationSequence()
Returns the animation sequence.

Returns:
the Animation sequence or null if none has been defined

animate

public void animate(float index,
                    int seq)
Calculates a new mesh for this object based on the keyframes of its animation sub-sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last (of the sub-sequence). If seq is zero, the whole animation will be treated as a sub-sequence.

Parameters:
index - the "time-index" into the sub-sequence of the animation
seq - the number of the sub.sequence (sub-sequence start at 1, 0 stands for the animation as a whole)

animate

public void animate(float index)
Calculates a new mesh for this object based on the keyframes of its animation sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last. Because no sub-sequence is indicated, the complete animation will be used.

Parameters:
index - the "time-index" into the animation

setCollisionMode

public void setCollisionMode(int mode)
Sets if and how the object will respond to collisions. Setting mode to COLLISION_CHECK_NONE (which is default) means, that the object can't be partner in a collision with other objects. Setting it to COLLISION_CHECK_OTHERS means that other objects may collide with this object and setting it to COLLISION_CHECK_SELF means, that the object itself may collide with other objects. The modes may be combined by using the or-operator | .

Parameters:
mode - The desired mode (COLLISION_CHECK_NONE, COLLISION_CHECK_OTHERS, COLLISION_CHECK_SELF or combinations)
See Also:
COLLISION_CHECK_NONE, COLLISION_CHECK_OTHERS, COLLISION_CHECK_SELF

setCollisionOptimization

public void setCollisionOptimization(boolean optimized)
Sets an optimization for collision detection to be used/not used. This optimization may cause problems on dynamically updated geometry from an animation or an IVertexController. Therefor, it's disabled by default. Couldn't hurt to try it anyway...:-)
This optimization affects collisions WITH this object, not OF this object.

Parameters:
optimized - should the collision detection be optimized or not
See Also:
COLLISION_DETECTION_OPTIMIZED, COLLISION_DETECTION_NOT_OPTIMIZED

setVisibility

public void setVisibility(boolean mode)
Sets the object to visible/invisible. Invisible objects won't be processed/rendered at all.

Parameters:
mode - visible or not
See Also:
OBJ_VISIBLE, OBJ_INVISIBLE

getVisibility

public boolean getVisibility()
Returns the current visibility state of the object.

Returns:
object is visible/invisible
See Also:
OBJ_VISIBLE, OBJ_INVISIBLE

calcBoundingBox

public void calcBoundingBox()
Calculates an AABB (Axis Aligned Bounding Box) for this object in object-space. The box will then be transformed together with the object so that it becomes an OBB (oriented bounding box) when the object will be transformed. Normally, there is no need to call this method directly, because it will already be called from the build() method. Exceptions could be the use of objects meshes for animation and similar tasks.

See Also:
build()

build

public void build()
Initializes some basic object properties that are needed for almost all further processing. build() has to be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set, animations and vertex controllers assigned).

See Also:
World.buildAllObjects()

build

public void build(boolean staticUV)
Initializes some basic object properties that are needed for almost all further processing. build() has to be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set, animations and vertex controllers assigned).
This method is a special purpose method that has to be used if the UV-coordinates are supposed to be modified.

See Also:
build()

disableVertexSharing

public void disableVertexSharing()
Disables the automatic vertex sharing that jPCT does for triangles added by addTriangle. This can be useful if single polygons of the object are supposed to change their positions independantly from the others (by using an IVertexController for example). It will hurt performance though.


hasChild

public boolean hasChild(Object3D obj)
Tests an object for being a child object of the current object. A child object inherits all the transformations of its parent.

Parameters:
obj - the object that should be tested for being a child of this
Returns:
true, if obj is a child. Otherwise false.
See Also:
hasParent(com.threed.jpct.Object3D)

hasParent

public boolean hasParent(Object3D obj)
Tests an object for being a parent object of the current object. The object inherits all the transformations from its parent object.

Parameters:
obj - the object that should be tested for being a parent of this
Returns:
true, if obj is a parent. Otherwise false.
See Also:
hasChild(com.threed.jpct.Object3D)

addChild

public void addChild(Object3D obj)
Defines an object as a child of this. A child object will inherit all transformations but no other attributes of this object.

Parameters:
obj - the object that should become a child of this.

removeChild

public void removeChild(Object3D obj)
Removes an object from the child-collection of this. The object itself won't be removed.

Parameters:
obj - the Object3D to remove

removeParent

public void removeParent(Object3D obj)
Removes an object from the parent-collection of this. The object itself won't be removed.

Parameters:
obj - the Object3D to remove

addParent

public void addParent(Object3D obj)
Defines an object as a parent of this. this will inherit all transformations from its parent and no other attributes. Defining child and parent object is basically the same. Child object of A will internally be stored by assigning A as their parent. It's a matter of taste which kind of logic one may use. Therefor, both are supported but the parent-logic is closer to the implementation...then again: Who cares?

Parameters:
obj - the object that should become a parent of this.

getParents

public Object3D[] getParents()
Returns all parents of this Object3D in an array.

Returns:
all parents

getID

public int getID()
Returns the object's ID. The ID is automatically generated and set in the constructor. This ID is used to manage the object once it has been added to an instance of World. In some cases, it could be necessary to reset the ID.

Returns:
the internal ID of the object
See Also:
resetNextID(), World.addObject(com.threed.jpct.Object3D)

getName

public java.lang.String getName()
Returns the name of the object. By default, this is set to "object" plus the object's internal ID. It may be overwritten using setName().

Returns:
the name of the object
See Also:
setName(java.lang.String)

setName

public void setName(java.lang.String n)
Sets the name of the object to a name other than the default one. The name may be used to identify the object in the world's collection of objects. Therefore, the name has to be unique.

Parameters:
n - the new name of the object
See Also:
World.getObjectByName(java.lang.String)

wasVisible

public boolean wasVisible()
Returns if the object was visible (or at least supposed to be) in the last frame. This can be useful for some rough optimizations on the application level, but beware of assuming too much frame coherence. The method doesn't take overdraw into account.

Returns:
true if it was visible

setCulling

public void setCulling(boolean mode)
Enables/Disables backface culling for the current object. Backface culling is applied to all objects by default. Anyway, some objects may require it to be disabled because of the way they are build. Disabling backface culling for any object usually double the amount of rendered polygons for this object.

Parameters:
mode - the culling mode
See Also:
CULLING_ENABLED, CULLING_DISABLED

getCulling

public boolean getCulling()
Returns the current culling mode.

Returns:
boolean
See Also:
CULLING_ENABLED, CULLING_DISABLED

setShadingMode

public void setShadingMode(int mode)
jPCT always uses gouraud shading and that can't be disabled. Anyway, with this method it's possible to enable a kind of faked flat shading. It will look like flat shading, but it isn't any faster than gouraud. It may even be slower, because triangle strips and some other optimizations jPCT can apply are disabled when using faked flat shading.

Parameters:
mode - the shading mode
See Also:
SHADING_GOURAUD, SHADING_FAKED_FLAT

setLighting

public void setLighting(int mode)
Sets the lighting mode. Default is, that all kinds of light jPCT knows of will influence the final lighting of the object.

Parameters:
mode - the lighting mode
See Also:
LIGHTING_ALL_ENABLED, LIGHTING_NO_LIGHTS

getLighting

public int getLighting()
Gets the lighting mode.

See Also:
LIGHTING_ALL_ENABLED, LIGHTING_NO_LIGHTS

setMaxLights

public void setMaxLights(int lightCount)
Sets the maximum number of lights that should have an influence on this object. This value affects compiled objects only. Default and global max. value is 8.

Parameters:
lightCount - a value between 0 and 8

getMaxLights

public int getMaxLights()
Returns the maximum number of lights that should have an influence on this object. Default is 8.

Returns:
the number of lights

setSpecularLighting

public void setSpecularLighting(boolean mode)
Enables/Disables specular lighting for the object. The specular lighting pass is applied in addition to ambient and diffuse lighting. Specular lighting may cause objects to look more reflective and realistic. It requires some extra processing but usually it's just a matter of taste if it will be used on a particular object or not. Specular lighting is disabled by default.

Parameters:
mode - the specular mode
See Also:
SPECULAR_ENABLED, SPECULAR_DISABLED

getSpecularLighting

public boolean getSpecularLighting()
Returns the state of specular lighting.

Returns:
the specular mode
See Also:
SPECULAR_ENABLED, SPECULAR_DISABLED

setTransparency

public void setTransparency(int trans)
Sets the object to be transparent using the given level of transparency. In addition to the global transparency of the whole object, every pixel with a color of #000000 will be completely transparent (if you don't supply an alpha channel with the texture). Note: The current implementation doesn't use #000000 but #0f0f0f due to accuracy issues with JPEG-compression.

Parameters:
trans - the tranparency level. 0 is the highest possible transparency, a value below 0 will disable tranparency for this object

setShader

public void setShader(GLSLShader shader)
Sets a shader other than the default shader set. This is only valid when using OpenGL ES 2.0.

Parameters:
shader - the shader

getShader

public GLSLShader getShader()
Returns the shader, if another one than the default shader is set. This is only valid when using OpenGL ES 2.0.

Returns:
the shader or null if none is set

calcTangentVectors

public void calcTangentVectors()
Tangent vectors are needed for some calculation in shaders. If you are using shaders (i.e. OpenGL ES 2.0) and your shader needs these vectors and jPCT-AE wasn't able to detect this (by searching for "attribute vec4 tangent" in the vertex shader, you might want to trigger this calculation manually. By default, the calculation happens automatically during build() if the need has been detected.


clearShader

public void clearShader()
Removes a shader and reverts to the default shader set. This is only valid when using OpenGL ES 2.0.


getTransparency

public int getTransparency()
Returns the current tranparency setting.

Returns:
int the transparency level

isTransparent

public boolean isTransparent()
Returns if the object is transparent of not.

Returns:
is it?

setTransparencyMode

public void setTransparencyMode(int mode)
Sets the transparency (blending) mode.

Parameters:
mode - the mode
See Also:
TRANSPARENCY_MODE_DEFAULT, TRANSPARENCY_MODE_ADD

getTransparencyMode

public int getTransparencyMode()
Returns the current transparency mode.

Returns:
int the mode
See Also:
TRANSPARENCY_MODE_DEFAULT, TRANSPARENCY_MODE_ADD

hasVertexAlpha

public boolean hasVertexAlpha()
Returns true, if this object uses vertex alpha values. False, if it doesn't, which is default.

Returns:
does it?

setAlphaWrites

public void setAlphaWrites(boolean alphaWrites)
Enabled/Disables alpha writes by this object into the framebuffer. This applies to transparent object on transparent framebuffers only. Default is true.

Parameters:
alphaWrites - do alpha writes or not

isAlphaWrites

public boolean isAlphaWrites()
Should alpha writes be used?

Returns:
should it?

setAdditionalColor

public void setAdditionalColor(RGBColor col)
Sets the additional color for this object. This color will be added to the regular color of each vertex (given by ambient, diffuse and specular lighting). This can be used to highlight particular objects on purpose. The limitation to the range of the AWT's Color doesn't matter here, because adding a color brighter than (255,255,255) (jPCT supports this overbright lighting) can be useful for lightsources but not for setting a color value that isn't processed any further. It simply doesn't get whiter than white...:-)

Parameters:
col - the color

setAdditionalColor

public void setAdditionalColor(int red,
                               int green,
                               int blue)
Sets the additional color for this object. This color will be added to the regular color of each vertex (given by ambient, diffuse and specular lighting). This can be used to highlight particular objects on purpose.

Parameters:
red - the red component (0..255)
green - the green component (0..255)
blue - the blue component (0..255)

getAdditionalColor

public RGBColor getAdditionalColor()
Returns the additional color.

Returns:
the color

clearAdditionalColor

public void clearAdditionalColor()
Removes additional color information form the object. Calling this method is equal to call setAdditionalColor(Color.black).


clearObject

public void clearObject()
Clears the object by removing all vertex/mesh information from it. This also affects objects that have been cloned from this object, because they will lose their mesh-data too. Every other property of the object stays intact.

See Also:
cloneObject(), decoupleMesh()

decoupleMesh

public void decoupleMesh()
Decouples the current mesh from the object. This may be useful to assign another mesh to the object without affecting cloned objects (from this object). Without the use of cloned objects, the results of clearObject() and decoupleMesh() are the same (= an empty object).

See Also:
cloneObject(), clearObject()

setBillboarding

public void setBillboarding(boolean mode)
Enables/disables billboarding for this object. A billboarded object will ingore its own rotation matrix and will always face the camera.

Parameters:
mode - the billboarding mode
See Also:
BILLBOARDING_ENABLED, BILLBOARDING_DISABLED

isEnvmapped

public boolean isEnvmapped()
Returns if environment mapping is used or not.

Returns:
used...or not...
See Also:
ENVMAP_ENABLED, ENVMAP_DISABLED

setEnvmapped

public void setEnvmapped(boolean mode)
Enables/Disables environment mapping for the object. If enabled, the texturemap assigned to the object will be used as a spherical environment map.

Parameters:
mode - the environment mapping mode
See Also:
ENVMAP_ENABLED, ENVMAP_DISABLED

setFixedPointMode

public void setFixedPointMode(boolean useFixedPoint)
If set to true, some operations will be using fixed point instead of floating point. This is less accurate and may cause problems with large coordinates, but is usually faster. Default is true.

Parameters:
useFixedPoint - use it?

rotateX

public void rotateX(float w)
Rotates the object's rotation matrix around the x-axis by the given angle w (radian, counter clockwise for positive values). This rotation is then applied to the object when it's rendered the next time.

Parameters:
w - the angle by which should be rotated

rotateY

public void rotateY(float w)
Rotates the object's rotation matrix around the y-axis by the given angle w (radian, clockwise for positive values). This rotation is then applied to the object when it's rendered the next time.

Parameters:
w - the angle by which should be rotated

rotateZ

public void rotateZ(float w)
Rotates the object's rotation matrix around the z-axis by the given angle w (radian, counter clockwise for positive values). This rotation is then applied to the object when it's rendered the next time.

Parameters:
w - the angle by which should be rotated

rotateAxis

public void rotateAxis(SimpleVector axis,
                       float angle)
Rotates the object's rotation matrix around an arbitrary axis. The method is more powerful than the normal rotate-around-an-axis methods, but also a bit slower. The resulting matrix will be orthonormalized to ensure numerical stability.

Parameters:
axis - a direction-vector pointing into the axis direction with the object's rotation pivot as position vector
angle - the angle of the rotation

translateMesh

public void translateMesh()
Translates the raw mesh data using the translation and the origin matrix of this object. This translation is applied directly onto the mesh and therefor it's permanent. This could be useful for defining animation keyframes via object meshes or for altering objects in objectspace. Translating a mesh forces the object's bounding box to be recalculated afterwards (automatically done).


translate

public void translate(SimpleVector trans)
Translates ("moves") the object in worldspace by modifying the translation matrix. The translation will be applied the next time the object is rendered.

Parameters:
trans - the translation vector

translate

public void translate(float x,
                      float y,
                      float z)
Translates ("moves") the object in worldspace by modifying the translation matrix. The translation will be applied the next time the object is rendered.

Parameters:
x - the number of units the object should be translated parallel to the x axis
y - the number of units the object should be translated parallel to the y axis
z - the number of units the object should be translated parallel to the z axis

align

public void align(Camera camera)
Aligns this object with a Camera using the camera's backbuffer matrix. This means that the object (i.e. its positive z-axis) will face into the same direction as the camera does. Calling this method modifies the object's rotation matrix, but not its translation or origin matrix, i.e. the object is facing into the camera's direction but it's not automatically placed at the camera's position. This has to be done "by hand" if required. Keep in mind that the rotation pivot of this object influences the outcome too.

Parameters:
camera - the Camera the Object3D should be aligned with

align

public void align(Object3D object)
Aligns this object with another Object3D. This basically means that both objects will face into the same direction after calling this method. Keep in mind that the rotation pivot influences the outcome too. This method works on the object's own rotation matrix only. It doesn't take transformations of parent objects into account.

Parameters:
object - the object this object should be aligned with

setOrientation

public void setOrientation(SimpleVector dir,
                           SimpleVector up)
Sets the orientation of this object by giving a direction and an up-vector.

Parameters:
dir - the direction
up - the up-vector

enableLazyTransformations

public void enableLazyTransformations()
Enables "lazy transformations". When lazy transformations are being used, the world-transformation matrix (as well as its inverse if needed) is calculated only once and used from there on until lazy transformations are being disabled again. This helps to improve performance for static objects and it can be VERY helpful to speed-up collision detection with such objects. It may also be used on none-static objects if they aren't moving/rotating for some time (for example: if a lot of objects should be checked for collision, it could be helpful to enable lazy transformations before doing this and disabling it right after the tests).
Enabling this again after it already has been clears the stored values, i.e. you can use this to update the calculated matrix inbetween without disabling the mode entirely.

See Also:
disableLazyTransformations()

disableLazyTransformations

public void disableLazyTransformations()
Disables "lazy transformations". This is the default setting for every new object.

See Also:
enableLazyTransformations()

scale

public void scale(float scale)
Scales the object. A scale-value greater than 1 will result in the object to get bigger, while a value lower than 1 causes the object to shrink (when transformed...the Mesh won't be touched). Remember that the scales (as well as rotations and translations) are cumulative.
Please note that setting or clearing the rotation matrix will reset this value. You are supposed to reset the scaling to 1 before doing so.

Parameters:
scale - the new scale
See Also:
setScale(float)

setScale

public void setScale(float absScale)
Sets an absolute value for the object's scaling. Useful, if the cumulative scaling of scale() isn't what one wants.
Please note that setting or clearing the rotation matrix will reset this value. You are supposed to reset the scaling to 1 before doing so.

Parameters:
absScale - the new (absolute) scale
See Also:
scale(float)

getScale

public float getScale()
Returns the cumulated scale value for this object.

Returns:
the current scaling

getTranslation

public SimpleVector getTranslation()
Returns the translation of the object (from its origin to its current position)

Returns:
the translation

getTranslation

public SimpleVector getTranslation(SimpleVector trns)
Returns the translation of the object. The returned SimpleVector is the same one as the one given as parameter. This is useful to save the creation of an additional object. If null is given, a new one will be created.

Parameters:
trns - the SimpleVector to fill and return
Returns:
the translation

getOrigin

public SimpleVector getOrigin()
Returns the origin of the object (as set by setOrigin()).

Returns:
the oring

getXAxis

public SimpleVector getXAxis()
Returns the x-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account.

Returns:
the x-axis

getYAxis

public SimpleVector getYAxis()
Returns the y-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account.

Returns:
the y-axis

getZAxis

public SimpleVector getZAxis()
Returns the z-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account.

Returns:
the z-axis

getXAxis

public SimpleVector getXAxis(SimpleVector toFill)
Returns the x-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account. This method fills the given SimpleVector in addition to returning it.

Parameters:
toFill - the vector to fill
Returns:
the x-axis

getYAxis

public SimpleVector getYAxis(SimpleVector toFill)
Returns the y-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account. This method fills the given SimpleVector in addition to returning it.

Parameters:
toFill - the vector to fill
Returns:
the y-axis

getZAxis

public SimpleVector getZAxis(SimpleVector toFill)
Returns the z-axis of the object. This is an imaginary axis useful for movement und rotations relative to the object. This is based on the rotation matrix only. It doesn't take any parent objects into account. This method fills the given SimpleVector in addition to returning it.

Parameters:
toFill - the vector to fill
Returns:
the z-axis

getRotationMatrix

public Matrix getRotationMatrix()
Returns the object's current rotation matrix.

Returns:
the rotation matrix of this object

getTranslationMatrix

public Matrix getTranslationMatrix()
Returns the object's current translation matrix.

Returns:
the translation matrix of this object

getOriginMatrix

public Matrix getOriginMatrix()
Returns the object's origin-translation matrix. This matrix is a kind of static translation matrix for the object used to initially place the object into worldspace. Without using child/parent-objects, there is no difference between using the translation and the origin matrix, but only the former will be applied to child objects of this object. It is advised to use the origin matrix to place the object into worldspace once and to execute all further translations by using the translation matrix (or by using the translate()-method which already does this for you).

Returns:
the origin-translation matrix of this object
See Also:
translate(float,float,float), setOrigin(com.threed.jpct.SimpleVector)

getLightCount

public int getLightCount()
Returns the number of lights that have an influence on this object. This is only valid during rendering, i.e. only when called from within an IRenderHook.

Returns:
the number of used lights

setRotationMatrix

public void setRotationMatrix(Matrix mat)
Sets the rotation matrix for the object. Usually, this is not required as long as the rotateX/Y/Z() methods are satisfying your needs. If you do this, make sure to reset the scale by calling setScale(1f) if you previously modified it.

Parameters:
mat - the new rotation matrix
See Also:
rotateX(float), rotateY(float), rotateZ(float)

clearRotation

public void clearRotation()
Resets the current rotation to the initial value, i.e. no rotation at all. This will also reset the scale.


clearTranslation

public void clearTranslation()
Resets the current translation to the initial value, i.e. no translation at all.


setTextureMatrix

public void setTextureMatrix(Matrix mat)
Sets a matrix that is applied to transform the texture in stage 0. If no transformation is needed, null should be set instead of an empty matrix.
Note: This doesn't work on all phones. On a Samsung Galaxy with Android 1.5 for example, changing the texture matrix has no effect!?

Parameters:
mat - the matrix

getTextureMatrix

public Matrix getTextureMatrix()
Returns the current texture matrix of null if none is set.

Returns:
the texture matrix

rotateMesh

public void rotateMesh()
Rotates the raw mesh data using the rotation matrix specified for this object. This rotation is applied directly onto the mesh and therefor it's permanent. This could be useful for defining animation keyframes via object meshes or for altering objects in objectspace. Rotating a mesh forces the object's bounding box to be recalculated afterwards (automatically done). The rotation matrix of the object won't be reset by this method.


setTranslationMatrix

public void setTranslationMatrix(Matrix mat)
Sets the translation matrix for the object. Usually, this is not required as long as the translate() method is satisfying your needs.

Parameters:
mat - the new translation matrix
See Also:
translate(float,float,float)

setMesh

public void setMesh(Mesh mesh)
Sets an object's mesh to another one. Shouldn't be required in normal applications.

Parameters:
mesh - the new mesh of the object
See Also:
getMesh(), calcBoundingBox()

getMesh

public Mesh getMesh()
Returns the current mesh of the object. This is useful for using an object's mesh data as keyframes for an animation. The returned mesh can also be added to another object by using setMesh(). If you do so, both objects will share the same instance of mesh. That isn't a problem as long as you don't want to modify the mesh of one object without changing the other's. In this case, you should better use a copy of the mesh obtained from Mesh.cloneMesh().

Returns:
the object's mesh
See Also:
Animation, Mesh.cloneMesh(boolean), setMesh(com.threed.jpct.Mesh)

getPolygonManager

public PolygonManager getPolygonManager()
Returns the PolygonManager for this object. A PolygonManager can be used to access an object's polygons. While you can obtain a PolygonManager from a stripped object, you can't safely modify the object.

Returns:
the manager
See Also:
strip()

setBoundingBox

public void setBoundingBox(float minx,
                           float maxx,
                           float miny,
                           float maxy,
                           float minz,
                           float maxz)
Sets a new AABB for the object. Usually, this shouldn't be required as it is automatically done by the build()-method.

Parameters:
minx - the lowest x-value of the AABB
maxx - the highest x-value of the AABB
miny - the lowest y-value of the AABB
maxy - the highest y-value of the AABB
minz - the lowest z-value of the AABB
maxz - the highest z-value of the AABB
See Also:
build(), calcBoundingBox()

cloneObject

public Object3D cloneObject()
Clones the current object. A cloned object A' of an object A is a copy of A at the point when the cloning takes places. This means that A' inherits all rotations, translations and rendering properties from A. However, A' and A are sharing the same mesh data (to save memory). This will cause A' to inherit all keyframe animations from A and vice versa. Keep this in mind when cloning animated objects. Cloning an object is a costly operation that should only be done when needed. If multiple copies of an object are required during runtime, it may be helpful to create them at startup. This method also copies properties like lazy transformation settings and similar, so take care to adjust afterwards on the cloned object if needed. Cloning doesn't clone collision modes. Please note that this doesn't work on stripped objects until you set their meshes to locked.

Returns:
the cloned object

getWorldTransformation

public Matrix getWorldTransformation()
Returns the transformation matrix used to transform the object from objectspace into worldspace. Could be useful for debugging purposes, but usually this information shouldn't be needed.

Returns:
the transformation matrix

getWorldTransformation

public Matrix getWorldTransformation(Matrix mat)
Variant of getWorldTransformation() to avoid the creation of an additional matrix where not needed. The given matrix will be filled with the returns and returned in addition.

Parameters:
mat - the matrix to be filled
Returns:
the transformation matrix

addCollisionListener

public void addCollisionListener(CollisionListener listener)
Adds a collision listener to this object. A collision listener gets notified in case of a collision with or caused by this object.

Parameters:
listener - the listener
See Also:
CollisionListener

removeCollisionListener

public void removeCollisionListener(CollisionListener listener)
Removes a collision listener from the list of listeners.

Parameters:
listener - the listener to remove

disableCollisionListeners

public void disableCollisionListeners()
Disables all collision listeners of this object, so that none of them will be notified in case of a collision.


enableCollisionListeners

public void enableCollisionListeners()
(Re-)enables all collision listerner of this object.


getCollisionListeners

public java.util.Iterator<CollisionListener> getCollisionListeners()
Returns the collision listeners of this object as an Iterator. The Iterator is empty if no listeners have been assigned.

Returns:
the listeners

setRenderHook

public void setRenderHook(IRenderHook hook)
Sets a new hook into the rendering pipeline. This is only valid for compiled objects. Any other object will never access this hook. The hook won't be serialized if the Object3D is.

Parameters:
hook - the hook into the rendering pipeline
See Also:
IRenderHook

getRenderHook

public IRenderHook getRenderHook()
Returns the render hook or null, if none has been set.

Returns:
the hook or null

checkForCollision

public int checkForCollision(SimpleVector dirVec,
                             float step)
Checks if the current object collides with something when moving into a particular direction. This is just a check, so no translations are being performed. A collision can only be detected with objects that are set to COLLISION_CHECK_OTHERS. This method uses a ray-polygon collision detection.

Parameters:
dirVec - the direction vector (a unit vector)
step - the length of the casted ray (a collision will only be detected of it takes place within this range)
Returns:
the ID of the Object3D if there is a collision, otherwise NO_OBJECT
See Also:
setCenter(com.threed.jpct.SimpleVector), setCollisionMode(int), getID(), NO_OBJECT

checkForCollisionSpherical

public SimpleVector checkForCollisionSpherical(SimpleVector translation,
                                               float radius)
Checks if the current object collides with something when moving into a particular direction. This is just a check, so no translations are being performed. A collision can only be detected with objects that are set to COLLISION_CHECK_OTHERS. This method uses a sphere-polygon collision detection.

Parameters:
translation - the translation the object should perform
radius - the radius of the sphere (a collision will only be detected of it takes place within this radius)
Returns:
a SimpleVector containing a corrected translation vector. This vector represents the translation that should be applied to the object to avoid a collision. If no collision takes place, the translation won't be corrected though (i.e. no collision means returned SimpleVector.equals(translation))
See Also:
setCenter(com.threed.jpct.SimpleVector), setCollisionMode(int)

checkForCollisionEllipsoid

public SimpleVector checkForCollisionEllipsoid(SimpleVector translation,
                                               SimpleVector ellipsoid,
                                               int recursionDepth)
Checks if the current object collides with something when moving into a particular direction. This is just a check, so no translations are being performed. A collision can only be detected with objects that are set to COLLISION_CHECK_OTHERS. This method uses a (swept)ellipsoid-polygon collision detection.

Parameters:
translation - the translation the object should perform
ellipsoid - the radius of the epplisoid in x,y and z direction
recursionDepth - the max. recursion depth of the collision detection. A higher value will improve the accuracy of the collision detection but reduce performance. Reasonable values lie between 1 and 5.
Returns:
a SimpleVector containing a corrected translation vector. This vector represents the translation that should be applied to the object to avoid a collision. If no collision takes place, the translation won't be corrected though (i.e. no collision means returned SimpleVector.equals(translation))
See Also:
setCenter(com.threed.jpct.SimpleVector), setCollisionMode(int)

setEllipsoidMode

public void setEllipsoidMode(int mode)
When doing ellipsoid collision detection with this object, the ellipsoid can be transformed according to the objects's transformation and in the source's object space or it remains static in the target's object space (i.e. "axis aligned").
The later is faster, but not suitable for all kinds of ellipsoids.

Parameters:
mode - int the mode
See Also:
ELLIPSOID_ALIGNED, ELLIPSOID_TRANSFORMED

getEllipsoidMode

public int getEllipsoidMode()
Returns the current ellipsoid mode.

Returns:
the mode
See Also:
ELLIPSOID_ALIGNED, ELLIPSOID_TRANSFORMED

wasTargetOfLastCollision

public boolean wasTargetOfLastCollision()
True, if this object was a target of the last collision detection that took place (regardless of what kind it was). Otherwise false. "A target" in this context means, that something has collided with this object, i.e. if one checks object A for collision with other objects and it collides with an object B, B is the target and A is the source. A collision is not automatically detected. One has to use one of the various ways jPCT offers for collision detection to detect it.

Returns:
was this object a target of the last detected collision?
See Also:
resetCollisionStatus()

resetCollisionStatus

public void resetCollisionStatus()
Sets the indicator that the object was a target of the last collision detection to false, i.e. the object won't be recognized any longer as part of the collision. This is done automatically the next time a collision detection method is being called.

See Also:
wasTargetOfLastCollision()

calcMinDistance

public float calcMinDistance(SimpleVector org,
                             SimpleVector dr)
Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction.

Parameters:
org - a SimpleVector containing the position vector
dr - a SimpleVector containing the direction vector
Returns:
the minimal distance to some polygon (= how far can one move into this direction until something will be hit). If there is no such polygon, COLLISION_NONE will be returned.
See Also:
COLLISION_NONE

calcMinDistance

public float calcMinDistance(SimpleVector org,
                             SimpleVector dr,
                             float ignoreIfLarger)
Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction. This version is a special purpose version of calcMinDistance() which only takes polygons into consideration that have at least one vertex that is closer than ignoreIfLarger units to the position vector. Can be useful to optimize calculations in situations where it is known how far away the polygon with the minimal distance can be at max.

Parameters:
org - a SimpleVector containing the position vector
dr - a SimpleVector containing the direction vector
ignoreIfLarger - only polygons within this range will be taken into account
Returns:
the minimal distance to some polygon (= how far can one move into this direction until something will be hit). If there is no such polygon, COLLISION_NONE will be returned.
See Also:
COLLISION_NONE

setCenter

public void setCenter(SimpleVector center)
Sets the center of the object (in object-space). This "center" doesn't has to be the real center of the object but it's the point in objectspace which will be used for collision detection. This means that if one tests if the object may move A units into (x,y,z)-direction, actually it's tested if this point (transformed into world-space) may move A units into (x,y,z)-direction. Calling build() resets this value to a calculated center, so this method should be called after calling build().

Parameters:
center - the center
See Also:
build()

getCenter

public SimpleVector getCenter()
Returns the center of the object (in object-space, i.e. unaffected by any transformation).

Returns:
the center

getTransformedCenter

public SimpleVector getTransformedCenter()
Returns the center of the object in worldspace, i.e. after the object's current transformations have been applied to it.

Returns:
the center transformed into worldspace

getTransformedCenter

public SimpleVector getTransformedCenter(SimpleVector toFill)
Returns the center of the object in worldspace, i.e. after the object's current transformations have been applied to it. The returned SimpleVector is the same one as the one given as parameter. This is useful to save the creation of an additional object. If null is given, a new one will be created.

Returns:
the center transformed into worldspace

setRotationPivot

public void setRotationPivot(SimpleVector pivot)
Sets the rotation pivot of the object. The rotation pivot is the point in objectspace around which the object will be rotated using its rotation matrix. Calling build() resets this value to a calculated rotation pivot, so this method should be called after calling build().

Parameters:
pivot - the rotation pivot
See Also:
build()

getRotationPivot

public SimpleVector getRotationPivot()
Returns the rotation pivot of the object

Returns:
the rotation pivot

calcCenter

public void calcCenter()
Tries to calculate the center of the object using its mesh data. This is a very rough approach and while it works very well on most objects, it may fail on others. This method sets both the center and the rotation pivot. This method is called by the build() method.

See Also:
setCenter(com.threed.jpct.SimpleVector), setRotationPivot(com.threed.jpct.SimpleVector), build()

setOcTree

public void setOcTree(OcTree ocTree)
Assigns an octree to the object. An octree may help to increase performance for some kind of objects (like large landscapes). It's not possible to combine portals and octrees (at least not in jPCT), so setting the octree will be ignored if portal rendering is enabled. In every other case, the object will be rendered using the octree as soon as it's assigned to it.
Please keep in mind that calculating triangle strips has to be done before building/assigning the tree, because it will destroy the tree.

Parameters:
ocTree - the octree that subdivides this object
See Also:
OcTree

getOcTree

public OcTree getOcTree()
Returns the OcTree assigned to this object or null, if none has been assigned.

Returns:
the OcTree (or null)

setOrigin

public void setOrigin(SimpleVector origin)
Sets the origin of the object. The origin is a position in worldspace at which the object will be placed before performing any other translations. The difference between the origin and a normal translation is, that the normal translation affects the child objects (if any) while the translation to the origin doesn't.

Parameters:
origin - the origin
See Also:
translate(float, float, float)

invert

public void invert()
Physically "inverts" the object, which means that the backface culling works the other way round. This could be used for example on a cube that is usually viewed from outside to make it possible to view it from the inside (and still use backface culling on it). Inverting an object is a costly operation.


invertCulling

public void invertCulling(boolean inv)
Inverts culling order if set to true. This affects culling only, not the mesh itself (unlike invert()).

Parameters:
inv - invert the culling?

cullingIsInverted

public boolean cullingIsInverted()
Returns true, if inverted culling is used on this object. False otherwise.

Returns:
is it?

calcNormals

public void calcNormals()
Calculates the object's vertex normals by calculating the face normals of the adjacent polygons of each vertex and averaging them. The normals are required for lighting and mapping, so they need to be calculated for every object. Usually, this is already done by calling the object's build() method. (Respective by the loader for MD2-files).

See Also:
build()

calcTextureWrap

public void calcTextureWrap()
"Wraps" a texture around the object. This may not look correct on every object, but it's a fast and easy way to assign texture coordinates to objects that didn't have any. This kind of wrapping is basically a kind of static environment mapping.

See Also:
calcTextureWrapSpherical()

calcTextureWrapSpherical

public void calcTextureWrapSpherical()
"Wraps" a texture around the object in a spherical way. Usually, this method produces better results than calcTextureWrap(), but it depends on the object. This method is well suited to assign texture-coordinates to objects that were generated using the Primitives class. This method recalculates the center of the object, so any modification to the center or the rotation-pivot will be lost after calling this method.

See Also:
calcTextureWrap(), Primitives

setTexture

public void setTexture(java.lang.String texname)
Sets the texture for the object. When using normal texture mapping, this texture is the only one used.

Parameters:
texname - the name of the texture as set in the TextureManager.addTexture()-method

setTexture

public void setTexture(TextureInfo tInf)
Sets the texture for the object via an instance of TextureInfo.
Texture coordinates for all layers are taken from the coordinates defined for the base layer of the Object3D, i.e. u/v coordinates given to this TextureInfo will be ignored.

Parameters:
tInf - the TextureInfo
See Also:
TextureInfo

shareTextureData

public void shareTextureData(Object3D source)
In addition to sharing the actual mesh data, you can also make objects share the same texturing information (the actual textures, not the uv-coordinates). If you do this, changing the texture on one object will change it on all sharing objects too.
This helps to save some memory, especially on objects that use multiple textures.

Parameters:
source - the source of the texturing information

rayIntersectsAABB

public float rayIntersectsAABB(SimpleVector org,
                               SimpleVector dr,
                               boolean isNormalized)
Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object. This can be useful to speed up some calculations. jPCT is using this method for faster collision detection.
If the object doesn't have a bounding box for whatever reason, RAY_MISSES_BOX will be returned.

Parameters:
org - the position vector of the ray
dr - the direction vector of the ray
isNormalized - indicates, that dr is already normalized. So the method can spare another normalization.
Returns:
the distance between the starting point of the ray and the nearest plane of the box. If the ray doesn't intersect the box, RAY_MISSES_BOX will be returned
See Also:
RAY_MISSES_BOX

rayIntersectsAABB

public float rayIntersectsAABB(SimpleVector org,
                               SimpleVector dr)
Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object. This can be useful to speed up some calculations. jPCT is using this method for faster collision detection.
If the object doesn't have a bounding box for whatever reason, RAY_MISSES_BOX will be returned.

Parameters:
org - the position vector of the ray
dr - the direction vector of the ray
Returns:
the distance between the starting point of the ray and the nearest plane of the box. If the ray doesn't intersect the box, RAY_MISSES_BOX will be returned
See Also:
RAY_MISSES_BOX

ellipsoidIntersectsAABB

public boolean ellipsoidIntersectsAABB(SimpleVector org,
                                       SimpleVector ellipsoid)
Checks if a given ellipsoid intersects the axis aligned bounding box (in object-space) of this object. This can be useful to speed up some calculations. jPCT is using this method for faster collision detection. "Intersection" means everything from touching it to being completely covered by it in this case.
If the object doesn't have a bounding box for whatever reason, false will be returned.

Parameters:
org - the position vector of the ellipsoid (the ellipsoid's center)
ellipsoid - the radius of the ellipsoid in x,y and z-direction as a SimpleVector
Returns:
true if there is an intersection, otherwise false

ellipsoidIntersectsAABB

public boolean ellipsoidIntersectsAABB(float orgx,
                                       float orgy,
                                       float orgz,
                                       SimpleVector ellipsoid)

sphereIntersectsAABB

public boolean sphereIntersectsAABB(SimpleVector org,
                                    float radius)
Checks if a given sphere intersects the axis aligned bounding box (in object-space) of this object. This can be useful to speed up some calculations. jPCT is using this method for faster collision detection. "Intersection" means everything from touching it to being completely covered by it in this case.
If the object doesn't have a bounding box for whatever reason, false will be returned.

Parameters:
org - the position vector of the sphere (the sphere's center)
radius - the radius of the sphere
Returns:
true if there is an intersection, otherwise false

addTriangle

public int addTriangle(SimpleVector vert1,
                       SimpleVector vert2,
                       SimpleVector vert3)
Adds a triangle to the object. Using the method, the texture of the object won't be set and the sector will be set to undefined. Texture coordinates won't be set (= set to (0,0) for all vertices). The vertices have to be defined counter-clockwise because jPCT backface culls them by default. One may also add them clockwise and call invert() afterwards to "invert" the order.

Parameters:
vert1 - the first vertex
vert2 - the second vertex
vert3 - the third vertex
Returns:
the number of the added triangle
See Also:
invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       float u,
                       float v,
                       SimpleVector vert2,
                       float u2,
                       float v2,
                       SimpleVector vert3,
                       float u3,
                       float v3)
Adds a triangle to the object. Using the method, the texture of the object won't be set and the sector will be set to undefined. The vertices have to be defined counter-clockwise because jPCT backface culls them by default. One may also add them clockwise and call invert() afterwards to "invert" the order.

Parameters:
vert1 - the first vertex
u - the u component of the texture position at the first vertex
v - the v component of the texture position at the first vertex
vert2 - the second vertex
u2 - the u component of the texture position at the second vertex
v2 - the v component of the texture position at the second vertex
vert3 - the third vertex
u3 - the u component of the texture position at the third vertex
v3 - the v component of the texture position at the third vertex
Returns:
the number of the added triangle
See Also:
invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       float u,
                       float v,
                       SimpleVector vert2,
                       float u2,
                       float v2,
                       SimpleVector vert3,
                       float u3,
                       float v3,
                       int textureID)
Adds a triangle to the object. Using the method, the sector will be set to undefined. The vertices have to be defined counter-clockwise because jPCT backface culls them by default. One may also add them clockwise and call invert() afterwards to "invert" the order.

Parameters:
vert1 - the first vertex
u - the u component of the texture position at the first vertex
v - the v component of the texture position at the first vertex
vert2 - the second vertex
u2 - the u component of the texture position at the second vertex
v2 - the v component of the texture position at the second vertex
vert3 - the third vertex
u3 - the u component of the texture position at the third vertex
v3 - the v component of the texture position at the third vertex
textureID - the ID of the texture as returned by TextureManager.getTextureID()
Returns:
the number of the added triangle
See Also:
TextureManager.getTextureID(java.lang.String), invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       float u,
                       float v,
                       SimpleVector vert2,
                       float u2,
                       float v2,
                       SimpleVector vert3,
                       float u3,
                       float v3,
                       int textureID,
                       int sec)
Adds a triangle to the object. The vertices have to be defined counter-clockwise because jPCT backface culls them by default. One may also add them clockwise and call invert() afterwards to "invert" the order.

Parameters:
vert1 - the first vertex
u - the u component of the texture position at the first vertex
v - the v component of the texture position at the first vertex
vert2 - the second vertex
u2 - the u component of the texture position at the second vertex
v2 - the v component of the texture position at the second vertex
vert3 - the third vertex
u3 - the u component of the texture position at the third vertex
v3 - the v component of the texture position at the third vertex
textureID - the ID of the texture as returned by TextureManager.getTextureID()
Returns:
the number of the added triangle
See Also:
TextureManager.getTextureID(java.lang.String), invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       SimpleVector vert2,
                       SimpleVector vert3,
                       TextureInfo tInf)
Adds a triangle to the object. The vertices have to be defined counter-clockwise because jPCT backface culls them by default. One may also add them clockwise and call invert() afterwards to "invert" the order.
This method takes a TextureInfo instead of the discrete u/v-coordinates and the textureID.

Parameters:
vert1 - the first vertex
vert2 - the second vertex
vert3 - the third vertex
tInf - the TextureInfo
Returns:
the number of the added triangle
See Also:
TextureManager.getTextureID(java.lang.String), TextureInfo, invert()

getInverseWorldTransformation

public Matrix getInverseWorldTransformation()

getInverseWorldTransformation

public Matrix getInverseWorldTransformation(Matrix mat)