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/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_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(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 and no other attributes 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, float u, float v, SimpleVector vert2, float u2, float v2, SimpleVector vert3, float u3, float v3, int textureID, SimpleVector vertexAlpha)
          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.
 int addTriangle(SimpleVector vert1, SimpleVector vert2, SimpleVector vert3, TextureInfo tInf, SimpleVector vertexAlpha)
          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 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 clearTranslation()
          Resets the current translation to the initial value, i.e. no translation at all.
 Object3D cloneObject()
          Clones the current object.
 void compile()
          Compiles an Object3D.
 void compile(boolean dynamic)
          Compiles an Object3D.
 void compile(boolean dynamic, boolean staticUV, boolean preferDisplayListsOrVBO, boolean indexed, int batchSize)
          Compiles an Object3D.
 void compileAndStrip()
          Compiles and strips an Object3D.
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 decompile(FrameBuffer buffer)
          Decompiles an 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".
 void forceGeometryIndices(boolean dnc)
          Does nothing in jPCT.
 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.
 Matrix getInverseWorldTransformation()
          Returns the inverse of the transformation matrix from object into world space.
 Matrix getInverseWorldTransformation(Matrix mat)
          Returns the inverse of the transformation matrix from object into world space and fills the result in the given matrix.
 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.
 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.
 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.
 Matrix getWorldTransformationTweaked(Matrix mat)
           
 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.
 void invertTextureCoords(boolean invertU, boolean invertV)
          Inverts the texture coordinates assuming that they are in the range of 0..1.
 boolean isBumpmapped()
          Returns if bumpmapping is used or not.
 boolean isCompiled()
          Returns if the object is compiled.
 boolean isEnvmapped()
          Returns if environment mapping is used or not.
 boolean isSelectable()
          Returns the current "selectable"-state of the object.
 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 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 setAdditionalColor(int red, int green, int blue)
          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 setDepthBufferWrites(boolean write)
          This is only important when using the software renderer.
 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 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 setReNormalization(boolean reNormalize)
          Enables re-normalization of transformed normal vectors.
 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 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 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()
          Strips an Object3D.
 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.
 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/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(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

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

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

compile

public void compile()
Compiles an Object3D. Don't confuse this with build(), which does something completely different. A compiled object can be rendered faster when using the hardware renderer but has some shortcomings: The object's number of texture layers will be limited to the number that the current hardware actually support. Everything higher will simply be ignored. You can't add polygons to a compiled object and changing textures of single polygons isn't possible. The lighting is always calculated with an implicit lightMul of 1, so it's advised to change Config.lightMul to 1 when mixing compiled with uncompiled objects (this method already does this for you).
This method compiles the object to a static object. You can't change vertices and/or uv-coordinates on this object afterwards, but it gives you the best performance.
Compiling only affects the hardware renderer, but you can't render an object compiled by the hardware renderer once with the software renderer. However, you may call compile() on any object as long as you are using the software renderer only...it won't show any effect.
A compiled object can only be rendered correctly with vertex arrays enabled in Config (which is default), which is why this methods enables them if needed.
The compiled part of the object won't be serialized.

See Also:
Config.lightMul

compileAndStrip

public void compileAndStrip()
Compiles and strips an Object3D.

See Also:
compile(), strip()

compile

public void compile(boolean dynamic)
Compiles an Object3D. Unlike compile(), this method allows to compile the object to a dynamic one. This can be used on animated objects, but the result will be slower than with a static object. Objects compiled with this method don't handle modified u/v-coordinates, just modified vertices.

Parameters:
dynamic - if true, the object will be compiled to a dynamic object, otherwise to a static one.
See Also:
compile()

compile

public void compile(boolean dynamic,
                    boolean staticUV,
                    boolean preferDisplayListsOrVBO,
                    boolean indexed,
                    int batchSize)
Compiles an Object3D. This is the most flexible compile()-method.

Parameters:
dynamic - if true, the object will be compiled to a dynamic object, otherwise to a static one.
staticUV - if true, uv changes are not supported. If false, they are (this is slower!)
preferDisplayListsOrVBO - if true, objects will be compiled to display lists or VBOs (depending on Config.glUseVBO) if possible. This is faster than not to.
indexed - if true, indexed geometry will be used. It's advised to do this on static objects while it can be slow on dynamic ones.
batchSize - the batch size for OpenGL. It's hard to find a good balance here. Very high values may lead to crashes in the driver or missing polygons.
See Also:
Config.glBatchSize

forceGeometryIndices

public void forceGeometryIndices(boolean dnc)
Does nothing in jPCT. It's in here just for compatibility reasons with jPCT-AE.

Parameters:
dnc - doesn't matter

isCompiled

public boolean isCompiled()
Returns if the object is compiled. Please note, that this method doesn't return true right after calling compile() on an object, because compilation happens later in the pipeline.

Returns:
has it been compiled?

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.
To share data, some preconditions have to be met. The object you would like to share data with must not share data itself with some other, it has to be a compiled object and must not use an octree. Furthermore, both objects have to use the same mesh (not just the same data but the exact same instance) and 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.
Please note that you still have to call compile() on this object. However, any parameters given to the compile method will be ignored.

Parameters:
withObj - the object to share data with

decompile

public void decompile(FrameBuffer buffer)
Decompiles an object. A decompiled object will be rendered using the normal rendering pipeline again. Stripped objects can't be decompiled. While compiling an object isn't a cheap operation, decompiling is.

Parameters:
buffer - the frame buffer. Because display lists are bound to the OpenGL context, it's needed here. It may be null if the object hasn't been send to the graphics card yet (i.e. if isCompiled() returns null).

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()
Strips an Object3D. This is only possible on compiled objects. It frees some memory that isn't needed anymore by a compiled object. It's NOT possible to decompile a stripped object anymore!
Be careful when objects are sharing meshes, because this method strips an object's mesh in a certain way too. This can only be done, if the mesh isn't used by no other uncompiled object anymore...the method tries to handle this, but it may fail if meshes are used across worlds.


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 uses a maximum number of 50 passes.

See Also:
World.createTriangleStrips(), Config.glTriangleStrips, Config.useMultipassStriping

createTriangleStrips

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

Parameters:
maxPasses - the maximum number of passes in case multipass striping is used
See Also:
World.createTriangleStrips(), Config.glTriangleStrips, Config.useMultipassStriping

rebuild

public void rebuild()
The same as build().

See Also:
build()

build

public 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...).
Adding new triangles to an object after calling build() may work but doesn't have to. If you want to do this, call unbuild() before.
There is no need to call build() for every object if buildAllObjects() is used. There is also no need to call build() for dummy objects. For any other object, build() should be called. "Building" the object is a costly operation, so it shouldn't be called without need.

