From 4f5ab0b6a3e0a36d1b75bb7cb6ab364d0849be9d Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 15 Feb 2008 01:28:33 +0000 Subject: [PATCH] added Ns support to WFObj, updated viewing method git-svn-id: svn://anubis/misc/wfobj-view@36 bd8a9e45-a331-0410-811e-c64571078777 --- wfobj-view.cc | 11 ++++++++--- wfobj/WFObj.cc | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/wfobj-view.cc b/wfobj-view.cc index 4e0af41..5e83efc 100644 --- a/wfobj-view.cc +++ b/wfobj-view.cc @@ -87,13 +87,17 @@ void Viewer::initgl() glShadeModel(GL_SMOOTH); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); - float pos[] = {0.0, -1.0, 0.0, 0.0}; - glLightfv(GL_LIGHT0, GL_POSITION, pos); glEnable(GL_CULL_FACE); glViewport(0, 0, WIDTH, HEIGHT); setProjection(); glLoadIdentity(); glGetFloatv(GL_MODELVIEW_MATRIX, m_rotationMatrix); +// float pos[] = {0.0, -1.0, 0.0, 0.0}; +// glLightfv(GL_LIGHT0, GL_POSITION, pos); + GLfloat lightAmbient[] = {0.2, 0.2, 0.2, 1}; + glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient); + GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0}; + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); } void Viewer::setProjection() @@ -101,7 +105,7 @@ void Viewer::setProjection() glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)WIDTH/(GLfloat)WIDTH, 0.01, 10000.0); - gluLookAt(0, -m_dist, 0, 0, 0, 0, 0, 0, 1); +// gluLookAt(0, m_dist, 0, 0, 0, 0, 0, 0, 1); glMatrixMode(GL_MODELVIEW); } @@ -109,6 +113,7 @@ void Viewer::display() { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glLoadIdentity(); + gluLookAt(0, -m_dist, 0, 0, 0, 0, 0, 0, 1); glMultMatrixf(m_rotationMatrix); if (m_list) glCallList(m_list); diff --git a/wfobj/WFObj.cc b/wfobj/WFObj.cc index 8f719ac..c2a5ff5 100644 --- a/wfobj/WFObj.cc +++ b/wfobj/WFObj.cc @@ -472,6 +472,21 @@ void WFMtl::renderBegin(const string & mtlname) didSomething = true; } } + else if (type == "Ns") /* set shininess */ + { + if (stmts[i].size() == 2) + { + pushAttributes(); + GLfloat shininess = 0.0f; + sscanf(stmts[i][1].c_str(), "%f", &shininess); +#ifdef DEBUGGL + cout << " glMaterialf(GL_FRONT, GL_SHININESS, " + << shininess << ")" << endl; +#endif + glMaterialf(GL_FRONT, GL_SHININESS, shininess); + didSomething = true; + } + } else if (type == "map_Kd") /* load a diffuse texture */ { /* TODO: figure out how i want to load the texture */