private static void ClickKeyboardKeys(byte key, int x, int y) { var matrix = new float[0, 0]; switch (key) { case 113: matrix = Matrices.GetRotationMatrix(0.1f); break; case 101: matrix = Matrices.GetRotationMatrix(-0.1f); break; case 119: matrix = Matrices.GetTranslationMatrix(0.0f, 1.0f); break; case 115: matrix = Matrices.GetTranslationMatrix(0.0f, -1.0f); break; case 100: matrix = Matrices.GetTranslationMatrix(1.0f, 0.0f); break; case 97: matrix = Matrices.GetTranslationMatrix(-1.0f, 0.0f); break; case 114: matrix = Matrices.GetMirrorReflectionMatrix(); break; default: return; } Calculator.CalculatePoints(Points, matrix); Glut.glutPostRedisplay(); }
private static void Idle() { if (!frozen) { spinY += 0.5f; if (spinY > 360) { spinY -= 360; } spinX += 10; if (spinX > 360) { spinX -= 360; } spinZ += 1; if (spinZ > 360) { spinZ -= 360; } } Glut.glutPostRedisplay(); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case (byte)'a': case (byte)'A': solidZ = MAXZ; transparentZ = MINZ; Glut.glutIdleFunc(new Glut.IdleCallback(Idle)); break; case (byte)'r': case (byte)'R': solidZ = MAXZ; transparentZ = MINZ; Glut.glutPostRedisplay(); break; case (byte)27: Environment.Exit(0); break; default: break; } }
static void Timer(int value) { if (!colisao) { iceZ += 0.1f; pontuacao += 1; if ((((iceX + 0.1f) > (b - 0.25f)) && ((iceX + 0.1f) < (b + 0.25f))) && (iceZ >= 2.5f)) { colisao = true; Console.WriteLine("\nJogador: " + jogador); Console.WriteLine("Pontuação: " + pontuacao); Console.WriteLine("\nPressione F1 para jogar novamente..."); } if (iceZ >= 3.4f) { iceZ = 0.0f; iceX = NextFloat(random); if (clock > 10) { clock -= 10; } } Glut.glutPostRedisplay(); Glut.glutTimerFunc(clock, Timer, 1); } }
private static void Motion(int x, int y) { y = Glut.glutGet(Glut.GLUT_WINDOW_HEIGHT) - y; rasterX = x - oldRasterX; rasterY = y - oldRasterY; Glut.glutPostRedisplay(); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: Environment.Exit(0); break; case (byte)'d': day = (day + 10) % 360; Glut.glutPostRedisplay(); break; case (byte)'D': day = (day - 10) % 360; Glut.glutPostRedisplay(); break; case (byte)'y': year = (year + 5) % 360; Glut.glutPostRedisplay(); break; case (byte)'Y': year = (year - 5) % 360; Glut.glutPostRedisplay(); break; default: break; } }
/// <summary> /// Called on a mouse event. /// </summary> private static void Mouse(int button, int state, int x, int y) { if (button == Glut.GLUT_LEFT_BUTTON) { // rotate if (state == Glut.GLUT_DOWN) { increment -= STEP; } else { increment += STEP; } } else if (button == Glut.GLUT_RIGHT_BUTTON) { if (state == Glut.GLUT_DOWN) { increment += STEP; } else { increment -= STEP; } } else { increment = 0.0f; } Glut.glutPostRedisplay(); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: Environment.Exit(0); break; case (byte)'f': case (byte)'F': if (fogMode == Gl.GL_EXP) { fogMode = Gl.GL_EXP2; Console.WriteLine("Fog mode is GL_EXP2"); } else if (fogMode == Gl.GL_EXP2) { fogMode = Gl.GL_LINEAR; Console.WriteLine("Fog mode is GL_LINEAR"); } else if (fogMode == Gl.GL_LINEAR) { fogMode = Gl.GL_EXP; Console.WriteLine("Fog mode is GL_EXP"); } Gl.glFogi(Gl.GL_FOG_MODE, fogMode); Glut.glutPostRedisplay(); break; default: break; } }
private static void specialKey(int key, int x, int y) { switch (key) { case Glut.GLUT_KEY_LEFT: //Повернуть по оси Y Yrot -= 2.0f; break; case Glut.GLUT_KEY_RIGHT: //Повернуть по оси Y Yrot += 2.0f; break; case Glut.GLUT_KEY_UP: //Повернуть по оси X Xrot -= 2.0f; break; case Glut.GLUT_KEY_DOWN: //Повернуть по оси X Xrot += 2.0f; break; case Glut.GLUT_KEY_PAGE_UP: //Повернуть по оси Z Zrot -= 2.0f; break; case Glut.GLUT_KEY_PAGE_DOWN: //Повернуть по оси Z Zrot += 2.0f; break; default: break; } Glut.glutPostRedisplay(); }
//Tempo static void Timer(int value) { rot -= 7; Glut.glutPostRedisplay(); Glut.glutTimerFunc(1, Timer, 1); }
/// <summary> /// Called on a mouse event. /// </summary> private static void Mouse(int button, int state, int x, int y) { if (button == Glut.GLUT_LEFT_BUTTON) { // when left mouse button is down, move left if (state == Glut.GLUT_DOWN) { rotation -= delta; } else if (state == Glut.GLUT_UP) { rotation += delta; } } else if (button == Glut.GLUT_RIGHT_BUTTON) { // when right mouse button down, move right if (state == Glut.GLUT_DOWN) { rotation += delta; } else if (state == Glut.GLUT_UP) { rotation -= delta; } } else { // reset the increment rotation = 0.0f; } Glut.glutPostRedisplay(); }
} // // *********************** 4-8 ********************* static void Meniu(int a) //metodas meniu { // switch (a) //nustatomas pasirinkimas { // case '1': //pirmas meniu pasirinkimas Gl.glColor3f(127 / 256f, 255 / 256f, 0 / 256f); //figuros spalvos nustatymas Glut.glutPostRedisplay(); //ekrano perpiesimas break; //pasirinkimo nutraukimas case '2': //antras meniu pasirinkimas Gl.glColor3f(0 / 256f, 0 / 256f, 139 / 256f); //figuros spalvos nustatymas Glut.glutPostRedisplay(); //ekrano perpiesimas break; //pasirinkimo nutraukimas case '3': //trecias meniu pasirinkimas Gl.glClearColor(1.0f, 1f, 1.0f, 1f); //fono spalvos nustatymas Glut.glutPostRedisplay(); //ekrano perpiesimas break; //pasirinkimo nutraukimas case '4': //ketvirtas meniu pasirinkimas Gl.glClearColor(0f, 0f, 0f, 1f); //fono spalvos nustatymas Glut.glutPostRedisplay(); //ekrano perpiesimas break; //pasirinkimo nutraukimas case '5': //penktas meniu pasirinkimas Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE); //piesiama neuzspalvinta figura Glut.glutPostRedisplay(); //ekrano perpiesimas break; //pasirinkimo nutraukimas case '6': //sestas meniu pasirinkimas Environment.Exit(0); // uždaromas programos langas break; //pasirinkimo nutraukimas } // } //
static void idle() { // static float lightVelocity = 0.008; // static float timeFlow = 0.01; /* Repeat rotating light around front 180 degrees. */ if (myLightAngle > Math.PI / 2) { myLightAngle = (float)Math.PI / 2; lightVelocity = -lightVelocity; } else if (myLightAngle < -Math.PI / 2) { myLightAngle = (float)-Math.PI / 2; lightVelocity = -lightVelocity; } myLightAngle += lightVelocity; /* Add a small angle (in radians). */ /* Repeatedly advance and rewind time. */ if (myTime > 10) { myTime = 10; timeFlow = -timeFlow; } else if (myTime < 0) { myTime = 0; timeFlow = -timeFlow; } myTime += timeFlow; /* Add time delta. */ Glut.glutPostRedisplay(); }
private static void ClickKeyboardKeys(byte key, int x, int y) { Axis axis; float fi; switch (key) { case 119: axis = Axis.X; fi = 0.1f; break; case 115: axis = Axis.X; fi = -0.1f; break; case 100: axis = Axis.Y; fi = 0.1f; break; case 97: axis = Axis.Y; fi = -0.1f; break; case 113: axis = Axis.Z; fi = 0.1f; break; case 101: axis = Axis.Z; fi = -0.1f; break; default: return; } cube.CalculateRotation(axis, fi); Glut.glutPostRedisplay(); }
static void Klaviatura(int ch, int x, int y) { switch (ch) { case Glut.GLUT_KEY_RIGHT: lightX += 0.05f; break; case Glut.GLUT_KEY_LEFT: lightX -= 0.05f; break; case Glut.GLUT_KEY_UP: lightY += 0.05f; break; case Glut.GLUT_KEY_DOWN: lightY -= 0.05f; break; case Glut.GLUT_KEY_PAGE_UP: lightZ += 0.05f; break; case Glut.GLUT_KEY_PAGE_DOWN: lightZ -= 0.05f; break; } Glut.glutPostRedisplay(); }
static void moverAsteroid(int value)//move o asteroid em time { // Muda a direção quando chega na borda esquerda ou direita if (ax > 0.5f || ax < -1.5f) { xstep = -xstep; } // Muda a direção quando chega na borda superior ou inferior if (ay <= -1.5f) { ay = 0.7f; } // Move o quadrado ax += xstep; ay -= ystep; cy -= 0.001f; if (cy <= -1.0f) { cy = 0.7f; } // Redesenha o quadrado com as novas coordenadas Glut.glutPostRedisplay(); Glut.glutTimerFunc(1, moverAsteroid, 1); rot -= 1;// Velocidade do giro do asteroid // Redesenha o quadrado com as novas coordenadas //Glut.glutPostRedisplay(); //Glut.glutTimerFunc(10, moverAsteroid, 1); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: Environment.Exit(0); break; case (byte)'w': case (byte)'W': if (currentWinding == Glu.GLU_TESS_WINDING_ODD) { currentWinding = Glu.GLU_TESS_WINDING_NONZERO; } else if (currentWinding == Glu.GLU_TESS_WINDING_NONZERO) { currentWinding = Glu.GLU_TESS_WINDING_POSITIVE; } else if (currentWinding == Glu.GLU_TESS_WINDING_POSITIVE) { currentWinding = Glu.GLU_TESS_WINDING_NEGATIVE; } else if (currentWinding == Glu.GLU_TESS_WINDING_NEGATIVE) { currentWinding = Glu.GLU_TESS_WINDING_ABS_GEQ_TWO; } else if (currentWinding == Glu.GLU_TESS_WINDING_ABS_GEQ_TWO) { currentWinding = Glu.GLU_TESS_WINDING_ODD; } MakeNewLists(); Glut.glutPostRedisplay(); break; } }
static void TeclasBola(int key, int x, int y) //Controle da bola principal { if (_fim) { return; } switch (key) { case Glut.GLUT_KEY_LEFT: if (_bolaX >= -6.5f) { _bolaX -= 0.5f; } break; case Glut.GLUT_KEY_RIGHT: if (_bolaX <= 6.5f) { _bolaX += 0.5f; } break; } Glut.glutPostRedisplay(); }
public override void VisualizeAlg(GenericGridWorldStaticState StaticState, GenericGridWorldDynamicState DynamicState, object AlgData) { lock (this) { PriorityQueue <Metric, GenericGridWorldDynamicState> OL = null; if (this.vd != null) { OL = vd.OL; } this.vd = (OpenGLStateVisualizer.OpenGlVisulizationData)AlgData; if (this.vd != null && this.vd.OL == null) { vd.OL = OL; } } while (!nextAction && !nextPlanning) { if (continuous && fast_continuous) { break; } Glut.glutPostRedisplay( ); Glut.glutMainLoopEvent( ); if (continuous) { break; } } nextPlanning = false; }
static void Timer(int value) { rot += 10f; // Redesenha o quadrado com as novas coordenadas Glut.glutPostRedisplay(); Glut.glutTimerFunc(100, Timer, 1); }
GenericGridWorldDynamicState> > Compute( GenericGridWorldStaticState StaticState, GenericGridWorldDynamicState DynamicState, Goal <GenericGridWorldStaticState, GenericGridWorldDynamicState> Goal, Operator <GenericGridWorldStaticState, GenericGridWorldDynamicState>[] Actions) { while (true) { while (Operators.Count == 0) { Thread.Sleep(100); if (this.sv != null) { sv.VisualizeAlg(StaticState, StaticState.InitialDynamicState, new OpenGLStateVisualizer.OpenGlVisulizationData( )); Glut.glutPostRedisplay( ); Glut.glutMainLoopEvent( ); Gl.glFinish( ); } } var op = Operators.Dequeue( ); System.Console.WriteLine("Got Op --> {0}", op); if (op.IsValidOn(StaticState.InitialDynamicState, StaticState, false)) { System.Console.WriteLine("Trying Op --> {0}", op); yield return(GridWorldOperator.MakePath(op)); } } }
static void moverGoleiroAlemanha(byte key, int x, int y) { if (key == 115 || key == 83) { if (gaPosy < -0.30f) { gaPosy += 0.0f; } else { gaPosy -= 0.03f; } } if (key == 119 || key == 87) { if (gaPosy > 0.30f) { gaPosy += 0.0f; } else { gaPosy += 0.03f; } } Glut.glutPostRedisplay(); }
static void TeclasEspeciais(int key, int x, int y) { switch (key) { case Glut.GLUT_KEY_LEFT: if (b > -1.1f) { b -= 0.1f; } break; case Glut.GLUT_KEY_RIGHT: if (b < 1.1f) { b += 0.1f; } break; case Glut.GLUT_KEY_F1: colisao = false; pontuacao = 0; iceZ = 0.0f; iceX = NextFloat(random); clock = 150; Glut.glutTimerFunc(clock, Timer, 1); break; } Glut.glutPostRedisplay(); }
//функция проверки значения координат с клика мыши public bool checkMouse(int mx, int my) { for (i = 0; i < 11; i++) // Цикл слева направо { for (j = 0; j < 11; j++) // Цикл сверху вниз { if (i < 10 && j < 10) { cells[i, j].lbx = 20 + (i * 60); cells[i, j].lby = 50 + (j * 45); } //ПРОВЕРКА НА ПОПАДАНИЕ КЛИКА КУРСОРА В ПОДХОДЯЩУЮ КЛЕТКУ if (/*mx>20 && my>50 && mx<620 && my<500*/ mx > cells[i, j].lbx && mx <cells[i, j].lbx + 60 && my> cells[i, j].lby && my < cells[i, j].lby + 45 && cells[i, j].locker != true && checkneighbors(i, j, count) == true) { if ((count) == 1) //нечетное { cells[i, j].condition = 1; //первое состояние (цвет) клетки fillneighbors(i, j); //закрашиваем вражеские соседние клетки } else { if ((count) == 2) { cells[i, j].condition = 2; // второе состояние (цвет) клетки fillneighbors(i, j); } } Glut.glutPostRedisplay(); return(true); } } } return(false); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case (byte)' ': spinC = 0; toggle = !toggle; if (toggle) { Glut.glutIdleFunc(null); } else { Glut.glutIdleFunc(new Glut.IdleCallback(Idle)); } break; case 27: Environment.Exit(0); break; default: break; } Glut.glutPostRedisplay(); }
private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: Environment.Exit(0); break; case (byte)'s': Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP); Glut.glutPostRedisplay(); break; case (byte)'S': Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT); Glut.glutPostRedisplay(); break; case (byte)'t': Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP); Glut.glutPostRedisplay(); break; case (byte)'T': Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT); Glut.glutPostRedisplay(); break; } }
/// <summary> /// <para> /// Rotate about x-axis when "x" typed; rotate about y-axis when "y" typed; /// "i" returns torus to original view /// </para> /// </summary> private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: Environment.Exit(0); break; case (byte)'x': case (byte)'X': Gl.glRotatef(30.0f, 1.0f, 0.0f, 0.0f); Glut.glutPostRedisplay(); break; case (byte)'y': case (byte)'Y': Gl.glRotatef(30.0f, 0.0f, 1.0f, 0.0f); Glut.glutPostRedisplay(); break; case (byte)'i': case (byte)'I': Gl.glLoadIdentity(); Glu.gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0); Glut.glutPostRedisplay(); break; } }
/// <summary> /// <para> /// Sets up selection mode, name stack, and projection matrix for picking. Then /// the objects are drawn. /// </para> /// </summary> private static void Mouse(int button, int state, int x, int y) { int[] selectBuffer = new int[BUFSIZE]; int hits; int[] viewport = new int[4]; if (button != Glut.GLUT_LEFT_BUTTON || state != Glut.GLUT_DOWN) { return; } Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport); Gl.glSelectBuffer(BUFSIZE, selectBuffer); Gl.glRenderMode(Gl.GL_SELECT); Gl.glInitNames(); Gl.glPushName(0); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPushMatrix(); Gl.glLoadIdentity(); // create 5x5 pixel picking region near cursor location Glu.gluPickMatrix((double)x, (double)(viewport[3] - y), 5.0, 5.0, viewport); Glu.gluOrtho2D(0.0, 3.0, 0.0, 3.0); DrawSquares(Gl.GL_SELECT); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPopMatrix(); Gl.glFlush(); hits = Gl.glRenderMode(Gl.GL_RENDER); ProcessHits(hits, selectBuffer); Glut.glutPostRedisplay(); }
/// <summary> /// Called on a key event. /// </summary> private static void Keyboard(byte key, int x, int y) { switch (key) { case 27: case (byte)'Q': case (byte)'q': Environment.Exit(0); break; case (byte)'+': case (byte)'=': alpha -= 0.02f; if (alpha < 0.05f) { alpha = 0.05f; } break; case (byte)'-': alpha += 0.02f; if (alpha > 1.0f) { alpha = 1.0f; } break; } Glut.glutPostRedisplay(); }
public void Timer(int value) { // Muda a direção quando chega na borda esquerda ou direita if (tz < -30.7) { tz = 13; } // Muda a direção quando chega na borda superior ou inferior if (ty > 3.7 || ty < 0) { movementVelocityY = -movementVelocityY; } // Move o quadrado tz += movementVelocityZ; ty += movementVelocityY; tx += movementVelocityX; //Console.WriteLine("TZ: " + tz + " TY: " + ty + " TX: " + tx); // Redesenha o quadrado com as novas coordenadas Glut.glutPostRedisplay(); Glut.glutTimerFunc(1, Timer, 1); }