00001
00009 #ifndef DRAWMGR_H
00010 #define DRAWMGR_H
00011
00012 #define MAX_DRAW_PASSES 3
00013
00014 #include "IS3DCommon.H"
00015 #include "DrawObj.H"
00016 #include "SelectMgr.H"
00017
00018 namespace IS3D {
00019
00020
00021 class DrawMgr
00022 {
00023 public:
00024
00027 static void registerObj(DrawObjRef o, int drawingPass=0);
00029 static void register2DObj(DrawObjRef o, int drawingPass=0);
00030
00031 static void registerShadowModel( G3D::PosedModelRef m );
00032 static void registerShadowModels( Array<PosedModelRef> models );
00033
00034
00036 static bool removeObj(DrawObjRef o, int drawingPass=0);
00038 static bool remove2DObj(DrawObjRef o, int drawingPass=0);
00040 static bool removeShadowModel( G3D::PosedModelRef m );
00041 static void clearShadowModels();
00042 static bool useShadows();
00043
00046 static void contextInit();
00047
00049 static void drawFrame();
00050
00056 static void drawThisObject(DrawObjRef d);
00057
00060 static void contextInitThisObject(DrawObjRef d);
00061
00062
00063 static int getNumDrawObjects(int drawingPass=0);
00064 static DrawObjRef getDrawObject(int objNum, int drawingPass=0);
00065 static int getNum2DDrawObjects(int drawingPass=0);
00066 static DrawObjRef get2DDrawObject(int objNum, int drawingPass=0);
00067
00070 static void setShowFPS(bool b) { _showFPS = b; }
00071 static void setShowPolygonCount( bool b ) { _show_polygon_count = b; }
00072
00074 static void drawFullscreenTexture(TextureRef t, float xmin, float ymin,
00075 float xmax, float ymax);
00076
00078 static void drawBackground();
00079
00080 static void drawShadows();
00081
00082 static void setBackgroundTexture(TextureRef t) { _bgTexture = t; }
00083 static void setBackgroundRepeat(float r) { _bgRepeat = r; }
00084 static void setBackgroundOffsetX(float o) { _bgOffsetX = o; }
00085 static void setBackgroundOffsetY(float o) { _bgOffsetY = o; }
00086
00087 static TextureRef getBackgroundTexture() { return _bgTexture; }
00088 static float getBackgroundRepeat() { return _bgRepeat; }
00089 static float getBackgroundOffgetX() { return _bgOffsetX; }
00090 static float getBackgroundOffsetY() { return _bgOffsetY; }
00091
00092
00093 static void pushAndPostMultiplyObjectToWorld(CoordinateFrame postMultFrame);
00094 static void pushAndReplaceObjectToWorld(CoordinateFrame newObjToWorld);
00095 static CoordinateFrame popObjectToWorld();
00096
00097
00105 static CoordinateFrame getRoomToVirtualSpaceFrame();
00106 static double getRoomToVirtualSpaceScale();
00107
00110 static void setRoomToVirtualSpaceFrame(const CoordinateFrame &roomToVirtual);
00111
00115 static void setRoomToVirtualSpaceScale(const double scale);
00116
00119 static Vector3 roomPointToVirtualSpace(const Vector3 &v);
00120 static Vector3 roomVectorToVirtualSpace(const Vector3 &v);
00121 static Vector3 roomNormalToVirtualSpace(const Vector3 &v);
00122
00125 static Vector3 virtualPointToRoomSpace(const Vector3 &v);
00126 static Vector3 virtualVectorToRoomSpace(const Vector3 &v);
00127 static Vector3 virtualNormalToRoomSpace(const Vector3 &v);
00128
00129 static Ray roomToVirtualSpace(const Ray &r);
00130 static Ray virtualToRoomSpace(const Ray &r);
00131
00132 static CoordinateFrame roomToVirtualSpace(const CoordinateFrame &c);
00133
00134
00137 static Vector2 screenPointToG3DCoords(const Vector2 &screenPt);
00138
00141 static Vector2 roomSpacePointToScreenPoint(const Vector3 &roomPt);
00142
00149 static Vector3 screenPointToRoomSpacePoint(const Vector2 &v, bool &hitGeometry);
00150
00153 static Vector3 screenPointToRoomSpaceXYPlane(const Vector2 &v);
00154
00157 static Vector3 screenPointToRoomSpaceZEqualsPlane(const Vector2 &v, double z);
00158
00163 static Vector3 screenPointToRoomSpaceFilmplane(const Vector2 &v);
00164
00167 static Plane getFilmplane();
00168
00169
00170 private:
00171
00174 static void drawFPS();
00175
00177 static GFontRef _fpsFont;
00178
00180 static Color3 _fpsColor;
00181
00183 static bool _showFPS;
00184 static bool _show_polygon_count;
00185 static int _polygon_count;
00186
00188 static Array<DrawObjRef> _objects[MAX_DRAW_PASSES];
00189
00191 static Array<DrawObjRef> _2dObjects[MAX_DRAW_PASSES];
00192
00193
00194 static Array<G3D::PosedModelRef> _shadow_models;
00195 static bool _use_shadows;
00196
00197
00199 static CoordinateFrame _roomToVirtual;
00201 static double _roomToVirtualScale;
00202
00204 static TextureRef _bgTexture;
00205 static float _bgRepeat;
00206 static float _bgOffsetX;
00207 static float _bgOffsetY;
00208
00209 static Array<CoordinateFrame> _objectToWorldStack;
00210
00211
00212
00213 };
00214
00215 }
00216
00217 #endif