com.threed.jpct
Class World

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

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

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.

See Also:
Serialized Form

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.
 boolean containsObject(Object3D obj)
          Returns true, if an Object3D belongs to this world and false otherwise.
 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, int size, boolean pointMode)
          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.
 float[] getBounds(boolean visibleOnly)
          Returns the world space bounds of all (optional only the visible) objects that belong to this world.
 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 removeAllPolylines()
          Removes all Polylines.
 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)
          Deprecated. Use the equally named method in Camera instead
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

FOGGING_DISABLED

public static final int FOGGING_DISABLED
No linear distance fogging will be used (default)

See Also:
Constant Field Values

FOGGING_ENABLED

public static final int FOGGING_ENABLED
Linear distance fogging will be used.

See Also:
Constant Field Values
Constructor Detail

World

public World()
Creates a new "world". A world is like an empty room that has to be filled with objects and lights. Every instance of world automatically creates an instance of Portals for managing sectors and portals within this world and an instance of Lights for managing the light sources. Additionally, the TextureManager for this VM is known to the world.

Method Detail

dispose

public void dispose()
Disposes the world. This method should be called before the world goes out of scope. This frees some resources that may otherwise be locked.


getSize

public int getSize()
Returns the number of user defined objects in this World.

Returns:
the number of objects

getCamera

public Camera getCamera()
Gets the current camera.

Returns:
the current camera

newCamera

public void newCamera()
Resets the camera to origin looking along the z-axis. This is the position and orientation the camera has after creating a new "world".


setCameraTo

public void setCameraTo(Camera cam)
Sets the camera to another one.

Parameters:
cam - the camera to use

setClippingPlanes

public void setClippingPlanes(float near,
                              float far)
Deprecated. Use the equally named method in Camera instead

If set, this overrides the settings in Config for the near and the far clipping plane for this world. If you don't touch this method, the settings in Config will be taken instead.
This method is deprecated and only here for compatibility reasons. The setting has moved into the Camera class. Calling this method here is just a shortcut to getCamera().setClippingPlanes(...).

Parameters:
near - the near plane
far - the far plane
See Also:
Config.farPlane, Config.nearPlane, Camera.setClippingPlanes(float, float)

removeObject

public void removeObject(int id)
Removes the object with the specified ID from the World's object collection. This method doesn't check for child/parent objects of the removed object, which will remain intact.

Parameters:
id - the ID of the object to remove

removeObject

public void removeObject(Object3D obj)
Removes the given object from the World's object collection. This method doesn't check for child/parent objects of the removed object, which will remain intact.

Parameters:
obj - the object to remove

getObject

public Object3D getObject(int id)
Returns the object with the given ID from the World's object collection. Raises an error, if the object doesn't exist.

Parameters:
id - the ID of the object
Returns:
the object

containsObject

public boolean containsObject(Object3D obj)
Returns true, if an Object3D belongs to this world and false otherwise.

Parameters:
obj - the object in question
Returns:
true or false

getObjectByName

public Object3D getObjectByName(java.lang.String name)
Returns the object named "name" from the World's object collection. This is an alternative albeit slower way to retrieve objects from the World. A better idea would be not ot lose them anyway...:-)

Parameters:
name - the name of the object
Returns:
the object or null if it doesn't exist

addObject

public int addObject(Object3D obj)
Adds an object to the World's object collection. The object will be referenced in this collection by its ID. The ID of the object in the collection is the same as the object's own ID. addObject() also returns this ID due to "historical reasons". So id=addObject(obj) is basically the same as id=obj.getID(); addObject(obj); Note: Current implementation limits the object-World bindings in a way that an object can only be added to one world at a time. This method doesn't check if the object has been added multiple times. This may change later.

Parameters:
obj - the object to be added
Returns:
the ID of the object in this World's collection
See Also:
Object3D.getID()

addObjects

