From b8078bf349fd5982734b3e5ca6ebc1d36d60a499 Mon Sep 17 00:00:00 2001 From: ducphamhong Date: Fri, 27 May 2022 09:40:03 +0700 Subject: [PATCH] #149 Add interface primitive object --- Projects/Editor/Source/Editor/CEditor.cpp | 4 +- .../Editor/Components/CEngineEditor.cpp | 7 ++ .../SpaceController/CSceneController.cpp | 10 +++ .../Components/Source/Primitive/CCube.cpp | 63 ++++++++++++++++++ .../Components/Source/Primitive/CCube.h | 48 ++++++++++++++ .../Source/Primitive/CPrimitive.cpp | 48 ++++++++++++++ .../Components/Source/Primitive/CPrimitive.h | 52 +++++++++++++++ .../Source/Primitive/CPrimitiveData.cpp | 30 +++++++++ .../Source/Primitive/CPrimitiveRenderer.cpp | 64 +++++++++++++++++++ .../Source/Primitive/CPrimitiveRenderer.h | 50 +++++++++++++++ .../Source/Primitive/CPrimiviteData.h | 43 +++++++++++++ .../Components/Source/Primitive/CSphere.cpp | 63 ++++++++++++++++++ .../Components/Source/Primitive/CSphere.h | 48 ++++++++++++++ .../Components/Source/SkySun/CSkySun.cpp | 2 +- .../Engine/Source/Entity/CEntityHandler.cpp | 6 ++ 15 files changed, 535 insertions(+), 3 deletions(-) create mode 100644 Projects/Skylicht/Components/Source/Primitive/CCube.cpp create mode 100644 Projects/Skylicht/Components/Source/Primitive/CCube.h create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimitive.cpp create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimitive.h create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimitiveData.cpp create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.cpp create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.h create mode 100644 Projects/Skylicht/Components/Source/Primitive/CPrimiviteData.h create mode 100644 Projects/Skylicht/Components/Source/Primitive/CSphere.cpp create mode 100644 Projects/Skylicht/Components/Source/Primitive/CSphere.h diff --git a/Projects/Editor/Source/Editor/CEditor.cpp b/Projects/Editor/Source/Editor/CEditor.cpp index 1a93cf6e3..bbcd658ec 100644 --- a/Projects/Editor/Source/Editor/CEditor.cpp +++ b/Projects/Editor/Source/Editor/CEditor.cpp @@ -369,14 +369,14 @@ namespace Skylicht submenu = object->getMenu(); submenu->OnCommand = BIND_LISTENER(&CEditor::OnCommandGameObject, this); - /* submenu->addItem(L"Cube"); submenu->addItem(L"Sphere"); + /* submenu->addItem(L"Capsule"); submenu->addItem(L"Cylinder"); submenu->addItem(L"Plane"); - submenu->addSeparator(); */ + submenu->addSeparator(); submenu->addItem(L"Skydome"); submenu->addItem(L"Skybox"); diff --git a/Projects/Editor/Source/Editor/Components/CEngineEditor.cpp b/Projects/Editor/Source/Editor/Components/CEngineEditor.cpp index 3dde19f1d..c67b53847 100644 --- a/Projects/Editor/Source/Editor/Components/CEngineEditor.cpp +++ b/Projects/Editor/Source/Editor/Components/CEngineEditor.cpp @@ -29,10 +29,14 @@ This file is part of the "Skylicht Engine". #include "RenderMesh/CRenderMesh.h" #include "IndirectLighting/CIndirectLighting.h" +#include "LightProbes/CLightProbes.h" #include "SkyDome/CSkyDome.h" #include "SkyBox/CSkyBox.h" +#include "Primitive/CCube.h" +#include "Primitive/CSphere.h" + #define USE_COMPONENT(component) CComponentSystem *component##_used = addComponent(new component()) namespace Skylicht @@ -63,6 +67,9 @@ namespace Skylicht USE_COMPONENT(CSkyDome); USE_COMPONENT(CSkyBox); USE_COMPONENT(CIndirectLighting); + USE_COMPONENT(CLightProbes); + USE_COMPONENT(CCube); + USE_COMPONENT(CSphere); // END DECLARE COMPONENT int clean = cleanUp(); diff --git a/Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp b/Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp index 23e1989ba..0a2b4cb6a 100644 --- a/Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp +++ b/Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp @@ -504,6 +504,16 @@ namespace Skylicht std::vector components = { "CLightProbes" }; createComponentObject("Light Probes", components, NULL); } + else if (objectType == L"Cube") + { + std::vector components = { "CCube" }; + createComponentObject("Cube", components, NULL); + } + else if (objectType == L"Sphere") + { + std::vector components = { "CSphere" }; + createComponentObject("Sphere", components, NULL); + } } diff --git a/Projects/Skylicht/Components/Source/Primitive/CCube.cpp b/Projects/Skylicht/Components/Source/Primitive/CCube.cpp new file mode 100644 index 000000000..59d129148 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CCube.cpp @@ -0,0 +1,63 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" +#include "CCube.h" + +namespace Skylicht +{ + ACTIVATOR_REGISTER(CCube); + + CATEGORY_COMPONENT(CCube, "Cube", "Renderer/Primitive"); + + CCube::CCube() + { + m_type = CPrimiviteData::Cube; + } + + CCube::~CCube() + { + + } + + void CCube::initComponent() + { + CPrimitive::initComponent(); + } + + void CCube::updateComponent() + { + + } + + CObjectSerializable* CCube::createSerializable() + { + return CPrimitive::createSerializable(); + } + + void CCube::loadSerializable(CObjectSerializable* object) + { + CPrimitive::loadSerializable(object); + } +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CCube.h b/Projects/Skylicht/Components/Source/Primitive/CCube.h new file mode 100644 index 000000000..c6b77db0b --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CCube.h @@ -0,0 +1,48 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "CPrimitive.h" + +namespace Skylicht +{ + class CCube : public CPrimitive + { + public: + CCube(); + + virtual ~CCube(); + + virtual void initComponent(); + + virtual void updateComponent(); + + virtual CObjectSerializable* createSerializable(); + + virtual void loadSerializable(CObjectSerializable* object); + + DECLARE_GETTYPENAME(CCube) + }; +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimitive.cpp b/Projects/Skylicht/Components/Source/Primitive/CPrimitive.cpp new file mode 100644 index 000000000..915861971 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimitive.cpp @@ -0,0 +1,48 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" +#include "CPrimitive.h" +#include "CPrimitiveRenderer.h" +#include "GameObject/CGameObject.h" +#include "Entity/CEntityManager.h" + +namespace Skylicht +{ + CPrimitive::CPrimitive() : + m_type(CPrimiviteData::Unknown) + { + + } + + CPrimitive::~CPrimitive() + { + + } + + void CPrimitive::initComponent() + { + m_gameObject->getEntityManager()->addRenderSystem(); + } +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimitive.h b/Projects/Skylicht/Components/Source/Primitive/CPrimitive.h new file mode 100644 index 000000000..c65a1de9e --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimitive.h @@ -0,0 +1,52 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "CPrimiviteData.h" +#include "Components/CComponentSystem.h" + +namespace Skylicht +{ + class CPrimitive : public CComponentSystem + { + protected: + CPrimiviteData::EPrimitive m_type; + + protected: + + CPrimitive(); + + virtual ~CPrimitive(); + + virtual void initComponent(); + + inline CPrimiviteData::EPrimitive getType() + { + return m_type; + } + + DECLARE_GETTYPENAME(CPrimitive) + }; +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimitiveData.cpp b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveData.cpp new file mode 100644 index 000000000..1f6400520 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveData.cpp @@ -0,0 +1,30 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" + +namespace Skylicht +{ + +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.cpp b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.cpp new file mode 100644 index 000000000..3f6fac6a0 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.cpp @@ -0,0 +1,64 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" +#include "CPrimitiveRenderer.h" + +namespace Skylicht +{ + CPrimitiveRenderer::CPrimitiveRenderer() + { + + } + + CPrimitiveRenderer::~CPrimitiveRenderer() + { + + } + + void CPrimitiveRenderer::beginQuery(CEntityManager* entityManager) + { + + } + + void CPrimitiveRenderer::onQuery(CEntityManager* entityManager, CEntity* entity) + { + + } + + void CPrimitiveRenderer::init(CEntityManager* entityManager) + { + + } + + void CPrimitiveRenderer::update(CEntityManager* entityManager) + { + + } + + void CPrimitiveRenderer::render(CEntityManager* entityManager) + { + + } +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.h b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.h new file mode 100644 index 000000000..3ad1b5352 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimitiveRenderer.h @@ -0,0 +1,50 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "Entity/IRenderSystem.h" + +namespace Skylicht +{ + class CPrimitiveRenderer : public IRenderSystem + { + protected: + + public: + CPrimitiveRenderer(); + + virtual ~CPrimitiveRenderer(); + + virtual void beginQuery(CEntityManager* entityManager); + + virtual void onQuery(CEntityManager* entityManager, CEntity* entity); + + virtual void init(CEntityManager* entityManager); + + virtual void update(CEntityManager* entityManager); + + virtual void render(CEntityManager* entityManager); + }; +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CPrimiviteData.h b/Projects/Skylicht/Components/Source/Primitive/CPrimiviteData.h new file mode 100644 index 000000000..6e5115b58 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CPrimiviteData.h @@ -0,0 +1,43 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "Entity/IEntityData.h" + +namespace Skylicht +{ + class CPrimiviteData : public IEntityData + { + public: + enum EPrimitive + { + Unknown, + Cube, + Sphere + }; + + + }; +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CSphere.cpp b/Projects/Skylicht/Components/Source/Primitive/CSphere.cpp new file mode 100644 index 000000000..481f944a0 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CSphere.cpp @@ -0,0 +1,63 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#include "pch.h" +#include "CSphere.h" + +namespace Skylicht +{ + ACTIVATOR_REGISTER(CSphere); + + CATEGORY_COMPONENT(CSphere, "Sphere", "Renderer/Primitive"); + + CSphere::CSphere() + { + m_type = CPrimiviteData::Sphere; + } + + CSphere::~CSphere() + { + + } + + void CSphere::initComponent() + { + CPrimitive::initComponent(); + } + + void CSphere::updateComponent() + { + + } + + CObjectSerializable* CSphere::createSerializable() + { + return CPrimitive::createSerializable(); + } + + void CSphere::loadSerializable(CObjectSerializable* object) + { + CPrimitive::loadSerializable(object); + } +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/Primitive/CSphere.h b/Projects/Skylicht/Components/Source/Primitive/CSphere.h new file mode 100644 index 000000000..3149818b8 --- /dev/null +++ b/Projects/Skylicht/Components/Source/Primitive/CSphere.h @@ -0,0 +1,48 @@ +/* +!@ +MIT License + +Copyright (c) 2022 Skylicht Technology CO., LTD + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files +(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This file is part of the "Skylicht Engine". +https://github.com/skylicht-lab/skylicht-engine +!# +*/ + +#pragma once + +#include "CPrimitive.h" + +namespace Skylicht +{ + class CSphere : public CPrimitive + { + public: + CSphere(); + + virtual ~CSphere(); + + virtual void initComponent(); + + virtual void updateComponent(); + + virtual CObjectSerializable* createSerializable(); + + virtual void loadSerializable(CObjectSerializable* object); + + DECLARE_GETTYPENAME(CSphere) + }; +} \ No newline at end of file diff --git a/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp b/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp index 9a262e724..cf4383490 100644 --- a/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp +++ b/Projects/Skylicht/Components/Source/SkySun/CSkySun.cpp @@ -98,7 +98,7 @@ namespace Skylicht else { // use orientation - core::vector3df front = m_gameObject->getTransformEuler()->getFront(); + const core::vector3df& front = m_gameObject->getTransformEuler()->getFront(); m_uniformDirection->FloatValue[0] = front.X; m_uniformDirection->FloatValue[1] = front.Y; m_uniformDirection->FloatValue[2] = front.Z; diff --git a/Projects/Skylicht/Engine/Source/Entity/CEntityHandler.cpp b/Projects/Skylicht/Engine/Source/Entity/CEntityHandler.cpp index 3405a2a2e..2822fef70 100644 --- a/Projects/Skylicht/Engine/Source/Entity/CEntityHandler.cpp +++ b/Projects/Skylicht/Engine/Source/Entity/CEntityHandler.cpp @@ -130,7 +130,13 @@ namespace Skylicht void CEntityHandler::removeAllEntities() { + if (m_gameObject == NULL) + return; + CEntityManager* entityManager = m_gameObject->getEntityManager(); + if (entityManager) + return; + for (int i = (int)m_entities.size() - 1; i >= 0; i--) entityManager->removeEntity(m_entities[i]); m_entities.clear();