void TriangleMan::Update( float time ) { mPrevTime = mCurTime; mBallPrevTime = mBallCurTime; //Their idling, update the time. if( mState == 0 ) { mCurTime += (time*mSpinType); mBallCurTime += (time*mSpinType); } UpdateNormals(); switch(mCurRegion) { //green case 0: { //Translate( ); mPathColor.z = mPathColor.x = 0.0f; mPathColor.y = 1.0f; break; } //red case 1: { //Do animation, mark attacking DrawRings(); mPathColor.y = mPathColor.z = 0.0f; mPathColor.x = 1.0f; break; } //blue case 2: { DrawRings( ); mPathColor.y = mPathColor.x = 0.0f; mPathColor.z = 1.0f; break; } } }
LRESULT CALLBACK RingsWndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { HDC hdc; PAINTSTRUCT ps; HCURSOR hCursor; switch( msg ) { // case WM_CREATE: // return NULL; case WM_CHAR: HandleChar( hwnd, wParam ); return 0; case WM_PAINT: hCursor = SetCursor( LoadCursor( NULL, MAKEINTRESOURCE(IDC_WAIT) ) ); ShowCursor( TRUE ); //ClearDebug(); //dprintf( "Drawing rings" ); hdc = BeginPaint( hwnd, &ps ); SetDCMapMode( hdc, wMappingMode ); SetTextCharacterExtra( hdc, nCharExtra ); SetTextJustification( hdc, nBreakExtra, nBreakCount ); DrawDCAxis( hwnd, hdc ); DrawRings( hwnd, hdc ); CleanUpDC( hdc ); SelectObject( hdc, GetStockObject( BLACK_PEN ) ); EndPaint( hwnd, &ps ); //dprintf( " Finished drawing rings" ); ShowCursor( FALSE ); SetCursor( hCursor ); return 0; case WM_DESTROY: return 0; } return DefWindowProc( hwnd, msg, wParam, lParam ); }
void Animate(void) { // limpa a janela glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Reset the matrix glMatrixMode(GL_MODELVIEW); glLoadIdentity(); if (!arcCam){ //MOVIMENTO E ROTAÇÃO DA CAMARA COM TECLADO E RATO // Move the camera to our location in space glRotatef(cam->getXRot(), 1.0f, 0.0f, 0.0f); // Rotate our camera on the x-axis (looking up and down) glRotatef(cam->getYRot(), 0.0f, 1.0f, 0.0f); // Rotate our camera on the y-axis (looking left and right) // Translate the ModelView matrix to the position of our camera - everything should now be drawn relative // to this position! glTranslatef(-cam->getXPos(), -cam->getYPos(), -cam->getZPos()); } else{ //Camara orbital arcCamX = arcCamRadius * sin(arcCamAngle); arcCamZ = arcCamRadius * cos(arcCamAngle); gluLookAt(arcCamX, 30, arcCamZ, 0, 0, 0, 0, 1, 0); arcCamAngle += 0.01; if (arcCamAngle > 2 * PI){ arcCamAngle = 0; } } if (spinMode) { //Controla a velocidade da simulação if (holdingMoreSimulationSpeed && simulationSpeed > 15){ simulationSpeed -= simulationSpeedChangeAcceleration; simulationSpeedChangeAcceleration += 0.1; } if (holdingLessSimulationSpeed){ simulationSpeed += simulationSpeedChangeAcceleration; simulationSpeedChangeAcceleration += 0.1; if (simulationSpeed > 5000){ spinMode = false; simulationSpeed = 5000; } } //Atualiza a posição dos planetas e luas UpdatePlanetas(); UpdateLuas(); } applyLights(); glViewport(0, 0, width, height); ResizeWindow(width, height); glEnable(GL_TEXTURE_2D); //Desenha os planetas e luas DrawPlanetas(false); DrawLuas(); //Desenhar displayLists de estrelas glCallList(displayListIndex); glPushMatrix(); //Mover oara posição da camara if (!arcCam){ glTranslatef(cam->getXPos(), 0, cam->getZPos()); } else{ glTranslatef(arcCamX, arcCamY, arcCamZ); } //Desenhar a skybox na posição da camara - a skybox acompanha o movimento da camara DrawSkybox(); glPopMatrix(); //Desenhar anéis de saturno DrawRings(); //Desenhar minimap DrawMinimap(); glfwSwapBuffers(); // Swap the buffers to display the scene (so we don't have to watch it being drawn!) }