00001 00010 #ifndef DRAWOBJ_H 00011 #define DRAWOBJ_H 00012 00013 #include "IS3DCommon.H" 00014 #include "BBox.H" 00015 00016 namespace IS3D { 00017 00018 typedef ReferenceCountedPointer<class DrawObj> DrawObjRef; 00019 class DrawObj : public ReferenceCountedObject 00020 { 00021 public: 00022 00023 DrawObj(std::string name, int roomObj=0, int displayInitially=1); 00024 virtual ~DrawObj(); 00025 00029 virtual void contextInit() {} 00030 00032 virtual void draw() = 0; 00033 00035 virtual void highlight() { showBoundingBox(); } 00037 virtual void unhighlight() { hideBoundingBox(); } 00038 00041 virtual void reColor(const Color4 &c, int colorNum=0); 00042 00045 virtual void reTexture(const std::string &texname, int texNum=0); 00046 00047 00048 virtual void setCoordinateFrame(CoordinateFrame cf) { _frame = cf; } 00049 virtual void setBoundingBox(BBox bbox) { _bbox = bbox; } 00050 virtual void setDisplayed(bool d); 00051 virtual void setBoundingBoxDisplayed(bool d) { _bboxDisplayed = d; } 00052 virtual void setMovable(bool m) { _movable = m; } 00053 virtual void setRenderAsTransparent(bool t) { _transparent = t; } 00054 virtual void setRoomObj(bool r) { _roomObj = r; } 00055 virtual void setDrawingPass(int d) { _drawingPass = d; } 00056 virtual void setContextInitialized() { _contextInitialized = true; } 00057 virtual void setLit(bool l) { _lit = l; } 00058 00059 00060 std::string getName() { return _name; } 00061 CoordinateFrame getCoordinateFrame() { return _frame; } 00062 BBox getBoundingBox() { return _bbox; } 00063 bool getDisplayed() { return _displayed; } 00064 bool getBoundingBoxDisplayed() { return _bboxDisplayed; } 00065 bool getMovable() { return _movable; } 00066 bool getSelectable() { return _selectable; } 00067 bool getRenderAsTransparent() { return _transparent; } 00068 bool getRoomObj() { return _roomObj; } 00069 int getDrawingPass() { return _drawingPass; } 00070 bool getContextInitialized() { return _contextInitialized; } 00071 bool getLit() { return _lit; } 00072 00073 // Visibility Shortcuts 00074 00075 virtual void show() { setDisplayed(true); } 00076 virtual void hide() { setDisplayed(false); } 00077 virtual void showBoundingBox() { setBoundingBoxDisplayed(true); } 00078 virtual void hideBoundingBox() { setBoundingBoxDisplayed(false); } 00079 00080 // Selection 00081 00088 virtual bool pointIntersectCoarse(const Vector3 &pobj); 00089 00094 virtual bool pointIntersectFine(const Vector3 &pobj); 00095 00096 // File I/O 00097 00099 virtual void writeVRML(ostream *os); 00101 virtual void readVRML(istream *is); 00102 00104 virtual void writeIS3(ostream *os); 00106 virtual void readIS3(istream *is); 00107 00108 protected: 00109 00110 std::string _name; 00111 CoordinateFrame _frame; 00112 BBox _bbox; 00113 bool _displayed; 00114 bool _bboxDisplayed; 00115 bool _movable; 00116 bool _selectable; 00117 bool _transparent; 00118 bool _roomObj; 00119 int _drawingPass; 00120 bool _contextInitialized; 00121 bool _lit; 00122 }; 00123 00124 00125 } 00126 00127 #endif