com.io7m.r2.core

## Class R2InstanceBillboardedDynamic

- java.lang.Object
- - com.io7m.r2.core.R2InstanceBillboardedDynamic

- All Implemented Interfaces:
    com.io7m.jcanephora.core.JCGLResourceUsableType, R2DeletableType, R2InstanceBillboardedDynamicType, R2InstanceBillboardedType, R2InstanceType

      public final class R2InstanceBillboardedDynamic
      extends Object
      implements R2InstanceBillboardedDynamicType

  The default implementation of the `R2InstanceBatchedDynamicType` interface.

  This implementation manages a fixed size set of at most `N` instances. It stores per-instance positions/scales/orientations in a vertex buffer object, and uses an "orphaning" strategy where the entire buffer storage is reallocated and populated on each call to `update(JCGLInterfaceGL33Type, R2TransformContextType)`.

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addInstance(com.io7m.jtensors.parameterized.PVectorI3F<R2SpaceWorldType> position, float scale, float rotation)` Enable rendering of an instance with transform `t`
    `com.io7m.jcanephora.core.JCGLArrayObjectType` | `arrayObject()`
    `void` | `clear()` Clear all instances.
    `void` | `delete(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)` Delete the current object.
    `int` | `enabledCount()`
    `long` | `instanceID()`
    `boolean` | `isDeleted()`
    `int` | `maximumSize()`
    `static R2InstanceBillboardedDynamicType` | `newBillboarded(R2IDPoolType pool, com.io7m.jcanephora.core.api.JCGLArrayBuffersType g_ab, com.io7m.jcanephora.core.api.JCGLArrayObjectsType g_ao, int count)` Construct a new batch of instances.
    `void` | `update(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g, R2TransformContextType context)` Update any data required for rendering on the GPU.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### newBillboarded

          public static R2InstanceBillboardedDynamicType newBillboarded(R2IDPoolType pool,
                                                                        com.io7m.jcanephora.core.api.JCGLArrayBuffersType g_ab,
                                                                        com.io7m.jcanephora.core.api.JCGLArrayObjectsType g_ao,
                                                                        int count)

      Construct a new batch of instances.
      Parameters:
        `pool` - The ID pool
        `g_ab` - An array buffer interface
        `g_ao` - An array object interface
        `count` - The maximum number of instances in the batch
      Returns:
        A new batch

    - #### maximumSize

          public int maximumSize()

      Specified by:
        `maximumSize` in interface `R2InstanceBillboardedDynamicType`
      Returns:
        The maximum number of instances that can be placed into the set

    - #### clear

          public void clear()

      Description copied from interface: `R2InstanceBillboardedDynamicType`
      Clear all instances.
      Specified by:
        `clear` in interface `R2InstanceBillboardedDynamicType`

    - #### addInstance

          public int addInstance(com.io7m.jtensors.parameterized.PVectorI3F<R2SpaceWorldType> position,
                                 float scale,
                                 float rotation)
                          throws R2ExceptionBatchIsFull

      Description copied from interface: `R2InstanceBillboardedDynamicType`
      Enable rendering of an instance with transform `t`
      Specified by:
        `addInstance` in interface `R2InstanceBillboardedDynamicType`
      Parameters:
        `position` - The world-space position
        `scale` - The scale
        `rotation` - The rotation
      Returns:
        The index of the enabled instance
      Throws:
        `R2ExceptionBatchIsFull` - If the batch cannot accept any more instances

    - #### delete

          public void delete(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g)
                      throws R2Exception

      Description copied from interface: `R2DeletableType`
      Delete the current object.
      Specified by:
        `delete` in interface `R2DeletableType`
      Parameters:
        `g` - An OpenGL interface
      Throws:
        `R2Exception` - On errors

    - #### isDeleted

          public boolean isDeleted()

      Specified by:
        `isDeleted` in interface `com.io7m.jcanephora.core.JCGLResourceUsableType`

    - #### instanceID

          public long instanceID()

      Specified by:
        `instanceID` in interface `R2InstanceType`
      Returns:
        The unique instance ID

    - #### arrayObject

          public com.io7m.jcanephora.core.JCGLArrayObjectType arrayObject()

      Specified by:
        `arrayObject` in interface `R2InstanceBillboardedType`
      Returns:
        The instance array object

    - #### update

          public void update(com.io7m.jcanephora.core.api.JCGLInterfaceGL33Type g,
                             R2TransformContextType context)

      Description copied from interface: `R2InstanceBillboardedType`
      Update any data required for rendering on the GPU.
      Specified by:
        `update` in interface `R2InstanceBillboardedType`
      Parameters:
        `g` - An OpenGL interface
        `context` - The transform context

    - #### enabledCount

          public int enabledCount()

      Specified by:
        `enabledCount` in interface `R2InstanceBillboardedType`
      Returns:
        The number of instances currently present in the set

Copyright © 2017 <code@io7m.com> http://io7m.com