void init () { glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); srand ( time ( 0x0 ) ); glClearColor( 0.49, 0.49, 0.49, 1.0 ); glShadeModel( GL_SMOOTH ); glEnable ( GL_COLOR_MATERIAL ); glEnable (GL_DEPTH_TEST); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask ( 1 ); glEnable ( GL_TEXTURE_2D ); // callbacks glutDisplayFunc( display ); glutReshapeFunc( reshape ); glutKeyboardFunc( keyboard_func ); glutMouseFunc( mouse_click_func ); glutMotionFunc( mouse_move_func ); glutIdleFunc( idle_func ); glutSetCursor ( GLUT_CURSOR_NONE ); cam_angs.x = 29; cam_angs.y = 75; cam_angs.z = 80.0; cam_to.x = 0; cam_to.y = 0; cam_to.z = 5; cam_fov = 35.0; light[0].x = 39; light[0].y = -60; light[0].z = 43; light_to[0].x = 0; light_to[0].y = 0; light_to[0].z = 0; light[1].x = 15; light[1].y = -5; light[1].z = 145; light_to[1].x = 0; light_to[1].y = 0; light_to[1].z = 0; light_fov = 45; #ifdef USE_SHADOWS createShadowTextures(); createFrameBuffer (); setShadowLight ( light[0].x, light[0].y, light[0].z, light_to[0].x, light_to[0].y, light_to[0].z, light_fov ); setShadowLightColor ( .7, .7, .7, 0.2, 0.2, 0.2 ); #endif obj_from.x = 0; obj_from.y = 0; obj_from.z = 20; // emitter obj_angs.x = 118.7; obj_angs.y = 200; obj_angs.z = 1.0; obj_dang.x = 1; obj_dang.y = 1; obj_dang.z = 0; psys.Initialize ( BFLUID, psys_nmax ); psys.SPH_CreateExample ( 0, psys_nmax ); psys.SetVec ( EMIT_ANG, Vector3DF ( obj_angs.x, obj_angs.y, obj_angs.z ) ); psys.SetVec ( EMIT_POS, Vector3DF ( obj_from.x, obj_from.y, obj_from.z ) ); psys.SetParam ( PNT_DRAWMODE, int(bPntDraw ? 1:0) ); psys.SetParam ( CLR_MODE, iClrMode ); }
void init () { srand ( time ( 0x0 ) ); obj_from.x = 0; obj_from.y = 0; obj_from.z = 20; // emitter obj_angs.x = 118.7; obj_angs.y = 200; obj_angs.z = 1.0; psys.Initialize ( BFLUID, psys_nmax ); psys.SPH_CreateExample ( 0, psys_nmax ); psys.SetVec ( EMIT_ANG, Vector3DF ( obj_angs.x, obj_angs.y, obj_angs.z ) ); psys.SetVec ( EMIT_POS, Vector3DF ( obj_from.x, obj_from.y, obj_from.z ) ); psys.SetParam ( PNT_DRAWMODE, int(bPntDraw ? 1:0) ); psys.SetParam ( CLR_MODE, iClrMode ); }
void keyboard_func ( unsigned char key, int x, int y ) { switch( key ) { case 'M': case 'm': { psys_nmax *= 2; if ( psys_nmax > 65535 ) psys_nmax = 65535; psys.SPH_CreateExample ( psys_demo, psys_nmax ); } break; case 'N': case 'n': { psys_nmax /= 2; if ( psys_nmax < 64 ) psys_nmax = 64; psys.SPH_CreateExample ( psys_demo, psys_nmax ); } break; case '0': UpdateEmit (); psys_freq++; psys.SetVec ( EMIT_RATE, Vector3DF(psys_freq, psys_rate, 0) ); break; case '9': UpdateEmit (); psys_freq--; if ( psys_freq < 0 ) psys_freq = 0; psys.SetVec ( EMIT_RATE, Vector3DF(psys_freq, psys_rate, 0) ); break; case '.': case '>': UpdateEmit (); if ( ++psys_rate > 100 ) psys_rate = 100; psys.SetVec ( EMIT_RATE, Vector3DF(psys_freq, psys_rate, 0) ); break; case ',': case '<': UpdateEmit (); if ( --psys_rate < 0 ) psys_rate = 0; psys.SetVec ( EMIT_RATE, Vector3DF(psys_freq, psys_rate, 0) ); break; case 'g': case 'G': psys.Toggle ( USE_CUDA ); break; case 'f': case 'F': mode = MODE_DOF; break; case 'z': case 'Z': mode = MODE_CAM_TO; break; case 'c': case 'C': mode = MODE_CAM; break; case 'h': case 'H': bHelp = !bHelp; break; case 'i': case 'I': UpdateEmit (); mode = MODE_OBJPOS; break; case 'o': case 'O': UpdateEmit (); mode = MODE_OBJ; break; case 'x': case 'X': if ( ++iClrMode > 2) iClrMode = 0; psys.SetParam ( CLR_MODE, iClrMode ); break; case 'l': case 'L': mode = MODE_LIGHTPOS; break; case 'd': case 'D': { int d = psys.GetParam ( PNT_DRAWMODE ) + 1; if ( d > 2 ) d = 0; psys.SetParam ( PNT_DRAWMODE, d ); } break; case 's': case 'S': if ( ++iShade > 2 ) iShade = 0; break; case 27: exit( 0 ); break; case '`': bRec = !bRec; break; case ' ': //psys.Run (); ptris.Rebuild (); break; bPause = !bPause; break; case '\'': case ';': psys.SPH_CreateExample ( psys_demo, psys_nmax ); break; case 'r': case 'R': psys.SPH_CreateExample ( psys_demo, psys_nmax ); break; case '[': psys_demo--; if (psys_demo < 0 ) psys_demo = 10; psys.SPH_CreateExample ( psys_demo, psys_nmax ); UpdateEmit (); break; case ']': psys_demo++; if (psys_demo > 10 ) psys_demo = 0; psys.SPH_CreateExample ( psys_demo, psys_nmax ); UpdateEmit (); break; default: break; } }