Beispiel #1
0
void drawOrientedBox(float l, float w, float h, const Matrix4& basis)
{
	glPushMatrix();
	glMultMatrix(basis);
	drawBoxCorner(l,w,h);
	glPopMatrix();
}
Beispiel #2
0
  void drawgeom(const GeometricPrimitive3D& geom)
  {
    switch(geom.type) {
    case GeometricPrimitive3D::Point:
      {
	glBegin(GL_POINTS);
	glVertex3v(*AnyCast<Vector3>(&geom.data));
	glEnd();
      }
      break;
    case GeometricPrimitive3D::Segment:
      {
	const Segment3D* seg=AnyCast<Segment3D>(&geom.data);
	glBegin(GL_LINES);
	glVertex3v(seg->a);
	glVertex3v(seg->b);
	glEnd();
      }
      break;
      /*
    case GeometricPrimitive3D::Circle:
      {
	const Circle3D* circle = AnyCast<Circle3D>(&geom.data);
	glPushMatrix();
	glTranslate(circle->center);
	drawCircle(circle->axis,circle->radius);
	glPopMatrix();
      }
      break;
      */
      /*
    case GeometricPrimitive3D::AABB:
      {
	const AABB3D* aabb=AnyCast<AABB3D>(&geom.data);
	drawBoundingBox(aabb->bmin,aabb->bmax);
      }
      break;
      */
    case GeometricPrimitive3D::Box:
      {
	const Box3D* box=AnyCast<Box3D>(&geom.data);
	Matrix4 m;
	box->getBasis(m);
	glPushMatrix();
	glMultMatrix(m);
	drawBoxCorner(box->dims.x,box->dims.y,box->dims.z);
	glPopMatrix();
	break;
      }
    case GeometricPrimitive3D::Triangle:
      {
	const Triangle3D* tri=AnyCast<Triangle3D>(&geom.data);
	drawTriangle(tri->a,tri->b,tri->c);
	break;
      }
    case GeometricPrimitive3D::Polygon:
      {
	const Polygon3D* p=AnyCast<Polygon3D>(&geom.data);
	Plane3D plane;
	p->getPlane(0,plane);
	glNormal3v(plane.normal);
	glBegin(GL_TRIANGLE_FAN);
	glVertex3v(p->vertices[0]);
	for(size_t i=1;i+1<p->vertices.size();i++) {
	  glVertex3v(p->vertices[i]);
	  glVertex3v(p->vertices[i+1]);
	}
	glEnd();
	break;
      }
    case GeometricPrimitive3D::Sphere:
      {
	const Sphere3D* s=AnyCast<Sphere3D>(&geom.data);
	glPushMatrix();
	glTranslate(s->center);
	drawSphere(s->radius,32,32);
	glPopMatrix();
	break;
      }
    case GeometricPrimitive3D::Cylinder:
      {
	const Cylinder3D* s=AnyCast<Cylinder3D>(&geom.data);
	glPushMatrix();
	glTranslate(s->center);
	drawCylinder(s->axis*s->height,s->radius,32);
	glPopMatrix();
	break;
      }
      break;
    default:
      fprintf(stderr,"draw: Unsupported geometry type\n");
      return;
    }
  }