193 void SetTexCoords(
int texture_unit,
const std::vector<Point2> &tex_coords);
198 void SetIndices(
const std::vector<unsigned int> index_array);
229 void SetTexCoords(
int texture_unit,
float *tex_coords_array,
int num_tex_coords);
317 std::vector<float> verts_;
318 std::vector<float> norms_;
319 std::vector<float> colors_;
320 std::vector< std::vector<float> > tex_coords_;
321 std::vector<unsigned int> indices_;
322 std::vector<float> instance_xforms_;
325 GLuint vertex_buffer_;
326 GLuint vertex_array_;
327 GLuint element_buffer_;
A Bounding Volume Hierarchy (BVH) data structure that can be used to accelerate ray-object intersecti...
Represents a 4-component (R,G,B,A) color, stored internally in a float array to be compatable with Op...
A triangle mesh data structure that can be rendered with a ShaderProgram like DefaultShader.
void SetVertices(float *verts_array, int num_verts)
Sets the vertex array for the mesh directly. Vertices are stored as (x,y,z), (x,y,...
void SetColors(int triangle_id, Color c1, Color c2, Color c3)
Sets per-vertex colors for the three vertices of a triangle that has already been added to the mesh.
std::vector< unsigned int > read_triangle_indices_data(int triangle_id) const
Read only access to the indices that make up a particular triangle. Data are returned as a 3-element ...
void SetTexCoords(int triangle_id, int texture_unit, Point2 uv1, Point2 uv2, Point2 uv3)
Sets the texture coordinates for the three vertices of a triangle that has already been added to the ...
void CalcPerFaceNormals()
This (re)calculates the normals for the mesh and stores them with the mesh data structure.
void SetVertices(const std::vector< Point3 > &verts)
Sets the vertex array for the mesh directly.
void SetIndices(const std::vector< unsigned int > index_array)
Sets the indices into the vertex array to use to create the triangles. Each consecutive set of 3 indi...
int AddTriangle(Point3 v1, Point3 v2, Point3 v3)
Adds a triangle to the mesh datastructure and returns a triangle ID.
void UpdateTriangle(int triangle_id, Point3 v1, Point3 v2, Point3 v3)
Updates the vertex positions for a triangle that has already been added to the mesh.
Vector3 read_normal_data(int vertex_id) const
Read only access to per-vertex normal data. Data are returned as a Vector3. Indexed by vertex number....
void SetNormals(int triangle_id, Vector3 n1, Vector3 n2, Vector3 n3)
Sets the normals for the three vertices of a triangle that has already been added to the mesh.
Point2 read_tex_coords_data(int texture_unit, int vertex_id) const
Read only access to per-vertex texture coordinates data. Data are returned as a Point2....
Mesh()
Creates an empty mesh.
void SetNormals(float *norms_array, int num_norms)
Sets the normal array for the mesh directly. Normals are stored as (x,y,z), (x,y,z),...
void SetInstanceTransforms(const std::vector< Matrix4 > &xforms)
void Draw()
This sends the mesh vertices and attributes down the graphics pipe using glDrawArrays() for the non-i...
Mesh(const Mesh &other)
Copies all data and sets GPU dirty bit for the new mesh.
void SetIndices(unsigned int *index_array, int num_indices)
Sets the indices into the vertex array to use to create the triangles. Each consecutive set of 3 indi...
void LoadFromOBJ(const std::string &filename)
This reads a mesh stored in the common Wavefront Obj file format.
void BuildBVH()
This (re)calculates a Bounding Volume Hierarchy for the mesh, which can be used together with Ray::Fa...
BVH * bvh_ptr()
Returns a pointer to the underlying BVH data structure.
int num_triangles() const
The total number of triangles in the mesh.
int num_vertices() const
The total number of vertices in the mesh.
void SetColors(const std::vector< Color > &colors)
Sets the per-vertex colors array for the mesh directly.
void SetTexCoords(int texture_unit, const std::vector< Point2 > &tex_coords)
Sets a texture coordinates array for the mesh directly.
Color read_color_data(int vertex_id) const
Read only access to per-vertex color data. Data are returned as a Color. Indexed by vertex number....
void UpdateGPUMemory()
This copies the entire mesh data structure to a vertex array in GPU memory, which must happen before ...
void SetTexCoords(int texture_unit, float *tex_coords_array, int num_tex_coords)
Sets a texture coordinates array for the mesh directly. Tex coords are stored as (u,...
void CalcPerVertexNormals()
This (re)calculates the normals for the mesh and stores them with the mesh data structure.
void SetNormals(const std::vector< Vector3 > &norms)
Sets the normal array for the mesh directly.
Point3 read_vertex_data(int vertex_id) const
Read only access to the vertex position data. Data are returned as a Point3. Indexed by vertex number...
void SetColors(float *colors_array, int num_colors)
Sets the per-vertex colors array for the mesh directly. Colors are stored as (r,g,...
A 2D Point with floating point coordinates, used for storing 2D texture coordinates,...
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Namespace for the MinGfx Toolkit.