public MouseEventArgs(Camera camera, Vector2 mouseViewportCoordinates, Vector3 mouseWorldCoordinates, 
            System.Windows.Forms.MouseButtons button)
        {
            // Project the mouse coordinates into world-space at the far z-plane
            var distantWorldPoint = Maths.Project(camera.ViewMatrix, camera.ProjectionMatrix,
                new Vector3(mouseViewportCoordinates.X, mouseViewportCoordinates.Y, 1f),
                (Rectangle)camera.Viewport).Xyz;

            // Produce a ray originating at the camera and pointing towards the distant world point^
            this.ScreenCoordinates = mouseViewportCoordinates;
            this.MouseRay = new Ray(camera.Position, distantWorldPoint);
            this.MouseRayFarPoint = (distantWorldPoint - camera.Position).Length;
            this.Button = button;
            this.WorldCoordinates = mouseWorldCoordinates;
        }
示例#2
0
 public CameraEventArgs(Camera camera)
 {
     this.Camera = camera;
 }
示例#3
0
        private void Initialization(object sender, EventArgs e)
        {
            Console.WriteLine(GL.GetString(StringName.Version));
            DebugDrawer.debugProgram = system_program;

            this.camera = new Camera();
            this.timer = new Stopwatch();
            this.grid = new CoordinateGrid();
            this.mousePole = new MousePole2D(camera);
            OpenGL.ReportError();

            this.BackColor = Colours.ClearColour;
            ActiveCamera = camera;

            this.camera.ViewProjectionMatrixChanged += viewport_ProjectionChanged;
            this.camera.ViewMatrixChanged += camera_ViewMatrixChanged;
            this.camera.CameraUpdated += mousePole.OnCameraUpdate;

            this.glControl1.MouseMove += camera.OnMouseMove;
            this.glControl1.MouseDown += camera.OnMouseDown;
            this.glControl1.MouseUp += camera.OnMouseUp;
            this.glControl1.MouseCaptureChanged += camera.OnMouseCaptureChanged;

            InitializeOpenGL();

            this.manager = new MeshManager(program, system_program);

            timer.Start();
            //  firing this method is meant to load the view-projection matrix values into 
            //  the shader uniforms, and initalizes the camera
            glControl1_Resize(this, new EventArgs());
        }