Package WildMagic.LibGraphics.SceneGraph
Class VertexBuffer
- java.lang.Object
-
- WildMagic.LibGraphics.ObjectSystem.GraphicsObject
-
- WildMagic.LibGraphics.SceneGraph.Spatial
-
- WildMagic.LibGraphics.Rendering.Bindable
-
- WildMagic.LibGraphics.SceneGraph.VertexBuffer
-
- All Implemented Interfaces:
java.io.Serializable
,NameIdInterface
,StreamInterface
public class VertexBuffer extends Bindable implements StreamInterface, java.io.Serializable
- Author:
- Alexandra
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class WildMagic.LibGraphics.Rendering.Bindable
Bindable.Info
-
Nested classes/interfaces inherited from class WildMagic.LibGraphics.SceneGraph.Spatial
Spatial.CullingMode
-
-
Field Summary
Fields Modifier and Type Field Description private float[][]
m_afColors
private float[]
m_afNormals
private float[]
m_afPositions
The vertex buffer data.private float[][]
m_afTextures
private java.nio.FloatBuffer[]
m_akColorBuffer
private java.nio.FloatBuffer
m_akNormalBuffer
private java.nio.FloatBuffer
m_akPositionBuffer
private java.nio.FloatBuffer[]
m_akTexCoordBuffer
private boolean[]
m_bColorsChanged
protected boolean
m_bLoadSub
Set to true to load a sub-vertex buffer to the GPUprivate boolean
m_bNormalsChanged
private boolean
m_bPositionsChanged
private boolean[]
m_bTexturesChanged
private int
m_iVertexQuantity
The number of vertices in the buffer.private Attributes
m_kAttributes
The format of a single vertex in the buffer.private static long
serialVersionUID
java.util.Vector<Vector2f>
SubVBuffer
-
Fields inherited from class WildMagic.LibGraphics.Rendering.Bindable
m_bShared, m_kInfoArray
-
Fields inherited from class WildMagic.LibGraphics.SceneGraph.Spatial
Culling, Local, m_iStartEffect, m_kEffects, m_kGlobalStates, m_kLights, m_pkParent, World, WorldBound, WorldBoundIsCurrent, WorldIsCurrent
-
-
Constructor Summary
Constructors Constructor Description VertexBuffer()
Default constructor.VertexBuffer(java.util.Vector<Vector3f> akPositions)
Create a VertexBuffer from a list of vertices.VertexBuffer(Vector3f[] akPositions)
Create a VertexBuffer from a list of vertices.VertexBuffer(Attributes rkAttributes, int iVertexQuantity)
Create a VertexBuffer with the given attributes and number of vertices.VertexBuffer(VertexBuffer pkVBuffer)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
copyBuffers(VertexBuffer pkVBuffer)
void
dispose()
Delete memory.Attributes
GetAttributes()
The format of a single vertex in the buffer.float
GetColor1(int iUnit, int i)
Set the color at the given index.ColorRGB
GetColor3(int iUnit, int i)
Get the color at the given index.void
GetColor3(int iUnit, int i, ColorRGB kResult)
Get the color at the given index.ColorRGBA
GetColor4(int iUnit, int i)
Get the color at the given index.void
GetColor4(int iUnit, int i, ColorRGBA kResult)
Get the color at the given index.java.nio.FloatBuffer
GetColors(int iUnit)
int
GetDiskUsed(StreamVersion rkVersion)
Returns the size of this object and it's children on disk for the current StreamVersion parameter.Vector3f
GetNormal3(int i)
Get the normal at the given index.void
GetNormal3(int i, Vector3f kResult)
Get the normal at the given index.float
GetNormal3fX(int i)
float
GetNormal3fY(int i)
float
GetNormal3fZ(int i)
java.nio.FloatBuffer
GetNormals()
Vector3f
GetPosition3(int i)
Get the position at the given index.void
GetPosition3(int i, Vector3f kResult)
Get the position at the given index.float
GetPosition3fX(int i)
Get the position at the given index.float
GetPosition3fY(int i)
float
GetPosition3fZ(int i)
Vector3f[]
GetPositionArray()
Return an array of the positions in the VertexBuffer.java.util.Vector<Vector3f>
GetPositionList()
Return an array of the positions in the VertexBuffer.java.nio.FloatBuffer
GetPositions()
float
GetTCoord1(int iUnit, int i)
Get the texture coordinate (1D) at the given index.void
GetTCoord2(int iUnit, int i, Vector2f kResult)
Get the texture coordinate (2D) at the given index.float
GetTCoord2fX(int iUnit, int i)
Get the texture coordinate (2D) at the given index.float
GetTCoord2fY(int iUnit, int i)
Vector3f
GetTCoord3(int iUnit, int i)
Get the texture coordinate (3D) at the given index.void
GetTCoord3(int iUnit, int i, Vector3f kResult)
Get the texture coordinate (3D) at the given index.java.nio.FloatBuffer
GetTCoords(int iUnit)
float[]
GetVertex(int i)
Get a copy of a vertex's dataint
GetVertexQuantity()
The number of vertices in the buffer.private void
initBuffers()
boolean
IsColorsChanged(int iUnit)
boolean
IsLoadSub()
boolean
IsNormalsChanged()
boolean
IsPositionsChanged()
boolean
IsTexturesChanged(int iUnit)
void
Link(Stream rkStream, Stream.Link pkLink)
Copies this objects children objects from the input Stream's HashTable, based on the LinkID of the child stored in the pkLink parameter.void
Load(Stream rkStream, Stream.Link pkLink)
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.void
LoadSub(boolean bOn)
void
LoadSub(int iMin, int iMax)
private void
readObject(java.io.ObjectInputStream in)
boolean
Register(Stream rkStream)
Registers this object with the input Stream parameter.void
Save(Stream rkStream)
Write this object and all it's children to the Stream.StringTree
SaveStrings(java.lang.String acTitle)
Write this object into a StringTree for the scene-graph visualization.void
SetChanged(boolean bChanged)
void
SetColor1(int iUnit, int i, float fR)
void
SetColor3(int iUnit, int i, float fR, float fG, float fB)
Set the color at the given index.void
SetColor3(int iUnit, int i, ColorRGB kC)
Set the color at the given index.void
SetColor4(int iUnit, int i, float fR, float fG, float fB, float fA)
Set the color at the given index.void
SetColor4(int iUnit, int i, ColorRGBA kC)
Set the color at the given index.void
SetNormal3(int i, float fX, float fY, float fZ)
Set the normal at the given index.void
SetNormal3(int i, Vector3f kN)
Set the normal at the given index.void
SetPosition(float[] positions)
void
SetPosition3(int i, float fX, float fY, float fZ)
Set the position at the given index.void
SetPosition3(int i, Vector3f kP)
Set the position at the given index.void
SetTCoord1(int iUnit, int i, float fValue)
Set the texture coordinate (1D) at the given index.void
SetTCoord2(int iUnit, int i, float fX, float fY)
Set the texture coordiante (2D) at the given index.void
SetTCoord2(int iUnit, int i, Vector2f kTC)
Set the texture coordiante (2D) at the given index.void
SetTCoord3(int iUnit, int i, float fX, float fY, float fZ)
Set the texture coordinate (3D) at the given index.void
SetTCoord3(int iUnit, int i, Vector3f kTC)
Set the texture coordiante (3D) at the given index.void
SetVertex(int i, float[] afVertexData)
Set a vertex's datavoid
SetVertexQuantity(int iVQuantity)
An application might want to vary the "active quantity" of vertices.private void
writeObject(java.io.ObjectOutputStream out)
-
Methods inherited from class WildMagic.LibGraphics.Rendering.Bindable
GetIdentifier, GetIdentifier, GetInfoQuantity, GetShared, GetVisibleSet, IsReload, IsReload, OnLoad, OnRelease, Release, Reload, Reload, Remove, SetShared, UpdateState, UpdateWorldBound
-
Methods inherited from class WildMagic.LibGraphics.SceneGraph.Spatial
AttachEffect, AttachGlobalState, AttachLight, DetachAllEffects, DetachAllGlobalStates, DetachAllLights, DetachEffect, DetachGlobalState, DetachLight, GetAllObjectsByName, GetEffect, GetEffectQuantity, GetGlobalState, GetGlobalState, GetGlobalStateQuantity, GetLight, GetLightQuantity, GetObjectByID, GetObjectByName, GetParent, GetStartEffect, OnGetVisibleSet, PopState, PropagateBoundToRoot, PropagateStateFromRoot, PushState, SetParent, SetStartEffect, UpdateBS, UpdateGS, UpdateGS, UpdateRS, UpdateRS, UpdateWorldData
-
Methods inherited from class WildMagic.LibGraphics.ObjectSystem.GraphicsObject
GetID, GetName, GetNextID, GetObjectByIDBase, GetObjectByNameBase, SetName
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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)
-
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 interfaceStreamInterface
- Overrides:
GetDiskUsed
in classSpatial
- 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 interfaceStreamInterface
- Overrides:
Link
in classSpatial
- 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 interfaceStreamInterface
- Overrides:
Load
in classSpatial
- 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 interfaceStreamInterface
- Overrides:
Register
in classSpatial
- 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 interfaceStreamInterface
- Overrides:
Save
in classSpatial
- 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 interfaceStreamInterface
- Overrides:
SaveStrings
in classSpatial
- 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 indexafVertexData
- 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
-
-