espresso3d.engine.world.sector
Class E3DSector

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.renderer.base.E3DRenderable
          extended byespresso3d.engine.world.sector.E3DSector
All Implemented Interfaces:
E3DLightableObject

public class E3DSector
extends E3DRenderable
implements E3DLightableObject

Author:
espresso3d Worlds are divided up into multiple sectors. Sectors contain actors, lights and geometry. A portaling algorithm then connects sectors together through portals. This is a way of reducing the potentially visibile triangles quickly. (portaling will come soon) Outdoor scenes will have special terrain sectors that will work in the same sort of fashion (not implemented).

Constructor Summary
E3DSector(E3DEngine engine, java.lang.String sectorID)
           
 
Method Summary
 void addActor(E3DActor actor)
          Add an actor to this sector
 void addLight(E3DLight light)
          Add a light to the sector
 void addParticleSystem(E3DParticleSystem particleSystem)
          Add a particle system to the engine
 void addPortal(E3DPortal portal)
          Add a portal to the sector.
 void addSprite(E3DSprite sprite)
          Add a sprite to the sector.
 void addTriangle(E3DTriangle triangle)
          Add a triangle to the geometry of the sector This is handled by map loading, but triangles can be added programatically as well.
 E3DActor getActorByID(java.lang.String actorID)
          Get an actor in this sector by its ID
 java.util.HashMap getActorMap()
           
 java.util.HashMap getLightMap()
           
 java.util.ArrayList getParticleSystemList()
          Get the list of E3DParticleSystem's in the sector
 java.util.HashMap getPortalMap()
          Return the hashmap of portals in the sector keyed off portalID
 java.lang.String getSectorID()
           
 java.util.ArrayList getSpriteList()
          Get the list of E3DSprite's (or E3DBillboardSprite's) in the sector
 java.util.ArrayList getTriangleList()
           
 java.util.ArrayList getUniqueDirectlyLinkedSectorList()
          This gets a list of sectors directly linked to this sector via portals.
 E3DWorld getWorld()
           
 boolean isLit()
          Return whether the sector is lit or not
 boolean isNeedingLightRecalc()
          If something has changed that makes the sector need lighting recalculations, set this to true and it will be relit the next frame.
 void removeActor(E3DActor actor)
          Remove an actor by its object
 void removeActor(java.lang.String actorID)
          Remove an actor with actorID from this sector
 void removeAllActors()
          Remove all actors from the sector
 void removeAllLights()
          Remove all lights from the sector
 void removeAllParticleSystems()
          Remove all particle systems from the sector
 void removeAllSprites()
          Remove all sprites from the sector
 void removeLight(E3DLight light)
          Remove a light by the E3DLight object
 void removeLight(java.lang.String lightID)
          Remove a light from the sector
 void removeParticleSystem(E3DParticleSystem particleSystem)
          Only ID's particle systems can be removed
 void removeSprite(E3DSprite sprite)
          Remove a sprite from the sector
 void render()
          This renders the sector geometry and actors in the sector atPosition This is handled by the engine's rendering loop TODO: OUT OF DATE since not ever used
 void render(E3DViewFrustum2D frustum, E3DActor curActor, java.util.HashMap alreadyRenderedSectors)
           
 void setLightMap(java.util.HashMap lightMap)
           
 void setLit(boolean lit)
          Set the sector geometry is lit or not.
 void setNeedingLightRecalc(boolean needingLightRecalc)
          If something has changed that makes the sector need lighting recalculations, set this to true and it and all its actor's will be relit the next frame.
 void setWorld(E3DWorld world)
           
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getBlendMode, getKey, getRenderMode, initCorrectGeometryRenderer, isKeyChanged, setBlendMode, setKeyChanged, setRenderMode
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

E3DSector

public E3DSector(E3DEngine engine,
                 java.lang.String sectorID)
Method Detail

addTriangle

public void addTriangle(E3DTriangle triangle)
Add a triangle to the geometry of the sector This is handled by map loading, but triangles can be added programatically as well.

Parameters:
triangle -

addPortal

public void addPortal(E3DPortal portal)
Add a portal to the sector. Portals link sectors to other sectors

Returns:

getSectorID

public java.lang.String getSectorID()
Returns:
Returns the sectorID.

isLit

public boolean isLit()
Return whether the sector is lit or not

Specified by:
isLit in interface E3DLightableObject

setLit

