Example #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();
  }
Example #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]);
}
Example #3
0
AABB3D FormTriangle::getAABB() {
	AABB3D aabb;

	aabb._lowerBound = aabb._upperBound = _points[0];

	aabb.expand(_points[1]);
	aabb.expand(_points[2]);

	aabb.calculateHalfDims();
	aabb.calculateCenter();

	return aabb;
}
bool StaticPositionModel::loadFromOBJ(const std::string &fileName, AABB3D &aabb, bool useBuffers, bool clearArrays) {
	std::ifstream fromFile(fileName);

	if (!fromFile.is_open()) {
#ifdef D3D_DEBUG
		std::cerr << "Could not load model file " << fileName << std::endl;
#endif
		return false;
	}

	std::string rootName(getRootName(fileName));

	std::vector<Vec3f> filePositions;

	// Hash map for linking indices to vertex array index for attributes
	std::unordered_map<staticPositionMeshIndexType, size_t> indexToVertex;

	// Initial extremes
	aabb._lowerBound = Vec3f(999999.0f, 999999.0f, 999999.0f);
	aabb._upperBound = Vec3f(-999999.0f, -999999.0f, -999999.0f);

	std::unordered_map<std::string, size_t> matReferences;

	while (!fromFile.eof()) {
		// Read line header
		std::string line;
		getline(fromFile, line);

		std::stringstream ss(line);

		std::string header;
		ss >> header;

		if (header == "v") {
			// Add vertex
			float x, y, z;

			ss >> x >> y >> z;

			filePositions.push_back(Vec3f(x, y, z));

			aabb.expand(Vec3f(x, y, z));
		}
		else if (header == "f") {
Example #5
0
void Triangle3D::getAABB(AABB3D& bb) const
{
	bb.setPoint(a);
	bb.expand(b);
	bb.expand(c);
}
void ConvexPolyhedron3D::getAABB(AABB3D& b) const
{
  b.setPoint(vertices[0]);
  for(int i=1; i<numVertices; i++)
    b.expand(vertices[i]);
}
Example #7
0
void Segment3D::getAABB(AABB3D& bb) const
{
    bb.setPoint(a);
    bb.expand(b);
}