See Also:
World.buildAllObjects(), build()

unbuild

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

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.


reorderSectors

public void reorderSectors(int mode)
Reorders the object's meshdata by grouping it according to the sectors. reorderSectors() should be used on objects that are used together with portal rendering. Normally, this method is already called by the build()-method for objects that require it. mode can be FINALIZE_DEFAULT (which is how build() calls this method) or FINALIZE_PRESORTX/Y/Z. Everything other than FINALIZE_DEFAULT is more or less in for future usage. Albeit it does indeed change the reorder-behaviour, it isn't useful at all. Stay with FINALIZE_DEFAULT if you have to use this method.

Parameters:
mode - How to sort
See Also:
FINALIZE_DEFAULT, FINALIZE_PRESORTX, FINALIZE_PRESORTY, FINALIZE_PRESORTZ

setSectorDetectionMode

public void setSectorDetectionMode(boolean mode)
Sets the method used for sector detection. When using portal rendering, it is important to determine in which sector an Object3D is placed. To do so, two different kinds of detection are available: static (precalculated) and dynamic (autodetect). Static detection should be used for objects which are placed into one (and exactly one) sector and which won't move (or at least which won't leave the sector). To use static detection, the object has to be assigned to a sector by calling the setSector()-method. Dynamic detection should be used for objects that are covering more than one sector or that (may) move between sectors. Dynamic detection is a bit more expensive than static. The main object (that is the object which defines the sectors, usually the "map") has to be static (it can't move anyway). A third method is to set the detection mode to static but to place the object into an undefined sector. This way, the object will always be processed which could be handy for small, short living objects like particles or projectiles.

Parameters:
mode - which method to use
See Also:
SECTOR_AUTODETECT, SECTOR_PRECALCULATED, Portals.SECTOR_UNDEFINED, setSector(int)

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 and no other attributes from its parent. 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)

setSelectable

public void setSelectable(boolean mode)
Sets the object as selectable/unselectable. An object that is set to be unselectable won't be processed by the pickPolygon() method in Interact2D. Default is MOUSE_SELECTABLE.

Parameters:
mode - MOUSE_SELECTABLE/MOUSE_UNSELECTABLE
See Also:
MOUSE_SELECTABLE, MOUSE_UNSELECTABLE