public void addObjects(Object3D... objs)
Adds all objects from the given array to the world. This can be useful, if one wants to add a Object3Ds loaded by the 3DS/OBJ loaders to a world at once.

Parameters:
objs - the objects

setAmbientLight

public void setAmbientLight(int r,
                            int g,
                            int b)
Sets the light intensity for the ambient light source.
Setting this is negative values will darken the whole scene while positive ones will light up everything.

Parameters:
r - the red component (100 is default)
g - the red component (100 is default)
b - the red component (100 is default)

getAmbientLight

public int[] getAmbientLight()
Returns the ambient light's intensities in an int[]-array in r,g,b order.

Returns:
the light's intensities

setFogging

public void setFogging(int fog)
Enables/Disables linear distance-fogging

Parameters:
fog - fogging enabled or not
See Also:
FOGGING_ENABLED, FOGGING_DISABLED, setFogParameters(float, float, float, float)

getFogging

public int getFogging()
Returns if fogging is being used or not.

Returns:
fogging usage
See Also:
FOGGING_ENABLED, FOGGING_DISABLED

setFogParameters

public void setFogParameters(float distance,
                             float red,
                             float green,
                             float blue)
Sets the parameters for the linear distance fog (if enabled). *

Parameters:
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)

setFogParameters

public void setFogParameters(float start,
                             float distance,
                             float red,
                             float green,
                             float blue)
Sets the parameters for the linear distance fog (if enabled).

Parameters:
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)

checkCollision

public 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. The method can be used to implement various kinds of collision detection/response and uses a ray-polygon collision detection. All objects should have been set to an appropiate collision mode.

Parameters:
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)
Returns:
the ID of the Object3D if there is a collision, otherwise NO_OBJECT
See Also:
Object3D.getID(), Object3D.NO_OBJECT

checkCollisionSpherical

public 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. The method can be used to implement various kinds of collision detection/response and uses a sphere-polygon collision detection. All objects should have been set to an appropiate collision mode.

Parameters:
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)
Returns:
a SimpleVector containing the corrected translation (i.e. the translation that should be used to avoid a collision) or, if no collision takes place, the translation from the call (i.e. no collision means returned SimpleVector.equals(translation)).

checkCollisionEllipsoid

public 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. The method can be used to implement various kinds of collision detection/response and uses a (swept)ellipsoid-polygon collision detection. All objects should have been set to an appropiate collision mode.

Parameters:
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 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 the corrected translation (i.e. the translation that should be used to avoid a collision) or, if no collision takes place, the translation from the call (i.e. no collision means returned SimpleVector.equals(translation)).

checkCameraCollision

public 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. If not, the camera will "slide" in the remaining directions. Uses a ray-polygon collision detection.

Parameters:
mode - the direction (relative to its orientation)
moveSpeed - the number of units the camera should move
Returns:
true if the camera collided with something, otherwise false
See Also:
Camera.CAMERA_MOVEDOWN, Camera.CAMERA_MOVEUP, Camera.CAMERA_MOVEIN, Camera.CAMERA_MOVEOUT, Camera.CAMERA_MOVELEFT, Camera.CAMERA_MOVERIGHT

checkCameraCollision

public 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. Uses a ray-polygon collision detection.

Parameters:
mode - the direction (relative to its orientation)
moveSpeed - the number of units the camera should move
slideMode - indicates if the camera should slide or just stand still in case of collision
Returns:
true if the camera collided with something, otherwise false
See Also:
Camera.CAMERA_MOVEDOWN, Camera.CAMERA_MOVEUP, Camera.CAMERA_MOVEIN, Camera.CAMERA_MOVEOUT, Camera.CAMERA_MOVELEFT, Camera.CAMERA_MOVERIGHT, Camera.SLIDE, Camera.DONT_SLIDE

checkCameraCollision

public 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. Uses a ray-polygon collision detection.

