Browse Source

Hoikas support for widescreen field of view (Hor+)

1e7cbc3daf
2a7d97d520
a8b667ca1e
Includes selected changes from "Obliterate hsBool":
a709e17069
tickets/04/4/1
John Johns 4 years ago
parent
commit
9a3f202d66
  1. 3
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp
  2. 80
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp
  3. 7
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.h
  4. 15
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.cpp
  5. 1
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h
  6. 96
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  7. 7
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h
  8. 19
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyCamera.cpp
  9. 5
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyCamera.h
  10. 1
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnMessage/plCameraMsg.h
  11. 6
      MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

3
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/Apps/plClient/plClient.cpp

@ -1545,8 +1545,7 @@ hsBool plClient::StartInit()
fNewCamera->SetPipeline( GetPipeline() ); fNewCamera->SetPipeline( GetPipeline() );
float aspectratio = (float)fPipeline->Width() / (float)fPipeline->Height(); float aspectratio = (float)fPipeline->Width() / (float)fPipeline->Height();
plVirtualCam1::SetAspectRatio(aspectratio); plVirtualCam1::Refresh();
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio ); pfGameGUIMgr::GetInstance()->SetAspectRatio( aspectratio );
plMouseDevice::Instance()->SetDisplayResolution((float)fPipeline->Width(), (float)fPipeline->Height()); plMouseDevice::Instance()->SetDisplayResolution((float)fPipeline->Width(), (float)fPipeline->Height());

80
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraBrain.cpp

@ -175,18 +175,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(hsScalar h, double t) void plCameraBrain1::SetFOVGoal(hsScalar w, hsScalar h, double t)
{ {
if (fFOVGoal == h || h == fCamera->GetFOVh()) if (fFOVhGoal == h || h == fCamera->GetFOVh() &&
fFOVwGoal == w || w == fCamera->GetFOVw())
return; return;
hsScalar dif = h - fCamera->GetFOVh(); hsScalar dif = h - fCamera->GetFOVh();
fFOVAnimRate = dif / ((hsScalar)t); fFOVhAnimRate = dif / ((hsScalar)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);
} }
@ -239,19 +253,26 @@ void plCameraBrain1::Update(hsBool forced)
// adjust FOV based on elapsed time // adjust FOV based on elapsed time
void plCameraBrain1::IAnimateFOV(double time) void plCameraBrain1::IAnimateFOV(double time)
{ {
hsScalar dH = fFOVAnimRate * hsTimer::GetDelSysSeconds(); hsScalar dH = fFOVhAnimRate * hsTimer::GetDelSysSeconds();
hsScalar 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( (hsScalar)(dH * plVirtualCam1::GetAspectRatio()) ); if (dW == fFOVwGoal && dH == fFOVhGoal)
fCamera->SetFOVh( dH ); fFlags.ClearBit(kAnimateFOV);
fCamera->SetFOV( dW, dH );
} }
@ -534,6 +555,14 @@ void plCameraBrain1::Write(hsStream* stream, hsResMgr* mgr)
stream->WriteSwapFloat(fZoomMin); stream->WriteSwapFloat(fZoomMin);
stream->WriteSwapFloat(fZoomMax); stream->WriteSwapFloat(fZoomMax);
} }
hsScalar plCameraBrain1::IMakeFOVwZoom(hsScalar fovH) const
{
hsScalar num = hsTan(hsScalarDegToRad(fovH / 2)) * hsTan(hsScalarDegToRad(fCamera->GetFOVw() / 2));
hsScalar denom = hsTan(hsScalarDegToRad(fCamera->GetFOVh() / 2));
return (hsScalar)(2 * hsABS(hsScalarRadToDeg(atan(num / denom))));
}
hsBool plCameraBrain1::MsgReceive(plMessage* msg) hsBool plCameraBrain1::MsgReceive(plMessage* msg)
{ {
plCameraMsg* pCamMsg = plCameraMsg::ConvertNoRef(msg); plCameraMsg* pCamMsg = plCameraMsg::ConvertNoRef(msg);
@ -542,16 +571,18 @@ hsBool 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
@ -635,8 +666,9 @@ hsBool 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;
} }
@ -644,8 +676,9 @@ hsBool 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(fZoomMax);
fFOVwAnimRate = fFOVhAnimRate = fZoomRate;
fFOVEndTime = hsTimer::GetSysSeconds() + 60; fFOVEndTime = hsTimer::GetSysSeconds() + 60;
return true; return true;
} }
@ -655,11 +688,12 @@ hsBool 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
MOULOpenSourceClientPlugin/Plasma20/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(hsScalar h, double t); void SetFOVGoal(hsScalar w, hsScalar h, double t);
void SetZoomParams(hsScalar max, hsScalar min, hsScalar rate); void SetZoomParams(hsScalar max, hsScalar min, hsScalar rate);
void SetXPanLimit(hsScalar x) {fXPanLimit = x;} void SetXPanLimit(hsScalar x) {fXPanLimit = x;}
@ -183,6 +183,7 @@ protected:
hsScalar IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime); hsScalar IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime);
hsBool IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal); hsBool IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal);
hsScalar IMakeFOVwZoom(hsScalar fovH) const;
plCameraModifier1* fCamera; plCameraModifier1* fCamera;
plKey fSubjectKey; plKey fSubjectKey;
@ -203,10 +204,10 @@ protected:
hsScalar fXPanLimit; hsScalar fXPanLimit;
hsScalar fZPanLimit; hsScalar fZPanLimit;
hsScalar fPanSpeed; hsScalar fPanSpeed;
hsScalar fFOVGoal; hsScalar fFOVwGoal, fFOVhGoal;
double fFOVStartTime; double fFOVStartTime;
double fFOVEndTime; double fFOVEndTime;
hsScalar fFOVAnimRate; hsScalar fFOVwAnimRate, fFOVhAnimRate;
hsScalar fZoomRate; hsScalar fZoomRate;
hsScalar fZoomMax; hsScalar fZoomMax;
hsScalar fZoomMin; hsScalar fZoomMin;

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

