Package com.massifmaps.celestial
Class CelestialSprite
java.lang.Object
com.massifmaps.celestial.CelestialObject
com.massifmaps.celestial.CelestialSprite
A flat, camera-facing object in the sky: a disc, a point of light, an icon overhead.
Its size is given either as an ANGULAR size in degrees - which is what a real body has, so it
grows and shrinks with the field of view like everything else in the world - or as a fixed
SCREEN size in pixels, which is what an icon or a marker wants. A sprite with no bitmap is
drawn as a soft disc in its own color, which is enough for most bodies and costs no
texture at all.
Its size is given either as an ANGULAR size in degrees - which is what a real body has, so it
grows and shrinks with the field of view like everything else in the world - or as a fixed
SCREEN size in pixels, which is what an icon or a marker wants. A sprite with no bitmap is
drawn as a soft disc in its own color, which is enough for most bodies and costs no
texture at all.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns the angular size of the sprite.Returns the bitmap of the sprite.floatReturns the extra radius that responds to a click.floatReturns the screen size of the sprite.floatReturns the edge softness of a disc sprite.voidsetAngularSize(float degrees) Sets the angular size of the sprite, the way a real body is measured - the disc then
covers the same angle whatever the field of view.voidSets the bitmap of the sprite.voidsetClickRadius(float degrees) Sets an extra angular radius that responds to a click, added to the sprite's own size.voidsetScreenSize(float pixels) Sets a fixed on-screen size, in pixels, independent of the field of view.voidsetSoftness(float softness) Sets the edge softness of a disc sprite.Methods inherited from class com.massifmaps.celestial.CelestialObject
equals, getAltitude, getAzimuth, getColor, getDistance, getMetaDataElement, getPosition, getPositionAltitude, hashCode, isDirectionAnchored, isVisible, setColor, setDirection, setMetaDataElement, setPosition, setVisible
-
Constructor Details
-
CelestialSprite
public CelestialSprite()
-
-
Method Details
-
getAngularSize
public float getAngularSize()Returns the angular size of the sprite.- Returns:
- The angular diameter in degrees, or 0 if the sprite is sized in pixels.
-
setAngularSize
public void setAngularSize(float degrees) Sets the angular size of the sprite, the way a real body is measured - the disc then
covers the same angle whatever the field of view.- Parameters:
degrees- The angular diameter in degrees.
-
getScreenSize
public float getScreenSize()Returns the screen size of the sprite.- Returns:
- The diameter in pixels, or 0 if the sprite is sized by angle.
-
setScreenSize
public void setScreenSize(float pixels) Sets a fixed on-screen size, in pixels, independent of the field of view. Use this for
icons and markers rather than for bodies.- Parameters:
pixels- The diameter in pixels.
-
getBitmap
Returns the bitmap of the sprite.- Returns:
- The bitmap, or null if the sprite is drawn as a plain disc.
-
setBitmap
Sets the bitmap of the sprite. Sprites are batched per bitmap, so objects that share one
bitmap - a catalogue of thousands, for instance - cost a single draw call.- Parameters:
bitmap- The new bitmap, or null to draw a plain disc.
-
getSoftness
public float getSoftness()Returns the edge softness of a disc sprite.- Returns:
- The softness, 0 for a hard edge and 1 for a fully soft one.
-
setSoftness
public void setSoftness(float softness) Sets the edge softness of a disc sprite. It has no effect on a sprite with a bitmap.- Parameters:
softness- The softness, 0 for a hard edge and 1 for a fully soft one.
-
getClickRadius
public float getClickRadius()Returns the extra radius that responds to a click.- Returns:
- The extra click radius in degrees.
-
setClickRadius
public void setClickRadius(float degrees) Sets an extra angular radius that responds to a click, added to the sprite's own size. A
sprite half a pixel across is impossible to hit otherwise.- Parameters:
degrees- The extra click radius in degrees.
-