Parameters:
mode - the direction (relative to its orientation)
moveSpeed - the number of units the camera should move
distance - 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
Returns:
true if the camera collided with something, otherwise false
See Also:
Camera.CAMERA_MOVEDOWN, Camera.CAMERA_MOVEUP, Camera.CAMERA_MOVEIN, Camera.CAMERA_MOVEOUT, Camera.CAMERA_MOVELEFT, Camera.CAMERA_MOVERIGHT, Camera.SLIDE, Camera.DONT_SLIDE

checkCameraCollision

public 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. Uses a ray-polygon collision detection.

Parameters:
direction - the direction (should be a normalized vector (i.e. a length of 1))
moveSpeed - the number of units the camera should move
distance - 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
Returns:
true if the camera collided with something, otherwise false
See Also:
Camera.SLIDE, Camera.DONT_SLIDE

calcMinDistanceAndObject3D

public 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. It only takes polygons into consideration that have at least one vertex that is closer than ignoreIfLarger units to the position vector and whose bounding box/octree-node is closer than that value too.
In addition to calcMinDistance(), this method returns the object to which the polygon belongs.

Parameters:
orig - a SimpleVector containing the x,y,z-coordinates of the position vector
dir - 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
Returns:
the minimal distance to some polygon (= how far can one move into this direction until something will be hit) and the object to which this polygon belongs in an Object[] containing a Float at position 0 and an Object3D on position 1. If there is no such polygon, the array will contain [COLLISION_NONE, null].
See Also:
Object3D.COLLISION_NONE

calcMinDistance

public 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. It only takes polygons into consideration that have at least one vertex that is closer than ignoreIfLarger units to the position vector and whose bounding box/octree-node is closer than that value too.

Parameters:
orig - a SimpleVector containing the x,y,z-coordinates of the position vector
dir - 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
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:
Object3D.COLLISION_NONE

checkCameraCollisionSpherical

public 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. Uses a sphere-polygon collision detection. This method can be used in CAMERA_DONT_MOVE-mode too, where the camera will only be adjusted automatically if anything that is a collider has moved in its way.

Parameters:
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 move
slideMode - indicates if the camera should slide or just stand still in case of collision
Returns:
true if the camera collided with something, otherwise false
See Also:
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

checkCameraCollisionSpherical

public 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. Uses a sphere-polygon collision detection.

Parameters:
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 move
slideMode - indicates if the camera should slide or just stand still in case of collision
Returns:
true if the camera collided with something, otherwise false
See Also:
Camera.SLIDE, Camera.DONT_SLIDE

checkCameraCollisionEllipsoid

public 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. Uses a (swept)ellipsoid-polygon collision detection. This method will always use sliding.

Parameters:
mode - the direction (relative to its orientation)
ellipsoid - the radius of the epplisoid in x,y and z direction
moveSpeed - the number of units the camera should move
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:
true if the camera collided with something, otherwise false
See Also:
Camera.CAMERA_MOVEDOWN, Camera.CAMERA_MOVEUP, Camera.CAMERA_MOVEIN, Camera.CAMERA_MOVEOUT, Camera.CAMERA_MOVELEFT, Camera.CAMERA_MOVERIGHT, Camera.CAMERA_DONT_MOVE

checkCameraCollisionEllipsoid

public 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. Uses a (swept)ellipsoid-polygon collision detection. This method will always use sliding.

Parameters:
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 direction
moveSpeed - the number of units the camera should move
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:
true if the camera collided with something, otherwise false

buildAllObjects

public void buildAllObjects()
Calls build() for every object in the world.

See Also:
Object3D.build()

compileAllObjects

public void compileAllObjects()
Compiles all objects in the world for better gpu processing. You don't have to call this method, because it will be done on demand anyway. However, it may be better to compile all objects before starting the actual render loop to avoid hick-ups when auto-compiling while drawing things. Already compiled objects won't be affected.


renderScene

