simbad.sim
Class World

java.lang.Object
  extended by simbad.sim.World

public class World
extends java.lang.Object

Represents a 3d world - this class use intensively JAVA3D. It creates the scenegraph and the view platform. The building process uses a EnvironmentDescription object containing colors , objects and attributes given by the user. This class is thighly coupled with Simulator Class. Remember to call System.setProperty("j3d.implicitAntialiasing", "true") at the very beginning of your program in order to enable antialiasing.


Field Summary
private  javax.media.j3d.AmbientLight ambientLight
           
(package private)  javax.vecmath.Color3f black
           
private  javax.media.j3d.Canvas3D canvas3d
          The main canvas for viewing the world.
private  javax.media.j3d.Light light1
           
private  javax.media.j3d.Light light2
           
(package private)  MouseOrbiter mouseOrbiter
          For managing the mouse mouvement in the Canvas3D
private  javax.media.j3d.BranchGroup pickableSceneBranch
          All the pickable/collidable objects should be attached under this sub-branch
private  javax.media.j3d.BranchGroup sceneBranch
          The content branch.
private  javax.media.j3d.TransformGroup sceneRot
          The base rotation of the sceneBranch.
private  javax.media.j3d.TransformGroup sceneTrans
          The base translation of the sceneBranch.
private  boolean show3d
           
(package private)  javax.media.j3d.VirtualUniverse universe
          J3D universe
private  javax.media.j3d.View view
           
static int VIEW_ABOVE_AGENT
           
static int VIEW_ABOVE_AGENT_NEAR
           
static int VIEW_AGENT_SIDE
           
static int VIEW_BEHIND_AGENT
           
static int VIEW_FROM_EAST
           
static int VIEW_FROM_TOP
           
private  javax.media.j3d.BranchGroup viewBranch
          The view branch
private  javax.media.j3d.ViewPlatform viewPlatform
           
private  javax.media.j3d.TransformGroup viewTransformGroup
           
(package private)  javax.vecmath.Color3f white
          Prepared colors.
protected  float worldSize
          The size of the square containing the world
 
Constructor Summary
World(EnvironmentDescription ed)
          Construct a World from a given EnvironmentDescription.
World(EnvironmentDescription ed, boolean display3d)
          Construct a World from a given EnvironmentDescription.
 
Method Summary
(package private)  javax.media.j3d.Light addLight(javax.vecmath.Vector3d pos, javax.vecmath.Color3f color)
          Add a light to the 3d world.
 void addObjectToPickableSceneBranch(BaseObject obj3d)
          Adds a 3D object to the world.
 void attach(BaseObject obj3d)
          attach a 3d object to the scenegraph.
 void changeViewPoint(int type, SimpleAgent agent)
          Change the user view Point .
(package private)  boolean checkCollisionAgainstBlockWorldObjects(javax.media.j3d.BoundingSphere bs)
           
private  void create(EnvironmentDescription ed)
          Creates the world from the given environement Description.
private  void createAxis()
          Creates a representation of the 3 axis of the 3d world.
private  void createCanvas3D()
          Creates the Canvas3D to visualize the 3D World.
private  void createFloor(EnvironmentDescription wd)
          Creates the floor of the 3d world.
private  void createSceneBranch(EnvironmentDescription wd)
          Creates the branch for the visible content of the scenegraph.
private  void createUniverse(EnvironmentDescription ed)
          Creates the universe to attach the scenegraph.
 void detach(BaseObject obj3d)
          Detach a previously attached object from the scenegraph.
 void dispose()
          Destroy the java3d graph
 javax.media.j3d.Canvas3D getCanvas3D()
           
(package private)  javax.media.j3d.BranchGroup getPickableSceneBranch()
           
 void renderOnce()
          Do one rendering on main canvas 3D .
 void startRendering()
          Restart rendering on main canvas 3D .
 void stopRendering()
          Stop rendering on main canvas 3D .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

universe

javax.media.j3d.VirtualUniverse universe
J3D universe


sceneBranch

private javax.media.j3d.BranchGroup sceneBranch
The content branch.


sceneTrans

private javax.media.j3d.TransformGroup sceneTrans
The base translation of the sceneBranch.


sceneRot

private javax.media.j3d.TransformGroup sceneRot
The base rotation of the sceneBranch.


pickableSceneBranch

private javax.media.j3d.BranchGroup pickableSceneBranch
All the pickable/collidable objects should be attached under this sub-branch


viewBranch

private javax.media.j3d.BranchGroup viewBranch
The view branch


viewTransformGroup

private javax.media.j3d.TransformGroup viewTransformGroup

viewPlatform

private javax.media.j3d.ViewPlatform viewPlatform

