Some CCamera cleanup and docs

master
krzys-h 2016-05-28 18:42:48 +02:00
parent bef27c3b36
commit 646e5104f6
16 changed files with 377 additions and 661 deletions

View File

@ -18,7 +18,7 @@
*/
/**
* \file common/pathman.h
* \file app/pathman.h
* \brief Class for managing data/lang/save paths
*/

View File

@ -480,10 +480,6 @@ void InitializeEventTypeTexts()
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERA] = "EVENT_OBJECT_CAMERA";
EVENT_TYPE_TEXT[EVENT_OBJECT_HELP] = "EVENT_OBJECT_HELP";
EVENT_TYPE_TEXT[EVENT_OBJECT_SOLUCE] = "EVENT_OBJECT_SOLUCE";
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAleft] = "EVENT_OBJECT_CAMERAleft";
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAright]= "EVENT_OBJECT_CAMERAright";
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAnear] = "EVENT_OBJECT_CAMERAnear";
EVENT_TYPE_TEXT[EVENT_OBJECT_CAMERAaway] = "EVENT_OBJECT_CAMERAaway";
EVENT_TYPE_TEXT[EVENT_OBJECT_SHORTCUT_MODE] = "EVENT_OBJECT_SHORTCUT_MODE";
EVENT_TYPE_TEXT[EVENT_OBJECT_MOVIELOCK] = "EVENT_OBJECT_MOVIELOCK";
EVENT_TYPE_TEXT[EVENT_OBJECT_EDITLOCK] = "EVENT_OBJECT_EDITLOCK";

View File

@ -394,10 +394,6 @@ void InitializeRestext()
stringsEvent[EVENT_OBJECT_GINFO] = TR("Transmitted information");
stringsEvent[EVENT_OBJECT_MAPZOOM] = TR("Zoom mini-map");
stringsEvent[EVENT_OBJECT_CAMERA] = TR("Camera (\\key camera;)");
stringsEvent[EVENT_OBJECT_CAMERAleft] = TR("Camera to left");
stringsEvent[EVENT_OBJECT_CAMERAright] = TR("Camera to right");
stringsEvent[EVENT_OBJECT_CAMERAnear] = TR("Camera nearest");
stringsEvent[EVENT_OBJECT_CAMERAaway] = TR("Camera awayest");
stringsEvent[EVENT_OBJECT_HELP] = TR("Help about selected object");
stringsEvent[EVENT_OBJECT_SOLUCE] = TR("Show the solution");
stringsEvent[EVENT_OBJECT_SHORTCUT_MODE]= TR("Switch bots <-> buildings");

View File

