com.jme3.scene
クラス VertexBuffer

java.lang.Object
  上位を拡張 com.jme3.renderer.GLObject
      上位を拡張 com.jme3.scene.VertexBuffer
すべての実装されたインタフェース:
Savable, java.lang.Cloneable

public class VertexBuffer
extends GLObject
implements Savable, java.lang.Cloneable

A VertexBuffer contains a particular type of geometry data used by Meshes. Every VertexBuffer set on a Mesh is sent as an attribute to the vertex shader to be processed.

Several terms are used throughout the javadoc for this class, explanation:


入れ子のクラスの概要
static class VertexBuffer.Format
          Specifies format of the data stored in the buffer.
static class VertexBuffer.Type
          Type of buffer.
static class VertexBuffer.Usage
          The usage of the VertexBuffer, specifies how often the buffer is used.
 
コンストラクタの概要
VertexBuffer()
          Serialization only.
VertexBuffer(VertexBuffer.Type type)
          Creates an empty, uninitialized buffer.
 
メソッドの概要
 void clearUpdateNeeded()
          Internal use only.
 VertexBuffer clone()
          Creates a deep clone of the VertexBuffer.
 VertexBuffer clone(VertexBuffer.Type overrideType)
          Creates a deep clone of this VertexBuffer but overrides the VertexBuffer.Type.
 void compact(int numElements)
          Reduces the capacity of the buffer to the given amount of elements, any elements at the end of the buffer are truncated as necessary.
 void convertToHalf()
          Converts single floating-point data to half floating-point data.
 void copyElement(int inIndex, VertexBuffer outVb, int outIndex)
          Copies a single element of data from this VertexBuffer to the given output VertexBuffer.
static java.nio.Buffer createBuffer(VertexBuffer.Format format, int components, int numElements)
          Creates a Buffer that satisfies the given type and size requirements of the parameters.
 GLObject createDestructableClone()
          Creates a shallow clone of this GL Object.
 void deleteObject(Renderer r)
          Deletes the GL object from the GPU when it is no longer used.
 VertexBuffer.Type getBufferType()
           
 java.nio.Buffer getData()
           
 java.lang.Object getElementComponent(int elementIndex, int componentIndex)
          Get the component inside an element.
 VertexBuffer.Format getFormat()
           
 int getNumComponents()
           
 int getNumElements()
           
 int getOffset()
           
 int getStride()
           
 VertexBuffer.Usage getUsage()
           
 boolean hasDataSizeChanged()
          Returns true if the data size of the VertexBuffer has changed.
 boolean isNormalized()
           
 void read(JmeImporter im)
           
 void resetObject()
          Called when the GL context is restarted to reset all IDs.
 void setElementComponent(int elementIndex, int componentIndex, java.lang.Object val)
          Modify a component inside an element.
 void setNormalized(boolean normalized)
           
 void setOffset(int offset)
           
 void setStride(int stride)
          Set the stride (in bytes) for the data.
 void setupData(VertexBuffer.Usage usage, int components, VertexBuffer.Format format, java.nio.Buffer data)
          Called to initialize the data in the VertexBuffer.
 void setUsage(VertexBuffer.Usage usage)
           
 java.lang.String toString()
           
 void updateData(java.nio.Buffer data)
          Called to update the data in the buffer with new data.
 void write(JmeExporter ex)
           
 
クラス com.jme3.renderer.GLObject から継承されたメソッド
getId, isUpdateNeeded, setId, setUpdateNeeded
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

コンストラクタの詳細

VertexBuffer

public VertexBuffer(VertexBuffer.Type type)
Creates an empty, uninitialized buffer. Must call setupData() to initialize.


VertexBuffer

public VertexBuffer()
Serialization only. Do not use.

メソッドの詳細

getOffset

public int getOffset()
戻り値:
The offset after which the data is sent to the GPU.
関連項目:
setOffset(int)

setOffset

public void setOffset(int offset)
パラメータ:
offset - Specify the offset (in bytes) from the start of the buffer after which the data is sent to the GPU.

getStride

public int getStride()
戻り値:
The stride (in bytes) for the data.
関連項目:
setStride(int)

setStride

public void setStride(int stride)
Set the stride (in bytes) for the data.

If the data is packed in the buffer, then stride is 0, if there's other data that is between the current component and the next component in the buffer, then this specifies the size in bytes of that additional data.

パラメータ:
stride - the stride (in bytes) for the data

getData

public java.nio.Buffer getData()
戻り値:
A native buffer, in the specified format.

getUsage

public VertexBuffer.Usage getUsage()
戻り値:
The usage of this buffer. See VertexBuffer.Usage for more information.

setUsage

public void setUsage(VertexBuffer.Usage usage)
パラメータ:
usage - The usage of this buffer. See VertexBuffer.Usage for more information.

setNormalized

public void setNormalized(boolean normalized)
パラメータ:
normalized - Set to true if integer components should be converted from their maximal range into the range 0.0 - 1.0 when converted to a floating-point value for the shader. E.g. if the VertexBuffer.Format is VertexBuffer.Format.UnsignedInt, then the components will be converted to the range 0.0 - 1.0 by dividing every integer by 2^32.

