SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoSceneLargeModel.cpp
Go to the documentation of this file.
1 /**
2  * \file AppDemoSceneLargeModel.cpp
3  * \brief Implementation for an SLScene inherited class
4  * \details For more info about App framework and the scene assembly see:
5  * https://cpvrlab.github.io/SLProject4/app-framework.html
6  * \date May 2024
7  * \authors Marcus Hudritsch, Marino von Wattenwyl
8  * \copyright http://opensource.org/licenses/GPL-3.0
9  * \remarks Please use clangformat to format the code. See more code style on
10  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
11 */
12 
13 #include <AppDemoSceneLargeModel.h>
14 #include <AppCommon.h>
15 #include <SLAssetLoader.h>
16 #include <SLLightSpot.h>
17 
18 //-----------------------------------------------------------------------------
20  : SLScene("Large Model Benchmark Scene")
21 {
22  info("Large Model with 7.2 mio. triangles.");
23 }
24 //-----------------------------------------------------------------------------
25 //! All assets the should be loaded in parallel must be registered in here.
27 {
30  "PLY/xyzrgb_dragon/xyzrgb_dragon.ply",
31  nullptr,
32  false,
33  true,
34  nullptr,
35  0.2f,
36  false,
39 }
40 //-----------------------------------------------------------------------------
41 //! After parallel loading of the assets the scene gets assembled in here.
43 {
44  SLCamera* cam1 = new SLCamera("Camera 1");
45  cam1->translation(0, 0, 220);
46  cam1->lookAt(0, 0, 0);
47  cam1->clipNear(1);
48  cam1->clipFar(10000);
49  cam1->focalDist(220);
50  cam1->background().colors(SLCol4f(0.7f, 0.7f, 0.7f),
51  SLCol4f(0.2f, 0.2f, 0.2f));
52  cam1->setInitialState();
54 
55  // Material for glass
56  SLMaterial* diffuseMat = new SLMaterial(am,
57  "diffuseMat",
60  _dragonModel->mesh()->mat(diffuseMat);
61 
62  SLLightSpot* light1 = new SLLightSpot(am,
63  this,
64  200,
65  200,
66  200,
67  1);
68  light1->powers(0.1f, 1.0f, 1.0f);
69  light1->attenuation(1, 0, 0);
70 
71  SLNode* scene = new SLNode("Scene");
72  root3D(scene);
73  scene->addChild(light1);
74  scene->addChild(_dragonModel);
75  scene->addChild(cam1);
76 
77  sv->camera(cam1);
78 }
79 //-----------------------------------------------------------------------------
The AppCommon class holds the top-level instances of the app-demo.
Class declaration for an SLScene inherited class.
@ SLProcess_Triangulate
Definition: SLImporter.h:36
@ SLProcess_JoinIdenticalVertices
Definition: SLImporter.h:34
SLVec4< SLfloat > SLCol4f
Definition: SLVec4.h:237
static SLDeviceRotation devRot
Mobile device rotation from IMU.
Definition: AppCommon.h:64
static SLDeviceLocation devLoc
Mobile device location from GPS.
Definition: AppCommon.h:65
static SLstring modelPath
Path to 3D models.
Definition: AppCommon.h:85
void assemble(SLAssetManager *am, SLSceneView *sv) override
After parallel loading of the assets the scene gets assembled in here.
void registerAssetsToLoad(SLAssetLoader &al) override
All scene specific assets have to be registered for async loading in here.
void addNodeToLoad(SLNode *&node, const SLstring &modelPath, SLSkybox *skybox=nullptr, SLbool deleteTexImgAfterBuild=false, SLbool loadMeshesOnly=true, SLMaterial *overrideMat=nullptr, float ambientFactor=0.5f, SLbool forceCookTorranceRM=false, SLuint flags=SLProcess_Triangulate|SLProcess_JoinIdenticalVertices|SLProcess_RemoveRedundantMaterials|SLProcess_FindDegenerates|SLProcess_FindInvalidData|SLProcess_SplitLargeMeshes)
Add mesh from file to load via assimp loader.
Toplevel holder of the assets meshes, materials, textures and shaders.
void colors(const SLCol4f &uniformColor)
Sets a uniform background color.
Active or visible camera node class.
Definition: SLCamera.h:54
void clipFar(const SLfloat cFar)
Definition: SLCamera.h:109
void clipNear(const SLfloat cNear)
Definition: SLCamera.h:108
void devRotLoc(SLDeviceRotation *devRot, SLDeviceLocation *devLoc)
Definition: SLCamera.h:120
void focalDist(const SLfloat f)
Definition: SLCamera.h:116
SLBackground & background()
Definition: SLCamera.h:165
void attenuation(const SLfloat kConstant, const SLfloat kLinear, const SLfloat kQuadratic)
Definition: SLLight.h:116
void powers(SLfloat ambiPow, SLfloat diffPow, SLfloat specPow, const SLCol4f &ambiDiffSpecCol=SLCol4f::WHITE)
Sets the ambient, diffuse and specular powers all with the same color.
Definition: SLLight.h:74
SLLightSpot class for a spot light source.
Definition: SLLightSpot.h:36
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
SLMaterial * mat() const
Definition: SLMesh.h:177
SLNode represents a node in a hierarchical scene graph.
Definition: SLNode.h:147
void addChild(SLNode *child)
Definition: SLNode.cpp:207
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
Definition: SLNode.cpp:828
SLMesh * mesh()
Definition: SLNode.h:304
void setInitialState()
Definition: SLNode.cpp:1084
void lookAt(SLfloat targetX, SLfloat targetY, SLfloat targetZ, SLfloat upX=0, SLfloat upY=1, SLfloat upZ=0, SLTransformSpace relativeTo=TS_world)
Definition: SLNode.h:652
The SLScene class represents the top level instance holding the scene structure.
Definition: SLScene.h:47
SLNode * root3D()
Definition: SLScene.h:99
friend class SLNode
Definition: SLScene.h:48
SLstring & info()
Definition: SLScene.h:102
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
void camera(SLCamera *camera)
Definition: SLSceneView.h:145
static SLVec4 WHITE
Definition: SLVec4.h:215