universe.server.database
Class GalaxySpiral

java.lang.Object
  |
  +--universe.common.database.DBItem
        |
        +--universe.server.database.GalaxyBase
              |
              +--universe.server.database.GalaxyStd
                    |
                    +--universe.server.database.GalaxySpiral
All Implemented Interfaces:
java.io.Serializable

public class GalaxySpiral
extends GalaxyStd

This class implements instances of randomly generated spiral galaxies. This type of galaxy is good for large scale games. At smaller scales, the spiral nature of the galaxy does not work as well, and thus an elliptical or globular galaxy is more suitable.

Author:
Allan Noordvyk (noordvyk@home.com)
See Also:
GalaxyElliptical, GalaxyGlobular, Serialized Form

Field Summary
static java.lang.String DESCRIPTION
           
private  float myAngStep
           
private  int myArmCount
           
private  float myCurrentAng
           
private  int myCurrentArm
           
private  float myCurrentRad
           
private  float[] myLastArmX
           
private  float[] myLastArmY
           
private  float myRadStep
           
 
Fields inherited from class universe.server.database.GalaxyStd
ourRandGen
 
Fields inherited from class universe.server.database.GalaxyBase
 
Constructor Summary
GalaxySpiral(float width, float height, float depth, float density)
          This is the designated constructor which should be used to create instances of this class.
 
Method Summary
 Coord newSystemCoord()
          This method returns a random coordinate within the overall shape of the galaxy (as tested with containsCoord).
private  void resetGenerator()
          This method is called by the initializer to prepare for the first call to newSystemCoord and by that method when the generation of new systems has reached the edge and must return to generating new systems from the center.
 int starSystemCount()
          This method has been overridden to reflect the fact that approx.
 java.lang.String structureDescription()
          This method overrides that of our superclass to return "Spiral".
 
Methods inherited from class universe.server.database.GalaxyStd
containsCoord, generateSystems, getCenter, getDensity, getSpan
 
Methods inherited from class universe.server.database.GalaxyBase
addSystem, getID, getIndex, getName, getSystems, hasGeneratedSystems, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DESCRIPTION

public static java.lang.String DESCRIPTION

myAngStep

private float myAngStep

myCurrentAng

private float myCurrentAng

myRadStep

private float myRadStep

myCurrentRad

private float myCurrentRad

myArmCount

private int myArmCount

myCurrentArm

private int myCurrentArm

myLastArmX

private float[] myLastArmX

myLastArmY

private float[] myLastArmY
Constructor Detail

GalaxySpiral

public GalaxySpiral(float width,
                    float height,
                    float depth,
                    float density)
This is the designated constructor which should be used to create instances of this class.

Parameters:
width - The width of the galaxy (in parsecs)
height - The height of the galaxy (in parsecs)
depth - The depth of the galaxy (in parsecs)
density - The average density (in systems per cubic parsec) of stars within the hull of the galaxy (not its bounding cube).
Method Detail

structureDescription

public java.lang.String structureDescription()
This method overrides that of our superclass to return "Spiral".

Overrides:
structureDescription in class GalaxyStd

starSystemCount

public int starSystemCount()
This method has been overridden to reflect the fact that approx. 40% of the bounding cube's volume will not be used by a spiral galaxy.

Overrides:
starSystemCount in class GalaxyStd

resetGenerator

private void resetGenerator()
This method is called by the initializer to prepare for the first call to newSystemCoord and by that method when the generation of new systems has reached the edge and must return to generating new systems from the center.


newSystemCoord

public Coord newSystemCoord()
Description copied from class: GalaxyStd
This method returns a random coordinate within the overall shape of the galaxy (as tested with containsCoord).

While this method is primarily used by the standard contructor it can also be used to generate locations for random events in interstellar space within the galaxy.

Subclasses may choose to override this method in order to more efficiently generate coordinates within some kind of overall galactic structure, as this implementation will test random points throughout the bounding cube. However, overridding the containsCoord method is all that is minimally required to get a new shape. Subclasses wishing to have the star system distribution follow a general internal structure, however, will definately wish to override this method.

Overrides:
newSystemCoord in class GalaxyStd
Returns:
An unoccupied coordinate within the galaxy suitable for placement of a new star system.
See Also:
#containsCoord()


Copyright © 2001 Universe Dev Team All Rights Reserved.