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_GL_BASIC_SIMULATOR_H_
00034 #define _VRJ_GL_BASIC_SIMULATOR_H_
00035
00036 #include <vrj/vrjConfig.h>
00037
00038 #include <vrj/Draw/OGL/GlSimInterface.h>
00039 #include <vrj/Draw/OGL/GlDrawObjectFunctor.h>
00040 #include <vrj/Draw/OGL/GlDrawWandFunctors.h>
00041
00042 #ifdef VPR_OS_Darwin
00043 # include <OpenGL/gl.h>
00044 # include <OpenGL/glu.h>
00045 #else
00046 # include <GL/gl.h>
00047 # include <GL/glu.h>
00048 #endif
00049
00050 #include <gadget/Type/PositionInterface.h>
00051
00052 #include <gmtl/Matrix.h>
00053 #include <gmtl/Vec.h>
00054
00055
00056 namespace vrj
00057 {
00062 class GlBasicSimulator : public GlSimInterface
00063 {
00064 public:
00065 GlBasicSimulator();
00066
00067 virtual ~GlBasicSimulator() {}
00068
00074 virtual bool config(jccl::ConfigElementPtr element);
00075
00076 static std::string getElementType()
00077 {
00078 return std::string("default_simulator");
00079 }
00080
00085 virtual void draw(const float scaleFactor);
00086
00087 virtual void initialize(SimViewport* simVp)
00088 {
00089 mSimViewport = simVp;
00090 }
00091
00095 virtual void setEventWindow(gadget::EventWindowInterface ewInterface);
00096
00097 public:
00098 gmtl::Matrix44f getCameraPos()
00099 { return mCameraPos; }
00100
00101 gmtl::Matrix44f getHeadPos()
00102 { return mHeadPos; }
00103
00104 gmtl::Matrix44f getWandPos()
00105 { return mWandPos; }
00106
00107 virtual void updateProjectionData(const float positionScale,
00108 Projection* leftProj, Projection* rightProj);
00109
00111 void updateInternalData(float positionScale);
00112
00113 public:
00114 bool shouldDrawProjections()
00115 { return mDrawProjections; }
00116
00117 gmtl::Vec3f getSurfaceColor()
00118 { return mSurfaceColor; }
00119
00120
00121 protected:
00126 void drawObjects();
00127
00129 void drawProjections(bool drawFrustum, gmtl::Vec3f surfColor, const float scaleFactor);
00130
00136 void drawSimulator(const float scaleFactor);
00137
00139 void setDrawWandFunctor(GlDrawObjectFunctor* functor)
00140 { mDrawWandFunctor = functor; }
00141
00142 protected:
00143 void initQuadObj();
00144 void drawLine(gmtl::Vec3f& start, gmtl::Vec3f& end);
00145 void drawSphere(float radius, int slices, int stacks);
00146 void drawCone(float base, float height, int slices, int stacks);
00147 void drawBox(float size, GLenum type);
00148 void drawWireCube(float size);
00149 void drawSolidCube(float size);
00150
00151
00152
00153 protected:
00154 GlDrawObjectFunctor* mDrawWandFunctor;
00155 GLUquadricObj* mQuadObj;
00157 protected:
00158 SimViewport* mSimViewport;
00159
00160
00161 bool mDrawProjections;
00162 gmtl::Vec3f mSurfaceColor;
00164 gadget::PositionInterface mCamera;
00165 gadget::PositionInterface mWand;
00166
00167 gmtl::Matrix44f mCameraPos;
00168 gmtl::Matrix44f mHeadPos;
00169 gmtl::Matrix44f mWandPos;
00170 };
00171
00172 }
00173
00174 #endif
00175