com.threed.jpct
Class Object3D

java.lang.Object
  extended bycom.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 boolean BLENDING_DISABLED
          Blending (bumpmapping+texturemapping) is not used
static boolean BLENDING_ENABLED
          Blending (bumpmapping+texturemapping) is used
static boolean BUMPMAPPING_DISABLED
          Bumpmapping is not used
static boolean BUMPMAPPING_ENABLED
          Bumpmapping is used
static int COLLISION_CHECK_NONE
          Don't perform any kind of collision detection for this object
static int COLLISION_CHECK_OTHERS
          Other Object3Ds 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_CAMERASPACE
          Environment mapping takes place in cameraspace
static boolean ENVMAP_DISABLED
          Environment mapping is disabled
static boolean ENVMAP_ENABLED
          Environment mapping is enabled
static boolean ENVMAP_WORLDSPACE
          Environment mapping takes place in worldspace
static int ENVMAP_XY
          'Direction' of spherical environment mapping is XY (default)
static int ENVMAP_XZ
          'Direction' of spherical environment mapping is XZ
static int ENVMAP_YZ
          'Direction' of spherical environment mapping is YZ
static boolean FILTERING_DISABLED
          Filtering is not used on this object
static boolean FILTERING_ENABLED
          Filtering is used on this object (where needed)
static int FINALIZE_DEFAULT
          Default mode for sector processing
static int FINALIZE_PRESORTX
          Alternative mode for sector processing (not very useful at all)
static int FINALIZE_PRESORTY
          Alternative mode for sector processing (not very useful at all)
static int FINALIZE_PRESORTZ
          Alternative mode for sector processing (not very useful at all)
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 boolean MOUSE_SELECTABLE
          This object will be processed by the methods of Interact2D
static boolean MOUSE_UNSELECTABLE
          This object won't be processed by the methods of Interact2D
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 boolean SECTOR_AUTODETECT
          Use autodetection of the covered sectors (for example for animated objects)
static boolean SECTOR_PRECALCULATED
          Use static sector information
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 and the only one that the legacy software renderer supports.
static int UNKNOWN_OBJECTSIZE
          The object is empty
 
Constructor Summary
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.
 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.
 int addTriangle(SimpleVector vert1, SimpleVector vert2, SimpleVector vert3, TextureInfo tInf, int sec)
          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() should be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set...).
 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 breakIfLarger)
          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 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.
 Object3D cloneObject()
          Clones the current object.
static Object3D createDummyObj()
          Static method that creates a dummy Object3D.
 void createTriangleStrips()
          Tries to rebuild the object in a way that it can be rendered by using triangle strips in the most optimal way.
 void createTriangleStrips(int maxPasses)
          Tries to rebuild the object in a way that it can be rendered by using triangle strips in the most optimal way.
 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(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".
 java.awt.Color getAdditionalColor()
          Returns the additional color.
 Animation getAnimationSequence()
          Returns the animation sequence.
 boolean getBlending()
          Returns true if blending is enable.
 SimpleVector getCenter()
          Returns the center of the object (in object-space, i.e. unaffected by any transformation).
 java.util.Enumeration getCollisionListeners()
          Returns the collision listeners of this object as an enumeration.
 boolean getCulling()
          Returns the current culling mode.
 int getEllipsoidMode()
          Returns the current ellipsoid mode.
 boolean getEnvmapMode()
          Returns the currently used mode for environment mapping (worldspace or cameraspace).
 int getID()
          Returns the object's ID.
 int getLighting()
          Gets the lighting mode.
 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.
 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.
 SimpleVector getTransformedCenter()
          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)
 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.
 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.
 void getWorldTransformationInternal(Matrix mat5)
          Special purpose method to avoid the creation of an additional matrix where not needed.
 SimpleVector getXAxis()
          Returns the x-axis of the object.
 SimpleVector getYAxis()
          Returns the y-axis of the object.
 SimpleVector getZAxis()
          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.
 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 isBumpmapped()
          Returns if bumpmapping is used or not.
 boolean isEnvmapped()
          Returns if environment mapping is used or not.
 boolean isSelectable()
          Returns the current "selectable"-state of the 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 rebuild()
          The same as build().
 void recreateTextureCoords()
          Rebuilds the actual texture coordinates for 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 removeMultiTexturing()
          Removes all multi texturing information from this object.
 void removeParent(Object3D obj)
          Removes an object from the parent-collection of this.
 void reorderSectors(int mode)
          Reorders the object's meshdata by grouping it according to the sectors.
 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(java.awt.Color col)
          Sets the additional color for this object.
 void setAllTextures(java.lang.String texname, java.lang.String bumpname)
          Sets the textures for an object.
 void setAllTextures(java.lang.String basename, java.lang.String texname, java.lang.String bumpname)
          Sets the textures for an object.
 void setAnimationSequence(Animation anim)
          Sets the keyframe animation sequence that should be used for this object.
 void setAsMultiSectored()
          Tells jPCT that this object is a multi-sectored one (for portal rendering).
 void setBaseTexture(java.lang.String texname)
          Sets the base texture for the whole object.
 void setBillboarding(boolean mode)
          Enables/disables billboarding for this object.
 void setBlending(boolean mode)
          Enables/Disables blending for the current object.
 void setBoundingBox(float minx, float maxx, float miny, float maxy, float minz, float maxz)
          Sets a new AABB for the object.
 void setBumpmapped(boolean mode)
          Enables/Disables enviroment bumpmapping for this object.
 void setBumpmapTexture(java.lang.String texname)
          Sets the bumpmap of 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 setEnvmapDirection(int dir)
          Sets the pair of coordinates from (x,y,z) that will be used for calculating the environment mapping.
 void setEnvmapMode(boolean mode)
          Sets the mode for environment mapping.
 void setEnvmapped(boolean mode)
          Enables/Disables environment mapping for the object.
 void setFiltering(boolean mode)
          Enables/Disables filtering on a per texel basis.
 void setLighting(int mode)
          Sets the lighting mode.
 void setMatrixCacheUsage(boolean useIt)
          Enables/Disables the matrix cache.
 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 setOrigin(SimpleVector origin)
          Sets the origin of the object.
 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 setSector(int sector)
          Places the object into a specific sector.
 void setSectorDetectionMode(boolean mode)
          Sets the method used for sector detection.
 void setSelectable(boolean mode)
          Sets the object as selectable/unselectable.
 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 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 setVisibility(boolean mode)
          Sets the object to visible/invisible.
 boolean sphereIntersectsAABB(SimpleVector org, float radius)
          Checks if a given sphere intersects the axis aligned bounding box (in object-space) of this 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.
 void unbuild()
          "Unbuilds" an object, i.e. it takes back some of the changes that build() does to the object, so that new triangles can be added again to 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_WORLDSPACE

