Skip to content

Commit

Permalink
Replaced faulty 3DS Model in MeshLoad Scene
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm4 committed Jul 9, 2024
1 parent 7ad8ea2 commit f158af4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
30 changes: 22 additions & 8 deletions apps/app_demo/source/scenes/AppDemoSceneMeshLoad.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/**
* \file AppDemoSceneMeshLoad.cpp
* \brief Implementation for an SLScene inherited class
* \details For more info about App framework and the scene assembly see:
* \details For more info about App framework and the scene assembly see:
* https://cpvrlab.github.io/SLProject4/app-framework.html
* \date May 2024
* \authors Marcus Hudritsch, Marino von Wattenwyl
* \copyright http://opensource.org/licenses/GPL-3.0
* \remarks Please use clangformat to format the code. See more code style on
* https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
*/
*/

#include <AppDemoSceneMeshLoad.h>
#include <AppCommon.h>
#include <SLAssetLoader.h>
#include <SLLightSpot.h>
#include <SLRectangle.h>
#include <SLSkybox.h>

//-----------------------------------------------------------------------------
AppDemoSceneMeshLoad::AppDemoSceneMeshLoad() : SLScene("Mesh 3D Loader Test")
Expand All @@ -29,9 +30,15 @@ AppDemoSceneMeshLoad::AppDemoSceneMeshLoad() : SLScene("Mesh 3D Loader Test")
//! All assets the should be loaded in parallel must be registered in here.
void AppDemoSceneMeshLoad::registerAssetsToLoad(SLAssetLoader& al)
{
al.addNodeToLoad(_mesh3DS,
al.addSkyboxToLoad(_skybox,
al.modelPath() +
"GLTF/glTF-Sample-Models/hdris/approaching_storm_4k.hdr",
SLVec2i(512, 512),
"HDR Skybox");

al.addNodeToLoad(_meshGLTF,
AppCommon::modelPath +
"3DS/Halloween/jackolan.3ds");
"GLTF/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf");
al.addNodeToLoad(_meshFBX,
AppCommon::modelPath +
"FBX/Duck/duck.fbx");
Expand Down Expand Up @@ -77,10 +84,16 @@ void AppDemoSceneMeshLoad::assemble(SLAssetManager* am, SLSceneView* sv)
charAnim->playbackRate(0.8f);

// Scale to so that the AstroBoy is about 2 (meters) high.
if (_mesh3DS)
if (_meshGLTF)
{
_mesh3DS->scale(0.1f);
_mesh3DS->translate(-22.0f, 1.9f, 3.5f, TS_object);
_meshGLTF->scale(0.8f);
_meshGLTF->translate(-2.4f, 0, -1.5f, TS_object);

// Update all materials and set their skybox to _skybox
_meshGLTF->updateMeshMat([=](SLMaterial* m)
{ m->skybox(_skybox); },
true);
_skybox->exposure(4.0f);
}
if (_meshDAE)
{
Expand Down Expand Up @@ -116,14 +129,15 @@ void AppDemoSceneMeshLoad::assemble(SLAssetManager* am, SLSceneView* sv)

SLNode* scene = new SLNode("Scene");
this->root3D(scene);
this->skybox(_skybox);
scene->addChild(light1);
scene->addChild(light2);
scene->addChild(rb);
scene->addChild(rl);
scene->addChild(rr);
scene->addChild(rf);
scene->addChild(rt);
if (_mesh3DS) scene->addChild(_mesh3DS);
if (_meshGLTF) scene->addChild(_meshGLTF);
if (_meshFBX) scene->addChild(_meshFBX);
if (_meshDAE) scene->addChild(_meshDAE);
scene->addChild(cam1);
Expand Down
35 changes: 18 additions & 17 deletions apps/app_demo/source/scenes/AppDemoSceneMeshLoad.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* \file AppDemoSceneMeshLoad.h
* \brief Class declaration for an SLScene inherited class
* \details For more info about App framework and the scene assembly see:
* \details For more info about App framework and the scene assembly see:
* https://cpvrlab.github.io/SLProject4/app-framework.html
* \date May 2024
* \authors Marcus Hudritsch, Marino von Wattenwyl
* \copyright http://opensource.org/licenses/GPL-3.0
* \remarks Please use clangformat to format the code. See more code style on
* https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
*/
*/

#ifndef APPDEMOSCENEMESHLOAD_H
#define APPDEMOSCENEMESHLOAD_H
Expand All @@ -21,30 +21,31 @@ class AppDemoSceneMeshLoad : public SLScene
{
public:
AppDemoSceneMeshLoad();

//! All scene specific assets have to be registered for async loading in here.
/*! @remark All scene sspecific assets have to be loaded async by overriding
SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and
assembling means that it happens in a parallel thread and that in there are
/*! @remark All scene sspecific assets have to be loaded async by overriding
SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and
assembling means that it happens in a parallel thread and that in there are
no OpenGL calls allowed. OpenGL calls are only allowed in the main thread.*/
void registerAssetsToLoad(SLAssetLoader& al) override;

//! After parallel loading of the assets the scene gets assembled in here.
/*! @remark All scene-specific assets have to be loaded async by overriding
SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and
assembling means that it happens in a parallel thread and that in there
are no OpenGL calls allowed. OpenGL calls are only allowed in the main
thread. It is important that all object instantiations within
SLScene::assemble do NOT call any OpenGL functions (gl*) because they happen
in a parallel thread. All objects that get rendered have to do their
initialization when they are used the first time during rendering in the
/*! @remark All scene-specific assets have to be loaded async by overriding
SLScene::registerAssetsToLoad and SLScene::assemble. Async loading and
assembling means that it happens in a parallel thread and that in there
are no OpenGL calls allowed. OpenGL calls are only allowed in the main
thread. It is important that all object instantiations within
SLScene::assemble do NOT call any OpenGL functions (gl*) because they happen
in a parallel thread. All objects that get rendered have to do their
initialization when they are used the first time during rendering in the
main thread.*/
void assemble(SLAssetManager* am, SLSceneView* sv) override;

private:
SLNode* _mesh3DS;
SLNode* _meshFBX;
SLNode* _meshDAE;
SLNode* _meshGLTF;
SLNode* _meshFBX;
SLNode* _meshDAE;
SLSkybox* _skybox;
};
//-----------------------------------------------------------------------------

Expand Down

0 comments on commit f158af4

Please sign in to comment.