mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Implement Hor+ FOVs
This commit is contained in:
@ -1578,11 +1578,8 @@ bool plClient::StartInit()
|
|||||||
fNewCamera->Init();
|
fNewCamera->Init();
|
||||||
fNewCamera->SetPipeline( GetPipeline() );
|
fNewCamera->SetPipeline( GetPipeline() );
|
||||||
|
|
||||||
float aspectratio = (float)fPipeline->Width() / (float)fPipeline->Height();
|
plVirtualCam1::Refresh();
|
||||||
plVirtualCam1::SetAspectRatio(aspectratio);
|
pfGameGUIMgr::GetInstance()->SetAspectRatio( (float)fPipeline->Width() / (float)fPipeline->Height() );
|
||||||
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
|
|
||||||
|
|
||||||
pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio );
|
|
||||||
plMouseDevice::Instance()->SetDisplayResolution((float)fPipeline->Width(), (float)fPipeline->Height());
|
plMouseDevice::Instance()->SetDisplayResolution((float)fPipeline->Width(), (float)fPipeline->Height());
|
||||||
plInputManager::SetRecenterMouse(false);
|
plInputManager::SetRecenterMouse(false);
|
||||||
|
|
||||||
|
@ -177,18 +177,32 @@ void plCameraBrain1::Pop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the goal to which we want to animate the fov
|
// set the goal to which we want to animate the fov
|
||||||
void plCameraBrain1::SetFOVGoal(float h, double t)
|
void plCameraBrain1::SetFOVGoal(float w, float h, double t)
|
||||||
{
|
{
|
||||||
if (fFOVGoal == h || h == fCamera->GetFOVh())
|
if (fFOVhGoal == h || h == fCamera->GetFOVh() &&
|
||||||
|
fFOVwGoal == w || w == fCamera->GetFOVw())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float dif = h - fCamera->GetFOVh();
|
|
||||||
fFOVAnimRate = dif / ((float)t);
|
|
||||||
|
|
||||||
fFOVGoal = h;
|
float dif = h - fCamera->GetFOVh();
|
||||||
|
fFOVhAnimRate = dif / ((float)t);
|
||||||
|
|
||||||
|
fFOVhGoal = h;
|
||||||
fFOVStartTime = hsTimer::GetSysSeconds();
|
fFOVStartTime = hsTimer::GetSysSeconds();
|
||||||
fFOVEndTime = fFOVStartTime + t;
|
fFOVEndTime = fFOVStartTime + t;
|
||||||
|
|
||||||
|
if (w == 0.f)
|
||||||
|
{
|
||||||
|
fFOVwGoal = IMakeFOVwZoom(h);
|
||||||
|
dif = fFOVwGoal - fCamera->GetFOVw();
|
||||||
|
fFOVwAnimRate = dif / ((float)t);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dif = w - fCamera->GetFOVw();
|
||||||
|
fFOVwAnimRate = dif / ((float)t);
|
||||||
|
fFOVwGoal = w;
|
||||||
|
}
|
||||||
|
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,20 +255,25 @@ void plCameraBrain1::Update(bool forced)
|
|||||||
// adjust FOV based on elapsed time
|
// adjust FOV based on elapsed time
|
||||||
void plCameraBrain1::IAnimateFOV(double time)
|
void plCameraBrain1::IAnimateFOV(double time)
|
||||||
{
|
{
|
||||||
float dH = fFOVAnimRate * hsTimer::GetDelSysSeconds();
|
float dH = fFOVhAnimRate * hsTimer::GetDelSysSeconds();
|
||||||
|
float dW = fFOVwAnimRate * hsTimer::GetDelSysSeconds();
|
||||||
dH += fCamera->GetFOVh();
|
dH += fCamera->GetFOVh();
|
||||||
|
dW += fCamera->GetFOVw();
|
||||||
|
|
||||||
if ( (fFOVAnimRate < 0.0f && dH <= fFOVGoal) ||
|
if ( (fFOVhAnimRate < 0.0f && dH <= fFOVhGoal) ||
|
||||||
(fFOVAnimRate > 0.0f && dH >= fFOVGoal) )
|
(fFOVhAnimRate > 0.0f && dH >= fFOVhGoal) )
|
||||||
{
|
{
|
||||||
fFlags.ClearBit(kAnimateFOV);
|
dH = fFOVhGoal;
|
||||||
dH = fFOVGoal;
|
}
|
||||||
|
if ( (fFOVwAnimRate < 0.0f && dW <= fFOVwGoal) ||
|
||||||
|
(fFOVwAnimRate > 0.0f && dW >= fFOVwGoal) )
|
||||||
|
{
|
||||||
|
dW = fFOVwGoal;
|
||||||
}
|
}
|
||||||
|
|
||||||
fCamera->SetFOVw( (float)(dH * plVirtualCam1::Instance()->GetAspectRatio()) );
|
if (dW == fFOVwGoal && dH == fFOVhGoal)
|
||||||
fCamera->SetFOVh( dH );
|
fFlags.ClearBit(kAnimateFOV);
|
||||||
|
fCamera->SetFOV( dW, dH );
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the camera's origin point (not where it is looking) toward where it is going
|
// move the camera's origin point (not where it is looking) toward where it is going
|
||||||
@ -262,7 +281,7 @@ void plCameraBrain1::IMoveTowardGoal(double elapsedTime)
|
|||||||
{
|
{
|
||||||
bool current = plVirtualCam1::Instance()->IsCurrentCamera(GetCamera());
|
bool current = plVirtualCam1::Instance()->IsCurrentCamera(GetCamera());
|
||||||
|
|
||||||
if (fFlags.IsBitSet(kCutPos) || fFlags.IsBitSet(kNonPhys) || !current)
|
if (fFlags.IsBitSet(kCutPos) || fFlags.IsBitSet(kNonPhys) || !current)
|
||||||
{
|
{
|
||||||
fCamera->SetTargetPos(fGoal);
|
fCamera->SetTargetPos(fGoal);
|
||||||
return;
|
return;
|
||||||
@ -280,12 +299,12 @@ void plCameraBrain1::IMoveTowardGoal(double elapsedTime)
|
|||||||
//smooth out stoppage...
|
//smooth out stoppage...
|
||||||
float adjMaxVel = fVelocity;
|
float adjMaxVel = fVelocity;
|
||||||
if (distToGoal <= 5.0f && distToGoal > 0.1f)
|
if (distToGoal <= 5.0f && distToGoal > 0.1f)
|
||||||
{
|
{
|
||||||
float mult = (distToGoal - 5.0f)*0.1f;
|
float mult = (distToGoal - 5.0f)*0.1f;
|
||||||
adjMaxVel = fVelocity - hsABS(fVelocity*mult);
|
adjMaxVel = fVelocity - hsABS(fVelocity*mult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (distToGoal > 0.0f)
|
if (distToGoal > 0.0f)
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
|
|
||||||
@ -536,6 +555,14 @@ void plCameraBrain1::Write(hsStream* stream, hsResMgr* mgr)
|
|||||||
stream->WriteLEFloat(fZoomMin);
|
stream->WriteLEFloat(fZoomMin);
|
||||||
stream->WriteLEFloat(fZoomMax);
|
stream->WriteLEFloat(fZoomMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float plCameraBrain1::IMakeFOVwZoom(float fovH) const
|
||||||
|
{
|
||||||
|
float num = tan(hsDegreesToRadians(fovH / 2)) * tan(hsDegreesToRadians(fCamera->GetFOVw() / 2));
|
||||||
|
float denom = tan(hsDegreesToRadians(fCamera->GetFOVh() / 2));
|
||||||
|
return 2 * hsABS(hsRadiansToDegrees(atan(num / denom)));
|
||||||
|
}
|
||||||
|
|
||||||
bool plCameraBrain1::MsgReceive(plMessage* msg)
|
bool plCameraBrain1::MsgReceive(plMessage* msg)
|
||||||
{
|
{
|
||||||
plCameraMsg* pCamMsg = plCameraMsg::ConvertNoRef(msg);
|
plCameraMsg* pCamMsg = plCameraMsg::ConvertNoRef(msg);
|
||||||
@ -544,16 +571,18 @@ bool plCameraBrain1::MsgReceive(plMessage* msg)
|
|||||||
if (pCamMsg->Cmd(plCameraMsg::kStartZoomIn))
|
if (pCamMsg->Cmd(plCameraMsg::kStartZoomIn))
|
||||||
{
|
{
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
fFOVGoal = fZoomMin;
|
fFOVhGoal = fZoomMin;
|
||||||
fFOVAnimRate = -1*fZoomRate;
|
fFOVwGoal = IMakeFOVwZoom(fZoomMin);
|
||||||
|
fFOVwAnimRate = fFOVhAnimRate = -1*fZoomRate;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (pCamMsg->Cmd(plCameraMsg::kStartZoomOut))
|
if (pCamMsg->Cmd(plCameraMsg::kStartZoomOut))
|
||||||
{
|
{
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
fFOVGoal = fZoomMax;
|
fFOVhGoal = fZoomMax;
|
||||||
fFOVAnimRate = fZoomRate;
|
fFOVwGoal = IMakeFOVwZoom(fZoomMax);
|
||||||
|
fFOVwAnimRate = fFOVhAnimRate = fZoomRate;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -637,8 +666,9 @@ bool plCameraBrain1::MsgReceive(plMessage* msg)
|
|||||||
if (pCMsg->GetControlCode() == B_CAMERA_ZOOM_IN && fFlags.IsBitSet(kZoomEnabled))
|
if (pCMsg->GetControlCode() == B_CAMERA_ZOOM_IN && fFlags.IsBitSet(kZoomEnabled))
|
||||||
{
|
{
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
fFOVGoal = fZoomMin;
|
fFOVhGoal = fZoomMin;
|
||||||
fFOVAnimRate = -1*fZoomRate;
|
fFOVwGoal = IMakeFOVwZoom(fZoomMin);
|
||||||
|
fFOVwAnimRate = fFOVhAnimRate = -1*fZoomRate;
|
||||||
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -646,8 +676,9 @@ bool plCameraBrain1::MsgReceive(plMessage* msg)
|
|||||||
if (pCMsg->GetControlCode() == B_CAMERA_ZOOM_OUT && fFlags.IsBitSet(kZoomEnabled))
|
if (pCMsg->GetControlCode() == B_CAMERA_ZOOM_OUT && fFlags.IsBitSet(kZoomEnabled))
|
||||||
{
|
{
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
fFOVGoal = fZoomMax;
|
fFOVhGoal = fZoomMax;
|
||||||
fFOVAnimRate = fZoomRate;
|
fFOVwGoal = IMakeFOVwZoom(fZoomMin);
|
||||||
|
fFOVwAnimRate = fFOVhAnimRate = fZoomRate;
|
||||||
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -657,11 +688,12 @@ bool plCameraBrain1::MsgReceive(plMessage* msg)
|
|||||||
if (fFlags.IsBitSet(kZoomEnabled))
|
if (fFlags.IsBitSet(kZoomEnabled))
|
||||||
{
|
{
|
||||||
fFlags.SetBit(kAnimateFOV);
|
fFlags.SetBit(kAnimateFOV);
|
||||||
fFOVGoal = fZoomMin + ((fZoomMax - fZoomMin) / 2);
|
fFOVhGoal = fZoomMin + ((fZoomMax - fZoomMin) / 2);
|
||||||
if (fCamera->GetFOVw() >= fFOVGoal)
|
fFOVwGoal = IMakeFOVwZoom(fFOVhGoal);
|
||||||
fFOVAnimRate = -1*fZoomRate;
|
if (fCamera->GetFOVh() >= fFOVhGoal)
|
||||||
|
fFOVwAnimRate = fFOVhAnimRate = -1*fZoomRate;
|
||||||
else
|
else
|
||||||
fFOVAnimRate = fZoomRate;
|
fFOVwAnimRate = fFOVhAnimRate = fZoomRate;
|
||||||
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
fFOVEndTime = hsTimer::GetSysSeconds() + 60;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
|
|
||||||
void SetGoal(hsPoint3 pt) { fGoal = pt; }
|
void SetGoal(hsPoint3 pt) { fGoal = pt; }
|
||||||
void SetPOAGoal(hsPoint3 pt) { fPOAGoal = pt; }
|
void SetPOAGoal(hsPoint3 pt) { fPOAGoal = pt; }
|
||||||
void SetFOVGoal(float h, double t);
|
void SetFOVGoal(float w, float h, double t);
|
||||||
void SetZoomParams(float max, float min, float rate);
|
void SetZoomParams(float max, float min, float rate);
|
||||||
|
|
||||||
void SetXPanLimit(float x) {fXPanLimit = x;}
|
void SetXPanLimit(float x) {fXPanLimit = x;}
|
||||||
@ -173,16 +173,17 @@ protected:
|
|||||||
void IMoveTowardGoal(double time);
|
void IMoveTowardGoal(double time);
|
||||||
void IPointTowardGoal(double time);
|
void IPointTowardGoal(double time);
|
||||||
void IAnimateFOV(double time);
|
void IAnimateFOV(double time);
|
||||||
void IAdjustVelocity(float adjAccelRate,
|
void IAdjustVelocity(float adjAccelRate,
|
||||||
float adjDecelRate,
|
float adjDecelRate,
|
||||||
hsVector3* dir,
|
hsVector3* dir,
|
||||||
hsVector3* vel,
|
hsVector3* vel,
|
||||||
float maxSpeed,
|
float maxSpeed,
|
||||||
float distToGoal,
|
float distToGoal,
|
||||||
double elapsedTime);
|
double elapsedTime);
|
||||||
|
|
||||||
float IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime);
|
float IClampVelocity(hsVector3* vel, float maxSpeed, double elapsedTime);
|
||||||
bool IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal);
|
bool IShouldDecelerate(float decelSpeed, float curSpeed, float distToGoal);
|
||||||
|
float IMakeFOVwZoom(float fovH) const;
|
||||||
|
|
||||||
plCameraModifier1* fCamera;
|
plCameraModifier1* fCamera;
|
||||||
plKey fSubjectKey;
|
plKey fSubjectKey;
|
||||||
@ -197,25 +198,25 @@ protected:
|
|||||||
float fPOAVelocity;
|
float fPOAVelocity;
|
||||||
float fPOAAccel;
|
float fPOAAccel;
|
||||||
float fPOADecel;
|
float fPOADecel;
|
||||||
hsVector3 fPOAOffset;
|
hsVector3 fPOAOffset;
|
||||||
hsPoint3 fGoal;
|
hsPoint3 fGoal;
|
||||||
hsPoint3 fPOAGoal;
|
hsPoint3 fPOAGoal;
|
||||||
float fXPanLimit;
|
float fXPanLimit;
|
||||||
float fZPanLimit;
|
float fZPanLimit;
|
||||||
float fPanSpeed;
|
float fPanSpeed;
|
||||||
float fFOVGoal;
|
float fFOVwGoal, fFOVhGoal;
|
||||||
double fFOVStartTime;
|
double fFOVStartTime;
|
||||||
double fFOVEndTime;
|
double fFOVEndTime;
|
||||||
float fFOVAnimRate;
|
float fFOVwAnimRate, fFOVhAnimRate;
|
||||||
float fZoomRate;
|
float fZoomRate;
|
||||||
float fZoomMax;
|
float fZoomMax;
|
||||||
float fZoomMin;
|
float fZoomMin;
|
||||||
hsBitVector fMoveFlags;
|
hsBitVector fMoveFlags;
|
||||||
hsBitVector fFlags;
|
hsBitVector fFlags;
|
||||||
hsMatrix44 fTargetMatrix;
|
hsMatrix44 fTargetMatrix;
|
||||||
float fOffsetLength;
|
float fOffsetLength;
|
||||||
float fOffsetPct;
|
float fOffsetPct;
|
||||||
double fFallTimer;
|
double fFallTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class plControlEventMsg;
|
class plControlEventMsg;
|
||||||
|
@ -135,20 +135,28 @@ plSceneObject* plCameraModifier1::GetSubject()
|
|||||||
return GetBrain()->GetSubject();
|
return GetBrain()->GetSubject();
|
||||||
else
|
else
|
||||||
return fSubObj;
|
return fSubObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void plCameraModifier1::SetFOV(float w, float h, bool fUpdateVCam)
|
||||||
|
{
|
||||||
|
fFOVw = w;
|
||||||
|
fFOVh = h;
|
||||||
|
if (plVirtualCam1::Instance() && fUpdateVCam)
|
||||||
|
plVirtualCam1::SetFOV(this);
|
||||||
|
}
|
||||||
|
|
||||||
void plCameraModifier1::SetFOVw(float f, bool fUpdateVCam)
|
void plCameraModifier1::SetFOVw(float f, bool fUpdateVCam)
|
||||||
{
|
{
|
||||||
fFOVw = f;
|
fFOVw = f;
|
||||||
if (plVirtualCam1::Instance() && fUpdateVCam)
|
if (plVirtualCam1::Instance() && fUpdateVCam)
|
||||||
plVirtualCam1::SetFOV(fFOVw, fFOVh, this);
|
plVirtualCam1::SetFOV(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plCameraModifier1::SetFOVh(float f, bool fUpdateVCam)
|
void plCameraModifier1::SetFOVh(float f, bool fUpdateVCam)
|
||||||
{
|
{
|
||||||
fFOVh = f;
|
fFOVh = f;
|
||||||
if (plVirtualCam1::Instance() && fUpdateVCam)
|
if (plVirtualCam1::Instance() && fUpdateVCam)
|
||||||
plVirtualCam1::SetFOV(fFOVw, fFOVh, this);
|
plVirtualCam1::SetFOV(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool plCameraModifier1::SetFaded(bool b)
|
bool plCameraModifier1::SetFaded(bool b)
|
||||||
@ -192,8 +200,9 @@ bool plCameraModifier1::MsgReceive(plMessage* msg)
|
|||||||
double time2 = (double)pEventMsg->fEventTime;
|
double time2 = (double)pEventMsg->fEventTime;
|
||||||
time = hsABS(time - time2);
|
time = hsABS(time - time2);
|
||||||
float h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh;
|
float h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh;
|
||||||
|
float w = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVw;
|
||||||
if (GetBrain())
|
if (GetBrain())
|
||||||
GetBrain()->SetFOVGoal(h, time);
|
GetBrain()->SetFOVGoal(w, h, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
plAnimCmdMsg* pAnimMsg = plAnimCmdMsg::ConvertNoRef(msg);
|
plAnimCmdMsg* pAnimMsg = plAnimCmdMsg::ConvertNoRef(msg);
|
||||||
|
@ -128,8 +128,9 @@ public:
|
|||||||
void SetTargetPOA(hsPoint3 pos) { fAt = pos; }
|
void SetTargetPOA(hsPoint3 pos) { fAt = pos; }
|
||||||
void SetSubworldPos(hsPoint3 pos) { fLastSubPos = pos; }
|
void SetSubworldPos(hsPoint3 pos) { fLastSubPos = pos; }
|
||||||
void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; }
|
void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; }
|
||||||
float GetFOVw() { return fFOVw; }
|
float GetFOVw() const { return fFOVw; }
|
||||||
float GetFOVh() { return fFOVh; }
|
float GetFOVh() const { return fFOVh; }
|
||||||
|
void SetFOV(float w, float h, bool fUpdateVCam = true);
|
||||||
void SetFOVw(float f, bool fUpdateVCam = true);
|
void SetFOVw(float f, bool fUpdateVCam = true);
|
||||||
void SetFOVh(float f, bool fUpdateVCam = true);
|
void SetFOVh(float f, bool fUpdateVCam = true);
|
||||||
bool GetInSubworld() { return fInSubLastUpdate; }
|
bool GetInSubworld() { return fInSubLastUpdate; }
|
||||||
|
@ -88,25 +88,22 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include "hsGeometry3.h"
|
#include "hsGeometry3.h"
|
||||||
#include "hsQuat.h"
|
#include "hsQuat.h"
|
||||||
|
|
||||||
float plVirtualCam1::fFOVw = 45.0f;
|
float plVirtualCam1::fFOVw = 45.0f;
|
||||||
float plVirtualCam1::fFOVh = 33.75f;
|
float plVirtualCam1::fFOVh = 33.75f;
|
||||||
float plVirtualCam1::fHither = 0.3f;
|
float plVirtualCam1::fAspectRatio = 4.f/3.f;
|
||||||
float plVirtualCam1::fYon = 500.0f;
|
float plVirtualCam1::fHither = 0.3f;
|
||||||
bool plVirtualCam1::printFOV = false;
|
float plVirtualCam1::fYon = 500.0f;
|
||||||
bool plVirtualCam1::fUseAccelOverride = 1;
|
bool plVirtualCam1::printFOV = false;
|
||||||
bool plVirtualCam1::freeze = 0;
|
bool plVirtualCam1::fUseAccelOverride = 1;
|
||||||
//float plVirtualCam1::fAccel = 5.0f;
|
bool plVirtualCam1::freeze = 0;
|
||||||
//float plVirtualCam1::fDecel = 5.0f;
|
float plVirtualCam1::fAccel = 50.0f;
|
||||||
//float plVirtualCam1::fVel = 10.0f;
|
float plVirtualCam1::fDecel = 50.0f;
|
||||||
float plVirtualCam1::fAccel = 50.0f;
|
float plVirtualCam1::fVel = 100.0f;
|
||||||
float plVirtualCam1::fDecel = 50.0f;
|
float plVirtualCam1::fPanResponseTime = 3.0f;
|
||||||
float plVirtualCam1::fVel = 100.0f;
|
float plVirtualCam1::fFallTimerDelay = 0.25f;
|
||||||
float plVirtualCam1::fPanResponseTime = 3.0f;
|
bool plVirtualCam1::alwaysCutForColin = false;
|
||||||
float plVirtualCam1::fFallTimerDelay = 0.25f;
|
bool plVirtualCam1::WalkPan3rdPerson = false;
|
||||||
bool plVirtualCam1::alwaysCutForColin = false;
|
bool plVirtualCam1::StayInFirstPersonForever = false;
|
||||||
bool plVirtualCam1::WalkPan3rdPerson = false;
|
|
||||||
bool plVirtualCam1::StayInFirstPersonForever = false;
|
|
||||||
float plVirtualCam1::fAspectRatio = fFOVw / fFOVh;
|
|
||||||
|
|
||||||
// #define STATUS_LOG
|
// #define STATUS_LOG
|
||||||
|
|
||||||
@ -269,7 +266,7 @@ void plVirtualCam1::RebuildStack(const plKey& key)
|
|||||||
pMsg->AddReceiver(plNetClientMgr::GetInstance()->GetLocalPlayerKey());
|
pMsg->AddReceiver(plNetClientMgr::GetInstance()->GetLocalPlayerKey());
|
||||||
plgDispatch::MsgSend(pMsg);
|
plgDispatch::MsgSend(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
fForceCutOnce=true;
|
fForceCutOnce=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -286,54 +283,43 @@ void plVirtualCam1::SetOffset(float x, float y, float z)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static function
|
// static function
|
||||||
void plVirtualCam1::SetFOV(float x, float y)
|
void plVirtualCam1::SetFOV(float w, float h)
|
||||||
{
|
{
|
||||||
|
static float fourXthree = (4.f/3.f);
|
||||||
|
|
||||||
float fovW = y * fAspectRatio;
|
fFOVh = h;
|
||||||
|
if (fAspectRatio == fourXthree)
|
||||||
fFOVw = fovW;
|
fFOVw = w;
|
||||||
fFOVh = y;
|
else
|
||||||
|
{
|
||||||
if (! plVirtualCam1::Instance()->fPipe)
|
float scale = fAspectRatio / fourXthree;
|
||||||
return;
|
fFOVw = 2 * hsRadiansToDegrees(atan(scale * tan(hsDegreesToRadians(w/2))));
|
||||||
|
}
|
||||||
plVirtualCam1::Instance()->SetFlags(plVirtualCam1::kSetFOV);
|
plVirtualCam1::Instance()->SetFlags(plVirtualCam1::kSetFOV);
|
||||||
|
|
||||||
#ifdef STATUS_LOG
|
|
||||||
if (printFOV)
|
|
||||||
camLog->AddLineF("FOV changed by console command to %f", fFOVw);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// static function
|
// static function
|
||||||
void plVirtualCam1::SetFOV(float x, float y, plCameraModifier1* pCam)
|
void plVirtualCam1::SetFOV(plCameraModifier1* pCam)
|
||||||
{
|
{
|
||||||
if (plVirtualCam1::Instance()->GetCurrentCamera() != pCam)
|
if (plVirtualCam1::Instance()->GetCurrentCamera() != pCam)
|
||||||
return;
|
return;
|
||||||
|
SetFOV(pCam->GetFOVw(), pCam->GetFOVh());
|
||||||
|
}
|
||||||
|
|
||||||
float diff = hsABS(fFOVw - x);
|
void plVirtualCam1::Refresh()
|
||||||
if (diff > 10.0f)
|
{
|
||||||
{
|
plPipeline* pipe = plVirtualCam1::Instance()->fPipe;
|
||||||
#ifdef STATUS_LOG
|
SetAspectRatio((float)pipe->Width() / (float)pipe->Height());
|
||||||
camLog->AddLineF("Radical FOV change of %f", diff);
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
void plVirtualCam1::SetAspectRatio(float ratio)
|
||||||
|
{
|
||||||
|
fAspectRatio = ratio;
|
||||||
|
|
||||||
float fovW = y * fAspectRatio;
|
// resize the FOV accordingly
|
||||||
|
plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCurrentCamera();
|
||||||
fFOVw = fovW;
|
hsAssert(pCam, "CameraModifier1 shouldn't be nullptr?");
|
||||||
fFOVh = y;
|
if (pCam)
|
||||||
|
SetFOV(pCam->GetFOVw(), pCam->GetFOVh());
|
||||||
if (! plVirtualCam1::Instance()->fPipe)
|
|
||||||
return;
|
|
||||||
|
|
||||||
plVirtualCam1::Instance()->SetFlags(plVirtualCam1::kSetFOV);
|
|
||||||
|
|
||||||
#ifdef STATUS_LOG
|
|
||||||
if (printFOV)
|
|
||||||
camLog->AddLineF("FOV changed to %f", fFOVw);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static function
|
// static function
|
||||||
@ -913,7 +899,7 @@ void plVirtualCam1::FirstPersonOverride()
|
|||||||
#ifdef STATUS_LOG
|
#ifdef STATUS_LOG
|
||||||
camLog->AddLineF("Built-In First Person Camera Disabled");
|
camLog->AddLineF("Built-In First Person Camera Disabled");
|
||||||
#endif
|
#endif
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
GetCurrentStackCamera()->Push(!HasFlags(kAvatarWalking));
|
GetCurrentStackCamera()->Push(!HasFlags(kAvatarWalking));
|
||||||
plAvatarInputInterface::GetInstance()->CameraInThirdPerson(true);
|
plAvatarInputInterface::GetInstance()->CameraInThirdPerson(true);
|
||||||
FreezeOutput(2);
|
FreezeOutput(2);
|
||||||
@ -938,7 +924,7 @@ void plVirtualCam1::FirstPersonOverride()
|
|||||||
fFirstPersonOverride = (plCameraModifier1*)pKey->GetObjectPtr();
|
fFirstPersonOverride = (plCameraModifier1*)pKey->GetObjectPtr();
|
||||||
GetCurrentStackCamera()->Pop();
|
GetCurrentStackCamera()->Pop();
|
||||||
fFirstPersonOverride->Push(!HasFlags(kAvatarWalking));
|
fFirstPersonOverride->Push(!HasFlags(kAvatarWalking));
|
||||||
SetFOV(fFirstPersonOverride->GetFOVw(), fFirstPersonOverride->GetFOVh(), fFirstPersonOverride);
|
SetFOV(fFirstPersonOverride);
|
||||||
plAvatarInputInterface::GetInstance()->CameraInThirdPerson(false);
|
plAvatarInputInterface::GetInstance()->CameraInThirdPerson(false);
|
||||||
// no need to keep transitioning if we are currently...
|
// no need to keep transitioning if we are currently...
|
||||||
if (fTransPos == POS_TRANS_FOLLOW)
|
if (fTransPos == POS_TRANS_FOLLOW)
|
||||||
@ -1178,12 +1164,12 @@ bool plVirtualCam1::MsgReceive(plMessage* msg)
|
|||||||
#endif
|
#endif
|
||||||
if (fFirstPersonOverride)
|
if (fFirstPersonOverride)
|
||||||
{
|
{
|
||||||
SetFOV(fFirstPersonOverride->GetFOVw(), fFirstPersonOverride->GetFOVh(), fFirstPersonOverride);
|
SetFOV(fFirstPersonOverride);
|
||||||
fFirstPersonOverride->Push(!HasFlags(kAvatarWalking));
|
fFirstPersonOverride->Push(!HasFlags(kAvatarWalking));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
GetCurrentStackCamera()->Push(!HasFlags(kAvatarWalking));
|
GetCurrentStackCamera()->Push(!HasFlags(kAvatarWalking));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1243,7 +1229,7 @@ bool plVirtualCam1::MsgReceive(plMessage* msg)
|
|||||||
pTrans->fCutPOA = pTrans->fCutPos = true;
|
pTrans->fCutPOA = pTrans->fCutPos = true;
|
||||||
StartTransition(pTrans);
|
StartTransition(pTrans);
|
||||||
delete(pTrans);
|
delete(pTrans);
|
||||||
SetFOV(fPythonOverride->GetFOVw(), fPythonOverride->GetFOVh(), fPythonOverride);
|
SetFOV(fPythonOverride);
|
||||||
ClearFlags(kFirstPersonEnabled);
|
ClearFlags(kFirstPersonEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1289,7 +1275,7 @@ bool plVirtualCam1::MsgReceive(plMessage* msg)
|
|||||||
#ifdef STATUS_LOG
|
#ifdef STATUS_LOG
|
||||||
camLog->AddLineF("Forcing 3rd Person from scripts");
|
camLog->AddLineF("Forcing 3rd Person from scripts");
|
||||||
#endif
|
#endif
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,7 +1306,7 @@ bool plVirtualCam1::MsgReceive(plMessage* msg)
|
|||||||
#ifdef STATUS_LOG
|
#ifdef STATUS_LOG
|
||||||
camLog->AddLineF("Forcing 3rd Person from code");
|
camLog->AddLineF("Forcing 3rd Person from code");
|
||||||
#endif
|
#endif
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
}
|
}
|
||||||
ClearFlags(kFirstPersonEnabled);
|
ClearFlags(kFirstPersonEnabled);
|
||||||
#ifdef STATUS_LOG
|
#ifdef STATUS_LOG
|
||||||
@ -1673,9 +1659,9 @@ void plVirtualCam1::PushCamera(plCameraModifier1* pCam, bool bDefault)
|
|||||||
AddCameraToStack(pCam);
|
AddCameraToStack(pCam);
|
||||||
#ifdef STATUS_LOG
|
#ifdef STATUS_LOG
|
||||||
camLog->AddLineF("Camera %s is now the DEFAULT camera for this age", pCam->GetKeyName().c_str());
|
camLog->AddLineF("Camera %s is now the DEFAULT camera for this age", pCam->GetKeyName().c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
}
|
}
|
||||||
|
|
||||||
void plVirtualCam1::PopCamera(plCameraModifier1* pCam)
|
void plVirtualCam1::PopCamera(plCameraModifier1* pCam)
|
||||||
@ -1812,7 +1798,7 @@ void plVirtualCam1::PopCamera(plCameraModifier1* pCam)
|
|||||||
fCameraStack.erase(it);
|
fCameraStack.erase(it);
|
||||||
}
|
}
|
||||||
if (!InTransition())
|
if (!InTransition())
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
SetFOV(GetCurrentStackCamera());
|
||||||
}
|
}
|
||||||
|
|
||||||
void plVirtualCam1::PopAll()
|
void plVirtualCam1::PopAll()
|
||||||
@ -1831,7 +1817,6 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
|
|||||||
{
|
{
|
||||||
GetCurrentStackCamera()->GetBrain()->SetFlags(plCameraBrain1::kCutPOAOnce);
|
GetCurrentStackCamera()->GetBrain()->SetFlags(plCameraBrain1::kCutPOAOnce);
|
||||||
GetCurrentStackCamera()->GetBrain()->SetFlags(plCameraBrain1::kCutPosOnce);
|
GetCurrentStackCamera()->GetBrain()->SetFlags(plCameraBrain1::kCutPosOnce);
|
||||||
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera());
|
|
||||||
fXPanLimit = GetCurrentStackCamera()->GetBrain()->GetXPanLimit();
|
fXPanLimit = GetCurrentStackCamera()->GetBrain()->GetXPanLimit();
|
||||||
fZPanLimit = GetCurrentStackCamera()->GetBrain()->GetZPanLimit();
|
fZPanLimit = GetCurrentStackCamera()->GetBrain()->GetZPanLimit();
|
||||||
StartInterpPanLimits();
|
StartInterpPanLimits();
|
||||||
@ -1877,7 +1862,7 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
|
|||||||
// pAvBrain->SetFlags(plCameraBrain1::kCutPOA);
|
// pAvBrain->SetFlags(plCameraBrain1::kCutPOA);
|
||||||
// }
|
// }
|
||||||
pAvBrain->SetSubject(pCam->GetBrain()->GetSubject());
|
pAvBrain->SetSubject(pCam->GetBrain()->GetSubject());
|
||||||
pBrain = pAvBrain;
|
pBrain = pAvBrain;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1960,12 +1945,12 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
|
|||||||
if (transition->fCutPOA)
|
if (transition->fCutPOA)
|
||||||
{
|
{
|
||||||
pBrain->SetFlags(plCameraBrain1::kCutPOA);
|
pBrain->SetFlags(plCameraBrain1::kCutPOA);
|
||||||
pCam->GetBrain()->SetFlags(plCameraBrain1::kCutPOAOnce);
|
pCam->GetBrain()->SetFlags(plCameraBrain1::kCutPOAOnce);
|
||||||
}
|
}
|
||||||
fTransitionCamera->SetBrain(pBrain);
|
fTransitionCamera->SetBrain(pBrain);
|
||||||
pBrain->SetCamera(fTransitionCamera);
|
pBrain->SetCamera(fTransitionCamera);
|
||||||
|
|
||||||
// deal with FOV -
|
// deal with FOV -
|
||||||
float diffH = hsABS(pCam->GetFOVh() - fPrevCam->GetFOVh());
|
float diffH = hsABS(pCam->GetFOVh() - fPrevCam->GetFOVh());
|
||||||
if ( diffH )
|
if ( diffH )
|
||||||
{
|
{
|
||||||
@ -1982,13 +1967,9 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
|
|||||||
hsPoint3 posdist = fTransitionCamera->GetTargetPos() - pCam->GetTargetPos();
|
hsPoint3 posdist = fTransitionCamera->GetTargetPos() - pCam->GetTargetPos();
|
||||||
dist.Set(&posdist);
|
dist.Set(&posdist);
|
||||||
}
|
}
|
||||||
|
|
||||||
time = (double)(dist.Magnitude() / pBrain->GetVelocity());
|
time = (dist.Magnitude() / pBrain->GetVelocity());
|
||||||
|
fTransitionCamera->GetBrain()->SetFOVGoal(pCam->GetFOVw(), pCam->GetFOVh(), time);
|
||||||
// set up the transition camera to the current FOV
|
|
||||||
fTransitionCamera->SetFOVh(GetFOVh(), false);
|
|
||||||
fTransitionCamera->SetFOVw(GetFOVw(), false);
|
|
||||||
fTransitionCamera->GetBrain()->SetFOVGoal(pCam->GetFOVh(), time);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
StartInterpPanLimits();
|
StartInterpPanLimits();
|
||||||
|
@ -123,17 +123,18 @@ public:
|
|||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
virtual bool MsgReceive(plMessage* msg);
|
virtual bool MsgReceive(plMessage* msg);
|
||||||
static void SetFOV(float w, float h);
|
static void SetFOV(float x, float y);
|
||||||
static void SetFOV(float w, float h, plCameraModifier1* pCam);
|
static void SetFOV(plCameraModifier1* pCam);
|
||||||
static void SetDepth(float h, float y);
|
static void SetDepth(float h, float y);
|
||||||
static float GetFOVw() { return fFOVw; }
|
static float GetFOVw() { return fFOVw; }
|
||||||
static float GetFOVh() { return fFOVh; }
|
static float GetFOVh() { return fFOVh; }
|
||||||
static float GetHither() { return fHither; }
|
static float GetHither() { return fHither; }
|
||||||
static float GetYon() { return fYon; }
|
static float GetYon() { return fYon; }
|
||||||
static void SetOffset(float x, float y, float z);
|
static void SetOffset(float x, float y, float z);
|
||||||
static void SetAspectRatio(float aspect) { fAspectRatio = aspect; }
|
static void Refresh();
|
||||||
static float GetAspectRatio() { return fAspectRatio; }
|
static float GetAspectRatio() { return fAspectRatio; }
|
||||||
|
static void SetAspectRatio(float ratio);
|
||||||
|
|
||||||
bool InTransition() { return fTransPos != POS_TRANS_OFF; }
|
bool InTransition() { return fTransPos != POS_TRANS_OFF; }
|
||||||
plCameraModifier1* GetCurrentCamera();
|
plCameraModifier1* GetCurrentCamera();
|
||||||
plCameraModifier1* GetCurrentStackCamera();
|
plCameraModifier1* GetCurrentStackCamera();
|
||||||
@ -231,7 +232,7 @@ private:
|
|||||||
double fUnPanEndTime;
|
double fUnPanEndTime;
|
||||||
double fInterpPanLimitTime;
|
double fInterpPanLimitTime;
|
||||||
float fRetainedFY;
|
float fRetainedFY;
|
||||||
|
|
||||||
// built-in cameras
|
// built-in cameras
|
||||||
plCameraModifier1* fDriveCamera; // for driving around
|
plCameraModifier1* fDriveCamera; // for driving around
|
||||||
plCameraModifier1* fTransitionCamera; // transitions between cameras placed in scenes
|
plCameraModifier1* fTransitionCamera; // transitions between cameras placed in scenes
|
||||||
@ -241,11 +242,11 @@ private:
|
|||||||
plCameraModifier1* fThirdPersonCam; // built in third person cam for ccr's when they jump about
|
plCameraModifier1* fThirdPersonCam; // built in third person cam for ccr's when they jump about
|
||||||
|
|
||||||
static float fFOVh, fFOVw;
|
static float fFOVh, fFOVw;
|
||||||
|
static float fAspectRatio;
|
||||||
static float fHither, fYon;
|
static float fHither, fYon;
|
||||||
static plVirtualCam1* fInstance;
|
static plVirtualCam1* fInstance;
|
||||||
static bool printFOV;
|
static bool printFOV;
|
||||||
static float fPanResponseTime;
|
static float fPanResponseTime;
|
||||||
static float fAspectRatio;
|
|
||||||
bool fForceCutOnce;
|
bool fForceCutOnce;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -267,7 +267,7 @@ void cyCamera::SetFOV(float fov, double t)
|
|||||||
plCameraBrain1* camBrain = curCam->GetBrain();
|
plCameraBrain1* camBrain = curCam->GetBrain();
|
||||||
if (camBrain)
|
if (camBrain)
|
||||||
{
|
{
|
||||||
camBrain->SetFOVGoal(fov,t);
|
camBrain->SetFOVGoal(0.f, fov, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
|
|
||||||
virtual void SetAspectRatio(float aspectratio) { plVirtualCam1::SetAspectRatio(aspectratio); }
|
virtual void SetAspectRatio(float aspectratio) { plVirtualCam1::SetAspectRatio(aspectratio); }
|
||||||
virtual float GetAspectRatio() const { return plVirtualCam1::GetAspectRatio(); }
|
virtual float GetAspectRatio() const { return plVirtualCam1::GetAspectRatio(); }
|
||||||
virtual void RefreshFOV() { plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh()); }
|
virtual void RefreshFOV() { plVirtualCam1::Refresh(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2241,9 +2241,8 @@ void plDXPipeline::IResetToDefaults(D3DPRESENT_PARAMETERS *params)
|
|||||||
plBitmap::SetGlobalLevelChopCount(2 - fDefaultPipeParams.TextureQuality);
|
plBitmap::SetGlobalLevelChopCount(2 - fDefaultPipeParams.TextureQuality);
|
||||||
|
|
||||||
// adjust camera properties
|
// adjust camera properties
|
||||||
plVirtualCam1::SetAspectRatio((float)fSettings.fOrigWidth / (float)fSettings.fOrigHeight);
|
plVirtualCam1::Refresh();
|
||||||
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
|
|
||||||
|
|
||||||
// fire off a message to the client so we can write defaults to the ini file, and adjust the window size
|
// fire off a message to the client so we can write defaults to the ini file, and adjust the window size
|
||||||
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );
|
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );
|
||||||
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kSetGraphicsDefaults);
|
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kSetGraphicsDefaults);
|
||||||
@ -2406,12 +2405,10 @@ void plDXPipeline::ResetDisplayDevice(int Width, int Height, int ColorDepth, boo
|
|||||||
// Force a device reset
|
// Force a device reset
|
||||||
fDeviceLost = true;
|
fDeviceLost = true;
|
||||||
fForceDeviceReset = true;
|
fForceDeviceReset = true;
|
||||||
|
|
||||||
plVirtualCam1::SetAspectRatio((float)Width / (float)Height);
|
plVirtualCam1::Refresh();
|
||||||
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
|
|
||||||
|
|
||||||
IResetDevice();
|
IResetDevice();
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -9257,7 +9254,6 @@ void plDXPipeline::SetViewTransform(const plViewTransform& v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
IUpdateViewFlags();
|
IUpdateViewFlags();
|
||||||
|
|
||||||
IWorldToCameraToD3D();
|
IWorldToCameraToD3D();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user