Class ModelBody

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, I3DTextRenderable, IModelRenderable, IQuadRenderable, IRenderable, IFocus, IStarContainer, IVisibilitySwitch, IPosition
Direct Known Subclasses:
Billboard, LightBeam, Planet, Satellite

public abstract class ModelBody extends CelestialBody
Abstract class with the basic functionality of bodies represented by a 3D model
  • Field Details

    • TH_ANGLE_POINT

      protected static final double TH_ANGLE_POINT
    • mc

      public ModelComponent mc
      MODEL
    • 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 String refPlane
      Name of the reference plane for this object. Defaults to equator
    • refPlaneTransform

      public String refPlaneTransform
      Name of the transformation to the reference plane
    • inverseRefPlaneTransform

      public 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
  • 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 class CelestialBody
    • initialize

      public void initialize()
      Overrides:
      initialize in class SceneGraphNode
    • doneLoading

      public void doneLoading(com.badlogic.gdx.assets.AssetManager manager)
      Overrides:
      doneLoading in class SceneGraphNode
    • updateLocal

      public void updateLocal(ITimeFrameProvider time, ICamera camera)
      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 class SceneGraphNode
    • 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: 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 class SceneGraphNode
    • renderTessellated

      public boolean renderTessellated()
    • getInnerRad

      public float getInnerRad()
      Specified by:
      getInnerRad in class CelestialBody
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class SceneGraphNode
    • render

      public void render(ExtShaderProgram shader, float alpha, IntMesh mesh, ICamera camera)
      Billboard quad rendering
      Specified by:
      render in interface IQuadRenderable
      Overrides:
      render in class CelestialBody
      Parameters:
      shader - The shader program
      alpha - Opacity value
      mesh - The mesh
      camera - 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 class CelestialBody
    • setModel

      public void setModel(ModelComponent mc)
    • getFuzzyRenderSize

      public float getFuzzyRenderSize(ICamera camera)
      Overrides:
      getFuzzyRenderSize in class CelestialBody
    • getViewAnglePow

      protected float getViewAnglePow()
      Overrides:
      getViewAnglePow in class CelestialBody
    • getThOverFactorScl

      protected float getThOverFactorScl()
      Overrides:
      getThOverFactorScl in class CelestialBody
    • getThOverFactor

      protected float getThOverFactor(ICamera camera)
      Overrides:
      getThOverFactor in class CelestialBody
    • textScale

      public float textScale()
      Description copied from interface: I3DTextRenderable
      Returns the text scale for the scale varying in the shader
      Specified by:
      textScale in interface I3DTextRenderable
      Overrides:
      textScale in class CelestialBody
      Returns:
      The scale
    • labelSizeConcrete

      protected float labelSizeConcrete()
      Overrides:
      labelSizeConcrete in class CelestialBody
    • setLocvamultiplier

      public void setLocvamultiplier(Double val)
    • setLocthoverfactor

      public void setLocthoverfactor(Double val)
    • setTransformations

      public void setTransformations(Object[] transformations)
    • 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 deg
      latitude - The latitude in deg
      distance - The distance in km
      out - The vector to store the result
      Returns:
      The cartesian position above the surface of this body
    • getHeight

      public double getHeight(Vector3b 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 interface IFocus
      Overrides:
      getHeight in class SceneGraphNode
      Parameters:
      camPos - The camera position
      Returns:
      The height of the projected position of the current camera
    • getHeight

      public double getHeight(Vector3b camPos, boolean useFuturePosition)
      Description copied from interface: IFocus
      Same as IFocus.getHeight(Vector3b) but with the option to use the future position of the body instead of the current one.
      Specified by:
      getHeight in interface IFocus
      Overrides:
      getHeight in class SceneGraphNode
      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

      public double getHeight(Vector3b camPos, Vector3b nextPos)
      Description copied from interface: IFocus
      Same as IFocus.getHeight(Vector3b) but with the option to use the given future position of the body instead of the current one.
      Specified by:
      getHeight in interface IFocus
      Overrides:
      getHeight in class SceneGraphNode
      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 interface IFocus
      Overrides:
      getHeightScale in class SceneGraphNode
      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 interface IFocus
      Overrides:
      addHit in class CelestialBody
      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 interface IFocus
      Overrides:
      addHit in class CelestialBody
      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 interface IFocus
      Overrides:
      getSize in class SceneGraphNode
      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 interface IFocus
      Overrides:
      getRadius in class SceneGraphNode
      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(Double sizescalefactor)
    • setRefplane

      public void setRefplane(String refplane)