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


C# Matrix3.Transpose方法代码示例

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


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

示例1: 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

示例2: GetRGBtoXYZTransformationMatrix

        /// <summary>
        /// This method is required to compute the transformation matrix to convert RGB to XYZ in dependency of the used white point and RR, GG, BB points
        /// </summary>
        /// <author>Markus Strobel</author>
        /// <returns>returns the 3x3 Matrix for Compute RGB to XYZ</returns>
        private static Matrix3 GetRGBtoXYZTransformationMatrix()
        {
            // Quelle: http://www.ryanjuckett.com/programming/rgb-color-space-conversion/

            Vector3 rr = new Vector3(RR_used.X, RR_used.Y, RR_used.Z);
            Vector3 gg = new Vector3(GG_used.X, GG_used.Y, GG_used.Z);
            Vector3 bb = new Vector3(BB_used.X, BB_used.Y, BB_used.Z);

            // Rx Gx Bx
            // Ry Gy By
            // Rz Gz Bz
            Matrix3 M = new Matrix3(rr, gg, bb);
            M.Transpose(); // M

            Matrix3 MInv = M.Inverted(); // M^-1

            //Vector3 WP_XYZ_used = new Vector3(WP_used.X / WP_used.Y, 1, WP_used.Z / WP_used.Y); // WP_xyz to WP_XYZ
            Vector3 WP_XYZ_used = new Vector3(WP_used.X, WP_used.Y, WP_used.Z);

            WP_XYZ_used.X = Reverse_Gamma_Correction(WP_XYZ_used.X);
            WP_XYZ_used.Y = Reverse_Gamma_Correction(WP_XYZ_used.Y);
            WP_XYZ_used.Z = Reverse_Gamma_Correction(WP_XYZ_used.Z);

            Vector3 temp = new Vector3();
            temp.X = MInv.M11 * WP_XYZ_used.X + MInv.M12 * WP_XYZ_used.Y + MInv.M13 * WP_XYZ_used.Z;
            temp.Y = MInv.M21 * WP_XYZ_used.X + MInv.M22 * WP_XYZ_used.Y + MInv.M23 * WP_XYZ_used.Z;
            temp.Z = MInv.M31 * WP_XYZ_used.X + MInv.M32 * WP_XYZ_used.Y + MInv.M33 * WP_XYZ_used.Z;

            M = Matrix3.Mult(M, new Matrix3(temp.X, 0, 0, 0, temp.Y, 0, 0, 0, temp.Z));

            return M;
        }
开发者ID:ArTc0re,项目名称:University,代码行数:37,代码来源:ColorHelper.cs

