-
public class RenderableManager.BuilderAdds renderable components to entities using a builder pattern.
-
-
Constructor Summary
Constructors Constructor Description RenderableManager.Builder(int count)Creates a builder for renderable components.
-
Method Summary
Modifier and Type Method Description RenderableManager.Buildergeometry(@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. RenderableManager.Buildergeometry(@IntRange(from = 0) int index, @NonNull() RenderableManager.PrimitiveType type, @NonNull() VertexBuffer vertices, @NonNull() IndexBuffer indices, @IntRange(from = 0) int offset, @IntRange(from = 0) int count)For details, see the geometry primary overload. RenderableManager.Buildergeometry(@IntRange(from = 0) int index, @NonNull() RenderableManager.PrimitiveType type, @NonNull() VertexBuffer vertices, @NonNull() IndexBuffer indices)For details, see the geometry primary overload. RenderableManager.Buildermaterial(@IntRange(from = 0) int index, @NonNull() MaterialInstance material)Binds a material instance to the specified primitive. RenderableManager.BuilderblendOrder(@IntRange(from = 0) int index, @IntRange(from = 0, to = 32767) int blendOrder)Sets the drawing order for blended primitives. RenderableManager.BuilderglobalBlendOrderEnabled(@IntRange(from = 0) int index, boolean enabled)Sets whether the blend order is global or local to this Renderable (by default). RenderableManager.BuilderboundingBox(@NonNull() Box aabb)The axis-aligned bounding box of the renderable. RenderableManager.BuilderlayerMask(@IntRange(from = 0, to = 255) int select, @IntRange(from = 0, to = 255) int value)Sets bits in a visibility mask. RenderableManager.Builderpriority(@IntRange(from = 0, to = 7) int priority)Provides coarse-grained control over draw order. RenderableManager.Builderchannel(@IntRange(from = 0, to = 3) int channel)Set the channel this renderable is associated to. RenderableManager.Builderculling(boolean enabled)Controls frustum culling, true by default. RenderableManager.BuilderlightChannel(@IntRange(from = 0, to = 7) int channel, boolean enable)Enables or disables a light channel. RenderableManager.Builderinstances(@IntRange(from = 1, to = 32767) int instanceCount)Specifies the number of draw instance of this renderable. RenderableManager.BuildercastShadows(boolean enabled)Controls if this renderable casts shadows, false by default. RenderableManager.BuilderreceiveShadows(boolean enabled)Controls if this renderable receives shadows, true by default. RenderableManager.BuilderscreenSpaceContactShadows(boolean enabled)Controls if this renderable uses screen-space contact shadows. RenderableManager.BuilderenableSkinningBuffers(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(). RenderableManager.Builderskinning(SkinningBuffer skinningBuffer, @IntRange(from = 0, to = 255) int boneCount, int offset)Enables GPU vertex skinning for up to 255 bones, 0 by default. RenderableManager.Builderskinning(@IntRange(from = 0, to = 255) int boneCount)RenderableManager.Builderskinning(@IntRange(from = 0, to = 255) int boneCount, @NonNull() Buffer bones)Enables GPU vertex skinning for up to 255 bones, 0 by default. RenderableManager.Buildermorphing(@IntRange(from = 0, to = 255) int targetCount)Controls if the renderable has vertex morphing targets, zero by default. RenderableManager.Buildermorphing(@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. RenderableManager.Buildermorphing(@IntRange(from = 0) int level, @IntRange(from = 0) int primitiveIndex, @NonNull() MorphTargetBuffer morphTargetBuffer)Utility method to specify morph target buffer for a primitive. voidbuild(@NonNull() Engine engine, int entity)Adds the Renderable component to an entity. -
-
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()andmaterial().- Parameters:
index- zero-based index of the primitive, must be less than the count passed to Builder constructortype- specifies the topology of the primitive (e.g.vertices- specifies the vertex buffer, which in turn specifies a set of attributesindices- 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 buffermaxIndex- specifies the maximum index contained in the index buffercount- number of indices to read (for triangles, this should be a multiple of 3)
-
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 count)
For details, see the geometry primary overload.
-
geometry
@NonNull() RenderableManager.Builder geometry(@IntRange(from = 0) int index, @NonNull() RenderableManager.PrimitiveType type, @NonNull() VertexBuffer vertices, @NonNull() IndexBuffer indices)
For details, see the geometry primary overload.
-
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 constructormaterial- 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 interestblendOrder- 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 interestenabled- 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 affectvalue- 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)
-
receiveShadows
@NonNull() RenderableManager.Builder receiveShadows(boolean enabled)
Controls if this renderable receives shadows, true by default.
-
screenSpaceContactShadows
@NonNull() RenderableManager.Builder screenSpaceContactShadows(boolean enabled)
Controls if this renderable uses screen-space contact shadows. This is moreexpensive but can improve the quality of shadows, especially in large scenes.(off by default).
-
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 useboneCount- 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)
-
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_INDICESslot (uvec4) and theBONE_WEIGHTSslot (float4).See also setBonesAsMatrices, which can be called on a per-frame basisto advance the animation.
- Parameters:
boneCount- Number of bones associated with this componentbones- 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 to
For legacy morphing, the attached VertexBuffer must provide data in theappropriate VertexBuffer.VertexAttribute slots (CONFIG_MAX_MORPH_TARGET_COUNTmorph targets.MORPH_POSITION_0etc).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 thelegacyMorphingmaterial 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 specifiedprimitiveIndex- zero-based index of the primitive, must be less than the count passed to Builder constructormorphTargetBuffer- specifies the morph target bufferoffset- 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)
-
morphing
@NonNull() RenderableManager.Builder morphing(@IntRange(from = 0) int level, @IntRange(from = 0) int primitiveIndex, @NonNull() MorphTargetBuffer morphTargetBuffer)
Utility method to specify morph target buffer for a primitive.For details, see the morphing.
-
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 theEngineto associate this renderable withentity- entity to add the renderable component to
-
-
-
-