Class CurveEntity

All Implemented Interfaces:
InstanceRenderAPI, MaterialRenderAPI, RenderDataAPI

public class CurveEntity extends BaseMIRenderData
This is a 2D curve.

Curve entity will not apply AA if depth based AA is enabled.

Use vanilla beam texture uv(transversal beam texture).

  • Field Details

    • _CIRCLE_FIX

      protected static final float _CIRCLE_FIX
      See Also:
    • _NODE_LENGTH

      protected static final byte _NODE_LENGTH
      See Also:
    • _curveID

      protected final int _curveID
    • _nodesVBO

      protected final int _nodesVBO
    • _isValid

      protected volatile boolean _isValid
    • nodeList

      protected List<NodeData> nodeList
    • _lastNodeLength

      protected int _lastNodeLength
    • _lastNodeLengthReal

      protected int _lastNodeLengthReal
    • _distance

      protected List<Float> _distance
    • shouldRenderingCount

      protected int shouldRenderingCount
    • nodeRefreshState

      protected final int[] nodeRefreshState
    • interpolation

      protected short interpolation
    • state

      protected final float[] state
    • stateB

      protected final boolean[] stateB
  • Constructor Details

    • CurveEntity

      public CurveEntity()
    • CurveEntity

      public CurveEntity(@NotNull List<NodeData> nodeList)
  • Method Details

    • _StatePackageStack

      protected int _StatePackageStack()
      Overrides:
      _StatePackageStack in class BaseMIRenderData
    • initResourceLayout

      protected void initResourceLayout()
    • getCurveID

      public int getCurveID()
    • getNodesVBO

      public int getNodesVBO()
    • isValid

      public boolean isValid()
    • _deleteExc

      protected void _deleteExc()
      Overrides:
      _deleteExc in class BaseMIRenderData
    • glDraw

      public void glDraw()
      Specified by:
      glDraw in interface RenderDataAPI
      Overrides:
      glDraw in class BaseInstanceRenderData
    • _resetExc

      protected void _resetExc()
      Overrides:
      _resetExc in class BaseRenderData
    • reset

      public void reset()
      Excludes nodeList data.
      Specified by:
      reset in interface RenderDataAPI
      Overrides:
      reset in class BaseRenderData
    • resetNodes

      public void resetNodes()
    • submitNodes

      public byte submitNodes()
      Use it when you changed the node data.

      Will not keeping any node data if beyonds the initial size or the maximum submit size, recommend to call mallocNodeData(int) for allocate enough size before.

      Cost 26 Byte * (2n - 2) of vRAM when have number of n nodes, that if it had 8192 nodes will cost 415.95 KB of vRAM.

      Returns:
      return BoxEnum.STATE_SUCCESS when success.

      return BoxEnum.STATE_FAILED when an empty node list or refresh count is zero.

      return BoxEnum.STATE_FAILED_OTHER when happened another error.

    • mallocNodeData

      public byte mallocNodeData(int nodeNum)
      Optional.

      Just malloc() without any submit call.

      Parameters:
      nodeNum - must be positive integer.
      Returns:
      return BoxEnum.STATE_SUCCESS when success.

      return BoxEnum.STATE_FAILED when parameter error.

      return BoxEnum.STATE_FAILED_OTHER when happened another error.

    • isSynchronousSubmit

      public boolean isSynchronousSubmit()
      Default value is false.
    • setSynchronousSubmit

      public void setSynchronousSubmit(boolean sync)
      High performance impact when is synchronized.
    • isMappingModeSubmitData

      public boolean isMappingModeSubmitData()
      Default value is true.
    • setMappingModeSubmitData

      public void setMappingModeSubmitData(boolean mappingMode)
      For some very slight data, use glBufferSubData() may faster.

      Besides, some devices(some ARM SoC) may slower with glMapBufferRange(), decided by the drive how implements it.

      Parameters:
      mappingMode - to controls whether submit use glMapBufferRange(), else use glBufferSubData().
    • getNodeRefreshIndex

      public int getNodeRefreshIndex()
    • setNodeRefreshIndex

      public void setNodeRefreshIndex(int index)
      Parameters:
      index - Will refresh node data start from this index.
    • setNodeRefreshSize

      public void setNodeRefreshSize(int size)
      Parameters:
      size - Will refresh node data count.
    • setNodeRefreshAllFromCurrentIndex

      public void setNodeRefreshAllFromCurrentIndex()
    • getSubmitLengthCalculatingStep

      public int getSubmitLengthCalculatingStep()
    • setSubmitLengthCalculatingStep

      public void setSubmitLengthCalculatingStep(int step)
      Parameters:
      step - must be greater than zero.
    • getValidNodeCount

      public int getValidNodeCount()
    • isHaveValidNodeCount

      public boolean isHaveValidNodeCount()
    • getRealValidNodeCount

      public int getRealValidNodeCount()
    • getNodeRenderingCount

      public int getNodeRenderingCount()
    • setNodeRenderingCount

      public void setNodeRenderingCount(int nodeCount)
    • getNodes

      public List<NodeData> getNodes()
    • setNodes

      public void setNodes(@NotNull List<NodeData> nodeList)
      Parameters:
      nodeList - Cannot have any null-node, and at least have two nodeList, if not then pass this entity when rendering.
    • addNode

      public void addNode(@NotNull NodeData node)
    • initLineStrip

      public CurveEntity initLineStrip(@NotNull List<org.lwjgl.util.vector.Vector2f> points, Color color, Color emissiveColor, float width, boolean closed)
      Create a line-strip as GL_LINE_STRIP, and submit nodeList.

      Flat tangent, just a line-strip.

      Parameters:
      points - size must be larger than 2.
    • initLine

      public CurveEntity initLine(@Nullable org.lwjgl.util.vector.Vector2f offset, float length, Color color, Color emissiveColor, float width)
      Create a two-points line, and submit nodeList.

      Flat tangent, just a line.

    • initSmoothLine

      public CurveEntity initSmoothLine(@Nullable org.lwjgl.util.vector.Vector2f offset, float length, Color color, Color emissiveColor, float width, float smoothFactor)
      Create a three-points line with smooth both ends, and submit nodeList.
    • initCircle

      public CurveEntity initCircle(@Nullable org.lwjgl.util.vector.Vector2f offset, float radius, Color color, Color emissiveColor, float width)
      Rough fitting but more performance.

      Create a circle with three-points, and submit nodeList.

      Interpolation should be greater than zero.

    • initElliptic

      public CurveEntity initElliptic(@Nullable org.lwjgl.util.vector.Vector2f offset, float radiusW, float radiusH, Color color, Color emissiveColor, float width)
      Rough fitting but more performance.

      Create an elliptic with three-points, and submit nodeList.

      Interpolation should be greater than zero.

    • getInterpolation

      public int getInterpolation()
    • setInterpolation

      public void setInterpolation(short interpolation)
      From zero.

      Will add points at geometry shader.

    • getCurveState

      public float[] getCurveState()
    • getTextureSpeed

      public float getTextureSpeed()
    • setTextureSpeed

      public void setTextureSpeed(float textureSpeed)
      It is working together with setTexturePixels(float).
      Parameters:
      textureSpeed - looks flowing forward when less than zero.
    • getTexturePixels

      public float getTexturePixels()
    • setTexturePixels

      public void setTexturePixels(float texturePixels)
      Parameters:
      texturePixels - texture fill size.
    • isFlowWhenPaused

      public boolean isFlowWhenPaused()
    • setFlowWhenPaused

      public void setFlowWhenPaused(boolean flow)
    • isGlobalUV

      public boolean isGlobalUV()
    • setGlobalUV

      public void setGlobalUV(boolean useGlobal)
      Force uv mapping to [0, 1] from the first node to the last node, such as used for flag or tentacle.
    • getUVOffset

      public float getUVOffset()
    • setUVOffset

      public void setUVOffset(float offset)
    • getFillStartAlpha

      public float getFillStartAlpha()
    • setFillStartAlpha

      public void setFillStartAlpha(float alpha)
    • getFillEndAlpha

      public float getFillEndAlpha()
    • setFillEndAlpha

      public void setFillEndAlpha(float alpha)
    • getFillStartFactor

      public float getFillStartFactor()
    • setFillStartFactor

      public void setFillStartFactor(float factor)
    • getFillEndFactor

      public float getFillEndFactor()
    • setFillEndFactor

      public void setFillEndFactor(float factor)
    • submitEntityData

      public void submitEntityData()
      Description copied from class: BaseRenderData
      Without matrix data or timer settings.
      Specified by:
      submitEntityData in interface RenderDataAPI
      Overrides:
      submitEntityData in class BaseMIRenderData
    • entityType

      public Object entityType()
      Specified by:
      entityType in interface RenderDataAPI
      Overrides:
      entityType in class BaseRenderData