Skip to content

Commit

Permalink
Format xrEngine sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 12, 2014
1 parent 2b2d0a3 commit 4aa9cd1
Show file tree
Hide file tree
Showing 249 changed files with 32,682 additions and 30,812 deletions.
108 changes: 59 additions & 49 deletions src/xrEngine/CameraBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@

CCameraBase::CCameraBase(CObject* p, u32 flags)
{
m_Flags.assign (flags);
vPosition.set (0,0,0);
vDirection.set (0,0,1);
vNormal.set (0,1,0);
yaw = 0;
pitch = 0;
roll = 0;
lim_yaw.set (0.f,0.f);
lim_pitch.set (0.f,0.f);
lim_roll.set (0.f,0.f);
bClampYaw = false;
bClampPitch = false;
bClampRoll = false;
SetParent (p);
f_fov = 90;
f_aspect = 1.f;
tag = 0;
m_Flags.assign(flags);
vPosition.set(0, 0, 0);
vDirection.set(0, 0, 1);
vNormal.set(0, 1, 0);
yaw = 0;
pitch = 0;
roll = 0;
lim_yaw.set(0.f, 0.f);
lim_pitch.set(0.f, 0.f);
lim_roll.set(0.f, 0.f);
bClampYaw = false;
bClampPitch = false;
bClampRoll = false;
SetParent(p);
f_fov = 90;
f_aspect = 1.f;
tag = 0;
}

CCameraBase::~CCameraBase()
Expand All @@ -34,51 +34,61 @@ CCameraBase::~CCameraBase()

void CCameraBase::Load(LPCSTR section)
{
rot_speed = pSettings->r_fvector3 (section,"rot_speed");
rot_speed = pSettings->r_fvector3(section, "rot_speed");

lim_yaw = pSettings->r_fvector2 (section,"lim_yaw");
lim_pitch = pSettings->r_fvector2 (section,"lim_pitch");
lim_yaw = pSettings->r_fvector2(section, "lim_yaw");
lim_pitch = pSettings->r_fvector2(section, "lim_pitch");

bClampPitch = (0!=lim_pitch[0])||(0!=lim_pitch[1]);
bClampYaw = (0!=lim_yaw[0])||(0!=lim_yaw[1]);
bClampPitch = (0 != lim_pitch[0]) || (0 != lim_pitch[1]);
bClampYaw = (0 != lim_yaw[0]) || (0 != lim_yaw[1]);

if (bClampPitch) pitch = (lim_pitch[0]+lim_pitch[1])*0.5f;
if (bClampYaw) yaw = (lim_yaw[0]+lim_yaw[1])*0.5f;
if (bClampPitch) pitch = (lim_pitch[0] + lim_pitch[1])*0.5f;
if (bClampYaw) yaw = (lim_yaw[0] + lim_yaw[1])*0.5f;
}

