//Draws a line for each ray that is slightly transparent
void RayTree::setupVBOs() {
	raytree_verts.clear();
	raytree_edge_indices.clear();

	//Sets different colors for each type and the constant for making the lines transparent
	double alpha = .5;
	Vec main_color(.7,.7,.7);
	Vec shadow_color(.1,.9,.1);
	Vec reflected_color(.9,.1,.1);
	Vec single_scatter_color(.1,.1,.9);
	Vec multiple_scatter_color(.9,.1,.9);

	unsigned int i;
	int count = 0;
	for(i = 0;i < main_segments.size();++i){
		raytree_verts.push_back(VBOPosColor4(main_segments[i].getStart(),main_color,alpha));
		raytree_verts.push_back(VBOPosColor4(main_segments[i].getEnd(),main_color,alpha));
		raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1));
		count+=2;
	}
	for(i = 0;i < shadow_segments.size();++i){
		raytree_verts.push_back(VBOPosColor4(shadow_segments[i].getStart(),shadow_color,alpha));
		raytree_verts.push_back(VBOPosColor4(shadow_segments[i].getEnd(),shadow_color,alpha));
		raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1));
		count+=2;
	}
	for(i = 0;i < reflected_segments.size();++i){
		raytree_verts.push_back(VBOPosColor4(reflected_segments[i].getStart(),reflected_color,alpha));
		raytree_verts.push_back(VBOPosColor4(reflected_segments[i].getEnd(),reflected_color,alpha));
		raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1));
		count+=2;
	}
	for(i = 0;i < single_scatter_segments.size();++i){
		raytree_verts.push_back(VBOPosColor4(single_scatter_segments[i].getStart(),single_scatter_color,alpha));
		raytree_verts.push_back(VBOPosColor4(single_scatter_segments[i].getEnd(),single_scatter_color,alpha));
		raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1));
		count+=2;
	}
	for(i = 0;i < multiple_scatter_segments.size();++i){
		raytree_verts.push_back(VBOPosColor4(multiple_scatter_segments[i].getStart(),multiple_scatter_color,alpha));
		raytree_verts.push_back(VBOPosColor4(multiple_scatter_segments[i].getEnd(),multiple_scatter_color,alpha));
		raytree_edge_indices.push_back(VBOIndexedEdge(count,count+1));
		count+=2;
	}

	int ne = raytree_edge_indices.size();

	cleanupVBOs();

	if(ne > 0) {
		glBindBuffer(GL_ARRAY_BUFFER,raytree_verts_VBO);
		glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosColor4) * ne *2,&raytree_verts[0],GL_STATIC_DRAW);
		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,raytree_edge_indices_VBO);
		glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(VBOIndexedEdge) * ne,&raytree_edge_indices[0],GL_STATIC_DRAW);
	}
}
Example #2
0
void Mesh::setupVBOs() {
  // delete all the old geometry
  mesh_tri_verts.clear(); 
  light_vert.clear();
  cleanupVBOs();
  // setup the new geometry
  Vec3f light_position = LightPosition();
  SetupLight(light_position);
  SetupMesh();
  SetupPlateVisualization();
  bbox.setupVBOs();
}
Example #3
0
void Mesh::setupVBOs() {
  // delete all the old geometry
  control_map_tri_verts.clear();
  board_tri_verts.clear();
  piece_tri_verts.clear();
  light_vert.clear();
  floor_quad_verts.clear();
  cleanupVBOs();
  // setup the new geometry
  //Vec3f light_position = LightPosition();
  //SetupLight(light_position);
  SetupFloor();
  SetupMesh(table, board_tri_verts_VBO, board_tri_verts);
  SetupMesh(control_map, control_map_tri_verts_VBO, control_map_tri_verts);
  SetupMesh(piece, piece_tri_verts_VBO, piece_tri_verts);
  bbox.setupVBOs();
}
Example #4
0
void MarchingCubes::setupVBOs() {
  double isosurface = 0.5;
  marching_cubes_verts.clear();
  marching_cubes_tri_indices.clear();

  for (int i = 0; i < nx-1; i++) {
    for (int j = 0; j < ny-1; j++) {
      for (int k = 0; k < nz-1; k++) {
	GridValue v[8];
	double eps = 0;//dx * 0.05;
	v[0] = GridValue(Vec3f(dx*i    +eps,dy*j    +eps,dz*k    +eps),getNormal(i  ,j  ,k  ),get(i  ,j  ,k  ));
	v[1] = GridValue(Vec3f(dx*i    +eps,dy*j    +eps,dz*(k+1)-eps),getNormal(i  ,j  ,k+1),get(i  ,j  ,k+1));
	v[2] = GridValue(Vec3f(dx*i    +eps,dy*(j+1)-eps,dz*k    +eps),getNormal(i  ,j+1,k  ),get(i  ,j+1,k  ));
	v[3] = GridValue(Vec3f(dx*i    +eps,dy*(j+1)-eps,dz*(k+1)-eps),getNormal(i  ,j+1,k+1),get(i  ,j+1,k+1));
	v[4] = GridValue(Vec3f(dx*(i+1)-eps,dy*j    +eps,dz*k    +eps),getNormal(i+1,j  ,k  ),get(i+1,j  ,k  ));
	v[5] = GridValue(Vec3f(dx*(i+1)-eps,dy*j    +eps,dz*(k+1)-eps),getNormal(i+1,j  ,k+1),get(i+1,j  ,k+1));
	v[6] = GridValue(Vec3f(dx*(i+1)-eps,dy*(j+1)-eps,dz*k    +eps),getNormal(i+1,j+1,k  ),get(i+1,j+1,k  ));
	v[7] = GridValue(Vec3f(dx*(i+1)-eps,dy*(j+1)-eps,dz*(k+1)-eps),getNormal(i+1,j+1,k+1),get(i+1,j+1,k+1));
	// need to alternate orientation of central tetrahedron to ensure that the diagonals line up
	if ((i+j+k)%2) {
	  PaintTetra(v[0],v[5],v[3],v[6],isosurface);
	  PaintTetra(v[0],v[1],v[3],v[5],isosurface);
	  PaintTetra(v[0],v[4],v[5],v[6],isosurface);
	  PaintTetra(v[0],v[2],v[6],v[3],isosurface);
	  PaintTetra(v[3],v[7],v[6],v[5],isosurface);
	} else {
	  PaintTetra(v[2],v[4],v[1],v[7],isosurface);
	  PaintTetra(v[5],v[4],v[7],v[1],isosurface);
	  PaintTetra(v[2],v[3],v[7],v[1],isosurface);
	  PaintTetra(v[4],v[2],v[1],v[0],isosurface);
	  PaintTetra(v[2],v[7],v[6],v[4],isosurface);
	}
      }
    }
  }

  // cleanup old buffer data (if any)
  cleanupVBOs();

  // copy the data to each VBO
  int num_marching_cubes_tris = marching_cubes_tri_indices.size();
  glBindBuffer(GL_ARRAY_BUFFER,marching_cubes_verts_VBO); 
  glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosNormal)*num_marching_cubes_tris*3,&marching_cubes_verts[0],GL_STATIC_DRAW); 
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,marching_cubes_tri_indices_VBO); 
  glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(VBOIndexedTri)*num_marching_cubes_tris,&marching_cubes_tri_indices[0],GL_STATIC_DRAW);
}
void PhotonMapping::setupVBOs() {
  photon_verts.clear();
  photon_direction_indices.clear();
  kdtree_verts.clear();
  kdtree_edge_indices.clear();

  // initialize the data
  int dir_count = 0;
  int edge_count = 0;
  BoundingBox *bb = mesh->getBoundingBox();
  double max_dim = bb->maxDim();

  if (kdtree == NULL) return;
  std::vector<const KDTree*> todo;  
  todo.push_back(kdtree);
  while (!todo.empty()) {
    const KDTree *node = todo.back();
    todo.pop_back(); 
    if (node->isLeaf()) {
      const std::vector<Photon> &photons = node->getPhotons();
      int num_photons = photons.size();
      for (int i = 0; i < num_photons; i++) {
	const Photon &p = photons[i];
	Vec3f energy = p.getEnergy()*args->num_photons_to_shoot;
	const Vec3f &position = p.getPosition();
	Vec3f other = position + p.getDirectionFrom()*0.02*max_dim;
	photon_verts.push_back(VBOPosColor(position,energy));
	photon_verts.push_back(VBOPosColor(other,energy));
	photon_direction_indices.push_back(VBOIndexedEdge(dir_count,dir_count+1)); dir_count+=2;
      }

      // initialize kdtree vbo
      const Vec3f& min = node->getMin();
      const Vec3f& max = node->getMax();
      kdtree_verts.push_back(VBOPos(Vec3f(min.x(),min.y(),min.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(min.x(),min.y(),max.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(min.x(),max.y(),min.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(min.x(),max.y(),max.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(max.x(),min.y(),min.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(max.x(),min.y(),max.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(max.x(),max.y(),min.z())));
      kdtree_verts.push_back(VBOPos(Vec3f(max.x(),max.y(),max.z())));

      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count  ,edge_count+1)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+1,edge_count+3)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+3,edge_count+2)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+2,edge_count  )); 

      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+4,edge_count+5)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+5,edge_count+7)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+7,edge_count+6)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+6,edge_count+4)); 

      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count  ,edge_count+4)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+1,edge_count+5)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+2,edge_count+6)); 
      kdtree_edge_indices.push_back(VBOIndexedEdge(edge_count+3,edge_count+7)); 


      edge_count += 8;

    } else {
      todo.push_back(node->getChild1());
      todo.push_back(node->getChild2());
    } 
  }
  assert (2*photon_direction_indices.size() == photon_verts.size());
  int num_directions = photon_direction_indices.size();
  int num_edges = kdtree_edge_indices.size();

  // cleanup old buffer data (if any)
  cleanupVBOs();

  // copy the data to each VBO
  if (num_directions > 0) {
    glBindBuffer(GL_ARRAY_BUFFER,photon_verts_VBO); 
    glBufferData(GL_ARRAY_BUFFER,
		 sizeof(VBOPosColor) * num_directions * 2,
		 &photon_verts[0],
		 GL_STATIC_DRAW); 
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,photon_direction_indices_VBO); 
    glBufferData(GL_ELEMENT_ARRAY_BUFFER,
		 sizeof(VBOIndexedEdge) * num_directions,
		 &photon_direction_indices[0], GL_STATIC_DRAW);
  } 

  if (num_edges > 0) {
    glBindBuffer(GL_ARRAY_BUFFER,kdtree_verts_VBO); 
    glBufferData(GL_ARRAY_BUFFER,
		 sizeof(VBOPos) * num_edges * 2,
		 &kdtree_verts[0],
		 GL_STATIC_DRAW); 
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,kdtree_edge_indices_VBO); 
    glBufferData(GL_ELEMENT_ARRAY_BUFFER,
		 sizeof(VBOIndexedEdge) * num_edges,
		 &kdtree_edge_indices[0], GL_STATIC_DRAW);
  } 
}
Example #6
0
void Fluid::setupVBOs() {
  HandleGLError("in setup fluid VBOs");

  fluid_particles.clear();
  fluid_velocity_vis.clear();  
  fluid_face_velocity_vis.clear();
  fluid_pressure_vis.clear();
  fluid_cell_type_vis.clear();

  // =====================================================================================
  // setup the particles
  // =====================================================================================
  for (int x = 0; x < nx; x++) {
    for (int y = 0; y < ny; y++) {
      for (int z = 0; z < nz; z++) {
	Cell *cell = getCell(x,y,z);
	std::vector<FluidParticle*> &particles = cell->getParticles();
	for (unsigned int iter = 0; iter < particles.size(); iter++) {
	  FluidParticle *p = particles[iter];
	  Vec3f v = p->getPosition();
	  fluid_particles.push_back(VBOPos(v));
	}
      }
    }
  }

  // =====================================================================================
  // visualize the velocity
  // =====================================================================================
  if (args->dense_velocity == 0) {
    // one velocity vector per cell, at the centroid
    for (int i = 0; i < nx; i++) {
      for (int j = 0; j < ny; j++) {
	for (int k = 0; k < nz; k++) {
	  Vec3f cell_center((i+0.5)*dx,(j+0.5)*dy,(k+0.5)*dz);
	  Vec3f direction(get_u_avg(i,j,k),get_v_avg(i,j,k),get_w_avg(i,j,k));
	  Vec3f pt2 = cell_center+100*args->timestep*direction;
	  fluid_velocity_vis.push_back(VBOPosColor(cell_center,Vec3f(1,0,0)));
	  fluid_velocity_vis.push_back(VBOPosColor(pt2,Vec3f(1,1,1)));
	}
      }
    }
  } else if (args->dense_velocity == 1) {
    double z = nz*dz / 2.0;
    for (double x = 0; x <= (nx+0.01)*dx; x+=0.25*dx) {
      for (double y = 0; y <= (ny+0.01)*dy; y+=0.25*dy) {
	Vec3f vel = getInterpolatedVelocity(Vec3f(x,y,z));
	Vec3f pt1(x,y,z);
	Vec3f pt2 = pt1 + 100*args->timestep*vel;
	fluid_velocity_vis.push_back(VBOPosColor(pt1,Vec3f(1,0,0)));
	fluid_velocity_vis.push_back(VBOPosColor(pt2,Vec3f(1,1,1)));
      } 
    }
  } else if (args->dense_velocity == 2) {
    double y = ny*dy / 2.0;
    for (double x = 0; x <= (nx+0.01)*dx; x+=0.25*dx) {
      for (double z = 0; z <= (nz+0.01)*dz; z+=0.25*dz) {
	Vec3f vel = getInterpolatedVelocity(Vec3f(x,y,z));
	Vec3f pt1(x,y,z);
	Vec3f pt2 = pt1 + 100*args->timestep*vel;
	fluid_velocity_vis.push_back(VBOPosColor(pt1,Vec3f(1,0,0)));
	fluid_velocity_vis.push_back(VBOPosColor(pt2,Vec3f(1,1,1)));
      }
    } 
  } else if (args->dense_velocity == 3) {
    double x = nx*dx / 2.0;
    for (double y = 0; y <= (ny+0.01)*dy; y+=0.25*dy) {
      for (double z = 0; z <= (nz+0.01)*dz; z+=0.25*dz) {
	Vec3f vel = getInterpolatedVelocity(Vec3f(x,y,z));
	Vec3f pt1(x,y,z);
	Vec3f pt2 = pt1 + 100*args->timestep*vel;
	fluid_velocity_vis.push_back(VBOPosColor(pt1,Vec3f(1,0,0)));
	fluid_velocity_vis.push_back(VBOPosColor(pt2,Vec3f(1,1,1)));
      }
    } 
  }

  // =====================================================================================
  // visualize the face velocity
  // render stubby triangles to visualize the u, v, and w velocities between cell faces
  // =====================================================================================
  for (int i = 0; i < nx; i++) {
    for (int j = 0; j < ny; j++) {
      for (int k = 0; k < nz; k++) {
	double dt = args->timestep;
	double u = get_u_plus(i,j,k)*100*dt;
	double v = get_v_plus(i,j,k)*100*dt;
	double w = get_w_plus(i,j,k)*100*dt;
	double x = i*dx;
	double y = j*dy;
	double z = k*dz;
	if (u < -10*dt) {
	  Vec3f pts[5] = { Vec3f(x+dx+u,y+0.5*dy,z+0.5*dz),
			   Vec3f(x+dx,y+0.55*dy,z+0.55*dz),
			   Vec3f(x+dx,y+0.55*dy,z+0.45*dz),
			   Vec3f(x+dx,y+0.45*dy,z+0.45*dz),
			   Vec3f(x+dx,y+0.45*dy,z+0.55*dz) };
	  setupConeVBO(pts,Vec3f(1,0,0),fluid_face_velocity_vis);	  
	} else if (u > 10*dt) {
	  Vec3f pts[5] = { Vec3f(x+dx+u,y+0.5*dy,z+0.5*dz),
			   Vec3f(x+dx,y+0.45*dy,z+0.45*dz),
			   Vec3f(x+dx,y+0.55*dy,z+0.45*dz),
			   Vec3f(x+dx,y+0.55*dy,z+0.55*dz),
			   Vec3f(x+dx,y+0.45*dy,z+0.55*dz) };
	  setupConeVBO(pts,Vec3f(1,0,0),fluid_face_velocity_vis);	  
	}
	if (v < -10*dt) {
	  Vec3f pts[5] = { Vec3f(x+0.5*dx,y+dy+v,z+0.5*dz),
			   Vec3f(x+0.45*dx,y+dy,z+0.45*dz),
			   Vec3f(x+0.55*dx,y+dy,z+0.45*dz),
			   Vec3f(x+0.55*dx,y+dy,z+0.55*dz),
			   Vec3f(x+0.45*dx,y+dy,z+0.55*dz) };
	  setupConeVBO(pts,Vec3f(0,1,0),fluid_face_velocity_vis);	  
	} else if (v > 10*dt) {
	  Vec3f pts[5] = { Vec3f(x+0.5*dx,y+dy+v,z+0.5*dz),
			   Vec3f(x+0.55*dx,y+dy,z+0.55*dz),
			   Vec3f(x+0.55*dx,y+dy,z+0.45*dz),
			   Vec3f(x+0.45*dx,y+dy,z+0.45*dz),
			   Vec3f(x+0.45*dx,y+dy,z+0.55*dz) };
	  setupConeVBO(pts,Vec3f(0,1,0),fluid_face_velocity_vis);	  
	}
	if (w < -10*dt) {
	  Vec3f pts[5] = { Vec3f(x+0.5*dx,y+0.5*dy,z+dz+w),
			   Vec3f(x+0.55*dx,y+0.55*dy,z+dz),
			   Vec3f(x+0.55*dx,y+0.45*dy,z+dz),
			   Vec3f(x+0.45*dx,y+0.45*dy,z+dz),
			   Vec3f(x+0.45*dx,y+0.55*dy,z+dz) };
	  setupConeVBO(pts,Vec3f(0,0,1),fluid_face_velocity_vis);	  
	} else if (w > 10*dt) {
	  Vec3f pts[5] = { Vec3f(x+0.5*dx,y+0.5*dy,z+dz+w),
			   Vec3f(x+0.45*dx,y+0.45*dy,z+dz),
			   Vec3f(x+0.55*dx,y+0.45*dy,z+dz),
			   Vec3f(x+0.55*dx,y+0.55*dy,z+dz),
			   Vec3f(x+0.45*dx,y+0.55*dy,z+dz) };
	  setupConeVBO(pts,Vec3f(0,0,1),fluid_face_velocity_vis);	  
	}
      }
    }
  }

  // =====================================================================================
  // visualize the cell pressure
  // =====================================================================================
  for (int i = 0; i < nx; i++) {
    for (int j = 0; j < ny; j++) {
      for (int k = 0; k < nz; k++) {
	Vec3f pts[8] = { Vec3f((i+0.1)*dx,(j+0.1)*dy,(k+0.1)*dz),
			 Vec3f((i+0.1)*dx,(j+0.1)*dy,(k+0.9)*dz),
			 Vec3f((i+0.1)*dx,(j+0.9)*dy,(k+0.1)*dz),
			 Vec3f((i+0.1)*dx,(j+0.9)*dy,(k+0.9)*dz),
			 Vec3f((i+0.9)*dx,(j+0.1)*dy,(k+0.1)*dz),
			 Vec3f((i+0.9)*dx,(j+0.1)*dy,(k+0.9)*dz),
			 Vec3f((i+0.9)*dx,(j+0.9)*dy,(k+0.1)*dz),
			 Vec3f((i+0.9)*dx,(j+0.9)*dy,(k+0.9)*dz) };
          double p = getCell(i,j,k)->getPressure();
          p *= 0.1;
          if (p > 1) p = 1;
          if (p < -1) p = -1;
          assert(p >= -1 && p <= 1);
          Vec3f color;
	  if (p < 0) {
            color = Vec3f(1+p,1+p,1);
          } else {
            color = Vec3f(1,1-p,1-p);
          }
	  setupCubeVBO(pts,color,fluid_pressure_vis);
      }
    }
  }

  // =====================================================================================
  // render the MAC cells (FULL, SURFACE, or EMPTY)
  // =====================================================================================
  for (int i = 0; i < nx; i++) {
    for (int j = 0; j < ny; j++) {
      for (int k = 0; k < nz; k++) {
	Vec3f pts[8] = { Vec3f((i+0.1)*dx,(j+0.1)*dy,(k+0.1)*dz),
			 Vec3f((i+0.1)*dx,(j+0.1)*dy,(k+0.9)*dz),
			 Vec3f((i+0.1)*dx,(j+0.9)*dy,(k+0.1)*dz),
			 Vec3f((i+0.1)*dx,(j+0.9)*dy,(k+0.9)*dz),
			 Vec3f((i+0.9)*dx,(j+0.1)*dy,(k+0.1)*dz),
			 Vec3f((i+0.9)*dx,(j+0.1)*dy,(k+0.9)*dz),
			 Vec3f((i+0.9)*dx,(j+0.9)*dy,(k+0.1)*dz),
			 Vec3f((i+0.9)*dx,(j+0.9)*dy,(k+0.9)*dz) };
	Cell *cell = getCell(i,j,k);
	Vec3f color;
	if (cell->getStatus() == CELL_FULL) {
	  color = Vec3f(1,0,0);
	} else if (cell->getStatus() == CELL_SURFACE) {
	  color=Vec3f(0,0,1);
	} else {
	  continue;
	}
	setupCubeVBO(pts,color,fluid_cell_type_vis);
      }
    }
  }

  // cleanup old buffer data (if any)
  cleanupVBOs();

  // copy the data to each VBO
  glBindBuffer(GL_ARRAY_BUFFER,fluid_particles_VBO); 
  glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPos)*fluid_particles.size(),&fluid_particles[0],GL_STATIC_DRAW); 
  if (fluid_velocity_vis.size() > 0) {
    glBindBuffer(GL_ARRAY_BUFFER,fluid_velocity_vis_VBO); 
    glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosColor)*fluid_velocity_vis.size(),&fluid_velocity_vis[0],GL_STATIC_DRAW); 
  }
  if (fluid_face_velocity_vis.size() > 0) {
    glBindBuffer(GL_ARRAY_BUFFER,fluid_face_velocity_vis_VBO); 
    glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosNormalColor)*fluid_face_velocity_vis.size(),&fluid_face_velocity_vis[0],GL_STATIC_DRAW); 
  }
  glBindBuffer(GL_ARRAY_BUFFER,fluid_pressure_vis_VBO); 
  glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosNormalColor)*fluid_pressure_vis.size(),&fluid_pressure_vis[0],GL_STATIC_DRAW); 
  glBindBuffer(GL_ARRAY_BUFFER,fluid_cell_type_vis_VBO); 
  glBufferData(GL_ARRAY_BUFFER,sizeof(VBOPosNormalColor)*fluid_cell_type_vis.size(),&fluid_cell_type_vis[0],GL_STATIC_DRAW); 

  HandleGLError("leaving setup fluid");

  // =====================================================================================
  // setup a marching cubes representation of the surface
  // =====================================================================================
  for (int i = 0; i <= nx; i++) {
    for (int j = 0; j <= ny; j++) {
      for (int k = 0; k <= nz; k++) {
	marchingCubes->set(i,j,k,interpolateIsovalue(Vec3f((i-0.5),(j-0.5),(k-0.5))));
      } 
    }
  }
  marchingCubes->setupVBOs();
}
Example #7
0
Radiosity::~Radiosity() {
  Cleanup();
  cleanupVBOs();
}