public void setLit(boolean lit)
Set the sector geometry is lit or not. If its not lit, all sector triangles will be fullbright

Specified by:
setLit in interface E3DLightableObject

getTriangleList

public java.util.ArrayList getTriangleList()
Returns:
Returns the list of triangles that comprise the geometry of the sector. Be careful modifying the triangles! It can have -really bad- consequences if they aren't modified through the correct procedures! For example, as triangles are added they are sorted by their texture. If you then later change the texture it will completely break the rendering pipeline optimization having to do with triangles.

render

public void render()
This renders the sector geometry and actors in the sector atPosition This is handled by the engine's rendering loop TODO: OUT OF DATE since not ever used

Specified by:
render in class E3DRenderable

render

public void render(E3DViewFrustum2D frustum,
                   E3DActor curActor,
                   java.util.HashMap alreadyRenderedSectors)

getLightMap

public java.util.HashMap getLightMap()
Returns:
Returns the lightMap.

setLightMap

public void setLightMap(java.util.HashMap lightMap)
Parameters:
lightMap - The lightMap to set.

addLight

public void addLight(E3DLight light)
Add a light to the sector

Parameters:
light -

removeLight

public void removeLight(java.lang.String lightID)
Remove a light from the sector

Parameters:
lightID -

removeLight

public void removeLight(E3DLight light)
Remove a light by the E3DLight object

Parameters:
light -

removeAllLights

public void removeAllLights()
Remove all lights from the sector


getActorMap

public java.util.HashMap getActorMap()
Returns:
Returns a HashMap of all E3DActor's in the sector keyed off actorID

addActor

public void addActor(E3DActor actor)
Add an actor to this sector

Parameters:
actor -

getActorByID

public E3DActor getActorByID(java.lang.String actorID)
Get an actor in this sector by its ID

Parameters:
actorID -
Returns:

removeActor

public void removeActor(java.lang.String actorID)
Remove an actor with actorID from this sector

Parameters:
actorID -

removeActor

public void removeActor(E3DActor actor)
Remove an actor by its object

Parameters:
actor -

removeAllActors

public void removeAllActors()
Remove all actors from the sector


addParticleSystem

public void addParticleSystem(E3DParticleSystem particleSystem)
Add a particle system to the engine

Parameters:
particleSystem -

removeParticleSystem

public void removeParticleSystem(E3DParticleSystem particleSystem)
Only ID's particle systems can be removed


removeAllParticleSystems

public void removeAllParticleSystems()
Remove all particle systems from the sector


addSprite

public void addSprite(E3DSprite sprite)
Add a sprite to the sector. This can be billboarding or non

Parameters:
sprite -

removeSprite

public void removeSprite(E3DSprite sprite)
Remove a sprite from the sector

Parameters:
sprite -

removeAllSprites

public void removeAllSprites()
Remove all sprites from the sector


getWorld

public E3DWorld getWorld()
Returns:
Returns the world the sector is in

setWorld

public void setWorld(E3DWorld world)
Parameters:
world - The world the sector is part of. This should only be used by the engine. If the world the sector is in changes, it needs more than to just be set here...

isNeedingLightRecalc

public boolean isNeedingLightRecalc()
If something has changed that makes the sector need lighting recalculations, set this to true and it will be relit the next frame. This is normally taken care of by the engine

Returns:

setNeedingLightRecalc

public void setNeedingLightRecalc(boolean needingLightRecalc)
If something has changed that makes the sector need lighting recalculations, set this to true and it and all its actor's will be relit the next frame. This is normally taken care of by the engine

Parameters:
needingLightRecalc -

getPortalMap

public java.util.HashMap getPortalMap()
Return the hashmap of portals in the sector keyed off portalID

Returns:

getParticleSystemList

public java.util.ArrayList getParticleSystemList()
Get the list of E3DParticleSystem's in the sector

Returns:

getSpriteList

public java.util.ArrayList getSpriteList()
Get the list of E3DSprite's (or E3DBillboardSprite's) in the sector

Returns:

getUniqueDirectlyLinkedSectorList

public java.util.ArrayList getUniqueDirectlyLinkedSectorList()
This gets a list of sectors directly linked to this sector via portals. It will contain only 1 copy of each sector it is linked to (even if it has multiple portals going to the same sector). This only traversed 1 level deep (e.g.: directly adjoining sectors). This does not include this sector.

Returns:
Returns an arraylist containing 1...n linked sectors (not including this sector) or null if no sectors are linked