IC float AClamp(Fvector2& l, float v){
return (2*v-l[0]-l[1])/(l[1]-l[0]);
IC float AClamp(Fvector2& l, float v)
{
return (2 * v - l[0] - l[1]) / (l[1] - l[0]);
}

float CCameraBase::CheckLimYaw( ){
if (bClampYaw){
return AClamp(lim_yaw,yaw);
}else
return 0;
float CCameraBase::CheckLimYaw()
{
if (bClampYaw)
{
return AClamp(lim_yaw, yaw);
}
else
return 0;
}

float CCameraBase::CheckLimPitch( ){
if (bClampYaw){
return AClamp(lim_pitch,pitch);
}else
return 0;
float CCameraBase::CheckLimPitch()
{
if (bClampYaw)
{
return AClamp(lim_pitch, pitch);
}
else
return 0;
}

float CCameraBase::CheckLimRoll( ){
if (bClampYaw){
return AClamp(lim_roll,roll);
}else
return 0;
float CCameraBase::CheckLimRoll()
{
if (bClampYaw)
{
return AClamp(lim_roll, roll);
}
else
return 0;
}
SCamEffectorInfo::SCamEffectorInfo()
{
p.set (0,0,0);
d.set (0,0,1);
n.set (0,1,0);
p.set(0, 0, 0);
d.set(0, 0, 1);
n.set(0, 1, 0);

fFov = 90.0f;
fFar = 100.0f;
fAspect = 1.f;
dont_apply = false;
affected_on_hud = true;
fFov = 90.0f;
fFar = 100.0f;
fAspect = 1.f;
dont_apply = false;
affected_on_hud = true;
}
101 changes: 51 additions & 50 deletions src/xrEngine/CameraBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,76 +11,77 @@
// refs
class CObject;

class ENGINE_API CCameraBase
class ENGINE_API CCameraBase
{
protected:
CObject* parent;
CObject* parent;

public:
BOOL bClampYaw, bClampPitch, bClampRoll;
float yaw,pitch,roll;
BOOL bClampYaw, bClampPitch, bClampRoll;
float yaw, pitch, roll;

enum{
flRelativeLink = (1<<0),
flPositionRigid = (1<<1),
flDirectionRigid = (1<<2),
};
Flags32 m_Flags;
enum
{
flRelativeLink = (1 << 0),
flPositionRigid = (1 << 1),
flDirectionRigid = (1 << 2),
};
Flags32 m_Flags;

ECameraStyle style;
Fvector2 lim_yaw,lim_pitch,lim_roll;
Fvector rot_speed;
ECameraStyle style;
Fvector2 lim_yaw, lim_pitch, lim_roll;
Fvector rot_speed;

Fvector vPosition;
Fvector vDirection;
Fvector vNormal;
float f_fov;
float f_aspect;
Fvector vPosition;
Fvector vDirection;
Fvector vNormal;
float f_fov;
float f_aspect;

IC Fvector Position () const { return vPosition; }
IC Fvector Direction () const { return vDirection;}
IC Fvector Up () const { return vNormal; }
IC Fvector Right () const { return Fvector().crossproduct( vNormal, vDirection ); }
IC float Fov () const { return f_fov; }
IC float Aspect () const { return f_aspect; }
IC Fvector Position() const { return vPosition; }
IC Fvector Direction() const { return vDirection; }
IC Fvector Up() const { return vNormal; }
IC Fvector Right() const { return Fvector().crossproduct(vNormal, vDirection); }
IC float Fov() const { return f_fov; }
IC float Aspect() const { return f_aspect; }

int tag;
int tag;
public:
CCameraBase ( CObject* p, u32 flags );
virtual ~CCameraBase ( );
virtual void Load (LPCSTR section);
void SetParent ( CObject* p ) {parent=p; VERIFY(p);}
virtual void OnActivate ( CCameraBase* old_cam ) {;}
virtual void OnDeactivate ( ) {;}
virtual void Move ( int cmd, float val=0, float factor=1.0f) {;}
virtual void Update ( Fvector& point, Fvector& noise_angle ) {;}
virtual void Get ( Fvector& P, Fvector& D, Fvector& N ) {P.set(vPosition);D.set(vDirection);N.set(vNormal);}
virtual void Set ( const Fvector& P, const Fvector& D, const Fvector& N ){vPosition.set(P);vDirection.set(D);vNormal.set(N);}
virtual void Set ( float Y, float P, float R ) {yaw=Y;pitch=P;roll=R;}

virtual float GetWorldYaw ( ) { return 0; };
virtual float GetWorldPitch ( ) { return 0; };
CCameraBase(CObject* p, u32 flags);
virtual ~CCameraBase();
virtual void Load(LPCSTR section);
void SetParent(CObject* p) { parent = p; VERIFY(p); }
virtual void OnActivate(CCameraBase* old_cam) { ; }
virtual void OnDeactivate() { ; }
virtual void Move(int cmd, float val = 0, float factor = 1.0f) { ; }
virtual void Update(Fvector& point, Fvector& noise_angle) { ; }
virtual void Get(Fvector& P, Fvector& D, Fvector& N) { P.set(vPosition); D.set(vDirection); N.set(vNormal); }
virtual void Set(const Fvector& P, const Fvector& D, const Fvector& N) { vPosition.set(P); vDirection.set(D); vNormal.set(N); }
virtual void Set(float Y, float P, float R) { yaw = Y; pitch = P; roll = R; }

virtual float CheckLimYaw ( );
virtual float CheckLimPitch ( );
virtual float CheckLimRoll ( );
virtual float GetWorldYaw() { return 0; };
virtual float GetWorldPitch() { return 0; };

virtual float CheckLimYaw();
virtual float CheckLimPitch();
virtual float CheckLimRoll();
};


template<typename T>
IC void tviewport_size( CRenderDeviceBase& D, float _viewport_near, const T &cam_info, float& h_w, float& h_h)
IC void tviewport_size(CRenderDeviceBase& D, float _viewport_near, const T& cam_info, float& h_w, float& h_h)
{
h_h = _viewport_near*tan(deg2rad(cam_info.Fov())/2.f);
VERIFY2( _valid(h_h), make_string("invalide viewporrt params fov: %f ", cam_info.Fov()) );
float aspect = D.fASPECT;//cam_info.Aspect();
VERIFY( aspect>EPS );
h_w = h_h/aspect;
h_h = _viewport_near*tan(deg2rad(cam_info.Fov()) / 2.f);
VERIFY2(_valid(h_h), make_string("invalide viewporrt params fov: %f ", cam_info.Fov()));
float aspect = D.fASPECT;//cam_info.Aspect();
VERIFY(aspect > EPS);
h_w = h_h / aspect;
}

template<typename T>
IC void viewport_size( float _viewport_near, const T &cam_info, float& h_w, float& h_h)
IC void viewport_size(float _viewport_near, const T& cam_info, float& h_w, float& h_h)
{
tviewport_size<T>( Device, _viewport_near, cam_info, h_w, h_h );
tviewport_size<T>(Device, _viewport_near, cam_info, h_w, h_h);
}

#endif // !defined(AFX_CAMERABASE_H__B11F8AE1_1213_11D4_B4E3_4854E82A090D__INCLUDED_)
32 changes: 16 additions & 16 deletions src/xrEngine/CameraDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
#include "iinputreceiver.h"
class ENGINE_API CCameraDebug :
public CCameraBase,
public pureRender,
public IInputReceiver
public CCameraBase,
public pureRender,
public IInputReceiver
{
D3DXMATRIX g_matPosition;
D3DXVECTOR3 g_vecVelocity;
D3DXVECTOR3 g_vecAngularVelocity;
Fvector savedP,savedD,savedN;
ECameraStyle savedStyle;
Flags32 savedDF;
D3DXMATRIX g_matPosition;
D3DXVECTOR3 g_vecVelocity;
D3DXVECTOR3 g_vecAngularVelocity;
Fvector savedP,savedD,savedN;
ECameraStyle savedStyle;
Flags32 savedDF;
public:
virtual void OnMove (void);
virtual void OnCameraActivate ( CCameraBase* old_cam );
virtual void OnCameraDeactivate ( );
virtual void OnRender ( );
virtual void IR_OnKeyboardPress (int dik);
virtual void OnMove (void);
virtual void OnCameraActivate ( CCameraBase* old_cam );
virtual void OnCameraDeactivate ( );
virtual void OnRender ( );
virtual void IR_OnKeyboardPress (int dik);
CCameraDebug();
virtual ~CCameraDebug();
CCameraDebug();
virtual ~CCameraDebug();
};
*/
77 changes: 40 additions & 37 deletions src/xrEngine/CameraDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,57 @@

struct ENGINE_API SBaseEffector
{
typedef fastdelegate::FastDelegate0<> CB_ON_B_REMOVE;
CB_ON_B_REMOVE m_on_b_remove_callback;
virtual ~SBaseEffector(){}
typedef fastdelegate::FastDelegate0<> CB_ON_B_REMOVE;
CB_ON_B_REMOVE m_on_b_remove_callback;
virtual ~SBaseEffector() {}
};

struct ENGINE_API SCamEffectorInfo
{
Fvector p;
Fvector d;
Fvector n;
Fvector r;
float fFov;
float fFar;
float fAspect;
bool dont_apply;
bool affected_on_hud;
SCamEffectorInfo();
SCamEffectorInfo& operator = (const SCamEffectorInfo& other)
{
p = other.p;
d = other.d;
n = other.n;
r = other.r;
fFov = other.fFov;
fFar = other.fFar;
fAspect = other.fAspect;
dont_apply = other.dont_apply;
affected_on_hud = other.affected_on_hud;
return *this;
}
Fvector p;
Fvector d;
Fvector n;
Fvector r;
float fFov;
float fFar;
float fAspect;
bool dont_apply;
bool affected_on_hud;
SCamEffectorInfo();
SCamEffectorInfo& operator = (const SCamEffectorInfo& other)
{
p = other.p;
d = other.d;
n = other.n;
r = other.r;
fFov = other.fFov;
fFar = other.fFar;
fAspect = other.fAspect;
dont_apply = other.dont_apply;
affected_on_hud = other.affected_on_hud;
return *this;
}
};

enum ECameraStyle {
csCamDebug,
csFirstEye,
csLookAt,
enum ECameraStyle
{
csCamDebug,
csFirstEye,
csLookAt,
csMax,
csFixed,
cs_forcedword = u32(-1)
csFixed,
cs_forcedword = u32(-1)
};

enum ECamEffectorType {
cefDemo =0,
cefNext
enum ECamEffectorType
{
cefDemo = 0,
cefNext
};

enum EEffectorPPType {
ppeNext =0,
enum EEffectorPPType
{
ppeNext = 0,
};

// refs
Expand Down
Loading

0 comments on commit 4aa9cd1

Please sign in to comment.