view

private javax.media.j3d.View view

canvas3d

private javax.media.j3d.Canvas3D canvas3d
The main canvas for viewing the world.


show3d

private boolean show3d

mouseOrbiter

MouseOrbiter mouseOrbiter
For managing the mouse mouvement in the Canvas3D


ambientLight

private javax.media.j3d.AmbientLight ambientLight

light1

private javax.media.j3d.Light light1

light2

private javax.media.j3d.Light light2

VIEW_FROM_TOP

public static final int VIEW_FROM_TOP
See Also:
Constant Field Values

VIEW_FROM_EAST

public static final int VIEW_FROM_EAST
See Also:
Constant Field Values

VIEW_BEHIND_AGENT

public static final int VIEW_BEHIND_AGENT
See Also:
Constant Field Values

VIEW_ABOVE_AGENT

public static final int VIEW_ABOVE_AGENT
See Also:
Constant Field Values

VIEW_ABOVE_AGENT_NEAR

public static final int VIEW_ABOVE_AGENT_NEAR
See Also:
Constant Field Values

VIEW_AGENT_SIDE

public static final int VIEW_AGENT_SIDE
See Also:
Constant Field Values

worldSize

protected float worldSize
The size of the square containing the world


white

javax.vecmath.Color3f white
Prepared colors.


black

javax.vecmath.Color3f black
Constructor Detail

World

public World(EnvironmentDescription ed)
Construct a World from a given EnvironmentDescription.


World

public World(EnvironmentDescription ed,
             boolean display3d)
Construct a World from a given EnvironmentDescription. Setting the second parameter to false will cause this world canvas to be created in background mode. Make sure you set up an: ImageComponent2D for your buffer and set the following; canvas3d.setOffScreenBuffer(img); canvas3d.getScreen3D().setSize(100, 100); canvas3d.getScreen3D().setPhysicalScreenWidth(0.1); canvas3d.getScreen3D().setPhysicalScreenHeight(0.1); canvas3d.renderOffScreenBuffer();

Method Detail

create

private void create(EnvironmentDescription ed)
Creates the world from the given environement Description. Used only in the creation phase.

Parameters:
ed - the environment description.

createUniverse

private void createUniverse(EnvironmentDescription ed)
Creates the universe to attach the scenegraph. Used only in the creation phase.

Parameters:
ed - the environment description.

createCanvas3D

private void createCanvas3D()
Creates the Canvas3D to visualize the 3D World. Used only in the creation phase.


addObjectToPickableSceneBranch

public void addObjectToPickableSceneBranch(BaseObject obj3d)
Adds a 3D object to the world. Used only in the creation phase.


detach

public void detach(BaseObject obj3d)
Detach a previously attached object from the scenegraph.


attach

public void attach(BaseObject obj3d)
attach a 3d object to the scenegraph.


addLight

javax.media.j3d.Light addLight(javax.vecmath.Vector3d pos,
                               javax.vecmath.Color3f color)
Add a light to the 3d world. Used only in the creation phase.


createSceneBranch

private void createSceneBranch(EnvironmentDescription wd)
Creates the branch for the visible content of the scenegraph. Used only in the creation phase.


createFloor

private void createFloor(EnvironmentDescription wd)
Creates the floor of the 3d world. Used only in the creation phase.

Parameters:
ed - the environment description.

createAxis

private void createAxis()
Creates a representation of the 3 axis of the 3d world. Used only in the creation phase.


changeViewPoint

public void changeViewPoint(int type,
                            SimpleAgent agent)
Change the user view Point . Note that we modify the ViewBranch transform not the scene transform.

Parameters:
type - can be VIEW_FROM_TOP,VIEW_FROM_EAST,VIEW_BEHIND_AGENT
agent - : specify the agent if VIEW_BEHIND_AGENT The VIEW_BEHIND_AGENT case has to be called regularly because of the agent displacement.

checkCollisionAgainstBlockWorldObjects

boolean checkCollisionAgainstBlockWorldObjects(javax.media.j3d.BoundingSphere bs)

stopRendering

public void stopRendering()
Stop rendering on main canvas 3D . Used for background mode.


startRendering

public void startRendering()
Restart rendering on main canvas 3D . Used for background mode.


renderOnce

public void renderOnce()
Do one rendering on main canvas 3D . Used for background mode.


dispose

public void dispose()
Destroy the java3d graph


getCanvas3D

public javax.media.j3d.Canvas3D getCanvas3D()
Returns:
the canvas3D associated to the world view platform

getPickableSceneBranch

javax.media.j3d.BranchGroup getPickableSceneBranch()
Returns:
the scene branchgroup containing the world's object which can be picked