Skip to content

Commit

Permalink
#80 Add interface of Decals (not yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed May 16, 2022
1 parent 8cb3eec commit 412db87
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace Skylicht
ui->addButton(layout, L"Add Probe")->OnPress = [&](GUI::CBase* button)
{
CLightProbes* probes = (CLightProbes*)m_component;
CEntity* newProbe = probes->addLightProbe();
CEntity* newProbe = probes->addLightProbe(core::vector3df());

CSceneController* sceneController = CSceneController::getInstance();
sceneController->updateTreeNode(m_gameObject);
Expand Down
41 changes: 41 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecalData.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
!@
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 "CDecalData.h"

namespace Skylicht
{
IMPLEMENT_DATA_TYPE_INDEX(CDecalData);

CDecalData::CDecalData()
{

}

CDecalData::~CDecalData()
{

}
}
47 changes: 47 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecalData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
!@
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 CDecalData : public IEntityData
{
public:
core::vector3df Dimension;
core::vector3df Normal;
float TextureRotation;
float LifeTime;
float Distance;

DECLARE_DATA_TYPE_INDEX;

public:
CDecalData();

virtual ~CDecalData();
};
}
99 changes: 99 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecals.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
!@
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 "CDecals.h"
#include "CDecalsRenderer.h"
#include "CDecalData.h"
#include "GameObject/CGameObject.h"
#include "Entity/CEntityManager.h"
#include "Transform/CWorldTransformData.h"

namespace Skylicht
{
ACTIVATOR_REGISTER(CDecals);

CATEGORY_COMPONENT(CDecals, "Renderer", "Decals");

CDecals::CDecals()
{

}

CDecals::~CDecals()
{

}

void CDecals::initComponent()
{
m_gameObject->getEntityManager()->addRenderSystem<CDecalsRenderer>();
}

void CDecals::updateComponent()
{

}

CObjectSerializable* CDecals::createSerializable()
{
return CComponentSystem::createSerializable();
}

void CDecals::loadSerializable(CObjectSerializable* object)
{
return CComponentSystem::loadSerializable(object);
}

CEntity* CDecals::addDecal(
const core::vector3df& position,
const core::vector3df& dimension,
const core::vector3df& normal,
float textureRotation,
float lifeTime,
float distance)
{
// References
// https://sourceforge.net/p/irrext/code/HEAD/tree/trunk/extensions/scene/ISceneNode/DecalSystem

CEntity* entity = createEntity();

CDecalData* decalData = entity->addData<CDecalData>();
decalData->Dimension = dimension;
decalData->Normal = normal;
decalData->TextureRotation = textureRotation;
decalData->LifeTime = lifeTime;
decalData->Distance = distance;

CWorldTransformData* transform = (CWorldTransformData*)entity->getDataByIndex(CWorldTransformData::DataTypeIndex);
transform->Relative.setTranslation(position);

return entity;
}

void CDecals::bake()
{

}
}
67 changes: 67 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecals.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
!@
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 "Components/CComponentSystem.h"
#include "Entity/CEntityHandler.h"

namespace Skylicht
{
class CDecals : public CEntityHandler
{
protected:
ITexture* m_texture;

public:
CDecals();

virtual ~CDecals();

virtual void initComponent();

virtual void updateComponent();

virtual CObjectSerializable* createSerializable();

virtual void loadSerializable(CObjectSerializable* object);

inline void setTexture(ITexture* texture)
{
m_texture = texture;
}

CEntity* addDecal(
const core::vector3df& position,
const core::vector3df& dimension,
const core::vector3df& normal,
float textureRotation,
float lifeTime,
float distance);

void bake();

DECLARE_GETTYPENAME(CDecals);
};
}
64 changes: 64 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecalsRenderer.cpp
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 "CDecalsRenderer.h"

namespace Skylicht
{
CDecalsRenderer::CDecalsRenderer()
{

}

CDecalsRenderer::~CDecalsRenderer()
{

}

void CDecalsRenderer::beginQuery(CEntityManager* entityManager)
{

}

void CDecalsRenderer::onQuery(CEntityManager* entityManager, CEntity* entity)
{

}

void CDecalsRenderer::init(CEntityManager* entityManager)
{

}

void CDecalsRenderer::update(CEntityManager* entityManager)
{

}

void CDecalsRenderer::render(CEntityManager* entityManager)
{

}
}
50 changes: 50 additions & 0 deletions Projects/Skylicht/Collision/Source/Decal/CDecalsRenderer.h
Original file line number Diff line number Diff line change
@@ -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 CDecalsRenderer : public IRenderSystem
{
protected:

public:
CDecalsRenderer();

virtual ~CDecalsRenderer();

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);
};
}
Loading

0 comments on commit 412db87

Please sign in to comment.