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

public class E3DSector
extends E3DRenderable

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).

Field Summary
 
Fields inherited from class espresso3d.engine.renderer.base.E3DRenderable
RENDERMODE_SOLID, RENDERMODE_TEXTURED, RENDERMODE_WIREFRAME
 
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
protected  espresso3d.engine.world.sector.E3DSector.RecursedTextureSortedObjects getRecursedTextureSortedObjectMap(E3DViewFrustum2D frustum, E3DSector fromSector, E3DActor curActor)
          Returns a RecursedTextureSortedTriangles object (that has 2 hashmaps) with all the triangles in the sector/actor and all triangles in particles stored in a HashMap, lit (if necessary) and sorted by texture
 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 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(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(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 renderAtPosition(E3DVector3F atPosition)
          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 renderAtPosition(E3DVector3F atPosition, E3DViewFrustum2D frustum, E3DActor curActor)
          This renders the sector geometry and actors in the sector atPosition It then recurses through the portals and renders linking sectors This is handled by the engine's rendering loop
 void setLightMap(java.util.HashMap lightMap)
           
 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
getRenderableOptionsKey, getRenderMode, initCorrectGeometryRenderer, render, setRenderMode
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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.

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.

renderAtPosition

public void renderAtPosition(E3DVector3F atPosition)
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:
renderAtPosition in class E3DRenderable

renderAtPosition

public void renderAtPosition(E3DVector3F atPosition,
                             E3DViewFrustum2D frustum,
                             E3DActor curActor)
This renders the sector geometry and actors in the sector atPosition It then recurses through the portals and renders linking sectors This is handled by the engine's rendering loop


getRecursedTextureSortedObjectMap

protected espresso3d.engine.world.sector.E3DSector.RecursedTextureSortedObjects getRecursedTextureSortedObjectMap(E3DViewFrustum2D frustum,
                                                                                                                  E3DSector fromSector,
                                                                                                                  E3DActor curActor)
Returns a RecursedTextureSortedTriangles object (that has 2 hashmaps) with all the triangles in the sector/actor and all triangles in particles stored in a HashMap, lit (if necessary) and sorted by texture

Parameters:
frustum - The frustum to determine if items are inside or not
fromSector - The sector that can see this sector and called for recursion
Returns:

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 -

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 -

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