mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Initial Commit of CyanWorlds.com Engine Open Source Client/Plugin
This commit is contained in:
@ -0,0 +1,54 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef pfCameraCreatable_inc
|
||||
#define pfCameraCreatable_inc
|
||||
|
||||
#include "../pnFactory/plCreatable.h"
|
||||
|
||||
#include "plCameraBrain.h"
|
||||
|
||||
REGISTER_CREATABLE( plCameraBrain1 );
|
||||
REGISTER_CREATABLE( plCameraBrain1_Drive );
|
||||
REGISTER_CREATABLE( plCameraBrain1_Avatar );
|
||||
REGISTER_CREATABLE( plCameraBrain1_FirstPerson);
|
||||
REGISTER_CREATABLE( plCameraBrain1_Fixed );
|
||||
REGISTER_CREATABLE( plCameraBrain1_Circle );
|
||||
|
||||
#include "plCameraModifier.h"
|
||||
|
||||
REGISTER_CREATABLE( plCameraModifier1 );
|
||||
|
||||
#include "plInterestingModifier.h"
|
||||
|
||||
REGISTER_CREATABLE( plInterestingModifier );
|
||||
|
||||
#include "plVirtualCamNeu.h"
|
||||
|
||||
REGISTER_CREATABLE( plVirtualCam1 );
|
||||
|
||||
|
||||
#endif // pfCameraCreatable_inc
|
@ -0,0 +1,68 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "pfCameraProxy.h"
|
||||
#include "plVirtualCamNeu.h"
|
||||
#include "../plDrawable/plDrawableGenerator.h"
|
||||
#include "../pnMessage/plProxyDrawMsg.h"
|
||||
#include "../plScene/plSceneNode.h"
|
||||
|
||||
plCameraProxy::plCameraProxy()
|
||||
: plProxyGen(hsColorRGBA().Set(0.2f,0.2f,0.8f,1.f), hsColorRGBA().Set(1.f,0.5f,0.5f,1.f), 0.2f),
|
||||
fOwner(nil), node(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plCameraProxy::~plCameraProxy()
|
||||
{
|
||||
}
|
||||
|
||||
hsBool plCameraProxy::Init(plVirtualCam1* aud)
|
||||
{
|
||||
plProxyGen::Init(aud);
|
||||
|
||||
fOwner = aud;
|
||||
fProxyMsgType = plProxyDrawMsg::kCamera;
|
||||
|
||||
return fOwner != nil;
|
||||
}
|
||||
|
||||
plKey plCameraProxy::IGetNode() const
|
||||
{
|
||||
if (node)
|
||||
return node->GetKey();
|
||||
return nil;
|
||||
}
|
||||
|
||||
plDrawableSpans* plCameraProxy::ICreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo)
|
||||
{
|
||||
if( fOwner )
|
||||
{
|
||||
// return fOwner->CreateProxy(mat, idx, addTo);
|
||||
}
|
||||
return nil;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plCameraProxy_inc
|
||||
#define plCameraProxy_inc
|
||||
|
||||
#include "../plDrawable/plProxyGen.h"
|
||||
|
||||
class plVirtualCam1;
|
||||
class plSceneNode;
|
||||
|
||||
class plCameraProxy : public plProxyGen
|
||||
{
|
||||
protected:
|
||||
plVirtualCam1* fOwner;
|
||||
|
||||
|
||||
virtual plDrawableSpans* ICreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo=nil);
|
||||
virtual plKey IGetNode() const;
|
||||
public:
|
||||
plCameraProxy();
|
||||
virtual ~plCameraProxy();
|
||||
|
||||
hsBool Init(plVirtualCam1* aud);
|
||||
plSceneNode* node;
|
||||
};
|
||||
|
||||
#endif // plCameraProxy_inc
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,390 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plCameraBrain_inc
|
||||
#define plCameraBrain_inc
|
||||
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "hsMatrix44.h"
|
||||
#include "hsBitVector.h"
|
||||
#include "hsTemplates.h"
|
||||
|
||||
class plMessage;
|
||||
class plCameraModifier1;
|
||||
class plSceneObject;
|
||||
class plRailCameraMod;
|
||||
|
||||
class plCameraBrain1 : public hsKeyedObject
|
||||
{
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
kCutPos = 0,
|
||||
kCutPosOnce,
|
||||
kCutPOA,
|
||||
kCutPOAOnce,
|
||||
kAnimateFOV,
|
||||
kFollowLocalAvatar,
|
||||
kPanicVelocity,
|
||||
kRailComponent,
|
||||
kSubject,
|
||||
kCircleTarget,
|
||||
kMaintainLOS,
|
||||
kZoomEnabled,
|
||||
kIsTransitionCamera,
|
||||
kWorldspacePOA,
|
||||
kWorldspacePos,
|
||||
kCutPosWhilePan,
|
||||
kCutPOAWhilePan,
|
||||
kNonPhys,
|
||||
kNeverAnimateFOV,
|
||||
kIgnoreSubworldMovement,
|
||||
kFalling,
|
||||
kRunning,
|
||||
kVerticalWhenFalling,
|
||||
kSpeedUpWhenRunning,
|
||||
kFallingStopped,
|
||||
kBeginFalling,
|
||||
};
|
||||
plCameraBrain1(plCameraModifier1* pMod);
|
||||
plCameraBrain1();
|
||||
~plCameraBrain1();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1 );
|
||||
GETINTERFACE_ANY( plCameraBrain1, hsKeyedObject );
|
||||
|
||||
void SetCamera(plCameraModifier1* pMod) { fCamera = pMod; }
|
||||
|
||||
void SetAccel (hsScalar f) { fAccel = f; }
|
||||
void SetDecel (hsScalar f) { fDecel = f; }
|
||||
void SetVelocity (hsScalar f) { fVelocity = f; }
|
||||
void SetPOAAccel (hsScalar f) { fPOAAccel = f; }
|
||||
void SetPOADecel (hsScalar f) { fPOADecel = f; }
|
||||
void SetPOAVelocity (hsScalar f) { fPOAVelocity = f; }
|
||||
|
||||
const plCameraModifier1* GetCamera() { return fCamera; }
|
||||
|
||||
virtual void Update(hsBool forced = false);
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
virtual plSceneObject* GetSubject();
|
||||
virtual void SetSubject(plSceneObject* sub);
|
||||
|
||||
virtual hsVector3 GetPOAOffset() { return fPOAOffset; }
|
||||
void SetPOAOffset(hsVector3 pt) { fPOAOffset = pt; }
|
||||
void AddTarget();
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual hsBool GetFaded() { return false; }
|
||||
virtual hsBool SetFaded(hsBool b) { return false; }
|
||||
|
||||
hsBool HasMovementFlag(int f) { return fMoveFlags.IsBitSet(f); }
|
||||
void SetMovementFlag(int f);
|
||||
void ClearMovementFlag(int which) { fMoveFlags.ClearBit( which ); }
|
||||
void SetFlags(int i) { fFlags.SetBit(i); }
|
||||
void ClearFlags(int which) { fFlags.ClearBit( which ); }
|
||||
hsBool HasFlag(int f) { return fFlags.IsBitSet(f); }
|
||||
|
||||
void SetGoal(hsPoint3 pt) { fGoal = pt; }
|
||||
void SetPOAGoal(hsPoint3 pt) { fPOAGoal = pt; }
|
||||
void SetFOVGoal(hsScalar h, double t);
|
||||
void SetZoomParams(hsScalar max, hsScalar min, hsScalar rate);
|
||||
|
||||
void SetXPanLimit(hsScalar x) {fXPanLimit = x;}
|
||||
void SetZPanLimit(hsScalar y) {fZPanLimit = y;}
|
||||
hsScalar GetXPanLimit() {return fXPanLimit;}
|
||||
hsScalar GetZPanLimit() {return fZPanLimit;}
|
||||
|
||||
void SetRail(plRailCameraMod* m) { fRail = m; }
|
||||
|
||||
hsPoint3 GetGoal() { return fGoal; }
|
||||
hsPoint3 GetPOAGoal() { return fPOAGoal; }
|
||||
|
||||
virtual void Push(hsBool recenter = true);
|
||||
virtual void Pop();
|
||||
|
||||
hsScalar GetVelocity() { return fVelocity; }
|
||||
hsScalar GetAccel() { return fAccel; }
|
||||
hsScalar GetDecel() { return fDecel; }
|
||||
hsScalar GetPOAAccel() { return fPOAAccel; }
|
||||
hsScalar GetPOAVelocity() { return fPOAVelocity; }
|
||||
hsScalar GetPOADecel() { return fPOADecel; }
|
||||
|
||||
hsScalar GetCurrentCamSpeed() { return fCurCamSpeed; }
|
||||
hsScalar GetCurrentViewSpeed() { return fCurViewSpeed; }
|
||||
|
||||
void SetCurrentCamSpeed(hsScalar s) { fCurCamSpeed = s; }
|
||||
void SetCurrentViewSpeed(hsScalar s) { fCurViewSpeed = s; }
|
||||
|
||||
hsMatrix44 GetTargetMatrix() { return fTargetMatrix; }
|
||||
|
||||
static hsScalar fFallVelocity;
|
||||
static hsScalar fFallAccel;
|
||||
static hsScalar fFallDecel;
|
||||
|
||||
static hsScalar fFallPOAVelocity;
|
||||
static hsScalar fFallPOAAccel;
|
||||
static hsScalar fFallPOADecel;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void AdjustForInput(double secs);
|
||||
void IMoveTowardGoal(double time);
|
||||
void IPointTowardGoal(double time);
|
||||
void IAnimateFOV(double time);
|
||||
void IAdjustVelocity(hsScalar adjAccelRate,
|
||||
hsScalar adjDecelRate,
|
||||
hsVector3* dir,
|
||||
hsVector3* vel,
|
||||
hsScalar maxSpeed,
|
||||
hsScalar distToGoal,
|
||||
double elapsedTime);
|
||||
|
||||
hsScalar IClampVelocity(hsVector3* vel, hsScalar maxSpeed, double elapsedTime);
|
||||
hsBool IShouldDecelerate(hsScalar decelSpeed, hsScalar curSpeed, hsScalar distToGoal);
|
||||
|
||||
plCameraModifier1* fCamera;
|
||||
plKey fSubjectKey;
|
||||
plRailCameraMod* fRail;
|
||||
hsScalar fCurCamSpeed;
|
||||
hsScalar fCurViewSpeed;
|
||||
double fLastTime;
|
||||
|
||||
hsScalar fVelocity;
|
||||
hsScalar fAccel;
|
||||
hsScalar fDecel;
|
||||
hsScalar fPOAVelocity;
|
||||
hsScalar fPOAAccel;
|
||||
hsScalar fPOADecel;
|
||||
hsVector3 fPOAOffset;
|
||||
hsPoint3 fGoal;
|
||||
hsPoint3 fPOAGoal;
|
||||
hsScalar fXPanLimit;
|
||||
hsScalar fZPanLimit;
|
||||
hsScalar fPanSpeed;
|
||||
hsScalar fFOVGoal;
|
||||
double fFOVStartTime;
|
||||
double fFOVEndTime;
|
||||
hsScalar fFOVAnimRate;
|
||||
hsScalar fZoomRate;
|
||||
hsScalar fZoomMax;
|
||||
hsScalar fZoomMin;
|
||||
hsBitVector fMoveFlags;
|
||||
hsBitVector fFlags;
|
||||
hsMatrix44 fTargetMatrix;
|
||||
hsScalar fOffsetLength;
|
||||
hsScalar fOffsetPct;
|
||||
double fFallTimer;
|
||||
};
|
||||
|
||||
class plControlEventMsg;
|
||||
|
||||
class plCameraBrain1_Drive : public plCameraBrain1
|
||||
{
|
||||
protected:
|
||||
hsPoint3 fDesiredPosition;
|
||||
hsPoint3 fFacingTarget;
|
||||
hsBool bUseDesiredFacing;
|
||||
hsScalar deltaX;
|
||||
hsScalar deltaY;
|
||||
hsBool bDisregardY; // these are here to prevent
|
||||
hsBool bDisregardX; // the camera from jumping when the mouse cursor recenters / wraps around.
|
||||
hsVector3 fUp;
|
||||
|
||||
public:
|
||||
|
||||
plCameraBrain1_Drive();
|
||||
plCameraBrain1_Drive(plCameraModifier1* pMod);
|
||||
~plCameraBrain1_Drive();
|
||||
|
||||
static SetSensitivity(hsScalar f) { fTurnRate = f; }
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1_Drive );
|
||||
GETINTERFACE_ANY( plCameraBrain1_Drive, plCameraBrain1 );
|
||||
|
||||
virtual void Update(hsBool forced = false);
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
virtual void Push(hsBool recenter = true);
|
||||
virtual void Pop();
|
||||
|
||||
static hsScalar fAcceleration;
|
||||
static hsScalar fDeceleration;
|
||||
static hsScalar fMaxVelocity;
|
||||
static hsScalar fTurnRate;
|
||||
};
|
||||
|
||||
|
||||
class plCameraBrain1_Avatar : public plCameraBrain1
|
||||
{
|
||||
public:
|
||||
|
||||
plCameraBrain1_Avatar();
|
||||
plCameraBrain1_Avatar(plCameraModifier1* pMod);
|
||||
~plCameraBrain1_Avatar();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1_Avatar );
|
||||
GETINTERFACE_ANY( plCameraBrain1_Avatar, plCameraBrain1 );
|
||||
|
||||
|
||||
virtual void Update(hsBool forced = false);
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
virtual void CalculatePosition();
|
||||
hsVector3 GetOffset() { return fOffset; }
|
||||
void SetOffset(hsVector3 pt) { fOffset = pt; }
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual hsBool GetFaded() { return fFaded; }
|
||||
virtual hsBool SetFaded(hsBool b) { fFaded = b; return true; }
|
||||
|
||||
virtual void Pop();
|
||||
virtual void Push(hsBool recenter = true);
|
||||
|
||||
protected:
|
||||
void ISendFadeMsg(hsBool fade);
|
||||
void IHandleObstacle();
|
||||
|
||||
hsPoint3 fHitPoint;
|
||||
hsVector3 fOffset;
|
||||
hsVector3 fHitNormal;
|
||||
hsBool bObscured;
|
||||
hsBool fFaded;
|
||||
plSceneObject* fObstacle;
|
||||
};
|
||||
|
||||
class plCameraBrain1_FirstPerson : public plCameraBrain1_Avatar
|
||||
{
|
||||
public:
|
||||
|
||||
plCameraBrain1_FirstPerson();
|
||||
plCameraBrain1_FirstPerson(plCameraModifier1* pMod);
|
||||
~plCameraBrain1_FirstPerson();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1_FirstPerson );
|
||||
GETINTERFACE_ANY( plCameraBrain1_FirstPerson, plCameraBrain1_Avatar );
|
||||
|
||||
virtual void CalculatePosition();
|
||||
virtual void Push(hsBool recenter = true);
|
||||
virtual void Pop();
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
// for console hack
|
||||
static hsBool fDontFade;
|
||||
protected:
|
||||
plSceneObject* fPosNode;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class plCameraBrain1_Fixed : public plCameraBrain1
|
||||
{
|
||||
public:
|
||||
|
||||
plCameraBrain1_Fixed();
|
||||
plCameraBrain1_Fixed(plCameraModifier1* pMod);
|
||||
~plCameraBrain1_Fixed();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1_Fixed );
|
||||
GETINTERFACE_ANY( plCameraBrain1_Fixed, plCameraBrain1 );
|
||||
|
||||
void SetTargetPoint(plCameraModifier1* pt) { fTargetPoint = pt; }
|
||||
|
||||
virtual void Update(hsBool forced = false);
|
||||
void CalculatePosition();
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
private:
|
||||
plCameraModifier1* fTargetPoint;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
// circle cam brain
|
||||
//
|
||||
class plCameraBrain1_Circle : public plCameraBrain1_Fixed
|
||||
{
|
||||
|
||||
public:
|
||||
enum CircleFlags
|
||||
{
|
||||
kLagged = 0x01,
|
||||
kAbsoluteLag = (0x02 | kLagged),
|
||||
kFarthest = 0x04,
|
||||
kTargetted = 0x08,
|
||||
kHasCenterObject = 0x10,
|
||||
kPOAObject = 0x20,
|
||||
kCircleLocalAvatar = 0x40,
|
||||
};
|
||||
protected:
|
||||
UInt32 fCircleFlags;
|
||||
hsPoint3 fCenter;
|
||||
plSceneObject* fCenterObject; // optional, use instead of fCenter
|
||||
hsScalar fRadius;
|
||||
hsScalar fCurRad, fGoalRad; // Radians
|
||||
plSceneObject* fPOAObj; // in this case the subject is who we stay close to/away from
|
||||
hsScalar fCirPerSec;
|
||||
|
||||
hsPoint3 IGetClosestPointOnCircle(const hsPoint3* toThisPt);
|
||||
public:
|
||||
plCameraBrain1_Circle();
|
||||
plCameraBrain1_Circle(plCameraModifier1* pMod);
|
||||
~plCameraBrain1_Circle();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraBrain1_Circle );
|
||||
GETINTERFACE_ANY( plCameraBrain1_Circle, plCameraBrain1_Fixed );
|
||||
|
||||
|
||||
virtual void Read(hsStream *stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream *stream, hsResMgr* mgr);
|
||||
virtual hsPoint3 MoveTowardsFromGoal(const hsPoint3* fromGoal, double secs, hsBool warp = false);
|
||||
virtual void Update(hsBool forced = false);
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
UInt32 GetCircleFlags() { return fCircleFlags; }
|
||||
hsPoint3* GetCenter() { return &fCenter; } // use GetCenterPoint
|
||||
hsPoint3 GetCenterPoint();
|
||||
hsScalar GetRadius() { return fRadius; }
|
||||
plSceneObject* GetCenterObject() { return fCenterObject; }
|
||||
|
||||
void SetCircumferencePerSec(hsScalar h) { fCirPerSec = h; }
|
||||
void SetCircleFlags(UInt32 f) { fCircleFlags|=f; }
|
||||
void SetCenter(hsPoint3* ctr) { fCenter = *ctr; } // Circle lies in the plane z = ctr->z
|
||||
void SetRadius(hsScalar radius) { fRadius = radius; }
|
||||
void SetFarCircleCam(hsBool farType) { if (farType) fCircleFlags |= kFarthest; else fCircleFlags &= ~kFarthest; }
|
||||
void SetCenterObjectKey(plKey k);
|
||||
void SetPOAObject(plSceneObject* pObj) { fPOAObj = pObj; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,478 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
|
||||
#include "plCameraModifier.h"
|
||||
#include "plCameraBrain.h"
|
||||
#include "plVirtualCamNeu.h"
|
||||
#include "hsTimer.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnSceneObject/plSceneObject.h"
|
||||
#include "../pnSceneObject/plCoordinateInterface.h"
|
||||
#include "../plMessage/plInputEventMsg.h"
|
||||
#include "../plMessage/plAnimCmdMsg.h"
|
||||
#include "../pnMessage/plTimeMsg.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "../pnKeyedObject/plFixedKey.h"
|
||||
#include "../plInputCore/plInputDevice.h"
|
||||
#include "../plInputCore/plInputManager.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "../pnMessage/plCameraMsg.h"
|
||||
#include "../plPhysical/plSimDefs.h"
|
||||
|
||||
#include "plPhysical.h"
|
||||
#include "../pnSceneObject/plSimulationInterface.h"
|
||||
#include "../plAvatar/plAvatarMgr.h"
|
||||
#include "../plAvatar/plArmatureMod.h"
|
||||
#include "../plAvatar/plAvCallbackAction.h"
|
||||
|
||||
// new stuff
|
||||
|
||||
plCameraModifier1::plCameraModifier1() :
|
||||
fBrain(nil),
|
||||
fSubObj(nil),
|
||||
fFOVw(45.0f),
|
||||
fFOVh(33.75f),
|
||||
fAnimated(false),
|
||||
fStartAnimOnPush(false),
|
||||
fStopAnimOnPop(false),
|
||||
fResetAnimOnPop(false),
|
||||
fInSubLastUpdate(false),
|
||||
fUpdateBrainTarget(false)
|
||||
{
|
||||
fFrom.Set(0,0,0);
|
||||
fAt.Set(0,1,0);
|
||||
}
|
||||
|
||||
|
||||
plCameraModifier1::~plCameraModifier1()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < GetNumTrans(); i++)
|
||||
delete(GetTrans(i));
|
||||
fTrans.SetCountAndZero(0);
|
||||
|
||||
for (i = 0; i < fMessageQueue.Count(); i++)
|
||||
hsRefCnt_SafeUnRef(fMessageQueue[i]);
|
||||
fMessageQueue.SetCountAndZero(0);
|
||||
|
||||
for (i = 0; i < fFOVInstructions.Count(); i++)
|
||||
hsRefCnt_SafeUnRef(fFOVInstructions[i]);
|
||||
fFOVInstructions.SetCountAndZero(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void plCameraModifier1::AddTarget(plSceneObject* so)
|
||||
{
|
||||
fTarget = so;
|
||||
if( plVirtualCam1::Instance() )
|
||||
plVirtualCam1::Instance()->AddCameraLoaded(so);
|
||||
fFrom = (so->GetWorldToLocal().GetTranslate());
|
||||
if (GetBrain())
|
||||
{
|
||||
if (fTarget->GetCoordinateInterface())
|
||||
GetBrain()->AddTarget();
|
||||
else
|
||||
fUpdateBrainTarget = true; // update the brain later
|
||||
}
|
||||
if (GetKey())
|
||||
{
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
void plCameraModifier1::SetSubject(plSceneObject* pObj)
|
||||
{
|
||||
if (GetBrain())
|
||||
GetBrain()->SetSubject(pObj);
|
||||
else
|
||||
fSubObj = pObj;
|
||||
}
|
||||
|
||||
plSceneObject* plCameraModifier1::GetSubject()
|
||||
{
|
||||
if (GetBrain())
|
||||
return GetBrain()->GetSubject();
|
||||
else
|
||||
return fSubObj;
|
||||
}
|
||||
|
||||
void plCameraModifier1::SetFOVw(hsScalar f, hsBool fUpdateVCam)
|
||||
{
|
||||
fFOVw = f;
|
||||
if (plVirtualCam1::Instance() && fUpdateVCam)
|
||||
plVirtualCam1::SetFOV(fFOVw, fFOVh, this);
|
||||
}
|
||||
|
||||
void plCameraModifier1::SetFOVh(hsScalar f, hsBool fUpdateVCam)
|
||||
{
|
||||
fFOVh = f;
|
||||
if (plVirtualCam1::Instance() && fUpdateVCam)
|
||||
plVirtualCam1::SetFOV(fFOVw, fFOVh, this);
|
||||
}
|
||||
|
||||
hsBool plCameraModifier1::SetFaded(hsBool b)
|
||||
{
|
||||
if (GetBrain())
|
||||
return GetBrain()->SetFaded(b);
|
||||
return false;
|
||||
}
|
||||
|
||||
hsBool plCameraModifier1::GetFaded()
|
||||
{
|
||||
if (GetBrain())
|
||||
return GetBrain()->GetFaded();
|
||||
return false;
|
||||
}
|
||||
hsBool plCameraModifier1::MsgReceive(plMessage* msg)
|
||||
{
|
||||
if (GetBrain())
|
||||
GetBrain()->MsgReceive(msg);
|
||||
|
||||
plCameraMsg* pCamMsg = plCameraMsg::ConvertNoRef(msg);
|
||||
if (pCamMsg)
|
||||
{
|
||||
if (pCamMsg->Cmd(plCameraMsg::kAddFOVKeyframe))
|
||||
{
|
||||
hsRefCnt_SafeRef(msg);
|
||||
fFOVInstructions.Append(pCamMsg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (pCamMsg->Cmd(plCameraMsg::kSetAnimated))
|
||||
{
|
||||
fAnimated = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
plEventCallbackMsg* pEventMsg = plEventCallbackMsg::ConvertNoRef(msg);
|
||||
if (pEventMsg)
|
||||
{
|
||||
double time = (double)fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fAccel;
|
||||
double time2 = (double)pEventMsg->fEventTime;
|
||||
time = hsABS(time - time2);
|
||||
hsScalar h = fFOVInstructions[pEventMsg->fIndex]->GetConfig()->fFOVh;
|
||||
if (GetBrain())
|
||||
GetBrain()->SetFOVGoal(h, time);
|
||||
}
|
||||
|
||||
plAnimCmdMsg* pAnimMsg = plAnimCmdMsg::ConvertNoRef(msg);
|
||||
if (pAnimMsg)
|
||||
{
|
||||
hsRefCnt_SafeRef(msg);
|
||||
msg->ClearReceivers();
|
||||
msg->AddReceiver(msg->GetSender());
|
||||
fMessageQueue.Append(msg);
|
||||
return true;
|
||||
}
|
||||
plGenRefMsg* pRefMsg = plGenRefMsg::ConvertNoRef(msg);
|
||||
if (pRefMsg )
|
||||
{
|
||||
if( pRefMsg->GetContext() & (plRefMsg::kOnCreate | plRefMsg::kOnRequest) )
|
||||
{
|
||||
if (pRefMsg->fType == kRefBrain)
|
||||
{
|
||||
plCameraBrain1* pBrain = plCameraBrain1::ConvertNoRef(pRefMsg->GetRef());
|
||||
if (pBrain)
|
||||
{
|
||||
pBrain->SetCamera(this);
|
||||
fBrain = pBrain;
|
||||
if (fSubObj)
|
||||
fBrain->SetSubject(fSubObj);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (pRefMsg->fType == kRefCallbackMsg && fMessageQueue[pRefMsg->fWhich] != nil)
|
||||
{
|
||||
|
||||
plgDispatch::MsgSend(fMessageQueue[pRefMsg->fWhich]);
|
||||
fMessageQueue[pRefMsg->fWhich] = nil;
|
||||
}
|
||||
}
|
||||
else if( pRefMsg->GetContext() & (plRefMsg::kOnDestroy | plRefMsg::kOnRemove) )
|
||||
{
|
||||
plCameraBrain1* pBrain = (plCameraBrain1*)(pRefMsg->GetRef());
|
||||
if (fBrain == pBrain)
|
||||
fBrain = nil;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return plSingleModifier::MsgReceive(msg);
|
||||
}
|
||||
|
||||
|
||||
void plCameraModifier1::Update()
|
||||
{
|
||||
// update the brain
|
||||
|
||||
// this freeze thing is a useful debugging tool...
|
||||
if (plVirtualCam1::Instance()->freeze)
|
||||
return;
|
||||
|
||||
if (GetBrain())
|
||||
{
|
||||
if (fUpdateBrainTarget && fTarget->GetCoordinateInterface()) // if we need to update the brain and the target is loaded
|
||||
{
|
||||
fUpdateBrainTarget = false;
|
||||
GetBrain()->AddTarget(); // update the brain's target
|
||||
}
|
||||
|
||||
hsBool moveInSub = !(GetBrain()->HasFlag(plCameraBrain1::kIgnoreSubworldMovement));
|
||||
|
||||
if (moveInSub && GetBrain()->GetSubject())
|
||||
{
|
||||
plKey worldKey = nil;
|
||||
|
||||
// First check if this is a physical. If so, grab the subworld from that
|
||||
if (GetBrain()->GetSubject()->GetSimulationInterface())
|
||||
{
|
||||
plPhysical* phys = GetBrain()->GetSubject()->GetSimulationInterface()->GetPhysical();
|
||||
if (phys)
|
||||
worldKey = phys->GetWorldKey();
|
||||
}
|
||||
// Also, check if this is an avatar. They don't have physicals, you
|
||||
// have to ask the avatar controller for the subworld key.
|
||||
if (!worldKey)
|
||||
{
|
||||
plArmatureMod* armMod = plAvatarMgr::FindAvatar(plKey(GetBrain()->GetSubject()->GetKey()));
|
||||
if (armMod && armMod->GetController() )
|
||||
worldKey = armMod->GetController()->GetSubworld();
|
||||
}
|
||||
|
||||
if (worldKey)
|
||||
{
|
||||
// this picks up and moves the camera to it's previous subworld coordinate (so the subworld isn't moving out from underneath us)
|
||||
hsMatrix44 l2w, w2l;
|
||||
plSceneObject* so = plSceneObject::ConvertNoRef(worldKey->ObjectIsLoaded());
|
||||
if (so)
|
||||
{
|
||||
l2w = so->GetLocalToWorld();
|
||||
w2l = so->GetWorldToLocal();
|
||||
|
||||
if (fInSubLastUpdate)
|
||||
{
|
||||
if (!(fLastSubPos == fFrom && fLastSubPOA == fAt))
|
||||
{
|
||||
SetTargetPos(l2w * fLastSubPos);
|
||||
SetTargetPOA(l2w * fLastSubPOA);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fInSubLastUpdate = true;
|
||||
}
|
||||
GetBrain()->Update();
|
||||
fLastSubPos = w2l * GetTargetPos();
|
||||
fLastSubPOA = w2l * GetTargetPOA();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
fInSubLastUpdate = false;
|
||||
}
|
||||
}
|
||||
GetBrain()->Update();
|
||||
fLastSubPos = GetTargetPos();
|
||||
fLastSubPOA = GetTargetPOA();
|
||||
}
|
||||
}
|
||||
|
||||
void plCameraModifier1::Read(hsStream* stream, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Read(stream, mgr);
|
||||
fBrain = nil;
|
||||
mgr->ReadKeyNotifyMe(stream, TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, 0, kRefBrain), plRefFlags::kActiveRef);
|
||||
int count = stream->ReadSwap32();
|
||||
int i;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
plKey key = mgr->ReadKey(stream);
|
||||
hsBool cutpos = stream->ReadBool();
|
||||
hsBool cutpoa = stream->ReadBool();
|
||||
hsBool ignore = stream->ReadBool();
|
||||
hsScalar v = stream->ReadSwapScalar();
|
||||
hsScalar a = stream->ReadSwapScalar();
|
||||
hsScalar d = stream->ReadSwapScalar();
|
||||
hsScalar pV = stream->ReadSwapScalar();
|
||||
hsScalar pA = stream->ReadSwapScalar();
|
||||
hsScalar pD = stream->ReadSwapScalar();
|
||||
|
||||
CamTrans* camTrans = TRACKED_NEW CamTrans(key);
|
||||
camTrans->fAccel = a;
|
||||
camTrans->fDecel = d;
|
||||
camTrans->fVelocity = v;
|
||||
camTrans->fPOAAccel = pA;
|
||||
camTrans->fPOADecel = pD;
|
||||
camTrans->fPOAVelocity = pV;
|
||||
camTrans->fCutPos = cutpos;
|
||||
camTrans->fCutPOA = cutpoa;
|
||||
camTrans->fIgnore = ignore;
|
||||
|
||||
fTrans.Append(camTrans);
|
||||
}
|
||||
fFOVw = stream->ReadSwapFloat();
|
||||
fFOVh = stream->ReadSwapFloat();
|
||||
int n = stream->ReadSwap32();
|
||||
fMessageQueue.SetCountAndZero(n);
|
||||
for(i = 0; i < n; i++ )
|
||||
{
|
||||
plMessage* pMsg = plMessage::ConvertNoRef(mgr->ReadCreatable(stream));
|
||||
fMessageQueue[i] = pMsg;
|
||||
}
|
||||
for(i = 0; i < n; i++ )
|
||||
{
|
||||
mgr->ReadKeyNotifyMe(stream, TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, i, kRefCallbackMsg), plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
n = stream->ReadSwap32();
|
||||
fFOVInstructions.SetCountAndZero(n);
|
||||
for(i = 0; i < n; i++ )
|
||||
{
|
||||
plCameraMsg* pMsg = plCameraMsg::ConvertNoRef(mgr->ReadCreatable(stream));
|
||||
fFOVInstructions[i] = pMsg;
|
||||
}
|
||||
fAnimated = stream->ReadBool();
|
||||
fStartAnimOnPush = stream->ReadBool();
|
||||
fStopAnimOnPop = stream->ReadBool();
|
||||
fResetAnimOnPop = stream->ReadBool();
|
||||
|
||||
}
|
||||
|
||||
void plCameraModifier1::Write(hsStream* stream, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Write(stream, mgr);
|
||||
if (fBrain)
|
||||
mgr->WriteKey(stream, fBrain );
|
||||
|
||||
int i = fTrans.Count();
|
||||
stream->WriteSwap32(i);
|
||||
for (i = 0; i < fTrans.Count(); i++)
|
||||
{
|
||||
mgr->WriteKey(stream, fTrans[i]->fTransTo);
|
||||
stream->WriteBool(fTrans[i]->fCutPos);
|
||||
stream->WriteBool(fTrans[i]->fCutPOA);
|
||||
stream->WriteBool(fTrans[i]->fIgnore);
|
||||
stream->WriteSwapScalar(fTrans[i]->fVelocity);
|
||||
stream->WriteSwapScalar(fTrans[i]->fAccel);
|
||||
stream->WriteSwapScalar(fTrans[i]->fDecel);
|
||||
stream->WriteSwapScalar(fTrans[i]->fPOAVelocity);
|
||||
stream->WriteSwapScalar(fTrans[i]->fPOAAccel);
|
||||
stream->WriteSwapScalar(fTrans[i]->fPOADecel);
|
||||
}
|
||||
stream->WriteSwapFloat(fFOVw);
|
||||
stream->WriteSwapFloat(fFOVh);
|
||||
stream->WriteSwap32(fMessageQueue.Count());
|
||||
for (i = 0; i < fMessageQueue.Count(); i++)
|
||||
{
|
||||
mgr->WriteCreatable(stream, fMessageQueue[i]);
|
||||
}
|
||||
for (i = 0; i < fMessageQueue.Count(); i++)
|
||||
{
|
||||
mgr->WriteKey(stream, fMessageQueue[i]->GetSender());
|
||||
}
|
||||
stream->WriteSwap32(fFOVInstructions.Count());
|
||||
for (i = 0; i < fFOVInstructions.Count(); i++)
|
||||
{
|
||||
mgr->WriteCreatable(stream, fFOVInstructions[i]);
|
||||
}
|
||||
stream->WriteBool(fAnimated);
|
||||
stream->WriteBool(fStartAnimOnPush);
|
||||
stream->WriteBool(fStopAnimOnPop);
|
||||
stream->WriteBool(fResetAnimOnPop);
|
||||
}
|
||||
|
||||
void plCameraModifier1::Push(hsBool recenter)
|
||||
{
|
||||
if (fAnimated)
|
||||
{
|
||||
if (fStartAnimOnPush)
|
||||
{
|
||||
plAnimCmdMsg* pMsg = TRACKED_NEW plAnimCmdMsg;
|
||||
pMsg->SetCmd(plAnimCmdMsg::kRunForward);
|
||||
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
|
||||
pMsg->AddReceiver(GetTarget()->GetKey());
|
||||
if (GetBrain() && GetBrain()->GetSubject())
|
||||
pMsg->AddReceiver(GetBrain()->GetSubject()->GetKey());
|
||||
pMsg->Send();
|
||||
}
|
||||
}
|
||||
if (fBrain)
|
||||
fBrain->Push(recenter);
|
||||
|
||||
|
||||
if (GetKey())
|
||||
{
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plMouseEventMsg::Index(), GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
void plCameraModifier1::Pop()
|
||||
{
|
||||
if (fAnimated)
|
||||
{
|
||||
if (fStopAnimOnPop)
|
||||
{
|
||||
plAnimCmdMsg* pMsg = TRACKED_NEW plAnimCmdMsg;
|
||||
pMsg->SetCmd(plAnimCmdMsg::kStop);
|
||||
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
|
||||
pMsg->AddReceiver(GetTarget()->GetKey());
|
||||
if (GetBrain() && GetBrain()->GetSubject())
|
||||
pMsg->AddReceiver(GetBrain()->GetSubject()->GetKey());
|
||||
pMsg->Send();
|
||||
}
|
||||
if (fResetAnimOnPop)
|
||||
{
|
||||
plAnimCmdMsg* pMsg = TRACKED_NEW plAnimCmdMsg;
|
||||
pMsg->SetCmd(plAnimCmdMsg::kGoToBegin);
|
||||
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
|
||||
pMsg->AddReceiver(GetTarget()->GetKey());
|
||||
if (GetBrain() && GetBrain()->GetSubject())
|
||||
pMsg->AddReceiver(GetBrain()->GetSubject()->GetKey());
|
||||
pMsg->Send();
|
||||
}
|
||||
}
|
||||
if (fBrain)
|
||||
fBrain->Pop();
|
||||
if (GetKey()) // the reason we might not have a key is a special run-time POA which doesn't need to receive messages...
|
||||
{
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plMouseEventMsg::Index(), GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
void plCameraModifier1::SetTransform(hsPoint3 at)
|
||||
{
|
||||
if (!GetTarget())
|
||||
return;
|
||||
hsMatrix44 l2w;
|
||||
hsMatrix44 w2l;
|
||||
hsVector3 up(0,0,1);
|
||||
l2w.Make(&fFrom, &at, &up);
|
||||
l2w.GetInverse(&w2l);
|
||||
IGetTargetCoordinateInterface(0)->SetTransform( l2w, w2l );
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plCameraModifier_inc
|
||||
#define plCameraModifier_inc
|
||||
|
||||
#include "../pnModifier/plSingleModifier.h"
|
||||
#include "hsBitVector.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "hsTemplates.h"
|
||||
|
||||
class plPipeline;
|
||||
class plKey;
|
||||
class plCameraBrain1;
|
||||
class plCameraMsg;
|
||||
struct CamTrans
|
||||
{
|
||||
// used when creating default track transitions at runtime
|
||||
CamTrans(plKey to)
|
||||
{
|
||||
fTransTo = to;
|
||||
|
||||
fAccel = 60.0f;
|
||||
fDecel = 60.0f;
|
||||
fVelocity = 60.0f;
|
||||
fPOADecel = 60.0f;
|
||||
fPOAAccel = 60.0f;
|
||||
fPOAVelocity = 60.0f;
|
||||
|
||||
fCutPos = false;
|
||||
fCutPOA = false;
|
||||
fIgnore = false;
|
||||
}
|
||||
plKey fTransTo;
|
||||
|
||||
hsBool fCutPos;
|
||||
hsBool fCutPOA;
|
||||
hsBool fIgnore;
|
||||
hsScalar fAccel;
|
||||
hsScalar fDecel;
|
||||
hsScalar fVelocity;
|
||||
hsScalar fPOAAccel;
|
||||
hsScalar fPOADecel;
|
||||
hsScalar fPOAVelocity;
|
||||
|
||||
};
|
||||
|
||||
class plCameraModifier1 : public plSingleModifier
|
||||
{
|
||||
enum
|
||||
{
|
||||
kRefBrain,
|
||||
kRefCut,
|
||||
kRefTrack,
|
||||
kRefCallbackMsg,
|
||||
};
|
||||
protected:
|
||||
|
||||
void Output();
|
||||
virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty) { return true; }
|
||||
|
||||
public:
|
||||
|
||||
plCameraModifier1();
|
||||
virtual ~plCameraModifier1();
|
||||
|
||||
CLASSNAME_REGISTER( plCameraModifier1 );
|
||||
GETINTERFACE_ANY( plCameraModifier1, plSingleModifier );
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
void Initialize();
|
||||
virtual void Update();
|
||||
|
||||
virtual void AddTarget(plSceneObject* so);
|
||||
|
||||
void SetBrain(plCameraBrain1* brain) { fBrain = brain; }
|
||||
|
||||
plCameraBrain1* GetBrain() { return fBrain;}
|
||||
|
||||
hsPoint3 GetTargetPos() { return fFrom; }
|
||||
hsPoint3 GetTargetPOA() { return fAt; }
|
||||
hsPoint3 GetSubworldPos() { return fLastSubPos; }
|
||||
hsPoint3 GetSubworldPOA() { return fLastSubPOA; }
|
||||
|
||||
|
||||
void SetTransform(hsPoint3 at);
|
||||
void SetTargetPos(hsPoint3 pos) { fFrom = pos; }
|
||||
void SetTargetPOA(hsPoint3 pos) { fAt = pos; }
|
||||
void SetSubworldPos(hsPoint3 pos) { fLastSubPos = pos; }
|
||||
void SetSubworldPOA(hsPoint3 pos) { fLastSubPOA = pos; }
|
||||
hsScalar GetFOVw() { return fFOVw; }
|
||||
hsScalar GetFOVh() { return fFOVh; }
|
||||
void SetFOVw(hsScalar f, hsBool fUpdateVCam = true);
|
||||
void SetFOVh(hsScalar f, hsBool fUpdateVCam = true);
|
||||
hsBool GetInSubworld() { return fInSubLastUpdate; }
|
||||
void InSubworld(hsBool b) { fInSubLastUpdate = b; }
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
void AddTrans(CamTrans* t) { fTrans.Append(t); }
|
||||
int GetNumTrans() { return fTrans.Count(); }
|
||||
CamTrans* GetTrans(int i) { return fTrans[i]; }
|
||||
void SetSubject(plSceneObject* pObj);
|
||||
plSceneObject* GetSubject();
|
||||
|
||||
virtual void Push(hsBool recenter = true);
|
||||
virtual void Pop();
|
||||
|
||||
virtual hsBool GetFaded();
|
||||
virtual hsBool SetFaded(hsBool b);
|
||||
|
||||
hsBool IsAnimated() { return fAnimated; }
|
||||
void SetAnimCommands(hsBool a, hsBool b, hsBool c) { fStartAnimOnPush = a; fStopAnimOnPop = b; fResetAnimOnPop = c; }
|
||||
|
||||
private:
|
||||
hsPoint3 fFrom;
|
||||
hsPoint3 fAt;
|
||||
plCameraBrain1* fBrain; // the 'logic' portion of the camera
|
||||
hsTArray<CamTrans*> fTrans;
|
||||
plSceneObject* fSubObj;
|
||||
hsScalar fFOVw;
|
||||
hsScalar fFOVh;
|
||||
hsTArray<plMessage*> fMessageQueue;
|
||||
hsTArray<plCameraMsg*> fFOVInstructions;
|
||||
hsBool fAnimated, fStartAnimOnPush, fStopAnimOnPop, fResetAnimOnPop;
|
||||
hsPoint3 fLastSubPos;
|
||||
hsPoint3 fLastSubPOA;
|
||||
hsBool fInSubLastUpdate;
|
||||
hsBool fUpdateBrainTarget; // sometimes our target isn't loaded yet, so wait to update the brain til later
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif plCameraModifier_inc
|
@ -0,0 +1,72 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnSceneObject/plDrawInterface.h"
|
||||
#include "../plMessage/plInterestingPing.h"
|
||||
#include "hsBounds.h"
|
||||
#include "plInterestingModifier.h"
|
||||
#include "../pnSceneObject/plSceneObject.h"
|
||||
#include "../pnMessage/plTimeMsg.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
|
||||
|
||||
hsScalar plInterestingModifier::fInterestRadius = 100.0f;
|
||||
hsScalar plInterestingModifier::fInterestWeight = 1.0f;
|
||||
|
||||
|
||||
hsBool plInterestingModifier::IEval(double secs, hsScalar del, UInt32 dirty)
|
||||
{
|
||||
for (int i=0; i < GetNumTargets(); i++)
|
||||
{
|
||||
if( GetTarget(i) && GetTarget(i)->GetDrawInterface() )
|
||||
{
|
||||
const hsBounds3Ext& targBnd = GetTarget(i)->GetDrawInterface()->GetWorldBounds();
|
||||
if( targBnd.GetType() == kBoundsNormal )
|
||||
{
|
||||
plInterestingModMsg* pMsg = TRACKED_NEW plInterestingModMsg;
|
||||
pMsg->fPos= GetTarget(i)->GetDrawInterface()->GetWorldBounds().GetCenter();
|
||||
pMsg->fSize = GetTarget(i)->GetDrawInterface()->GetWorldBounds().GetMaxDim();
|
||||
pMsg->fRadius = fInterestRadius;
|
||||
pMsg->fWeight = fInterestWeight;
|
||||
pMsg->fObj = GetTarget(i)->GetKey();
|
||||
pMsg->fType = GetType();
|
||||
pMsg->SetBCastFlag( plMessage::kPropagateToModifiers );
|
||||
plgDispatch::MsgSend( pMsg );
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void plInterestingModifier::AddTarget(plSceneObject* so)
|
||||
{
|
||||
fTarget = so;
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plInterestingModifier_inc
|
||||
#define plInterestingModifier_inc
|
||||
|
||||
#include "../pnModifier/plSingleModifier.h"
|
||||
#include "../pnMessage/plMessage.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "hsGeometry3.h"
|
||||
#include "hsStream.h"
|
||||
|
||||
class plInputEventMsg;
|
||||
|
||||
class plInterestingModifier : public plSingleModifier
|
||||
{
|
||||
protected:
|
||||
|
||||
enum
|
||||
{
|
||||
kTypeInteresting = 0,
|
||||
kTypeLookAtMod,
|
||||
};
|
||||
|
||||
UInt8 fType;
|
||||
hsScalar fView;
|
||||
|
||||
static hsScalar fInterestRadius;
|
||||
static hsScalar fInterestWeight;
|
||||
|
||||
virtual hsBool IEval(double secs, hsScalar del, UInt32 dirty);
|
||||
|
||||
public:
|
||||
plInterestingModifier(){ fType = kTypeInteresting;}
|
||||
virtual ~plInterestingModifier(){;}
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg) {return false;}
|
||||
|
||||
CLASSNAME_REGISTER( plInterestingModifier );
|
||||
GETINTERFACE_ANY( plInterestingModifier, plSingleModifier );
|
||||
|
||||
hsScalar GetInterestWeight() { return fInterestWeight; }
|
||||
hsScalar GetInterestRadius() { return fInterestRadius; }
|
||||
|
||||
void SetInterestWeight(hsScalar _InterestRadius) { fInterestWeight =_InterestRadius; }
|
||||
void SetInterestRadius(hsScalar _InterestWeight) { fInterestRadius =_InterestWeight; }
|
||||
|
||||
virtual void AddTarget(plSceneObject* so);
|
||||
|
||||
void SetType(UInt8 type) { fType = type; }
|
||||
UInt8 GetType() { return fType; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif plInterestingModifier_inc
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,235 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plVirtualCam1_inc
|
||||
#define plVirtualCam1_inc
|
||||
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "hsMatrix44.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
class plPipeline;
|
||||
class plCameraModifier1;
|
||||
class plCameraBrain1;
|
||||
class plSceneObject;
|
||||
class plKey;
|
||||
class hsGMaterial;
|
||||
class plDrawableSpans;
|
||||
class plCameraProxy;
|
||||
class plSceneNode;
|
||||
class plDebugInputInterface;
|
||||
class plPlate;
|
||||
|
||||
#include "hsTemplates.h"
|
||||
|
||||
struct CamTrans;
|
||||
struct hsColorRGBA;
|
||||
|
||||
#define POS_TRANS_OFF 0
|
||||
#define POS_TRANS_FIXED 1
|
||||
#define POS_TRANS_FOLLOW 2
|
||||
#define POA_TRANS_OFF 3
|
||||
#define POA_TRANS_FIXED 4
|
||||
#define POA_TRANS_FOLLOW 5
|
||||
|
||||
class plVirtualCam1 : public hsKeyedObject
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
void Output();
|
||||
void IUpdate();
|
||||
void INext();
|
||||
|
||||
public:
|
||||
enum flags
|
||||
{
|
||||
kSetFOV,
|
||||
kCutNextTrans,
|
||||
kRender,
|
||||
kRegionIgnore,
|
||||
kFirstPersonEnabled,
|
||||
kResponderForced3rd,
|
||||
kScriptsForced3rd,
|
||||
kScriptsDisabled1st,
|
||||
kAvatarWalking,
|
||||
kUnPanCamera,
|
||||
kInterpPanLimits,
|
||||
kFalling,
|
||||
//kRegisteredForBehaviors, // not reliable anymore since we have a dummy avatar in the startup age
|
||||
kFirstPersonAtLinkOut,
|
||||
kJustLinkedIn,
|
||||
kFirstPersonUserSelected,
|
||||
};
|
||||
|
||||
enum action
|
||||
{
|
||||
kPush = 0,
|
||||
kPop,
|
||||
kReplacement,
|
||||
kBackgroundPop,
|
||||
kRefCamera,
|
||||
};
|
||||
plVirtualCam1();
|
||||
virtual ~plVirtualCam1();
|
||||
|
||||
CLASSNAME_REGISTER( plVirtualCam1 );
|
||||
GETINTERFACE_ANY( plVirtualCam1, hsKeyedObject );
|
||||
|
||||
void SetPipeline(plPipeline* p);
|
||||
void Init();
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
static void SetFOV(hsScalar w, hsScalar h);
|
||||
static void SetFOV(hsScalar w, hsScalar h, plCameraModifier1* pCam);
|
||||
static void SetDepth(hsScalar h, hsScalar y);
|
||||
static hsScalar GetFOVw() { return fFOVw; }
|
||||
static hsScalar GetFOVh() { return fFOVh; }
|
||||
static hsScalar GetHither() { return fHither; }
|
||||
static hsScalar GetYon() { return fYon; }
|
||||
static void SetOffset(float x, float y, float z);
|
||||
static void SetAspectRatio(float aspect) { fAspectRatio = aspect; }
|
||||
static float GetAspectRatio() { return fAspectRatio; }
|
||||
|
||||
hsBool InTransition() { return fTransPos != POS_TRANS_OFF; }
|
||||
plCameraModifier1* GetCurrentCamera();
|
||||
plCameraModifier1* GetCurrentStackCamera();
|
||||
plCameraModifier1* GetTransitionCamera(){return fTransitionCamera;}
|
||||
hsBool Is1stPersonCamera();
|
||||
|
||||
hsBool HasMovementFlag(int f) { return fMoveFlags.IsBitSet(f); }
|
||||
void SetMovementFlag(int f, hsBool on = true) { fMoveFlags.SetBit(f, on);}
|
||||
|
||||
hsPoint3 GetCameraPos() { return fOutputPos; }
|
||||
hsPoint3 GetCameraPOA() { return fOutputPOA; }
|
||||
hsVector3 GetCameraUp() { return fOutputUp; }
|
||||
void SetCutNextTrans(); // used when player warps into a new camera region
|
||||
|
||||
const hsMatrix44 GetCurrentMatrix() { return fMatrix; }
|
||||
static plVirtualCam1* Instance() { return fInstance; }
|
||||
|
||||
int GetNumCameras() { return fCameraStack.Count(); }
|
||||
plCameraModifier1* GetCameraNumber(int camNumber);
|
||||
void RebuildStack(const plKey& key);
|
||||
|
||||
void SetFlags(int flag) { fFlags.SetBit(flag); }
|
||||
hsBool HasFlags(int flag) { return fFlags.IsBitSet(flag); }
|
||||
void ClearFlags(int flag) { fFlags.ClearBit(flag); }
|
||||
|
||||
// console command stuff
|
||||
static void Next();
|
||||
static void Prev();
|
||||
static void Deactivate();
|
||||
void CameraRegions(hsBool b) { fFlags.SetBit(kRegionIgnore,b); }
|
||||
void LogFOV(hsBool b) { printFOV = b; }
|
||||
void Drive();
|
||||
void PushThirdPerson();
|
||||
|
||||
static void AddMsgToLog(const char* msg);
|
||||
static hsBool IsCurrentCamera(const plCameraModifier1* mod);
|
||||
void ClearStack();
|
||||
|
||||
void AddCameraLoaded(plSceneObject* pCam) { fCamerasLoaded.Append(pCam); }
|
||||
hsBool RestoreFromName(const char* name);
|
||||
void StartUnPan();
|
||||
// these are for console access
|
||||
static hsBool fUseAccelOverride, freeze, alwaysCutForColin, WalkPan3rdPerson,StayInFirstPersonForever;
|
||||
static hsScalar fDecel, fAccel, fVel;
|
||||
static hsScalar fFallTimerDelay;
|
||||
|
||||
private:
|
||||
|
||||
void Reset(hsBool bRender);
|
||||
void PushCamera(plCameraModifier1* pCam, hsBool bDefault = false);
|
||||
void PopCamera(plCameraModifier1* pCam);
|
||||
void AddCameraToStack(plCameraModifier1* pCam);
|
||||
void PopAll();
|
||||
void CreateDefaultCamera(plSceneObject* subject);
|
||||
void StartTransition(CamTrans* transition);
|
||||
void RunTransition();
|
||||
void FinishTransition();
|
||||
void SetRender(hsBool render);
|
||||
void IHandleCameraStatusLog(plCameraModifier1* pMod, int action);
|
||||
void ICreatePlate();
|
||||
void FreezeOutput(int frames) { fFreezeCounter = frames; } // I hate this and I hate myself for doing it
|
||||
void UnFadeAvatarIn(int frames) { fFadeCounter = frames; } // ditto
|
||||
void FirstPersonOverride();
|
||||
|
||||
void AdjustForInput();
|
||||
void UnPanIfNeeded();
|
||||
void StartInterpPanLimits();
|
||||
void InterpPanLimits();
|
||||
|
||||
plPipeline* fPipe;
|
||||
hsMatrix44 fMatrix;
|
||||
hsPoint3 fOutputPos;
|
||||
hsPoint3 fOutputPOA;
|
||||
hsVector3 fOutputUp;
|
||||
int fTransPos;
|
||||
plDebugInputInterface* fCameraDriveInterface;
|
||||
plPlate* fEffectPlate;
|
||||
FILE* foutLog;
|
||||
hsTArray<plCameraModifier1*> fCameraStack;
|
||||
int fFreezeCounter;
|
||||
int fFadeCounter;
|
||||
hsBitVector fFlags;
|
||||
hsTArray<plSceneObject*> fCamerasLoaded;
|
||||
hsBitVector fMoveFlags;
|
||||
hsScalar fX;
|
||||
hsScalar fY;
|
||||
hsScalar fXPanLimit;
|
||||
hsScalar fZPanLimit;
|
||||
hsScalar fXPanLimitGoal;
|
||||
hsScalar fZPanLimitGoal;
|
||||
hsScalar fXUnPanRate;
|
||||
hsScalar fZUnPanRate;
|
||||
hsScalar fXPanInterpRate;
|
||||
hsScalar fZPanInterpRate;
|
||||
double fUnPanEndTime;
|
||||
double fInterpPanLimitTime;
|
||||
hsScalar fRetainedFY;
|
||||
|
||||
// built-in cameras
|
||||
plCameraModifier1* fDriveCamera; // for driving around
|
||||
plCameraModifier1* fTransitionCamera; // transitions between cameras placed in scenes
|
||||
plCameraModifier1* fPythonOverride; // a special camera pushed by python
|
||||
plCameraModifier1* fFirstPersonOverride; // the built-in first person camera
|
||||
plCameraModifier1* fPrevCam; // the last camera we were displaying
|
||||
plCameraModifier1* fThirdPersonCam; // built in third person cam for ccr's when they jump about
|
||||
|
||||
static hsScalar fFOVh, fFOVw;
|
||||
static hsScalar fHither, fYon;
|
||||
static plVirtualCam1* fInstance;
|
||||
static hsBool printFOV;
|
||||
static hsScalar fPanResponseTime;
|
||||
static float fAspectRatio;
|
||||
hsBool fForceCutOnce;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif plVirtualCam1_inc
|
Reference in New Issue
Block a user