public void renderScene(FrameBuffer buffer)
Transforms and lights all the polygons. This method does everything required to start drawing the current scene. It just doesn't scanconvert the results. This is done by the draw()-method. This method has to be called at least once before blitting into the FrameBuffer will work correctly. If you are not abusing jPCT as a pure 2D blitting engine, then this shouldn't be a problem anyway.

Parameters:
buffer - the framebuffer that should be used for rendering
See Also:
draw(com.threed.jpct.FrameBuffer)

draw

public void draw(FrameBuffer buffer)
Draws the current scene that has been generated geometry wise by renderScene(). Usually, renderScene() and draw() are used one right after the other (with draw being the last).

Parameters:
buffer - the framebuffer that should be used for rendering
See Also:
renderScene(com.threed.jpct.FrameBuffer)

drawWireframe

public void drawWireframe(FrameBuffer buffer,
                          RGBColor color,
                          int size,
                          boolean pointMode)
Draws the current scene as a single-colored wireframe. This is done using the same buffer draw() draws into. drawWireframe() can be called instead of draw() to get the wireframe only as well as right after draw() to combine the two renderings for some special effects. Calling drawWireframe() before draw() doesn't make much sense.
Because of a "great" design decision in OpenGL ES, the result might not look particularly good though.

Parameters:
buffer - the framebuffer that should be used for rendering
color - the wireframe's color
size - the size of the primitive, i.e. the width of a line of the size of a point
pointMode - if true, it will render points instead of lines

getFrameCounter

public long getFrameCounter()
Returns the number of frames rendered since startup.

Returns:
the number of frames (to be precise: how often draw() has been called)

getObjects

public java.util.Enumeration<Object3D> getObjects()
Returns an Enumeration of all user defined objects in this world.

Returns:
the objects (instances of Object3D)

setObjectsVisibility

public void setObjectsVisibility(boolean visible)
Sets the visibility for all objects that belong to a world.

Parameters:
visible - visible or not?

removeAll

public void removeAll()
Removes all lights and objects from the world.


removeAllObjects

public void removeAllObjects()
Removes all but the internal objects from the world. The world is empty after calling this method.


removeAllLights

public void removeAllLights()
Removes all lights from the world. The scene will be lit by ambient lighting only after calling this method.


addPolyline

public void addPolyline(Polyline line)
Adds a new Polyline to the world. A Polyline is a line strip with a color that will be drawn into the scene after all other objects has been drawn. A Polyline's coordinates are to be given in world space. You can add multiple Polylines to a world.

Parameters:
line - the Polyline

removePolyline

public void removePolyline(Polyline line)
Removes a Polyline from a world.

Parameters:
line - the line

removeAllPolylines

public void removeAllPolylines()
Removes all Polylines.


setDefaultThread

public static void setDefaultThread(java.lang.Thread def)
jPCT's methods might be called from within different threads. However, it's very likely that one thread will do most of the work while others may run less often or doing less work. With this method, it's possible to tell jPCT which is the "default" thread, i.e. the thread that does most of the work. If jPCT knows this, some optimizations for this thread can be performed. Note that this value isn't serialized if World is.
If you don't set this value, jPCT will auto-detect the default thread.

Parameters:
def - the "default" thread

getDefaultThread

public static java.lang.Thread getDefaultThread()
Returns the default thread or null if none has been set.

Returns:
the thread or null

setGlobalShader

public void setGlobalShader(GLSLShader globalShader)
Sets a global shader. If set, this shader will be applied to all objects that have no own shader assigned.

Parameters:
globalShader - the global shader

getGlobalShader

public GLSLShader getGlobalShader()
Returns the global shader or null if none has been set.

Returns:
the global shader

getBounds

public float[] getBounds(boolean visibleOnly)
Returns the world space bounds of all (optional only the visible) objects that belong to this world. Or in other words: All vertices of all objects in this world will be located inside the returned bounding box. Format of the return array is minX, maxX, minY, maxY, minZ, maxZ.

Parameters:
visibleOnly - if true, only visible objects will be taken into account. If false, all objects will.
Returns:
the bounding box