|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.threed.jpct.Object3D
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()).
World,
Serialized Form| Field Summary | |
static boolean |
BILLBOARDING_DISABLED
The object won't use billboarding (default) |
static boolean |
BILLBOARDING_ENABLED
The object will use billboarding (i.e. it always faces the camera) |
static boolean |
BLENDING_DISABLED
Blending (bumpmapping+texturemapping) is not used |
static boolean |
BLENDING_ENABLED
Blending (bumpmapping+texturemapping) is used |
static boolean |
BUMPMAPPING_DISABLED
Bumpmapping is not used |
static boolean |
BUMPMAPPING_ENABLED
Bumpmapping is used |
static int |
COLLISION_CHECK_NONE
Don't perform any kind of collision detection for this object |
static int |
COLLISION_CHECK_OTHERS
Other Object3Ds may collide with this object |
static int |
COLLISION_CHECK_SELF
This Object3D may collide with other objects |
static boolean |
COLLISION_DETECTION_NOT_OPTIMIZED
Disables (default) an automated optimization for collision detection in case of problems with this optimization. |
static boolean |
COLLISION_DETECTION_OPTIMIZED
Enables an automated optimization for speeding up collision detection in some case. |
static float |
COLLISION_NONE
Signals that no collision has been detected for this object |
static boolean |
CULLING_DISABLED
Backface culling won't be applied to this object |
static boolean |
CULLING_ENABLED
Backface culling will be applied to this object before rendering |
static int |
ELLIPSOID_ALIGNED
The object's ellipsoid won't be transformed when performing collision detection (default). |
static int |
ELLIPSOID_TRANSFORMED
The object's ellipsoid will be transformed when performing collision detection. |
static boolean |
ENVMAP_CAMERASPACE
Environment mapping takes place in cameraspace |
static boolean |
ENVMAP_DISABLED
Environment mapping is disabled |
static boolean |
ENVMAP_ENABLED
Environment mapping is enabled |
static boolean |
ENVMAP_WORLDSPACE
Environment mapping takes place in worldspace |
static int |
ENVMAP_XY
'Direction' of spherical environment mapping is XY (default) |
static int |
ENVMAP_XZ
'Direction' of spherical environment mapping is XZ |
static int |
ENVMAP_YZ
'Direction' of spherical environment mapping is YZ |
static boolean |
FILTERING_DISABLED
Filtering is not used on this object |
static boolean |
FILTERING_ENABLED
Filtering is used on this object (where needed) |
static int |
FINALIZE_DEFAULT
Default mode for sector processing |
static int |
FINALIZE_PRESORTX
Alternative mode for sector processing (not very useful at all) |
static int |
FINALIZE_PRESORTY
Alternative mode for sector processing (not very useful at all) |
static int |
FINALIZE_PRESORTZ
Alternative mode for sector processing (not very useful at all) |
static int |
LIGHTING_ALL_ENABLED
Indicates that all kinds of light (lightsources, ambient and additional color) will be used on this object. |
static int |
LIGHTING_NO_LIGHTS
Indicates that no lightsources will be taken into account to calculate an object's lighting. |
static boolean |
MOUSE_SELECTABLE
This object will be processed by the methods of Interact2D |
static boolean |
MOUSE_UNSELECTABLE
This object won't be processed by the methods of Interact2D |
static int |
NO_OBJECT
The "ID" of an Object3D that doesn't exist. |
static boolean |
OBJ_INVISIBLE
The object is invisible and won't be processed, rendered...nothing... |
static boolean |
OBJ_VISIBLE
The object is visible |
static float |
RAY_MISSES_BOX
Signals that a ray/box-intersection test has failed (the ray doesn't intersect with the box) |
static boolean |
SECTOR_AUTODETECT
Use autodetection of the covered sectors (for example for animated objects) |
static boolean |
SECTOR_PRECALCULATED
Use static sector information |
static int |
SHADING_FAKED_FLAT
Indicates that (faked) flat shading should be used. |
static int |
SHADING_GOURAUD
Indicates that gouraud shading should be used (default) |
static boolean |
SPECULAR_DISABLED
Specular highLights won't be calculated |
static boolean |
SPECULAR_ENABLED
Specular highLights will be calculated |
static int |
TRANSPARENCY_MODE_ADD
An alternative transparency mode for additive blending. |
static int |
TRANSPARENCY_MODE_DEFAULT
The default transparency mode and the only one that the legacy software renderer supports. |
static int |
UNKNOWN_OBJECTSIZE
The object is empty |
| Constructor Summary | |
Object3D(int maxTriangles)
Creates a new instance of Object3D. |
|
Object3D(Object3D obj)
This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class. |
|
Object3D(Object3D obj,
boolean reuseMesh)
This constructor works similar to cloneObject() but it allows to extend Object3D and still use the static methods from Loader/Primitives by adding a call to super(Object3D) in the constructor of your class. |
|
| Method Summary | |
void |
addChild(Object3D obj)
Defines an object as a child of this. |
void |
addCollisionListener(CollisionListener listener)
Adds a collision listener to this object. |
void |
addParent(Object3D obj)
Defines an object as a parent of this. this will inherit all transformations from its parent. |
int |
addTriangle(SimpleVector vert1,
float u,
float v,
SimpleVector vert2,
float u2,
float v2,
SimpleVector vert3,
float u3,
float v3)
Adds a triangle to the object. |
int |
addTriangle(SimpleVector vert1,
float u,
float v,
SimpleVector vert2,
float u2,
float v2,
SimpleVector vert3,
float u3,
float v3,
int textureID)
Adds a triangle to the object. |
int |
addTriangle(SimpleVector vert1,
float u,
float v,
SimpleVector vert2,
float u2,
float v2,
SimpleVector vert3,
float u3,
float v3,
int textureID,
int sec)
Adds a triangle to the object. |
int |
addTriangle(SimpleVector vert1,
SimpleVector vert2,
SimpleVector vert3)
Adds a triangle to the object. |
int |
addTriangle(SimpleVector vert1,
SimpleVector vert2,
SimpleVector vert3,
TextureInfo tInf)
Adds a triangle to the object. |
int |
addTriangle(SimpleVector vert1,
SimpleVector vert2,
SimpleVector vert3,
TextureInfo tInf,
int sec)
Adds a triangle to the object. |
void |
align(Camera camera)
Aligns this object with a Camera using the camera's backbuffer matrix. |
void |
align(Object3D object)
Aligns this object with another Object3D. |
void |
animate(float index)
Calculates a new mesh for this object based on the keyframes of its animation sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last. |
void |
animate(float index,
int seq)
Calculates a new mesh for this object based on the keyframes of its animation sub-sequence and "index". index is a value between 0 and 1 where 0 is the first keyframe and 1 the last (of the sub-sequence). |
void |
build()
Initializes some basic object properties that are needed for almost all further processing. build() should be called if the object is "ready to render" (loaded, Textures assigned, placed, rendering modes set...). |
void |
calcBoundingBox()
Calculates an AABB (Axis Aligned Bounding Box) for this object in object-space. |
void |
calcCenter()
Tries to calculate the center of the object using its mesh data. |
float |
calcMinDistance(SimpleVector org,
SimpleVector dr)
Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction. |
float |
calcMinDistance(SimpleVector org,
SimpleVector dr,
float breakIfLarger)
Returns the minimal distance to some polygon of the object from a particular position vector looking into a specific direction. |
void |
calcNormals()
Calculates the object's vertex normals by calculating the face normals of the adjacent polygons of each vertex and averaging them. |
void |
calcTextureWrap()
"Wraps" a texture around the object. |
void |
calcTextureWrapSpherical()
"Wraps" a texture around the object in a spherical way. |
int |
checkForCollision(SimpleVector dirVec,
float step)
Checks if the current object collides with something when moving into a particular direction. |
SimpleVector |
checkForCollisionEllipsoid(SimpleVector translation,
SimpleVector ellipsoid,
int recursionDepth)
Checks if the current object collides with something when moving into a particular direction. |
SimpleVector |
checkForCollisionSpherical(SimpleVector translation,
float radius)
Checks if the current object collides with something when moving into a particular direction. |
void |
clearAdditionalColor()
Removes additional color information form the object. |
void |
clearAnimation()
Clears the animation for this object. |
void |
clearObject()
Clears the object by removing all vertex/mesh information from it. |
Object3D |
cloneObject()
Clones the current object. |
static Object3D |
createDummyObj()
Static method that creates a dummy Object3D. |
void |
createTriangleStrips()
Tries to rebuild the object in a way that it can be rendered by using triangle strips in the most optimal way. |
void |
createTriangleStrips(int maxPasses)
Tries to rebuild the object in a way that it can be rendered by using triangle strips in the most optimal way. |
boolean |
cullingIsInverted()
Returns true, if inverted culling is used on this object. |
void |
decoupleMesh()
Decouples the current mesh from the object. |
void |
disableCollisionListeners()
Disables all collision listeners of this object, so that none of them will be notified in case of a collision. |
void |
disableLazyTransformations()
Disables "lazy transformations". |
void |
disableVertexSharing()
Disables the automatic vertex sharing that jPCT does for triangles added by addTriangle. |
boolean |
ellipsoidIntersectsAABB(SimpleVector org,
SimpleVector ellipsoid)
Checks if a given ellipsoid intersects the axis aligned bounding box (in object-space) of this object. |
void |
enableCollisionListeners()
(Re-)enables all collision listerner of this object. |
void |
enableLazyTransformations()
Enables "lazy transformations". |
java.awt.Color |
getAdditionalColor()
Returns the additional color. |
Animation |
getAnimationSequence()
Returns the animation sequence. |
boolean |
getBlending()
Returns true if blending is enable. |
SimpleVector |
getCenter()
Returns the center of the object (in object-space, i.e. unaffected by any transformation). |
java.util.Enumeration |
getCollisionListeners()
Returns the collision listeners of this object as an enumeration. |
boolean |
getCulling()
Returns the current culling mode. |
int |
getEllipsoidMode()
Returns the current ellipsoid mode. |
boolean |
getEnvmapMode()
Returns the currently used mode for environment mapping (worldspace or cameraspace). |
int |
getID()
Returns the object's ID. |
int |
getLighting()
Gets the lighting mode. |
Mesh |
getMesh()
Returns the current mesh of the object. |
java.lang.String |
getName()
Returns the name of the object. |
static int |
getNextID()
Static method that returns the ID the next object will get. |
OcTree |
getOcTree()
Returns the OcTree assigned to this object or null, if none has been assigned. |
SimpleVector |
getOrigin()
Returns the origin of the object (as set by setOrigin()). |
Matrix |
getOriginMatrix()
Returns the object's origin-translation matrix. |
Object3D[] |
getParents()
Returns all parents of this Object3D in an array. |
PolygonManager |
getPolygonManager()
Returns the PolygonManager for this object. |
Matrix |
getRotationMatrix()
Returns the object's current rotation matrix. |
SimpleVector |
getRotationPivot()
Returns the rotation pivot of the object |
float |
getScale()
Returns the cumulated scale value for this object. |
SimpleVector |
getTransformedCenter()
Returns the center of the object in worldspace, i.e. after the object's current transformations have been applied to it. |
SimpleVector |
getTranslation()
Returns the translation of the object (from its origin to its current position) |
Matrix |
getTranslationMatrix()
Returns the object's current translation matrix. |
int |
getTransparency()
Returns the current tranparency setting. |
int |
getTransparencyMode()
Returns the current transparency mode. |
java.lang.Object |
getUserObject()
Return the user defined object. |
boolean |
getVisibility()
Returns the current visibility state of the object. |
Matrix |
getWorldTransformation()
Returns the transformation matrix used to transform the object from objectspace into worldspace. |
void |
getWorldTransformationInternal(Matrix mat5)
Special purpose method to avoid the creation of an additional matrix where not needed. |
SimpleVector |
getXAxis()
Returns the x-axis of the object. |
SimpleVector |
getYAxis()
Returns the y-axis of the object. |
SimpleVector |
getZAxis()
Returns the z-axis of the object. |
boolean |
hasChild(Object3D obj)
Tests an object for being a child object of the current object. |
boolean |
hasParent(Object3D obj)
Tests an object for being a parent object of the current object. |
void |
invert()
Physically "inverts" the object, which means that the backface culling works the other way round. |
void |
invertCulling(boolean inv)
Inverts culling order if set to true. |
boolean |
isBumpmapped()
Returns if bumpmapping is used or not. |
boolean |
isEnvmapped()
Returns if environment mapping is used or not. |
boolean |
isSelectable()
Returns the current "selectable"-state of the object. |
static Object3D |
mergeObjects(Object3D first,
Object3D second)
Static method that merges two objects into a third one. |
float |
rayIntersectsAABB(SimpleVector org,
SimpleVector dr)
Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object. |
float |
rayIntersectsAABB(SimpleVector org,
SimpleVector dr,
boolean isNormalized)
Checks if a given ray intersects with the axis aligned bounding box (in object-space) of this object. |
void |
rebuild()
The same as build(). |
void |
recreateTextureCoords()
Rebuilds the actual texture coordinates for this object. |
void |
removeChild(Object3D obj)
Removes an object from the child-collection of this. |
void |
removeCollisionListener(CollisionListener listener)
Removes a collision listener from the list of listeners. |
void |
removeMultiTexturing()
Removes all multi texturing information from this object. |
void |
removeParent(Object3D obj)
Removes an object from the parent-collection of this. |
void |
reorderSectors(int mode)
Reorders the object's meshdata by grouping it according to the sectors. |
void |
resetCollisionStatus()
Sets the indicator that the object was a target of the last collision detection to false, i.e. the object won't be recognized any longer as part of the collision. |
static void |
resetNextID()
Resets the internal object-counter. |
void |
rotateAxis(SimpleVector axis,
float angle)
Rotates the object's rotation matrix around an arbitrary axis. |
void |
rotateMesh()
Rotates the raw mesh data using the rotation matrix specified for this object. |
void |
rotateX(float w)
Rotates the object's rotation matrix around the x-axis by the given angle w (radian, counter clockwise for positive values). |
void |
rotateY(float w)
Rotates the object's rotation matrix around the y-axis by the given angle w (radian, clockwise for positive values). |
void |
rotateZ(float w)
Rotates the object's rotation matrix around the z-axis by the given angle w (radian, counter clockwise for positive values). |
void |
scale(float scale)
Scales the object. |
void |
setAdditionalColor(java.awt.Color col)
Sets the additional color for this object. |
void |
setAllTextures(java.lang.String texname,
java.lang.String bumpname)
Sets the textures for an object. |
void |
setAllTextures(java.lang.String basename,
java.lang.String texname,
java.lang.String bumpname)
Sets the textures for an object. |
void |
setAnimationSequence(Animation anim)
Sets the keyframe animation sequence that should be used for this object. |
void |
setAsMultiSectored()
Tells jPCT that this object is a multi-sectored one (for portal rendering). |
void |
setBaseTexture(java.lang.String texname)
Sets the base texture for the whole object. |
void |
setBillboarding(boolean mode)
Enables/disables billboarding for this object. |
void |
setBlending(boolean mode)
Enables/Disables blending for the current object. |
void |
setBoundingBox(float minx,
float maxx,
float miny,
float maxy,
float minz,
float maxz)
Sets a new AABB for the object. |
void |
setBumpmapped(boolean mode)
Enables/Disables enviroment bumpmapping for this object. |
void |
setBumpmapTexture(java.lang.String texname)
Sets the bumpmap of the object. |
void |
setCenter(SimpleVector center)
Sets the center of the object (in object-space). |
void |
setCollisionMode(int mode)
Sets if and how the object will respond to collisions. |
void |
setCollisionOptimization(boolean optimized)
Sets an optimization for collision detection to be used/not used. |
void |
setCulling(boolean mode)
Enables/Disables backface culling for the current object. |
void |
setEllipsoidMode(int mode)
When doing ellipsoid collision detection with this object, the ellipsoid can be transformed according to the objects's transformation and in the source's object space or it remains static in the target's object space (i.e. |
void |
setEnvmapDirection(int dir)
Sets the pair of coordinates from (x,y,z) that will be used for calculating the environment mapping. |
void |
setEnvmapMode(boolean mode)
Sets the mode for environment mapping. |
void |
setEnvmapped(boolean mode)
Enables/Disables environment mapping for the object. |
void |
setFiltering(boolean mode)
Enables/Disables filtering on a per texel basis. |
void |
setLighting(int mode)
Sets the lighting mode. |
void |
setMatrixCacheUsage(boolean useIt)
Enables/Disables the matrix cache. |
void |
setMesh(Mesh mesh)
Sets an object's mesh to another one. |
void |
setName(java.lang.String n)
Sets the name of the object to a name other than the default one. |
static void |
setNextID(int next)
Sets the ID the next object will get. |
void |
setOcTree(OcTree ocTree)
Assigns an octree to the object. |
void |
setOrigin(SimpleVector origin)
Sets the origin of the object. |
void |
setRotationMatrix(Matrix mat)
Sets the rotation matrix for the object. |
void |
setRotationPivot(SimpleVector pivot)
Sets the rotation pivot of the object. |
void |
setScale(float absScale)
Sets an absolute value for the object's scaling. |
void |
setSector(int sector)
Places the object into a specific sector. |
void |
setSectorDetectionMode(boolean mode)
Sets the method used for sector detection. |
void |
setSelectable(boolean mode)
Sets the object as selectable/unselectable. |
void |
setShadingMode(int mode)
jPCT always uses gouraud shading and that can't be disabled. |
void |
setSortOffset(float offset)
Sets on offset for the z-Sorting. |
void |
setSpecularLighting(boolean mode)
Enables/Disables specular lighting for the object. |
void |
setTexture(java.lang.String texname)
Sets the texture for the object. |
void |
setTexture(TextureInfo tInf)
Sets the texture for the object via an instance of TextureInfo. |
void |
setTranslationMatrix(Matrix mat)
Sets the translation matrix for the object. |
void |
setTransparency(int trans)
Sets the object to be transparent using the given level of transparency. |
void |
setTransparencyMode(int mode)
Sets the transparency (blending) mode. |
void |
setUserObject(java.lang.Object obj)
This method is a "workaround" in case you want to give additional information to an Object3D but don't want to (or can't) extend Object3D itself. |
void |
setVisibility(boolean mode)
Sets the object to visible/invisible. |
boolean |
sphereIntersectsAABB(SimpleVector org,
float radius)
Checks if a given sphere intersects the axis aligned bounding box (in object-space) of this object. |
void |
translate(float x,
float y,
float z)
Translates ("moves") the object in worldspace by modifying the translation matrix. |
void |
translate(SimpleVector trans)
Translates ("moves") the object in worldspace by modifying the translation matrix. |
void |
translateMesh()
Translates the raw mesh data using the translation and the origin matrix of this object. |
void |
unbuild()
"Unbuilds" an object, i.e. it takes back some of the changes that build() does to the object, so that new triangles can be added again to this object. |
boolean |
wasTargetOfLastCollision()
True, if this object was a target of the last collision detection that took place (regardless of what kind it was). |
boolean |
wasVisible()
Returns if the object was visible (or at least supposed to be) in the last frame. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final boolean ENVMAP_WORLDSPACE
public static final boolean ENVMAP_CAMERASPACE
public static final boolean ENVMAP_ENABLED
public static final boolean ENVMAP_DISABLED
public static final boolean BUMPMAPPING_ENABLED
public static final boolean BUMPMAPPING_DISABLED
public static final boolean BLENDING_ENABLED
public static final boolean BLENDING_DISABLED
public static final int TRANSPARENCY_MODE_DEFAULT
public static final int TRANSPARENCY_MODE_ADD
public static final boolean BILLBOARDING_ENABLED
public static final boolean BILLBOARDING_DISABLED
public static final boolean MOUSE_SELECTABLE
public static final boolean MOUSE_UNSELECTABLE
public static final boolean FILTERING_ENABLED
public static final boolean FILTERING_DISABLED
public static final boolean CULLING_ENABLED
public static final boolean CULLING_DISABLED
public static final boolean SPECULAR_ENABLED
public static final boolean SPECULAR_DISABLED
public static final int FINALIZE_DEFAULT
public static final int FINALIZE_PRESORTZ
public static final int FINALIZE_PRESORTY
public static final int FINALIZE_PRESORTX
public static final int ENVMAP_XY
public static final int ENVMAP_XZ
public static final int ENVMAP_YZ
public static final boolean OBJ_VISIBLE
public static final boolean OBJ_INVISIBLE
public static final boolean SECTOR_AUTODETECT
public static final boolean SECTOR_PRECALCULATED
public static final int COLLISION_CHECK_NONE
public static final int COLLISION_CHECK_OTHERS
public static final int COLLISION_CHECK_SELF
public static final float COLLISION_NONE
public static final float RAY_MISSES_BOX
public static final boolean COLLISION_DETECTION_OPTIMIZED
public static final boolean COLLISION_DETECTION_NOT_OPTIMIZED
public static final int SHADING_GOURAUD
public static final int SHADING_FAKED_FLAT
public static final int LIGHTING_ALL_ENABLED
public static final int LIGHTING_NO_LIGHTS
public static final int ELLIPSOID_ALIGNED
public static final int ELLIPSOID_TRANSFORMED
public static final int UNKNOWN_OBJECTSIZE
public static final int NO_OBJECT
| Constructor Detail |
public Object3D(int maxTriangles)
maxTriangles - the maximum number of triangles for this object.createDummyObj()public Object3D(Object3D obj)
obj - the Object3D to construct this Object3D from
public Object3D(Object3D obj,
boolean reuseMesh)
obj - the Object3D to construct this Object3D fromreuseMesh - if true, the new object will use the same mesh| Method Detail |
public static Object3D createDummyObj()
World.addObject(com.threed.jpct.Object3D)public void setUserObject(java.lang.Object obj)
obj - Object whatever you like...public java.lang.Object getUserObject()
public void setSortOffset(float offset)
offset - the offset
public static Object3D mergeObjects(Object3D first,
Object3D second)
first - the first object to mergesecond - the second object to merge
public static void resetNextID()
public static int getNextID()
public static void setNextID(int next)
next - the next IDpublic void setAnimationSequence(Animation anim)
anim - the animation sequenceAnimation,
getMesh()public void clearAnimation()
public Animation getAnimationSequence()
public void animate(float index,
int seq)
index - the "time-index" into the sub-sequence of the animationseq - the number of the sub.sequence (sub-sequence start at 1, 0
stands for the animation as a whole)public void animate(float index)
index - the "time-index" into the animationpublic void setCollisionMode(int mode)
mode - The desired mode (COLLISION_CHECK_NONE,
COLLISION_CHECK_OTHERS, COLLISION_CHECK_SELF or combinations)COLLISION_CHECK_NONE,
COLLISION_CHECK_OTHERS,
COLLISION_CHECK_SELFpublic void setCollisionOptimization(boolean optimized)
optimized - should the collision detection be optimized or notCOLLISION_DETECTION_OPTIMIZED,
COLLISION_DETECTION_NOT_OPTIMIZEDpublic void setVisibility(boolean mode)
mode - visible or notOBJ_VISIBLE,
OBJ_INVISIBLEpublic boolean getVisibility()
OBJ_VISIBLE,
OBJ_INVISIBLEpublic void calcBoundingBox()
build()public void createTriangleStrips()