added Ns support to WFObj, updated viewing method

git-svn-id: svn://anubis/misc/wfobj-view@36 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2008-02-15 01:28:33 +00:00
parent d476dd822f
commit 4f5ab0b6a3
2 changed files with 23 additions and 3 deletions

View File

@ -87,13 +87,17 @@ void Viewer::initgl()
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
float pos[] = {0.0, -1.0, 0.0, 0.0};
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
setProjection(); setProjection();
glLoadIdentity(); glLoadIdentity();
glGetFloatv(GL_MODELVIEW_MATRIX, m_rotationMatrix); 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() void Viewer::setProjection()
@ -101,7 +105,7 @@ void Viewer::setProjection()
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(60.0, (GLfloat)WIDTH/(GLfloat)WIDTH, 0.01, 10000.0); 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); glMatrixMode(GL_MODELVIEW);
} }
@ -109,6 +113,7 @@ void Viewer::display()
{ {
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glLoadIdentity(); glLoadIdentity();
gluLookAt(0, -m_dist, 0, 0, 0, 0, 0, 0, 1);
glMultMatrixf(m_rotationMatrix); glMultMatrixf(m_rotationMatrix);
if (m_list) if (m_list)
glCallList(m_list); glCallList(m_list);

View File

@ -472,6 +472,21 @@ void WFMtl::renderBegin(const string & mtlname)
didSomething = true; 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 */ else if (type == "map_Kd") /* load a diffuse texture */
{ {
/* TODO: figure out how i want to load the texture */ /* TODO: figure out how i want to load the texture */