void RubikGame::run() { initSystems(); const std::vector<std::string> texPaths = { texture_path1, texture_path2, texture_path3, texture_path4, texture_path5, texture_path6 }; const std::string texPathsSame[6] = { texture_pathAyse, texture_pathAyse, texture_pathAyse, texture_pathAyse, texture_pathAyse, texture_pathAyse }; initVoxels(glm::vec3{ 0.0f, 0.0f, 0.0f }, glm::vec3{ 1.0f, 1.0f, 1.0f }, texPaths); gameLoop(); }
BoxGrid::BoxGrid(const Mesh & mesh,const int res,string filename) { initRes(res); if(exists(filename)) initFromFile(filename); else initVoxels(mesh,res); initStructure(); compute(); }
void runFluidSim() { Fluid_Solver fluid_solver(dimx,dimy,dimz,gridh,1.0f/30.0f,9.82f,1.0f,Nparticles); fluid_solver.init_box(); OpenGl_initViewer(600, 600, dimx, dimy, dimz, gridh); OpenGl_initParticles(&fluid_solver.particles.pos[0], &fluid_solver.particles.vel[0], sizeof(vec3f)*fluid_solver.particles.currnp, fluid_solver.particles.currnp); int Nvoxels = dimx*dimy*dimz; Array3f voxelFlags(dimx,dimy,dimz); float * voxelPositions = new float[3*dimx*dimy*dimz]; initVoxels(voxelPositions,dimx,dimy,dimz); OpenGl_initWireframeCube(voxelPositions,voxelFlags.data,Nvoxels); update_voxel_flags(fluid_solver.grid,voxelFlags); while(running) { if(reset) fluid_solver.reset(); reset = false; if(showgrid) { update_voxel_flags(fluid_solver.grid,voxelFlags); OpenGl_updateVoxels(voxelPositions, voxelFlags, Nvoxels); } OpenGl_drawAndUpdate(running); if(step || play) { // stopwatch.startTimer(); fluid_solver.step_frame(); // stopwatch.stopTimer(); // std::cout << std::scientific; // std::cout << stopwatch.getElapsedTime() << "\n"; // if(numframes >= 6) // avgtime += stopwatch.getElapsedTime(); // numframes++; write_paricle_pos_binary(fluid_solver.particles); //fluid_solver.createSurface(); //openGl_setMesh(fluid_solver.tri,fluid_solver.nrofTriangles); } OpenGl_updateParticles(fluid_solver.particles); } TerminateViewer(); // std::cout << std::scientific; // std::cout << "Avg. time" << avgtime/(numframes-6) << "\n"; // std::cout << "Press any key to quit...\n"; // std::cin.get(); }