@ -137,18 +137,26 @@ plSceneObject* plCameraModifier1::GetSubject()
return fSubObj; return fSubObj;
} }
void plCameraModifier1::SetFOV(hsScalar w, hsScalar h, bool fUpdateVCam)
{
fFOVw = w;
fFOVh = h;
if (plVirtualCam1::Instance() && fUpdateVCam)
plVirtualCam1::SetFOV(this);
}
void plCameraModifier1::SetFOVw(hsScalar f, hsBool fUpdateVCam) void plCameraModifier1::SetFOVw(hsScalar f, hsBool fUpdateVCam)
{ {
fFOVw = f; fFOVw = f;
if (plVirtualCam1::Instance() && fUpdateVCam) if (plVirtualCam1::Instance() && fUpdateVCam)
plVirtualCam1::SetFOV(fFOVw, fFOVh, this); plVirtualCam1::SetFOV(this);
} }
void plCameraModifier1::SetFOVh(hsScalar f, hsBool fUpdateVCam) void plCameraModifier1::SetFOVh(hsScalar f, hsBool fUpdateVCam)
{ {
fFOVh = f; fFOVh = f;
if (plVirtualCam1::Instance() && fUpdateVCam) if (plVirtualCam1::Instance() && fUpdateVCam)
plVirtualCam1::SetFOV(fFOVw, fFOVh, this); plVirtualCam1::SetFOV(this);
} }
hsBool plCameraModifier1::SetFaded(hsBool b) hsBool plCameraModifier1::SetFaded(hsBool b)
@ -192,8 +200,9 @@ hsBool plCameraModifier1::MsgReceive(plMessage* msg)
double time2 = (double)pEventMsg->fEventTime; double time2 = (double)pEventMsg->fEventTime;
time = hsABS(time - time2); time = hsABS(time - time2);
hsScalar h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh; hsScalar h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh;
hsScalar 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);

1
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plCameraModifier.h

@ -130,6 +130,7 @@ public:
void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; } void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; }
hsScalar GetFOVw() { return fFOVw; } hsScalar GetFOVw() { return fFOVw; }
hsScalar GetFOVh() { return fFOVh; } hsScalar GetFOVh() { return fFOVh; }
void SetFOV(hsScalar w, hsScalar h, bool fUpdateVCam = true);
void SetFOVw(hsScalar f, hsBool fUpdateVCam = true); void SetFOVw(hsScalar f, hsBool fUpdateVCam = true);
void SetFOVh(hsScalar f, hsBool fUpdateVCam = true); void SetFOVh(hsScalar f, hsBool fUpdateVCam = true);
hsBool GetInSubworld() { return fInSubLastUpdate; } hsBool GetInSubworld() { return fInSubLastUpdate; }

