SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLRectangle.h
Go to the documentation of this file.
1 /**
2  * \file SLRectangle.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 SLRECTANGLE_H
11 #define SLRECTANGLE_H
12 
13 #include <SLMesh.h>
14 
15 //-----------------------------------------------------------------------------
16 /**
17  * @brief SLRectangle creates a rectangular mesh with a certain resolution
18  * @details The SLRectangle node draws a rectangle with a minimal and a maximal
19  * corner in the x-y-plane. The normal is [0,0,1].
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 SLRectangle : public SLMesh
29 {
30 public:
31  //! ctor for rectangle w. min & max corner
32  SLRectangle(SLAssetManager* assetMgr,
33  const SLVec2f& min,
34  const SLVec2f& max,
35  SLuint resX,
36  SLuint resY,
37  const SLstring& name = "rectangle mesh",
38  SLMaterial* mat = nullptr);
39 
40  //! ctor for rectangle w. min & max corner & tex. coord.
41  SLRectangle(SLAssetManager* assetMgr,
42  const SLVec2f& min,
43  const SLVec2f& max,
44  const SLVec2f& uv_min,
45  const SLVec2f& uv_max,
46  SLuint resX,
47  SLuint resY,
48  const SLstring& name = "rectangle mesh",
49  SLMaterial* mat = nullptr);
50 
51  void buildMesh(SLMaterial* mat);
52 
53 protected:
54  SLVec3f _min; //!< min corner
55  SLVec3f _max; //!< max corner
56  SLVec2f _uv_min; //!< min corner tex.coord.
57  SLVec2f _uv_max; //!< max corner tex.coord.
58  SLuint _resX; //!< resolution in x direction
59  SLuint _resY; //!< resolution in y direction
60 };
61 //-----------------------------------------------------------------------------
62 #endif
unsigned int SLuint
Definition: SL.h:171
string SLstring
Definition: SL.h:158
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
SLRectangle creates a rectangular mesh with a certain resolution.
Definition: SLRectangle.h:29
SLuint _resX
resolution in x direction
Definition: SLRectangle.h:58
SLVec3f _max
max corner
Definition: SLRectangle.h:55
SLVec3f _min
min corner
Definition: SLRectangle.h:54
void buildMesh(SLMaterial *mat)
SLRectangle::buildMesh fills in the underlying arrays from the SLMesh object.
Definition: SLRectangle.cpp:65
SLuint _resY
resolution in y direction
Definition: SLRectangle.h:59
SLRectangle(SLAssetManager *assetMgr, const SLVec2f &min, const SLVec2f &max, SLuint resX, SLuint resY, const SLstring &name="rectangle mesh", SLMaterial *mat=nullptr)
ctor for rectangle w. min & max corner
Definition: SLRectangle.cpp:16
SLVec2f _uv_min
min corner tex.coord.
Definition: SLRectangle.h:56
SLVec2f _uv_max
max corner tex.coord.
Definition: SLRectangle.h:57