Package gaiasky.render.system
Class InstancedRenderSystem
java.lang.Object
gaiasky.render.system.AbstractRenderSystem
gaiasky.render.system.ImmediateModeRenderSystem
gaiasky.render.system.InstancedRenderSystem
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
,IObserver
,IRenderSystem
,Comparable<IRenderSystem>
- Direct Known Subclasses:
ParticleSetInstancedRenderer
,StarSetInstancedRenderer
,VariableSetInstancedRenderer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Holds temporary instanced model data.Nested classes/interfaces inherited from class gaiasky.render.system.ImmediateModeRenderSystem
ImmediateModeRenderSystem.MeshData, ImmediateModeRenderSystem.OwnUsage
Nested classes/interfaces inherited from class gaiasky.render.system.AbstractRenderSystem
AbstractRenderSystem.RenderSystemRunnable
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.badlogic.gdx.utils.Array
<InstancedRenderSystem.InstancedModel> Instanced model list, one per particle group.Fields inherited from class gaiasky.render.system.ImmediateModeRenderSystem
curr, inGpu, meshes, meshIdx, tempIndices, tempVerts
Fields inherited from class gaiasky.render.system.AbstractRenderSystem
alphas, auxd, auxf, comp, postRunners, preRunners, programs, rc, sceneRenderer
-
Constructor Summary
ConstructorDescriptionInstancedRenderSystem
(SceneRenderer sceneRenderer, RenderGroup rg, float[] alphas, ExtShaderProgram[] shaders) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAttributesDivisor0
(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int posArraySize, boolean useNormals, boolean useTexCoords) Adds the required vertex attributes for this renderer to the given list.protected abstract void
addAttributesDivisor1
(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int primitive) Adds the required vertex attributes for this renderer to the given list.protected int
addMeshData
(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelFile, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.protected com.badlogic.gdx.graphics.VertexAttribute[]
buildAttributesDivisor0
(int posArraySize, boolean useNormals, boolean useTexCoords) Builds the vertex attributes with divisor=0 array and returns it.protected com.badlogic.gdx.graphics.VertexAttribute[]
buildAttributesDivisor1
(int primitive) Builds the vertex attributes with divisor=1 array and returns it The content of divisor-1 attributes is updated for each instance.protected InstancedRenderSystem.InstancedModel
getModel
(ParticleSet set, int offset) protected InstancedRenderSystem.InstancedModel
getModel
(IntModel modelFile, String modelType, Map<String, Object> modelParams, int primitive, int offset) protected void
boolean
isWireframe
(int primitive) protected abstract void
Computes the offset for each vertex attribute.protected abstract void
Computes the offset for each vertex attribute in the instanced array.protected void
postRenderObjects
(ExtShaderProgram shaderProgram, ICamera camera) protected void
preRenderObjects
(ExtShaderProgram shaderProgram, ICamera camera) protected void
renderObject
(ExtShaderProgram shaderProgram, IRenderable renderable) void
renderStud
(List<IRenderable> renderables, ICamera camera, double t) protected void
setModel
(int offset, InstancedRenderSystem.InstancedModel model) Methods inherited from class gaiasky.render.system.ImmediateModeRenderSystem
clearMeshData, clearMeshes, color, color, color, color, createMeshData, dispose, ensureTempIndicesSize, ensureTempVertsSize, getCount, getOffset, inGpu, setCount, setInGpu, setOffset, vertex
Methods inherited from class gaiasky.render.system.AbstractRenderSystem
addCameraUpCubemapMode, addDepthBufferUniforms, addEffectsUniforms, addGravWaveUniforms, addPostRunnables, addPreRunnables, addPreviousFrameUniforms, addRelativisticUniforms, addVRScale, compareTo, getAlpha, getAlpha, getAlpha, getRenderGroup, getShaderProgram, getShaderProgram, initShaderProgram, render, resetFlags, resize, run, updateBatchSize
-
Field Details
-
models
Instanced model list, one per particle group.
-
-
Constructor Details
-
InstancedRenderSystem
public InstancedRenderSystem(SceneRenderer sceneRenderer, RenderGroup rg, float[] alphas, ExtShaderProgram[] shaders)
-
-
Method Details
-
initVertices
protected void initVertices()- Specified by:
initVertices
in classImmediateModeRenderSystem
-
isWireframe
public boolean isWireframe(int primitive) -
setModel
-
getModel
-
getModel
-
addAttributesDivisor0
protected void addAttributesDivisor0(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int posArraySize, boolean useNormals, boolean useTexCoords) Adds the required vertex attributes for this renderer to the given list. These attributes are added only once for all instances (divisor=0)- Parameters:
attributes
- The list of attributes with divisor=0posArraySize
- Size of the position array (2 or 3).useNormals
- Add normal attributes as a vector-3.useTexCoords
- Add texture coordinates attribute as a vector-2.
-
addAttributesDivisor1
protected abstract void addAttributesDivisor1(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.VertexAttribute> attributes, int primitive) Adds the required vertex attributes for this renderer to the given list. These attributes are added for every instance (divisor=1)- Parameters:
attributes
- The list of attributes with divisor=1primitive
- The rendering primitive.
-
buildAttributesDivisor0
protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor0(int posArraySize, boolean useNormals, boolean useTexCoords) Builds the vertex attributes with divisor=0 array and returns it. The content of divisor-0 attributes is updated in each iteration of the vertex shader.- Parameters:
posArraySize
- Size of the position array (2 or 3).useNormals
- Add normal attributes as a vector-3.useTexCoords
- Add texture coordinates attribute as a vector-2.- Returns:
- The vertex attributes array
-
buildAttributesDivisor1
protected com.badlogic.gdx.graphics.VertexAttribute[] buildAttributesDivisor1(int primitive) Builds the vertex attributes with divisor=1 array and returns it The content of divisor-1 attributes is updated for each instance.- Parameters:
primitive
- The rendering primitive.- Returns:
- The vertex attributes array.
-
offsets0
protected abstract void offsets0(ImmediateModeRenderSystem.MeshData curr, InstancedRenderSystem.InstancedModel model) Computes the offset for each vertex attribute. The offsets will be used later in the render stage.- Parameters:
curr
- The current mesh data.model
- The instanced model.
-
offsets1
protected abstract void offsets1(ImmediateModeRenderSystem.MeshData curr, InstancedRenderSystem.InstancedModel model) Computes the offset for each vertex attribute in the instanced array. The offsets will be used later in the render stage.- Parameters:
curr
- The current mesh data.model
- The instanced model.
-
addMeshData
protected int addMeshData(InstancedRenderSystem.InstancedModel model, int maxVerts, int maxInstances, int maxIndices, String modelFile, String modelType, int primitive) Adds a new mesh data to the meshes list and increases the mesh data index.- Parameters:
model
- The instanced model instance.maxVerts
- The max number of vertices the divisor 0 mesh data can hold.maxInstances
- The max number of vertices the divisor 1 mesh data can hold.modelFile
- The model file, if any.modelType
- The model type string.primitive
- The rendering primitive.- Returns:
- The index of the new mesh data.
-
preRenderObjects
-
renderObject
-
postRenderObjects
-
renderStud
- Specified by:
renderStud
in classAbstractRenderSystem
-