/// set the bounding box values void SphereVolume::calcBB() { bb.clear(); GLVertex maxpt = GLVertex(center.x + radius, center.y + radius, center.z + radius); GLVertex minpt = GLVertex(center.x - radius, center.y - radius, center.z - radius); bb.addPoint( maxpt ); bb.addPoint( minpt ); }
// FIXME?? void RectVolume::calcBB() { bb.clear(); GLVertex maxp; GLVertex minp; double bignum = 1e6; maxp = GLVertex(bignum,bignum,bignum); minp = GLVertex( -bignum,-bignum,-bignum); bb.addPoint( maxp ); bb.addPoint( minp ); }
GLVertex operator*(const double &a) const { return GLVertex(*this) *= a; }
GLVertex cross(const GLVertex &p) const { GLfloat xc = y * p.z - z * p.y; GLfloat yc = z * p.x - x * p.z; GLfloat zc = x * p.y - y * p.x; return GLVertex(xc, yc, zc); }
const GLVertex operator-( const GLVertex &p) const { return GLVertex(*this) -= p; }
const GLVertex operator+( const GLVertex &p) const { return GLVertex(*this) += p; }
RectVolume::RectVolume() { corner = GLVertex(0,0,0); v1 = GLVertex(1,0,0); v2 = GLVertex(0,1,0); v3 = GLVertex(0,0,1); }
/// sphere at center SphereVolume::SphereVolume() { center = GLVertex(0,0,0); radius = 1.0; calcBB(); }
/// modify given vertex void GLData::modifyVertex( unsigned int id, float x, float y, float z, float r, float g, float b, float nx, float ny, float nz) { GLVertex p = GLVertex(x,y,z,r,g,b,nx,ny,nz); vertexArray[workIndex][id] = p; }
/// add a vertex with given position and color, return its index unsigned int GLData::addVertex(float x, float y, float z, float r, float g, float b) { return addVertex( GLVertex(x,y,z,r,g,b), NULL ); }
// minx maxx miny maxy minz maxz Bbox::Bbox(double b1, double b2, double b3, double b4, double b5, double b6) { minpt = GLVertex(b1,b3,b5); maxpt = GLVertex(b2,b4,b6); initialized = true; }
Bbox::Bbox() { minpt = GLVertex(0,0,0); maxpt = GLVertex(0,0,0); initialized = false; }