drawing managed boxes now (i think)
git-svn-id: svn://anubis/anaglym/trunk@126 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
3ee41bfa9f
commit
c79ff10b43
38
Engine.cc
38
Engine.cc
@ -623,7 +623,7 @@ Engine::Object::Object(bool is_static, OdeWorld & world,
|
|||||||
m_is_visible = true;
|
m_is_visible = true;
|
||||||
m_scale = 1.0f;
|
m_scale = 1.0f;
|
||||||
m_is_scaled = false;
|
m_is_scaled = false;
|
||||||
m_display_list = -1;
|
m_display_list = 0;
|
||||||
m_display_list_refcnt = NULL;
|
m_display_list_refcnt = NULL;
|
||||||
m_ode_object = world.createObject(
|
m_ode_object = world.createObject(
|
||||||
geom_type == OdeWorld::PLANE ? false : is_static,
|
geom_type == OdeWorld::PLANE ? false : is_static,
|
||||||
@ -713,6 +713,8 @@ void Engine::Object::render()
|
|||||||
}
|
}
|
||||||
if (!valid)
|
if (!valid)
|
||||||
return;
|
return;
|
||||||
|
if (m_display_list > 0)
|
||||||
|
glDeleteLists(m_display_list, 1);
|
||||||
m_display_list = glGenLists(1);
|
m_display_list = glGenLists(1);
|
||||||
glNewList(m_display_list, GL_COMPILE);
|
glNewList(m_display_list, GL_COMPILE);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, m_color);
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, m_color);
|
||||||
@ -720,7 +722,39 @@ void Engine::Object::render()
|
|||||||
/* TODO: finish */
|
/* TODO: finish */
|
||||||
switch (m_geom_type)
|
switch (m_geom_type)
|
||||||
{
|
{
|
||||||
case OdeWorld::CUBE:
|
case OdeWorld::CUBE: {
|
||||||
|
struct { float norm[3]; float verts[4][3]; } sides[] = {
|
||||||
|
{ {1, 0, 0}, /* right */
|
||||||
|
{ {1, -1, -1}, {1, 1, -1}, {1, 1, 1}, {1, -1, 1} } },
|
||||||
|
{ {-1, 0, 0}, /* left */
|
||||||
|
{ {-1, 1, -1}, {-1, -1, -1}, {-1, -1, 1}, {-1, 1, 1} } },
|
||||||
|
{ {0, 1, 0}, /* back */
|
||||||
|
{ {1, 1, -1}, {-1, 1, -1}, {-1, 1, 1}, {1, 1, 1} } },
|
||||||
|
{ {0, -1, 0}, /* front */
|
||||||
|
{ {-1, -1, -1}, {1, -1, -1}, {1, -1, 1}, {-1, -1, 1} } },
|
||||||
|
{ {0, 0, 1}, /* top */
|
||||||
|
{ {-1, -1, 1}, {1, -1, 1}, {1, 1, 1}, {-1, 1, 1} } },
|
||||||
|
{ {0, 0, -1}, /* bottom */
|
||||||
|
{ {1, -1, -1}, {-1, -1, -1}, {-1, 1, -1}, {1, 1, -1} } }
|
||||||
|
};
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
float width = (*m_args)[0];
|
||||||
|
float depth = (*m_args)[1];
|
||||||
|
float height = (*m_args)[2];
|
||||||
|
for (unsigned int s = 0;
|
||||||
|
s < (sizeof(sides)/sizeof(sides[0]));
|
||||||
|
s++)
|
||||||
|
{
|
||||||
|
glNormal3fv(sides[s].norm);
|
||||||
|
for (int v = 0; v < 4; v++)
|
||||||
|
{
|
||||||
|
glVertex3f(sides[s].verts[v][0] * width / 2.0,
|
||||||
|
sides[s].verts[v][1] * depth / 2.0,
|
||||||
|
sides[s].verts[v][2] * height / 2.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OdeWorld::SPHERE:
|
case OdeWorld::SPHERE:
|
||||||
gluSphere(quad, (*m_args)[0], 16, 8);
|
gluSphere(quad, (*m_args)[0], 16, 8);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user