CSEngine
Loading...
Searching...
No Matches
WebDemoScene.cpp
1#include "WebDemoScene.h"
2#include "../Util/Render/SEnvironmentMgr.h"
3#include "../Component/LightComponent.h"
4#include "../Component/CameraComponent.h"
5#include "../Component/CustomComponent.h"
6
7#include "../Util/Loader/DAE/DAELoader.h"
8#include "../Util/Render/SFrameBuffer.h"
9#include "../../Assets/cube.h"
10
11using namespace CSE;
12
13void WebDemoScene::Init() {
14// SPrefab* stormtrooper = SResource::Create<SPrefab>("stormtrooper.prefab");
15 SPrefab* stormtrooper = SResource::Create<SPrefab>("model.prefab");
16
17 auto root = new SGameObject("root");
18 auto ab = stormtrooper->Clone(vec3{ 0, -0.3f, 0 }, root);
19// ab->GetTransform()->m_scale = vec3{ 0.2f, 0.2f, 0.2f };
20 ab->GetTransform()->m_scale = vec3{ 0.08f, 0.08f, 0.08f };
21 ab->GetTransform()->m_rotation = Quaternion::AngleAxis(vec3{1, 0, 0}, Pi/2.f);
22 ab->CreateComponent<CustomComponent>();
23 ab->GetComponent<CustomComponent>()->SetClassName("Stormtrooper.script");
24
25 auto camera = new SGameObject("camera");
26 const auto& camera_comp = camera->CreateComponent<CameraComponent>();
27 camera->GetTransform()->m_position = vec3{0, 0, 1.2f };
28 camera_comp->SetBackgroundSkybox();
29 camera_comp->SetBackgroundType(CameraBase::SKYBOX);
30
31 SGameObject* direction = new SGameObject();
32 direction->SetParent(root);
33 direction->SetName("directional");
34 direction->GetTransform()->m_position = vec3{ 0.f, 0.5f, 0.f };
35 direction->CreateComponent<LightComponent>();
36 direction->GetComponent<LightComponent>()->SetSunrising(true);
37 direction->GetComponent<LightComponent>()->SetLightType(LightComponent::DIRECTIONAL);
38 direction->GetComponent<LightComponent>()->SetDirection(vec4{ 0.0f, 1.0f, 1, 0 });
39 direction->GetComponent<LightComponent>()->SetShadow(true);
40
41// auto a_cam = camera->GetComponent<CameraComponent>();
42// a_cam->SetTarget(ab);
43}
44
45void WebDemoScene::Tick(float elapsedTime) {
46
47}
48
49void WebDemoScene::Destroy() {
50
51}