Пример #1
0
void generateRoomGrid(room_s* r)
{
	if(!r)return;

	initRoomGrid(r);
	
	int i, j;
	for(i=0;i<r->rectangleGridSize.x;i++)
	{
		for(j=0;j<r->rectangleGridSize.z;j++)
		{
			generateGridCell(r,&r->rectangleGrid[i+j*r->rectangleGridSize.x],i,j);
		}
	}
}
Пример #2
0
  std::vector<Primitive *> Particles::getSurfacePrims(double isolevel, double fStepSize, BSDF* bsdf) {
    std::vector<Primitive *> prims;
    double xmin = getParticlesAxisMin(0);
    double ymin = getParticlesAxisMin(1);
    double zmin = getParticlesAxisMin(2);
    double xmax = getParticlesAxisMax(0);
    double ymax = getParticlesAxisMax(1);
    double zmax = getParticlesAxisMax(2);
    int xsteps = (int)((xmax-xmin)/fStepSize);
    int ysteps = (int)((ymax-ymin)/fStepSize);
    int zsteps = (int)((zmax-zmin)/fStepSize);

    vector<vector<Index> > polygons;
    vector<Vector3D> vertexPositions;

    for (int ix = 0; ix <= xsteps; ix++)
      for (int iy = 0; iy <= ysteps; iy++)
        for (int iz = 0; iz <= zsteps; iz++) {
          double x1 = xmin+ix*fStepSize;
          double x2 = std::min(xmax, x1+fStepSize);
          double y1 = ymin+iy*fStepSize;
          double y2 = std::min(ymax, y1+fStepSize);
          double z1 = zmin+iz*fStepSize;
          double z2 = std::min(zmax, z1+fStepSize);

          GridCell grid = generateGridCell(x1,x2,y1,y2,z1,z2);
          std::vector<TriangleVertices *> triangles = polygonise(grid, isolevel);
          for (int i=0; i<triangles.size(); i++) {
            Vector3D p1 = triangles[i]->p[0];
            Vector3D p2 = triangles[i]->p[1];
            Vector3D p3 = triangles[i]->p[2];
            Vector3D n1 = getVertexNormal(p1);
            Vector3D n2 = getVertexNormal(p2);
            Vector3D n3 = getVertexNormal(p3);

            MarchingTriangle *tri = new MarchingTriangle(p1, p2, p3, n1, n2, n3, bsdf);
            prims.push_back(tri);
          }
    }
    return prims;
  }