Commit 08a3f452 authored by AL's avatar AL

object now faces camera

parent 4640cccb
......@@ -35,7 +35,18 @@ public:
DirectX::XMFLOAT3 GetPosition() const noexcept;
//for debugging
void Rotate(float dx, float dy) noexcept
{
baseTrans.tilt.yaw +=dx;
baseTrans.tilt.pitch += dx;
}
void Translate(DirectX::XMFLOAT3 translation) noexcept
{
baseTrans.pos.x += translation.x;
baseTrans.pos.y += translation.y;
baseTrans.pos.z += translation.z;
}
private:
CamTrans baseTrans;
......
......@@ -136,11 +136,7 @@ int CombatManager::ProcessInput(Keyboard::Event in_event) //why does it return
{
CM::PendScenario(CM::Scenario::Defend);
}
if (curTurn != Turn::NotInCombat)
{
if (curTurn == Turn::Player)
......
......@@ -85,7 +85,7 @@ HudEffect<Effect3DSequence, PlaneTexNorm>::HudEffect(DXGraphics& gfx, Effect3DSe
{
BindPositionData(&refPosData);
BindAdditionalData(&refAddData);
refAddData.emplace_back( 1.0f,1.0f,1.0f, 1.0f );
refAddData.emplace_back();
refPosData.emplace_back();
}
......@@ -103,6 +103,7 @@ HudEffect<Effect3DSequence, PlaneTexNorm>::HudEffect(HudEffect&& mvFrom) :
PlaneTexNorm(std::move(mvFrom)),
cbData(std::move(mvFrom.cbData)),
refPosData(std::move(mvFrom.refPosData)),
refAddData(std::move(mvFrom.refAddData)),
cbuf(std::move(mvFrom.cbuf)),
effectSequence(std::move(mvFrom.effectSequence)),
gfx(std::move(mvFrom.gfx)) {}
......@@ -136,6 +137,10 @@ bool HudEffect<Effect3DSequence, PlaneTexNorm>::UpdateData(float dt)
refPosData[0].rot.x = nd->roll;
refPosData[0].rot.y = nd->pitch;
refPosData[0].rot.z = nd->yaw;
refAddData[0].x = nd->scale;
refAddData[0].y = nd->scale;
refAddData[0].z = nd->scale;
refAddData[0].w = nd->scale;
//cbData.fillness = nd->opacity;
//cbuf->Update(gfx, cbData);
return 0;
......@@ -271,15 +276,15 @@ void EffectHandler::AddEffect3D(Effect e)
{
case Effect::GhoulAttack: //is called from switch on enemyState in LevelLayout
{
PositionData posData = { 3.3f, -0.1f, 0.6f, 0.0f,0.0f,0.0f };
PositionData posData = { 3.7f, 1.0f, 1.0f, 0.0f, 3 * PI / 2.0f, PI / 2.0f };
Effect3DSequence e3ds1;
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z * 1.0f, 0.8f }, 10.65f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z * 1.5f, 0.0f }, 0.0f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z , 0.8f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 2.65f);
e3ds1.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.0f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
EffectHandler::AddEffect3D(e3ds1, L"Media\\Models\\Enemy_hit.obj");
Effect3DSequence e3ds2;
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 1.0f }, 11.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 1.0f }, 0.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 0.0f ,0.5f,posData.rot.x,posData.rot.y,posData.rot.z }, 5.0f);
e3ds2.AddStage({ posData.pos.x,posData.pos.y,posData.pos.z, 1.0f ,1.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
EffectHandler::AddEffect3D(e3ds2, L"Media\\Models\\Enemy_hit.obj");
break;
}
......
......@@ -112,6 +112,18 @@ public:
void UpdateAndBindLight(float dt, DirectX::XMMATRIX cameraTransform);
DirectX::XMMATRIX GetCameraMatrix() const noexcept; //only called from Game class
DirectX::XMFLOAT3 GetCameraPosition() const noexcept;
//for debugging
void Rotate(float dx, float dy) noexcept
{
camMan.Rotate(dx, dy);
}
void Translate(DirectX::XMFLOAT3 translation) noexcept
{
camMan.Translate(translation);
}
private:
void RemoveCorpses();
DXGraphics& gfx; //to reduce the amount of argument passing
......
......@@ -88,7 +88,7 @@ namespace Bind
{
namespace dx = DirectX;
const auto modelTransform = pParent->GetTransformXM(); //world
auto modelTransform = pParent->GetTransformXM(); //world
const auto addData = pParent->GetAdditionalTransformData(); //roll+scale
const auto camera = gfx.GetCamera(); //view
const auto camPos = gfx.GetCamPos();
......@@ -104,6 +104,7 @@ namespace Bind
float cosDeltaAngle = (diff / diff.Len()) * Vec3{ 0.0f, 0.0f, -1.0f };//no explanation here...
//just know that works ONLY with posData.rot = { 0.0f, 3 * PI / 2, PI / 2 };
dx::XMMATRIX newWorldTrans;
if (diff.x > 0.0f)
{
......@@ -114,10 +115,10 @@ namespace Bind
newWorldTrans = dx::XMMatrixRotationX(acos(cosDeltaAngle)) * modelTransform;
}
newWorldTrans*=dx::XMMatrixRotationAxis({ diff.x,diff.y,diff.z }, addData.x);
newWorldTrans *= dx::XMMatrixScaling(addData.y, addData.y, addData.y);
//newWorldTrans*=dx::XMMatrixRotationAxis({ diff.x,diff.y,diff.z }, addData.x);
dx::XMMATRIX newWorldView = dx::XMMatrixMultiply(newWorldTrans, camera);
//newWorldView *= dx::XMMatrixScaling(addData.y, addData.y, addData.y);
return {
dx::XMMatrixTranspose(newWorldView),
dx::XMMatrixTranspose(
......@@ -125,6 +126,7 @@ namespace Bind
gfx.GetProjection()
)
};
break;
}
case Bind::TransformCbuf::DataType::NotSpecified: assert(false && "please,specify data type fot transform constant buffer");
......
......@@ -41,6 +41,46 @@ int Game::Go()
if (isExiting)break;
while (const auto e = wnd.kbd.ReadKey())
{
float k = 10.3f;
if (wnd.kbd.KeyIsPressed(VK_NUMPAD8))
{
ll.Translate(DirectX::XMFLOAT3{ 0.0f,0.0f,0.3f });
}
if (wnd.kbd.KeyIsPressed(VK_NUMPAD4))
{
ll.Translate(DirectX::XMFLOAT3{ -0.3f,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed(VK_NUMPAD5))
{
ll.Translate(DirectX::XMFLOAT3{ 0.0f,0.0f,-0.3f });
}
if (wnd.kbd.KeyIsPressed(VK_NUMPAD6))
{
ll.Translate(DirectX::XMFLOAT3{ 0.3f,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed(VK_NUMPAD7))
{
ll.Rotate(-0.1f,0.0f);
}
if (wnd.kbd.KeyIsPressed(VK_NUMPAD9))
{
ll.Rotate(0.1f, 0.0f);
}
if (!e->IsPress())
{
continue;
......@@ -88,34 +128,7 @@ int Game::Go()
td.SubmitText(dt);
fc.Execute(wnd.DXGfx(),dt);
/*if (!wnd.CursorEnabled())
{
float k = 0.3f;
if (wnd.kbd.KeyIsPressed('W'))
{
cam.Translate({ 0.0f,0.0f,dt*k });
}
if (wnd.kbd.KeyIsPressed('A'))
{
cam.Translate({ -dt*k,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed('S'))
{
cam.Translate({ 0.0f,0.0f,-dt*k });
}
if (wnd.kbd.KeyIsPressed('D'))
{
cam.Translate({ dt*k,0.0f,0.0f });
}
if (wnd.kbd.KeyIsPressed('R'))
{
cam.Translate({ 0.0f,dt*k,0.0f });
}
if (wnd.kbd.KeyIsPressed('F'))
{
cam.Translate({ 0.0f,-dt*k,0.0f });
}
}*/
//while (const auto delta = wnd.mouse.ReadRawDelta())
//{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment