Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ISMeshObj.H

Go to the documentation of this file.
00001 
00009 #ifndef MESHOBJ_H
00010 #define MESHOBJ_H
00011 
00012 
00013 #include "DrawObj.H"
00014 #include "ISMesh.H"
00015 #include "Texture.H"
00016 
00017 // Gluebase includes
00018 #define OUTSIDE_GLUE_CORE
00019 #include <std/hash.H>
00020 #include <mlib/points.H>
00021 #include <config/config.H>
00022 
00023 namespace InSpace {
00024 
00025 class ISMeshObj : public DrawObj
00026 {
00027  public:
00028   ISMeshObj(str_ptr name) : DrawObj(name + str_ptr("_drawobj")) {
00029     _shininess = CONFIGval("DEFAULT_SHININESS",100,false);
00030     _diffuse   = Color(CONFIGval("DEFAULT_DIFFUSE",
00031                  str_ptr("0.5 0.5 0.5 1.0"),false));
00032     _specular  = Color(CONFIGval("DEFAULT_SPECULAR",
00033                  str_ptr("1.0 1.0 1.0 1.0"),false));
00034     _emission  = Color(CONFIGval("DEFAULT_EMISSION",
00035                  str_ptr("0.2 0.2 0.2 1.0"),false));
00036     _ambient   = Color(CONFIGval("DEFAULT_AMBIENT",
00037                  str_ptr("0.7 0.7 0.7 1.0"),false));
00038     _textureValid = 0;
00039     _isLit=1;
00040   };
00041   
00042   ISMeshObj(str_ptr name, ISMesh *m) : DrawObj(name + str_ptr("_drawobj")) {
00043     _shininess = CONFIGval("DEFAULT_SHININESS",100,false);
00044     _diffuse   = Color(CONFIGval("DEFAULT_DIFFUSE",
00045                  str_ptr("0.5 0.5 0.5 1.0"),false));
00046     _specular  = Color(CONFIGval("DEFAULT_SPECULAR",
00047                  str_ptr("1.0 1.0 1.0 1.0"),false));
00048     _emission  = Color(CONFIGval("DEFAULT_EMISSION",
00049                  str_ptr("0.2 0.2 0.2 1.0"),false));
00050     _ambient   = Color(CONFIGval("DEFAULT_AMBIENT",
00051                  str_ptr("0.7 0.7 0.7 1.0"),false));
00052     _textureValid = 0;
00053     _isLit=1;
00054     addMesh(m);
00055   }
00056 
00057   virtual ~ISMeshObj();
00058 
00059   void addMesh(ISMesh *m) {
00060     _meshes += m;
00061   }
00062 
00063 
00064   void setDiffuse(Color c) {
00065     _diffuse = c;
00066   }
00067 
00068   void setShininess(double value) {
00069     _shininess = value;
00070   }
00071 
00072   void setSpecular(Color c) {
00073     _specular = c;
00074   }
00075 
00076   void setEmission(Color c) {
00077     _emission = c;
00078   }
00079 
00080   void setAmbient(Color c) {
00081     _ambient = c;
00082   }
00083 
00084   void reTexture(str_ptr texname) {
00085     cout << "in meshobj settexture" << endl;
00086     setTextureName(texname);
00087   }
00088 
00089   void setTextureName(str_ptr texName);
00090    
00091 
00092   void reColor(Color c) {
00093     _diffuse = c;
00094     _ambient = c;
00095     //cout << "setting meshObj color\n";
00096   }
00097 
00098   Color   diffuse()   { return _diffuse; }
00099   double  shininess() { return _shininess; }
00100   Color   specular()  { return _specular; }
00101   Color   emission()  { return _emission; }
00102   Color   ambient()   { return _ambient; }
00103   str_ptr texname()   { if (_textures.num()>0) return _textures[0]; return str_ptr(""); }
00104   
00105   BBox* recalcBBox() {
00106     _bbox.reset();
00107     for (int i=0;i<_meshes.num();i++) {
00108       _bbox.addBBox(_meshes[i]->bbox());
00109     }
00110     return &_bbox;
00111   }
00112   
00113   virtual void setLit(int lit){_isLit=lit;}
00114   virtual int isLit(){return _isLit;}
00115 
00116   // pre: must be called from within a GL rendering context
00117   // post: all meshes contained in this object have been drawn
00118   virtual void draw();
00119   
00120   //adds the second or third... texture to the stroke
00121   virtual void addMultiTexture(str_ptr texture,
00122                    double alpha=1.0, 
00123                    Wtransf texTransform=Wtransf());
00124 
00125   void writeVRML(ostream *ofs);
00126   bool readVRML(istream *is);
00127 
00128 
00129   int pointSelectFine(Wpt pw);
00130   int pointSelectFine(ROOMpt pr);
00131   
00132   
00133   // Array of meshes contained in this object
00134   ARRAY<ISMesh*> _meshes;
00135   void cleanUp(double epsilon);
00136 
00137 
00138 
00139  protected:
00140   ARRAY<str_ptr> _textures;
00141   ARRAY<double> _textureAlphas;
00142   ARRAY<Wtransf> _textureTransforms;
00143 
00144   // Object-wide material properties
00145   double _shininess;
00146   Color _diffuse;
00147   Color _specular;
00148   Color _emission;
00149   Color _ambient;
00150   
00151   int _textureValid;
00152   int _isLit;
00153   //str_ptr _texName;
00154   
00155 };
00156 
00157 }
00158 
00159 #endif

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4