1#include "../Util/Render/SEnvironmentMgr.h"
2#include "FirstDemoScene.h"
3#include "../Component/LightComponent.h"
4#include "../Component/DrawableSkinnedMeshComponent.h"
5#include "../Component/CameraComponent.h"
6#include "../../Assets/teapot_smooth.h"
7#include "../Component/RenderComponent.h"
8#include "../Component/CustomComponent.h"
9#include "../Manager/GameObjectMgr.h"
11#include "../Util/Loader/DAE/DAELoader.h"
12#include "../Util/AssetsDef.h"
13#include "../Manager/SCloneFactory.h"
14#include "../Util/Loader/SCENE/SSceneLoader.h"
15#include "../Util/Render/SFrameBuffer.h"
16#include "../Util/Render/SMaterial.h"
20FirstDemoScene::FirstDemoScene() =
default;
23FirstDemoScene::~FirstDemoScene() =
default;
26void FirstDemoScene::Init() {
31 SPrefab* jack = SResource::Create<SPrefab>(
"jack.prefab");
32 SPrefab* plane = SResource::Create<SPrefab>(
"plane_circle.prefab");
33 SPrefab* roomPrefab = SResource::Create<SPrefab>(
"room.prefab");
63 root->GetTransform()->m_position =
vec3{0, -1, 0};
65 auto room = roomPrefab->Clone(
vec3{0, 0.2f, 0}, root);
66 room->GetTransform()->m_scale =
vec3{ 4.f, 4.f, 4.f };
67 room->GetTransform()->m_rotation.Rotate(Quaternion::AngleAxis(
vec3{0, 1, 0}, 3.14f / 2));
69 const auto& room_children = room->GetChildren();
70 for (
const auto& gameObject : room_children) {
72 if(component ==
nullptr)
continue;
73 component->SetMaterial(SResource::Create<SMaterial>(
"File:Material/Room.mat"));
84 cube =
new MeshSurface(CH02::teapot_smoothNumVerts, CH02::teapot_smoothVerts, CH02::teapot_smoothNormals);
85 cube->SetUndestroyable(
false);
89 buf_tex->SetName(
"framebuffer_test");
90 buf_tex->SetAbsoluteID(
"framebuffer_test");
95 root->AddChild(testing);
98 camera_gm->SetParent(testing);
99 camera_gm->GetTransform()->m_position =
vec3{ 0, -0.3f, 0 };
102 sc->SetClassName(
"testScript.script");
106 light_gm->SetParent(testing);
107 light_gm->GetTransform()->m_scale =
vec3{ 0.2f, 0.2f, 0.2f };
110 sc->SetClassName(
"testScriptFast.script");
114 a->SetParent(camera_gm);
118 ab->GetTransform()->m_scale =
vec3{ 0.0002f, 0.0002f, 0.0002f };
119 ab2->GetTransform()->m_scale =
vec3{ 0.0002f, 0.0002f, 0.0002f };
120 ab2->GetTransform()->m_rotation.Rotate(Quaternion::AngleAxis(
vec3{1, 0, 0}, 3.14f / 2));
121 ab2->GetTransform()->m_rotation.Rotate(Quaternion::AngleAxis(
vec3{0, 1, 0}, 1.f));
126 const auto& ab_children = ab->GetChildren();
127 for (
const auto& gameObject : ab_children) {
129 if (component ==
nullptr)
continue;
130 if(gameObject->GetName() ==
"Mesh-mesh") {
131 const auto& material = SResource::Create<SMaterial>(
"File:Material/Jack.mat");
132 material->SetOrderLayer(5500);
133 component->SetMaterial(material);
136 const auto& material = SResource::Create<SMaterial>(
"File:Material/Label.mat");
137 component->SetMaterial(material);
142 const auto& ab_children = ab2->GetChildren();
143 for (
const auto& gameObject : ab_children) {
145 if (component ==
nullptr)
continue;
146 if(gameObject->GetName() ==
"Mesh-mesh") {
147 const auto& material = SResource::Create<SMaterial>(
"File:Material/Jack.mat");
148 material->SetOrderLayer(5500);
149 component->SetMaterial(material);
152 const auto& material = SResource::Create<SMaterial>(
"File:Material/Label.mat");
153 component->SetMaterial(material);
159 c2->SetParent(testing);
165 c2->GetTransform()->m_position =
vec3{ -0.2f, -0.3f, -0.2f };
166 c2->GetTransform()->m_scale =
vec3{ 0.5f, 0.5f, 0.5f };
169 const auto& material = SResource::Create<SMaterial>(
"File:Material/SSS_PBR.mat");
170 material->SetOrderLayer(6000);
171 render->SetMaterial(material);
177 c3->GetTransform()->m_position.y = -0.7f;
180 c3->GetComponent<
CustomComponent>()->SetClassName(
"testScript2.script");
197 auto c4 = SCloneFactory::Clone(c3, c3);
200 c4->GetTransform()->m_position.y = -0.1f;
201 c4->GetTransform()->m_position.x = -2.f;
202 c4->GetTransform()->m_scale.Set(0.5, 0.5, 0.5);
207 direction->SetParent(root);
208 direction->SetName(
"directional");
209 direction->GetTransform()->m_position =
vec3{ 0.f, 1.f, 0.f };
214 direction->GetComponent<
LightComponent>()->SetLightType(LightComponent::DIRECTIONAL);
219 direction->GetComponent<
CustomComponent>()->SetClassName(
"directionalLight.script");
228 d->GetTransform()->m_position =
vec3{ -2.8f, -1.5f, 0 };
229 light_gm->AddChild(d);
232 d->GetComponent<
LightComponent>()->SetLightType(LightComponent::POINT);
250 a->GetTransform()->m_position =
vec3{ 0, 0.2f, 0.8f };
255 a_cam->SetTarget(camera_gm);
256 a_cam->SetBackgroundSkybox();
257 a_cam->SetBackgroundType(CameraBase::SKYBOX);
264 c4->GetComponent<
CameraComponent>()->SetBackgroundType(CameraBase::SKYBOX);
266 SResource::Create<SFrameBuffer>(
"File:Texture/TestFrameBuffer.framebuffer"));
269 SSceneLoader::SavePrefab(root, CSE::NativeAssetsPath() +
"Scene/test_scene.scene");
273void FirstDemoScene::Tick(
float elapsedTime) {
275 if (startTIme == 0) {
276 startTIme = elapsedTime;
287 if (elapsedTime - startTIme > 3000) {
288 startTIme = elapsedTime;
289 isInvisible = !isInvisible;
295void FirstDemoScene::Destroy() {
299void FirstDemoScene::switchingObject() {
301 c3->SetIsEnable(!isInvisible);
314 c2->GetTransform()->m_position.y = 0.5f;
STexture * GenerateTexturebuffer(BufferType type, int channel, int level=0)
void RasterizeFramebuffer()
void GenerateFramebuffer(BufferDimension dimension, int width, int height)
void Destroy() override
자동 삭제가 아닌 특정한 상황에서 삭제될 때 호출되는 함수