96
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -104,7 +104,7 @@ hsScalar plVirtualCam1::fFallTimerDelay = 0.25f;
hsBool plVirtualCam1::alwaysCutForColin = false; hsBool plVirtualCam1::alwaysCutForColin = false;
hsBool plVirtualCam1::WalkPan3rdPerson = false; hsBool plVirtualCam1::WalkPan3rdPerson = false;
hsBool plVirtualCam1::StayInFirstPersonForever = false; hsBool plVirtualCam1::StayInFirstPersonForever = false;
float plVirtualCam1::fAspectRatio = fFOVw / fFOVh; float plVirtualCam1::fAspectRatio = 4.f/3.f;
// #define STATUS_LOG // #define STATUS_LOG
@ -287,58 +287,48 @@ void plVirtualCam1::SetOffset(float x, float y, float z)
} }
// static function // static function
void plVirtualCam1::SetFOV(hsScalar x, hsScalar y) void plVirtualCam1::SetFOV(hsScalar w, hsScalar h)
{ {
float fovW = y * fAspectRatio; static float fourXthree = (4.f/3.f);
fFOVw = fovW; fFOVh = h;
fFOVh = y; if (fAspectRatio == fourXthree)
fFOVw = w;
if (! plVirtualCam1::Instance()->fPipe) else
return; {
float scale = fAspectRatio / fourXthree;
fFOVw = (hsScalar)(2 * hsScalarRadToDeg(atan(scale * tan(hsScalarDegToRad(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(hsScalar x, hsScalar 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());
}
hsScalar 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) void plVirtualCam1::SetAspectRatio(float ratio)
return; {
fAspectRatio = ratio;
plVirtualCam1::Instance()->SetFlags(plVirtualCam1::kSetFOV); // resize the FOV accordingly
plCameraModifier1* pCam = plVirtualCam1::Instance()->GetCurrentCamera();
#ifdef STATUS_LOG hsAssert(pCam, "CameraModifier1 shouldn't be nullptr?");
if (printFOV) if (pCam)
camLog->AddLineF("FOV changed to %f", fFOVw); SetFOV(pCam->GetFOVw(), pCam->GetFOVh());
#endif
} }
// static function // static function
void plVirtualCam1::SetDepth(hsScalar h, hsScalar y) void plVirtualCam1::SetDepth(hsScalar h, hsScalar y)
{ {
return; return;
@ -913,7 +903,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 +928,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 +1168,12 @@ hsBool 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 +1233,7 @@ hsBool 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 +1279,7 @@ hsBool 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 +1310,7 @@ hsBool 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
@ -1384,6 +1374,11 @@ hsBool plVirtualCam1::MsgReceive(plMessage* msg)
} }
} }
} }
else
if (pCam->Cmd(plCameraMsg::kRefreshFOV))
{
Refresh();
}
} }
plGenRefMsg* pRefMsg = plGenRefMsg::ConvertNoRef(msg); plGenRefMsg* pRefMsg = plGenRefMsg::ConvertNoRef(msg);
if (pRefMsg ) if (pRefMsg )
@ -1678,7 +1673,7 @@ void plVirtualCam1::PushCamera(plCameraModifier1* pCam, hsBool bDefault)
camLog->AddLineF("Camera %s is now the DEFAULT camera for this age", pCam->GetKeyName()); camLog->AddLineF("Camera %s is now the DEFAULT camera for this age", pCam->GetKeyName());
#endif #endif
} }
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera()); SetFOV(GetCurrentStackCamera());
} }
void plVirtualCam1::PopCamera(plCameraModifier1* pCam) void plVirtualCam1::PopCamera(plCameraModifier1* pCam)
@ -1819,7 +1814,7 @@ void plVirtualCam1::PopCamera(plCameraModifier1* pCam)
} }
} }
if (!InTransition()) if (!InTransition())
SetFOV(GetCurrentStackCamera()->GetFOVw(), GetCurrentStackCamera()->GetFOVh(), GetCurrentStackCamera()); SetFOV(GetCurrentStackCamera());
} }
void plVirtualCam1::PopAll() void plVirtualCam1::PopAll()
@ -1838,7 +1833,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();
@ -1984,12 +1978,8 @@ void plVirtualCam1::StartTransition(CamTrans* transition)
else else
dist.Set(&(fTransitionCamera->GetTargetPos() - pCam->GetTargetPos())); dist.Set(&(fTransitionCamera->GetTargetPos() - pCam->GetTargetPos()));
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();