示例3: display

        public override void display()
        {
            g_lightTimer.Update();

            GL.ClearColor(0.75f, 0.75f, 1.0f, 1.0f);
            GL.ClearDepth(1.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            if((g_pObjectMesh != null) && (g_pCubeMesh != null))
            {
                MatrixStack modelMatrix = new MatrixStack();
                modelMatrix.SetMatrix(g_viewPole.CalcMatrix());
                Matrix4 worldToCamMat = modelMatrix.Top();

                LightBlock lightData = new LightBlock(NUMBER_OF_LIGHTS);

                lightData.ambientIntensity = new Vector4(0.2f, 0.2f, 0.2f, 1.0f);
                lightData.lightAttenuation = g_fLightAttenuation;

                Vector3 globalLightDirection = new Vector3(0.707f, 0.707f, 0.0f);

                lightData.lights[0].cameraSpaceLightPos =
                    Vector4.Transform(new Vector4(globalLightDirection, 0.0f), worldToCamMat);
                lightData.lights[0].lightIntensity = new Vector4(0.6f, 0.6f, 0.6f, 1.0f);

                lightData.lights[1].cameraSpaceLightPos = Vector4.Transform(CalcLightPosition(), worldToCamMat);
                lightData.lights[1].lightIntensity = new Vector4(0.4f, 0.4f, 0.4f, 1.0f);

                g_litShaderProg.lightBlock.Update(lightData);
                g_litTextureProg.lightBlock.Update(lightData);

                using ( PushStack pushstack = new PushStack(modelMatrix))
                {
                    modelMatrix.ApplyMatrix(g_objtPole.CalcMatrix());
                    modelMatrix.Scale(2.0f);

                    Matrix3 normMatrix = new Matrix3(modelMatrix.Top());
                    normMatrix.Transpose();
                    //TEST
                    normMatrix = Matrix3.Identity;
                    //normMatrix = glm::transpose(glm::inverse(normMatrix));

                    ProgramData prog = g_bUseTexture ? g_litTextureProg : g_litShaderProg;

                    GL.UseProgram(prog.theProgram);
                    Matrix4 mm = modelMatrix.Top();
                    GL.UniformMatrix4(prog.modelToCameraMatrixUnif, false, ref mm);
                    GL.UniformMatrix3(prog.normalModelToCameraMatrixUnif, false, ref normMatrix);

                    GL.ActiveTexture(TextureUnit.Texture0 + g_gaussTexUnit);
                    GL.BindTexture(TextureTarget.Texture1D, g_gaussTextures[g_currTexture]);
                    GL.BindSampler(g_gaussTexUnit, g_gaussSampler);

                    g_pObjectMesh.Render("lit");

                    GL.BindSampler(g_gaussTexUnit, 0);
                    GL.BindTexture(TextureTarget.Texture1D, 0);

                    GL.UseProgram(0);
                }

                if(g_bDrawLights)
                {
                    using (PushStack pushstack = new PushStack(modelMatrix))
                    {
                        modelMatrix.Translate(new Vector3(CalcLightPosition()));
                        modelMatrix.Scale(0.25f);

                        GL.UseProgram(g_Unlit.theProgram);
                        Matrix4 mm = modelMatrix.Top();
                        GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);

                        Vector4 lightColor = new Vector4(1f, 1f, 1f, 1f);
                        GL.Uniform4(g_Unlit.objectColorUnif, ref lightColor);
                        g_pCubeMesh.Render("flat");
                    }

                    modelMatrix.Translate(globalLightDirection * 100.0f);
                    modelMatrix.Scale(5.0f);

                    Matrix4 mm2 = modelMatrix.Top();
                    GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm2);
                    g_pCubeMesh.Render("flat");

                    GL.UseProgram(0);
                }

                if(g_bDrawCameraPos)
                {
                    using (PushStack pushstack = new PushStack(modelMatrix))
                    {
                        modelMatrix.SetIdentity();
                        modelMatrix.Translate(new Vector3(0.0f, 0.0f, -g_viewPole.GetView().radius));
                        modelMatrix.Scale(0.25f);

                        GL.Disable(EnableCap.DepthTest);
                        GL.DepthMask(false);
                        GL.UseProgram(g_Unlit.theProgram);
                        Matrix4 mm = modelMatrix.Top();
                        GL.UniformMatrix4(g_Unlit.modelToCameraMatrixUnif, false, ref mm);
//.........这里部分代码省略.........
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:101,代码来源:Tut_14_Basic_Textures.cs

示例4: Transpose_Success

        public void Transpose_Success()
        {
            Matrix3 mat = new Matrix3(new double[,]
            {
                { 1.0, 2.0, 3.0},
                {4.0, 5.0, 6.0},
                {7.0, 8.0, 9.0}
            });

            Matrix3 transpose = mat.Transpose();

            Assert.AreEqual(1.0, transpose[0, 0], Epsilon);
            Assert.AreEqual(4.0, transpose[0,1], Epsilon);
            Assert.AreEqual(6.0, transpose[2,1], Epsilon);
            Assert.AreEqual(7.0, transpose[0,2], Epsilon);
        }
开发者ID:patricknboyd,项目名称:VectorMath,代码行数:16,代码来源:Matrix3_Test.cs

示例5: Transpose_Empty_Success

        public void Transpose_Empty_Success()
        {
            Matrix3 mat = new Matrix3();
            Matrix3 transpose = mat.Transpose();

            Assert.AreEqual(0.0, transpose[0, 0], Epsilon);
            Assert.AreEqual(0.0, transpose[0, 1], Epsilon);
            Assert.AreEqual(0.0, transpose[2, 1], Epsilon);
            Assert.AreEqual(0.0, transpose[0, 2], Epsilon);
        }
开发者ID:patricknboyd,项目名称:VectorMath,代码行数:10,代码来源:Matrix3_Test.cs

示例6: OnRenderFrame

        protected void OnRenderFrame(object sender, FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            // first Material's uniforms
            _program.Material_DiffuseAndHeight.BindTexture(TextureUnit.Texture0, _textureDiffuseHeight);
            _program.Material_NormalAndGloss.BindTexture(TextureUnit.Texture1, _textureNormalGloss);
            _program.Material_ScaleBiasShininess.Set(_materialScaleAndBiasAndShininess);

            // the rest are vectors
            _program.Camera_Position.Set(Camera.State.Position);
            _program.Light_Position.Set(_lightPosition);
            _program.Light_DiffuseColor.Set(_lightDiffuse);
            _program.Light_SpecularColor.Set(_lightSpecular);

            // set up matrices
            SetupPerspective();
            var normalMatrix = new Matrix3(ModelView).Inverted();
            normalMatrix.Transpose();
            _program.NormalMatrix.Set(normalMatrix);
            _program.ModelViewMatrix.Set(ModelView);
            _program.ModelViewProjectionMatrix.Set(ModelView * Projection);

            // render
            _vao.DrawArrays(PrimitiveType.TriangleStrip, 0, _buffer.ElementCount);

            SwapBuffers();
        }
开发者ID:olegbom,项目名称:ObjectTK,代码行数:28,代码来源:ParallaxMappingExample.cs

示例7: 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

示例8: transpose

        public static void transpose() {
            var a = new Matrix3(_priorTrans);

            a.Transpose();

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


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