void drawPrecipitationWithRadar(){ //Make the skybox based on weather// modelview = endRender(modelview); modelview = rotate(modelview, (GLfloat) RotatedX, vec3(1,0,0)); modelview = rotate(modelview, (GLfloat) RotatedY, vec3(0,1,0)); skybox.Draw(projection, modelview, tod, 0); //Make precipitation if(weatherType > 1){ mat4 another; for(int i=0; i<numParts; i++){ another = rotate(modelview, 90.0f, vec3(1,0,0)); another = translate(another, vec3(partX[i],partY[i],3*tan(((weatherType == 2 ? 2 : 0.75) *current_timeDisplay)+partOffset[i]))); another = rotate(another, 270.0f, vec3(1,0,0)); another = rotate(another, 90.0f, vec3(0,1,0)); if(weatherType == 2){ mat4 rainScale = another;rainScale = scale(rainScale, vec3(0.35, 2, 0.35)); rain2.Draw(projection, rainScale, tod, 0); } else{snow2.Draw(projection, another, tod, 0);} } } modelview = rotate(modelview, (GLfloat) -RotatedY, vec3(0,1,0)); modelview = rotate(modelview, (GLfloat) -RotatedX, vec3(1,0,0)); drawRadar(); modelview = render(modelview); }
void drawRadar(){ //Set up orthographic projection for radar mat4 projection1 = perspective(45.0f, window.window_aspect, 0.01f, 10.0f); glm::mat4 Projection2 = glm::ortho( -10.0f, 10.0f, -10.0f, 00.0f,1.0f, 10.0f); glm::mat4 View = glm::lookAt( glm::vec3(0,0,5), // Camera is at (0,0,5), in World Space glm::vec3(0,0,0), // and looks at the origin glm::vec3(0,1,0) // Head is up (set to 0,-1,0 to look upside-down) ); mat4 another = View; mat4 healthBarMatrix = View; another = translate(another, vec3(8.5,-8.5,0)); another = rotate(another, 90.0f, vec3(0,1,0)); another = rotate(another, 90.0f, vec3(0,0,1)); healthBarMatrix = translate(healthBarMatrix, vec3(-9.5,-0.5,0)); //healthBarMatrix = rotate(healthBarMatrix, 90.0f, vec3(0,1,0)); healthBarMatrix = rotate(healthBarMatrix, -90.0f, vec3(0,0,1)); healthBarMatrix = scale(healthBarMatrix, vec3(0.05f, userTeam.soldiers[0].health/10.f, 0.05f)); if(userTeam.soldiers[0].health < 50){ healthBar.color = vec3(1.f, userTeam.soldiers[0].health/50.f, 0.f); } else{ healthBar.color = vec3(1.f - (userTeam.soldiers[0].health-50.f)/50.f, 1.f, 0.f); } healthBar.Draw(Projection2, healthBarMatrix, tod, 0); mat4 radar = another; //Radar display int radarBlipTime = current_timeDisplay * 1000; float radarBlip = 0.0015 * (radarBlipTime%1000); radar = scale(radar, vec3(radarBlip, radarBlip, radarBlip)); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); disc.color = vec3(0,1,0); disc.Draw(Projection2, radar, tod, 0); another = scale(another, vec3(1.5, 1.5, 1.5)); disc.Draw(Projection2, another, tod, 0); glPolygonMode(GL_FRONT_AND_BACK, window.wireframe ? GL_LINE : GL_FILL); disc.color = vec3(0,0.25,0); disc.Draw(Projection2, another, tod, 0); another = translate(View, vec3(8.5 - ((3/104.6)*transX),-8.6 + ((3/104.6)*transZ),0)); usr.Draw(Projection2, another, tod, 0); stringstream ammo (stringstream::in | stringstream::out); ammo << userTeam.soldiers[0].ammo; activeTextDisplay(("Ammo: " + ammo.str()).c_str(), -0.95f, -0.85f, 16); }
void drawSoundSphere(Sphere& s){ if (Calc_Hit(s, Hand)){ PlaySound(s.sound_src, NULL, SND_ASYNC); s.flag = false; } glLoadIdentity(); //視点の設定 gluLookAt(0.0, 0.0, -500.0, //カメラの座標 0.0, 0.0, 0.0, // 注視点の座標 0.0, 1.0, 0.0); // 画面の上方向を指すベクトル s.Draw(); }
void display(void) { kinect.run(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, WIDTH, HEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //視野角,アスペクト比(ウィンドウの幅/高さ),描画する範囲(最も近い距離,最も遠い距離) gluPerspective(30.0, (double)WIDTH / (double)HEIGHT, 1.0, 2000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //視点の設定 gluLookAt(0.0, 0.0, -500.0, //カメラの座標 0.0, 0.0, 0.0, // 注視点の座標 0.0, 1.0, 0.0); // 画面の上方向を指すベクトル //ライトの設定 glLightfv(GL_LIGHT0, GL_POSITION, lightpos); //Hand.Pos.x = 500 - kinect.kinectX[NUI_SKELETON_POSITION_HAND_LEFT]; Hand.Pos.y = 130.0 - float(kinect.kinectY[NUI_SKELETON_POSITION_HAND_LEFT]) * (260.0/480.0); std::cout << Hand.Pos.y << std::endl; Hand.Draw(); drawSoundSphere(Do); drawSoundSphere(Do1); drawSoundSphere(So); drawSoundSphere(So1); drawSoundSphere(La); drawSoundSphere(La1); drawSoundSphere(So2); glutSwapBuffers(); }