isSelectable

public boolean isSelectable()
Returns the current "selectable"-state of the object. On compiled objects, this will always return false.

Returns:
selectable or not
See Also:
MOUSE_SELECTABLE, MOUSE_UNSELECTABLE, setSelectable(boolean)

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

setFiltering

public void setFiltering(boolean mode)
Enables/Disables filtering on a per texel basis. This filtering helps to avoid the blocky look of pick-nearest-filtering but it's not as slow as real bilinear filtering. However, it does decrease performance a little bit and may introduce rendering artifacts in some situations. Setting this to enabled will cause the object to be filtered regardless of what the filtering heuristic of the engine says. If it's disabled, jPCT tries to determine if a texel needs to be filtered or not (if filtering is enabled at all using the Config.texelFilter setting). This setting doesn't affect the OpenGL renderer. Disabled is default.

Parameters:
mode - the filtering mode
See Also:
FILTERING_ENABLED, FILTERING_DISABLED, Config.texelFilter

setTransparency

public void setTransparency(int trans)
Sets the object to be transparent using the given level of transparency. Transparency can't be combined with any form of bumpmapping at the moment. 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

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. This setting isn't supported by the legacy renderer and behaviour differs slightly between software and hardware renderer.

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

getTransparencyMode

public int getTransparencyMode()
Returns the current transparency mode. This setting is supported by the OpenGL renderers only.

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?

setAdditionalColor

public void setAdditionalColor(java.awt.Color 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...:-)
When using the ShadowHelper, this can affect the shadow appearance in a way that the shadow isn't visible. The ShadowHelper has a method to disable the additional color for these cases.

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.
When using the ShadowHelper, this can affect the shadow appearance in a way that the shadow isn't visible. The ShadowHelper has a method to disable the additional color for these cases.

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

getAdditionalColor

public java.awt.Color 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()

setMatrixCacheUsage

public void setMatrixCacheUsage(boolean useIt)
Enables/Disables the matrix cache. This cache won't improve performance but reduces creation of short lived matrix instances. It's enabled by default.

Parameters:
useIt - use the cache or don't

setReNormalization

public void setReNormalization(boolean reNormalize)
Enables re-normalization of transformed normal vectors. Usually, this isn't needed as long as you don't set your own rotation matrix, which has a non-uniform scaling or some other fancy transformation applied that jPCT doesn't know of.
This will reduce performance of the vertex transformations and shouldn't be enabled without need. In fact, it's a kind of workaround for a problem with lighting that will otherwise occur if you use such matrices.

Parameters:
reNormalize - do it?

setDepthBufferWrites

public void setDepthBufferWrites(boolean write)
This is only important when using the software renderer. By default, transparent objects don't write into the zbuffer at all. For some fog effects, this may cause a problem. In that case, set this to true to make the object write into the zbuffer regardless of the transparency setting. Default is false.

Parameters:
write - write to the buffer or not

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

setBlending

public void setBlending(boolean mode)
Enables/Disables blending for the current object. The term blending in this context refers to the blending of an environment bumpmapped surface together with a normal textured one. This means that the object is textured not only by using bumpmapping or normal texture mapping, but by a combination of both. While this may look quite good, it is the most fillrate hungry kind of texturing offered. To use blending, the texturemap and the bumpmap need to be of the same size. Blending is not yet supported by the OpenGL renderer.

Parameters:
mode - the blending mode
See Also:
BLENDING_ENABLED, BLENDING_DISABLED

getBlending

public boolean getBlending()
Returns true if blending is enable.

Returns:
boolean is blending enabled?

setBumpmapped

public void setBumpmapped(boolean mode)
Enables/Disables enviroment bumpmapping for this object. To use this, a bumpmap has to be assigned to the object. The object's texturemap will be used as an environment map and has to be 256*256 pixel in size (albeit it may work with other formats but it's not advised to use them and a warning will be printed out if you do). This is supported only by the software renderer.

Parameters:
mode - the bumpmapping mode
See Also:
BUMPMAPPING_ENABLED, BUMPMAPPING_DISABLED

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

isBumpmapped

public boolean isBumpmapped()
Returns if bumpmapping is used or not. Bumpmapping is not yet supported by the OpenGL renderer.

Returns:
used...or not...
See Also:
BUMPMAPPING_ENABLED, BUMPMAPPING_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

setEnvmapMode

