fluidvis
Public Member Functions | List of all members
sx::BufferedMesh Class Reference

#include <SXCore.h>

Inheritance diagram for sx::BufferedMesh:
sx::Mesh sx::EffectObject sx::SXResource

Public Member Functions

EX BufferedMesh (const string &id)
 
EX ~BufferedMesh ()
 
EX void unload ()
 
EX void load ()
 
EX bool isLoaded () const
 
EX void save (const string &filename)
 
EX void beginCapture (Shader &shader)
 
EX void endCapture (Shader &shader)
 
EX unsigned int countCreatedVertices () const
 
EX void setMaxVertexCount (unsigned int count)
 
EX unsigned int getMaxVertexCount () const
 
EX void setVertexCount (unsigned int count)
 
EX void render (Shader &shader)
 
EX void renderInstanced (Shader &shader, vector< BufferedMesh * > &instanceBuffers)
 
EX void addBuffer (const string &identifier, const string &outputIdentifier, vector< float > &buffer, unsigned int attributeSize)
 
EX void addBuffer (const string &identifier, vector< float > &buffer, unsigned int attributeSize)
 
EX void addBuffers (const string &path)
 
EX void addBuffers (const string &path, bool discardStandardBuffers)
 
EX void setOutputIdentifier (const string &identifier, const string &outputIdentifier)
 
EX VertexBuffergetBuffer (const string &identifier)
 
EX map< string, VertexBuffer * > & getBuffers ()
 
EX bool setUniforms (const vector< Uniform * > &uniforms, const vector< string > &bufferIDs, unsigned int location)
 
EX bool removeUniforms (unsigned int location)
 
EX void removeUniforms ()
 
EX void resetUniforms ()
 
EX void loadBuffersToUniforms ()
 
EX void loadBuffersToUniforms (unsigned int firstLocation, unsigned int lastLocation)
 
EX void loadBufferToUniforms (const string &bufferID)
 
EX void loadBufferToUniforms (const string &bufferID, unsigned int firstLocation, unsigned int lastLocation)
 
EX void loadUniformsToBuffers ()
 
EX void loadUniformsToBuffers (unsigned int firstLocation, unsigned int lastLocation)
 
EX void loadUniformsToBuffer (const string &bufferID)
 
EX void loadUniformsToBuffer (const string &bufferID, unsigned int firstLocation, unsigned int lastLocation)
 
EX vector< BonegetSkeleton () const
 
EX Matrix getSkeletonMatrix () const
 
EX void setSkeleton (const vector< Bone > &bones)
 
EX void setSkeletonMatrix (const Matrix &skeletonMatrix)
 
EX void execute (vector< string > &input)
 
- Public Member Functions inherited from sx::Mesh
EX ~Mesh ()
 
EX void setFaceSize (unsigned int faceSize)
 
EX unsigned int getFaceSize () const
 
EX unsigned int getVertexCount () const
 
- Public Member Functions inherited from sx::SXResource
virtual EX ~SXResource ()
 
EX const string & getID () const
 

Additional Inherited Members

- Protected Attributes inherited from sx::Mesh
unsigned int newFaceSize
 
unsigned int faceSize
 
unsigned int vertexCount
 
- Protected Attributes inherited from sx::SXResource
string id
 

Detailed Description

A Mesh stored in VRam

Constructor & Destructor Documentation

EX sx::BufferedMesh::BufferedMesh ( const string &  id)

constructor constructing a BufferedMesh with identifier id

EX sx::BufferedMesh::~BufferedMesh ( )

deconstructor

Member Function Documentation

EX void sx::BufferedMesh::addBuffer ( const string &  identifier,
const string &  outputIdentifier,
vector< float > &  buffer,
unsigned int  attributeSize 
)

Adds a new attribute buffer. The vertex attributes can be read by using variablename identifier in the shaders. For writing vertex attributes, the variablename outputIdentifier is used. Each attributeSize elements in buffer in sequence form a vertex attribute.

