73 Vec3f bbMin(FLT_MAX,FLT_MAX,FLT_MAX);
74 Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX);
76 for(
unsigned int i=0; i<vertices_.size(); ++i)
117 glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
119 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
127 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
129 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
140 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
145 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
150 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
177 OBJNode::draw_obj()
const 179 glBegin(GL_TRIANGLES);
181 for(
unsigned int i=0; i<faces_.size(); ++i)
197 OBJNode::draw_obj_tex()
const 199 glBegin(GL_TRIANGLES);
201 for(
unsigned int i=0; i<faces_.size(); ++i)
204 if (faces_[i].t0 != -1)
262 FILE* in = fopen(_filename.c_str(),
"r");
263 if (!in)
return false;
277 while(!feof(in) && fgets(s, 200, in))
280 if (s[0] ==
'#')
continue;
284 else if (strncmp(s,
"v ", 2) == 0)
286 if (sscanf(s,
"v %30f %30f %30f", &x, &y, &z))
288 vertices_.push_back(
Vec3f(x,y,z));
294 else if (strncmp(s,
"vt ", 3) == 0)
296 if (sscanf(s,
"vt %40f %40f", &u, &v))
297 texCoords_.push_back(
Vec2f(u, v));
302 else if (strncmp(s,
"f ", 2) == 0)
304 std::vector<unsigned int> vIdx, tIdx;
305 int component(0), nV(0);
306 bool endOfVertex(
false);
320 while (*p1 !=
'/' && *p1 !=
'\r' && *p1 !=
'\n' &&
321 *p1 !=
' ' && *p1 !=
'\0')
325 if (*p1 !=
'/') endOfVertex =
true;
335 if (*p1 ==
'\0' || *p1 ==
'\n')
343 case 0: vIdx.push_back(atoi(p0)-1);
break;
344 case 1: tIdx.push_back(atoi(p0)-1);
break;
360 if (vIdx.size() >= 3)
363 if (vIdx.size() == tIdx.size())
365 for (
unsigned int i1=1, i2=2; i2 < vIdx.size(); ++i1, ++i2)
366 faces_.push_back(
Face(vIdx[0], vIdx[i1], vIdx[i2],
367 tIdx[0], tIdx[i1], tIdx[i2]));
373 for (
unsigned int i1=1, i2=2; i2 < vIdx.size(); ++i1, ++i2)
375 faces_.push_back(
Face(vIdx[0], vIdx[i1], vIdx[i2]));
401 normals_.reserve(faces_.size());
403 std::vector<Face>::const_iterator f_it(faces_.begin()), f_end(faces_.end());
404 for (; f_it!=f_end; ++f_it)
409 normals_.push_back(((v1-v0) % (v2-v0)).normalize());
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
void glTexCoord(const Vec2f &_t)
Wrapper: glTexCoord for Vec2f.
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
static void shadeModel(GLenum _mode)
replaces glShadeModel, supports locking
picks edges (may not be implemented for all nodes)
void glNormal(const Vec3f &_n)
Wrapper: glNormal for Vec3f.
picks faces (should be implemented for all nodes)
VectorT< float, 2 > Vec2f
Namespace providing different geometric functions concerning angles.
const Vec4f & base_color() const
get base color (used when lighting is off)
DrawMode HIDDENLINE
draw hidden line (2 rendering passes needed)
vector_type & maximize(const vector_type &_rhs)
maximize values: same as *this = max(*this, _rhs), but faster
Vec3f & vertex(unsigned int _i)
get i'th vertex
static void depthRange(GLclampd _zNear, GLclampd _zFar)
replaces glDepthRange, supports locking
PickTarget
What target to use for picking.
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
VectorT< float, 3 > Vec3f
pick any of the prior targets (should be implemented for all nodes)
bool pick_set_maximum(size_t _idx)
Set the maximal number of primitives/components of your object.
DrawMode SOLID_TEXTURED
draw textured faces
void draw(GLState &_state, const DrawModes::DrawMode &_drawMode) override
drawing the primitive
picks verices (may not be implemented for all nodes)
vector_type & minimize(const vector_type &_rhs)
minimize values: same as *this = min(*this, _rhs), but faster
DrawModes::DrawMode availableDrawModes() const override
return available draw modes
void update_face_normals()
Update face normals. Call when geometry changes.
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
DrawMode POINTS
draw unlighted points using the default base color
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
DrawMode WIREFRAME
draw wireframe
void pick_set_name(size_t _idx)
sets the current name/color (like glLoadName(_idx))
void pick(GLState &_state, PickTarget _target) override
picking
bool read(const std::string &_filename)
Read from file. Implemented using OpenMesh loader and OBJNodeExporter.
const Vec4f & clear_color() const
get background color
void boundingBox(Vec3d &_bbMin, Vec3d &_bbMax) override
update bounding box
VectorT< double, 3 > Vec3d