79 Vec3f bbMin(FLT_MAX,FLT_MAX,FLT_MAX);
80 Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX);
82 for(
unsigned int i=0; i<vertices_.size(); ++i)
123 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
125 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
133 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
135 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
146 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
151 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
156 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
183 OBJNode::draw_obj()
const 185 glBegin(GL_TRIANGLES);
187 for(
unsigned int i=0; i<faces_.size(); ++i)
203 OBJNode::draw_obj_tex()
const 205 glBegin(GL_TRIANGLES);
207 for(
unsigned int i=0; i<faces_.size(); ++i)
210 if (faces_[i].t0 != -1)
268 FILE* in = fopen(_filename.c_str(),
"r");
269 if (!in)
return false;
283 while(!feof(in) && fgets(s, 200, in))
286 if (s[0] ==
'#')
continue;
290 else if (strncmp(s,
"v ", 2) == 0)
292 if (sscanf(s,
"v %30f %30f %30f", &x, &y, &z))
294 vertices_.push_back(
Vec3f(x,y,z));
300 else if (strncmp(s,
"vt ", 3) == 0)
302 if (sscanf(s,
"vt %40f %40f", &u, &v))
303 texCoords_.push_back(
Vec2f(u, v));
308 else if (strncmp(s,
"f ", 2) == 0)
310 std::vector<unsigned int> vIdx, tIdx;
311 int component(0), nV(0);
312 bool endOfVertex(
false);
326 while (*p1 !=
'/' && *p1 !=
'\r' && *p1 !=
'\n' &&
327 *p1 !=
' ' && *p1 !=
'\0')
331 if (*p1 !=
'/') endOfVertex =
true;
341 if (*p1 ==
'\0' || *p1 ==
'\n')
349 case 0: vIdx.push_back(atoi(p0)-1);
break;
350 case 1: tIdx.push_back(atoi(p0)-1);
break;
366 if (vIdx.size() >= 3)
369 if (vIdx.size() == tIdx.size())
371 for (
unsigned int i1=1, i2=2; i2 < vIdx.size(); ++i1, ++i2)
372 faces_.push_back(
Face(vIdx[0], vIdx[i1], vIdx[i2],
373 tIdx[0], tIdx[i1], tIdx[i2]));
379 for (
unsigned int i1=1, i2=2; i2 < vIdx.size(); ++i1, ++i2)
381 faces_.push_back(
Face(vIdx[0], vIdx[i1], vIdx[i2]));
407 normals_.reserve(faces_.size());
409 std::vector<Face>::const_iterator f_it(faces_.begin()), f_end(faces_.end());
410 for (; f_it!=f_end; ++f_it)
415 normals_.push_back(((v1-v0) % (v2-v0)).normalize());
VectorT< float, 2 > Vec2f
const Vec4f & clear_color() const
get background color
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
bool read(const std::string &_filename)
Read from file. Implemented using OpenMesh loader and OBJNodeExporter.
DrawMode WIREFRAME
draw wireframe
void glNormal(const Vec3f &_n)
Wrapper: glNormal for Vec3f.
DrawModes::DrawMode availableDrawModes() const
return available draw modes
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
void update_face_normals()
Update face normals. Call when geometry changes.
DrawMode POINTS
draw unlighted points using the default base color
PickTarget
What target to use for picking.
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
static void enable(GLenum _cap)
replaces glEnable, but supports locking
DrawMode SOLID_TEXTURED
draw textured faces
VectorT< float, 3 > Vec3f
const Vec4f & base_color() const
get base color (used when lighting is off)
bool pick_set_maximum(unsigned int _idx)
Set the maximal number of primitives/components of your object.
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
static void disable(GLenum _cap)
replaces glDisable, but supports locking
Namespace providing different geometric functions concerning angles.
picks verices (may not be implemented for all nodes)
void pick_set_name(unsigned int _idx)
sets the current name/color (like glLoadName(_idx))
picks edges (may not be implemented for all nodes)
void glTexCoord(const Vec2f &_t)
Wrapper: glTexCoord for Vec2f.
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax)
update bounding box
pick any of the prior targets (should be implemented for all nodes)
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode)
drawing the primitive
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
Vec3f & vertex(unsigned int _i)
get i'th vertex
VectorT< double, 3 > Vec3d
picks faces (should be implemented for all nodes)
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
void pick(GLState &_state, PickTarget _target)
picking