SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLTriangle.h
Go to the documentation of this file.
1 /**
2  * \file SLTriangle.h
3  * \date July 2014
4  * \remarks Please use clangformat to format the code. See more code style on
5  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
6  * \authors Philipp Jueni, Marcus Hudritsch
7  * \copyright http://opensource.org/licenses/GPL-3.0
8 */
9 
10 #ifndef SLTRIANGLE_H
11 #define SLTRIANGLE_H
12 
13 #include <SLMesh.h>
14 
15 //-----------------------------------------------------------------------------
16 /**
17  * @brief A triangle class as the most simplest mesh
18  * @remarks It is important that during instantiation NO OpenGL functions (gl*)
19  * get called because this constructor will be most probably called in a parallel
20  * thread from within an SLScene::registerAssetsToLoad or SLScene::assemble
21  * function. All objects that get rendered have to do their OpenGL initialization
22  * when they are used the first time during rendering in the main thread.
23  * For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP,
24  * _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.
25  */
26 class SLTriangle : public SLMesh
27 {
28 public:
29  SLTriangle(SLAssetManager* assetMgr,
30  SLMaterial* mat,
31  const SLstring& name = "triangle mesh",
32  const SLVec3f& p0 = SLVec3f(0, 0, 0),
33  const SLVec3f& p1 = SLVec3f(1, 0, 0),
34  const SLVec3f& p2 = SLVec3f(0, 1, 0),
35  const SLVec2f& t0 = SLVec2f(0, 0),
36  const SLVec2f& t1 = SLVec2f(1, 0),
37  const SLVec2f& t2 = SLVec2f(0, 1));
38 
39  void buildMesh(SLMaterial* mat);
40 
41 protected:
42  SLVec3f p[3]; //!< Array of 3 vertex positions
43  SLVec2f t[3]; //!< Array of 3 vertex tex. coords. (opt.)
44 };
45 //-----------------------------------------------------------------------------
46 #endif // SLTRIANGLE_H
string SLstring
Definition: SL.h:158
SLVec2< SLfloat > SLVec2f
Definition: SLVec2.h:141
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
Toplevel holder of the assets meshes, materials, textures and shaders.
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLMaterial * mat() const
Definition: SLMesh.h:177
const SLstring & name() const
Definition: SLObject.h:38
A triangle class as the most simplest mesh.
Definition: SLTriangle.h:27
void buildMesh(SLMaterial *mat)
Builds the mesh by copying the vertex info into the arrays of SLMescj.
Definition: SLTriangle.cpp:39
SLTriangle(SLAssetManager *assetMgr, SLMaterial *mat, const SLstring &name="triangle mesh", const SLVec3f &p0=SLVec3f(0, 0, 0), const SLVec3f &p1=SLVec3f(1, 0, 0), const SLVec3f &p2=SLVec3f(0, 1, 0), const SLVec2f &t0=SLVec2f(0, 0), const SLVec2f &t1=SLVec2f(1, 0), const SLVec2f &t2=SLVec2f(0, 1))
Definition: SLTriangle.cpp:13
SLVec2f t[3]
Array of 3 vertex tex. coords. (opt.)
Definition: SLTriangle.h:43
SLVec3f p[3]
Array of 3 vertex positions.
Definition: SLTriangle.h:42