isNormalized

public boolean isNormalized()
戻り値:
True if integer components should be converted to the range 0-1.
関連項目:
setNormalized(boolean)

getBufferType

public VertexBuffer.Type getBufferType()
戻り値:
The type of information that this buffer has.

getFormat

public VertexBuffer.Format getFormat()
戻り値:
The format, or data type of the data.

getNumComponents

public int getNumComponents()
戻り値:
The number of components of the given format per element.

getNumElements

public int getNumElements()
戻り値:
The total number of data elements in the data buffer.

setupData

public void setupData(VertexBuffer.Usage usage,
                      int components,
                      VertexBuffer.Format format,
                      java.nio.Buffer data)
Called to initialize the data in the VertexBuffer. Must only be called once.

パラメータ:
usage - The usage for the data, or how often will the data be updated per frame. See the VertexBuffer.Usage enum.
components - The number of components per element.
format - The format, or data-type of a single component.
data - A native buffer, the format of which matches the VertexBuffer.Format argument.

updateData

public void updateData(java.nio.Buffer data)
Called to update the data in the buffer with new data. Can only be called after setupData(com.jme3.scene.VertexBuffer.Usage, int, com.jme3.scene.VertexBuffer.Format, java.nio.Buffer) has been called. Note that it is fine to call this method on the data already set, e.g. vb.updateData(vb.getData()), this will just set the proper update flag indicating the data should be sent to the GPU again. It is allowed to specify a buffer with different capacity than the originally set buffer.

パラメータ:
data - The data buffer to set

hasDataSizeChanged

public boolean hasDataSizeChanged()
Returns true if the data size of the VertexBuffer has changed. Internal use only.

戻り値:
true if the data size has changed

clearUpdateNeeded

public void clearUpdateNeeded()
クラス GLObject の記述:
Internal use only. Indicates that the state changes were applied.

オーバーライド:
クラス GLObject 内の clearUpdateNeeded

convertToHalf

public void convertToHalf()
Converts single floating-point data to half floating-point data.


compact

public void compact(int numElements)
Reduces the capacity of the buffer to the given amount of elements, any elements at the end of the buffer are truncated as necessary.

パラメータ:
numElements - The number of elements to reduce to.

setElementComponent

public void setElementComponent(int elementIndex,
                                int componentIndex,
                                java.lang.Object val)
Modify a component inside an element. The val parameter must be in the buffer's format: VertexBuffer.Format.

パラメータ:
elementIndex - The element index to modify
componentIndex - The component index to modify
val - The value to set, either byte, short, int or float depending on the VertexBuffer.Format.

getElementComponent

public java.lang.Object getElementComponent(int elementIndex,
                                            int componentIndex)
Get the component inside an element.

パラメータ:
elementIndex - The element index
componentIndex - The component index
戻り値:
The component, as one of the primitive types, byte, short, int or float.

copyElement

public void copyElement(int inIndex,
                        VertexBuffer outVb,
                        int outIndex)
Copies a single element of data from this VertexBuffer to the given output VertexBuffer.

パラメータ:
inIndex - The input element index
outVb - The buffer to copy to
outIndex - The output element index
例外:
java.lang.IllegalArgumentException - If the formats of the buffers do not match.

createBuffer

public static java.nio.Buffer createBuffer(VertexBuffer.Format format,
                                           int components,
                                           int numElements)
Creates a Buffer that satisfies the given type and size requirements of the parameters. The buffer will be of the type specified by format and would be able to contain the given number of elements with the given number of components in each element.


clone

public VertexBuffer clone()
Creates a deep clone of the VertexBuffer.

戻り値:
Deep clone of this buffer

clone

public VertexBuffer clone(VertexBuffer.Type overrideType)
Creates a deep clone of this VertexBuffer but overrides the VertexBuffer.Type.

パラメータ:
overrideType - The type of the cloned VertexBuffer
戻り値:
A deep clone of the buffer

toString

public java.lang.String toString()
オーバーライド:
クラス GLObject 内の toString

resetObject

public void resetObject()
クラス GLObject の記述:
Called when the GL context is restarted to reset all IDs. Prevents "white textures" on display restart.

定義:
クラス GLObject 内の resetObject

deleteObject

public void deleteObject(Renderer r)
クラス GLObject の記述:
Deletes the GL object from the GPU when it is no longer used. Called automatically by the GL object manager.

定義:
クラス GLObject 内の deleteObject
パラメータ:
r - The renderer to be used to delete the object

createDestructableClone

public GLObject createDestructableClone()
クラス GLObject の記述:
Creates a shallow clone of this GL Object. The deleteObject method should be functional for this object.

定義:
クラス GLObject 内の createDestructableClone

write

public void write(JmeExporter ex)
           throws java.io.IOException
定義:
インタフェース Savable 内の write
例外:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
定義:
インタフェース Savable 内の read
例外:
java.io.IOException