drawing capped cylinders now (i think)

git-svn-id: svn://anubis/anaglym/trunk@125 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-10-27 14:56:06 +00:00
parent 869e6465cc
commit 3ee41bfa9f
2 changed files with 24 additions and 3 deletions

View File

@ -733,9 +733,27 @@ void Engine::Object::render()
gluCylinder(quad, (*m_args)[0], (*m_args)[0], (*m_args)[1], 12, 1);
glPopMatrix();
break;
case OdeWorld::CCYLINDER:
case OdeWorld::CCYLINDER: {
glPushAttrib(GL_TRANSFORM_BIT); /* save current clip planes */
double halfheight = (*m_args)[1] / 2.0;
glPushMatrix();
glTranslatef(0, 0, -halfheight);
gluCylinder(quad, (*m_args)[0], (*m_args)[0], (*m_args)[1], 12, 1);
double clip_plane[] = {0, 0, -1, halfheight};
glClipPlane(GL_CLIP_PLANE0, clip_plane);
glEnable(GL_CLIP_PLANE0);
gluSphere(quad, (*m_args)[0], 12, 8);
glTranslatef(0, 0, 2*halfheight);
clip_plane[2] = 1.0;
glClipPlane(GL_CLIP_PLANE0, clip_plane);
gluSphere(quad, (*m_args)[0], 12, 8);
glPopMatrix();
glPopAttrib();
}
break;
}
gluDeleteQuadric(quad);
glEndList();
}

View File

@ -19,11 +19,14 @@ camx, camy, camz, cx, cy, cz = ag.getCamera()
ball = ag.loadModel("checkerball")
ball:setPosition(2*camx - cx, 2*camy - cy, 2*camz - cz)
function key_down_event(key)
if (key == "space") then
function mousebutton_down_event(button)
local function button1()
local newball = ball:clone()
newball:setPosition(camx, camy, camz)
force = 10000
newball:addForce(force * (cx-camx), force * (cy-camy), force * (cz-camz))
end
if (button == 1) then
button1()
end
end