Class SegmentEntity

java.lang.Object
org.boxutil.base.BaseRenderData
org.boxutil.units.standard.entity.SegmentEntity
All Implemented Interfaces:
MaterialRenderAPI, RenderDataAPI

public class SegmentEntity extends BaseRenderData implements MaterialRenderAPI
This is a 2D curve.

Segment 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_SIZE_F16

      protected static final byte _NODE_SIZE_F16
      See Also:
    • _NODE_SIZE_F32

      protected static final byte _NODE_SIZE_F32
      See Also:
    • _segmentID

      protected final int _segmentID
    • _nodesVBO

      protected final int _nodesVBO
    • _isValid

      protected volatile boolean _isValid
    • _useHalfFloat

      protected final boolean _useHalfFloat
    • _currNodeSize

      protected final byte _currNodeSize
    • _currNodeBitOffset

      protected final byte _currNodeBitOffset
    • nodeList

      protected List<NodeData> nodeList
    • _lastNodeLength

      protected int _lastNodeLength
    • shouldRenderingCount

      protected int shouldRenderingCount
    • nodeRefreshState

      protected final int[] nodeRefreshState
    • _distance

      protected List<Float> _distance
    • interpolation

      protected short interpolation
    • state

      protected final float[] state
    • stateB

      protected boolean[] stateB
    • material

      protected MaterialData material
  • Constructor Details

    • SegmentEntity

      public SegmentEntity(boolean useHalfFloat)
      Parameters:
      useHalfFloat - true that the data buffer will use half-float, else use float.
    • SegmentEntity

      public SegmentEntity()
  • Method Details

    • _StatePackageStack

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

      protected void initResourceLayout()
    • getSegmentID

      public int getSegmentID()
    • getNodesVBO

      public int getNodesVBO()
    • isValid

      public boolean isValid()
    • isHalfFloatData

      public boolean isHalfFloatData()
    • _deleteExc

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

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

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

      public void resetNodes()
    • getRealNodeCount

      protected static int getRealNodeCount(int num)
    • isEndNode

      protected static boolean isEndNode(int index)
    • 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.

      For half-float, cost 22 Byte * n of vRAM when have number of n nodes(n is non-zero even number), that if it had 8192 nodes will cost 176 KiB of vRAM.

      For float, cost 36 Byte * n and 8192 nodes will cost 176 KiB 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().
    • getListValidNodeCount

      public int getListValidNodeCount()
    • 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()
    • getSegmentsRenderingCount

      public int getSegmentsRenderingCount()
    • setSegmentsRenderingCount

      public void setSegmentsRenderingCount(int segmentsCount)
    • getNodes

      public List<NodeData> getNodes()
    • setNodes

      public void setNodes(@NotNull List<NodeData> nodeList)
      Each two nodes be a segment, for example: {Node-0, Node-1, Node-2, Node-3} => {Segment-0{Node-0, Node-1}, Segment-1{Node-2, Node-3}}.

      Ignore isolated node.

      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 SegmentEntity 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 SegmentEntity 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.

    • initCircle

      public SegmentEntity 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 SegmentEntity 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 CurveEntity.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)
    • 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)
    • getMaterialData

      @NotNull public MaterialData getMaterialData()
      Specified by:
      getMaterialData in interface MaterialRenderAPI
    • setMaterialData

      public void setMaterialData(@NotNull MaterialData material)
      Specified by:
      setMaterialData in interface MaterialRenderAPI
    • 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 BaseRenderData
    • entityType

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