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
FieldsModifier and TypeFieldDescriptionprotected floatFade opacity, special to model bodiesfloatThOverFactor for LocsfloatMultiplier for Loc view angleMODELName of the reference plane for this object.Name of the transformation to the reference planeintState 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 objectfloatSize factor, which can be set to scale model objects up or downprotected static doubleTRANSFORMATIONS - are applied each cycleFields inherited from class gaiasky.scenegraph.CelestialBody
absmag, appmag, ccPale, ccTransit, colorbv, compalpha, coordinatesTimeOverflow, rc, TH_OVER_FACTOR, wikinameFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHit(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)doubleReturns 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)doubleSame asIFocus.getHeight(Vector3b)but with the option to use the future position of the body instead of the current one.doubleSame asIFocus.getHeight(Vector3b)but with the option to use the given future position of the body instead of the current one.doubleReturns the height scale of this focus, or 0 if it has no height infofloatgetPositionAboveSurface(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.doubleReturns the radius in internal unitsdoublegetSize()Returns the size (diameter) of this entity in internal units.protected floatgetThOverFactor(ICamera camera)protected floatprotected floatvoidbooleanisShadow()Whether shadows should be rendered for this objectprotected floatlabelMax()protected floatprotected voidSets the shadow environmentvoidrender(IntModelBatch modelBatch, float alpha, double t, RenderingContext rc, SceneGraphRenderer.RenderGroup group)Model renderingvoidrender(IntModelBatch modelBatch, SceneGraphRenderer.RenderGroup group, float alpha, double t, boolean shadowEnv)Model opaque rendering.voidrender(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)Billboard quad renderingbooleanvoidsetLocthoverfactor(Double val)voidsetLocvamultiplier(Double val)voidsetModel(ModelComponent mc)voidsetRefplane(String refplane)voidsetShadowvalues(double[] shadowMapValues)Sets the shadow mapping values for this objectvoidsetSizescalefactor(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(Object[] transformations)floatReturns the text scale for the scale varying in the shaderdoubleAngle limit for rendering as point.voidupdateLocal(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 voidUpdate 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_QUADMethods 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, updateNamesRecMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, isCopyMethods 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_POINTin classCelestialBody
-
initialize
public void initialize()- Overrides:
initializein classSceneGraphNode
-
doneLoading
public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)- Overrides:
doneLoadingin classSceneGraphNode
-
updateLocal
Description copied from class:SceneGraphNodeUpdates 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:
updateLocalin 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:SceneGraphNodeAdds this entity to the necessary render lists after the distance to the camera and the view angle have been determined.- Overrides:
addToRenderListsin classSceneGraphNode
-
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
Billboard quad rendering- Specified by:
renderin interfaceIQuadRenderable- Overrides:
renderin 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:
labelMaxin classCelestialBody
-
setModel
-
getFuzzyRenderSize
- Overrides:
getFuzzyRenderSizein classCelestialBody
-
getViewAnglePow
protected float getViewAnglePow()- Overrides:
getViewAnglePowin classCelestialBody
-
getThOverFactorScl
protected float getThOverFactorScl()- Overrides:
getThOverFactorSclin classCelestialBody
-
getThOverFactor
- 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
-
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: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 classSceneGraphNode- Parameters:
camPos- The camera position- Returns:
- The height of the projected position of the current camera
-
getHeight
Description copied from interface:IFocusSame asIFocus.getHeight(Vector3b)but with the option to use the future position of the body instead of the current one.- Specified by:
getHeightin interfaceIFocus- Overrides:
getHeightin 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:IFocusSame asIFocus.getHeight(Vector3b)but with the option to use the given future position of the body instead of the current one.- Specified by:
getHeightin interfaceIFocus- Overrides:
getHeightin 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:IFocusReturns the height scale of this focus, or 0 if it has no height info- Specified by:
getHeightScalein interfaceIFocus- Overrides:
getHeightScalein 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:
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:SceneGraphNodeReturns the size (diameter) of this entity in internal units.- Specified by:
getSizein interfaceIFocus- Overrides:
getSizein classSceneGraphNode- Returns:
- The size in internal units.
-
getRadius
public double getRadius()Description copied from class:SceneGraphNodeReturns the radius in internal units- Specified by:
getRadiusin interfaceIFocus- Overrides:
getRadiusin 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
-