Commit 0c161e11 authored by AL's avatar AL

discovered a wat to rotate cam facing models

parent 342d4df0
......@@ -294,7 +294,7 @@ void EffectHandler::AddEffect3D(Effect e)
{
case Effect::GhoulAttack: //is called from switch on enemyState in LevelLayout
{
PositionData posData = { 3.7f, 1.0f, 1.0f, 0.0f, 3 * PI / 2.0f, PI / 2.0f };
PositionData posData = { 3.7f, 1.0f, 1.0f, 0.0f, 3.0f * PI / 2.0f,PI/2.0f };
Effect3DSequence e3ds1;
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.8f ,0.0f,posData.rot.x,posData.rot.y,posData.rot.z }, 0.0f);
......
......@@ -35,7 +35,7 @@ namespace Bind
switch (datTyp)
{
case Bind::TransformCbuf::DataType::Standart:
{
{ //modelTransform = dx::XMMatrixRotationY(PI / 3.0f) * modelTransform;
const auto modelView = pParent->GetTransformXM() * gfx.GetCamera();
return {
DirectX::XMMatrixTranspose(modelView),
......@@ -46,6 +46,7 @@ namespace Bind
};
}
break;
case Bind::TransformCbuf::DataType::CamFacingEX:
case Bind::TransformCbuf::DataType::CameraFacing:
{
namespace dx = DirectX;
......@@ -64,7 +65,8 @@ namespace Bind
Vec3 diff = camPosVec - worldPos;
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 };
//just know that works ONLY with posData.rot = { 0.0f, 3 * PI / 2, ... };
//use ... to change roll (PI/2.0f - no roll)
dx::XMMATRIX newWorldTrans;
if (diff.x > 0.0f)
{
......@@ -84,50 +86,6 @@ namespace Bind
};
break;
}
case Bind::TransformCbuf::DataType::CamFacingEX:
{
namespace dx = DirectX;
auto modelTransform = pParent->GetTransformXM(); //world
const auto camera = gfx.GetCamera(); //view
const auto camPos = gfx.GetCamPos();
dx::XMFLOAT4X4 modelTransStored;
dx::XMStoreFloat4x4(&modelTransStored, modelTransform);
dx::XMFLOAT4X4 viewsStored;
dx::XMStoreFloat4x4(&viewsStored, camera);
Vec3 worldPos{ modelTransStored._41, modelTransStored._42,modelTransStored._43 };
Vec3 camPosVec{ camPos.x, camPos.y, camPos.z };
Vec3 diff = camPosVec - worldPos;
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)
{
newWorldTrans = dx::XMMatrixRotationX(-acos(cosDeltaAngle)) * modelTransform;
}
else
{
newWorldTrans = dx::XMMatrixRotationX(acos(cosDeltaAngle)) * modelTransform;
}
//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(
newWorldView *
gfx.GetProjection()
)
};
break;
}
case Bind::TransformCbuf::DataType::NotSpecified: assert(false && "please,specify data type fot transform constant buffer");
default:
assert(false && "programmer missed the case");
......
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