SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLBox.h
Go to the documentation of this file.
1 /**
2  * \file SLBox.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 SLBOX_H
11 #define SLBOX_H
12 
13 #include <SLEnums.h>
14 #include <SLMesh.h>
15 
16 //-----------------------------------------------------------------------------
17 /**
18  * @brief Axis aligned box mesh
19  * @details The SLBox node draws an axis aligned box from a minimal corner to
20  * a maximal corner. If the minimal and maximal corner are swapped the normals
21  * will point inside.
22  * @remarks It is important that during instantiation NO OpenGL functions (gl*)
23  * get called because this constructor will be most probably called in a parallel
24  * thread from within an SLScene::registerAssetsToLoad or SLScene::assemble
25  * function. All objects that get rendered have to do their OpenGL initialization
26  * when they are used the first time during rendering in the main thread.
27  * For this SLMesh it means that the objects for OpenGL drawing (_vao, _vaoP,
28  * _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.
29  */
30 class SLBox : public SLMesh
31 {
32 public:
33  SLBox(SLAssetManager* assetMgr,
34  SLfloat minx = 0,
35  SLfloat miny = 0,
36  SLfloat minz = 0,
37  SLfloat maxx = 1,
38  SLfloat maxy = 1,
39  SLfloat maxz = 1,
40  const SLstring& name = "box mesh",
41  SLMaterial* mat = nullptr);
42  SLBox(SLAssetManager* assetMgr,
43  const SLVec3f& min,
44  const SLVec3f& max,
45  const SLstring& name = "box mesh",
46  SLMaterial* mat = nullptr);
47 
48  void buildMesh(SLMaterial* mat);
49 
50 private:
51  SLVec3f _min; //!< minimal corner
52  SLVec3f _max; //!< maximum corner
53 };
54 //-----------------------------------------------------------------------------
55 #endif
float SLfloat
Definition: SL.h:173
string SLstring
Definition: SL.h:158
Toplevel holder of the assets meshes, materials, textures and shaders.
Axis aligned box mesh.
Definition: SLBox.h:31
SLBox(SLAssetManager *assetMgr, SLfloat minx=0, SLfloat miny=0, SLfloat minz=0, SLfloat maxx=1, SLfloat maxy=1, SLfloat maxz=1, const SLstring &name="box mesh", SLMaterial *mat=nullptr)
SLBox::SLBox ctor with min. & max. coords. of the axis aligned box.
Definition: SLBox.cpp:15
SLVec3f _max
maximum corner
Definition: SLBox.h:52
void buildMesh(SLMaterial *mat)
SLBox::buildMesh fills in the underlying arrays from the SLMesh object.
Definition: SLBox.cpp:47
SLVec3f _min
minimal corner
Definition: SLBox.h:51
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