Browse Source

Merge pull request #299 from Hoikas/hor-plus

Implement Hor+ FOVs
Branan Purvine-Riley 12 years ago
parent
commit
1e7cbc3daf
  1. 7
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 82
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  3. 7
      Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.h
  4. 15
      Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp
  5. 5
      Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h
  6. 95
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  7. 9
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  8. 2
      Sources/Plasma/FeatureLib/pfPython/cyCamera.cpp
  9. 2
      Sources/Plasma/FeatureLib/pfPython/cyCamera.h
  10. 8
      Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

7
Sources/Plasma/Apps/plClient/plClient.cpp

@ -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);

82
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp

@ -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(); float dif = h - fCamera->GetFOVh();
fFOVAnimRate = dif / ((float)t); fFOVhAnimRate = dif / ((float)t);
fFOVGoal = h; 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
@ -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;

7
Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.h

@ -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;}
@ -183,6 +183,7 @@ protected:
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;
@ -203,10 +204,10 @@ protected:
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;

15
Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp

@ -137,18 +137,26 @@ plSceneObject* plCameraModifier1::GetSubject()
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);

5
Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h

@ -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; }

95
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -90,14 +90,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
float plVirtualCam1::fFOVw = 45.0f; float plVirtualCam1::fFOVw = 45.0f;
float plVirtualCam1::fFOVh = 33.75f; float plVirtualCam1::fFOVh = 33.75f;
float plVirtualCam1::fAspectRatio = 4.f/3.f;
float plVirtualCam1::fHither = 0.3f; float plVirtualCam1::fHither = 0.3f;
float plVirtualCam1::fYon = 500.0f; float plVirtualCam1::fYon = 500.0f;
bool plVirtualCam1::printFOV = false; bool plVirtualCam1::printFOV = false;
bool plVirtualCam1::fUseAccelOverride = 1; bool plVirtualCam1::fUseAccelOverride = 1;
bool plVirtualCam1::freeze = 0; bool plVirtualCam1::freeze = 0;
//float plVirtualCam1::fAccel = 5.0f;
//float plVirtualCam1::fDecel = 5.0f;
//float plVirtualCam1::fVel = 10.0f;
float plVirtualCam1::fAccel = 50.0f; float plVirtualCam1::fAccel = 50.0f;
float plVirtualCam1::fDecel = 50.0f; float plVirtualCam1::fDecel = 50.0f;
float plVirtualCam1::fVel = 100.0f; float plVirtualCam1::fVel = 100.0f;
@ -106,7 +104,6 @@ float plVirtualCam1::fFallTimerDelay = 0.25f;
bool plVirtualCam1::alwaysCutForColin = false; bool plVirtualCam1::alwaysCutForColin = false;
bool plVirtualCam1::WalkPan3rdPerson = false; bool plVirtualCam1::WalkPan3rdPerson = false;
bool plVirtualCam1::StayInFirstPersonForever = false; bool plVirtualCam1::StayInFirstPersonForever = false;
float plVirtualCam1::fAspectRatio = fFOVw / fFOVh;
// #define STATUS_LOG // #define STATUS_LOG
@ -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
}
float fovW = y * fAspectRatio;
fFOVw = fovW;
fFOVh = y;
if (! plVirtualCam1::Instance()->fPipe)
return;
plVirtualCam1::Instance()->SetFlags(plVirtualCam1::kSetFOV); void plVirtualCam1::SetAspectRatio(float ratio)
{
fAspectRatio = ratio;
#ifdef STATUS_LOG // resize the FOV accordingly
if (printFOV) plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCurrentCamera();
camLog->AddLineF("FOV changed to %f", fFOVw); hsAssert(pCam, "CameraModifier1 shouldn't be nullptr?");
#endif if (pCam)
SetFOV(pCam->GetFOVw(), pCam->GetFOVh());
} }
// 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
@ -1675,7 +1661,7 @@ void plVirtualCam1::PushCamera(plCameraModifier1* pCam, bool bDefault)
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();
@ -1983,12 +1968,8 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
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();

9
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h

@ -123,16 +123,17 @@ 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();
@ -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;
}; };

2
Sources/Plasma/FeatureLib/pfPython/cyCamera.cpp

@ -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);
} }
} }
} }

2
Sources/Plasma/FeatureLib/pfPython/cyCamera.h

@ -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(); }
}; };

8
Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

@ -2241,8 +2241,7 @@ 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 );
@ -2407,9 +2406,7 @@ void plDXPipeline::ResetDisplayDevice(int Width, int Height, int ColorDepth, boo
fDeviceLost = true; fDeviceLost = true;
fForceDeviceReset = true; fForceDeviceReset = true;
plVirtualCam1::SetAspectRatio((float)Width / (float)Height); plVirtualCam1::Refresh();
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
IResetDevice(); IResetDevice();
@ -9257,7 +9254,6 @@ void plDXPipeline::SetViewTransform(const plViewTransform& v)
} }
IUpdateViewFlags(); IUpdateViewFlags();
IWorldToCameraToD3D(); IWorldToCameraToD3D();
} }

Loading…
Cancel
Save