public static final boolean ENVMAP_WORLDSPACE
Environment mapping takes place in worldspace

See Also:
Constant Field Values

ENVMAP_CAMERASPACE

public static final boolean ENVMAP_CAMERASPACE
Environment mapping takes place in cameraspace

See Also:
Constant Field Values

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

BUMPMAPPING_ENABLED

public static final boolean BUMPMAPPING_ENABLED
Bumpmapping is used

See Also:
Constant Field Values

BUMPMAPPING_DISABLED

public static final boolean BUMPMAPPING_DISABLED
Bumpmapping is not used

See Also:
Constant Field Values

BLENDING_ENABLED

public static final boolean BLENDING_ENABLED
Blending (bumpmapping+texturemapping) is used

See Also:
Constant Field Values

BLENDING_DISABLED

public static final boolean BLENDING_DISABLED
Blending (bumpmapping+texturemapping) is not used

See Also:
Constant Field Values

TRANSPARENCY_MODE_DEFAULT

public static final int TRANSPARENCY_MODE_DEFAULT
The default transparency mode and the only one that the legacy software renderer supports.

See Also:
Constant Field Values

TRANSPARENCY_MODE_ADD

public static final int TRANSPARENCY_MODE_ADD
An alternative transparency mode for additive blending. Supported by the OpenGL renderers and the Opengl-alike software renderer.

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

MOUSE_SELECTABLE

public static final boolean MOUSE_SELECTABLE
This object will be processed by the methods of Interact2D

See Also:
Constant Field Values

MOUSE_UNSELECTABLE

public static final boolean MOUSE_UNSELECTABLE
This object won't be processed by the methods of Interact2D

See Also:
Constant Field Values

FILTERING_ENABLED

public static final boolean FILTERING_ENABLED
Filtering is used on this object (where needed)

See Also:
Constant Field Values

FILTERING_DISABLED

public static final boolean FILTERING_DISABLED
Filtering is not used on this object

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

FINALIZE_DEFAULT

public static final int FINALIZE_DEFAULT
Default mode for sector processing

See Also:
Constant Field Values

FINALIZE_PRESORTZ

public static final int FINALIZE_PRESORTZ
Alternative mode for sector processing (not very useful at all)

See Also:
Constant Field Values

FINALIZE_PRESORTY

public static final int FINALIZE_PRESORTY
Alternative mode for sector processing (not very useful at all)

See Also:
Constant Field Values

FINALIZE_PRESORTX

public static final int FINALIZE_PRESORTX
Alternative mode for sector processing (not very useful at all)

See Also:
Constant Field Values

ENVMAP_XY

public static final int ENVMAP_XY
'Direction' of spherical environment mapping is XY (default)

See Also:
Constant Field Values

ENVMAP_XZ

public static final int ENVMAP_XZ
'Direction' of spherical environment mapping is XZ

See Also:
Constant Field Values

ENVMAP_YZ

public static final int ENVMAP_YZ
'Direction' of spherical environment mapping is YZ

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

SECTOR_AUTODETECT

public static final boolean SECTOR_AUTODETECT
Use autodetection of the covered sectors (for example for animated objects)

See Also:
Constant Field Values

SECTOR_PRECALCULATED

public static final boolean SECTOR_PRECALCULATED
Use static sector information

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 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(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.

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.

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)

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

resetNextID

public static void resetNextID()
Resets the internal object-counter. This could be useful in applets, where the static class members are not reinitialized when reloading the applet.


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

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()

createTriangleStrips

public void createTriangleStrips()
Tries to rebuild the object in a way that it can be rendered by using triangle strips in the most optimal way. This may be useful when using the OpenGL renderer to increase performance for complex objects. The software renderer doesn't use this information (but it shouldn't hurt either). This calculation may take a lot of time on complex objects.
The current implementation is not very clever...there is room for improvement in later versions. In case multipass striping is used, this method