Package gaiasky.scenegraph
Class ModelBody
- java.lang.Object
-
- gaiasky.scenegraph.SceneGraphNode
-
- gaiasky.scenegraph.AbstractPositionEntity
-
- gaiasky.scenegraph.CelestialBody
-
- gaiasky.scenegraph.ModelBody
-
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,I3DTextRenderable
,IModelRenderable
,IQuadRenderable
,IRenderable
,IFocus
,IStarContainer
,IPosition
public abstract class ModelBody extends CelestialBody
Abstract class with the basic functionality of bodies represented by a 3D model.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class gaiasky.scenegraph.SceneGraphNode
SceneGraphNode.RenderGroup, SceneGraphNode.TLV3, SceneGraphNode.TLV3D
-
-
Field Summary
Fields Modifier and Type Field Description protected float
fadeOpacity
Fade opacity, special to model bodiesjava.lang.String
inverseRefPlaneTransform
float
locThOverFactor
ThOverFactor for Locsfloat
locVaMultiplier
Multiplier for Loc view angleModelComponent
mc
MODELjava.lang.String
refPlane
Name of the reference plane for this object.java.lang.String
refPlaneTransform
Name of the transformation to the reference planeint
shadow
State flag; whether to render the shadow (number of times left)double[]
shadowMapValues
Array with shadow camera distance, cam near and cam far as a function of the radius of the objectfloat
sizeScaleFactor
Size factor, which can be set to scale model objects up or downprotected static double
TH_ANGLE_POINT
ITransform[]
transformations
TRANSFORMATIONS - are applied each cyclejava.lang.String
wikiname
NAME FOR WIKIPEDIA-
Fields inherited from class gaiasky.scenegraph.CelestialBody
absmag, appmag, ccPale, ccTransit, colorbv, compalpha, coordinatesTimeOverflow, lastTransitIncrease, rc, TH_OVER_FACTOR, transits
-
Fields inherited from class gaiasky.scenegraph.AbstractPositionEntity
cc, coordinates, copy, distToCamera, octant, octantId, pos, posSph, size, viewAngle, viewAngleApparent
-
Fields inherited from class gaiasky.scenegraph.SceneGraphNode
aux3d1, aux3d2, aux3d3, aux3d4, aux3f1, aux3f2, aux3f3, aux3f4, children, computed, ct, id, localTransform, name, namekey, numChildren, opacity, orientation, parent, parentkey, parentName, ROOT_NAME, sg, translation
-
-
Constructor Summary
Constructors Constructor Description ModelBody()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHit(int screenX, int screenY, int w, int h, int minPixDist, NaturalCamera camera, com.badlogic.gdx.utils.Array<IFocus> hits)
If we render the model, we set up a sphere at the object's position with its radius and check for intersections with the rayvoid
addHit(Vector3d p0, Vector3d p1, NaturalCamera camera, com.badlogic.gdx.utils.Array<IFocus> hits)
Adds this focus to the hits list if it is hit by the given rayprotected void
addToRenderLists(ICamera camera)
Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.void
dispose()
void
doneLoading(com.badlogic.gdx.assets.AssetManager manager)
float
getFuzzyRenderSize(ICamera camera)
double
getHeight(Vector3d camPos)
Returns the height of the projected position of the current camera on this focus object, which is usually the radius plus a value lookup in the height texture (if exists)double
getHeight(Vector3d camPos, boolean useFuturePosition)
Same asIFocus.getHeight(Vector3d)
but with the option to use the future position of the body instead of the current one.double
getHeight(Vector3d camPos, Vector3d nextPos)
Same asIFocus.getHeight(Vector3d)
but with the option to use the given future position of the body instead of the current one.double
getHeightScale()
Returns the height scale of this focus, or 0 if it has no height infofloat
getInnerRad()
Vector3d
getPositionAboveSurface(double longitude, double latitude, double distance, Vector3d out)
Returns the cartesian position in the internal reference system above the surface at the given longitude and latitude and distance.double
getRadius()
Returns the radius in internal unitsdouble
getSize()
Returns the size (diameter) of this entity in internal units.protected float
getThOverFactor(ICamera camera)
protected float
getThOverFactorScl()
protected float
getViewAnglePow()
java.lang.String
getWikiname()
void
initialize()
boolean
isShadow()
Whether shadows should be rendered for this objectprotected float
labelMax()
protected float
labelSizeConcrete()
protected void
prepareShadowEnvironment()
Sets the shadow environmentvoid
render(IntModelBatch modelBatch, float alpha, double t, boolean shadowEnv)
Model opaque rendering.void
render(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc)
Model renderingvoid
render(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)
Billboard quad renderingboolean
renderTessellated()
void
setLocthoverfactor(java.lang.Double val)
void
setLocvamultiplier(java.lang.Double val)
void
setModel(ModelComponent mc)
void
setRefplane(java.lang.String refplane)
void
setShadowvalues(double[] shadowMapValues)
Sets the shadow mapping values for this objectvoid
setSizescalefactor(java.lang.Double sizescalefactor)
void
setToLocalTransform(float size, float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)
void
setToLocalTransform(float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)
void
setTransformations(java.lang.Object[] transformations)
void
setWikiname(java.lang.String wikiname)
float
textScale()
Returns the text scale for the scale varying in the shaderdouble
THRESHOLD_POINT()
Angle limit for rendering as point.void
updateLocal(ITimeFrameProvider time, ICamera camera)
Updates the local transform matrix.protected void
updateLocalTransform()
Update the local transform with the transform and the rotations/scales necessary.boolean
withinMagLimit()
Returns true if the focus is within the magnitude limit defined inGlobalConf
-
Methods inherited from class gaiasky.scenegraph.CelestialBody
addFocusableObjects, addToIndex, checkClickDistance, checkHitCondition, computeViewAngle, getAbsmag, getAltname, getAppmag, getCandidateId, getCandidateName, getCandidateViewAngleApparent, getClosestAbsolutePos, getClosestDistToCamera, getClosestName, getFocus, getOrientationQuaternion, getPmX, getPmY, getPmZ, getRotationComponent, getSimpleCopy, getTextOpacity, getViewAngle, hasAtmosphere, isActive, isCoordinatesTimeOverflow, isLabel, isStar, isValidPosition, labelFactor, makeFocus, removeFromIndex, render, renderText, setAbsmag, setAltname, setAppmag, setColor2Data, setMag, setRotation, setSize, text, textColour, textDepthBuffer, textPosition, textSize, THRESHOLD_NONE, THRESHOLD_QUAD, timeCondition, update, updateTransitNumber
-
Methods inherited from class gaiasky.scenegraph.AbstractPositionEntity
computeFuturePosition, getAbsoluteOrientation, getAbsolutePosition, getAbsolutePosition, getAlpha, getDelta, getDistToCamera, getNext, getOctant, getPos, getPosition, getPosition, getPosSph, getPredictedPosition, getViewAngleApparent, isCopy, mustUpdatePosition, render2DLabel, render2DLabel, render2DLabel, render2DLabel, render3DLabel, setColor, setColor, setCoordinates, setSize, updateLocalValues
-
Methods inherited from class gaiasky.scenegraph.SceneGraphNode
add, add, addChild, addChild, addNodes, addToRender, getAggregatedChildren, getChildByName, getChildByNameAndType, getChildrenByType, getComponentType, getCt, getFirstStarAncestor, getId, getLineCopy, getName, getNode, getNode, getOpacity, getOrientation, getRoot, getSceneGraphDepth, getStarCount, getVelocity, insert, isInRender, isInRender, isVisibilityOn, mustAddToIndex, removeChild, removeFromRender, returnToPool, setComputedFlag, setCt, setCt, setId, setName, setNamekey, setParent, setParentkey, setUp, toString, update, updateNames, updateNamesRec
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface gaiasky.scenegraph.IFocus
getAbsolutePosition, getAbsolutePosition, getAlpha, getCt, getDelta, getDistToCamera, getFirstStarAncestor, getId, getName, getNext, getOctant, getOrientation, getPos, getPosSph, getPredictedPosition, getSceneGraphDepth, getViewAngleApparent, isCopy
-
Methods inherited from interface gaiasky.render.IRenderable
getComponentType, getDistToCamera, getOpacity
-
-
-
-
Field Detail
-
TH_ANGLE_POINT
protected static final double TH_ANGLE_POINT
-
mc
public ModelComponent mc
MODEL
-
wikiname
public java.lang.String wikiname
NAME FOR WIKIPEDIA
-
transformations
public ITransform[] transformations
TRANSFORMATIONS - are applied each cycle
-
locVaMultiplier
public float locVaMultiplier
Multiplier for Loc view angle
-
locThOverFactor
public float locThOverFactor
ThOverFactor for Locs
-
sizeScaleFactor
public float sizeScaleFactor
Size factor, which can be set to scale model objects up or down
-
fadeOpacity
protected float fadeOpacity
Fade opacity, special to model bodies
-
shadow
public int shadow
State flag; whether to render the shadow (number of times left)
-
refPlane
public java.lang.String refPlane
Name of the reference plane for this object. Defaults to equator
-
refPlaneTransform
public java.lang.String refPlaneTransform
Name of the transformation to the reference plane
-
inverseRefPlaneTransform
public java.lang.String inverseRefPlaneTransform
-
shadowMapValues
public double[] shadowMapValues
Array with shadow camera distance, cam near and cam far as a function of the radius of the object
-
-
Method Detail
-
THRESHOLD_POINT
public double THRESHOLD_POINT()
Angle limit for rendering as point. If angle is any bigger, we render with shader.- Specified by:
THRESHOLD_POINT
in classCelestialBody
-
initialize
public void initialize()
- Overrides:
initialize
in classSceneGraphNode
-
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
- Overrides:
doneLoading
in classAbstractPositionEntity
-
updateLocal
public void updateLocal(ITimeFrameProvider time, ICamera camera)
Description copied from class:AbstractPositionEntity
Updates the local transform matrix.- Overrides:
updateLocal
in classAbstractPositionEntity
-
updateLocalTransform
protected void updateLocalTransform()
Update the local transform with the transform and the rotations/scales necessary. Override if your model contains more than just the position and size.
-
setToLocalTransform
public void setToLocalTransform(float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)
-
setToLocalTransform
public void setToLocalTransform(float size, float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)
-
addToRenderLists
protected void addToRenderLists(ICamera camera)
Description copied from class:AbstractPositionEntity
Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.- Specified by:
addToRenderLists
in classAbstractPositionEntity
-
renderTessellated
public boolean renderTessellated()
-
getInnerRad
public float getInnerRad()
- Specified by:
getInnerRad
in classCelestialBody
-
dispose
public void dispose()
- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
- Overrides:
dispose
in classSceneGraphNode
-
render
public void render(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)
Billboard quad rendering- Specified by:
render
in interfaceIQuadRenderable
- Overrides:
render
in classCelestialBody
-
render
public void render(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc)
Model rendering
-
render
public void render(IntModelBatch modelBatch, float alpha, double t, boolean shadowEnv)
Model opaque rendering. Disable shadow mapping
-
withinMagLimit
public boolean withinMagLimit()
Description copied from interface:IFocus
Returns true if the focus is within the magnitude limit defined inGlobalConf
- Specified by:
withinMagLimit
in interfaceIFocus
- Overrides:
withinMagLimit
in classCelestialBody
- Returns:
- True if focus within magnitude limit
-
labelMax
protected float labelMax()
- Specified by:
labelMax
in classCelestialBody
-
setModel
public void setModel(ModelComponent mc)
-
getFuzzyRenderSize
public float getFuzzyRenderSize(ICamera camera)
- Overrides:
getFuzzyRenderSize
in classCelestialBody
-
getViewAnglePow
protected float getViewAnglePow()
- Overrides:
getViewAnglePow
in classCelestialBody
-
getThOverFactorScl
protected float getThOverFactorScl()
- Overrides:
getThOverFactorScl
in classCelestialBody
-
getThOverFactor
protected float getThOverFactor(ICamera camera)
- Overrides:
getThOverFactor
in classCelestialBody
-
textScale
public float textScale()
Description copied from interface:I3DTextRenderable
Returns the text scale for the scale varying in the shader- Specified by:
textScale
in interfaceI3DTextRenderable
- Overrides:
textScale
in classCelestialBody
- Returns:
- The scale
-
labelSizeConcrete
protected float labelSizeConcrete()
- Overrides:
labelSizeConcrete
in classCelestialBody
-
getWikiname
public java.lang.String getWikiname()
-
setWikiname
public void setWikiname(java.lang.String wikiname)
-
setLocvamultiplier
public void setLocvamultiplier(java.lang.Double val)
-
setLocthoverfactor
public void setLocthoverfactor(java.lang.Double val)
-
setTransformations
public void setTransformations(java.lang.Object[] transformations)
-
getPositionAboveSurface
public Vector3d getPositionAboveSurface(double longitude, double latitude, double distance, Vector3d out)
Returns the cartesian position in the internal reference system above the surface at the given longitude and latitude and distance.- Parameters:
longitude
- The longitude in deglatitude
- The latitude in degdistance
- The distance in kmout
- The vector to store the result- Returns:
- The cartesian position above the surface of this body
-
getHeight
public double getHeight(Vector3d camPos)
Description copied from interface:IFocus
Returns the height of the projected position of the current camera on this focus object, which is usually the radius plus a value lookup in the height texture (if exists)- Specified by:
getHeight
in interfaceIFocus
- Overrides:
getHeight
in classAbstractPositionEntity
- Parameters:
camPos
- The camera position- Returns:
- The height of the projected position of the current camera
-
getHeight
public double getHeight(Vector3d camPos, boolean useFuturePosition)
Description copied from interface:IFocus
Same asIFocus.getHeight(Vector3d)
but with the option to use the future position of the body instead of the current one.- Specified by:
getHeight
in interfaceIFocus
- Overrides:
getHeight
in classAbstractPositionEntity
- Parameters:
camPos
- The camera positionuseFuturePosition
- Whether to use the future position or the current one- Returns:
- The height of the projected position of the current camera on the surface
-
getHeight
public double getHeight(Vector3d camPos, Vector3d nextPos)
Description copied from interface:IFocus
Same asIFocus.getHeight(Vector3d)
but with the option to use the given future position of the body instead of the current one.- Specified by:
getHeight
in interfaceIFocus
- Overrides:
getHeight
in classAbstractPositionEntity
- Parameters:
camPos
- The camera positionnextPos
- The future position of this body to use- Returns:
- The height of the projected position of the current camera on the surface
-
getHeightScale
public double getHeightScale()
Description copied from interface:IFocus
Returns the height scale of this focus, or 0 if it has no height info- Specified by:
getHeightScale
in interfaceIFocus
- Overrides:
getHeightScale
in classAbstractPositionEntity
- Returns:
- The height scale in internal units
-
prepareShadowEnvironment
protected void prepareShadowEnvironment()
Sets the shadow environment
-
addHit
public void addHit(int screenX, int screenY, int w, int h, int minPixDist, NaturalCamera camera, com.badlogic.gdx.utils.Array<IFocus> hits)
If we render the model, we set up a sphere at the object's position with its radius and check for intersections with the ray- Specified by:
addHit
in interfaceIFocus
- Overrides:
addHit
in classCelestialBody
- Parameters:
screenX
- The x position of the hitscreenY
- The y position of the hitw
- The viewport widthh
- The viewport heightminPixDist
- The minimum pixel distance to consider as hitcamera
- The camerahits
- The list where to add the element
-
addHit
public void addHit(Vector3d p0, Vector3d p1, NaturalCamera camera, com.badlogic.gdx.utils.Array<IFocus> hits)
Description copied from interface:IFocus
Adds this focus to the hits list if it is hit by the given ray- Specified by:
addHit
in interfaceIFocus
- Overrides:
addHit
in classCelestialBody
- Parameters:
p0
- Start point of the rayp1
- End point of the raycamera
- The camerahits
- The list where the focus is to be added
-
getSize
public double getSize()
Description copied from class:AbstractPositionEntity
Returns the size (diameter) of this entity in internal units.- Specified by:
getSize
in interfaceIFocus
- Overrides:
getSize
in classAbstractPositionEntity
- Returns:
- The size in internal units.
-
getRadius
public double getRadius()
Description copied from class:AbstractPositionEntity
Returns the radius in internal units- Specified by:
getRadius
in interfaceIFocus
- Overrides:
getRadius
in classAbstractPositionEntity
- Returns:
- The radius of the object, in internal units
-
isShadow
public boolean isShadow()
Whether shadows should be rendered for this object- Returns:
- Whether shadows should be rendered for this object
-
setShadowvalues
public void setShadowvalues(double[] shadowMapValues)
Sets the shadow mapping values for this object- Parameters:
shadowMapValues
- The values
-
setSizescalefactor
public void setSizescalefactor(java.lang.Double sizescalefactor)
-
setRefplane
public void setRefplane(java.lang.String refplane)
-
-