@ -94,8 +94,8 @@ CCamera::CCamera()
m_actualLookat = Math::Vector(0.0f, 0.0f, 0.0f);
m_finalEye = Math::Vector(0.0f, 0.0f, 0.0f);
m_finalLookat = Math::Vector(0.0f, 0.0f, 0.0f);
m_normEye = Math::Vector(0.0f, 0.0f, 0.0f);
m_normLookat = Math::Vector(0.0f, 0.0f, 0.0f);
m_prevEye = Math::Vector(0.0f, 0.0f, 0.0f);
m_prevLookat = Math::Vector(0.0f, 0.0f, 0.0f);
m_focus = 1.0f;
m_eyePt = Math::Vector(0.0f, 0.0f, 0.0f);
@ -109,7 +109,6 @@ CCamera::CCamera()
m_backMin = 0.0f;
m_addDirectionH = 0.0f;
m_addDirectionV = 0.0f;
m_transparency = false;
m_fixDist = 0.0f;
m_fixDirectionH = 0.0f;
@ -121,8 +120,6 @@ CCamera::CCamera()
m_visitType = CAM_TYPE_NULL;
m_visitDirectionV = 0.0f;
m_remotePan = 0.0f;
m_centeringPhase = CAM_PHASE_NULL;
m_centeringAngleH = 0.0f;
m_centeringAngleV = 0.0f;
@ -238,7 +235,6 @@ void CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay)
m_scriptEye = m_actualEye;
m_scriptLookat = m_actualLookat;
m_focus = 1.00f;
m_remotePan = 0.0f;
FlushEffect();
FlushOver();
@ -258,9 +254,7 @@ CObject* CCamera::GetControllingObject()
void CCamera::SetType(CameraType type)
{
m_remotePan = 0.0f;
if ( (m_type == CAM_TYPE_BACK) && m_transparency )
if ( (m_type == CAM_TYPE_BACK) )
{
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
{
@ -270,13 +264,12 @@ void CCamera::SetType(CameraType type)
SetTransparency(obj, 0.0f); // opaque object
}
}
m_transparency = false;
if (type == CAM_TYPE_INFO ||
type == CAM_TYPE_VISIT) // xx -> info ?
{
m_normEye = m_engine->GetEyePt();
m_normLookat = m_engine->GetLookatPt();
m_prevEye = m_engine->GetEyePt();
m_prevLookat = m_engine->GetLookatPt();
m_engine->SetFocus(1.00f); // normal
m_type = type;
@ -290,7 +283,7 @@ void CCamera::SetType(CameraType type)
m_type = type;
Math::Vector upVec = Math::Vector(0.0f, 1.0f, 0.0f);
SetViewParams(m_normEye, m_normLookat, upVec);
SetViewParams(m_prevEye, m_prevLookat, upVec);
return;
}
@ -386,70 +379,6 @@ CameraSmooth CCamera::GetSmooth()
return m_smooth;
}
void CCamera::SetDist(float dist)
{
m_fixDist = dist;
}
float CCamera::GetDist()
{
return m_fixDist;
}
void CCamera::SetFixDirectionH(float angle)
{
m_fixDirectionH = angle;
}
float CCamera::GetFixDirectionH()
{
return m_fixDirectionH;
}
void CCamera::SetFixDirectionV(float angle)
{
m_fixDirectionV = angle;
}
float CCamera::GetFixDirectionV()
{
return m_fixDirectionV;
}
void CCamera::SetRemotePan(float value)
{
m_remotePan = value;
}
float CCamera::GetRemotePan()
{
return m_remotePan;
}
void CCamera::SetRemoteZoom(float value)
{
value = Math::Norm(value);
if ( m_type == CAM_TYPE_BACK )
m_backDist = m_backMin + (200.0f - m_backMin) * value;
if ( m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE )
m_fixDist = 10.0f + (200.0f - 10.0f) * value;
}
float CCamera::GetRemoteZoom()
{
if ( m_type == CAM_TYPE_BACK )
return (m_backDist - m_backMin) / (200.0f - m_backMin);
if ( m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE )
return (m_fixDist - 10.0f) / (200.0f - 10.0f);
return 0.0f;
}
void CCamera::StartVisit(Math::Vector goal, float dist)
{
m_visitType = m_type;
@ -824,98 +753,74 @@ void CCamera::OverFrame(const Event &event)
}
}
void CCamera::FixCamera()
void CCamera::UpdateCameraAnimation(const Math::Vector &eyePt,
const Math::Vector &lookatPt,
float rTime)
{
m_initDelay = 0.0f;
m_actualEye = m_finalEye = m_scriptEye;
m_actualLookat = m_finalLookat = m_scriptLookat;
SetViewTime(m_scriptEye, m_scriptLookat, 0.0f);
}
void CCamera::SetViewTime(const Math::Vector &eyePt,
const Math::Vector &lookatPt,
float rTime)
{
Math::Vector eye, lookat;
if (m_type == CAM_TYPE_INFO)
if (m_initDelay > 0.0f)
{
eye = eyePt;
lookat = lookatPt;
m_initDelay -= rTime;
if (m_initDelay < 0.0f)
m_initDelay = 0.0f;
rTime /= 1.0f+m_initDelay;
}
m_finalEye = eyePt;
m_finalLookat = lookatPt;
IsCollision(m_finalEye, m_finalLookat);
float prog = 0.0f;
float dist = Math::Distance(m_finalEye, m_actualEye);
if (m_smooth == CAM_SMOOTH_NONE) prog = dist;
if (m_smooth == CAM_SMOOTH_NORM) prog = powf(dist, 1.5f) * rTime * 0.75f;
if (m_smooth == CAM_SMOOTH_HARD) prog = dist * rTime * 4.0f;
if (dist == 0.0f)
{
m_actualEye = m_finalEye;
}
else
{
if (m_initDelay > 0.0f)
{
m_initDelay -= rTime;
if (m_initDelay < 0.0f)
m_initDelay = 0.0f;
rTime /= 1.0f+m_initDelay;
}
eye = eyePt;
lookat = lookatPt;
if ( !IsCollision(eye, lookat) )
{
m_finalEye = eye;
m_finalLookat = lookat;
}
float prog = 0.0f;
float dist = Math::Distance(m_finalEye, m_actualEye);
if (m_smooth == CAM_SMOOTH_NONE) prog = dist;
if (m_smooth == CAM_SMOOTH_NORM) prog = powf(dist, 1.5f) * rTime * 0.75f;
if (m_smooth == CAM_SMOOTH_HARD) prog = dist * rTime * 4.0f;
if (dist == 0.0f)
{
m_actualEye = m_finalEye;
}
else
{
if (prog > dist)
prog = dist;
m_actualEye = (m_finalEye - m_actualEye) / dist * prog + m_actualEye;
}
dist = Math::Distance(m_finalLookat, m_actualLookat);
if ( m_smooth == CAM_SMOOTH_NONE ) prog = dist;
if ( m_smooth == CAM_SMOOTH_NORM ) prog = powf(dist, 1.5f) * rTime * 3.0f;
if ( m_smooth == CAM_SMOOTH_HARD ) prog = dist * rTime * 4.0f;
if ( dist == 0.0f )
{
m_actualLookat = m_finalLookat;
}
else
{
if (prog > dist)
prog = dist;
m_actualLookat = (m_finalLookat - m_actualLookat) / dist * prog + m_actualLookat;
}
eye = m_effectOffset+m_actualEye;
m_water->AdjustEye(eye);
float h = m_terrain->GetFloorLevel(eye);
if (eye.y < h + 4.0f)
eye.y = h + 4.0f;
lookat = m_effectOffset+m_actualLookat;
if (prog > dist)
prog = dist;
m_actualEye = (m_finalEye - m_actualEye) / dist * prog + m_actualEye;
}
Math::Vector upVec = Math::Vector(0.0f, 1.0f, 0.0f);
SetViewParams(eye, lookat, upVec);
dist = Math::Distance(m_finalLookat, m_actualLookat);
if ( m_smooth == CAM_SMOOTH_NONE ) prog = dist;
if ( m_smooth == CAM_SMOOTH_NORM ) prog = powf(dist, 1.5f) * rTime * 3.0f;
if ( m_smooth == CAM_SMOOTH_HARD ) prog = dist * rTime * 4.0f;
if ( dist == 0.0f )
{
m_actualLookat = m_finalLookat;
}
else
{
if (prog > dist)
prog = dist;
m_actualLookat = (m_finalLookat - m_actualLookat) / dist * prog + m_actualLookat;
}
Math::Vector eye = m_effectOffset+m_actualEye;
m_water->AdjustEye(eye);
float h = m_terrain->GetFloorLevel(eye);
if (eye.y < h + 4.0f)
eye.y = h + 4.0f;
Math::Vector lookat = m_effectOffset+m_actualLookat;
SetViewParams(eye, lookat);
}
bool CCamera::IsCollision(Math::Vector &eye, Math::Vector lookat)
void CCamera::IsCollision(Math::Vector &eye, Math::Vector lookat)
{
if (m_type == CAM_TYPE_BACK ) return IsCollisionBack(eye, lookat);
if (m_type == CAM_TYPE_FIX ) return IsCollisionFix (eye, lookat);
if (m_type == CAM_TYPE_PLANE) return IsCollisionFix (eye, lookat);
return false;
if (m_type == CAM_TYPE_BACK ) IsCollisionBack();
if (m_type == CAM_TYPE_FIX ) IsCollisionFix (eye, lookat);
if (m_type == CAM_TYPE_PLANE) IsCollisionFix (eye, lookat);
}
bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
void CCamera::IsCollisionBack()
{
ObjectType iType;
if (m_cameraObj == nullptr)
@ -933,8 +838,6 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
max.y = Math::Max(m_actualEye.y, m_actualLookat.y);
max.z = Math::Max(m_actualEye.z, m_actualLookat.z);
m_transparency = false;
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
{
if (IsObjectBeingTransported(obj))
@ -1001,12 +904,10 @@ bool CCamera::IsCollisionBack(Math::Vector &eye, Math::Vector lookat)
if (len > del) continue;
SetTransparency(obj, 1.0f); // transparent object
m_transparency = true;
}
return false;
}
bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
void CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
{
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
{
@ -1041,165 +942,135 @@ bool CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
dist = Math::Distance(eye, lookat);
Math::Vector proj = Projection(eye, lookat, objPos);
eye = (lookat - eye) * objRadius / dist + proj;
return false;
return;
}
}
return false;
}
bool CCamera::EventProcess(const Event &event)
{
switch (event.type)
if (event.type == EVENT_MOUSE_MOVE)
{
case EVENT_FRAME:
EventFrame(event);
break;
if (m_engine->GetMouseType() == ENG_MOUSE_SCROLLR ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLL ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLU ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLD ||
m_engine->GetMouseType() == ENG_MOUSE_MOVE )
{
m_engine->SetMouseType(ENG_MOUSE_NORM);
}
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
EventMouseButton(event);
break;
if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0)
{
Math::Point newDelta = event.mousePos - m_mousePos;
if (m_cameraInvertX)
newDelta.x = -newDelta.x;
if (m_cameraInvertY)
newDelta.y = -newDelta.y;
m_mouseDelta += newDelta;
case EVENT_MOUSE_MOVE:
EventMouseMove(event);
break;
m_engine->SetMouseType(ENG_MOUSE_MOVE);
}
case EVENT_MOUSE_WHEEL:
EventMouseWheel(event);
break;
m_mouseDeltaEdge.LoadZero();
if (m_oldCameraScroll)
{
if (event.mousePos.x < MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.x = event.mousePos.x / MOUSE_EDGE_MARGIN - 1.0f;
if (event.mousePos.x > 1.0f - MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.x = 1.0f - (1.0f - event.mousePos.x) / MOUSE_EDGE_MARGIN;
if (event.mousePos.y < MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.y = event.mousePos.y / MOUSE_EDGE_MARGIN - 1.0f;
if (event.mousePos.y > 1.0f - MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.y = 1.0f - (1.0f - event.mousePos.y) / MOUSE_EDGE_MARGIN;
default:
break;
}
return true;
}
if (m_type == CAM_TYPE_FREE ||
m_type == CAM_TYPE_EDIT ||
m_type == CAM_TYPE_BACK ||
m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE ||
m_type == CAM_TYPE_EXPLO )
{
if (m_mouseDeltaEdge.x > 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLR);
if (m_mouseDeltaEdge.x < 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLL);
}
if (m_type == CAM_TYPE_FREE ||
m_type == CAM_TYPE_EDIT )
{
if (m_mouseDeltaEdge.y > 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLU);
if (m_mouseDeltaEdge.y < 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLD);
}
bool CCamera::EventMouseMove(const Event &event)
{
if (m_engine->GetMouseType() == ENG_MOUSE_SCROLLR ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLL ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLU ||
m_engine->GetMouseType() == ENG_MOUSE_SCROLLD ||
m_engine->GetMouseType() == ENG_MOUSE_MOVE )
{
m_engine->SetMouseType(ENG_MOUSE_NORM);
m_mouseDeltaEdge.x /= 2*Math::PI;
m_mouseDeltaEdge.y /= Math::PI;
}
m_mousePos = event.mousePos;
}
if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0)
if (event.type == EVENT_MOUSE_WHEEL)
{
Math::Point newDelta = event.mousePos - m_mousePos;
auto dir = event.GetData<MouseWheelEventData>()->y;
m_mouseWheelDelta -= dir;
}
if (event.type == EVENT_MOUSE_BUTTON_DOWN || event.type == EVENT_MOUSE_BUTTON_UP)
{
if (event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_RIGHT || event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_MIDDLE)
{
if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0)
{
m_engine->SetMouseType(ENG_MOUSE_MOVE);
}
else
{
m_engine->SetMouseType(ENG_MOUSE_NORM);
}
}
}
if (event.type == EVENT_FRAME && !m_freeze)
{
Math::Point newDelta = m_mouseDeltaEdge * m_speed * event.rTime;
if (m_cameraInvertX)
newDelta.x = -newDelta.x;
if (m_cameraInvertY)
newDelta.y = -newDelta.y;
m_mouseDelta += newDelta;
m_engine->SetMouseType(ENG_MOUSE_MOVE);
}
EffectFrame(event);
OverFrame(event);
m_mouseDeltaEdge.LoadZero();
if (m_oldCameraScroll)
{
if (event.mousePos.x < MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.x = event.mousePos.x / MOUSE_EDGE_MARGIN - 1.0f;
if (event.mousePos.x > 1.0f - MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.x = 1.0f - (1.0f - event.mousePos.x) / MOUSE_EDGE_MARGIN;
if (event.mousePos.y < MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.y = event.mousePos.y / MOUSE_EDGE_MARGIN - 1.0f;
if (event.mousePos.y > 1.0f - MOUSE_EDGE_MARGIN)
m_mouseDeltaEdge.y = 1.0f - (1.0f - event.mousePos.y) / MOUSE_EDGE_MARGIN;
if (m_type == CAM_TYPE_FREE ||
m_type == CAM_TYPE_EDIT ||
m_type == CAM_TYPE_BACK ||
m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE ||
m_type == CAM_TYPE_EXPLO )
{
if (m_mouseDeltaEdge.x > 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLR);
if (m_mouseDeltaEdge.x < 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLL);
}
if (m_type == CAM_TYPE_FREE ||
m_type == CAM_TYPE_EDIT )
{
if (m_mouseDeltaEdge.y > 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLU);
if (m_mouseDeltaEdge.y < 0.0f)
m_engine->SetMouseType(ENG_MOUSE_SCROLLD);
}
m_type == CAM_TYPE_EDIT)
return EventFrameFree(event, m_type != CAM_TYPE_EDIT);
m_mouseDeltaEdge.x /= 2*Math::PI;
m_mouseDeltaEdge.y /= Math::PI;
if (m_type == CAM_TYPE_BACK)
return EventFrameBack(event);
if (m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE)
return EventFrameFix(event);
if (m_type == CAM_TYPE_EXPLO)
return EventFrameExplo(event);
if (m_type == CAM_TYPE_ONBOARD)
return EventFrameOnBoard(event);
if (m_type == CAM_TYPE_SCRIPT)
return EventFrameScript(event);
if (m_type == CAM_TYPE_INFO)
return EventFrameInfo(event);
if (m_type == CAM_TYPE_VISIT)
return EventFrameVisit(event);
}
m_mousePos = event.mousePos;
return true;
}
void CCamera::EventMouseWheel(const Event &event)
{
auto dir = event.GetData<MouseWheelEventData>()->y;
m_mouseWheelDelta -= dir;
}
void CCamera::EventMouseButton(const Event &event)
{
if (event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_RIGHT || event.GetData<MouseButtonEventData>()->button == MOUSE_BUTTON_MIDDLE)
{
if ((event.mouseButtonsState & MOUSE_BUTTON_RIGHT) != 0 || (event.mouseButtonsState & MOUSE_BUTTON_MIDDLE) != 0)
{
m_engine->SetMouseType(ENG_MOUSE_MOVE);
}
else
{
m_engine->SetMouseType(ENG_MOUSE_NORM);
}
}
}
bool CCamera::EventFrame(const Event &event)
{
if (m_freeze)
return true;
Math::Point newDelta = m_mouseDeltaEdge * m_speed * event.rTime;
if (m_cameraInvertX)
newDelta.x = -newDelta.x;
if (m_cameraInvertY)
newDelta.y = -newDelta.y;
m_mouseDelta += newDelta;
EffectFrame(event);
OverFrame(event);
if (m_type == CAM_TYPE_FREE ||
m_type == CAM_TYPE_EDIT)
return EventFrameFree(event, m_type != CAM_TYPE_EDIT);
if (m_type == CAM_TYPE_BACK)
return EventFrameBack(event);
if (m_type == CAM_TYPE_FIX ||
m_type == CAM_TYPE_PLANE)
return EventFrameFix(event);
if (m_type == CAM_TYPE_EXPLO)
return EventFrameExplo(event);
if (m_type == CAM_TYPE_ONBOARD)
return EventFrameOnBoard(event);
if (m_type == CAM_TYPE_SCRIPT)
return EventFrameScript(event);
if (m_type == CAM_TYPE_INFO)
return EventFrameInfo(event);
if (m_type == CAM_TYPE_VISIT)
return EventFrameVisit(event);
return true;
}
@ -1255,7 +1126,7 @@ bool CCamera::EventFrameFree(const Event &event, bool keysAllowed)
if (m_terrain->AdjustToFloor(lookatPt, true))
lookatPt.y += m_heightLookat;
SetViewTime(m_eyePt, lookatPt, event.rTime);
UpdateCameraAnimation(m_eyePt, lookatPt, event.rTime);
return true;
}
@ -1347,7 +1218,7 @@ bool CCamera::EventFrameBack(const Event &event)
{
h += Math::PI; // back
}
h = Math::NormAngle(h)+m_remotePan;
h = Math::NormAngle(h);
float v = 0.0f; //?
h += m_centeringCurrentH;
@ -1382,7 +1253,7 @@ bool CCamera::EventFrameBack(const Event &event)
m_eyePt = ExcludeTerrain(m_eyePt, lookatPt, h, v);
m_eyePt = ExcludeObject(m_eyePt, lookatPt, h, v);
SetViewTime(m_eyePt, lookatPt, event.rTime);
UpdateCameraAnimation(m_eyePt, lookatPt, event.rTime);
m_directionH = h + Math::PI / 2.0f;
m_directionV = v;
@ -1407,7 +1278,7 @@ bool CCamera::EventFrameFix(const Event &event)
{
Math::Vector lookatPt = m_cameraObj->GetPosition();
float h = m_fixDirectionH + m_remotePan;
float h = m_fixDirectionH;
float v = m_fixDirectionV;
float d = m_fixDist;
@ -1416,7 +1287,7 @@ bool CCamera::EventFrameFix(const Event &event)
m_eyePt = ExcludeTerrain(m_eyePt, lookatPt, h, v);
m_eyePt = ExcludeObject(m_eyePt, lookatPt, h, v);
SetViewTime(m_eyePt, lookatPt, event.rTime);
UpdateCameraAnimation(m_eyePt, lookatPt, event.rTime);
m_directionH = h + Math::PI / 2.0f;
m_directionV = v;
@ -1452,7 +1323,7 @@ bool CCamera::EventFrameExplo(const Event &event)
if (m_terrain->AdjustToFloor(lookatPt, true))
lookatPt.y += m_heightLookat;
SetViewTime(m_eyePt, lookatPt, event.rTime);
UpdateCameraAnimation(m_eyePt, lookatPt, event.rTime);
return true;
}
@ -1476,9 +1347,8 @@ bool CCamera::EventFrameOnBoard(const Event &event)
bool CCamera::EventFrameInfo(const Event &event)
{
SetViewTime(Math::Vector(0.0f, 0.0f, 0.0f),
Math::Vector(0.0f, 0.0f, 1.0f),
event.rTime);
SetViewParams(Math::Vector(0.0f, 0.0f, 0.0f),
Math::Vector(0.0f, 0.0f, 1.0f));
return true;
}
@ -1501,28 +1371,43 @@ bool CCamera::EventFrameVisit(const Event &event)
Math::Vector eye = RotateView(m_visitGoal, angleH, angleV, m_visitDist);
eye = ExcludeTerrain(eye, m_visitGoal, angleH, angleV);
eye = ExcludeObject(eye, m_visitGoal, angleH, angleV);
SetViewTime(eye, m_visitGoal, event.rTime);
UpdateCameraAnimation(eye, m_visitGoal, event.rTime);
return true;
}
bool CCamera::EventFrameScript(const Event &event)
{
SetViewTime(m_scriptEye + m_effectOffset,
m_scriptLookat + m_effectOffset, event.rTime);
UpdateCameraAnimation(m_scriptEye + m_effectOffset,
m_scriptLookat + m_effectOffset, event.rTime);
return true;
}
void CCamera::SetScriptEye(Math::Vector eye)
void CCamera::SetScriptCameraAnimateEye(Math::Vector eye)
{
m_scriptEye = eye;
}
void CCamera::SetScriptLookat(Math::Vector lookat)
void CCamera::SetScriptCameraAnimateLookat(Math::Vector lookat)
{
m_scriptLookat = lookat;
}
void CCamera::SetScriptCamera(Math::Vector eye, Math::Vector lookat)
{
SetScriptCameraAnimate(eye, lookat);
m_initDelay = 0.0f;
m_actualEye = m_finalEye = m_scriptEye;
m_actualLookat = m_finalLookat = m_scriptLookat;
}
void CCamera::SetScriptCameraAnimate(Math::Vector eye, Math::Vector lookat)
{
m_scriptEye = eye;
m_scriptLookat = lookat;
}
void CCamera::SetViewParams(const Math::Vector &eye, const Math::Vector &lookat,
const Math::Vector &up)
{

View File

@ -45,7 +45,7 @@ enum CameraType
{
//! Undefined
CAM_TYPE_NULL = 0,
//! Free camera (? never in principle ?)
//! Free camera
CAM_TYPE_FREE = 1,
//! Camera while editing a program
CAM_TYPE_EDIT = 2,
@ -57,11 +57,11 @@ enum CameraType
CAM_TYPE_FIX = 5,
//! Camera steady after explosion
CAM_TYPE_EXPLO = 6,
//! Camera during a film script
//! Camera during a cutscene
CAM_TYPE_SCRIPT = 7,
//! Camera for displaying information
//! Camera for displaying SatCom (???)
CAM_TYPE_INFO = 8,
//! Visit instead of an error
//! Visit camera, rotates around given position
CAM_TYPE_VISIT = 9,
//! Static camera height
CAM_TYPE_PLANE = 11,
@ -91,15 +91,15 @@ enum CameraEffect
CAM_EFFECT_NULL = 0,
//! Digging in
CAM_EFFECT_TERRAFORM = 1,
//! ? Vehicle driving is severely ?
//! Hard landing
CAM_EFFECT_CRASH = 2,
//! Explosion
CAM_EFFECT_EXPLO = 3,
//! ? Not mortal shot ?
//! Shot by an enemy
CAM_EFFECT_SHOT = 4,
//! Vibration during construction
CAM_EFFECT_VIBRATION = 5,
//! ? Spleen reactor ?
//! Overheated reactor
CAM_EFFECT_PET = 6,
};
@ -124,7 +124,9 @@ enum CameraOverEffect
\class CCamera
\brief Camera moving in 3D scene
... */
This class manages everything related to animating the camera in 3D scene.
Calculated values are then passed to Gfx::CEngine.
*/
class CCamera
{
public:
@ -134,70 +136,83 @@ public:
//! Management of an event
bool EventProcess(const Event &event);
//! Initializes the camera
/**
* \brief Initializes the camera
* \param eye Initial eye position
* \param lookat Initial lookat position
* \param delay Time of the initial entry animation
*/
void Init(Math::Vector eye, Math::Vector lookat, float delay);
//! Sets the object controlling the camera
void SetControllingObject(CObject* object);
//! Gets the object controlling the camera
CObject* GetControllingObject();
//! Change the type of camera
void SetType(CameraType type);
//! Get the type of the camera
CameraType GetType();
//! Management of the smoothing mode
//! Set smoothing mode
void SetSmooth(CameraSmooth type);
//! Get smoothing mode
CameraSmooth GetSmooth();
//! Management of the setback distance
void SetDist(float dist);
float GetDist();
//! Manage angle mode CAM_TYPE_FIX
void SetFixDirectionH(float angle);
float GetFixDirectionH();
void SetFixDirectionV(float angle);
float GetFixDirectionV();
//! Managing the triggering mode of the camera panning
void SetRemotePan(float value);
float GetRemotePan();
//! Management of the remote zoom (0 .. 1) of the camera
void SetRemoteZoom(float value);
float GetRemoteZoom();
//! Start with a tour round the camera
void StartVisit(Math::Vector goal, float dist);
//! Circular end of a visit with the camera
void StopVisit();
//! Returns the point of view of the camera
//! Returns the current point of view of the camera
void GetCamera(Math::Vector &eye, Math::Vector &lookat);
//! Specifies a special movement of camera to frame action
//! \name Visit camera management (CAM_TYPE_VISIT) - camera in this mode shows a position, constantly rotating around it
//@{
//! Start visit camera
void StartVisit(Math::Vector goal, float dist);
//! Stop visit camera
void StopVisit();
//@}
//! \name Camera "centering" - moves the camera to show some happening action (e.g. sniffer sniffing)
//@{
//! Move camera to show happening action
bool StartCentering(CObject *object, float angleH, float angleV, float dist, float time);
//! Ends a special movement of camera to frame action
//! Go back to normal position after showing some happening action
bool StopCentering(CObject *object, float time);
//! Stop framing special in the current position
//! Abort centering animation in the current position
void AbortCentering();
//@}
//! Removes the special effect with the camera
void FlushEffect();
//! Starts a special effect with the camera
//! \name Camera shake effects
//@{
//! Starts a camera shake effect
void StartEffect(CameraEffect effect, Math::Vector pos, float force);
//! Removes the camera shake effect
void FlushEffect();
//@}
//! Removes the effect of superposition in the foreground
void FlushOver();
//! Specifies the base color
void SetOverBaseColor(Color color);
//! \name Camera overlay effects
//@{
//! Starts camera overlay effect
void StartOver(CameraOverEffect effect, Math::Vector pos, float force);
//! Removes camera overlay effect
void FlushOver();
//! Specifies camera overlay effect base color
void SetOverBaseColor(Color color);
//@}
//! Sets the soft movement of the camera
void FixCamera();
void SetScriptEye(Math::Vector eye);
void SetScriptLookat(Math::Vector lookat);
//! \name Script camera - cutscenes controlled by external code
//@{
//! Script camera: Set camera position
void SetScriptCamera(Math::Vector eye, Math::Vector lookat);
//! Script camera: Animate to given camera position
void SetScriptCameraAnimate(Math::Vector eye, Math::Vector lookat);
//! Script camera: Animate to given eye position
void SetScriptCameraAnimateEye(Math::Vector eye);
//! Script camera: Animate to given lookat position
void SetScriptCameraAnimateLookat(Math::Vector lookat);
//@}
//! \name Configuration settings
//@{
void SetEffect(bool enable);
bool GetEffect();
void SetBlood(bool enable);
@ -208,58 +223,66 @@ public:
bool GetCameraInvertX();
void SetCameraInvertY(bool invert);
bool GetCameraInvertY();
//@}
//! Temporarily freeze camera movement
void SetFreeze(bool freeze);
//! Set camera speed
void SetCameraSpeed(float speed);
protected:
//! Changes the camera according to the mouse moved
bool EventMouseMove(const Event &event);
//! Mouse wheel operation
void EventMouseWheel(const Event &event);
//! Mouse button handling
void EventMouseButton(const Event &event);
//! Changes the camera according to the time elapsed
bool EventFrame(const Event &event);
//! Moves the point of view
//! Advances the effect of the camera
void EffectFrame(const Event &event);
//! Advanced overlay effect in the foreground
void OverFrame(const Event &event);
bool EventFrameFree(const Event &event, bool keysAllowed);
//! Moves the point of view
bool EventFrameBack(const Event &event);
//! Moves the point of view
bool EventFrameFix(const Event &event);
//! Moves the point of view
bool EventFrameExplo(const Event &event);
//! Moves the point of view
bool EventFrameOnBoard(const Event &event);
//! Moves the point of view
bool EventFrameInfo(const Event &event);
//! Moves the point of view
bool EventFrameVisit(const Event &event);
//! Moves the point of view
bool EventFrameScript(const Event &event);
//! Specifies the location and direction of view to the 3D engine
void SetViewTime(const Math::Vector &eyePt, const Math::Vector &lookatPt, float rTime);
//! Avoid the obstacles
bool IsCollision(Math::Vector &eye, Math::Vector lookat);
//! Avoid the obstacles
bool IsCollisionBack(Math::Vector &eye, Math::Vector lookat);
//! Avoid the obstacles
bool IsCollisionFix(Math::Vector &eye, Math::Vector lookat);
/**
* \brief Calculates camera animation and sends updated camera position to the 3D engine
* \param eyePt Eye point
* \param lookatPt Lookat point
* \param rTime Time since last time this function was called (used to calculate animation)
* \see SetViewParams
*/
void UpdateCameraAnimation(const Math::Vector &eyePt, const Math::Vector &lookatPt, float rTime);
/**
* \brief Avoid the obstacles
*
* For CAM_TYPE_BACK: make obstacles transparent
* For CAM_TYPE_FIX or CAM_TYPE_PLANE: adjust eye not to hit the obstacles
*
* \param eye Eye position, may be adjusted
* \param lookat Lookat point
*/
void IsCollision(Math::Vector &eye, Math::Vector lookat);
//! Avoid the obstacles (CAM_TYPE_BACK)
void IsCollisionBack();
//! Avoid the obstacles (CAM_TYPE_FIX or CAM_TYPE_PLANE)
void IsCollisionFix(Math::Vector &eye, Math::Vector lookat);
//! Adjusts the camera not to enter the ground
Math::Vector ExcludeTerrain(Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV);
//! Adjusts the camera not to enter an object
Math::Vector ExcludeObject(Math::Vector eye, Math::Vector lookat, float &angleH, float &angleV);
//! Specifies the location and direction of view
void SetViewParams(const Math::Vector &eye, const Math::Vector &lookat, const Math::Vector &up);
//! Advances the effect of the camera
void EffectFrame(const Event &event);
//! Advanced overlay effect in the foreground
void OverFrame(const Event &event);
/**
* \brief Updates the location and direction of the camera in the 3D engine
* \param eye Eye point
* \param lookat Lookat point
* \param up Up vector
* \see CEngine::SetViewParams
*/
void SetViewParams(const Math::Vector &eye, const Math::Vector &lookat, const Math::Vector &up = Math::Vector(0.0f, 1.0f, 0.0f));
/**
* \brief Calculate camera movement (from user inputs) to apply
@ -280,10 +303,10 @@ protected:
//! Type of smoothing
CameraSmooth m_smooth;
//! Object linked to the camera
CObject* m_cameraObj;
CObject* m_cameraObj;
//! Time of initial centering
float m_initDelay;
//! Remaining time of initial camera entry animation
float m_initDelay;
//! Current eye
Math::Vector m_actualEye;
@ -294,11 +317,11 @@ protected:
//! Final lookat
Math::Vector m_finalLookat;
//! Eye position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT
Math::Vector m_normEye;
Math::Vector m_prevEye;
//! Lookat position at the moment of entering CAM_TYPE_INFO/CAM_TYPE_VISIT
Math::Vector m_normLookat;
Math::Vector m_prevLookat;
float m_focus;
float m_focus;
//! CAM_TYPE_FREE: eye
Math::Vector m_eyePt;
@ -315,19 +338,18 @@ protected:
//! CAM_TYPE_BACK: distance
float m_backDist;
//! CAM_TYPE_BACK: distance minimal
//! CAM_TYPE_BACK: minimal distance
float m_backMin;
//! CAM_TYPE_BACK: additional direction
//! CAM_TYPE_BACK: additional horizontal direction
float m_addDirectionH;
//! CAM_TYPE_BACK: additional direction
//! CAM_TYPE_BACK: additional vertical direction
float m_addDirectionV;
bool m_transparency;
//! CAM_TYPE_FIX: distance
float m_fixDist;
//! CAM_TYPE_FIX: direction
//! CAM_TYPE_FIX: horizontal direction
float m_fixDirectionH;
//! CAM_TYPE_FIX: direction
//! CAM_TYPE_FIX: vertical direction
float m_fixDirectionV;
//! CAM_TYPE_VISIT: target position
@ -341,12 +363,13 @@ protected:
//! CAM_TYPE_VISIT: direction
float m_visitDirectionV;
float m_remotePan;
//! Last known mouse position, used to calculate change since last frame
Math::Point m_mousePos = Math::Point(0.5f, 0.5f);
//! Change of mouse position since last frame
Math::Point m_mouseDelta = Math::Point(0.0f, 0.0f);
//! Change of camera position caused by edge camera
Math::Point m_mouseDeltaEdge = Math::Point(0.0f, 0.0f);
//! Change of mouse wheel since last frame
float m_mouseWheelDelta = 0.0f;
CenteringPhase m_centeringPhase;
@ -376,19 +399,17 @@ protected:
Math::Vector m_scriptEye;
Math::Vector m_scriptLookat;
//! Shocks if explosion?
bool m_effect;
//! Blood?
bool m_blood;
//! Scroll in the edges?
bool m_oldCameraScroll;
//! X inversion in the edges?
bool m_cameraInvertX;
//! Y inversion in the edges?
bool m_cameraInvertY;
//! Is camera frozen?
bool m_freeze = false;
//! \name Configuration settings
//@{
bool m_effect;
bool m_blood;
bool m_oldCameraScroll;
bool m_cameraInvertX;
bool m_cameraInvertY;
//@}
};

View File

@ -18,7 +18,7 @@
*/
/**
* \file graphics/opengl/gldevice.h
* \file graphics/opengl/gl21device.h
* \brief OpenGL implementation - CGL21Device class
*/

View File

@ -95,9 +95,7 @@ bool CMainMovie::Start(MainMovieType type, float time)
m_camera->GetCamera(m_initialEye, m_initialLookat);
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
m_camera->SetSmooth(Gfx::CAM_SMOOTH_HARD);
m_camera->SetScriptEye(m_initialEye);
m_camera->SetScriptLookat(m_initialLookat);
m_camera->FixCamera();
m_camera->SetScriptCamera(m_initialEye, m_initialLookat);
mat = pObj->GetWorldMatrix(0);
m_finalLookat[0] = Math::Transform(*mat, Math::Vector( 1.6f, 1.0f, 1.2f));
@ -187,9 +185,7 @@ bool CMainMovie::EventProcess(const Event &event)
eye = (finalEye-initialEye)*progress+initialEye;
lookat = (finalLookat-initialLookat)*progress+initialLookat;
m_camera->SetScriptEye(eye);
m_camera->SetScriptLookat(lookat);
// m_camera->FixCamera();
m_camera->SetScriptCameraAnimate(eye, lookat);
}
else
{

View File

@ -239,9 +239,6 @@ CRobotMain::CRobotMain()
m_shotSaving = 0;
m_cameraPan = 0.0f;
m_cameraZoom = 0.0f;
m_build = 0;
m_researchDone.clear(); // no research done
m_researchDone[0] = 0;
@ -459,8 +456,6 @@ void CRobotMain::ChangePhase(Phase phase)
m_camera->SetType(Gfx::CAM_TYPE_NULL);
m_movie->Flush();
m_movieInfoIndex = -1;
m_cameraPan = 0.0f;
m_cameraZoom = 0.0f;
m_shortCut = true;
}
ClearInterface();
@ -677,7 +672,6 @@ bool CRobotMain::ProcessEvent(Event &event)
}
m_displayText->EventProcess(event);
RemoteCamera(m_cameraPan, m_cameraZoom, event.rTime);
if (m_displayInfo != nullptr) // current edition?
m_displayInfo->EventProcess(event);
@ -852,7 +846,6 @@ bool CRobotMain::ProcessEvent(Event &event)
{
auto data = event.GetData<KeyEventData>();
KeyCamera(event.type, data->slot);
HiliteClear();
if (m_editLock) // current edition?
{
@ -999,13 +992,6 @@ bool CRobotMain::ProcessEvent(Event &event)
break;
}
case EVENT_KEY_UP:
{
auto data = event.GetData<KeyEventData>();
KeyCamera(event.type, data->slot);
break;
}
case EVENT_MOUSE_BUTTON_DOWN:
{
if (event.GetData<MouseButtonEventData>()->button != MOUSE_BUTTON_LEFT) // only left mouse button
@ -1032,14 +1018,6 @@ bool CRobotMain::ProcessEvent(Event &event)
break;
}
case EVENT_MOUSE_BUTTON_UP:
if (event.GetData<MouseButtonEventData>()->button != MOUSE_BUTTON_LEFT) // only left mouse button
break;
m_cameraPan = 0.0f;
m_cameraZoom = 0.0f;
break;
case EVENT_OBJECT_LIMIT:
StartShowLimit();
break;
@ -1057,19 +1035,6 @@ bool CRobotMain::ProcessEvent(Event &event)
ChangeCamera();
break;
case EVENT_OBJECT_CAMERAleft:
m_cameraPan = -1.0f;
break;
case EVENT_OBJECT_CAMERAright:
m_cameraPan = 1.0f;
break;
case EVENT_OBJECT_CAMERAnear:
m_cameraZoom = -1.0f;
break;
case EVENT_OBJECT_CAMERAaway:
m_cameraZoom = 1.0f;
break;
case EVENT_OBJECT_DELETE:
m_ui->GetDialog()->StartQuestion(
RT_DIALOG_DELOBJ, true, false, false,
@ -1851,7 +1816,6 @@ void CRobotMain::SelectOneObject(CObject* obj, bool displayError)
type == OBJECT_APOLLO2 )
{
m_camera->SetType(dynamic_cast<CControllableObject*>(obj)->GetCameraType());
m_camera->SetDist(dynamic_cast<CControllableObject*>(obj)->GetCameraDist());
}
else
{
@ -2323,84 +2287,6 @@ void CRobotMain::ChangeCamera()
m_camera->SetType(type);
}
//! Remote control the camera using the arrow keys
void CRobotMain::KeyCamera(EventType event, InputSlot key)
{
if (event == EVENT_KEY_UP)
{
if (key == INPUT_SLOT_LEFT)
{
m_cameraPan = 0.0f;
}
if (key == INPUT_SLOT_RIGHT)
{
m_cameraPan = 0.0f;
}
if (key == INPUT_SLOT_UP)
{
m_cameraZoom = 0.0f;
}
if (key == INPUT_SLOT_DOWN)
{
m_cameraZoom = 0.0f;
}
}
if (m_phase != PHASE_SIMUL) return;
if (m_editLock) return; // current edition?
if (m_trainerPilot) return;
CObject* obj = GetSelect();
if (obj == nullptr) return;
assert(obj->Implements(ObjectInterfaceType::Controllable));
if (!dynamic_cast<CControllableObject*>(obj)->GetTrainer()) return;
if (event == EVENT_KEY_DOWN)
{
if (key == INPUT_SLOT_LEFT)
{
m_cameraPan = -1.0f;
}
if (key == INPUT_SLOT_RIGHT)
{
m_cameraPan = 1.0f;
}
if (key == INPUT_SLOT_UP)
{
m_cameraZoom = -1.0f;
}
if (key == INPUT_SLOT_DOWN)
{
m_cameraZoom = 1.0f;
}
}
}
//! Panned with the camera if a button is pressed
void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
{
if (pan != 0.0f)
{
float value = m_camera->GetRemotePan();
value += pan*rTime*1.5f;
m_camera->SetRemotePan(value);
}
if (zoom != 0.0f)
{
float value = m_camera->GetRemoteZoom();
value += zoom*rTime*0.3f;
m_camera->SetRemoteZoom(value);
}
}
//! Cancels the current movie
void CRobotMain::AbortMovie()
@ -3660,8 +3546,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (line->GetParam("fadeIn")->AsBool(false))
m_camera->StartOver(Gfx::CAM_OVER_EFFECT_FADEIN_WHITE, Math::Vector(0.0f, 0.0f, 0.0f), 1.0f);
m_camera->SetFixDirectionH(line->GetParam("fixDirection")->AsFloat(0.25f)*Math::PI);
continue;
}
@ -3822,7 +3706,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{
Math::Vector pos = sel->GetPosition();
m_camera->Init(pos, pos, 0.0f);
m_camera->FixCamera();
SelectObject(sel);
m_camera->SetControllingObject(sel);
@ -5971,9 +5854,6 @@ void CRobotMain::SetCodeBattleSpectatorMode(bool mode)
m_codeBattleSpectator = mode;
SelectObject(obj, false); // this uses code battle selection mode already
if (mode)
m_camera->SetFixDirectionV(-0.25f*Math::PI);
}
void CRobotMain::UpdateDebugCrashSpheres()

View File

@ -390,8 +390,6 @@ protected:
void ClearTooltip();
CObject* DetectObject(Math::Point pos);
void ChangeCamera();
void RemoteCamera(float pan, float zoom, float rTime);
void KeyCamera(EventType event, InputSlot key);
void AbortMovie();
void SelectOneObject(CObject* obj, bool displayError=true);
void HelpObject();
@ -535,9 +533,6 @@ protected:
std::vector<NewScriptName> m_newScriptName;
float m_cameraPan = 0.0f;
float m_cameraZoom = 0.0f;
EventType m_visitLast = EVENT_NULL;
CObject* m_visitObject = nullptr;
CObject* m_visitArrow = nullptr;

View File

@ -170,7 +170,6 @@ begin:
{
assert(pObj->Implements(ObjectInterfaceType::Controllable));
m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
m_camera->SetDist(dynamic_cast<CControllableObject*>(pObj)->GetCameraDist());
}
m_main->StartMusic();
@ -203,18 +202,17 @@ begin:
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos = m_pos;
pos.x -= 150.0f;
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
m_posSound = pos;
Math::Vector eye = m_pos;
eye.x -= 150.0f;
m_terrain->AdjustToFloor(eye);
eye.y += 10.0f;
pos = m_object->GetPosition();
pos.y += 300.0f+50.0f;
m_camera->SetScriptLookat(pos);
Math::Vector lookat = m_object->GetPosition();
lookat.y += 300.0f+50.0f;
m_camera->SetScriptCamera(eye, lookat);
m_posSound = eye;
m_camera->FixCamera();
m_engine->SetFocus(2.0f);
m_engine->SetFogStart(0.9f);
@ -266,9 +264,8 @@ begin:
pos.x += 1000.0f;
pos.z -= 60.0f;
pos.y += 80.0f;
m_camera->SetScriptEye(pos);
m_posSound = pos;
m_camera->FixCamera();
m_camera->SetScriptCamera(pos, Math::Vector(0.0f, 0.0f, 0.0f));
m_engine->SetFocus(1.0f);
BeginTransit();
@ -345,15 +342,15 @@ begin:
vibCir *= Math::Min(1.0f, (1.0f-m_progress)*3.0f);
m_object->SetCirVibration(vibCir);
pos = m_pos;
pos.x -= 150.0f;
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
Math::Vector eye = m_pos;
eye.x -= 150.0f;
m_terrain->AdjustToFloor(eye);
eye.y += 10.0f;
pos = m_object->GetPosition();
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
Math::Vector lookat = m_object->GetPosition();
lookat.y += 50.0f;
m_camera->SetScriptCameraAnimate(eye, lookat);
m_engine->SetFocus(1.0f+(1.0f-m_progress));
@ -494,7 +491,7 @@ begin:
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
pos.y += m_progress*40.0f;
m_camera->SetScriptEye(pos);
m_camera->SetScriptCameraAnimateEye(pos);
m_engine->SetFogStart(0.9f-(0.9f-m_fogStart)*m_progress);
}
@ -556,7 +553,7 @@ begin:
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
pos.y += m_progress*40.0f;
m_camera->SetScriptEye(pos);
m_camera->SetScriptCameraAnimateEye(pos);
m_engine->SetFogStart(0.9f-(0.9f-m_fogStart)*m_progress);
}
@ -598,7 +595,6 @@ begin:
{
assert(pObj->Implements(ObjectInterfaceType::Controllable));
m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
m_camera->SetDist(dynamic_cast<CControllableObject*>(pObj)->GetCameraDist());
}
m_sound->Play(SOUND_BOUM, m_object->GetPosition());
m_soundChannel = -1;
@ -749,15 +745,15 @@ begin:
vibCir.y = 0.0f;
m_object->SetCirVibration(vibCir);
pos = m_pos;
pos.x -= 110.0f+m_progress*250.0f;
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
Math::Vector eye = m_pos;
eye.x -= 110.0f+m_progress*250.0f;
m_terrain->AdjustToFloor(eye);
eye.y += 10.0f;
pos = m_object->GetPosition();
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
Math::Vector lookat = m_object->GetPosition();
lookat.y += 50.0f;
m_camera->SetScriptCameraAnimate(eye, lookat);
m_engine->SetFocus(1.0f+m_progress);
@ -907,7 +903,7 @@ begin:
pos.x += event.rTime*(2000.0f/BASE_TRANSIT_TIME);
m_object->SetPosition(pos);
pos.x += 60.0f;
m_camera->SetScriptLookat(pos);
m_camera->SetScriptCameraAnimateLookat(pos);
}
else
{
@ -1129,7 +1125,6 @@ bool CAutoBase::Abort()
{
assert(pObj->Implements(ObjectInterfaceType::Controllable));
m_camera->SetType(dynamic_cast<CControllableObject*>(pObj)->GetCameraType());
m_camera->SetDist(dynamic_cast<CControllableObject*>(pObj)->GetCameraDist());
}
m_engine->SetFogStart(m_fogStart);
@ -1387,16 +1382,16 @@ Error CAutoBase::TakeOff(bool printMsg)
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
Math::Vector pos = m_pos;
pos.x -= 110.0f;
m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
m_posSound = pos;
Math::Vector eye = m_pos;
eye.x -= 110.0f;
m_terrain->AdjustToFloor(eye);
eye.y += 10.0f;
pos = m_object->GetPosition();
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
Math::Vector lookat = m_object->GetPosition();
lookat.y += 50.0f;
m_camera->SetScriptCameraAnimate(eye, lookat);
m_posSound = eye;
m_engine->SetFocus(1.0f);

View File

@ -164,19 +164,17 @@ bool CAutoPortico::EventProcess(const Event &event)
m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos = m_startPos;
pos.x += -100.0f;
pos.y += 9.0f;
pos.z += -200.0f;
m_camera->SetScriptEye(pos);
Math::Vector eye = m_startPos;
eye.x += -100.0f;
eye.y += 9.0f;
eye.z += -200.0f;
pos = m_object->GetPosition();
pos.x += 0.0f;
pos.y += 10.0f;
pos.z += -40.0f;
m_camera->SetScriptLookat(pos);
Math::Vector lookat = m_object->GetPosition();
lookat.x += 0.0f;
lookat.y += 10.0f;
lookat.z += -40.0f;
m_camera->FixCamera();
m_camera->SetScriptCamera(eye, lookat);
}
}
@ -329,23 +327,20 @@ bool CAutoPortico::EventProcess(const Event &event)
if ( m_cameraProgress < 1.0f )
{
if ( m_cameraProgress < 0.5f )
{
}
else
if ( m_cameraProgress >= 0.5f )
{
pos = m_startPos;
pos.x += -100.0f-(m_cameraProgress-0.5f)*1.0f*120.0f;
pos.y += 9.0f;
pos.z += -200.0f+(m_cameraProgress-0.5f)*1.0f*210.0f;
m_camera->SetScriptEye(pos);
m_camera->SetScriptCameraAnimateEye(pos);
}
pos = m_object->GetPosition();
pos.x += 0.0f;
pos.y += 10.0f;
pos.z += -40.0f;
m_camera->SetScriptLookat(pos);
m_camera->SetScriptCameraAnimateLookat(pos);
}
return true;

