Skip to content

Commit

Permalink
#80 Update decal projection
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed May 17, 2022
1 parent f9f5bba commit 0719cb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 9 additions & 5 deletions Projects/Skylicht/Collision/Source/Decal/CDecalsRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace Skylicht
r1.rotationFromTo(core::vector3df(0.0f, 1.0f, 0.0f), decal->Normal);

core::quaternion r2;
r2.fromAngleAxis(-decal->TextureRotation * core::DEGTORAD, core::vector3df(0.0f, 1.0f, 0.0f));
r2.fromAngleAxis(decal->TextureRotation * core::DEGTORAD, core::vector3df(0.0f, 1.0f, 0.0f));

core::quaternion q = r2 * r1;

Expand Down Expand Up @@ -178,17 +178,21 @@ namespace Skylicht
uvMatrix.transformVect(uvTriangle.pointB);
uvMatrix.transformVect(uvTriangle.pointC);


// Fill vertices and indices
{
video::SColor color(255, 255, 255, 255);

for (u32 p = 0; p < 3; p++)
{
core::vector3df uvPos = uvTriangle.pointA * uvScale + uvOffset;
core::vector3df pos = triangle.pointA;
core::vector3df uvPos;
core::vector3df pos;

if (p == 1)
if (p == 0)
{
uvPos = uvTriangle.pointA * uvScale + uvOffset;
pos = triangle.pointA;
}
else if (p == 1)
{
uvPos = uvTriangle.pointB * uvScale + uvOffset;
pos = triangle.pointB;
Expand Down
8 changes: 4 additions & 4 deletions Samples/Collision/Source/CViewDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool CViewDemo::OnEvent(const SEvent& event)
m_mouseX = (float)event.MouseInput.X;
m_mouseY = (float)event.MouseInput.Y;

if (event.MouseInput.isLeftPressed())
if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
{
// press
if (m_currentTest == 2)
Expand Down Expand Up @@ -116,7 +116,7 @@ void CViewDemo::onUpdate()
box.MaxEdge = intersection + halfBox;
sceneDebug->addBoudingBox(box, SColor(255, 0, 255, 0));

// query
// query triangles
core::array<core::triangle3df*> listTris;
core::array<CCollisionNode*> listNodes;

Expand All @@ -133,7 +133,7 @@ void CViewDemo::onUpdate()
core::vector3df normal = triangle.getNormal();
normal.normalize();

// draw bbox query
// draw decal projection box
core::aabbox3df box;
core::vector3df halfBox = core::vector3df(m_decalSizeX * 0.5f, m_decalSizeY * 0.5f, m_decalSizeZ * 0.5f);
box.MinEdge = -halfBox;
Expand All @@ -143,7 +143,7 @@ void CViewDemo::onUpdate()
r1.rotationFromTo(core::vector3df(0.0f, 1.0f, 0.0f), normal);

core::quaternion r2;
r2.fromAngleAxis(-m_decalRotation * core::DEGTORAD, core::vector3df(0.0f, 1.0f, 0.0f));
r2.fromAngleAxis(m_decalRotation * core::DEGTORAD, core::vector3df(0.0f, 1.0f, 0.0f));

core::quaternion q = r2 * r1;

Expand Down

0 comments on commit 0719cb3

Please sign in to comment.