Skip to content
Carl Hewett edited this page Jun 3, 2016 · 10 revisions

An object geometry holds all the necessary data to create an object (indices, vertex positions, UV coords, normals). This data is stored on the GPU using GPUBuffers (either GPUBuffer_uint, GPUBuffer_vec2 or GPUBuffer_vec3. You can create an object geometry from Lua, which lets you do some awesome stuff.

Class ObjectGeometry

ObjectGeometry(string name, {int} indices, {Vec3} positions, {Vec2} UVCoords, {Vec3} normals,

Create a new geometry. Consider using an ObjectGeometryGroup for holding your geometries. Then, you can use the ResourceManager to track them. However, simply using an object geometry by its own is fine.

string getName()

Get the object geometry's name.

GPUBuffer_uint& getIndexBuffer()

Get the index buffer. The number of elements in this buffer is equal to the amount of vertices in the mesh. Each value in this buffer holds an index to the other buffers (positions, UVs, normals). If you want to avoid this, just set the index buffer from 0 to n number of vertices, and fill in your other buffers as you wish (in the order of your vertices). The index buffer has 0-based indices!

GPUBuffer_vec3& getPositionBuffer()

Get the position buffer. This buffer holds all the vertex positions of the meshes, in pixels!. Keep in mind that they are indexed, check out getIndexBuffer().

GPUBuffer_vec2& getUVBuffer()

Get the UV buffer. This buffer holds the UV-coords (texcoords) of the mesh. Keep in mind it is indexed, check out getIndexBuffer().

GPUBuffer_vec3& getNormalBuffer()

Get the normal buffer. This buffer holds the normals; the vectors used for lighting effects. Keep in mind it is indexed, check out getIndexBuffer().