Skip to content

Commit

Permalink
#149 Add interface primitive object
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed May 27, 2022
1 parent 2d4a7d8 commit b8078bf
Show file tree
Hide file tree
Showing 15 changed files with 535 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Projects/Editor/Source/Editor/CEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
7 changes: 7 additions & 0 deletions Projects/Editor/Source/Editor/Components/CEngineEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions Projects/Editor/Source/Editor/SpaceController/CSceneController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,16 @@ namespace Skylicht
std::vector<std::string> components = { "CLightProbes" };
createComponentObject("Light Probes", components, NULL);
}
else if (objectType == L"Cube")
{
std::vector<std::string> components = { "CCube" };
createComponentObject("Cube", components, NULL);
}
else if (objectType == L"Sphere")
{
std::vector<std::string> components = { "CSphere" };
createComponentObject("Sphere", components, NULL);
}

}

Expand Down
63 changes: 63 additions & 0 deletions Projects/Skylicht/Components/Source/Primitive/CCube.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
}
48 changes: 48 additions & 0 deletions Projects/Skylicht/Components/Source/Primitive/CCube.h
Original file line number Diff line number Diff line change
@@ -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)
};
}
48 changes: 48 additions & 0 deletions Projects/Skylicht/Components/Source/Primitive/CPrimitive.cpp
Original file line number Diff line number Diff line change
@@ -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<CPrimitiveRenderer>();
}
}
52 changes: 52 additions & 0 deletions Projects/Skylicht/Components/Source/Primitive/CPrimitive.h
Original file line number Diff line number Diff line change
@@ -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)
};
}
30 changes: 30 additions & 0 deletions Projects/Skylicht/Components/Source/Primitive/CPrimitiveData.cpp
Original file line number Diff line number Diff line change
@@ -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
{

}
Original file line number Diff line number Diff line change
@@ -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)
{

}
}
Loading

0 comments on commit b8078bf

Please sign in to comment.