Class VertexBuffer

    • Field Detail

      • m_kAttributes

        private Attributes m_kAttributes
        The format of a single vertex in the buffer.
      • m_iVertexQuantity

        private int m_iVertexQuantity
        The number of vertices in the buffer.
      • m_afPositions

        private float[] m_afPositions
        The vertex buffer data.
      • m_afNormals

        private float[] m_afNormals
      • m_afTextures

        private float[][] m_afTextures
      • m_afColors

        private float[][] m_afColors
      • m_bPositionsChanged

        private boolean m_bPositionsChanged
      • m_bNormalsChanged

        private boolean m_bNormalsChanged
      • m_bTexturesChanged

        private boolean[] m_bTexturesChanged
      • m_bColorsChanged

        private boolean[] m_bColorsChanged
      • m_akPositionBuffer

        private java.nio.FloatBuffer m_akPositionBuffer
      • m_akNormalBuffer

        private java.nio.FloatBuffer m_akNormalBuffer
      • m_akTexCoordBuffer

        private java.nio.FloatBuffer[] m_akTexCoordBuffer
      • m_akColorBuffer

        private java.nio.FloatBuffer[] m_akColorBuffer
      • SubVBuffer

        public java.util.Vector<Vector2f> SubVBuffer
      • m_bLoadSub

        protected boolean m_bLoadSub
        Set to true to load a sub-vertex buffer to the GPU
    • Constructor Detail

      • VertexBuffer

        public VertexBuffer()
        Default constructor.
      • VertexBuffer

        public VertexBuffer​(Attributes rkAttributes,
                            int iVertexQuantity)
        Create a VertexBuffer with the given attributes and number of vertices. Calculate the size of the VertexBuffer based on the Attributes.
        Parameters:
        rkAttributes - vertex buffer attributes.
        iVertexQuantity - number of vertices.
      • VertexBuffer

        public VertexBuffer​(Vector3f[] akPositions)
        Create a VertexBuffer from a list of vertices.
        Parameters:
        akPositions - List of vertices to copy.
      • VertexBuffer

        public VertexBuffer​(java.util.Vector<Vector3f> akPositions)
        Create a VertexBuffer from a list of vertices.
        Parameters:
        akPositions - List of vertices to copy.
      • VertexBuffer

        public VertexBuffer​(VertexBuffer pkVBuffer)
        Copy constructor.
        Parameters:
        pkVBuffer - VertexBuffer to copy into this.
    • Method Detail

      • initBuffers

        private void initBuffers()
      • copyBuffers

        private void copyBuffers​(VertexBuffer pkVBuffer)
      • dispose

        public void dispose()
        Delete memory.
        Overrides:
        dispose in class Spatial
      • GetAttributes

        public final Attributes GetAttributes()
        The format of a single vertex in the buffer.
        Returns:
        vertex attributes.
      • IsPositionsChanged

        public boolean IsPositionsChanged()
      • IsNormalsChanged

        public boolean IsNormalsChanged()
      • IsTexturesChanged

        public boolean IsTexturesChanged​(int iUnit)
      • IsColorsChanged

        public boolean IsColorsChanged​(int iUnit)
      • GetColor1

        public float GetColor1​(int iUnit,
                               int i)
        Set the color at the given index.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
      • GetColor3

        public ColorRGB GetColor3​(int iUnit,
                                  int i)
        Get the color at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        Returns:
        color.
      • GetColor3

        public void GetColor3​(int iUnit,
                              int i,
                              ColorRGB kResult)
        Get the color at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
      • GetColor4

        public ColorRGBA GetColor4​(int iUnit,
                                   int i)
        Get the color at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        Returns:
        color.
      • GetColor4

        public void GetColor4​(int iUnit,
                              int i,
                              ColorRGBA kResult)
        Get the color at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
      • GetDiskUsed

        public int GetDiskUsed​(StreamVersion rkVersion)
        Returns the size of this object and it's children on disk for the current StreamVersion parameter.
        Specified by:
        GetDiskUsed in interface StreamInterface
        Overrides:
        GetDiskUsed in class Spatial
        Parameters:
        rkVersion - the current version of the Stream file being created.
        Returns:
        the size of this object on disk.
      • GetNormal3

        public Vector3f GetNormal3​(int i)
        Get the normal at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
        Returns:
        normal.
      • GetNormal3

        public void GetNormal3​(int i,
                               Vector3f kResult)
        Get the normal at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
      • GetNormal3fX

        public float GetNormal3fX​(int i)
      • GetNormal3fY

        public float GetNormal3fY​(int i)
      • GetNormal3fZ

        public float GetNormal3fZ​(int i)
      • GetNormals

        public java.nio.FloatBuffer GetNormals()
      • GetTCoords

        public java.nio.FloatBuffer GetTCoords​(int iUnit)
      • GetColors

        public java.nio.FloatBuffer GetColors​(int iUnit)
      • GetPosition3

        public Vector3f GetPosition3​(int i)
        Get the position at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
        Returns:
        position.
      • GetPosition3

        public void GetPosition3​(int i,
                                 Vector3f kResult)
        Get the position at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
      • GetPosition3fX

        public float GetPosition3fX​(int i)
        Get the position at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
        Returns:
        position.
      • GetPosition3fY

        public float GetPosition3fY​(int i)
      • GetPosition3fZ

        public float GetPosition3fZ​(int i)
      • GetPositionArray

        public Vector3f[] GetPositionArray()
        Return an array of the positions in the VertexBuffer.
        Returns:
        an array of the positions in the VertexBuffer.
      • GetPositionList

        public java.util.Vector<Vector3f> GetPositionList()
        Return an array of the positions in the VertexBuffer.
        Returns:
        an array of the positions in the VertexBuffer.
      • GetPositions

        public java.nio.FloatBuffer GetPositions()
      • GetTCoord1

        public float GetTCoord1​(int iUnit,
                                int i)
        Get the texture coordinate (1D) at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        Returns:
        texture coordinate.
      • GetTCoord2

        public void GetTCoord2​(int iUnit,
                               int i,
                               Vector2f kResult)
        Get the texture coordinate (2D) at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
      • GetTCoord2fX

        public float GetTCoord2fX​(int iUnit,
                                  int i)
        Get the texture coordinate (2D) at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        Returns:
        texture coordinate.
      • GetTCoord2fY

        public float GetTCoord2fY​(int iUnit,
                                  int i)
      • GetTCoord3

        public Vector3f GetTCoord3​(int iUnit,
                                   int i)
        Get the texture coordinate (3D) at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
        Returns:
        texture coordinate.
      • GetTCoord3

        public void GetTCoord3​(int iUnit,
                               int i,
                               Vector3f kResult)
        Get the texture coordinate (3D) at the given index. Use these accessors for convenience. No range checking is performed, so you should be sure that the attribute exists and that the number of channels is correct.
        Parameters:
        i - vertex index.
      • GetVertex

        public float[] GetVertex​(int i)
        Get a copy of a vertex's data
        Parameters:
        i - vertex index
        Returns:
        new array with vertex's data.
      • GetVertexQuantity

        public final int GetVertexQuantity()
        The number of vertices in the buffer.
        Returns:
        number of vertices.
      • Link

        public void Link​(Stream rkStream,
                         Stream.Link pkLink)
        Description copied from class: Spatial
        Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.
        Specified by:
        Link in interface StreamInterface
        Overrides:
        Link in class Spatial
        Parameters:
        rkStream - the Stream where the child objects are stored.
        pkLink - the Link class from which the child object IDs are read.
      • Load

        public void Load​(Stream rkStream,
                         Stream.Link pkLink)
        Description copied from class: Spatial
        Loads this object from the input parameter rkStream, using the input Stream.Link to store the IDs of children objects of this object for linking after all objects are loaded from the Stream.
        Specified by:
        Load in interface StreamInterface
        Overrides:
        Load in class Spatial
        Parameters:
        rkStream - the Stream from which this object is being read.
        pkLink - the Link class for storing the IDs of this object's children objects.
      • IsLoadSub

        public boolean IsLoadSub()
      • LoadSub

        public void LoadSub​(boolean bOn)
      • LoadSub

        public void LoadSub​(int iMin,
                            int iMax)
      • Register

        public boolean Register​(Stream rkStream)
        Registers this object with the input Stream parameter. All objects streamed to disk are registered with the Stream so that a unique list of objects is maintained.
        Specified by:
        Register in interface StreamInterface
        Overrides:
        Register in class Spatial
        Parameters:
        rkStream - the Stream where the child objects are stored.
        Returns:
        true if this object is registered, false if the object has already been registered.
      • Save

        public void Save​(Stream rkStream)
        Write this object and all it's children to the Stream.
        Specified by:
        Save in interface StreamInterface
        Overrides:
        Save in class Spatial
        Parameters:
        rkStream - the Stream where the child objects are stored.
      • SaveStrings

        public StringTree SaveStrings​(java.lang.String acTitle)
        Write this object into a StringTree for the scene-graph visualization.
        Specified by:
        SaveStrings in interface StreamInterface
        Overrides:
        SaveStrings in class Spatial
        Parameters:
        acTitle - the header for this object in the StringTree.
        Returns:
        StringTree containing a String-based representation of this object and it's children.
      • SetChanged

        public void SetChanged​(boolean bChanged)
      • SetColor1

        public void SetColor1​(int iUnit,
                              int i,
                              float fR)
      • SetColor3

        public void SetColor3​(int iUnit,
                              int i,
                              ColorRGB kC)
        Set the color at the given index.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        kC - new color.
      • SetColor3

        public void SetColor3​(int iUnit,
                              int i,
                              float fR,
                              float fG,
                              float fB)
        Set the color at the given index.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        kC - new color.
      • SetColor4

        public void SetColor4​(int iUnit,
                              int i,
                              ColorRGBA kC)
        Set the color at the given index.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        kC - new color.
      • SetColor4

        public void SetColor4​(int iUnit,
                              int i,
                              float fR,
                              float fG,
                              float fB,
                              float fA)
        Set the color at the given index.
        Parameters:
        iUnit - color unit (1-4).
        i - vertex index.
        kC - new color.
      • SetNormal3

        public void SetNormal3​(int i,
                               float fX,
                               float fY,
                               float fZ)
        Set the normal at the given index.
        Parameters:
        i - vertex index.
        kN - new normal.
      • SetNormal3

        public void SetNormal3​(int i,
                               Vector3f kN)
        Set the normal at the given index.
        Parameters:
        i - vertex index.
        kN - new normal.
      • SetPosition3

        public void SetPosition3​(int i,
                                 float fX,
                                 float fY,
                                 float fZ)
        Set the position at the given index.
        Parameters:
        i - vertex index.
        kP - new position.
      • SetPosition3

        public void SetPosition3​(int i,
                                 Vector3f kP)
        Set the position at the given index.
        Parameters:
        i - vertex index.
        kP - new position.
      • SetPosition

        public void SetPosition​(float[] positions)
      • SetTCoord1

        public void SetTCoord1​(int iUnit,
                               int i,
                               float fValue)
        Set the texture coordinate (1D) at the given index.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        fValue - new texture coordinate.
      • SetTCoord2

        public void SetTCoord2​(int iUnit,
                               int i,
                               float fX,
                               float fY)
        Set the texture coordiante (2D) at the given index.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        kTC - new texture coordinate.
      • SetTCoord2

        public void SetTCoord2​(int iUnit,
                               int i,
                               Vector2f kTC)
        Set the texture coordiante (2D) at the given index.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        kTC - new texture coordinate.
      • SetTCoord3

        public void SetTCoord3​(int iUnit,
                               int i,
                               float fX,
                               float fY,
                               float fZ)
        Set the texture coordinate (3D) at the given index.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        kTC - new texture coordinate.
      • SetTCoord3

        public void SetTCoord3​(int iUnit,
                               int i,
                               Vector3f kTC)
        Set the texture coordiante (3D) at the given index.
        Parameters:
        iUnit - texture coordinate unit (1-4).
        i - vertex index.
        kTC - new texture coordinate.
      • SetVertex

        public void SetVertex​(int i,
                              float[] afVertexData)
        Set a vertex's data
        Parameters:
        i - vertex index
        afVertexData - Data to copy
      • SetVertexQuantity

        public final void SetVertexQuantity​(int iVQuantity)
        An application might want to vary the "active quantity" of vertices. Use this function to do so. It does not change the data storage, only the m_iVertexQuantity member. The caller is responsible for saving the full quantity of vertices and resetting this when finished with the vertex buffer. The caller also should not pass in a quantity that is larger than the original full quantity.
        Parameters:
        iVQuantity - set vertex quantity.
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream out)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readObject

        private void readObject​(java.io.ObjectInputStream in)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException