glGetDoublev() private method

private glGetDoublev ( uint pname, double paramsx ) : void
pname uint
paramsx double
return void
示例#1
0
        protected virtual void initRenderingGL()
        {
            if (m_DeviceContext == 0 || m_RenderingContext == 0)
            {
                return;
            }
            if (m_DisplayPanel.Width == 0 || m_DisplayPanel.Height == 0)
            {
                return;
            }

            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);


            GL.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, m_DisplayPanel.Width, m_DisplayPanel.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(70.0, 1.0, 0.4, 500.0);

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
            TextureUtills.GenerateTextures();
            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
示例#2
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);

            GL.glEnable(GL.GL_LIGHT0);
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, Width, Height);
            GL.glClearColor(0, 0, 0, 0);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();
            GLU.gluPerspective(45.0, 1.0, 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedTraslations);

            InitTexture("SurgeryRoom.bmp");
        }
示例#3
0
        double[] WillPlace(float x, float y, float z)
        {
            double[] Robot_place_temp = new double[2];
            Robot_place_temp[0] = RobotPlace[0];
            Robot_place_temp[1] = RobotPlace[1];
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            GL.glTranslatef(x, y, z);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            WillRobotPlace[0] = AccumulatedRotationsTraslations[12];
            WillRobotPlace[1] = AccumulatedRotationsTraslations[14];


            if (Math.Abs(WillRobotPlace[0]) < Math.Abs(Robot_place_temp[0]) && Math.Abs(Robot_place_temp[0]) > 1.5)
            {
                Robot_place_temp[0] = 18.49f;
            }
            else if (Math.Abs(WillRobotPlace[0]) > Math.Abs(Robot_place_temp[0]) && Math.Abs(Robot_place_temp[0]) < 1.5 && Math.Abs(Robot_place_temp[1]) < 4)
            {
                Robot_place_temp[0] = 1.6f;
            }
            if (Math.Abs(WillRobotPlace[1]) < Math.Abs(Robot_place_temp[1]) && Math.Abs(Robot_place_temp[1]) > 4.5)
            {
                Robot_place_temp[1] = 18.49f;
            }
            else if (Math.Abs(WillRobotPlace[1]) > Math.Abs(Robot_place_temp[1]) && Math.Abs(Robot_place_temp[1]) < 4.5 && Math.Abs(Robot_place_temp[1]) > 4)
            {
                Robot_place_temp[1] = 4.6f;
            }

            //return to orginal position matrix
            GL.glTranslatef(-x, -y, -z);
            GL.glRotatef(Robot.WalkAngle, 0, 1, 0);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            return(Robot_place_temp);
        }
示例#4
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(45.0, 1.0, 0.4, 100.0);


            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
示例#5
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);


            GL.glEnable(GL.GL_LIGHT0);
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(45.0, 1.0, 0.4, 100.0);

            //! TEXTURE 1a
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            float[] emis = { 0.3f, 0.3f, 0.3f, 1 };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, emis);
            //! TEXTURE 1a



            GL.glShadeModel(GL.GL_SMOOTH);
            GLU.gluPerspective(viewAngle, (float)Width / (float)Height, 0.45f, 30.0f);

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            //! TEXTURE 1a
            GenerateTextures();
            //! TEXTURE 1b
            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
示例#6
0
        public void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);

            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //Z-BUFFER SHOW begin
            if (!bPerspective)
            {
                GL.glOrtho(-4, 4, -4, 4, -4, 4);
            }
            else
            {
                // - no Grey nuances: differences of our objects Z
                //        are relatively 0 to 100.0f ... 0.45f
                GLU.gluPerspective(45.0f, Width / Height, 0.45f, 500.0f);
            }
            GL.glMatrixMode(GL.GL_MODELVIEW);

            GL.glLoadIdentity();

            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            Zbuf = new float[Width * Height];


            GenerateTextures();
        }
示例#7
0
        public void Draw()
        {
            pos[0] = -4 + (float)xExisOrigin + (float)ScrollValue[11];
            pos[1] = 15 + (float)yExisOrigin + (float)ScrollValue[12];
            pos[2] = 15 + (float)ScrollValue[13];


            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            GL.glLoadIdentity();


            // not trivial
            double [] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double [] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -30.0f);

            GL.glRotatef(105, 0, 0, 1);
            GL.glRotatef(70, 0, 1, 0);
            GL.glRotatef(15, 1, 0, 0);
            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 5.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //REFLECTION//DrawAxes();

            //REFLECTION b
            intOptionB += 1;  //for rotation
            intOptionC += 10; //for rotation
            // without REFLECTION was only DrawAll();
            // now
            //!!!!------sky box
            GL.glPushMatrix();
            GL.glPushAttrib(GL.GL_CURRENT_BIT);
            GL.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);


            GL.glEnable(GL.GL_TEXTURE_2D);
            GL.glDisable(GL.GL_BLEND);
            GL.glRotatef(90, 1, 0, 0);
            DrawTexturedCube();
            GL.glPopAttrib();
            GL.glPopMatrix();
            /////
            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);


            //only floor, draw only to STENCIL buffer
            GL.glEnable(GL.GL_STENCIL_TEST);
            GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
            GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); // draw floor always
            GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
            GL.glDisable(GL.GL_DEPTH_TEST);

            DrawFloor3();

            // restore regular settings
            GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
            GL.glEnable(GL.GL_DEPTH_TEST);

            // reflection is drawn only where STENCIL buffer value equal to 1
            GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF);
            GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);

            GL.glEnable(GL.GL_STENCIL_TEST);

            // draw reflected scene
            GL.glPushMatrix();
            GL.glScalef(1, 1, -1); //swap on Z axis
            GL.glEnable(GL.GL_CULL_FACE);
            GL.glCullFace(GL.GL_BACK);
            DrawFigures();

            GL.glCullFace(GL.GL_FRONT);
            DrawFigures();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();

            // really draw floor
            //( half-transparent ( see its color's alpha byte)))
            // in order to see reflected objects
            GL.glDepthMask((byte)GL.GL_FALSE);

            DrawFloor3();

            GL.glDepthMask((byte)GL.GL_TRUE);
            // Disable GL.GL_STENCIL_TEST to show All, else it will be cut on GL.GL_STENCIL
            GL.glDisable(GL.GL_STENCIL_TEST);



            DrawFigures();



            GL.glDisable(GL.GL_TEXTURE_2D);

            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
示例#8
0
        public void Draw()
        {
            float delta = 0;

            double[] ModelViewMatrixBeforeTransforms = new double[16];
            double[] CurrentTraslation = new double[16];

            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);
            GL.glLoadIdentity();

            if (enableLookAtValue)
            {
                GLU.gluLookAt(LookAtNumberValue[0], LookAtNumberValue[1], LookAtNumberValue[2],
                              LookAtNumberValue[3], LookAtNumberValue[4], LookAtNumberValue[5],
                              LookAtNumberValue[6], LookAtNumberValue[7], LookAtNumberValue[8]);
            }

            GL.glTranslatef(0.0f, 0.0f, -20.0f);

            if (enableRotate)
            {
                GL.glRotatef(viewAngle, 0.0f, 1.0f, 0.0f);
                viewAngle -= 2f;
            }

            DrawRoom();
            DrawOldAxes();
            DrawLightSource();

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelViewMatrixBeforeTransforms);
            GL.glLoadIdentity();

            if (coordSysMoveDirection != 0)
            {
                delta = 5.0f * Math.Abs(coordSysMoveDirection) / coordSysMoveDirection;

                switch (Math.Abs(coordSysMoveDirection))
                {
                case 1:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 2:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 3:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;

                case 4:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 5:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 6:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;
                }
            }

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentTraslation);
            GL.glLoadMatrixd(AccumulatedTraslations);
            GL.glMultMatrixd(CurrentTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedTraslations);
            GL.glLoadMatrixd(ModelViewMatrixBeforeTransforms);
            GL.glMultMatrixd(AccumulatedTraslations);

            DrawAxes();
            GL.glCallList(handList);

            if (enableReflection)
            {
                GL.glEnable(GL.GL_BLEND);
                GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
                GL.glEnable(GL.GL_STENCIL_TEST);
                GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
                GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF);
                GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
                GL.glDisable(GL.GL_DEPTH_TEST);

                //DrawFloor();
                GL.glCallList(floorMainList);

                GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
                GL.glEnable(GL.GL_DEPTH_TEST);
                GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF);
                GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);
                GL.glEnable(GL.GL_STENCIL_TEST);
                GL.glPushMatrix();
                GL.glScalef(1, -1, 1);
                GL.glEnable(GL.GL_CULL_FACE);
                GL.glCullFace(GL.GL_BACK);

                GL.glTranslated(0, 3, 0);
                DrawFigures();

                GL.glCullFace(GL.GL_FRONT);

                DrawFigures();

                GL.glDisable(GL.GL_CULL_FACE);
                GL.glPopMatrix();
                GL.glDepthMask((byte)GL.GL_FALSE);

                //DrawFloor();
                GL.glCallList(floorMainList);

                GL.glDepthMask((byte)GL.GL_TRUE);
                GL.glDisable(GL.GL_STENCIL_TEST);
            }

            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
示例#9
0
        void MakeShadow(double[] ModelVievMatrixBeforeSpecificTransforms, double[] CurrentRotationTraslation)
        {
            #region Shadow Robot floor
            GL.glPushMatrix();
            MakeShadowMatrix(floorCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();                               // make it identity matrix
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //draw Robot shadow on floor
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);

            Robot.Draw(true);
            //GL.glRotatef(180, 0, 1, 0);

            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();
            #endregion



            #region Shadow Robot back wall
            GL.glPushMatrix();
            MakeShadowMatrix(backWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            //draw Robot shadow on back wall
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(true);
            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();

            #endregion
            #region Shadow Robot front wall
            GL.glPushMatrix();
            MakeShadowMatrix(frontWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            //draw Robot shadow on front wall
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(true);
            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();
            #endregion

            #region Shadow Robot right wall
            GL.glPushMatrix();
            MakeShadowMatrix(rightWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            //draw Robot shadow on right wall
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(true);
            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();
            #endregion
            #region Shadow Robot left wall
            GL.glPushMatrix();
            MakeShadowMatrix(leftWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            //draw Robot shadow on left wall
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(true);
            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();
            #endregion

            #region Shadow Robot roof
            GL.glPushMatrix();
            MakeShadowMatrix(ceilingCoordForShadow);
            GL.glMultMatrixf(cubeXform);

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            //draw Robot shadow on roof
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(true);
            GL.glPopMatrix();

            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glPopMatrix();
            #endregion
        }
示例#10
0
        public void Draw()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            GL.glLoadIdentity();

            if (Weaponchanged)
            {
                //if WeaponIndex changed create lists again!
                Robot.PrepareAndDraw();
                Robot.PrepareAndDrawShadow();
                Weaponchanged = false;
            }

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);

            #region Mouse Control
            GL.glTranslatef(-X, -Y, -Z);
            GL.glRotatef(rotX, 1.0f, 0.0f, 0.0f);
            GL.glRotatef(rotY, 0.0f, 1.0f, 0.0f);
            GL.glRotatef(rotZ, 0.0f, 0.0f, 1.0f);
            #endregion


            //move camera to initial position - center of cube and above floor
            GL.glTranslatef(0.0f, 0.0f, -1.0f);
            GL.glTranslatef(0.0f, 5.0f, 0.0f);
            GL.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);


            //update light position
            LightPosition[0] = ScrollValue[10];
            LightPosition[1] = ScrollValue[11];
            LightPosition[2] = ScrollValue[12];
            LightPosition[3] = 1.0f;

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            GL.glLoadIdentity(); // make it identity matrix

            MoveRobotByDirection();

            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //draw actual cube
            cube.Scale(xMaxOfCube, yMaxOfCube, zMaxOfCube);
            cube.Draw(1);

            GL.glRotatef(180, 0, 1, 0);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);

            GL.glPushMatrix();
            GL.glLoadIdentity();
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);


            //!!!!!!!!!!! draw orginal Robot
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glEnable(GL.GL_LIGHTING);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(false);
            GL.glPopMatrix();


            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            RobotPlace[0]        = AccumulatedRotationsTraslations[12];
            RobotPlaceForward[0] = RobotPlaceBackward[0] = RobotPlaceRight[0] = RobotPlaceLeft[0] = AccumulatedRotationsTraslations[12];
            RobotPlace[1]        = AccumulatedRotationsTraslations[14];
            RobotPlaceForward[1] = RobotPlaceBackward[1] = RobotPlaceRight[1] = RobotPlaceLeft[1] = AccumulatedRotationsTraslations[14];

            switch (WhatWillDirection)
            {
            case arrow.forward:
                //Look future to get wallk forward
                RobotPlaceForward = WillPlace(2.1f, 0, 0);
                break;

            case arrow.backward:
                //Look future to get wallk backward
                RobotPlaceBackward = WillPlace(-2.1f, 0, 0);
                break;

            case arrow.right:
                //Look future to get wallk right
                RobotPlaceRight = WillPlace(0, 0, 2.1f);
                break;

            case arrow.left:
                //Look future to get wallk left
                RobotPlaceLeft = WillPlace(0, 0, -2.1f);
                break;
            }

            if (((RobotPlace[0] < ((car.Drive % 46) - 23) + 7) && (RobotPlace[0] > ((car.Drive % 46) - 23) - 4)) && //in car length
                RobotPlace[1] > 5 && RobotPlace[1] < 10 && !Robot.IsJumping)     //in car width & not jumping
            {
                Robot.IsCrashWithCar = true;
            }

            //!!!!!!!!!!!
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            GL.glRotatef(-180, 0, 1, 0);

            #region Reflaction to cube
            StartReflaction(-1, 1, -1);     //Reflaction to cube

            cube.Scale(xMaxOfCube - 0.002f, yMaxOfCube - 0.002f, zMaxOfCube - 0.002f);
            cube.Draw(-1);       //decrease 0.002 from each dimension of cube to avoid unexpected lines and -1 for mirrow efect
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();
            #endregion

            // really draw mirror
            //( half-transparent ( see its color's alpha byte)))
            // in order to see reflected objects
            //GL.glPushMatrix();
            //GL.glTranslatef(0, -4, 0);
            //GL.glDepthMask((byte)GL.GL_FALSE);
            //GL.glRotatef(90,0,1,0);
            //DrawMirror();
            //GL.glDepthMask((byte)GL.GL_TRUE);
            //GL.glPopMatrix();

            GL.glScalef(-1, 1, 1);//Some rotation for normal Cube direction
            GL.glRotatef(180, 0, 1, 0);

            #region Reflaction to Robot
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            StartReflaction(-1, 1, 1);  //Start Reflaction to Robot
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);
            GL.glLoadMatrixd(AccumulatedRotationsTraslations);
            GL.glMultMatrixd(CurrentRotationTraslation);
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            GL.glMultMatrixd(AccumulatedRotationsTraslations);



            //draw reflected Robot
            GL.glPushMatrix();
            RotateRobotByDirection();
            GL.glCullFace(GL.GL_BACK);
            GL.glCullFace(GL.GL_FRONT);
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glRotatef(-Robot.WalkAngle, 0, 1, 0);
            Robot.Draw(false);
            GL.glPopMatrix();
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();


            //draw all Robot shadows in the mirror!!
            MakeShadow(ModelVievMatrixBeforeSpecificTransforms, CurrentRotationTraslation);
            DrawLight();   //draw reflected light
            GL.glDisable(GL.GL_STENCIL_TEST);
            #endregion

            GL.glScalef(1, 1, -1);                                                          //Some rotation for normal Cube direction
            GL.glRotatef(180, 0, 1, 0);
            DrawLight();                                                                    //draw actual light
            MakeShadow(ModelVievMatrixBeforeSpecificTransforms, CurrentRotationTraslation); //draw all Robot shadows


            car.Drive += 0.5f;    //for animation of car moving

            //draw car reflection
            StartReflaction(-1, 1, 1);
            car.Draw(false);

            //draw car reflection shadow on floor
            StartReflaction(-1, 1, 1);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glPushMatrix();
            MakeShadowMatrix(floorCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();

            //draw car reflection shadow on back wall
            StartReflaction(-1, 1, 1);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glPushMatrix();
            MakeShadowMatrix(backWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();

            //draw car reflection shadow on front wall
            StartReflaction(-1, 1, 1);
            GL.glDisable(GL.GL_LIGHTING);
            GL.glPushMatrix();
            MakeShadowMatrix(frontWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();
            GL.glDisable(GL.GL_STENCIL_TEST);

            //draw the Frame of mirror
            mirror.DrawFrame();

            //draw mirror again to cover car from being shown on the other side of mirror
            GL.glPushMatrix();
            GL.glTranslatef(0, -4, 0);
            GL.glRotatef(90, 0, 1, 0);
            mirror.Draw();
            GL.glPopMatrix();

            //draw car
            car.Draw(false);

            //draw shadow car on floor
            GL.glPushMatrix();
            MakeShadowMatrix(floorCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();

            //draw shadow car on back wall
            GL.glPushMatrix();
            MakeShadowMatrix(backWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();

            //draw shadow car on front wall
            GL.glPushMatrix();
            MakeShadowMatrix(frontWallCoordForShadow);
            GL.glMultMatrixf(cubeXform);
            car.Draw(true);
            GL.glPopMatrix();


            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
示例#11
0
        public void Draw()
        {
            //Shadows
            pos[0] = 0;//ScrollValue[9];
            pos[1] = ScrollValue[8];
            pos[2] = ScrollValue[7];
            pos[3] = ScrollValue[9];


            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            GL.glLoadIdentity();



            // not trivial
            double[] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double[] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -1.0f);


            if (!bPerspective)
            {
                GL.glTranslatef(0.0f, 0.0f, 8.0f);
            }



            //3D model b3
            GL.glTranslatef(0.0f, -5.0f, -15.0f);
            GL.glRotated(180, 0, 1, 0);
            //3D model e



            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            //  GL.glLoadIdentity(); // make it identity matrix
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 5.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            GL.glEnable(GL.GL_TEXTURE_2D);


            if (!rotate)
            {
                GL.glRotatef(0, 0, 20, 0);
                GL.glDepthRange(1, 1);////////if the zebra behind the cube, change to (1,1)
                GL.glPushMatrix();

                DrawTexturedCube();

                GL.glPopMatrix();
            }
            else
            {
                GL.glRotatef(0, 0, 20, 0);
                GL.glDepthRange(1, 1);
                GL.glPushMatrix();
                angle -= 0.1f;
                GL.glRotatef(angle, 0, 2, 0);
                DrawTexturedCube();

                GL.glPopMatrix();
            }


            GL.glRotated(100, 0, 90, 0);
            GL.glScaled(0.05, 0.05, 0.05);



            GL.glRotated(-90, 180, 0, 0);
            GL.glScaled(30, 30, 30);

            DrawFigures();


            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);


            //only floor, draw only to STENCIL buffer
            GL.glEnable(GL.GL_STENCIL_TEST);
            GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
            GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF); // draw floor always
            GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
            GL.glDisable(GL.GL_DEPTH_TEST);


            // restore regular settings
            GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
            GL.glEnable(GL.GL_DEPTH_TEST);


            GL.glEnable(GL.GL_STENCIL_TEST);

            // draw reflected scene
            GL.glPushMatrix();
            GL.glScalef(1, 1, -1); //swap on Z axis
            GL.glEnable(GL.GL_CULL_FACE);
            GL.glCullFace(GL.GL_BACK);
            DrawFigures();
            GL.glCullFace(GL.GL_FRONT);
            DrawFigures();
            GL.glDisable(GL.GL_CULL_FACE);
            GL.glPopMatrix();


            // really draw floor
            //( half-transparent ( see its color's alpha byte)))
            // in order to see reflected objects
            GL.glDepthMask((byte)GL.GL_FALSE);
            DrawFloor();
            GL.glDepthMask((byte)GL.GL_TRUE);
            // Disable GL.GL_STENCIL_TEST to show All, else it will be cut on GL.GL_STENCIL
            GL.glDisable(GL.GL_STENCIL_TEST);
            DrawFigures();
            //REFLECTION e
            GL.glFlush();

            WGL.wglSwapBuffers(m_uint_DC);
        }
示例#12
0
        public void Draw()
        {
            //Light position for shadows
            MainLightSource.X = ScrollValue[10];
            MainLightSource.Y = ScrollValue[11];
            MainLightSource.Z = ScrollValue[12];
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, MainLightSource.LightLocation());
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, new float[] { 0f, 0f, 0f, 1f });
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, new float[] { 1f, 1f, 1f });
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, new float[] { 0.628281f, 0.555802f, 0.366065f });

            GL.glLightfv(GL.GL_LIGHT2, GL.GL_POSITION, StaticRedLightSource.LightLocation());
            GL.glLightfv(GL.GL_LIGHT2, GL.GL_AMBIENT, new float[] { 0f, 0f, 0f, 1f });
            GL.glLightfv(GL.GL_LIGHT2, GL.GL_DIFFUSE, new float[] { 1f, 0f, 0f });
            GL.glLightfv(GL.GL_LIGHT2, GL.GL_SPECULAR, new float[] { 0.628281f, 0.555802f, 0.366065f });

            GL.glLightfv(GL.GL_LIGHT3, GL.GL_POSITION, StaticBlueLightSource.LightLocation());
            GL.glLightfv(GL.GL_LIGHT3, GL.GL_AMBIENT, new float[] { 0f, 0f, 0f, 1f });
            GL.glLightfv(GL.GL_LIGHT3, GL.GL_DIFFUSE, new float[] { 0f, 0f, 1f });
            GL.glLightfv(GL.GL_LIGHT3, GL.GL_SPECULAR, new float[] { 0.628281f, 0.555802f, 0.366065f });

            //GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, bannerLightPos);
            if (m_DeviceContext == 0 || m_RenderingContext == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            GL.glLoadIdentity();

            // not trivial
            double[] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double[] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -3.0f);

            DrawOldAxes();

            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 3.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);
            GL.glPushMatrix();             // save the current matrix
            GL.glScalef(zoom, zoom, zoom); // scale the matrix
            DrawAxes();
            DrawFigures();
            GL.glPopMatrix(); // load the unscaled matrix
            GL.glFlush();

            WGL.wglSwapBuffers(m_DeviceContext);
        }
示例#13
0
        public void Draw()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            GL.glLoadIdentity();

            // not trivial
            double [] ModelVievMatrixBeforeSpecificTransforms = new double[16];
            double [] CurrentRotationTraslation = new double[16];

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);
            GL.glTranslatef(0.0f, 0.0f, -1.0f);

            DrawOldAxes();

            //save current ModelView Matrix values
            //in ModelVievMatrixBeforeSpecificTransforms array
            //ModelView Matrix ========>>>>>> ModelVievMatrixBeforeSpecificTransforms
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, ModelVievMatrixBeforeSpecificTransforms);
            //ModelView Matrix was saved, so
            GL.glLoadIdentity(); // make it identity matrix

            //make transformation in accordance to KeyCode
            float delta;

            if (intOptionC != 0)
            {
                delta = 5.0f * Math.Abs(intOptionC) / intOptionC; // signed 5

                switch (Math.Abs(intOptionC))
                {
                case 1:
                    GL.glRotatef(delta, 1, 0, 0);
                    break;

                case 2:
                    GL.glRotatef(delta, 0, 1, 0);
                    break;

                case 3:
                    GL.glRotatef(delta, 0, 0, 1);
                    break;

                case 4:
                    GL.glTranslatef(delta / 20, 0, 0);
                    break;

                case 5:
                    GL.glTranslatef(0, delta / 20, 0);
                    break;

                case 6:
                    GL.glTranslatef(0, 0, delta / 20);
                    break;
                }
            }
            //as result - the ModelView Matrix now is pure representation
            //of KeyCode transform and only it !!!

            //save current ModelView Matrix values
            //in CurrentRotationTraslation array
            //ModelView Matrix =======>>>>>>> CurrentRotationTraslation
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, CurrentRotationTraslation);

            //The GL.glLoadMatrix function replaces the current matrix with
            //the one specified in its argument.
            //The current matrix is the
            //projection matrix, modelview matrix, or texture matrix,
            //determined by the current matrix mode (now is ModelView mode)
            GL.glLoadMatrixd(AccumulatedRotationsTraslations); //Global Matrix

            //The GL.glMultMatrix function multiplies the current matrix by
            //the one specified in its argument.
            //That is, if M is the current matrix and T is the matrix passed to
            //GL.glMultMatrix, then M is replaced with M • T
            GL.glMultMatrixd(CurrentRotationTraslation);

            //save the matrix product in AccumulatedRotationsTraslations
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            //replace ModelViev Matrix with stored ModelVievMatrixBeforeSpecificTransforms
            GL.glLoadMatrixd(ModelVievMatrixBeforeSpecificTransforms);
            //multiply it by KeyCode defined AccumulatedRotationsTraslations matrix
            GL.glMultMatrixd(AccumulatedRotationsTraslations);

            DrawAxes();

            DrawFigures();

            GL.glFlush();

            WGL.wglSwapBuffers(m_uint_DC);
        }