// static method used for glut callbacks static void Draw( void ) { cu::cutStartTimer(timer); glClearColor( 0.0, 0.0, 0.0, 1.0 ); glClear( GL_COLOR_BUFFER_BIT ); VHFluidSolver* fluidSolver = VHFluidSolver::solverList[0]; if (pause == 0) fluidSolver->solveFluid(); //glDisable(GL_DEPTH_TEST); fluidSolver->drawFluid(0,0,0,0,0,0); //glEnable(GL_DEPTH_TEST); glutSwapBuffers(); //glutReportErrors(); cu::cutStopTimer(timer); computeFPS(); }
void GR_CudaHardware::renderWire(GU_Detail *gdp, RE_Render &ren, const GR_AttribOffset & /*ptinfo*/, const GR_DisplayOption *dopt, float /*lod*/, const GU_PrimGroupClosure * /*hidden_geometry*/) { GEO_AttributeHandle fluidAh= gdp->getDetailAttribute("cudaFluidPreview"); fluidAh.setElement(gdp); if (fluidAh.getI()== 1) { GEO_AttributeHandle fluidIdAh= gdp->getDetailAttribute("solverId"); fluidIdAh.setElement(gdp); VHFluidSolver* currSolver = VHFluidSolver::solverList[fluidIdAh.getI()]; UT_Vector4 fluidPos(0,0,0); UT_Vector3D fluidRot(0,0,0); if(gdp->volumeCount() == 1) { GEO_Primitive* pprim = gdp->primitives().head(); GU_PrimVolume* volume = (GU_PrimVolume *)pprim; UT_Matrix4 fluidRotMat; volume->getTransform4(fluidRotMat); UT_XformOrder rotOrder; UT_Vector3D scale, trans; fluidRotMat.explode(rotOrder, fluidRot, scale, trans); fluidRot.radToDeg(); fluidPos = volume->getVertex().getPt()->getPos(); } currSolver->drawFluid(fluidRot.x(), fluidRot.y(), fluidRot.z(), fluidPos.x(), fluidPos.y(), fluidPos.z()); } GEO_AttributeHandle partsAh= gdp->getDetailAttribute("cudaParticlesPreview"); partsAh.setElement(gdp); if (partsAh.getI()== 1) { GEO_AttributeHandle partsIdAh= gdp->getDetailAttribute("systemId"); partsIdAh.setElement(gdp); ren.toggleLighting(0); VHParticlesSystem* currSystem = VHParticlesSystem::systemsList[partsIdAh.getI()]; glClear(GL_COLOR_BUFFER_BIT); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE ); currSystem->draw(); glDisable( GL_BLEND ); ren.toggleLighting(1); } GEO_AttributeHandle fluid3DAh= gdp->getDetailAttribute("cudaFluid3DPreview"); fluid3DAh.setElement(gdp); GEO_AttributeHandle fluid3DSliceAh= gdp->getDetailAttribute("sliceDisplay"); fluid3DSliceAh.setElement(gdp); if (fluid3DAh.getI() == 1 || fluid3DSliceAh.getI()== 1) { GEO_AttributeHandle fluidIdAh= gdp->getDetailAttribute("solverId"); fluidIdAh.setElement(gdp); ren.toggleLighting(0); VHFluidSolver3D* curr3DSolver = VHFluidSolver3D::solverList[fluidIdAh.getI()]; UT_Vector4 fluidPos(0,0,0); UT_Vector3D fluidRot(0,0,0); if(gdp->volumeCount() > 0) { GEO_Primitive* pprim = gdp->primitives().head(); GU_PrimVolume* volume = (GU_PrimVolume *)pprim; UT_Matrix4 fluidRotMat; volume->getTransform4(fluidRotMat); UT_XformOrder rotOrder; UT_Vector3D scale, trans; fluidRotMat.explode(rotOrder, fluidRot, scale, trans); fluidRot.radToDeg(); fluidPos = volume->getVertex().getPt()->getPos(); } float sizeX = curr3DSolver->fluidSize.x*0.5; float sizeY = curr3DSolver->fluidSize.y*0.5; float sizeZ = curr3DSolver->fluidSize.z*0.5; if(curr3DSolver->drawCube) { glPushMatrix(); glTranslatef(fluidPos.x(),fluidPos.y(),fluidPos.z()); glRotatef(fluidRot.z(),0,0,1); glRotatef(fluidRot.y(),0,1,0); glRotatef(fluidRot.x(),1,0,0); drawWireCube(sizeX,sizeY,sizeZ, ren); glPopMatrix(); } if (fluid3DAh.getI()== 1) { curr3DSolver->drawFluid(fluidRot.x(), fluidRot.y(), fluidRot.z(), fluidPos.x(), fluidPos.y(), fluidPos.z()); } if (fluid3DSliceAh.getI()== 1) { curr3DSolver->drawFluidSlice(fluidRot.x(), fluidRot.y(), fluidRot.z(), fluidPos.x(), fluidPos.y(), fluidPos.z()); } ren.toggleLighting(1); } }