Package gaiasky.scenegraph
Class ModelBody
java.lang.Object
gaiasky.scenegraph.SceneGraphNode
gaiasky.scenegraph.CelestialBody
gaiasky.scenegraph.ModelBody
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,I3DTextRenderable
,IModelRenderable
,IQuadRenderable
,IRenderable
,IFocus
,IStarContainer
,IVisibilitySwitch
,IPosition
Abstract class with the basic functionality of bodies represented by a 3D
model
-
Field Summary
Modifier and TypeFieldDescriptionprotected float
Fade opacity, special to model bodiesfloat
ThOverFactor for Locsfloat
Multiplier for Loc view angleMODELName of the reference plane for this object.Name of the transformation to the reference planeint
State flag; whether to render the shadow (number of times left)double[]
Array with shadow camera distance, cam near and cam far as a function of the radius of the objectfloat
Size factor, which can be set to scale model objects up or downprotected static double
TRANSFORMATIONS - are applied each cycleFields inherited from class gaiasky.scenegraph.CelestialBody
absmag, appmag, ccPale, ccTransit, colorbv, compalpha, coordinatesTimeOverflow, rc, TH_OVER_FACTOR, wikiname
Fields inherited from class gaiasky.scenegraph.SceneGraphNode
aux3b1, aux3b2, aux3b3, aux3b4, aux3d1, aux3d2, aux3d3, aux3d4, aux3f1, aux3f2, aux3f3, aux3f4, cc, children, computed, coordinates, copy, ct, distToCamera, id, lastStateChangeTimeMs, localTransform, namekey, names, numChildren, octant, octantId, opacity, orientation, parent, parentkey, parentName, pos, posSph, ROOT_NAME, size, translation, viewAngle, viewAngleApparent, visible
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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
Same asIFocus.getHeight(Vector3b)
but with the option to use the future position of the body instead of the current one.double
Same asIFocus.getHeight(Vector3b)
but with the option to use the given future position of the body instead of the current one.double
Returns the height scale of this focus, or 0 if it has no height infofloat
getPositionAboveSurface(double longitude, double latitude, double distance, Vector3b out)
Returns the cartesian position in the internal reference system above the surface at the given longitude and latitude and distance.double
Returns the radius in internal unitsdouble
getSize()
Returns the size (diameter) of this entity in internal units.protected float
getThOverFactor(ICamera camera)
protected float
protected float
void
boolean
isShadow()
Whether shadows should be rendered for this objectprotected float
labelMax()
protected float
protected void
Sets the shadow environmentvoid
render(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc, SceneGraphRenderer.RenderGroup group)
Model renderingvoid
render(IntModelBatch modelBatch, SceneGraphRenderer.RenderGroup group, float alpha, double t, boolean shadowEnv)
Model opaque rendering.void
render(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)
Billboard quad renderingboolean
void
setLocthoverfactor(Double val)
void
setLocvamultiplier(Double val)
void
setModel(ModelComponent mc)
void
setRefplane(String refplane)
void
setShadowvalues(double[] shadowMapValues)
Sets the shadow mapping values for this objectvoid
setSizescalefactor(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(Object[] transformations)
float
Returns the text scale for the scale varying in the shaderdouble
Angle limit for rendering as point.void
updateLocal(ITimeFrameProvider time, ICamera camera)
Updates the transform matrix with the transformations that will apply to the children and the local transform matrix with the transformations that will apply only to this object.protected void
Update the local transform with the transform and the rotations/scales necessary.Methods inherited from class gaiasky.scenegraph.CelestialBody
addFocusableObjects, checkClickDistance, checkHitCondition, computeViewAngle, getAbsmag, getAppmag, getCandidateId, getCandidateName, getCandidateViewAngleApparent, getClosestAbsolutePos, getClosestDistToCamera, getClosestName, getFocus, getOrientationQuaternion, getPmX, getPmY, getPmZ, getRotationComponent, getSimpleCopy, getTextOpacity, getViewAngle, getWikiname, hasAtmosphere, isActive, isCoordinatesTimeOverflow, isLabel, isStar, isValidPosition, labelFactor, makeFocus, render, renderText, setAbsmag, setAltname, setAppmag, setColor2Data, setColorbv, setMag, setRotation, setSize, setWikiname, text, textColour, textDepthBuffer, textPosition, textSize, THRESHOLD_NONE, THRESHOLD_QUAD
Methods inherited from class gaiasky.scenegraph.SceneGraphNode
add, add, addChild, addChild, addName, addNodes, addToIndex, addToRender, computeFuturePosition, getAbsoluteOrientation, getAbsolutePosition, getAbsolutePosition, getAggregatedChildren, getAlpha, getChildByName, getChildByNameAndType, getChildrenByComponentType, getChildrenByType, getColor, getComponentType, getCt, getDelta, getDescription, getDistToCamera, getFirstStarAncestor, getId, getLineCopy, getName, getNames, getNext, getNode, getNode, getOctant, getOpacity, getOrientation, getPos, getPosition, getPosition, getPosSph, getPredictedPosition, getRoot, getSceneGraphDepth, getStarCount, getUnrotatedPos, getVelocity, getViewAngleApparent, getVisibilityOpacityFactor, hasCt, hasName, hasName, insert, isCopy, isInRender, isInRender, isVisibilityOn, isVisible, isVisible, isVisible, isVisibleGroup, msSinceStateChange, mustAddToIndex, mustUpdatePosition, namesConcat, removeChild, removeFromIndex, removeFromRender, render2DLabel, render2DLabel, render2DLabel, render2DLabel, render3DLabel, render3DLabel, returnToPool, setColor, setColor, setComputedFlag, setCoordinates, setCt, setCt, setDescription, setId, setLabelcolor, setLabelcolor, setName, setNamekey, setNames, setParent, setParentkey, setSize, setUp, setVisible, setVisible, setVisibleGroup, shouldRender, toString, update, update, updateLocalValues, 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, getColor, getCt, getDelta, getDistToCamera, getFirstStarAncestor, getId, getName, getNames, getNext, getOctant, getOrientation, getPos, getPosSph, getPredictedPosition, getSceneGraphDepth, getViewAngleApparent, hasName, hasName, isCopy
Methods inherited from interface gaiasky.render.IRenderable
getComponentType, getDistToCamera, getOpacity
-
Field Details
-
TH_ANGLE_POINT
protected static final double TH_ANGLE_POINT -
mc
MODEL -
transformations
TRANSFORMATIONS - are applied each cycle -
locVaMultiplier
public float locVaMultiplierMultiplier for Loc view angle -
locThOverFactor
public float locThOverFactorThOverFactor for Locs -
sizeScaleFactor
public float sizeScaleFactorSize factor, which can be set to scale model objects up or down -
fadeOpacity
protected float fadeOpacityFade opacity, special to model bodies -
shadow
public int shadowState flag; whether to render the shadow (number of times left) -
refPlane
Name of the reference plane for this object. Defaults to equator -
refPlaneTransform
Name of the transformation to the reference plane -
inverseRefPlaneTransform
-
shadowMapValues
public double[] shadowMapValuesArray with shadow camera distance, cam near and cam far as a function of the radius of the object
-
-
Constructor Details
-
ModelBody
public ModelBody()
-
-
Method Details
-
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 classSceneGraphNode
-
updateLocal
Description copied from class:SceneGraphNode
Updates the transform matrix with the transformations that will apply to the children and the local transform matrix with the transformations that will apply only to this object.- Overrides:
updateLocal
in classSceneGraphNode
-
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
Description copied from class:SceneGraphNode
Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.- Overrides:
addToRenderLists
in classSceneGraphNode
-
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
Billboard quad rendering- Specified by:
render
in interfaceIQuadRenderable
- Overrides:
render
in classCelestialBody
- Parameters:
shader
- The shader programalpha
- Opacity valuemesh
- The meshcamera
- The camera
-
render
public void render(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc, SceneGraphRenderer.RenderGroup group)Model rendering -
render
public void render(IntModelBatch modelBatch, SceneGraphRenderer.RenderGroup group, float alpha, double t, boolean shadowEnv)Model opaque rendering. Disable shadow mapping -
labelMax
protected float labelMax()- Specified by:
labelMax
in classCelestialBody
-
setModel
-
getFuzzyRenderSize
- Overrides:
getFuzzyRenderSize
in classCelestialBody
-
getViewAnglePow
protected float getViewAnglePow()- Overrides:
getViewAnglePow
in classCelestialBody
-
getThOverFactorScl
protected float getThOverFactorScl()- Overrides:
getThOverFactorScl
in classCelestialBody
-
getThOverFactor
- 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
-
setLocvamultiplier
-
setLocthoverfactor
-
setTransformations
-
getPositionAboveSurface
public Vector3b getPositionAboveSurface(double longitude, double latitude, double distance, Vector3b 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
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 classSceneGraphNode
- Parameters:
camPos
- The camera position- Returns:
- The height of the projected position of the current camera
-
getHeight
Description copied from interface:IFocus
Same asIFocus.getHeight(Vector3b)
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 classSceneGraphNode
- 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
Description copied from interface:IFocus
Same asIFocus.getHeight(Vector3b)
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 classSceneGraphNode
- 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 classSceneGraphNode
- 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:SceneGraphNode
Returns the size (diameter) of this entity in internal units.- Specified by:
getSize
in interfaceIFocus
- Overrides:
getSize
in classSceneGraphNode
- Returns:
- The size in internal units.
-
getRadius
public double getRadius()Description copied from class:SceneGraphNode
Returns the radius in internal units- Specified by:
getRadius
in interfaceIFocus
- Overrides:
getRadius
in classSceneGraphNode
- 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
-
setRefplane
-