EX void sx::BufferedMesh::addBuffer ( const string &  identifier,
vector< float > &  buffer,
unsigned int  attributeSize 
)

Adds a new attribute buffer. The vertex attributes can be accessed by the variablename identifier in the shaders. Each attributeSize elements in buffer in sequence form a vertex attribute.

EX void sx::BufferedMesh::addBuffers ( const string &  path)

Adds a new file to be loaded. Files with extension ply in their filename are assumed to be in PLY (polygon file format of the stanford file format), and files with extension dae are assumed to be in Collada format.

*.ply (polygon file format) files: Properties x, y, z, w in element vertex are stored in a buffer with identifier "vertices". The attributeSize is equal to the number of properties called x, y, z, w declared in element vertex. Properties nx, ny, nz, nw in element vertex are stored in a buffer with identifier "normals". The attributeSize is equal to the number of properties called nx, ny, nz, nw declared in element vertex. Properties s, t, p, q in element vertex are stored in a buffer with identifier "texcoords". The attributeSize is equal to the number of properties called s, t, p, q declared in element vertex. Each other property with a name n in element vertex is stored in a buffer called n with attributeSize 1. *.dae (Collada) files: The mesh of the first geometry in library_geometries is loaded into the buffers. Each float_array referenced in polylist is loaded into a buffer having a name equal to property semantic. Buffers with semantic "VERTEX", "NORMAL" or "TEXCOORDS" are treated differently: The buffers with those semantics are called "vertices", "normals" and "texcoords". If element input has semantic "NORMAL", or property normalize="true", and references a float array with dimension 3 or 4, the vectors in the float array are normalized. Let t1 be the transformationmatrix specified in the node in visual_scene in library_visual_scenes, which has the name of the geometry. And let t2 be the identity matrix, or the bind_shape_matrix in the controller in library_controllers referenced by the node, if a skeleton is attached to the mesh. Then transformation t2 * t1 is applied to each three or fourdimensional buffer, which does not have semantic "NORMAL", and does not have property normal="true" in element input. The normalmatrix of t2 * t1 is applied to each three or fourdimensional buffer, which has semantic "NORMAL", or property normal="true" in element input. The vertexwheights of the bones are loaded as buffers with attributeSize 1, such that each buffer with vertexwheights has the name of the associated bone.

EX void sx::BufferedMesh::addBuffers ( const string &  path,
bool  discardStandardBuffers 
)

Adds a new file to be loaded without the standard buffers. A standard buffer is a buffer, which has one of the following identifyers: vertices, normals, texcoords, colors

EX void sx::BufferedMesh::beginCapture ( Shader shader)

Starts recording the vertices generated by the vertex, tessellation and geometry shader in shader into the mesh, until maxVertexCount vertices are created. The mesh dataset is deleted before anything is written to the mesh.

EX unsigned int sx::BufferedMesh::countCreatedVertices ( ) const

Returns the number of vertices created in between the call of beginCapture and endCapture. The number of created vertices doesn't equal the number of vertices written to the mesh, if more than maxVertexCount vertices are created.

EX void sx::BufferedMesh::endCapture ( Shader shader)

Stops recording vertices.

EX void sx::BufferedMesh::execute ( vector< string > &  input)
virtual

Strings called "readUniforms" and "writeUniforms" in input are considered in order: for each "readUniforms" in input method loadUniformsToBuffers() is called for each "writeUniforms" in input method loadBuffersToUniforms() is callsed

Implements sx::EffectObject.

EX VertexBuffer* sx::BufferedMesh::getBuffer ( const string &  identifier)

Returns the VBO having identifier identifier. If no such VBO exists, 0 is returned.

EX map<string,VertexBuffer *>& sx::BufferedMesh::getBuffers ( )

returns the set of all VBOs having their identifiers as keys

EX unsigned int sx::BufferedMesh::getMaxVertexCount ( ) const

getter

EX vector<Bone> sx::BufferedMesh::getSkeleton ( ) const