public void setEnvmapMode(boolean mode)
Sets the mode for environment mapping. Environment mapping can be applied using the objects worldspace coordinates or the objects cameraspace coordinates. The worldspace-based method is used by default and usually closer to reality, but the cameraspace-based approach may look better on rather static objects but with a moving camera.

Parameters:
mode - the used mode
See Also:
ENVMAP_WORLDSPACE, ENVMAP_CAMERASPACE

setEnvmapDirection

public void setEnvmapDirection(int dir)
Sets the pair of coordinates from (x,y,z) that will be used for calculating the environment mapping.

Parameters:
dir - from which "direction" the environment mapping should be applied
See Also:
ENVMAP_XY, ENVMAP_YZ, ENVMAP_XZ

getEnvmapMode

public boolean getEnvmapMode()
Returns the currently used mode for environment mapping (worldspace or cameraspace).

Returns:
the used mode
See Also:
setEnvmapMode(boolean)

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

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) is you have previously modified it.

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

setTextureMatrix

public void setTextureMatrix(Matrix mat)
Sets a matrix that is applied to transform the texture in stage 0. Only works realible on compiled objects. On none-compiled objects, it works for non-threaded renderers, but not on threaded ones. If no transformation is needed, null should be set instead of an empty matrix.

Parameters:
mat - the matrix

getTextureMatrix

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

Returns:

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.


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.

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

getWorldTransformationTweaked

public Matrix getWorldTransformationTweaked(Matrix mat)

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

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.Enumeration getCollisionListeners()
Returns the collision listeners of this object as an enumeration. The enumeration 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)

setSector

public void setSector(int sector)
Places the object into a specific sector. This is required for performing static sector detection on objects other than the main world (= the "map" or "level"). Sector detection is only required if portal rendering should be used. Objects using dynamic sector detection don't need to be bound to a specific sector. The sectors are being defined by the polygons of the main World (= the "map") and are constructed automatically when calling build() on the main world. setSector() should be called (only if needed of course) after the object has been added to an instance of World. Doing it the other way round is possible but not recommended.

Parameters:
sector - the sector number in which the object is in
See Also:
Portals.SECTOR_UNDEFINED, build()

setAsMultiSectored

public void setAsMultiSectored()
Tells jPCT that this object is a multi-sectored one (for portal rendering). Multi-sectored objects are supported but despite from the main world, which has to be multi-sectored, not recommended. Not because they won't work, but because they don't make much sense. If one still thinks that they do, this is the method to tell jPCT for any object other than the main world, that it is a multi-sectored one. To call reorderSectors() after creating such an object is absolutly required (as well as calcNormals())...build() doesn't make much sense with such objects (but it wouldn't hurt anyway). To keep this short. Support is there but if it's possible to avoid these kind of objects: do it!


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). jPCT has two different methods for calculating the normals. One is faster for smaller objects while the other one is (much!) faster for more complex objects. jPCT automatically decides which method to use depending on the object and the value of optimizeNormalCalcTH in Config.

See Also:
build(), Config.optimizeNormalCalcTH

calcTangentVectors

public void calcTangentVectors()
Tangent vectors are needed for some calculation in shaders. If you are using shaders and your shader needs these vectors and jPCT 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 if the need has been detected.


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. It is advised to call recreateTextureCoords() after calling this method (if the object already has a texture).

See Also:
recreateTextureCoords(), 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. It is advised to call recreateTextureCoords() after calling this method (if the object already has a texture). 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:
recreateTextureCoords(), calcTextureWrap(), Primitives

recreateTextureCoords

public void recreateTextureCoords()
Rebuilds the actual texture coordinates for this object. This should be called after assigning another texture to an object or after calling calcTextureWrap...().

See Also:
calcTextureWrap(), calcTextureWrapSpherical()

setAllTextures

public void setAllTextures(java.lang.String texname,
                           java.lang.String bumpname)
Sets the textures for an object. The textures will be set for the whole object (= the same for all polygons). The object's basemap (used for blending) is set to it's texturemap.

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

setAllTextures

public void setAllTextures(java.lang.String basename,
                           java.lang.String texname,
                           java.lang.String bumpname)
Sets the textures for an object. The textures will be set for the whole object (= the same for all polygons).

Parameters:
basename - the name of the base Texture (used for blending) as set in the TextureManager.addTexture()-method
texname - the name of the Texture as set in the TextureManager.addTexture()-method
bumpname - the name of the bumpmap as set in the TextureManager.addTexture()-method

setBaseTexture

