Skip to content

Commit 1f7b4a4

Browse files
committed
Fix for #29 Normal Generation by Smoothing Group Id - Commit 2
1 parent 15f47e2 commit 1f7b4a4

File tree

2 files changed

+0
-103
lines changed

2 files changed

+0
-103
lines changed

examples/viewer/trackball.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "stdafx.h" // Required to be included in a Visual Studio Win32 application
2-
31
/*
42
* (c) Copyright 1993, 1994, Silicon Graphics, Inc.
53
* ALL RIGHTS RESERVED

examples/viewer/viewer.cc

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include "stdafx.h" // Required to be included in a Visual Studio Win32 application
21
//
32
// Simple .obj viewer(vertex only)
43
//
@@ -775,13 +774,6 @@ static void Init() {
775774
up[2] = 0.0f;
776775
}
777776

778-
// Gopal: I am commenting out the original main function.
779-
// Then, I make a copy and split in to two fuctions -
780-
// tinyObjectViewerMainCreateWindow and tinyObjectViewerMainLoop.
781-
// I need to separate these two functions in my windows project.
782-
// Ths first one is used to create the OpenGL window and link it to my
783-
// main application window. After that the second function is called.
784-
/*
785777
int main(int argc, char** argv) {
786778
if (argc < 2) {
787779
std::cout << "Needs input.obj\n" << std::endl;
@@ -866,96 +858,3 @@ int main(int argc, char** argv) {
866858

867859
glfwTerminate();
868860
}
869-
*/
870-
871-
// The parameters bmin, bmax, materials and textures are shared between the two funations.
872-
// They are also declared as static to retain the values.
873-
static float bmin[3], bmax[3];
874-
static std::vector<tinyobj::material_t> materials;
875-
static std::map<std::string, GLuint> textures;
876-
877-
int tinyObjectViewerMainCreateWindow(int argc, char** argv) {
878-
if (argc < 2) {
879-
std::cout << "Needs input.obj\n" << std::endl;
880-
return 0;
881-
}
882-
883-
Init();
884-
885-
if (!glfwInit()) {
886-
std::cerr << "Failed to initialize GLFW." << std::endl;
887-
return -1;
888-
}
889-
890-
window = glfwCreateWindow(width, height, "Obj viewer", NULL, NULL);
891-
if (window == NULL) {
892-
std::cerr << "Failed to open GLFW window. " << std::endl;
893-
glfwTerminate();
894-
return 1;
895-
}
896-
897-
glfwMakeContextCurrent(window);
898-
glfwSwapInterval(1);
899-
900-
// Callback
901-
glfwSetWindowSizeCallback(window, reshapeFunc);
902-
glfwSetKeyCallback(window, keyboardFunc);
903-
glfwSetMouseButtonCallback(window, clickFunc);
904-
glfwSetCursorPosCallback(window, motionFunc);
905-
906-
glewExperimental = true;
907-
if (glewInit() != GLEW_OK) {
908-
std::cerr << "Failed to initialize GLEW." << std::endl;
909-
return -1;
910-
}
911-
912-
reshapeFunc(window, width, height);
913-
914-
if (false == LoadObjAndConvert(bmin, bmax, &gDrawObjects, materials, textures, argv[1])) {
915-
return -1;
916-
}
917-
918-
return 0;
919-
}
920-
921-
void tinyObjectViewerMainLoop()
922-
{
923-
float maxExtent = 0.5f * (bmax[0] - bmin[0]);
924-
if (maxExtent < 0.5f * (bmax[1] - bmin[1])) {
925-
maxExtent = 0.5f * (bmax[1] - bmin[1]);
926-
}
927-
if (maxExtent < 0.5f * (bmax[2] - bmin[2])) {
928-
maxExtent = 0.5f * (bmax[2] - bmin[2]);
929-
}
930-
931-
while (glfwWindowShouldClose(window) == GL_FALSE) {
932-
glfwPollEvents();
933-
glClearColor(0.1f, 0.2f, 0.3f, 1.0f);
934-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
935-
936-
glEnable(GL_DEPTH_TEST);
937-
glEnable(GL_TEXTURE_2D);
938-
939-
// camera & rotate
940-
glMatrixMode(GL_MODELVIEW);
941-
glLoadIdentity();
942-
GLfloat mat[4][4];
943-
gluLookAt(eye[0], eye[1], eye[2], lookat[0], lookat[1], lookat[2], up[0],
944-
up[1], up[2]);
945-
build_rotmatrix(mat, curr_quat);
946-
glMultMatrixf(&mat[0][0]);
947-
948-
// Fit to -1, 1
949-
glScalef(1.0f / maxExtent, 1.0f / maxExtent, 1.0f / maxExtent);
950-
951-
// Centerize object.
952-
glTranslatef(-0.5 * (bmax[0] + bmin[0]), -0.5 * (bmax[1] + bmin[1]),
953-
-0.5 * (bmax[2] + bmin[2]));
954-
955-
Draw(gDrawObjects, materials, textures);
956-
957-
glfwSwapBuffers(window);
958-
}
959-
960-
glfwTerminate();
961-
}

0 commit comments

Comments
 (0)