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:
parent
d476dd822f
commit
4f5ab0b6a3
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user