Ejemplo n.º 1
0
void Octree::split()
{
	float subX = bounds.cent.x;
	float subY = bounds.cent.y;
	float subZ = bounds.cent.z;

	Moo::Vector3D halfD = bounds.cent - bounds.min;
	int nextLevel = level + 1;
	//lower layer cells(0-3)
	Moo::BoundingBox box0(bounds.min, bounds.cent);
	std::shared_ptr<Octree> oct0 = std::make_shared<Octree>(nextLevel, box0, &*this, this->cr);

	Moo::Vector3D box1Min(bounds.min.x, bounds.min.y, bounds.cent.z);
	Moo::Vector3D box1Max = box1Min + halfD;
	Moo::BoundingBox box1(box1Min, box1Max);
	std::shared_ptr<Octree> oct1 = std::make_shared<Octree>(nextLevel, box1, &*this, this->cr);

	Moo::Vector3D box2Min(bounds.cent.x, bounds.min.y, bounds.cent.z);
	Moo::Vector3D box2Max = box2Min + halfD;
	Moo::BoundingBox box2(box2Min, box2Max);
	std::shared_ptr<Octree> oct2 = std::make_shared<Octree>(nextLevel, box2, &*this, this->cr);

	Moo::Vector3D box3Min(bounds.cent.x, bounds.min.y, bounds.min.z);
	Moo::Vector3D box3Max = box3Min + halfD;
	Moo::BoundingBox box3(box3Min, box3Max);
	std::shared_ptr<Octree> oct3 = std::make_shared<Octree>(nextLevel, box3, &*this, this->cr);

	//upper layer cells(4-7)
	Moo::Vector3D box4Min(bounds.min.x, bounds.cent.y, bounds.min.z);
	Moo::Vector3D box4Max = box4Min + halfD;
	Moo::BoundingBox box4(box4Min, box4Max);
	std::shared_ptr<Octree> oct4 = std::make_shared<Octree>(nextLevel, box4, &*this, this->cr);

	Moo::Vector3D box5Min(bounds.min.x, bounds.cent.y, bounds.cent.z);
	Moo::Vector3D box5Max = box5Min + halfD;
	Moo::BoundingBox box5(box5Min, box5Max);
	std::shared_ptr<Octree> oct5 = std::make_shared<Octree>(nextLevel, box5, &*this, this->cr);

	Moo::Vector3D box6Min = bounds.cent;
	Moo::Vector3D box6Max = bounds.max;
	Moo::BoundingBox box6(box6Min, box6Max);
	std::shared_ptr<Octree> oct6 = std::make_shared<Octree>(nextLevel, box6, &*this, this->cr);

	Moo::Vector3D box7Min(bounds.cent.x, bounds.cent.y, bounds.min.z);
	Moo::Vector3D box7Max = box7Min + bounds.cent;
	Moo::BoundingBox box7(box7Min, box7Max);
	std::shared_ptr<Octree> oct7 = std::make_shared<Octree>(nextLevel, box7, &*this, this->cr);

	childNode[0] = oct0;
	childNode[1] = oct1;
	childNode[2] = oct2;
	childNode[3] = oct3;
	childNode[4] = oct4;
	childNode[5] = oct5;
	childNode[6] = oct6;
	childNode[7] = oct7;
	
}
Ejemplo n.º 2
0
int main()
{
  Scene scene("scene");
  
  PlyBox<VertexType> box1("box1", VertexType(0.,  0.,  0.), 1., 1., 1.);
  PlyBox<VertexType> box2("box2", VertexType(1.5, 1.5, 0.), 0.5, 0.5, 0.5);
  PlyBox<VertexType> box3("box3", VertexType(0.,  2.,  0.), 1., 5., 1.);
  PlyBox<VertexType> box4("box4", VertexType(0.,  -1., 0.), 1., -5., 1.);

  scene.add(&box1); scene.add(&box2); scene.add(&box3); scene.add(&box4);

  PlyWriter writer("test_PlyBox_output.ply");
  writer.write(scene);
  writer.close();
  
  return 0;
}
Ejemplo n.º 3
0
static void box_c(uint8_t *bits,int col,int16_t x,int16_t y,int16_t w,int16_t h,uint8_t chunk)
{
  // Clipped box draw, anyway aligned. This does real clipping instead of
  // just rejecting out of bounds stuff like the pix_c calls.

  int16_t bb;
  if(x>=XREZ||y>=YREZ) return;
  if(x<0) 
  {
    w+=x;
    x=0;
  }
  if(w<0) return;
  bb=x+w;
  if(bb>=XREZ) w-=(bb-XREZ)+1;
  if(w<0||w>=XREZ) return;
  if(y<0) 
  {
    h+=y;
    y=0;
  }
  if(h<0) return; 
  bb=y+h;
  if(bb>=YREZ) h-=(bb-YREZ)+1;
  if(h<0||h>=YREZ) return;
  switch(chunk)
  {
  default: // any align, byte data
    box(bits,getcol1(col),x,y,w,h);
    break;
  case 2: // word align, word data
    box2(bits,getcol2(col),x,y,w,h);
    break;
  case 4: // long align, long data
    box4(bits,getcol4(col),x,y,w,h);
    break;
  }
}