SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLPolygon.h
Go to the documentation of this file.
1 /**
2  * \file SLPolygon.h
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLPOLYGON_H
11 #define SLPOLYGON_H
12 
13 #include <SLMesh.h>
14 
15 //-----------------------------------------------------------------------------
16 /**
17  * @brief SLPolygon creates a convex polyon mesh
18  * @details The SLPolygon node draws a convex polygon with. The normale vector
19  * is calculated from the first 3 vertices.
20  * @remarks It is important that during instantiation NO OpenGL functions (gl*)
21  * get called because this constructor will be most probably called in a parallel
22  * thread from within an SLScene::registerAssetsToLoad or SLScene::assemble
23  * function. All objects that get rendered have to do their OpenGL initialization
24  * when they are used the first time during rendering in the main thread.
25  * For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP,
26  * _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.
27  */
28 class SLPolygon : public SLMesh
29 {
30 public:
31  //! ctor for generic convex polygon
32  SLPolygon(SLAssetManager* assetMgr,
33  const SLVVec3f& corner,
34  const SLstring& name = "polygon mesh",
35  SLMaterial* mat = nullptr);
36 
37  //! ctor for generic convex polygon with texCoords
38  SLPolygon(SLAssetManager* assetMgr,
39  const SLVVec3f& corners,
40  const SLVVec2f& texcoords,
41  const SLstring& name = "polygon mesh",
42  SLMaterial* mat = nullptr);
43 
44  //! ctor for centered rectangle in x-y-plane (N=-z)
45  SLPolygon(SLAssetManager* assetMgr,
46  SLfloat width,
47  SLfloat height,
48  const SLstring& name,
49  SLMaterial* mat = nullptr);
50 
51  void buildMesh(SLMaterial* mat);
52 
53 protected:
54  SLVVec3f _corners; //!< corners in ccw order
55  SLVVec2f _uv1; //!< texture coords for corners
56 };
57 //-----------------------------------------------------------------------------
58 #endif
float SLfloat
Definition: SL.h:173
string SLstring
Definition: SL.h:158
vector< SLVec2f > SLVVec2f
Definition: SLVec2.h:143
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
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
SLPolygon creates a convex polyon mesh.
Definition: SLPolygon.h:29
SLVVec2f _uv1
texture coords for corners
Definition: SLPolygon.h:55
void buildMesh(SLMaterial *mat)
SLPolygon::buildMesh fills in the underlying arrays from the SLMesh object.
Definition: SLPolygon.cpp:56
SLVVec3f _corners
corners in ccw order
Definition: SLPolygon.h:54
SLPolygon(SLAssetManager *assetMgr, const SLVVec3f &corner, const SLstring &name="polygon mesh", SLMaterial *mat=nullptr)
ctor for generic convex polygon
Definition: SLPolygon.cpp:14