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

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18