Package 

Class RenderableManager.Builder

    • Constructor Detail

      • RenderableManager.Builder

        RenderableManager.Builder(int count)
        Creates a builder for renderable components.
        Parameters:
        count - the number of primitives that will be supplied to the builderNote that builders typically do not have a long lifetime since clients should discardthem after calling build.
    • Method Detail

      • geometry

        @NonNull() RenderableManager.Builder geometry(@IntRange(from = 0) int index, @NonNull() RenderableManager.PrimitiveType type, @NonNull() VertexBuffer vertices, @NonNull() IndexBuffer indices, @IntRange(from = 0) int offset, @IntRange(from = 0) int minIndex, @IntRange(from = 0) int maxIndex, @IntRange(from = 0) int count)

        Specifies the geometry data for a primitive.Filament primitives must have an associated VertexBuffer and IndexBuffer.Typically, each primitive is specified with a pair of daisy-chained calls:geometry() and material().

        Parameters:
        index - zero-based index of the primitive, must be less than the count passed to Builder constructor
        type - specifies the topology of the primitive (e.g.
        vertices - specifies the vertex buffer, which in turn specifies a set of attributes
        indices - specifies the index buffer (either u16 or u32)
        offset - specifies where in the index buffer to start reading (expressed as a number of indices)
        minIndex - specifies the minimum index contained in the index buffer
        maxIndex - specifies the maximum index contained in the index buffer
        count - number of indices to read (for triangles, this should be a multiple of 3)
      • material

        @NonNull() RenderableManager.Builder material(@IntRange(from = 0) int index, @NonNull() MaterialInstance material)

        Binds a material instance to the specified primitive.

        If no material is specified for a given primitive, Filament will fall back to a basicdefault material.

        Parameters:
        index - zero-based index of the primitive, must be less than the count passed to Builder constructor
        material - the material to bind
      • blendOrder

        @NonNull() RenderableManager.Builder blendOrder(@IntRange(from = 0) int index, @IntRange(from = 0, to = 32767) int blendOrder)

        Sets the drawing order for blended primitives. The drawing order is either global orlocal (default) to this Renderable. In either case, the Renderable priority takesprecedence.

        Parameters:
        index - the primitive of interest
        blendOrder - draw order number (0 by default).
      • globalBlendOrderEnabled

        @NonNull() RenderableManager.Builder globalBlendOrderEnabled(@IntRange(from = 0) int index, boolean enabled)

        Sets whether the blend order is global or local to this Renderable (by default).

        Parameters:
        index - the primitive of interest
        enabled - true for global, false for local blend ordering.
      • boundingBox

        @NonNull() RenderableManager.Builder boundingBox(@NonNull() Box aabb)

        The axis-aligned bounding box of the renderable.

        This is an object-space AABB used for frustum culling. For skinning and morphing, thisshould encompass all possible vertex positions. It is mandatory unless culling isdisabled for the renderable.

      • layerMask

        @NonNull() RenderableManager.Builder layerMask(@IntRange(from = 0, to = 255) int select, @IntRange(from = 0, to = 255) int value)

        Sets bits in a visibility mask. By default, this is 0x1.

        This feature provides a simple mechanism for hiding and showing groups of renderablesin a Scene. See setVisibleLayers.

        For example, to set bit 1 and reset bits 0 and 2 while leaving all other bitsunaffected, do: builder.layerMask(7, 2).

        Parameters:
        select - the set of bits to affect
        value - the replacement values for the affected bits
      • priority

        @NonNull() RenderableManager.Builder priority(@IntRange(from = 0, to = 7) int priority)

        Provides coarse-grained control over draw order.

        In general Filament reserves the right to re-order renderables to allow for efficientrendering. However clients can control ordering at a coarse level using priority.The priority is applied separately for opaque and translucent objects, that is, opaqueobjects are always drawn before translucent objects regardless of the priority.

        For example, this could be used to draw a semitransparent HUD, if a client wishes toavoid using a separate View for the HUD. Note that priority is completely orthogonal to layerMask, which merely controls visibility.

        The Skybox always using the lowest priority, so it's drawn last, which may improveperformance.

        Parameters:
        priority - clamped to the range [0..7], defaults to 4; 7 is lowest priority(rendered last).
      • channel

        @NonNull() RenderableManager.Builder channel(@IntRange(from = 0, to = 3) int channel)

        Set the channel this renderable is associated to. There can be 4 channels.

        All renderables in a given channel are rendered together, regardless of anything else.They are sorted as usual within a channel.

        Channels work similarly to priorities, except that they enforce the strongestordering.

        Channels 0 and 1 may not have render primitives using a material with `refractionType`set to `screenspace`.

        Parameters:
        channel - clamped to the range [0..3], defaults to 2.
      • culling

        @NonNull() RenderableManager.Builder culling(boolean enabled)

        Controls frustum culling, true by default.

        Do not confuse frustum culling with backface culling. The latter is controlled viathe material.

      • lightChannel

        @NonNull() RenderableManager.Builder lightChannel(@IntRange(from = 0, to = 7) int channel, boolean enable)

        Enables or disables a light channel. Light channel 0 is enabled by default.

        Parameters:
        channel - Light channel to enable or disable, between 0 and 7.
        enable - Whether to enable or disable the light channel.
      • instances

        @NonNull() RenderableManager.Builder instances(@IntRange(from = 1, to = 32767) int instanceCount)

        Specifies the number of draw instance of this renderable. The default is 1 instance andthe maximum number of instances allowed is 32767. 0 is invalid.All instances are culled using the same bounding box, so care must be taken to makesure all instances render inside the specified bounding box.The material can use getInstanceIndex() in the vertex shader to get the instance index andpossibly adjust the position or transform.

        Parameters:
        instanceCount - the number of instances silently clamped between 1 and 32767.
      • castShadows

        @NonNull() RenderableManager.Builder castShadows(boolean enabled)

        Controls if this renderable casts shadows, false by default.If the View's shadow type is set to VSM, castShadows should onlybe disabled if either is true:

        • setReceiveShadows is also disabled
        • the object is guaranteed to not cast shadows on itself or other objects (forexample, a ground plane)
      • enableSkinningBuffers

        @NonNull() RenderableManager.Builder enableSkinningBuffers(boolean enabled)

        Allows bones to be swapped out and shared using SkinningBuffer.If skinning buffer mode is enabled, clients must call #setSkinningBuffer() rather than#setBonesAsQuaternions(). This allows sharing of data between renderables.

        Parameters:
        enabled - If true, enables buffer object mode.
      • skinning

        @NonNull() RenderableManager.Builder skinning(SkinningBuffer skinningBuffer, @IntRange(from = 0, to = 255) int boneCount, int offset)

        Enables GPU vertex skinning for up to 255 bones, 0 by default.

        Skinning Buffer mode must be enabled.

        Each vertex can be affected by up to 4 bones simultaneously. The attachedVertexBuffer must provide data in the BONE_INDICES slot (uvec4) and theBONE_WEIGHTS slot (float4).

        See also setSkinningBuffer, setBonesAsMatrices or setBonesAsQuaternions,which can be called on a per-frame basis to advance the animation.

        Parameters:
        skinningBuffer - null to disable, otherwise the SkinningBuffer to use
        boneCount - 0 to disable, otherwise the number of bone transforms (up to 255)
        offset - offset in the SkinningBuffer
      • skinning

        @NonNull() RenderableManager.Builder skinning(@IntRange(from = 0, to = 255) int boneCount, @NonNull() Buffer bones)

        Enables GPU vertex skinning for up to 255 bones, 0 by default.

        Skinning Buffer mode must be disabled.

        Each vertex can be affected by up to 4 bones simultaneously. The attachedVertexBuffer must provide data in the BONE_INDICES slot (uvec4) and theBONE_WEIGHTS slot (float4).

        See also setBonesAsMatrices, which can be called on a per-frame basisto advance the animation.

        Parameters:
        boneCount - Number of bones associated with this component
        bones - A FloatBuffer containing boneCount transforms.
      • morphing

        @NonNull() RenderableManager.Builder morphing(@IntRange(from = 0, to = 255) int targetCount)

        Controls if the renderable has vertex morphing targets, zero by default. This isrequired to enable GPU morphing.

        Filament supports two morphing modes: standard (default) and legacy.

        For standard morphing, A MorphTargetBuffer must be created and provided via setMorphTargetBufferAt. Standard morphing supports up toCONFIG_MAX_MORPH_TARGET_COUNT morph targets.

        For legacy morphing, the attached VertexBuffer must provide data in theappropriate VertexBuffer.VertexAttribute slots (MORPH_POSITION_0 etc).Legacy morphing only supports up to 4 morph targets and will be deprecated in the future.Legacy morphing must be enabled on the material definition: either via thelegacyMorphing material attribute or by calling ::useLegacyMorphing.

        See also setMorphWeights, which can be called on a per-frame basisto advance the animation.

      • morphing

        @NonNull() RenderableManager.Builder morphing(@IntRange(from = 0) int level, @IntRange(from = 0) int primitiveIndex, @NonNull() MorphTargetBuffer morphTargetBuffer, @IntRange(from = 0) int offset, @IntRange(from = 0) int count)

        Specifies the morph target buffer for a primitive.The morph target buffer must have an associated renderable and geometry. Two conditionsmust be met:1. The number of morph targets in the buffer must equal the renderable's morph targetcount.2. The vertex count of each morph target must equal the geometry's vertex count.

        Parameters:
        level - the level of detail (lod), only 0 can be specified
        primitiveIndex - zero-based index of the primitive, must be less than the count passed to Builder constructor
        morphTargetBuffer - specifies the morph target buffer
        offset - specifies where in the morph target buffer to start reading (expressed as a number of vertices)
        count - number of vertices in the morph target buffer to read, must equal the geometry's count (for triangles, this should be a multiple of 3)
      • build

         void build(@NonNull() Engine engine, int entity)

        Adds the Renderable component to an entity.

        If this component already exists on the given entity and the construction is successful,it is first destroyed as if destroy was called.

        Parameters:
        engine - reference to the Engine to associate this renderable with
        entity - entity to add the renderable component to