00001 #include "shape.h"
00002
00007 using namespace std;
00008
00010
00011 GltShape::GltShape(const bool solid)
00012 : _solid(solid),
00013 _visible(true),
00014 _convexity(1),
00015 _inheritColor(false),
00016 _inheritSolid(false),
00017 _expired(false)
00018 {
00019 }
00020
00021 GltShape::~GltShape()
00022 {
00023 }
00024
00025 GltFieldPtr
00026 GltShape::settings()
00027 {
00028 GltFields *root = new GltFields(name());
00029
00030 root->add(_visible ,"visible" );
00031 root->add(_solid ,"solid" );
00032 root->add(_name ,"name" );
00033 root->add(_color ,"color" );
00034 root->add(_transformation,"transformation");
00035
00036 return root;
00037 }
00038
00039 GLdouble GltShape::volume() const { return 0.0; }
00040 string GltShape::description() const { return name(); }
00041 bool GltShape::povrayExport(ostream &os) const { return false; }
00042
00043 Matrix &GltShape::transformation() { return _transformation; }
00044 GltColor &GltShape::color() { return _color; }
00045 bool &GltShape::solid() { return _solid; }
00046 bool &GltShape::visible() { return _visible; }
00047 string &GltShape::name() { return _name; }
00048 int &GltShape::convexity() { return _convexity; }
00049 bool &GltShape::inheritColor() { return _inheritColor; }
00050 bool &GltShape::inheritSolid() { return _inheritSolid; }
00051 bool &GltShape::expired() { return _expired; }
00052
00053 const Matrix &GltShape::transformation() const { return _transformation; }
00054 const GltColor &GltShape::color() const { return _color; }
00055 const bool &GltShape::solid() const { return _solid; }
00056 const bool &GltShape::visible() const { return _visible; }
00057 const string &GltShape::name() const { return _name; }
00058 const int &GltShape::convexity() const { return _convexity; }
00059 const bool &GltShape::inheritColor() const { return _inheritColor; }
00060 const bool &GltShape::inheritSolid() const { return _inheritSolid; }
00061 const bool &GltShape::expired() const { return _expired; }
00062
00063 void
00064 GltShape::flushExpired()
00065 {
00066 }
00067
00068 void
00069 GltShape::boundingBox(BoundingBox &box) const
00070 {
00071
00072
00073
00074 box.reset();
00075 }
00076
00077 bool
00078 GltShape::inside(const Vector &pos) const
00079 {
00080 return false;
00081 }
00082
00083 void
00084 GltShape::glColor() const
00085 {
00086 if (!_inheritColor)
00087 _color.glColor();
00088 }
00089
00090 void
00091 GltShape::transformPoints(vector<Vector> &v) const
00092 {
00093 for (uint32 i=0; i<v.size(); i++)
00094 v[i] = _transformation * v[i];
00095 }
00096
00097 bool
00098 GltShape::intersects(const GltShape &shape) const
00099 {
00100 BoundingBox box1,box2;
00101
00102 boundingBox(box1);
00103 if (!box1.defined())
00104 return false;
00105
00106 shape.boundingBox(box2);
00107 if (!box2.defined())
00108 return false;
00109
00110 return box1.intersects(box2);
00111 }
00112