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 floatfadeOpacityFade opacity, special to model bodiesjava.lang.StringinverseRefPlaneTransformfloatlocThOverFactorThOverFactor for LocsfloatlocVaMultiplierMultiplier for Loc view angleModelComponentmcMODELjava.lang.StringrefPlaneName of the reference plane for this object.java.lang.StringrefPlaneTransformName of the transformation to the reference planeintshadowState flag; whether to render the shadow (number of times left)double[]shadowMapValuesArray with shadow camera distance, cam near and cam far as a function of the radius of the objectfloatsizeScaleFactorSize factor, which can be set to scale model objects up or downprotected static doubleTH_ANGLE_POINTITransform[]transformationsTRANSFORMATIONS - are applied each cyclejava.lang.StringwikinameNAME 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 voidaddHit(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 rayvoidaddHit(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 voidaddToRenderLists(ICamera camera)Adds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.voiddispose()voiddoneLoading(com.badlogic.gdx.assets.AssetManager manager)floatgetFuzzyRenderSize(ICamera camera)doublegetHeight(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)doublegetHeight(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.doublegetHeight(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.doublegetHeightScale()Returns the height scale of this focus, or 0 if it has no height infofloatgetInnerRad()Vector3dgetPositionAboveSurface(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.doublegetRadius()Returns the radius in internal unitsdoublegetSize()Returns the size (diameter) of this entity in internal units.protected floatgetThOverFactor(ICamera camera)protected floatgetThOverFactorScl()protected floatgetViewAnglePow()java.lang.StringgetWikiname()voidinitialize()booleanisShadow()Whether shadows should be rendered for this objectprotected floatlabelMax()protected floatlabelSizeConcrete()protected voidprepareShadowEnvironment()Sets the shadow environmentvoidrender(IntModelBatch modelBatch, float alpha, double t, boolean shadowEnv)Model opaque rendering.voidrender(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc)Model renderingvoidrender(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)Billboard quad renderingbooleanrenderTessellated()voidsetLocthoverfactor(java.lang.Double val)voidsetLocvamultiplier(java.lang.Double val)voidsetModel(ModelComponent mc)voidsetRefplane(java.lang.String refplane)voidsetShadowvalues(double[] shadowMapValues)Sets the shadow mapping values for this objectvoidsetSizescalefactor(java.lang.Double sizescalefactor)voidsetToLocalTransform(float size, float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)voidsetToLocalTransform(float sizeFactor, com.badlogic.gdx.math.Matrix4 localTransform, boolean forceUpdate)voidsetTransformations(java.lang.Object[] transformations)voidsetWikiname(java.lang.String wikiname)floattextScale()Returns the text scale for the scale varying in the shaderdoubleTHRESHOLD_POINT()Angle limit for rendering as point.voidupdateLocal(ITimeFrameProvider time, ICamera camera)Updates the local transform matrix.protected voidupdateLocalTransform()Update the local transform with the transform and the rotations/scales necessary.booleanwithinMagLimit()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_POINTin classCelestialBody
-
initialize
public void initialize()
- Overrides:
initializein classSceneGraphNode
-
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
- Overrides:
doneLoadingin classAbstractPositionEntity
-
updateLocal
public void updateLocal(ITimeFrameProvider time, ICamera camera)
Description copied from class:AbstractPositionEntityUpdates the local transform matrix.- Overrides:
updateLocalin 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:AbstractPositionEntityAdds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.- Specified by:
addToRenderListsin classAbstractPositionEntity
-
renderTessellated
public boolean renderTessellated()
-
getInnerRad
public float getInnerRad()
- Specified by:
getInnerRadin classCelestialBody
-
dispose
public void dispose()
- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classSceneGraphNode
-
render
public void render(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)
Billboard quad rendering- Specified by:
renderin interfaceIQuadRenderable- Overrides:
renderin 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:IFocusReturns true if the focus is within the magnitude limit defined inGlobalConf- Specified by:
withinMagLimitin interfaceIFocus- Overrides:
withinMagLimitin classCelestialBody- Returns:
- True if focus within magnitude limit
-
labelMax
protected float labelMax()
- Specified by:
labelMaxin classCelestialBody
-
setModel
public void setModel(ModelComponent mc)
-
getFuzzyRenderSize
public float getFuzzyRenderSize(ICamera camera)
- Overrides:
getFuzzyRenderSizein classCelestialBody
-
getViewAnglePow
protected float getViewAnglePow()
- Overrides:
getViewAnglePowin classCelestialBody
-
getThOverFactorScl
protected float getThOverFactorScl()
- Overrides:
getThOverFactorSclin classCelestialBody
-
getThOverFactor
protected float getThOverFactor(ICamera camera)
- Overrides:
getThOverFactorin classCelestialBody
-
textScale
public float textScale()
Description copied from interface:I3DTextRenderableReturns the text scale for the scale varying in the shader- Specified by:
textScalein interfaceI3DTextRenderable- Overrides:
textScalein classCelestialBody- Returns:
- The scale
-
labelSizeConcrete
protected float labelSizeConcrete()
- Overrides:
labelSizeConcretein 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:IFocusReturns 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:
getHeightin interfaceIFocus- Overrides:
getHeightin 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:IFocusSame asIFocus.getHeight(Vector3d)but with the option to use the future position of the body instead of the current one.- Specified by:
getHeightin interfaceIFocus- Overrides:
getHeightin 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:IFocusSame asIFocus.getHeight(Vector3d)but with the option to use the given future position of the body instead of the current one.- Specified by:
getHeightin interfaceIFocus- Overrides:
getHeightin 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:IFocusReturns the height scale of this focus, or 0 if it has no height info- Specified by:
getHeightScalein interfaceIFocus- Overrides:
getHeightScalein 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:
addHitin interfaceIFocus- Overrides:
addHitin 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:IFocusAdds this focus to the hits list if it is hit by the given ray- Specified by:
addHitin interfaceIFocus- Overrides:
addHitin 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:AbstractPositionEntityReturns the size (diameter) of this entity in internal units.- Specified by:
getSizein interfaceIFocus- Overrides:
getSizein classAbstractPositionEntity- Returns:
- The size in internal units.
-
getRadius
public double getRadius()
Description copied from class:AbstractPositionEntityReturns the radius in internal units- Specified by:
getRadiusin interfaceIFocus- Overrides:
getRadiusin 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)
-
-