当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3.Invert方法代码示例

本文整理汇总了C#中Matrix3.Invert方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3.Invert方法的具体用法?C# Matrix3.Invert怎么用?C# Matrix3.Invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrix3的用法示例。


在下文中一共展示了Matrix3.Invert方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: display

        public override void display()
        {
            ClearDisplay();

            if (current_mesh != null)
            {
                MatrixStack modelMatrix = new MatrixStack();
                using (PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.Translate(Camera.g_camTarget);
                    modelMatrix.Translate(0f, 0f, 0f);
                    modelMatrix.Scale(15.0f, 15.0f, 15.0f);
                    modelMatrix.Rotate(axis, angle);
                    angle = angle + 1f;

                    GL.UseProgram(currentProgram.theProgram);
                    Matrix4 mm = modelMatrix.Top();

                    if (noWorldMatrix)
                    {
                        Matrix4 cm2 = Matrix4.Mult(mm, cm);
                        GL.UniformMatrix4(currentProgram.modelToCameraMatrixUnif, false, ref cm2);
                        if (currentProgram.normalModelToCameraMatrixUnif != 0)
                        {
                            Matrix3 normalModelToCameraMatrix = Matrix3.Identity;
                            Matrix4 applyMatrix = Matrix4.Mult(Matrix4.Identity,
                                                                     Matrix4.CreateTranslation(dirToLight));
                            normalModelToCameraMatrix = new Matrix3(applyMatrix);
                            normalModelToCameraMatrix.Invert();
                            GL.UniformMatrix3(currentProgram.normalModelToCameraMatrixUnif, false,
                                              ref normalModelToCameraMatrix);
                            //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                            //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);

                        }
                        //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                        //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);
                    }
                    else
                    {
                        GL.UniformMatrix4(currentProgram.modelToWorldMatrixUnif, false, ref mm);
                    }
                }
                current_mesh.Render();
                GL.UseProgram(0);
            }
        }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:47,代码来源:Tut_SingleMeshItem.cs

示例2: Draw

        public override void Draw(DrawEventArgs e)
        {
            shader.Use();

            /* Calculate Model/View/Projection matrix */
            Matrix4.Mult(ref this.modelMatrix, ref e.ModelMatrix, out mvp);
            Matrix3 m = new Matrix3(mvp);
            shader.SetMatrix3("model", ref m); // TODO: Mat4 instead?
            Matrix4.Mult(ref mvp, ref e.Camera.ViewProjection, out mvp);
            shader.SetMatrix("mvp", ref mvp);

            /* Normal matrix */
            m.Invert();
            m.Transpose();
            shader.SetMatrix3("G", ref m);

            mesh.DrawElements(this.triangles * 3, DrawElementsType.UnsignedShort);

            base.Draw(e);
        }
开发者ID:johanhenriksson,项目名称:univ,代码行数:20,代码来源:Model.cs

