2011-09-07 23:06:51 +02:00
|
|
|
#ifndef _CAMERA_H_
|
|
|
|
#define _CAMERA_H_
|
|
|
|
|
|
|
|
#include "object.h"
|
2012-05-29 01:33:22 +02:00
|
|
|
#include "lc_math.h"
|
2013-08-16 01:43:18 +02:00
|
|
|
#include "lc_array.h"
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
class TiledRender;
|
2012-08-20 06:05:56 +02:00
|
|
|
class View;
|
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
#define LC_CAMERA_HIDDEN 0x0001
|
|
|
|
#define LC_CAMERA_SIMPLE 0x0002
|
2014-05-03 03:22:24 +02:00
|
|
|
#define LC_CAMERA_ORTHO 0x0004
|
2014-05-01 16:55:12 +02:00
|
|
|
#define LC_CAMERA_POSITION_SELECTED 0x0010
|
|
|
|
#define LC_CAMERA_POSITION_FOCUSED 0x0020
|
|
|
|
#define LC_CAMERA_TARGET_SELECTED 0x0040
|
|
|
|
#define LC_CAMERA_TARGET_FOCUSED 0x0080
|
|
|
|
#define LC_CAMERA_UPVECTOR_SELECTED 0x0100
|
|
|
|
#define LC_CAMERA_UPVECTOR_FOCUSED 0x0200
|
|
|
|
|
|
|
|
#define LC_CAMERA_SELECTION_MASK (LC_CAMERA_POSITION_SELECTED | LC_CAMERA_TARGET_SELECTED | LC_CAMERA_UPVECTOR_SELECTED)
|
|
|
|
#define LC_CAMERA_FOCUS_MASK (LC_CAMERA_POSITION_FOCUSED | LC_CAMERA_TARGET_FOCUSED | LC_CAMERA_UPVECTOR_FOCUSED)
|
|
|
|
|
2012-08-20 06:05:56 +02:00
|
|
|
enum LC_VIEWPOINT
|
|
|
|
{
|
|
|
|
LC_VIEWPOINT_FRONT,
|
|
|
|
LC_VIEWPOINT_BACK,
|
|
|
|
LC_VIEWPOINT_TOP,
|
2012-08-22 03:13:32 +02:00
|
|
|
LC_VIEWPOINT_BOTTOM,
|
2012-08-20 06:05:56 +02:00
|
|
|
LC_VIEWPOINT_LEFT,
|
|
|
|
LC_VIEWPOINT_RIGHT,
|
|
|
|
LC_VIEWPOINT_HOME
|
|
|
|
};
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
enum lcCameraSection
|
|
|
|
{
|
|
|
|
LC_CAMERA_SECTION_POSITION,
|
|
|
|
LC_CAMERA_SECTION_TARGET,
|
|
|
|
LC_CAMERA_SECTION_UPVECTOR
|
|
|
|
};
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LC_CAMERA_FRONT,LC_CAMERA_BACK,
|
|
|
|
LC_CAMERA_TOP, LC_CAMERA_UNDER,
|
|
|
|
LC_CAMERA_LEFT, LC_CAMERA_RIGHT,
|
|
|
|
LC_CAMERA_MAIN, LC_CAMERA_USER
|
|
|
|
} LC_CAMERA_TYPES;
|
|
|
|
|
2014-05-01 20:42:11 +02:00
|
|
|
class lcCamera : public lcObject
|
2011-09-07 23:06:51 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-05-01 20:42:11 +02:00
|
|
|
lcCamera(bool Simple);
|
|
|
|
lcCamera(float ex, float ey, float ez, float tx, float ty, float tz);
|
|
|
|
virtual ~lcCamera();
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
const char* GetName() const
|
2012-08-20 06:05:56 +02:00
|
|
|
{
|
|
|
|
return m_strName;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-08-07 17:22:33 +02:00
|
|
|
void CreateName(const lcArray<lcCamera*>& Cameras);
|
2012-08-22 03:13:32 +02:00
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
bool IsSimple() const
|
2012-08-20 06:05:56 +02:00
|
|
|
{
|
2014-05-01 16:55:12 +02:00
|
|
|
return (mState & LC_CAMERA_SIMPLE) != 0;
|
2012-08-20 06:05:56 +02:00
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-05-03 03:22:24 +02:00
|
|
|
bool IsOrtho() const
|
|
|
|
{
|
|
|
|
return (mState & LC_CAMERA_ORTHO) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetOrtho(bool Ortho)
|
|
|
|
{
|
|
|
|
if (Ortho)
|
|
|
|
mState |= LC_CAMERA_ORTHO;
|
|
|
|
else
|
|
|
|
mState &= ~LC_CAMERA_ORTHO;
|
|
|
|
}
|
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
virtual bool IsSelected() const
|
2012-08-20 06:05:56 +02:00
|
|
|
{
|
2014-05-01 16:55:12 +02:00
|
|
|
return (mState & LC_CAMERA_SELECTION_MASK) != 0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual bool IsSelected(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_CAMERA_SECTION_POSITION:
|
|
|
|
return (mState & LC_CAMERA_POSITION_SELECTED) != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_TARGET:
|
|
|
|
return (mState & LC_CAMERA_TARGET_SELECTED) != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_UPVECTOR:
|
|
|
|
return (mState & LC_CAMERA_UPVECTOR_SELECTED) != 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetSelected(bool Selected)
|
|
|
|
{
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_CAMERA_SELECTION_MASK;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_SELECTION_MASK | LC_CAMERA_FOCUS_MASK);
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual void SetSelected(lcuint32 Section, bool Selected)
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_CAMERA_SECTION_POSITION:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_CAMERA_POSITION_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_POSITION_SELECTED | LC_CAMERA_POSITION_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_TARGET:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_CAMERA_TARGET_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_TARGET_SELECTED | LC_CAMERA_TARGET_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_UPVECTOR:
|
|
|
|
if (Selected)
|
|
|
|
mState |= LC_CAMERA_UPVECTOR_SELECTED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_UPVECTOR_SELECTED | LC_CAMERA_UPVECTOR_FOCUSED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsFocused() const
|
|
|
|
{
|
|
|
|
return (mState & LC_CAMERA_FOCUS_MASK) != 0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual bool IsFocused(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_CAMERA_SECTION_POSITION:
|
|
|
|
return (mState & LC_CAMERA_POSITION_FOCUSED) != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_TARGET:
|
|
|
|
return (mState & LC_CAMERA_TARGET_FOCUSED) != 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_UPVECTOR:
|
|
|
|
return (mState & LC_CAMERA_UPVECTOR_FOCUSED) != 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual void SetFocused(lcuint32 Section, bool Focus)
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_CAMERA_SECTION_POSITION:
|
|
|
|
if (Focus)
|
|
|
|
mState |= LC_CAMERA_POSITION_SELECTED | LC_CAMERA_POSITION_FOCUSED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_POSITION_SELECTED | LC_CAMERA_POSITION_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_TARGET:
|
|
|
|
if (Focus)
|
|
|
|
mState |= LC_CAMERA_TARGET_SELECTED | LC_CAMERA_TARGET_FOCUSED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_TARGET_SELECTED | LC_CAMERA_TARGET_FOCUSED);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_UPVECTOR:
|
|
|
|
if (Focus)
|
|
|
|
mState |= LC_CAMERA_UPVECTOR_SELECTED | LC_CAMERA_UPVECTOR_FOCUSED;
|
|
|
|
else
|
|
|
|
mState &= ~(LC_CAMERA_UPVECTOR_SELECTED | LC_CAMERA_UPVECTOR_FOCUSED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual lcuint32 GetFocusSection() const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
if (mState & LC_CAMERA_POSITION_FOCUSED)
|
|
|
|
return LC_CAMERA_SECTION_POSITION;
|
|
|
|
|
|
|
|
if (mState & LC_CAMERA_TARGET_FOCUSED)
|
|
|
|
return LC_CAMERA_SECTION_TARGET;
|
|
|
|
|
|
|
|
if (mState & LC_CAMERA_UPVECTOR_FOCUSED)
|
|
|
|
return LC_CAMERA_SECTION_UPVECTOR;
|
|
|
|
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
2014-05-18 01:03:05 +02:00
|
|
|
virtual lcVector3 GetSectionPosition(lcuint32 Section) const
|
2014-05-01 16:55:12 +02:00
|
|
|
{
|
|
|
|
switch (Section)
|
|
|
|
{
|
|
|
|
case LC_CAMERA_SECTION_POSITION:
|
|
|
|
return mPosition;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_TARGET:
|
|
|
|
return mTargetPosition;
|
|
|
|
|
|
|
|
case LC_CAMERA_SECTION_UPVECTOR:
|
|
|
|
return lcMul31(lcVector3(0, 1, 0), lcMatrix44AffineInverse(mWorldView));
|
|
|
|
}
|
|
|
|
|
|
|
|
return lcVector3(0.0f, 0.0f, 0.0f);
|
2012-08-20 06:05:56 +02:00
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-09-02 05:44:51 +02:00
|
|
|
void SaveLDraw(lcFile& File) const;
|
2014-09-03 16:34:53 +02:00
|
|
|
bool ParseLDrawLine(QTextStream& Stream);
|
2014-09-02 05:44:51 +02:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
public:
|
2014-05-01 16:55:12 +02:00
|
|
|
// void Hide()
|
|
|
|
// { mState = LC_CAMERA_HIDDEN; }
|
|
|
|
// void UnHide()
|
|
|
|
// { mState &= ~LC_CAMERA_HIDDEN; }
|
2011-09-07 23:06:51 +02:00
|
|
|
char* GetName()
|
|
|
|
{ return m_strName; }
|
|
|
|
bool IsSide()
|
|
|
|
{ return m_nType < LC_CAMERA_MAIN; }
|
2014-05-01 16:55:12 +02:00
|
|
|
bool IsVisible() const
|
|
|
|
{ return (mState & LC_CAMERA_HIDDEN) == 0; }
|
2014-09-02 05:44:51 +02:00
|
|
|
|
2014-08-30 01:52:42 +02:00
|
|
|
bool IsHidden() const
|
2014-09-02 05:44:51 +02:00
|
|
|
{
|
|
|
|
return (mState & LC_CAMERA_HIDDEN) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHidden(bool Hidden)
|
|
|
|
{
|
|
|
|
if (Hidden)
|
|
|
|
mState |= LC_CAMERA_HIDDEN;
|
|
|
|
else
|
|
|
|
mState &= ~LC_CAMERA_HIDDEN;
|
|
|
|
}
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-08-31 02:53:12 +02:00
|
|
|
void SetPosition(const lcVector3& Position, lcStep Step, bool AddKey)
|
|
|
|
{
|
|
|
|
ChangeKey(mPositionKeys, Position, Step, AddKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetTargetPosition(const lcVector3& TargetPosition, lcStep Step, bool AddKey)
|
|
|
|
{
|
|
|
|
ChangeKey(mTargetPositionKeys, TargetPosition, Step, AddKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetUpVector(const lcVector3& UpVector, lcStep Step, bool AddKey)
|
|
|
|
{
|
|
|
|
ChangeKey(mPositionKeys, UpVector, Step, AddKey);
|
|
|
|
}
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
public:
|
2014-05-01 16:55:12 +02:00
|
|
|
virtual void RayTest(lcObjectRayTest& ObjectRayTest) const;
|
|
|
|
virtual void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;
|
|
|
|
|
2014-08-31 02:53:12 +02:00
|
|
|
void InsertTime(lcStep Start, lcStep Time);
|
|
|
|
void RemoveTime(lcStep Start, lcStep Time);
|
|
|
|
|
2012-03-23 00:44:56 +01:00
|
|
|
bool FileLoad(lcFile& file);
|
|
|
|
void FileSave(lcFile& file) const;
|
2012-08-23 20:47:37 +02:00
|
|
|
void Select(bool bSelecting, bool bFocus, bool bMultiple);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
void UpdatePosition(lcStep Step);
|
2014-08-07 17:22:33 +02:00
|
|
|
void CopyPosition(const lcCamera* camera);
|
2014-04-14 05:20:16 +02:00
|
|
|
void Render(View* View);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
2014-07-06 08:04:09 +02:00
|
|
|
void ZoomExtents(View* view, const lcVector3& Center, const lcVector3* Points, int NumPoints, lcStep Step, bool AddKey);
|
|
|
|
void ZoomRegion(const lcVector3* Points, float RatioX, float RatioY, lcStep Step, bool AddKey);
|
|
|
|
void Zoom(float Distance, lcStep Step, bool AddKey);
|
|
|
|
void Pan(float DistanceX, float DistanceY, lcStep Step, bool AddKey);
|
|
|
|
void Orbit(float DistanceX, float DistanceY, const lcVector3& CenterPosition, lcStep Step, bool AddKey);
|
|
|
|
void Roll(float Distance, lcStep Step, bool AddKey);
|
|
|
|
void Center(lcVector3& point, lcStep Step, bool AddKey);
|
|
|
|
void Move(lcStep Step, bool AddKey, const lcVector3& Distance);
|
|
|
|
void SetViewpoint(LC_VIEWPOINT Viewpoint, lcStep Step, bool AddKey);
|
|
|
|
void SetFocalPoint(const lcVector3& focus, lcStep Step, bool AddKey);
|
2011-09-07 23:06:51 +02:00
|
|
|
|
|
|
|
void StartTiledRendering(int tw, int th, int iw, int ih, float fAspect);
|
|
|
|
void GetTileInfo(int* row, int* col, int* width, int* height);
|
|
|
|
bool EndTile();
|
|
|
|
|
2013-08-09 06:57:18 +02:00
|
|
|
char m_strName[81];
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
float m_fovy;
|
|
|
|
float m_zNear;
|
|
|
|
float m_zFar;
|
|
|
|
|
2012-05-29 01:33:22 +02:00
|
|
|
lcMatrix44 mWorldView;
|
|
|
|
lcVector3 mPosition;
|
|
|
|
lcVector3 mTargetPosition;
|
|
|
|
lcVector3 mUpVector;
|
2013-12-17 03:43:16 +01:00
|
|
|
lcVector3 mOrthoTarget;
|
2014-05-03 08:08:52 +02:00
|
|
|
TiledRender* m_pTR;
|
2012-05-29 01:33:22 +02:00
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
protected:
|
2014-08-31 02:53:12 +02:00
|
|
|
lcArray<lcObjectKey<lcVector3>> mPositionKeys;
|
|
|
|
lcArray<lcObjectKey<lcVector3>> mTargetPositionKeys;
|
|
|
|
lcArray<lcObjectKey<lcVector3>> mUpVectorKeys;
|
|
|
|
|
2011-09-07 23:06:51 +02:00
|
|
|
void Initialize();
|
|
|
|
|
2014-05-01 16:55:12 +02:00
|
|
|
lcuint32 mState;
|
2011-09-07 23:06:51 +02:00
|
|
|
unsigned char m_nType;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _CAMERA_H_
|