public void setBaseTexture(java.lang.String texname)
Sets the base texture for the whole object. The base texture is used for blending only. When using normal texture mapping, the normal texture is used for texturing the object. When using blending, three textures are used: A bumpmap (defined by the object's bumpmap), a normal texturemap (which is used as an environment map in this mode) and the basemap (which is blended together with the bumpmapped environment map...hence the name of the mode).

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

setTexture

public void setTexture(java.lang.String texname)
Sets the texture for the object. When using normal texturemapping, this texture is the only one used. With environment mapping enabled, this texture is used as an environment map. With environment bumpmapping enabled (software renderer only), this texture is pertubed by the bumpmap.

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

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.

Parameters:
source - the source of the texturing information

setTexture

public void setTexture(TextureInfo tInf)
Sets the texture for the object via an instance of TextureInfo. TextureInfo may contain multiple texture layers, but this is supported only by the OpenGL renderer. The software renderer will threat a multi layered TextureInfo as if it were a single layered one, i.e. it ignores the additional texture layers.
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

setBumpmapTexture

public void setBumpmapTexture(java.lang.String texname)
Sets the bumpmap of the object. When using normal texturemapping, this texture is not used. With environment bumpmapping enabled, this texture pertubes the environment map. Is this supported only by the software renderer.

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

removeMultiTexturing

public void removeMultiTexturing()
Removes all multi texturing information from this object. The object will use simple single texturing after calling this method and the removed information can't be restored.


invertTextureCoords

public void invertTextureCoords(boolean invertU,
                                boolean invertV)
Inverts the texture coordinates assuming that they are in the range of 0..1. Inverting means 1-coord.

Parameters:
invertU - if true, u will be inverted
invertV - if true, v will be inverted

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

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:
Portals.SECTOR_UNDEFINED, 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:
Portals.SECTOR_UNDEFINED, 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:
Portals.SECTOR_UNDEFINED, 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,
                       SimpleVector vertexAlpha)
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()
vertexAlpha - the alpha values (0..1) of the three vertices stored in x,y and z. This isn't supported by the software renderer.
Returns:
the number of the added triangle
See Also:
Portals.SECTOR_UNDEFINED, 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()
sec - the number of the sector to which the polygon belongs (important when using portal rendering with static sector detection for this object)
Returns:
the number of the added triangle
See Also:
Portals.SECTOR_UNDEFINED, TextureManager.getTextureID(java.lang.String), invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       SimpleVector vert2,
                       SimpleVector vert3,
                       TextureInfo tInf,
                       SimpleVector vertexAlpha)
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. With that, it's possible to use multi texturing in jPCT. But be aware that only the OpenGL renderer supports this feature. The software renderer will ignore the additional texture stages.

Parameters:
vert1 - the first vertex
vert2 - the second vertex
vert3 - the third vertex
tInf - the TextureInfo
vertexAlpha - the alpha values (0..1) of the three vertices stored in x,y and z. This isn't supported by the software renderer.
Returns:
the number of the added triangle
See Also:
Portals.SECTOR_UNDEFINED, TextureManager.getTextureID(java.lang.String), TextureInfo, 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. With that, it's possible to use multi texturing in jPCT. But be aware that only the OpenGL renderer supports this feature. The software renderer will ignore the additional texture stages.

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:
Portals.SECTOR_UNDEFINED, TextureManager.getTextureID(java.lang.String), TextureInfo, invert()

addTriangle

public int addTriangle(SimpleVector vert1,
                       SimpleVector vert2,
                       SimpleVector vert3,
                       TextureInfo tInf,
                       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.
This method takes a TextureInfo instead of the discrete u/v-coordinates and the textureID. With that, it's possible to use multi texturing in jPCT. But be aware that only the OpenGL renderer supports this feature. The software renderer will ignore the additional texture stages.

Parameters:
vert1 - the first vertex
vert2 - the second vertex
vert3 - the third vertex
tInf - the TextureInfo
sec - the number of the sector to which the polygon belongs (important when using portal rendering with static sector detection for this object)
Returns:
the number of the added triangle
See Also:
Portals.SECTOR_UNDEFINED, TextureManager.getTextureID(java.lang.String), TextureInfo, invert()

getInverseWorldTransformation

public Matrix getInverseWorldTransformation()
Returns the inverse of the transformation matrix from object into world space.

Returns:
the inverse

getInverseWorldTransformation

public Matrix getInverseWorldTransformation(Matrix mat)
Returns the inverse of the transformation matrix from object into world space and fills the result in the given matrix.

Returns:
the inverse (mat)