SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGrid.h
Go to the documentation of this file.
1 /**
2  * \file SLGrid.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 SLGRID_H
11 #define SLGRID_H
12 
13 #include <SLMesh.h>
14 
15 //-----------------------------------------------------------------------------
16 /**
17  * @brief SLGrid creates a rectangular grid with lines with a certain resolution
18  * @details The SLGrid mesh draws a grid between a minimal and a maximal corner
19  * in the XZ-plane.
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 SLGrid : public SLMesh
29 {
30 public:
31  //! ctor for rectangle w. min & max corner
32  SLGrid(SLAssetManager* assetMgr,
33  SLVec3f minXZ,
34  SLVec3f maxXZ,
35  SLuint resX,
36  SLuint resZ,
37  SLstring name = "grid mesh",
38  SLMaterial* mat = nullptr);
39 
40  void buildMesh(SLMaterial* mat);
41 
42 protected:
43  SLVec3f _min; //!< min corner
44  SLVec3f _max; //!< max corner
45  SLuint _resX; //!< resolution in x direction
46  SLuint _resZ; //!< resolution in z direction
47 };
48 //-----------------------------------------------------------------------------
49 #endif
unsigned int SLuint
Definition: SL.h:171
string SLstring
Definition: SL.h:158
Toplevel holder of the assets meshes, materials, textures and shaders.
SLGrid creates a rectangular grid with lines with a certain resolution.
Definition: SLGrid.h:29
void buildMesh(SLMaterial *mat)
SLGrid::buildMesh fills in the underlying arrays from the SLMesh object.
Definition: SLGrid.cpp:39
SLVec3f _max
max corner
Definition: SLGrid.h:44
SLGrid(SLAssetManager *assetMgr, SLVec3f minXZ, SLVec3f maxXZ, SLuint resX, SLuint resZ, SLstring name="grid mesh", SLMaterial *mat=nullptr)
ctor for rectangle w. min & max corner
Definition: SLGrid.cpp:15
SLVec3f _min
min corner
Definition: SLGrid.h:43
SLuint _resZ
resolution in z direction
Definition: SLGrid.h:46
SLuint _resX
resolution in x direction
Definition: SLGrid.h:45
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