示例3: display

        public override void display()
        {
            ClearDisplay();

            if (meshes[currentMesh] != null)
            {
                MatrixStack modelMatrix = new MatrixStack();
                using (PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.Rotate(axis, angle);   // rotate last to leave in place
                    modelMatrix.Translate(Camera.g_camTarget);
                    modelMatrix.Scale(initialScale.X / scaleFactor.X,
                        initialScale.Y / scaleFactor.Y,
                        initialScale.Z / scaleFactor.Z);

                    GL.UseProgram(currentProgram.theProgram);
                    Matrix4 mm = modelMatrix.Top();

                    if (noWorldMatrix)
                    {
                        Matrix4 cm2 = Matrix4.Mult(mm, cm);
                        GL.UniformMatrix4(currentProgram.modelToCameraMatrixUnif, false, ref cm2);
                        if (currentProgram.normalModelToCameraMatrixUnif != 0)
                        {
                            Matrix3 normalModelToCameraMatrix = Matrix3.Identity;
                            Matrix4 applyMatrix = Matrix4.Mult(Matrix4.Identity,
                                                                     Matrix4.CreateTranslation(dirToLight));
                            normalModelToCameraMatrix = new Matrix3(applyMatrix);
                            normalModelToCameraMatrix.Invert();
                            GL.UniformMatrix3(currentProgram.normalModelToCameraMatrixUnif, false,
                                              ref normalModelToCameraMatrix);
                            //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                            //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);

                        }
                        //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                        //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);
                    }
                    else
                    {
                        GL.UniformMatrix4(currentProgram.modelToWorldMatrixUnif, false, ref mm);
                    }
                }
                if (renderWithString)
                {
                    try
                    {
                        meshes[currentMesh].Render(renderString);
                    }
                    catch (Exception ex)
                    {
                        renderWithString = false;
                        MessageBox.Show("Error displaying mesh wih render string " + renderString + " " + ex.ToString());
                    }
                }
                else
                {
                    meshes[currentMesh].Render();
                }
                GL.UseProgram(0);
                if (perspectiveAngle != newPerspectiveAngle)
                {
                    perspectiveAngle = newPerspectiveAngle;
                    reshape();
                }
            }
        }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:67,代码来源:Tut_MoveMeshItem.cs

示例4: display

        public override void display()
        {
            ClearDisplay();

            cameraMatrix = g_viewPole.CalcMatrix();

            if (meshes[currentMesh] != null)
            {
                MatrixStack modelMatrix = new MatrixStack();
                using (PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.Rotate(axis, angle);   // rotate last to leave in place
                    //modelMatrix.Translate(Camera.g_camTarget);
                    //modelMatrix.Scale(initialScale.X / scaleFactor.X,
                    //	initialScale.Y / scaleFactor.Y,
                    //	initialScale.Z / scaleFactor.Z);

                    GL.UseProgram(programs[currentProgram].theProgram);

                    GL.UniformMatrix4(programs[currentProgram].cameraToLightProjMatrixUnif, false, ref cameraToLightProjMatrix);

                    GL.Uniform3(programs[currentProgram].cameraSpaceProjLightPosUnif, cameraSpaceProjLightPos);

                    GL.Uniform1(programs[currentProgram].diffuseColorTexUnif, 0);
                    GL.Uniform1(programs[currentProgram].lightProjTexUnif, 1);

                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.BindTexture(TextureTarget.Texture2D, currentTexture);

                    GL.ActiveTexture(TextureUnit.Texture1);
                    GL.BindTexture(TextureTarget.Texture2D, lightTexture);

                    cameraMatrix = cameraMatrixStack.Top();

                    modelToCameraMatrix = Matrix4.Mult(Matrix4.Identity, cameraMatrix);
                    GL.UniformMatrix4(programs[currentProgram].modelToCameraMatrixUnif, false, ref modelToCameraMatrix);
                    if (programs[currentProgram].normalModelToCameraMatrixUnif != 0)
                    {
                        Matrix3 normalModelToCameraMatrix = Matrix3.Identity;
                        Matrix4 applyMatrix = Matrix4.Mult(Matrix4.Identity,
                            Matrix4.CreateTranslation(dirToLight));
                        normalModelToCameraMatrix = new Matrix3(applyMatrix);
                        normalModelToCameraMatrix.Invert();
                        GL.UniformMatrix3(programs[currentProgram].normalModelToCameraMatrixUnif, false,
                            ref normalModelToCameraMatrix);
                        Matrix4 cameraToClipMatrix = Matrix4.Identity;
                        GL.UniformMatrix4(programs[currentProgram].cameraToClipMatrixUnif, false, ref cameraToClipMatrix);

                    }
                }
                if (renderWithString)
                {
                    try
                    {
                        meshes[currentMesh].Render(renderStrings[renderString]);
                    }
                    catch (Exception ex)
                    {
                        renderWithString = false;
                        MessageBox.Show("Error displaying mesh wih render string " + renderStrings[renderString] + " " + ex.ToString());
                    }
                }
                else
                {
                    meshes[currentMesh].Render();
                }
                GL.UseProgram(0);
                if (perspectiveAngle != newPerspectiveAngle)
                {
                    perspectiveAngle = newPerspectiveAngle;
                    reshape();
                }
            }
        }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:74,代码来源:Tut_Projected_Light_Test.cs

