diff --git a/Assets/Editor/Font.meta b/Assets/Editor/Font.meta deleted file mode 100644 index 0c5a08248..000000000 --- a/Assets/Editor/Font.meta +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/Assets/Editor/Fonts.meta b/Assets/Editor/Fonts.meta new file mode 100644 index 000000000..0848e1182 --- /dev/null +++ b/Assets/Editor/Fonts.meta @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Assets/Editor/Font/droidsans.ttf b/Assets/Editor/Fonts/droidsans.ttf similarity index 100% rename from Assets/Editor/Font/droidsans.ttf rename to Assets/Editor/Fonts/droidsans.ttf diff --git a/Assets/Editor/Font/droidsans.ttf.meta b/Assets/Editor/Fonts/droidsans.ttf.meta similarity index 100% rename from Assets/Editor/Font/droidsans.ttf.meta rename to Assets/Editor/Fonts/droidsans.ttf.meta diff --git a/Assets/Editor/Textures.meta b/Assets/Editor/Textures.meta new file mode 100644 index 000000000..133bd24ca --- /dev/null +++ b/Assets/Editor/Textures.meta @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Assets/Editor/Textures/oxyz.png b/Assets/Editor/Textures/oxyz.png new file mode 100644 index 000000000..4a78cdfa0 Binary files /dev/null and b/Assets/Editor/Textures/oxyz.png differ diff --git a/Assets/Editor/Textures/oxyz.png.meta b/Assets/Editor/Textures/oxyz.png.meta new file mode 100644 index 000000000..fe67edce1 --- /dev/null +++ b/Assets/Editor/Textures/oxyz.png.meta @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Assets/Editor/Textures/oxyz.psd b/Assets/Editor/Textures/oxyz.psd new file mode 100644 index 000000000..de38718bf Binary files /dev/null and b/Assets/Editor/Textures/oxyz.psd differ diff --git a/Assets/Editor/Textures/oxyz.psd.meta b/Assets/Editor/Textures/oxyz.psd.meta new file mode 100644 index 000000000..907f5a124 --- /dev/null +++ b/Assets/Editor/Textures/oxyz.psd.meta @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp b/Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp index 93ef48ad6..250ada53d 100644 --- a/Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp +++ b/Projects/Editor/Source/Editor/Space/Scene/CSpaceScene.cpp @@ -205,7 +205,7 @@ namespace Skylicht core::vector3df up(matData[4], matData[5], matData[6]); up.normalize(); - float distance = 2.5f; + float distance = 2.0f; core::vector3df pos = -dir * distance; m_viewpointCamera->setPosition(pos); diff --git a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.cpp b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.cpp index 53f65f0a1..78b5a4713 100644 --- a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.cpp +++ b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.cpp @@ -26,7 +26,7 @@ This file is part of the "Skylicht Engine". #include "CViewpointData.h" #include "Projective/CProjective.h" #include "Material/Shader/CShaderManager.h" - +#include "TextureManager/CTextureManager.h" #include "GameObject/CGameObject.h" #include "Camera/CCamera.h" @@ -37,11 +37,14 @@ namespace Skylicht CViewpointData::CViewpointData() { Buffer = new CMeshBuffer(getVideoDriver()->getVertexDescriptor(EVT_STANDARD)); - Buffer->getMaterial().MaterialType = CShaderManager::getInstance()->getShaderIDByName("VertexColor"); + Buffer->getMaterial().MaterialType = CShaderManager::getInstance()->getShaderIDByName("TextureColorAlpha"); Buffer->getMaterial().BackfaceCulling = false; Buffer->setHardwareMappingHint(EHM_STREAM); - const float p = 1.0f; + ITexture* texture = CTextureManager::getInstance()->getTexture("Editor/Textures/oxyz.png"); + Buffer->getMaterial().setTexture(0, texture); + + const float p = 0.8f; Position[0].set(p, 0.0f, 0.0f); Position[1].set(-p, 0.0f, 0.0f); @@ -67,12 +70,12 @@ namespace Skylicht idx[i * 6 + 5] = i * 4 + 3; } - SColor blue = SColor(255, 65, 105, 140); + SColor blue = SColor(255, 44, 143, 255); SColor red = SColor(255, 155, 65, 80); SColor green = SColor(255, 105, 140, 45); core::vector3df zero(0.0f, 0.0f, 0.0f); - float s = 0.7f; + float s = 0.8f; addLineVertexBatch(zero, Position[0] * s, red); addLineVertexBatch(zero, Position[2] * s, blue); addLineVertexBatch(zero, Position[4] * s, green); @@ -83,7 +86,7 @@ namespace Skylicht } - void CViewpointData::updateBillboard(const core::vector3df& look, const core::vector3df& up) + void CViewpointData::updateBillboard(const core::vector3df& look, const core::vector3df& up, const core::vector3df& campos) { video::S3DVertex* vtx = (video::S3DVertex*)Buffer->getVertexBuffer()->getVertices(); @@ -97,17 +100,67 @@ namespace Skylicht sideQuad *= 0.25f; SColor color(255, 255, 255, 255); - core::vector2df uvScale(1.0f, 1.0f); + core::vector2df uvScale(0.5f, 0.5f); core::vector2df uvOffset(0.0f, 0.0f); + // sort to fix alpha depth + std::vector> sortPosition; + for (int i = 0; i < 6; i++) + { + float d = Position[i].getDistanceFromSQ(campos); + sortPosition.push_back(std::pair(i, d)); + } + struct { + bool operator()(const std::pair& a, const std::pair& b) const { return a.second > b.second; } + } customLess; + std::sort(sortPosition.begin(), sortPosition.end(), customLess); + for (int i = 0; i < 6; i++) { int offset = i * 4; - int offsetVertex = offset; - float x = Position[i].X; - float y = Position[i].Y; - float z = Position[i].Z; + int id = sortPosition[i].first; + + float x = Position[id].X; + float y = Position[id].Y; + float z = Position[id].Z; + + if (id == 1) + { + // -x + uvOffset.set(0.5f, 0.5f); + color.set(255, 154, 57, 71); + } + else if (id == 3) + { + // -y + uvOffset.set(0.5f, 0.5f); + color.set(255, 52, 100, 154); + } + else if (id == 5) + { + // -z + uvOffset.set(0.5f, 0.5f); + color.set(255, 98, 138, 34); + } + else if (id == 0) + { + // x + uvOffset.set(0.0f, 0.0f); + color.set(255, 255, 255, 255); + } + else if (id == 2) + { + // y + uvOffset.set(0.0f, 0.5f); + color.set(255, 255, 255, 255); + } + else if (id == 4) + { + // z + uvOffset.set(0.5f, 0.0f); + color.set(255, 255, 255, 255); + } // top left vertex vtx[offset].Pos.set( diff --git a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.h b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.h index 225a3e0e9..965bded54 100644 --- a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.h +++ b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointData.h @@ -56,7 +56,7 @@ namespace Skylicht virtual ~CViewpointData(); - void updateBillboard(const core::vector3df& look, const core::vector3df& up); + void updateBillboard(const core::vector3df& look, const core::vector3df& up, const core::vector3df& campos); EAxis hit(CCamera* camera, float x, float y, int viewportW, int viewportH); }; diff --git a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointRenderer.cpp b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointRenderer.cpp index eefdddc6b..146366e10 100644 --- a/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointRenderer.cpp +++ b/Projects/Editor/Source/EditorComponents/Viewpoint/CViewpointRenderer.cpp @@ -24,6 +24,7 @@ This file is part of the "Skylicht Engine". #include "pch.h" #include "CViewpointRenderer.h" +#include "Entity/CEntityManager.h" namespace Skylicht { @@ -90,6 +91,8 @@ namespace Skylicht look.normalize(); up.normalize(); + core::vector3df camPos = entityManager->getCamera()->getGameObject()->getPosition(); + for (u32 i = 0, n = m_viewpoints.size(); i < n; i++) { driver->setTransform(video::ETS_WORLD, transforms[i]->World); @@ -101,7 +104,7 @@ namespace Skylicht for (u32 i = 0, n = m_viewpoints.size(); i < n; i++) { driver->setTransform(video::ETS_WORLD, transforms[i]->World); - viewpoints[i]->updateBillboard(look, up); + viewpoints[i]->updateBillboard(look, up, camPos); IMeshBuffer* buffer = viewpoints[i]->Buffer; driver->setMaterial(buffer->getMaterial()); diff --git a/Projects/Editor/Source/GUI/Theme/CThemeConfig.cpp b/Projects/Editor/Source/GUI/Theme/CThemeConfig.cpp index 52d61f33d..4da9a2ccc 100644 --- a/Projects/Editor/Source/GUI/Theme/CThemeConfig.cpp +++ b/Projects/Editor/Source/GUI/Theme/CThemeConfig.cpp @@ -32,7 +32,7 @@ namespace Skylicht namespace GUI { std::string CThemeConfig::FontName = "Droid Sans"; - std::string CThemeConfig::FontPath = "Editor/Font/droidsans.ttf"; + std::string CThemeConfig::FontPath = "Editor/Fonts/droidsans.ttf"; SGUIColor CThemeConfig::White = SGUIColor(255, 255, 255, 255); SGUIColor CThemeConfig::Black = SGUIColor(255, 0, 0, 0);