From ce1da5f7a876e12632ad326fa31bdf424bebcbc5 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 27 Oct 2009 21:31:21 +0000 Subject: [PATCH] working on drawing planes git-svn-id: svn://anubis/anaglym/trunk@127 99a6e188-d820-4881-8870-2d33a10e2619 --- Engine.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Engine.cc b/Engine.cc index a48b913..fa97ba0 100644 --- a/Engine.cc +++ b/Engine.cc @@ -759,7 +759,28 @@ void Engine::Object::render() case OdeWorld::SPHERE: gluSphere(quad, (*m_args)[0], 16, 8); break; - case OdeWorld::PLANE: + case OdeWorld::PLANE: { + dMatrix3 r; + dRFromEulerAngles(r, (*m_args)[3], (*m_args)[4], (*m_args)[5]); + dVector3 default_plane_direction = {0, 0, 1, 0}; + dVector3 default_x = {1, 0, 0, 0}; + dVector3 default_y = {0, 1, 0, 0}; + dVector3 rotated_plane_direction; + dVector3 rotated_x; + dVector3 rotated_y; + dMultiply0(rotated_plane_direction, default_plane_direction, r, 1, 3, 3); + dMultiply0(rotated_x, default_x, r, 1, 3, 3); + dMultiply0(rotated_y, default_y, r, 1, 3, 3); + + float a = rotated_plane_direction[0]; + float b = rotated_plane_direction[1]; + float c = rotated_plane_direction[2]; + float d = (a * (*m_args)[0] + b * (*m_args)[1] + c * (*m_args)[2]); + /* plane equation: ax + by + cz = d, plane normal: (a, b, c) */ + glBegin(GL_QUAD_STRIP); + glNormal3f(a, b, c); + glEnd(); + } break; case OdeWorld::CYLINDER: glPushMatrix();