|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.threed.jpct.World
public class World
The World class is the most important class in jPCT. It's like the "glue" that holds everything together. The world contains objects and light sources that define the scene for jPCT.
Field Summary | |
---|---|
static int |
FOGGING_DISABLED
No linear distance fogging will be used (default) |
static int |
FOGGING_ENABLED
Linear distance fogging will be used. |
Constructor Summary | |
---|---|
World()
Creates a new "world". |
Method Summary | |
---|---|
int |
addObject(Object3D obj)
Adds an object to the World's object collection. |
void |
addObjects(Object3D[] objs)
Adds all objects from the given array to the world. |
void |
addPolyline(Polyline line)
Adds a new Polyline to the world. |
void |
buildAllObjects()
Calls build() for every object in the world. |
float |
calcMinDistance(SimpleVector orig,
SimpleVector dir,
float ignoreIfLarger)
Returns the minimal distance to some polygon of the world's objects (have to be colliders) from a particular position vector looking into a specific direction. |
java.lang.Object[] |
calcMinDistanceAndObject3D(SimpleVector orig,
SimpleVector dir,
float ignoreIfLarger)
Returns the minimal distance to some polygon of the world's objects (have to be colliders) from a particular position vector looking into a specific direction. |
boolean |
checkCameraCollision(int mode,
float moveSpeed)
Moves the camera moveSpeed units from its current position and regarding its current orientation into "mode" direction, if this is possible. |
boolean |
checkCameraCollision(int mode,
float moveSpeed,
boolean slideMode)
Moves the camera moveSpeed units from its current position and regarding its current orientation into "mode" direction, if this is possible. |
boolean |
checkCameraCollision(int mode,
float moveSpeed,
float distance,
boolean slideMode)
Moves the camera moveSpeed units from its current position and regarding its current orientation into "mode" direction, if this is possible. |
boolean |
checkCameraCollision(SimpleVector direction,
float moveSpeed,
float distance,
boolean slideMode)
Moves the camera moveSpeed units from its current position into an arbitrary direction, if this is possible. |
boolean |
checkCameraCollisionEllipsoid(int mode,
SimpleVector ellipsoid,
float moveSpeed,
int recursionDepth)
Moves the camera moveSpeed units from its current position into an arbitrary direction, if this is possible. |
boolean |
checkCameraCollisionEllipsoid(SimpleVector direction,
SimpleVector ellipsoid,
float moveSpeed,
int recursionDepth)
Moves the camera moveSpeed units from its current position into an arbitrary direction, if this is possible. |
boolean |
checkCameraCollisionSpherical(int mode,
float radius,
float moveSpeed,
boolean slideMode)
Moves the camera moveSpeed units from its current position and regarding its current orientation into "mode" direction, if this is possible. |
boolean |
checkCameraCollisionSpherical(SimpleVector direction,
float radius,
float moveSpeed,
boolean slideMode)
Moves the camera moveSpeed units from its current position into an arbitrary direction, if this is possible. |
int |
checkCollision(SimpleVector org,
SimpleVector dr,
float step)
Checks if a collision between "something" and an object would take place if this "something" would move step units from its position into a given direction. |
SimpleVector |
checkCollisionEllipsoid(SimpleVector org,
SimpleVector translation,
SimpleVector ellipsoid,
int recursionDepth)
Checks if a collision between "something" and an object would take place if this "something" would move step units from its position into a given direction. |
SimpleVector |
checkCollisionSpherical(SimpleVector org,
SimpleVector translation,
float radius)
Checks if a collision between "something" and an object would take place if this "something" would move step units from its position into a given direction. |
void |
compileAllObjects()
Compiles all objects in the world for better gpu processing. |
void |
dispose()
Disposes the world. |
void |
draw(FrameBuffer buffer)
Draws the current scene that has been generated geometry wise by renderScene(). |
void |
drawWireframe(FrameBuffer buffer,
RGBColor color)
Draws the current scene as a single-colored wireframe. |
int[] |
getAmbientLight()
Returns the ambient light's intensities in an int[]-array in r,g,b order. |
Camera |
getCamera()
Gets the current camera. |
static java.lang.Thread |
getDefaultThread()
Returns the default thread or null if none has been set. |
int |
getFogging()
Returns if fogging is being used or not. |
long |
getFrameCounter()
Returns the number of frames rendered since startup. |
GLSLShader |
getGlobalShader()
Returns the global shader or null if none has been set. |
Object3D |
getObject(int id)
Returns the object with the given ID from the World's object collection. |
Object3D |
getObjectByName(java.lang.String name)
Returns the object named "name" from the World's object collection. |
java.util.Enumeration<Object3D> |
getObjects()
Returns an Enumeration of all user defined objects in this world. |
int |
getSize()
Returns the number of user defined objects in this World. |
void |
newCamera()
Resets the camera to origin looking along the z-axis. |
void |
removeAll()
Removes all lights and objects from the world. |
void |
removeAllLights()
Removes all lights from the world. |
void |
removeAllObjects()
Removes all but the internal objects from the world. |
void |
removeObject(int id)
Removes the object with the specified ID from the World's object collection. |
void |
removeObject(Object3D obj)
Removes the given object from the World's object collection. |
void |
removePolyline(Polyline line)
Removes a Polyline from a world. |
void |
renderScene(FrameBuffer buffer)
Transforms and lights all the polygons. |
void |
setAmbientLight(int r,
int g,
int b)
Sets the light intensity for the ambient light source. |
void |
setCameraTo(Camera cam)
Sets the camera to another one. |
void |
setClippingPlanes(float near,
float far)
If set, this overrides the settings in Config for the near and the far clipping plane for this world. |
static void |
setDefaultThread(java.lang.Thread def)
jPCT's methods might be called from within different threads. |
void |
setFogging(int fog)
Enables/Disables linear distance-fogging |
void |
setFogParameters(float distance,
float red,
float green,
float blue)
Sets the parameters for the linear distance fog (if enabled) |
void |
setFogParameters(float start,
float distance,
float red,
float green,
float blue)
Sets the parameters for the linear distance fog (if enabled). |
void |
setGlobalShader(GLSLShader globalShader)
Sets a global shader. |
void |
setObjectsVisibility(boolean visible)
Sets the visibility for all objects that belong to a world. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FOGGING_DISABLED
public static final int FOGGING_ENABLED
Constructor Detail |
---|
public World()
Method Detail |
---|
public void dispose()
public int getSize()
public Camera getCamera()
public void newCamera()
public void setCameraTo(Camera cam)
cam
- the camera to usepublic void setClippingPlanes(float near, float far)
near
- the near planefar
- the far planeConfig.farPlane
,
Config.nearPlane
public void removeObject(int id)
id
- the ID of the object to removepublic void removeObject(Object3D obj)
obj
- the object to removepublic Object3D getObject(int id)
id
- the ID of the object
public Object3D getObjectByName(java.lang.String name)
name
- the name of the object
public int addObject(Object3D obj)
obj
- the object to be added
Object3D.getID()
public void addObjects(Object3D[] objs)
objs
- the objectspublic void setAmbientLight(int r, int g, int b)
r
- the red component (100 is default)g
- the red component (100 is default)b
- the red component (100 is default)public int[] getAmbientLight()
public void setFogging(int fog)
fog
- fogging enabled or notFOGGING_ENABLED
,
FOGGING_DISABLED
,
setFogParameters(float, float, float, float)
public int getFogging()
FOGGING_ENABLED
,
FOGGING_DISABLED
public void setFogParameters(float distance, float red, float green, float blue)
distance
- the distance in camera-space coordinates at which the fog
reaches its maximum density (150 is default, 1 is minimum)red
- the red component of the fog ([0..255], 0 is default)green
- the green component of the fog ([0..255], 0 is default)blue
- the blue component of the fog ([0..255], 0 is default)public void setFogParameters(float start, float distance, float red, float green, float blue)
start
- where the fog actually starts.distance
- the distance in camera-space coordinates at which the fog
reaches its maximum density (150 is default, 1 is minimum)red
- the red component of the fog ([0..255], 0 is default)green
- the green component of the fog ([0..255], 0 is default)blue
- the blue component of the fog ([0..255], 0 is default)public int checkCollision(SimpleVector org, SimpleVector dr, float step)
org
- the position vector of "something"dr
- the direction vector of "something" (a unit vector, if not
it'll be made one)step
- the length of the casted ray (a collision will only be
detected of it takes place within this range)
Object3D.getID()
,
Object3D.NO_OBJECT
public SimpleVector checkCollisionSpherical(SimpleVector org, SimpleVector translation, float radius)
org
- the position vector of "something"translation
- that should be applied to "something" (Note that this method
just checks this translation...it doesn't apply it)radius
- the radius of the sphere (a collision will only be detected of
it takes place within this radius)
public SimpleVector checkCollisionEllipsoid(SimpleVector org, SimpleVector translation, SimpleVector ellipsoid, int recursionDepth)
org
- the position vector of "something"translation
- that should be applied to "something" (Note that this method
just checks this translation...it doesn't apply it)ellipsoid
- the radius of the epplisoid in x,y and z directionrecursionDepth
- 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.
public boolean checkCameraCollision(int mode, float moveSpeed)
mode
- the direction (relative to its orientation)moveSpeed
- the number of units the camera should move
Camera.CAMERA_MOVEDOWN
,
Camera.CAMERA_MOVEUP
,
Camera.CAMERA_MOVEIN
,
Camera.CAMERA_MOVEOUT
,
Camera.CAMERA_MOVELEFT
,
Camera.CAMERA_MOVERIGHT
public boolean checkCameraCollision(int mode, float moveSpeed, boolean slideMode)
mode
- the direction (relative to its orientation)moveSpeed
- the number of units the camera should moveslideMode
- indicates if the camera should slide or just stand still in
case of collision
Camera.CAMERA_MOVEDOWN
,
Camera.CAMERA_MOVEUP
,
Camera.CAMERA_MOVEIN
,
Camera.CAMERA_MOVEOUT
,
Camera.CAMERA_MOVELEFT
,
Camera.CAMERA_MOVERIGHT
,
Camera.SLIDE
,
Camera.DONT_SLIDE
public boolean checkCameraCollision(int mode, float moveSpeed, float distance, boolean slideMode)
mode
- the direction (relative to its orientation)moveSpeed
- the number of units the camera should movedistance
- the maximum distance the position vector can have from the
polygon before a collision is detected.slideMode
- indicates if the camera should slide or just stand still in
case of collision
Camera.CAMERA_MOVEDOWN
,
Camera.CAMERA_MOVEUP
,
Camera.CAMERA_MOVEIN
,
Camera.CAMERA_MOVEOUT
,
Camera.CAMERA_MOVELEFT
,
Camera.CAMERA_MOVERIGHT
,
Camera.SLIDE
,
Camera.DONT_SLIDE
public boolean checkCameraCollision(SimpleVector direction, float moveSpeed, float distance, boolean slideMode)
direction
- the direction (should be a normalized vector (i.e. a length of
1))moveSpeed
- the number of units the camera should movedistance
- the maximum distance the position vector can have from the
polygon before a collision is detected.slideMode
- indicates if the camera should slide or just stand still in
case of collision
Camera.SLIDE
,
Camera.DONT_SLIDE
public java.lang.Object[] calcMinDistanceAndObject3D(SimpleVector orig, SimpleVector dir, float ignoreIfLarger)
orig
- a SimpleVector containing the x,y,z-coordinates of the
position vectordir
- a SimpleVector array containing the x,y,z-coordinates of the
direction vector (a unit vector)ignoreIfLarger
- only polygons/bounding boxes/octree-nodes within this range
will be taken into account
Object3D.COLLISION_NONE
public float calcMinDistance(SimpleVector orig, SimpleVector dir, float ignoreIfLarger)
orig
- a SimpleVector containing the x,y,z-coordinates of the
position vectordir
- a SimpleVector array containing the x,y,z-coordinates of the
direction vector (a unit vector)ignoreIfLarger
- only polygons/bounding boxes/octree-nodes within this range
will be taken into account
Object3D.COLLISION_NONE
public boolean checkCameraCollisionSpherical(int mode, float radius, float moveSpeed, boolean slideMode)
mode
- the direction (relative to its orientation)radius
- the radius of the sphere. A collision will only be detected
within this radius.moveSpeed
- the number of units the camera should moveslideMode
- indicates if the camera should slide or just stand still in
case of collision
Camera.CAMERA_MOVEDOWN
,
Camera.CAMERA_MOVEUP
,
Camera.CAMERA_MOVEIN
,
Camera.CAMERA_MOVEOUT
,
Camera.CAMERA_MOVELEFT
,
Camera.CAMERA_MOVERIGHT
,
Camera.CAMERA_DONT_MOVE
,
Camera.SLIDE
,
Camera.DONT_SLIDE
public boolean checkCameraCollisionSpherical(SimpleVector direction, float radius, float moveSpeed, boolean slideMode)
direction
- the direction (should be a normalized vector (i.e. a length of
1))radius
- the radius of the sphere. A collision will only be detected
within this radius.moveSpeed
- the number of units the camera should moveslideMode
- indicates if the camera should slide or just stand still in
case of collision
Camera.SLIDE
,
Camera.DONT_SLIDE
public boolean checkCameraCollisionEllipsoid(int mode, SimpleVector ellipsoid, float moveSpeed, int recursionDepth)
mode
- the direction (relative to its orientation)ellipsoid
- the radius of the epplisoid in x,y and z directionmoveSpeed
- the number of units the camera should moverecursionDepth
- 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.
Camera.CAMERA_MOVEDOWN
,
Camera.CAMERA_MOVEUP
,
Camera.CAMERA_MOVEIN
,
Camera.CAMERA_MOVEOUT
,
Camera.CAMERA_MOVELEFT
,
Camera.CAMERA_MOVERIGHT
,
Camera.CAMERA_DONT_MOVE
public boolean checkCameraCollisionEllipsoid(SimpleVector direction, SimpleVector ellipsoid, float moveSpeed, int recursionDepth)
direction
- the direction (should be a normalized vector (i.e. a length of
1))ellipsoid
- the radius of the epplisoid in x,y and z directionmoveSpeed
- the number of units the camera should moverecursionDepth
- 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.
public void buildAllObjects()
Object3D.build()
public void compileAllObjects()
public void renderScene(FrameBuffer buffer)
buffer
- the framebuffer that should be used for renderingdraw(com.threed.jpct.FrameBuffer)
public void draw(FrameBuffer buffer)
buffer
- the framebuffer that should be used for renderingrenderScene(com.threed.jpct.FrameBuffer)
public void drawWireframe(FrameBuffer buffer, RGBColor color)
buffer
- the framebuffer that should be used for renderingcolor
- the wireframe's colorpublic long getFrameCounter()
public java.util.Enumeration<Object3D> getObjects()
public void setObjectsVisibility(boolean visible)
visible
- visible or not?public void removeAll()
public void removeAllObjects()
public void removeAllLights()
public void addPolyline(Polyline line)
line
- the Polylinepublic void removePolyline(Polyline line)
line
- the linepublic static void setDefaultThread(java.lang.Thread def)
def
- the "default" threadpublic static java.lang.Thread getDefaultThread()
public void setGlobalShader(GLSLShader globalShader)
globalShader
- the global shaderpublic GLSLShader getGlobalShader()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |