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();