returns the root bones of the mesh's skeleton

EX Matrix sx::BufferedMesh::getSkeletonMatrix ( ) const

returns the transformation from the space containing the root bones into the model space

EX bool sx::BufferedMesh::isLoaded ( ) const
virtual

true iff the last invocation of load loaded all buffers

Implements sx::SXResource.

EX void sx::BufferedMesh::load ( )
virtual

Deconstructs the previously loaded attribute buffers, and loads the new attribute buffers. All files, which are used as a source of some buffers, must be parsed successfully, and each of the loaded buffers must have the same number of vertices. Otherwise the load method will leave this in an uninitialized state.

Implements sx::SXResource.

EX void sx::BufferedMesh::loadBuffersToUniforms ( )

Loads the content of the VertexBuffers to the Uniforms associated with the VertexBuffers by calling setUniforms. Let A be a uniform associated to vertex B in a certain buffer, then loadBuffersToUniforms assigns the value of B to A.

EX void sx::BufferedMesh::loadBuffersToUniforms ( unsigned int  firstLocation,
unsigned int  lastLocation 
)

Loads the content of the VertexBuffers to the Uniforms associated with the VertexBuffers by calling setUniforms with a location greater or equal to firstLocation, and smaller or equal to lastLocation. Let A be a uniform associated to vertex B in a certain buffer, then loadBuffersToUniforms assigns the value of B to A.

EX void sx::BufferedMesh::loadBufferToUniforms ( const string &  bufferID)

Loads the content of the VertexBuffer with id bufferID to the Uniforms associated with the VertexBuffer by calling setUniforms. Let A be a uniform associated to vertex B in VertexBuffer with id bufferID, then loadBuffersToUniforms assigns the value of B to A.

EX void sx::BufferedMesh::loadBufferToUniforms ( const string &  bufferID,
unsigned int  firstLocation,
unsigned int  lastLocation 
)

Loads the content of the VertexBuffer with id bufferID to the Uniforms associated with the VertexBuffer by calling setUniforms with a location greater or equal to firstLocation, and smaller or equal to lastLocation. Let A be a uniform associated to vertex B in VertexBuffer with id bufferID, then loadBuffersToUniforms assigns the value of B to A.

EX void sx::BufferedMesh::loadUniformsToBuffer ( const string &  bufferID)

Loads the content of the Uniforms associated with the VertexBuffer with id bufferID by calling setUniforms to the VertexBuffer. Let A be a uniform associated to vertex B in the VertexBuffer with id bufferID, then loadBuffersToUniforms the value of A to B.

EX void sx::BufferedMesh::loadUniformsToBuffer ( const string &  bufferID,
unsigned int  firstLocation,
unsigned int  lastLocation 
)

Loads the content of the Uniforms associated with the VertexBuffer with id bufferID by calling setUniforms to the VertexBuffer with a location greater or equal to firstLocation, and smaller or equal than lastLocation. Let A be a uniform associated to vertex B in the VertexBuffer with id bufferID, then loadBuffersToUniforms the value of A to B.

EX void sx::BufferedMesh::loadUniformsToBuffers ( )

Loads the content of the Uniforms associated with the VertexBuffers by calling setUniforms to the VertexBuffers. Let A be a uniform associated to vertex B in a certain buffer, then loadBuffersToUniforms the value of A to B.

EX void sx::BufferedMesh::loadUniformsToBuffers ( unsigned int  firstLocation,
unsigned int  lastLocation 
)

Loads the content of the Uniforms associated with the VertexBuffers by calling setUniforms to the VertexBuffers with a location greater or equal to firstLocation, and smaller or equal than lastLocation. Let A be a uniform associated to vertex B in a certain buffer, then loadBuffersToUniforms the value of A to B.

EX bool sx::BufferedMesh::removeUniforms ( unsigned int  location)

Undoes the association of the uniforms with the k. vertex created by setUniforms. The method has no effect and returns false iff this is not loaded, or no such assignment exists.

EX void sx::BufferedMesh::removeUniforms ( )