View File

@ -58,10 +58,6 @@ public:
virtual void SetCameraType(Gfx::CameraType type) = 0;
//! Return camera type for this object
virtual Gfx::CameraType GetCameraType() = 0;
//! Set camera distance for this object
virtual void SetCameraDist(float dist) = 0;
//! Return camera distance for this object
virtual float GetCameraDist() = 0;
//! Disallow camera changes
virtual void SetCameraLock(bool lock) = 0;
//! Check if camera changes are disallowed

View File

@ -150,7 +150,6 @@ COldObject::COldObject(int id)
m_character.wheelRight = 1.0f;
m_cameraType = Gfx::CAM_TYPE_BACK;
m_cameraDist = 50.0f;
m_bCameraLock = false;
for (int i=0 ; i<OBJECTMAXPART ; i++ )
@ -1031,7 +1030,6 @@ void COldObject::Read(CLevelParserLine* line)
if (line->GetParam("camera")->IsDefined())
SetCameraType(line->GetParam("camera")->AsCameraType());
SetCameraDist(line->GetParam("cameraDist")->AsFloat(50.0f));
SetCameraLock(line->GetParam("cameraLock")->AsBool(false));
if (line->GetParam("pyro")->IsDefined())
@ -2499,16 +2497,6 @@ Gfx::CameraType COldObject::GetCameraType()
return m_cameraType;
}
void COldObject::SetCameraDist(float dist)
{
m_cameraDist = dist;
}
float COldObject::GetCameraDist()
{
return m_cameraDist;
}
void COldObject::SetCameraLock(bool lock)
{
m_bCameraLock = lock;

View File

@ -218,8 +218,6 @@ public:
void SetCameraType(Gfx::CameraType type) override;
Gfx::CameraType GetCameraType() override;
void SetCameraDist(float dist) override;
float GetCameraDist() override;
void SetCameraLock(bool lock) override;
bool GetCameraLock() override;
@ -351,7 +349,6 @@ protected:
float m_gunGoalV;
float m_gunGoalH;
Gfx::CameraType m_cameraType;
float m_cameraDist;
bool m_bCameraLock;
float m_magnifyDamage;

View File

@ -1324,26 +1324,6 @@ bool CObjectInterface::CreateInterface(bool bSelect)
}
}
if ( m_object->GetToy() && !m_object->GetManual() )
{
pos.x = ox+sx*9.0f;
pos.y = oy+sy*0;
pb = pw->CreateButton(pos, dim, 55, EVENT_OBJECT_CAMERAleft);
pb->SetImmediat(true);
pos.x = ox+sx*11.0f;
pos.y = oy+sy*0;
pb = pw->CreateButton(pos, dim, 48, EVENT_OBJECT_CAMERAright);
pb->SetImmediat(true);
pos.x = ox+sx*10.0f;
pos.y = oy+sy*1;
pb = pw->CreateButton(pos, dim, 49, EVENT_OBJECT_CAMERAnear);
pb->SetImmediat(true);
pos.x = ox+sx*10.0f;
pos.y = oy+sy*0;
pb = pw->CreateButton(pos, dim, 50, EVENT_OBJECT_CAMERAaway);
pb->SetImmediat(true);
}
pos.x = ox+sx*13.4f;
pos.y = oy+sy*0;
if ( m_object->GetTrainer() ) // Training?

View File

@ -619,21 +619,17 @@ void CScreenApperance::CameraPerso()
{
Gfx::CCamera* camera = m_main->GetCamera();
camera->SetType(Gfx::CAM_TYPE_SCRIPT);
if ( m_apperanceTab == 0 )
{
//? camera->Init(Math::Vector(4.0f, 0.0f, 0.0f),
//? Math::Vector(0.0f, 0.0f, 1.0f), 0.0f);
camera->Init(Math::Vector(6.0f, 0.0f, 0.0f),
Math::Vector(0.0f, 0.2f, 1.5f), 0.0f);
camera->SetScriptCamera(Math::Vector(6.0f, 0.0f, 0.0f),
Math::Vector(0.0f, 0.2f, 1.5f));
}
else
{
camera->Init(Math::Vector(18.0f, 0.0f, 4.5f),
Math::Vector(0.0f, 1.6f, 4.5f), 0.0f);
camera->SetScriptCamera(Math::Vector(18.0f, 0.0f, 4.5f),
Math::Vector(0.0f, 1.6f, 4.5f));
}
camera->SetType(Gfx::CAM_TYPE_SCRIPT);
camera->FixCamera();
}
// Sets a fixed color.