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
thresholdLabel for children locations.float
Multiplier for Loc view angle.MODELThe components to randomize---possible values are ["model", "cloud", "atmosphere"]Name of the reference plane for this object.Name of the transformation to the reference planeThe seed for random componentsint
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 downTRANSFORMATIONS - are applied each cycleFields inherited from class gaiasky.scenegraph.CelestialBody
absmag, appmag, ccPale, colorbv, compalpha, coordinatesTimeOverflow, labelFactor, labelMax, primitiveRenderScale, rc, textScale, thresholdLabel, thresholdNone, thresholdPoint, thresholdQuad, wikiname
Fields inherited from class gaiasky.scenegraph.SceneGraphNode
B31, B32, B33, B34, cc, children, computed, coordinates, copy, ct, D31, D32, D33, D34, distToCamera, F31, F32, F33, F34, forceLabel, id, labelcolor, lastStateChangeTimeMs, localizedNameIndex, localTransform, names, numChildren, octant, octantId, opacity, orientation, parent, 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 ray.protected 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 info.float
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 unitsprotected long
Gets the seed corresponding to the given component by matching it using the position in the randomize vector.double
getSize()
Returns the size (diameter) of this entity in internal units.protected float
void
protected boolean
protected boolean
protected boolean
boolean
isShadow()
Whether shadows should be rendered for this objectprotected 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
void
setLocvamultiplier
(Double val) void
void
void
setRandomize
(String randomize) void
setRandomize
(String[] randomize) void
setRefplane
(String refplane) void
setSeed
(int[] seed) void
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 shadervoid
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, makeFocus, render, renderText, setAbsmag, setAltname, setAppmag, setColor2Data, setColorbv, setLabelFactor, setLabelMax, setMag, setPrimitiveRenderScale, setRotation, setSize, setTextScale, setThresholdNone, setThresholdPoint, setThresholdQuad, setWikiname, text, textColour, textDepthBuffer, textPosition, textSize
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, getCoordinates, getCt, getDelta, getDescription, getDistToCamera, getFirstStarAncestor, getId, getLabelcolor, getLineCopy, getLocalizedName, 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, isForceLabel, isForceLabel, isInRender, isInRender, isVisibilityOn, isVisible, isVisible, isVisible, isVisibleGroup, isVisibleGroup, msSinceStateChange, mustAddToIndex, mustUpdatePosition, namesConcat, removeChild, removeFromIndex, removeFromRender, render2DLabel, render2DLabel, render2DLabel, render2DLabel, render3DLabel, render3DLabel, returnToPool, setColor, setColor, setComputedFlag, setCoordinates, setCt, setCt, setDescription, setForcelabel, setForceLabel, setForceLabel, setId, setLabelcolor, setLabelcolor, setLabelcolor, setName, setName, setNames, setParent, setPos, setSize, setUp, setVisible, setVisible, setVisibleGroup, shouldRender, toString, update, update, updateLocalizedName, updateLocalizedNameRecursive, updateLocalValues
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, getLocalizedName, 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
-
mc
MODEL -
transformations
TRANSFORMATIONS - are applied each cycle -
locVaMultiplier
public float locVaMultiplierMultiplier for Loc view angle. -
locThresholdLabel
public float locThresholdLabelthresholdLabel for children locations. -
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 -
seed
The seed for random components -
randomize
The components to randomize---possible values are ["model", "cloud", "atmosphere"]
-
-
Constructor Details
-
ModelBody
public ModelBody()
-
-
Method Details
-
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 -
setModel
-
getFuzzyRenderSize
- Overrides:
getFuzzyRenderSize
in classCelestialBody
-
getViewAnglePow
protected float getViewAnglePow()- Overrides:
getViewAnglePow
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
-
setLocViewAngleMultiplier
-
setLocthoverfactor
-
setLocThresholdLabel
-
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 position.useFuturePosition
- 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 position.nextPos
- 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 hit.screenY
- The y position of the hit.w
- The viewport width.h
- The viewport height.minPixDist
- The minimum pixel distance to consider as hit.camera
- The camera.hits
- 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 ray.p1
- End point of the ray.camera
- The camera.hits
- 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
-
setSeed
-
setSeed
public void setSeed(int[] seed) -
setRandomize
-
setRandomize
-
isRandomizeModel
protected boolean isRandomizeModel() -
getSeed
Gets the seed corresponding to the given component by matching it using the position in the randomize vector.- Parameters:
component
- The component name.- Returns:
- The seed.
-
isRandomizeAtmosphere
protected boolean isRandomizeAtmosphere() -
isRandomizeCloud
protected boolean isRandomizeCloud() -
getModelComponent
-
getMaterialComponent
-