undoes all associations created by setUniforms

EX void sx::BufferedMesh::render ( Shader shader)
virtual

renders the attribute buffers, if the last invocation of load loaded all buffers successfully

Implements sx::Mesh.

EX void sx::BufferedMesh::renderInstanced ( Shader shader,
vector< BufferedMesh * > &  instanceBuffers 
)

Renders the attribute buffers, for each vertex in instanceBuffers. The command has only an effect, if the last invocation of load loaded all buffers successfully. Let n be the minimum vertex count out of all loaded meshes in instanceBuffers, then the buffers of this are rendered repeatedly for n times. For the k. time the buffers of this are rendered, the k. vertex of each buffer of each loaded mesh in instanceBuffers can be accessed in the Shaderprogram shader. Meshes in instanceBuffers, which haven't been loaded yet are not considered.

EX void sx::BufferedMesh::resetUniforms ( )

undoes all associations created by setUniforms, and releases the memory allocated for holding this associations

EX void sx::BufferedMesh::save ( const string &  filename)

Saves the mesh in a file. Only the first vertexCount vertices are saved. Files with extension .dae are assumed to be in Collada format. Files with extension .c are assumed to be in SX resource file format (see doc/SX reference cards/SX language/SX language.pdf ). An Exception is thrown, if the file can't be saved.

EX void sx::BufferedMesh::setMaxVertexCount ( unsigned int  count)

Sets the maximum number of vertices, which can be written to the mesh, of the next BufferedMesh loaded by load(). If buffers with vc vertices assigned to each buffer are added by calling addBuffer, and maxVertexCount is less than vc, vc is assigned to maxVertexCount.

EX void sx::BufferedMesh::setOutputIdentifier ( const string &  identifier,
const string &  outputIdentifier 
)

Specifies the outputIdentifier of the buffer identifier after the execution of load(). If no such buffer has been added since the last load / unload call, this method has no effect.

EX void sx::BufferedMesh::setSkeleton ( const vector< Bone > &  bones)

Setter. Has no effect, if the boneIDs are not unique.

EX void sx::BufferedMesh::setSkeletonMatrix ( const Matrix skeletonMatrix)

setter

EX bool sx::BufferedMesh::setUniforms ( const vector< Uniform * > &  uniforms,
const vector< string > &  bufferIDs,
unsigned int  location 
)

Assigns the Uniforms in uniforms to the location. vertex of each VertexBuffer with an ID in bufferIDs. Calling loadBuffersToUniforms() will update the uniforms with the values of the location. vertex, and calling loadUniformsToBuffers() will update the location. vertex with the values of the uniforms. Let A be the k. element of uniforms, and B be the VertexBuffer with the id equal to the k. element of bufferIDs, then the operations loadBuffersToUniforms() and loadUniformsToBuffers() will exchange data between A and B. If a set of uniforms was already assigned to location, the assignment is undone and replaced by the uniform set in the parameters. The method has no effect and returns false iff this is not loaded, or one of the uniforms is a Texture or a Volume, or location is greater or equal to maxVertexCount, or uniforms and bufferIDs have different sizes, or bufferIDs contains a string, which is not equal to any id of a VertexBuffer, or the dimension of a uniform assigned to a VertexBuffer is not equal to the attributeSize of the VertexBuffer. Furthermore the method is only guaranteed to work if the ids in bufferIDs are mutually different, and the objects in uniforms are mutually different.

EX void sx::BufferedMesh::setVertexCount ( unsigned int  count)

Includes the first count vertices of the buffers into the mesh (, which from then on are considered for rendering and being saved through method save). vertexCount will be the biggest number smaller or equal to count, smaller or equal to maxVertexCount and a number divisible by faceSize. The method has immediate effect. If this is not loaded, the method has no effect.

EX void sx::BufferedMesh::unload ( )

deconstructs the previously loaded attribute buffers, if something has been loaded, and leaves this unloaded


The documentation for this class was generated from the following file: