예제 #1
0
        public void Init()
        {
            BrushSize = 16;                                             // brush size
            this.prevMousePosition = new MyVector2();                   // prev mouse pos
            this.mouseDownPosition = new MyVector2();                   // mouse down pos
            this.currMousePosition = new MyVector2();                   // curr mouse pos

            // initialize textures, airbrushes, and parameters
            this.LoadTextures();                                                                // load canvas, brush textures


            // 3d entities
            //this.eyePos = new MyVector3(0, 0.1, 1);				// eye (camera) position
            this.eyePos        = new MyVector3(0, 0, -0.5);                     // eye (camera) position
            this.lightPosition = new MyVector3(5, 5, 5);                        // light position


            // util
            Utils.InitialRandomColors(53);                                              // initial random colors

            // opengl
            GLBasicDraw.InitGlMaterialLights();


            // mode
            //this.currentMode = EnumOperationMode.Adjusting;
            this.currentMode = EnumOperationMode.Viewing;

            // opengl projector
            this.glProjector = new OpenGLProjector();
        }
        public void ObtainGLProjector()
        {
            if (!this.camera.Calibrated)
            {
                return;
            }

            // -------------------------------------------------------------------------
            // draw 3d sense
            int w = this.Canvas.Width, h = this.Canvas.Height;

            GL.Viewport(0, this.view.Height - h, w, h);
            GL.PushMatrix();
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.LoadMatrix(this.camera.glprojMatrix);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.LoadMatrix(this.camera.glmodelViewMatrix);

            MyMatrix4d m = this.arcBall.GetMatrix() * this.modelTransformation;

            m = MyMatrix4d.TranslationMatrix(this.currTransCenter) * m * MyMatrix4d.TranslationMatrix(
                new MyVector3() - this.currTransCenter);
            GL.PushMatrix();
            GL.MultMatrix((m.Transpose()).ToArray());
            this.glProjector = new OpenGLProjector();
            GL.PopMatrix();
            GL.PopMatrix();
        }