Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void onDraw(void) {
- glPushMatrix();
- glLoadIdentity();
- //glScaled(10, 10, 10);
- //cout << "num faces:" << mesh->f->size() << endl;
- // Foreach face:
- for(int i = 0; i < mesh->f->size(); ++i) {
- //glBegin(GL_POLYGON);
- glBegin(GL_LINES);
- glColor3f(1.0f, 0.0f, 0.0f);
- // Foreach vertex index:
- for(int j = 0; j < mesh->f->at(i).vertexIndices.size(); ++j) {
- // Support for broken models!
- if(mesh->f->at(i).vertexIndices.at(j)-1 >= mesh->v->size()) {
- cout << "j:" << j << " index out of bounds! " << (mesh->f->at(i).vertexIndices.at(j)) << " is more than " << mesh->v->size() << endl;
- } else {
- // Note: The -1 is required b.c obj files start counting at 1, and the computer starts at 0.
- glVertex3f(
- mesh->v->at(mesh->f->at(i).vertexIndices.at(j) - 1).x,
- mesh->v->at(mesh->f->at(i).vertexIndices.at(j) - 1).y,
- mesh->v->at(mesh->f->at(i).vertexIndices.at(j) - 1).z
- );
- }
- }
- glEnd();
- }
- glTranslatef(center.x, center.y, center.z);
- glPopMatrix();
- }
Advertisement
Add Comment
Please, Sign In to add comment