Beispiel #1
0
  virtual bool Initialize() {
    viewport.n = 0.1;
    viewport.f = 100;
    viewport.setLensAngle(DtoR(30.0));
    camera.dist = 6;
    if(!geometry.empty()) {
      AABB3D bb;
      bb.minimize();
      for(size_t i=0;i<geometry.size();i++) {
	AABB3D bi = geometry[i]->GetAABB();
	bb.expand(bi.bmin);
	bb.expand(bi.bmax);
      }
      camera.tgt = (bb.bmin + bb.bmax)*0.5;
      Real size = (bb.bmax-bb.bmin).maxElement();
      camera.dist = 3.0*size;
      if(size < 0.1) viewport.n = size;
      if(size*3 > 100) viewport.f = size*3;
    }
    
    glEnable(GL_CULL_FACE);
    glEnable(GL_DEPTH_TEST);
    glClearColor(0,0,0,0);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    return GLUTNavigationProgram::Initialize();
  }
Beispiel #2
0
void Polygon3D::getAABB(AABB3D& bb) const
{
  if(vertices.size() == 0) {
    bb.minimize();
    return;
  }
  bb.setPoint(vertices[0]);
  for(size_t i=1; i<vertices.size(); i++)
    bb.expand(vertices[i]);
}