コード例 #1
0
        public override void sendMouse(vec2 current, vec2 oldmouse)
        {
            ArcBall ball  = new ArcBall(new vec2(Width / 2.0f, Height / 2.0f), Math.Min(Height, Width) / 2.0f);
            quat    final = ball.rotation(tranform(oldmouse), tranform(current));

            rotation = quat.Combine(rotation, final);
        }
コード例 #2
0
        //控件大小调整事件
        //改变大小时触发,在程序启动时将执行一次
        private void glControl1_Resize(object sender, EventArgs e)
        {
            if (!GLLoaded)//如果没有加载控件,则返回
            {
                return;
            }

            if (glControl1.ClientSize.Height == 0)
            {
                glControl1.ClientSize = new System.Drawing.Size(glControl1.ClientSize.Width, 1);
            }

            GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
            //设置3D绘图画布
            float aspect_ratio = Width / (float)Height;//求得控件宽高比
            //三维透视矩阵
            Matrix4 perpective = Matrix4.CreatePerspectiveFieldOfView(PerpectAngle,
                                                                      aspect_ratio, DisNear, DisFar);

            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref perpective);//加载透视矩阵
            //创建轨迹球
            _ArcBall = new ArcBall(-Eye_distance, -Eye_distance,
                                   Eye_distance, 0, 0, 0, 0, 0, 1);
            _ArcBall.SetBounds(Width, Height);//设置高宽
        }
コード例 #3
0
ファイル: HoldingObject.cs プロジェクト: jonbro/ggj16
	// Use this for initialization
	void Start () {
		drifter = GetComponent<FirstPersonDrifter>();
		mouseLook = GetComponent<MouseLook>();
		mouseLookVert = Camera.main.GetComponent<MouseLook>();
		arcBall = holdPosition.GetComponent<ArcBall>();
		currentTarget = holdPositionTarget;

	}
コード例 #4
0
        public override void Initialize()
        {
            base.Initialize();

            ball = new ArcBall();

            tmp_proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GameContainer.Graphics.GraphicsDevice.Viewport.AspectRatio, 2, 3);
            tmp_view = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up);

            msLast = Mouse.GetState();
        }
コード例 #5
0
        public override void Initialize()
        {
            base.Initialize();

            ball = new ArcBall();

            tmp_proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GameContainer.Graphics.GraphicsDevice.Viewport.AspectRatio, 2, 3);
            tmp_view = Matrix.CreateLookAt(new Vector3(0, 0, 1), Vector3.Zero, Vector3.Up);

            msLast = Mouse.GetState();
        }
コード例 #6
0
ファイル: DisplayControl.cs プロジェクト: xusongfei/LeadChina
 private void openGLControl1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         _isMouseDown = true;
         ArcBall.MouseDown(e.X, e.Y);
     }
     else if (e.Button == MouseButtons.Right)
     {
         ArcBall = new ArcBall();
     }
 }
コード例 #7
0
    void Awake()
    {
        // start coroutine that checks for screen resize
        StartCoroutine(checkForResize());

        // only one gui draw fase
        useGUILayout = false;

        // setup our lensmodel
        mLensmodel = ScriptableObject.CreateInstance <LensModel>();
        mLensmodel.init(LensModel.LENSMODEL.EQUIRECTANGULAR, Screen.width, Screen.height, 1.0f, 1.0f);

        // setup arcball
        mArcball = ScriptableObject.CreateInstance <ArcBall>();
        mArcball.init(Screen.width, Screen.height, transform.rotation);

        // setup FPS counter
        mFps = ScriptableObject.CreateInstance <FPS>();
    }
コード例 #8
0
ファイル: DisplayControl.cs プロジェクト: xusongfei/LeadChina
        private void openGLControl1_OpenGLInitialized(object sender, EventArgs e)
        {
            var gl = openGLControl1.OpenGL;

            gl.Viewport(0, 0, openGLControl1.Width, openGLControl1.Height);

            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Perspective(90, (float)openGLControl1.Width / openGLControl1.Height, 1, 1000);


            gl.LookAt(-200, 0, 50, 0, 0, 0, 0, 0, 1);


            gl.ShadeModel(OpenGL.GL_SMOOTH);
            var mat_specular  = new[] { 1.0f, 1.0f, 1.0f, 1.0f };
            var mat_ambient   = new[] { 0.2f, 0.2f, 0.2f, 0.2f };
            var mat_diffuse   = new[] { 2.0f, 2.0f, 2.0f, 0.1f };
            var mat_shininess = new[] { 100.0f };

            gl.Material(OpenGL.GL_FRONT, OpenGL.GL_SPECULAR, mat_specular);
            gl.Material(OpenGL.GL_FRONT, OpenGL.GL_AMBIENT, mat_ambient);
            gl.Material(OpenGL.GL_FRONT, OpenGL.GL_DIFFUSE, mat_diffuse);
            gl.Material(OpenGL.GL_FRONT, OpenGL.GL_SHININESS, mat_shininess);

            var ambientLight = new[] { 0.2f, 0.2f, 0.2f, 0.2f };
            var diffuseLight = new[] { 1.0f, 1.0f, 1.0f, 1.0f };
            var posLight0    = new[] { -200.0f, 200.0f, 200f, 1.0f };

            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_AMBIENT, ambientLight);
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_DIFFUSE, diffuseLight);
            gl.Light(OpenGL.GL_LIGHT0, OpenGL.GL_POSITION, posLight0);

            gl.Enable(OpenGL.GL_LIGHTING);
            gl.Enable(OpenGL.GL_LIGHT0);
            gl.Enable(OpenGL.GL_COLOR_MATERIAL);
            gl.Enable(OpenGL.GL_DEPTH_TEST);
            gl.Enable(OpenGL.GL_DOUBLEBUFFER);

            ArcBall.SetBounds(openGLControl1.Width, openGLControl1.Height);
        }
コード例 #9
0
ファイル: DisplayControl.cs プロジェクト: xusongfei/LeadChina
        private void openGLControl1_OpenGLDraw(object sender, RenderEventArgs args)
        {
            var gl = openGLControl1.OpenGL;

            gl.ClearColor(0.2f, 0.4f, 0.2f, 0.2f);
            gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT);


            gl.MatrixMode(OpenGL.GL_PROJECTION);
            gl.LoadIdentity();
            gl.Perspective(90, (float)openGLControl1.Width / openGLControl1.Height, 1, 1000);
            gl.LookAt(vx, vy, vz, 0, 0, 0, upx, upy, upz);
            ArcBall.TransformMatrix(gl);

            gl.MatrixMode(OpenGL.GL_MODELVIEW);
            gl.LoadIdentity();

            DrawAxis(gl);
            DrawPos(gl);


            gl.Finish();
            gl.Flush();
        }
コード例 #10
0
 public ArcBallEffect(Cameras.LookAtCamera camera)
 {
     arcBall = new ArcBall(camera);
 }