示例5: display

        public override void display()
        {
            GL.Disable(EnableCap.DepthTest);
            ClearDisplay();
            if (drawWalls) backWall.Draw();
            if (drawWalls) leftWall.Draw();
            if (drawWalls) rightWall.Draw();
            if (drawWalls) topWall.Draw();
            if (drawWalls) bottomWall.Draw();

            ball.Draw();

            if (current_mesh != null)
            {
                MatrixStack modelMatrix = new MatrixStack();
                using (PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.Rotate(axis, angle);   // rotate last to leave in place
                    modelMatrix.Translate(position);
                    modelMatrix.Scale(15.0f, 15.0f, 15.0f);
                    ballModelMatrix = modelMatrix.Top();

                    GL.UseProgram(currentProgram.theProgram);
                    Matrix4 mm = modelMatrix.Top();

                    if (noWorldMatrix)
                    {
                        Matrix4 cm2 = Matrix4.Mult(mm, worldToCameraMatrix);
                        GL.UniformMatrix4(currentProgram.modelToCameraMatrixUnif, false, ref cm2);
                        if (currentProgram.normalModelToCameraMatrixUnif != 0)
                        {
                            Matrix3 normalModelToCameraMatrix = Matrix3.Identity;
                            Matrix4 applyMatrix = Matrix4.Mult(Matrix4.Identity,
                                                                     Matrix4.CreateTranslation(dirToLight));
                            normalModelToCameraMatrix = new Matrix3(applyMatrix);
                            normalModelToCameraMatrix.Invert();
                            GL.UniformMatrix3(currentProgram.normalModelToCameraMatrixUnif, false,
                                              ref normalModelToCameraMatrix);
                            //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                            //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);

                        }
                        //Matrix4 cameraToClipMatrix = Matrix4.Identity;
                        //GL.UniformMatrix4(currentProgram.cameraToClipMatrixUnif, false, ref cameraToClipMatrix);
                    }
                    else
                    {
                        GL.UniformMatrix4(currentProgram.modelToWorldMatrixUnif, false, ref mm);
                    }
                }
                if (renderWithString)
                {
                    current_mesh.Render(renderString);
                }
                else
                {
                    current_mesh.Render();
                }
                GL.UseProgram(0);
                if (perspectiveAngle != newPerspectiveAngle)
                {
                    perspectiveAngle = newPerspectiveAngle;
                    reshape();
                }
            }
            if (drawWalls) frontWall.Draw();
            if (pause == false)
            {
                UpdatePosition();
                if (rotateWorld)
                {
                    RotateWorldSub();
                }
            }
        }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:75,代码来源:Tut_Tennis3D.cs

示例6: Draw

        public override void Draw(DrawEventArgs e)
        {
            shader.Use();

            /* Calculate Model/View/Projection matrix */
            Matrix4.Mult(ref this.modelMatrix, ref e.ModelMatrix, out mvp);
            Matrix3 m = new Matrix3(mvp); // Copy the top-right 3x3 model matrix for later...
            Matrix4.Mult(ref mvp, ref e.Camera.ViewProjection, out mvp);
            shader.SetMatrix("mvp", ref mvp);

            /* Normal matrix */
            m.Invert();
            m.Transpose();
            shader.SetMatrix3("G", ref m);

            geometry.Draw(vertexData.Length);

            base.Draw(e);
        }
开发者ID:johanhenriksson,项目名称:univ,代码行数:19,代码来源:Voxel.cs

示例7: invert

        public static void invert() {
            var a = new Matrix3(_priorInvert);

            a.Invert();

            a.Should().Be(_postInvert);
        }
开发者ID:aarondandy,项目名称:vertesaur,代码行数:7,代码来源:Matrix3Facts.cs


注:本文中的Matrix3.Invert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。