00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _VRJ_VIEWPORT_H_
00034 #define _VRJ_VIEWPORT_H_
00035
00036 #include <vrj/vrjConfig.h>
00037
00038 #include <string>
00039 #include <gmtl/Vec.h>
00040 #include <jccl/Config/ConfigElementPtr.h>
00041
00042 namespace vrj
00043 {
00044
00045 class Display;
00046 class Projection;
00047 class User;
00048
00055 class VJ_CLASS_API Viewport
00056 {
00057 public:
00058 Viewport()
00059 : mUser(NULL), mDisplay(NULL),
00060 mLeftProj(NULL), mRightProj(NULL)
00061 {
00062 mXorigin = mYorigin = mXsize = mYsize = -1.0f;
00063 mType = Viewport::UNDEFINED;
00064 mActive = false;
00065 }
00066
00067 Viewport(const Viewport& v)
00068 : mName(v.mName), mUser(v.mUser), mType(v.mType), mView(v.mView),
00069 mActive(v.mActive), mDisplay(v.mDisplay),
00070 mViewportElement(v.mViewportElement), mXorigin(v.mXorigin),
00071 mYorigin(v.mYorigin), mXsize(v.mXsize), mYsize(v.mYsize),
00072 mLeftProj(v.mLeftProj), mRightProj(v.mRightProj)
00073 {
00074 }
00075
00076 virtual ~Viewport()
00077 {;}
00078
00080 enum Type
00081 {
00082 UNDEFINED,
00083 SURFACE,
00084 SIM
00085 };
00086
00088 enum View
00089 {
00090 NONE=0,
00091 LEFT_EYE=1,
00092 RIGHT_EYE=2,
00093 STEREO=3
00094 };
00095
00096 public:
00107 virtual void config(jccl::ConfigElementPtr element);
00108
00114 virtual void updateProjections(const float positionScale) = 0;
00115
00116 public:
00117 Viewport::Type getType()
00118 { return mType;}
00119
00120 bool isSimulator()
00121 { return (mType == SIM); }
00122
00123 bool isSurface()
00124 { return (mType == SURFACE); }
00125
00126 bool isActive()
00127 { return mActive; }
00128
00129 void setName(const std::string& name)
00130 {
00131 mName = name;
00132 }
00133
00135 const std::string& getName()
00136 {
00137 return mName;
00138 }
00139
00143 bool inStereo()
00144 { return (mView == STEREO); }
00145
00146
00147 Viewport::View getView()
00148 { return mView; }
00149
00150 void setOriginAndSize(float xo, float yo, float xs, float ys)
00151 { mXorigin = xo; mYorigin = yo; mXsize = xs; mYsize = ys;}
00152 void getOriginAndSize(float& xo, float& yo, float& xs, float& ys)
00153 {
00154 xo = mXorigin; yo = mYorigin; xs = mXsize; ys = mYsize;
00155 }
00156
00158 jccl::ConfigElementPtr getConfigElement()
00159 {
00160 return mViewportElement;
00161 }
00162
00164 User* getUser()
00165 { return mUser;}
00166
00167 void setDisplay(Display* disp)
00168 { mDisplay = disp; }
00169 Display* getDisplay()
00170 { return mDisplay; }
00171
00172 Projection* getLeftProj()
00173 { return mLeftProj; }
00174
00175 Projection* getRightProj()
00176 { return mRightProj; }
00177
00178
00179 virtual std::ostream& outStream(std::ostream& out,
00180 const unsigned int indentLevel = 0);
00181 friend VJ_API(std::ostream&) operator<<(std::ostream& out, Viewport& viewport);
00182
00183 protected:
00184 std::string mName;
00185 User* mUser;
00186 Viewport::Type mType;
00187 Viewport::View mView;
00188 bool mActive;
00190 Display* mDisplay;
00192 jccl::ConfigElementPtr mViewportElement;
00198 float mXorigin, mYorigin, mXsize, mYsize;
00200
00205 Projection* mLeftProj;
00206 Projection* mRightProj;
00208
00209 };
00210
00211 }
00212
00213 #endif