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, -80.0f); CubeMesh myCube = new CubeMesh(); myCube.position = new Vector3(Gaussian.Generate(0, 15), rng.GenerateInt(), 0); myCubes.Add(myCube); foreach (var Cube in myCubes) { Cube.Draw(gl, rng.GenerateDouble(), rng.GenerateDouble(), rng.GenerateDouble(), size.GenerateDouble()); } cntr++; if (cntr > 100) { cntr = 0; myCubes.Clear(); } //myCube.position += new Vector3(0, .1f, 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, -100.0f); CubeMesh myCube = new CubeMesh(); myCube.Position = new Vector3(Gaussian.Generate(0, 15), r.Next(-20, 20), 0); myCubes.Add(myCube); foreach (var cube in myCubes) { cube.Draw(gl); } }
private void bounce(CubeMesh cube) { cube.ApplyForce(wind); cube.ApplyForce(gravity); if (cube.Position.y <= boxB) { cube.Velocity.y -= cube.Velocity.y * 2; } if (cube.Position.y >= boxT) { cube.Velocity.y -= cube.Velocity.y * 2; } if (cube.Position.x >= boxR) { cube.Velocity.x -= cube.Velocity.x * 2; } if (cube.Position.x <= boxL) { cube.Velocity.x -= cube.Velocity.x * 2; } }
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, -100.0f); CubeMesh myCube = new CubeMesh(); myCube.Position = new Vector3(Gaussian.Generate(0, 15), Y.GenerateDouble(), 0); myCubes.Add(myCube); foreach (var cube in myCubes) { gl.Color(colorRand.GenerateDouble(), colorRand.GenerateDouble(), colorRand.GenerateDouble()); cube.Draw(gl); } //switch (rng.Generate()) //{ // case Right: // myCube.Position += new Vector3(0.1f, 0.0f, 0.0f); // break; // case left: // myCube.Position += new Vector3(-0.1f, 0.0f, 0.0f); // break; // case Up: // myCube.Position += new Vector3(0.0f, 0.1f, 0.0f); // break; // case Down: // myCube.Position += new Vector3(0.0f, -0.1f, 0.0f); // break; // case UpRi: // myCube.Position += new Vector3(0.1f, 0.1f, 0.0f); // break; // case UpLe: // myCube.Position += new Vector3(0.1f, -0.1f, 0.0f); // break; // case DnLe: // myCube.Position += new Vector3(-0.1f, -0.1f, 0.0f); // break; // case DnRi: // myCube.Position += new Vector3(-0.1f, 0.1f, 0.0f); // break; //} //myCube.Draw(gl); //myCube.Position += new Vector3(0, 0.1f, 0); //gl.Translate(0.0f, 0.0f, -40.0f); ////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); }