private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); mover.Draw(gl); if (reached == false) { mover.Velocity += acceleration; mover.Velocity.Clamp(3.0f); } if (mover.Position.x > 25.0f) { mover.Velocity.x = -1.0f; reached = true; } if (reached == true) { mover.Velocity += acceleration; mover.Velocity.Clamp(0.0f); } gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Move Left And Into The Screen gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); lightCube.Draw(gl, 1, 0, 0); lightCube.ApplyForce(wind); lightCube.ApplyForce(gravity); mediumCube.Draw(gl, 0, 1, 0); mediumCube.ApplyForce(wind); mediumCube.ApplyForce(gravity); heavyCube.Draw(gl, 0, 0, 1); heavyCube.ApplyForce(wind); heavyCube.ApplyForce(gravity); if (heavyCube.Position.x >= rightBorder) { heavyCube.Velocity.x *= -1; } if (mediumCube.Position.x >= rightBorder) { mediumCube.Velocity.x *= -1; } if (lightCube.Position.x >= rightBorder) { lightCube.Velocity.x *= -1; } if (heavyCube.Position.y <= bottomBorder) { heavyCube.Velocity.y *= -1; } if (mediumCube.Position.y <= bottomBorder) { mediumCube.Velocity.y *= -1; } if (lightCube.Position.y <= bottomBorder) { lightCube.Velocity.y *= -1; } }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); lightCube.Draw(gl); lightCube.ApplyForce(wind); lightCube.ApplyForce(gravity); if (lightCube.Position.x >= 27) { lightCube.Velocity.x = -1; } if (lightCube.Position.y <= -15) { lightCube.Velocity.y = 1; } mediumCube.Draw(gl); mediumCube.ApplyForce(wind); mediumCube.ApplyForce(gravity); if (mediumCube.Position.x >= 27) { mediumCube.Velocity.x = -1; } if (mediumCube.Position.y <= -15) { mediumCube.Velocity.y = 1; } heavyCube.Draw(gl); heavyCube.ApplyForce(wind); heavyCube.ApplyForce(gravity); if (heavyCube.Position.x >= 27) { heavyCube.Velocity.x = -1; } if (heavyCube.Position.y <= -15) { heavyCube.Velocity.y = 1; } }
//private List<CubeMesh> myCubes = new List<CubeMesh>(); private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; this.Title = "Light Saber"; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -50.0f); mover.Draw(gl); mover.Velocity += acceleration; mover.Velocity.Clamp(2.0f); if (mover.Position.x >= 25.0f) { mover.Velocity = acceleration; mover.Velocity = Stop; } gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); mousePos.Normalize(); mousePos *= 10; //myVector = a - b; //gl.Color(0.0f, 0.0f, 1.0f); //gl.LineWidth(10); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(a.x, a.y); //gl.Vertex(b.x, b.y); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.LineWidth(5); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(a.x, a.y); //gl.Vertex(b.x, b.y); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.LineWidth(5); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(5, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.LineWidth(5); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(6, 5, 4); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.LineWidth(5); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //if (Keyboard.IsKeyDown(Key.W)) //{ // b.x += 1; //} //if (Keyboard.IsKeyDown(Key.A)) //{ // b.x += -1; //} //if (Keyboard.IsKeyDown(Key.S)) //{ // b.y += 1; //} //if (Keyboard.IsKeyDown(Key.D)) //{ // b.y += -1; //} //gl.DrawText(0, 1, 0, 1, 1, "Arial", 15, "myVector magnitude is:" + myVector.GetMagnitude()); //myCube.Draw(gl); //myCube.Position += velocity * speed; //if (myCube.Position.x >= 30.0f) //{ // velocity.x = -1; //} //if (myCube.Position.x <= -30.0f) //{ // velocity.x = 1; //} //if (myCube.Position.y >= 20.0f) //{ // velocity.y = -1; //} //if (myCube.Position.y <= -20.0f) //{ // velocity.y = 1; //} //CubeMesh myCube = new CubeMesh(); //myCube.Position = new Vector3(Gaussian.Generate(0, 15), rng.GenerateInt(),0); //myCube.Add(myCube); //foreach (var cube in myCubes) //{ // gl.Color(color.GenerateDouble(), color.GenerateDouble(), color.GenerateDouble()); // cube.Draw(gl); //} //switch (rng.GenerateInt()) //{ // case 0: // myCube.Position += new Vector3(0.1f, 0, 0); // break; // case 1: // myCube.Position += new Vector3(-0.1f, 0, 0); // break; // case 2: // myCube.Position += new Vector3(0, 0.1f, 0); // break; // case 3: // myCube.Position += new Vector3(0, -0.1f, 0); // break; // case 4: // myCube.Position += new Vector3(-0.1f, 0.1f, 0); // break; // case 5: // myCube.Position += new Vector3(0.1f, -0.1f, 0); // break; // case 6: // myCube.Position += new Vector3(0.1f, 0.1f, 0); // break; // case 7: // myCube.Position += new Vector3(-0.1f, -0.1f, 0); // break; //} //myCube.Draw(gl); // myCube.Position += new Vector3(0, 1, 0); ////gl.Color(0, 1, 0); //DrawCartesianPlane(gl); //draw cartesian plane with unit lines //DrawPoint(gl, 1, 1); //draw a point with coordinates (1, 1) //DrawLinearFunction(gl); //DrawQuadraticFunction(gl); //DrawCircle(gl); }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Move Left And Into The Screen gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -50.0f); lightCube.Draw(gl); lightCube.ApplyForce(wind); lightCube.ApplyForce(gravity); medCube.Draw(gl); medCube.ApplyForce(wind); medCube.ApplyForce(gravity); heavyCube.Draw(gl); heavyCube.ApplyForce(wind); heavyCube.ApplyForce(gravity); #region LightCube //LightCube if (lightCube.Position.x >= 16.0f) { lightCube.Acceleration.x -= 1.0f; this.wind.x -= 0.005f; } else if (lightCube.Position.x <= 6.0f) { lightCube.Acceleration.x += 0.1f; lightCube.Velocity.Clamp(1.0f); } if (lightCube.Position.y >= 10.0f) { lightCube.Acceleration.y -= 1.0f; this.gravity.y -= 0.005f; } else if (lightCube.Position.y <= -5.0f) { lightCube.Acceleration.y += 0.1f; lightCube.Velocity.Clamp(0.0f); } #endregion #region MedCube //MedCube if (medCube.Position.x >= 16.0f) { medCube.Acceleration.x -= 1.0f; this.wind.x -= 0.005f; } else if (medCube.Position.x <= 6.0f) { medCube.Acceleration.x += 0.1f; medCube.Velocity.Clamp(1.0f); } if (medCube.Position.y >= 10.0f) { medCube.Acceleration.y -= 1.0f; this.gravity.y -= 0.005f; } else if (medCube.Position.y <= -5.0f) { medCube.Acceleration.y += 0.2f; medCube.Velocity.Clamp(0.0f); } #endregion #region HeavyCube //HeavyCube if (heavyCube.Position.x >= 15.0f) { heavyCube.Acceleration.x -= 1.0f; this.wind.x -= 0.005f; } else if (heavyCube.Position.x <= 6.0f) { heavyCube.Acceleration.x = 1.0f; heavyCube.Velocity.Clamp(1.0f); } if (heavyCube.Position.y >= 10.0f) { heavyCube.Acceleration.y -= 1.0f; this.gravity.y -= 0.005f; } else if (heavyCube.Position.y <= -5.0f) { heavyCube.Acceleration.y += 0.2f; heavyCube.Velocity.Clamp(0.0f); } #endregion //if (mover.Position.x <= 25.0f) //{ // mover.Velocity += acceleration; // mover.Velocity.Clamp(2.0f); //} //else if (mover.Velocity.x >= 0.0f) //{ // mover.Velocity += deceleration; // mover.Velocity.Clamp(0.0f); //} //gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); //return; //mousePos.Normalize(); //mousePos *= 10; //Line1 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); ////Line 2 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(0.0f, 1.0f, 0.0f); //gl.Vertex(50, 20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(50, 20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); ////Line 3 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Vertex(-50, -20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(-50, -20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); //myVector = a - b; // myCube.Draw(gl); //Light Cube gl.Color(1.0f, 0.0f, 0.0f); lightCube.Draw(gl); lightCube.ApplyForce(wind); lightCube.ApplyForce(gravity); //Medium Cube gl.Color(0.0f, 1.0f, 0.0f); mediumCube.Draw(gl); mediumCube.ApplyForce(wind); mediumCube.ApplyForce(gravity); //Heavy Cube gl.Color(0.0f, 0.0f, 1.0f); heavyCube.Draw(gl); heavyCube.ApplyForce(wind); heavyCube.ApplyForce(gravity); //Right Border if (lightCube.Position.x >= 20.0f) { lightCube.Velocity.x -= 0.25f; lightCube.Velocity.x *= .25f; } //Bottom Border if (lightCube.Position.y <= -10.0f) { lightCube.Velocity.y *= -0.50f; lightCube.Velocity.y -= -0.50f; } if (mediumCube.Position.x >= 20.0f) { mediumCube.Velocity.x -= 0.25f; mediumCube.Velocity.x *= .25f; } //Bottom Border if (mediumCube.Position.y <= -10.0f) { mediumCube.Velocity.y *= -0.50f; mediumCube.Velocity.y -= -0.50f; } if (heavyCube.Position.x >= 20.0f) { heavyCube.Velocity.x -= 0.25f; heavyCube.Velocity.x *= .25f; } //Bottom Border if (heavyCube.Position.y <= -10.0f) { heavyCube.Velocity.y *= -0.50f; heavyCube.Velocity.y -= -0.50f; } ////Right Border //if (mediumCube.Position.x >= 20.0f) //{ // mediumCube.Velocity.x -= 0.25f; // mediumCube.Velocity.x *= .25f; //} ////Bottom Border //if (mediumCube.Position.y <= -10.0f) //{ // mediumCube.Velocity.y *= -0.50f; // mediumCube.Velocity.y -= -0.50f; //} ////Right Border //if (heavyCube.Position.x >= 20.0f) //{ // heavyCube.Velocity.x -= 0.25f; // heavyCube.Velocity.x *= .25f; //} ////Bottom Border //if (heavyCube.Position.y <= -10.0f) //{ // heavyCube.Velocity.y *= -0.50f; // heavyCube.Velocity.y -= -0.50f; //} gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, myCube.Velocity.x + " "); #region velocityregion /* * CubeMesh myCube = new CubeMesh(); * myCube.Position = new Vector3(Gaussian.Generate(0, 15), rng.GenerateInt(), 0); * myCubes.Add(myCube); * myCube.Draw(gl); * Seatwork * myCube.Position += velocity * speed; * right * if (myCube.Position.x >= 20) * { * velocity.x = -1; * velocity.y = 1; * } * left * if (myCube.Position.x <= -15) * { * velocity.x = 1; * velocity.y = -1; * } * up * if (myCube.Position.y >= 10) * { * velocity.x = 1; * velocity.y = -1; * } * * if (myCube.Position.y <= -15) * { * velocity.y = -1; * velocity.y = 1; * } * * gl.Color(1.0f, 0.0f, 0.0f); * gl.LineWidth(20); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(b.x, b.y); * gl.Vertex(a.x, a.y); * gl.End(); * * gl.Color(1.0f, 1.0f, 1.0f); * gl.LineWidth(3); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(b.x, b.y); * gl.Vertex(a.x, a.y); * gl.End(); */ #endregion //This will make the line into 1 #region lightsaber following mouse /* gl.Color(1.0f, 0.0f, 0.0f); * mousePos.Normalize(); * mousePos *= 10; * gl.LineWidth(20); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(0, 0, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); * * gl.Color(0.0f, 0.0f, 1.0f); * gl.LineWidth(3); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(0, 0, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); * * gl.Color(0.0f, 1.0f, 0.0f); * gl.LineWidth(20); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(-10, 5, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); * * gl.Color(0.0f, 1.0f, 1.0f); * gl.LineWidth(3); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(-10, 5, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); * * gl.Color(0.0f, 1.0f, 0.0f); * gl.LineWidth(20); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(10, -5, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); * * gl.Color(1.0f, 0.0f, 1.0f); * gl.LineWidth(3); * gl.Begin(OpenGL.GL_LINE_STRIP); * gl.Vertex(10, -5, 0); * gl.Vertex(mousePos.x, mousePos.y, 0); * gl.End(); */ #endregion }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Move Left And Into The Screen gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -50.0f); mover.Draw(gl); if (mover.Position.x <= 25.0f) { mover.Velocity += acceleration; mover.Velocity.Clamp(2.0f); } else if (mover.Velocity.x >= 0.0f) { mover.Velocity += deceleration; mover.Velocity.Clamp(0.0f); } gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); return; //mousePos.Normalize(); //mousePos *= 10; //Line1 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); ////Line 2 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(0.0f, 1.0f, 0.0f); //gl.Vertex(50, 20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(50, 20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); ////Line 3 //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Vertex(-50, -20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(-50, -20, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Move Left And Into The Screen gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); mover.Draw(gl); mover.Velocity += acceleration; if (mover.Position.x >= 25.0f) { mover.Velocity += acceleration; mover.Position.x = 0; } //mover.Velocity += decelaration; //if (mover.Position.x >= 25.0f) //{ // //mover.Velocity += acceleration; // mover.Position.x = 0; //} gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + ""); //gl.Translate(0.0f, 0.0f, -100.0f); ////VECTOR A //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(b.x, b.y); ////gl.Vertex(a.x, a.y); //gl.End(); ////VECTOR B //gl.Color(0.0f, 0.0f, 1.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(5, 7, 0); //gl.End(); //if (Keyboard.IsKeyDown(Key.W)) //{ // b.x += 1; //} //if (Keyboard.IsKeyDown(Key.S)) //{ // b.x -= 1; //} //if (Keyboard.IsKeyDown(Key.D)) //{ // b.y += 1; //} //if (Keyboard.IsKeyDown(Key.A)) //{ // b.y -= 1; //} //mousePos.Normalize(); //mousePos *= 10; //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); gl.Color(1.0f, 0, 0); lightCube.Draw(gl); bounce(lightCube); gl.Color(0, 1.0f, 0); midCube.Draw(gl); bounce(midCube); gl.Color(0, 0, 1.0f); heavyCube.Draw(gl); bounce(heavyCube); gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, lightCube.Velocity.y + " "); gl.DrawText(20, 45, 0, 1, 0, "Arial", 25, lightCube.Acceleration.y + " "); gl.DrawText(20, 70, 0, 0, 1, "Arial", 25, lightCube.Position.y + " "); #region meh //feb17=========================================================================== //mover.Draw(gl); //mover.Velocity.Clamp(2.0f); //mover.Velocity.ClampMin(-2.0f); //if (cnt == 0) //{ // mover.Velocity += acceleration; //} //if (cnt == 1) //{ // mover.Velocity -= acceleration; //} //if (mover.Position.x >= 25.0f) //{ // cnt = 1; // //mover.Position.x = -25.0f; // mover.Velocity.x = -mover.Velocity.x; // acceleration.x = 0.05f; //} //if (mover.Velocity.x <= -2.0f) //{ // mover.Velocity.x = 0.0f; // acceleration.x = -0.0f; //} //gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); //feb17=========================================================================== //mousePos.Normalize(); //mousePos *= 10; //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); ////if (cnt <= 10) ////{ //// gl.Vertex(10, 0, 0); ////} ////if (cnt > 10) ////{ //// gl.Vertex(-10, 0, 0); ////} ////if (cnt == 20) //// cnt = 0; //gl.Vertex(10, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(-10, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Vertex(0, 10, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //quiz#01=========================================================== //Console.WriteLine(cnt); //CubeMesh myCube = new CubeMesh(); //myCube.Position = new Vector3(Gaussian.Generate(0, 15), yPos.GenerateInt(), 0); //myCubes.Add(myCube); //foreach (var cube in myCubes) //{ // gl.Color((float)colorOn.GenerateInt(), (float)colorOn.GenerateInt(), (float)colorOn.GenerateInt()); // cube.Draw(gl); //} ////clear on frame 100 //if (cnt == 100) //{ // cnt = 0; // myCubes.Clear(); //} //quiz#01End=========================================================== //Feb10================================================================ //Seatwork #2========================================================== //myCube.Draw(gl); //myCube.Position += velocity * speed; //if (myCube.Position.x >= 25.0f) //{ // velocity.x = -1; //} //if (myCube.Position.y >= 15.0f) //{ // velocity.y = -1; //} //if (myCube.Position.x <= -25.0f) //{ // velocity.x = 1; //} //if (myCube.Position.y <= -15.0f) //{ // velocity.y = 1; //} //SW#2 End =========================================================== //myVector = a - b; ////vector a //gl.Color(1.0f, 0.0f, 0.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(0, 0); //gl.Vertex(a.x, a.y); //gl.End(); ////vector b //gl.Color(0.0f, 1.0f, 0.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(a.x, a.y); //gl.Vertex(b.x, b.y); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(b.x, b.y); //gl.Vertex(0, 0); //gl.End(); //Seatwork #3 ========================================================= //gl.LineWidth(1.0f); //gl.Color(0.0f, 1.0f, 0.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(origin.x, origin.y); //gl.Vertex(tip.x, tip.y); //gl.End(); //gl.LineWidth(5.0f); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(origin.x, origin.y); //gl.Vertex(tip.x, tip.y); //gl.End(); //magnitude = tip - origin; //Console.WriteLine(magnitude.GetMagnitude()); //gl.DrawText(10, 10, 1.0f, 1.0f, 1.0f, "Arial", 15.0f, "Lenght: " + magnitude.GetMagnitude()); //Feb10================================================================ //myCube.Draw(gl); //myCube.Position += new Vector3(0, 1, 0); //switch(rngDirection.GenerateInt()) //{ // case UP: // myCube.Position += new Vector3(0, 0.1f, 0); // break; // case DOWN: // myCube.Position += new Vector3(0, -0.1f, 0); // break; // case LEFT: // myCube.Position += new Vector3(-0.1f, 0, 0); // break; // case RIGHT: // myCube.Position += new Vector3(0.1f, 0, 0); // break; // case UP_LEFT: // myCube.Position += new Vector3(-0.1f, 0.1f, 0); // break; // case UP_RIGHT: // myCube.Position += new Vector3(0.1f, 0.1f, 0); // break; // case DOWN_LEFT: // myCube.Position += new Vector3(-0.1f, -0.1f, 0); // break; // case DOWN_RIGHT: // myCube.Position += new Vector3(0.1f, -0.1f, 0); // break; //} ////gl.Color(0, 1, 0); //DrawCartesianPlane(gl); //draw cartesian plane with unit lines //DrawPoint(gl, 1, 1); //draw a point with coordinates (1, 1) //DrawLinearFunction(gl); //DrawQuadraticFunction(gl); //DrawCircle(gl); #endregion }
//private Vector3 deceleration = new Vector3(-0.01f, 0, 0); //private CubeMesh myCube = new CubeMesh(); //private Randomizer rng = new Randomizer(-1, 1); ////private CubeMesh myCube = new CubeMesh(); //private Vector3 velocity = new Vector3(1, 0, 0); //private float speed = 2.0f; //private Vector3 myVector = new Vector3(); //private Vector3 a = new Vector3(5, 7, 0); //private Vector3 b = new Vector3(-7, -6, 0); //private List<CubeMesh> myCubes = new List<CubeMesh>(); private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; //this.Title = "Vectors"; //myVector = a; gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -40.0f); lightCube.Draw(gl); lightCube.ApplyForce(wind); lightCube.ApplyForce(gravity); gl.Color(1.0f, 0.0f, 0.0f); middleWeightCube.Draw(gl); middleWeightCube.ApplyForce(wind); middleWeightCube.ApplyForce(gravity); gl.Color(0.0f, 0.0f, 1.0f); heavyCube.Draw(gl); heavyCube.ApplyForce(wind); heavyCube.ApplyForce(gravity); gl.Color(0.0f, 1.0f, 0.0f); //mover.Draw(gl); //mover.Velocity += acceleration; ////mover.Velocity -= deceleration; //mover.Velocity.Clamp(2.0f); if (lightCube.Position.x >= 25.0f) { lightCube.Position.y = -25; } else if (mover.Position.x >= 25.0f) { lightCube.Position.y = 0; } //gl.DrawText(20, 20, 1, 0, 0, "Arial", 25, mover.Velocity.x + " "); //OpenGL.GL_LINE_WIDTH(1.0f, 1.0f, 0); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(15, 0); //gl.Vertex(a.x, a.y); //gl.End(); //mousePos.Normalize(); //mousePos *= 10; //gl.LineWidth(30.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Color(0.0f, 1.0f, 0.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.LineWidth(3.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Color(1.0f, 1.0f, 1.0f); //gl.Vertex(0, 0, 0); //gl.Vertex(mousePos.x, mousePos.y, 0); //gl.End(); //gl.Color(1.0f, 0.0f, 0.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(0, 0); //gl.Vertex(a.x, a.y); //gl.End(); //gl.Color(0.0f, 1.0f, 0.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(0, 0); //gl.Vertex(a.x, a.y); //gl.Vertex(b.x, b.y); //gl.End(); //gl.Color(0.0f, 0.0f, 1.0f); //gl.Begin(OpenGL.GL_LINE_STRIP); //gl.Vertex(b.x, b.y); //gl.Vertex(0,0); //gl.End(); //gl.DrawText(0, 0, 1, 1, 1 "Arial", 15, "myVector magnitude"); //CubeMesh myCube = new CubeMesh(); //myCube.Position = new Vector3(Gaussian.Generate(0, 15), yAxis.GenerateDouble(), 0); //myCubes.Add(myCube); //myCube.Draw(gl); //myCube.Position += velocity * speed; //if (myCube.Position.x >= 25.0f) //{ // velocity.x = -1; //} //else if (myCube.Position.x <= -25.0f) //{ // velocity.x = 1; //} // if (myCube.Position.y >= 10.0f) // { // velocity.y = -1; // } // else if (myCube.Position.y <= -10.0f) // { // velocity.y = 1; // } //if (myCube.Position.y >= 30.0f) //{ // velocity.x = -1; //} //if (myCube.Position.y <= 30.0f) //{ // velocity.y = 1; //} //CubeMesh myCube2 = new CubeMesh(); //myCube2.Position = new Vector3(Generate(-20, 20),0); //myCubes.Add(myCube2); //foreach (var cube in myCubes) //{ //// //gl.Color(RGB.Generate(), RGB.Generate(), RGB.Generate()); // cube.Draw(gl); //} }
private void OpenGLControl_OpenGLDraw(object sender, SharpGL.SceneGraph.OpenGLEventArgs args) { OpenGL gl = args.OpenGL; // Clear The Screen And The Depth Buffer gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // Move Left And Into The Screen gl.LoadIdentity(); gl.Translate(0.0f, 0.0f, -80.0f); lightCube.Draw(gl); gl.Color(1.0f, 0.0f, 0.0f); lightCube.ApplyForce(wind); if (lightCube.Position.x >= rightWall) { lightCube.ApplyForce(gravity); } if (lightCube.Position.y >= rightWall) { lightCube.ApplyForce(wind); } //bounce up if (lightCube.Position.y <= rightWall) { lightCube.Velocity.y -= lightCube.Velocity.y * 2; } //bounce right if (lightCube.Position.x >= 15 && lightCube.Position.x >= 20) { lightCube.Velocity.x -= lightCube.Velocity.x * 2; } heavyCube.Draw(gl); gl.Color(0.0f, 1.0f, 0.0f); heavyCube.ApplyForce(wind); if (heavyCube.Position.x >= rightWall) { heavyCube.ApplyForce(gravity); } if (heavyCube.Position.y >= rightWall) { lightCube.ApplyForce(wind); } //bounce up if (heavyCube.Position.y <= rightWall) { heavyCube.Velocity.y -= heavyCube.Velocity.y * 2; } //bounce right if (heavyCube.Position.x >= 15) { heavyCube.Velocity.x -= heavyCube.Velocity.x * 2; } moderateCube.Draw(gl); gl.Color(0.0f, 0.0f, 1.0f); moderateCube.ApplyForce(wind); if (moderateCube.Position.x >= rightWall) { moderateCube.ApplyForce(gravity); } if (moderateCube.Position.y >= rightWall) { lightCube.ApplyForce(wind); } //bounce up if (moderateCube.Position.y <= rightWall) { moderateCube.Velocity.y -= moderateCube.Velocity.y * 2; } //bounce right if (moderateCube.Position.x >= 15) { moderateCube.Velocity.x -= moderateCube.Velocity.x * 2; } }