bool BBox::Overlap( const vec3f& p ) const { bool x = (pMax.x() >= p.x()) && (pMin.x() <= p.x()); bool y = (pMax.y() >= p.y()) && (pMin.y() <= p.y()); bool z = (pMax.z() >= p.z()) && (pMin.z() <= p.z()); return (x && y && z); }
void GLVBO::DrawQuad( int type, const vec3f &p1, const vec3f &p2, const vec3f &p3, const vec3f &p4) { GLfloat verts[] = { p1.x(), p1.y(), p1.z(), p2.x(), p2.y(), p2.z(), p3.x(), p3.y(), p3.z(), p4.x(), p4.y(), p4.z() }; glVertexPointer(3, GL_FLOAT, 0, verts); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(type, 0, 4); glDisableClientState(GL_VERTEX_ARRAY); }
void clamp(vec3f & v, float min, float max) { if(v.peekx() > max) v.x() = max; if(v.peekx() < min) v.x() = min; if(v.peeky() > max) v.y() = max; if(v.peeky() < min) v.y() = min; if(v.peekz() > max) v.z() = max; if(v.peekz() < min) v.z() = min; }
void clamp(vec3f & v, float vmin, float vmax) { if(v.peekx() > vmax) v.x() = vmax; if(v.peekx() < vmin) v.x() = vmin; if(v.peeky() > vmax) v.y() = vmax; if(v.peeky() < vmin) v.y() = vmin; if(v.peekz() > vmax) v.z() = vmax; if(v.peekz() < vmin) v.z() = vmin; }
vec2f Grid::coordsToMapPos(vec3f coords) { GLfloat width = d_cellWidth * d_rows; GLfloat height = d_cellHeight * d_cols; GLfloat x = floor(coords.x() / width); GLfloat y = floor(coords.z() / height); // Clamp the values into the bounds if (x > d_rows) { x = d_rows; } else if (x < 0) { x = 0; } if (y > d_cols) { y = d_cols; } else if (y < 0) { y = 0; } return vec2f(x, y); }
void Shader::setUniform(const std::string &name, const vec3f v, bool warn) { glUniform3f(uniform(name, warn), v.x(), v.y(), v.z()); }
vec3i::vec3i( const vec3f &v ) { m_x = (int)v.x(); m_y = (int)v.y(); m_z = (int)v.z(); }
bool BBox::Inside( const vec3f& pt) const { return (pt.x() >= pMin.x() && pt.x() <= pMax.x() && pt.y() >= pMin.y() && pt.y() <= pMax.y() && pt.z() >= pMin.z() && pt.z() <= pMax.z()); }