7
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h

@ -121,16 +121,17 @@ public:
virtual hsBool MsgReceive(plMessage* msg); virtual hsBool MsgReceive(plMessage* msg);
static void SetFOV(hsScalar w, hsScalar h); static void SetFOV(hsScalar w, hsScalar h);
static void SetFOV(hsScalar w, hsScalar h, plCameraModifier1* pCam); static void SetFOV(plCameraModifier1* pCam);
static void SetDepth(hsScalar h, hsScalar y); static void SetDepth(hsScalar h, hsScalar y);
static hsScalar GetFOVw() { return fFOVw; } static hsScalar GetFOVw() { return fFOVw; }
static hsScalar GetFOVh() { return fFOVh; } static hsScalar GetFOVh() { return fFOVh; }
static hsScalar GetHither() { return fHither; } static hsScalar GetHither() { return fHither; }
static hsScalar GetYon() { return fYon; } static hsScalar 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);
hsBool InTransition() { return fTransPos != POS_TRANS_OFF; } hsBool InTransition() { return fTransPos != POS_TRANS_OFF; }
plCameraModifier1* GetCurrentCamera(); plCameraModifier1* GetCurrentCamera();
plCameraModifier1* GetCurrentStackCamera(); plCameraModifier1* GetCurrentStackCamera();

19
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyCamera.cpp

@ -263,7 +263,7 @@ void cyCamera::SetFOV(hsScalar 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);
} }
} }
} }
@ -370,17 +370,12 @@ hsBool cyCamera::IsStayInFirstPerson()
return false; return false;
} }
void cyCamera::SetAspectRatio(float aspectratio) void cyCamera::RefreshFOV()
{ {
plVirtualCam1::SetAspectRatio(aspectratio);
}
float cyCamera::GetAspectRatio() plCameraMsg* pMsg = new plCameraMsg();
{ pMsg->SetSender(fSender);
return plVirtualCam1::GetAspectRatio(); pMsg->SetCmd(plCameraMsg::kRefreshFOV);
} pMsg->Send(fTheCam);
void cyCamera::RefreshFOV() }
{
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
}

5
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfPython/cyCamera.h

@ -55,6 +55,7 @@ class pyKey;
#include <python.h> #include <python.h>
#include "pyGlueHelpers.h" #include "pyGlueHelpers.h"
#include "../pfCamera/plVirtualCamNeu.h"
class cyCamera class cyCamera
{ {
@ -114,8 +115,8 @@ public:
virtual void SetStayInFirstPerson(hsBool state); virtual void SetStayInFirstPerson(hsBool state);
virtual hsBool IsStayInFirstPerson(); virtual hsBool IsStayInFirstPerson();
virtual void SetAspectRatio(float aspectratio); virtual void SetAspectRatio(float aspectratio) { plVirtualCam1::SetAspectRatio(aspectratio); }
virtual float GetAspectRatio(); virtual float GetAspectRatio() const { return plVirtualCam1::GetAspectRatio(); }
virtual void RefreshFOV(); virtual void RefreshFOV();
}; };

1
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/NucleusLib/pnMessage/plCameraMsg.h

@ -207,6 +207,7 @@ public:
kNonPhysOn, kNonPhysOn,
kNonPhysOff, kNonPhysOff,
kResetPanning, kResetPanning,
kRefreshFOV,
kNumCmds kNumCmds
}; };

6
MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

@ -2209,8 +2209,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 );
@ -2375,8 +2374,7 @@ void plDXPipeline::ResetDisplayDevice(int Width, int Height, int ColorDepth, hsB
fDeviceLost = true; fDeviceLost = true;
fForceDeviceReset = true; fForceDeviceReset = true;
plVirtualCam1::SetAspectRatio((float)Width / (float)Height); plVirtualCam1::Refresh();
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
IResetDevice(); IResetDevice();

Loading…
Cancel
Save