# Vertex Geometry Modifier

#### <a class="anchor" id="bkmrk--182"></a>Overview

The [VertexGeometryModifier](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_vertex_geometry_modifier.html "In conjunction with a VertexAccessor, the VertexGeometryModifier helps to effectively modify VertexGe..."), in conjunction with a [VertexAccessor](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_vertex_accessor.html), helps to modify [VertexGeometry](http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_vertex_geometry.html "The VertexGeometry holds all vertex data of a mesh. VertexGeometry may be used also for multiple Vert...") objects by the means of the setters offered by the class interface. The interface offers also getters which are helpful to retrieve the values of the vertex elements from a given vertex buffer.

#### <a class="anchor" id="bkmrk--183"></a>Example

The example below shows how to change the position values for the vertices from a vertex buffer of a given mesh.

```
            VertexGeometry* vertexGeom;
            bool isMutable = m_mesh3->GetVertexBuffer()->GetVertexGeometry()->GetVertexArrayResourceHandle().m_isMutable;
            // Get the vertex geometry of the mesh
            if (isMutable) {
                vertexGeom = m_mesh3->GetVertexBuffer()->GetVertexGeometry();
            }
            else {
                DiagnosticPlatform::ConsoleOut("VertexGeometryData not mutable");
                break;
            }
             // The vertex accessor will be used by the vertex geometry modifier to access the vertices
            VertexAccessor accessor(*vertexGeom);

            // Create a vertex geometry modifier specifying as usage the type of vertex attribute
            // which will be changed
            VertexGeometryModifier modifier(*vertexGeom, <a class="code" href="http://dev.doc.cgistudio.at/APILINK/class_candera_1_1_vertex_geometry.html#af7691f69f328ccb7417ebdf28c39bb9ea952812830012c7d152a2513c8e14ed44" title="The position of a vertex in local space.">VertexGeometry::Position</a>, 0);
            Float vertexData[3];
            for(Int i = 0; i<8; i++) {
                if(s_inflate) {
                // Retrieve the position data of the vertex "i" in the vertexData array
                modifier.GetVertexElement(accessor.GetVertex(i), vertexData, 3);

                // Alter the data and set it back
                modifier.SetVertexElement(accessor.GetMutableVertex(i), vertexData[0]*1.3F, vertexData[1]*1.3F, vertexData[2]*1.3F);
                } 
                else {
                    // Set the position of the vertex with data get from an array (Float c_positionData[8][3])
                    modifier.SetVertexElement(accessor.GetMutableVertex(i), c_positionData[i], 3);
                }
            }

            // Update the vertex buffer on the mesh
            m_mesh3->GetVertexBuffer()->Update(0, m_mesh3->GetVertexBuffer()->GetVertexGeometry()->GetVertexCount());
```