Class RenderableManager


  • public class RenderableManager
    extends java.lang.Object
    Factory and manager for renderables, which are entities that can be drawn.

    Renderables are bundles of primitives, each of which has its own geometry and material. All primitives in a particular renderable share a set of rendering attributes, such as whether they cast shadows or use vertex skinning. Kotlin usage example:

     val entity = EntityManager.get().create()
    
     RenderableManager.Builder(1)
             .boundingBox(Box(0.0f, 0.0f, 0.0f, 9000.0f, 9000.0f, 9000.0f))
             .geometry(0, RenderableManager.PrimitiveType.TRIANGLES, vb, ib)
             .material(0, material)
             .build(engine, entity)
    
     scene.addEntity(renderable)
     

    To modify the state of an existing renderable, clients should first use RenderableManager to get a temporary handle called an instance. The instance can then be used to get or set the renderable's state. Please note that instances are ephemeral; clients should store entities, not instances.

    • Method Detail

      • hasComponent

        public boolean hasComponent​(int entity)
        Checks if the given entity already has a renderable component.
      • getInstance

        public int getInstance​(int entity)
        Gets a temporary handle that can be used to access the renderable state.
      • destroy

        public void destroy​(int entity)
        Destroys the renderable component in the given entity.
      • setSkinningBuffer

        public void setSkinningBuffer​(int i,
                                      @NonNull
                                      SkinningBuffer skinningBuffer,
                                      int count,
                                      int offset)
        Associates a SkinningBuffer to a renderable instance
        Parameters:
        i - Instance of the Renderable
        skinningBuffer - SkinningBuffer to use
        count - Numbers of bones to set
        offset - Offset in the SkinningBuffer
      • setBonesAsMatrices

        public void setBonesAsMatrices​(int i,
                                       @NonNull
                                       java.nio.Buffer matrices,
                                       @IntRange(from=0L,to=255L)
                                       int boneCount,
                                       @IntRange(from=0L)
                                       int offset)
        Sets the transforms associated with each bone of a Renderable.
        Parameters:
        i - Instance of the Renderable
        matrices - A FloatBuffer containing boneCount 4x4 packed matrices (i.e. 16 floats each matrix and no gap between matrices)
        boneCount - Number of bones to set
        offset - Index of the first bone to set
      • setBonesAsQuaternions

        public void setBonesAsQuaternions​(int i,
                                          @NonNull
                                          java.nio.Buffer quaternions,
                                          @IntRange(from=0L,to=255L)
                                          int boneCount,
                                          @IntRange(from=0L)
                                          int offset)
        Sets the transforms associated with each bone of a Renderable.
        Parameters:
        i - Instance of the Renderable
        quaternions - A FloatBuffer containing boneCount transforms. Each transform consists of 8 float. float 0 to 3 encode a unit quaternion w+ix+jy+kz stored as x,y,z,w. float 4 to 7 encode a translation stored as x,y,z,1
        boneCount - Number of bones to set
        offset - Index of the first bone to set
      • setMorphWeights

        public void setMorphWeights​(int i,
                                    @NonNull
                                    float[] weights,
                                    @IntRange(from=0L)
                                    int offset)
        Updates the vertex morphing weights on a renderable, all zeroes by default.

        The renderable must be built with morphing enabled. In legacy morphing mode, only the first 4 weights are considered.

        See Also:
        RenderableManager.Builder.morphing(int)
      • setMorphTargetBufferAt

        public void setMorphTargetBufferAt​(int i,
                                           @IntRange(from=0L)
                                           int level,
                                           @IntRange(from=0L)
                                           int primitiveIndex,
                                           @NonNull
                                           MorphTargetBuffer morphTargetBuffer,
                                           @IntRange(from=0L)
                                           int offset,
                                           @IntRange(from=0L)
                                           int count)
        Changes the morph target buffer for the given primitive.

        The renderable must be built with morphing enabled.

        See Also:
        RenderableManager.Builder.morphing(int)
      • getMorphTargetCount

        @IntRange(from=0L)
        public int getMorphTargetCount​(int i)
        Gets the morph target count on a renderable.
      • setLightChannel

        public void setLightChannel​(int i,
                                    @IntRange(from=0L,to=7L)
                                    int channel,
                                    boolean enable)
        Enables or disables a light channel. Light channel 0 is enabled by default.
        Parameters:
        i - Instance of the component obtained from getInstance().
        channel - Light channel to set
        enable - true to enable, false to disable
        See Also:
        RenderableManager.Builder.lightChannel(int, boolean)
      • getLightChannel

        public boolean getLightChannel​(int i,
                                       @IntRange(from=0L,to=7L)
                                       int channel)
        Returns whether a light channel is enabled on a specified renderable.
        Parameters:
        i - Instance of the component obtained from getInstance().
        channel - Light channel to query
        Returns:
        true if the light channel is enabled, false otherwise
      • getPrimitiveCount

        @IntRange(from=0L)
        public int getPrimitiveCount​(int i)
        Gets the immutable number of primitives in the given renderable.
      • getMaterialInstanceAt

        @NonNull
        public MaterialInstance getMaterialInstanceAt​(int i,
                                                      @IntRange(from=0L)
                                                      int primitiveIndex)
        Creates a MaterialInstance Java wrapper object for a particular material instance.
      • setGeometryAt

        public void setGeometryAt​(int i,
                                  @IntRange(from=0L)
                                  int primitiveIndex,
                                  @NonNull
                                  RenderableManager.PrimitiveType type,
                                  @IntRange(from=0L)
                                  int offset,
                                  @IntRange(from=0L)
                                  int count)
        Changes the geometry for the given primitive.
        See Also:
        Builder.geometry
      • setBlendOrderAt

        public void setBlendOrderAt​(int instance,
                                    @IntRange(from=0L)
                                    int primitiveIndex,
                                    @IntRange(from=0L,to=65535L)
                                    int blendOrder)
        Changes the ordering index for blended primitives that all live at the same Z value.
        Parameters:
        instance - the renderable of interest
        primitiveIndex - the primitive of interest
        blendOrder - draw order number (0 by default). Only the lowest 15 bits are used.
        See Also:
        RenderableManager.Builder.blendOrder(int, int)
      • getEnabledAttributesAt

        public java.util.Set<VertexBuffer.VertexAttribute> getEnabledAttributesAt​(int i,
                                                                                  @IntRange(from=0L)
                                                                                  int primitiveIndex)
        Retrieves the set of enabled attribute slots in the given primitive's VertexBuffer.
      • getNativeObject

        public long getNativeObject()