• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Framework.Matrix类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Xna.Framework.Matrix的典型用法代码示例。如果您正苦于以下问题:C# Matrix类的具体用法?C# Matrix怎么用?C# Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Matrix类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了Matrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Reset

 // Reset
 public void Reset()
 {
     Offset = new Vector2();
     Scale = new Vector2( 1.0f );
     Rotation = new Vector3();
     TransformMatrix = Matrix.Identity;
 }
开发者ID:JacobNorlin,项目名称:project-duck,代码行数:8,代码来源:CameraSettings.cs


示例2: DrawWireframe

        public static void DrawWireframe(PrimitiveDrawer primitiveDrawer,
			Vector3 cameraPosition, Matrix cameraView, Matrix cameraProjection,
			Vector3 center, float radius, Quaternion rotation, Color color)
        {
            // Draw three orthogonal discs.
            Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Up, rotation)), radius, color, true);
            Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Forward, rotation)), radius, color, true);
            Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Left, rotation)), radius, color, true);

            // Draw disc aligned with camera. To do this, first calculate the largest visible cross section using
             			// the technique described here: http://www.quantimegroup.com/solutions/pages/Article/Article.html

            // Solve for dy.
            Vector3 cameraToCenter = center - cameraPosition;
            float distanceToCenter = cameraToCenter.Length();
            float radius2 = radius * radius;
            float dy = radius2 / distanceToCenter;
            float r = MathUtility.Sqrt(radius2 - (dy * dy));

            Vector3 directionToCenter = Vector3.Normalize(cameraToCenter);
            Vector3 newCenter = cameraPosition + directionToCenter * (distanceToCenter - dy);

            // Disc aligned with camera
            Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection,
                newCenter, directionToCenter, r, Color.White, false);
        }
开发者ID:tgjones,项目名称:osiris,代码行数:26,代码来源:Sphere.cs


示例3: Draw

        public override void Draw(GameTime gameTime)
        {
            Matrix worldMatrix = Matrix.Identity;
            switch (Resources.Instance.GameSize)
            {
                case Resources.LevelSize.SMALL:
                    worldMatrix = Matrix.Identity * Matrix.CreateScale(85);
                    break;
                case Resources.LevelSize.MEDIUM:
                    worldMatrix = Matrix.Identity * Matrix.CreateScale(100);
                    break;

                case Resources.LevelSize.LARGE:
                    worldMatrix = Matrix.Identity * Matrix.CreateScale(115);
                    break;
            }
            

            Matrix[] transforms = new Matrix[_model.Bones.Count];
            _model.CopyAbsoluteBoneTransformsTo(transforms);
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.Projection = MathConverter.Convert(_manager.Camera.ProjectionMatrix);
                    effect.View = MathConverter.Convert(_manager.Camera.ViewMatrix);
                    effect.World = worldMatrix;
                }

                mesh.Draw();
            }

            base.Draw(gameTime);
        }
开发者ID:boddie,项目名称:AsteroidDestroyer,代码行数:35,代码来源:Boundary.cs


示例4: Draw

        /// <summary>
        /// Draws the display object.
        /// </summary>
        /// <param name="viewMatrix">Current view matrix.</param>
        /// <param name="projectionMatrix">Current projection matrix.</param>
        public override void Draw(Matrix viewMatrix, Matrix projectionMatrix)
        {
            //This is not a particularly fast method of drawing.
            //It's used very rarely in the demos.
            model.CopyAbsoluteBoneTransformsTo(transforms);
            for (int i = 0; i < Model.Meshes.Count; i++)
            {
                for (int j = 0; j < Model.Meshes[i].Effects.Count; j++)
                {
                    var effect = Model.Meshes[i].Effects[j] as BasicEffect;
                    if (effect != null)
                    {
                        effect.World = transforms[Model.Meshes[i].ParentBone.Index] * WorldTransform;
                        effect.View = viewMatrix;
                        effect.Projection = projectionMatrix;

                        if (Texture != null)
                        {
                            effect.TextureEnabled = true;
                            effect.Texture = Texture;
                        }
                        else
                            effect.TextureEnabled = false;
                    }
                }
                Model.Meshes[i].Draw();
            }
        }
开发者ID:VICOGameStudio-Ujen,项目名称:igf,代码行数:33,代码来源:DisplayModel.cs


示例5: ResetCamera

 public void ResetCamera()
 {
     Position = Vector3.Zero;
       Target = Vector3.Zero;
       ViewMatrix = Matrix.Identity;
       ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), Engine.Video.GraphicsDevice.Viewport.AspectRatio, 0.5f, 500f);
 }
开发者ID:PhoenixWright,项目名称:Mystery,代码行数:7,代码来源:Camera3D.cs


示例6: Draw

        public static void Draw(this BoundingFrustum frustum, GraphicsDevice graphicsDevice, Matrix view, Matrix projection, Color color)
        {
            if (effect == null)
            {
                effect = new BasicEffect(graphicsDevice);
                effect.VertexColorEnabled = true;
                effect.LightingEnabled = false;
            }

            Vector3[] corners = frustum.GetCorners();
            for (int i = 0; i < 8; i++)
            {
                verts[i].Position = corners[i];
                verts[i].Color = color;
            }

            effect.View = view;
            effect.Projection = projection;
            foreach (var t in effect.Techniques)
                foreach (var p in t.Passes)
                {
                    p.Apply();

                    graphicsDevice.DrawUserIndexedPrimitives(
                        PrimitiveType.LineList, verts, 0, 8,
                        indices, 0, indices.Length / 2);

                }
        }
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:29,代码来源:FrustumPrimitive.cs


示例7: Draw

 public void Draw(Matrix view, Matrix projection)
 {
     Effect.Projection = projection;
     Effect.View = view;
     Effect.CurrentTechnique.Passes[0].Apply();
     Device.DrawUserPrimitives(PrimitiveType.LineList, Vertices, 0, 3);
 }
开发者ID:Hammerstad,项目名称:CustomerDrivenProject,代码行数:7,代码来源:Axis.cs


示例8: EnvironmentBatch

 public EnvironmentBatch(GraphicsDevice device, ContentManager content, Matrix projection)
 {
     _environmentEffect = content.Load<Effect>("AmbientEffect");
     _environmentEffect.Parameters["BaseTexture"].SetValue(content.Load<Texture2D>("Drydock Floor"));
     _environmentEffect.Parameters["Projection"].SetValue(projection);
     _environmentEffect.Parameters["World"].SetValue(Matrix.CreateScale(_environmentScale));
 }
开发者ID:bsamuels453,项目名称:Drydock,代码行数:7,代码来源:EnvironmentBatch.cs


示例9: Draw

        public void Draw(Scattaring fx)
        {
            Matrix[] modelTansforms = new Matrix[Fbx.Bones.Count];
            Fbx.CopyAbsoluteBoneTransformsTo(modelTansforms);

            foreach (ModelMesh mesh in Fbx.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    Matrix world = modelTansforms[mesh.ParentBone.Index] * fx.WorldMatrix;
                    currentEffect.Parameters["WorldViewProj"].SetValue(world * fx.viewProjection);
                    currentEffect.Parameters["WorldInverseTranspose"].SetValue(fx.invertTransposeWorld);
                    currentEffect.Parameters["World"].SetValue(world);
                    currentEffect.Parameters["ViewInv"].SetValue(fx.invertView);

                    currentEffect.Parameters["LightDirection"].SetValue(fx.lightDirection);
                    currentEffect.Parameters["LightColor"].SetValue(fx.lightColor);
                    currentEffect.Parameters["LightColorAmbient"].SetValue(fx.lightColorAmbient);
                    currentEffect.Parameters["FogColor"].SetValue(fx.fogColor);
                    currentEffect.Parameters["fDensity"].SetValue(fx.fogDensity);
                    currentEffect.Parameters["SunLightness"].SetValue(fx.sunLightness);
                    currentEffect.Parameters["sunRadiusAttenuation"].SetValue(fx.sunRadiusAttenuation);
                    currentEffect.Parameters["largeSunLightness"].SetValue(fx.largeSunLightness);
                    currentEffect.Parameters["largeSunRadiusAttenuation"].SetValue(fx.largeSunRadiusAttenuation);
                    currentEffect.Parameters["dayToSunsetSharpness"].SetValue(fx.dayToSunsetSharpness);
                    currentEffect.Parameters["hazeTopAltitude"].SetValue(fx.hazeTopAltitude);
                }
                mesh.Draw();
            }
        }
开发者ID:Andrusza,项目名称:PiratesArr,代码行数:30,代码来源:ObjectSkydome.cs


示例10: Lamp

 public Lamp(Game game, Matrix worldMatrix)
     : base(game)
 {
     Name = "Lamp";
     On = true;
     WorldMatrix = worldMatrix;
 }
开发者ID:steinbergerbernd,项目名称:Shaders,代码行数:7,代码来源:Lamp.cs


示例11: Process

        /// <summary>
        /// Processes the particles.
        /// </summary>
        /// <param name="dt">Elapsed time in whole and fractional seconds.</param>
        /// <param name="particleArray">A pointer to an array of particles.</param>
        /// <param name="count">The number of particles which need to be processed.</param>
        protected internal override unsafe void Process(float dt, Particle* particleArray, int count)
        {
            // Create the transformation matrix...
            float h = ((this.HueShift * dt) * Calculator.Pi) / 180f;

            float u = Calculator.Cos(h);
            float w = Calculator.Sin(h);

            Matrix hueTransform = new Matrix(1f, 0f, 0f, 0f,
                                             0f,  u, -w, 0f,
                                             0f,  w,  u, 0f,
                                             0f, 0f, 0f, 1f);

            for (int i = 0; i < count; i++)
            {
                Particle* particle = (particleArray + i);

                Vector4 colour;

                // Convert the current colour of the particle to YIQ colour space...
                Vector4.Transform(ref particle->Colour, ref HueShiftModifier.YIQTransformMatrix, out colour);

                // Transform the colour in YIQ space...
                Vector4.Transform(ref colour, ref hueTransform, out colour);

                // Convert the colour back to RGB...
                Vector4.Transform(ref colour, ref HueShiftModifier.RGBTransformMatrix, out colour);

                // And apply back to the particle...
                particle->Colour.X = colour.X;
                particle->Colour.Y = colour.Y;
                particle->Colour.Z = colour.Z;
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:40,代码来源:HueShiftModifier.cs


示例12: Draw

        /*
         * Draw
         *
         * This function will draw the current menu
         *
         * SpriteBatch spriteBatch: The current sprite batch used to draw
         *
         * GraphicsDeviceManager graphics: The current graphics manager
         */
        public void Draw(SpriteBatch spriteBatch, GraphicsDeviceManager graphics, Matrix scale)
        {
            spriteBatch.Begin(SpriteSortMode.Immediate,
                BlendState.AlphaBlend,
                SamplerState.LinearClamp,
                DepthStencilState.None,
                RasterizerState.CullCounterClockwise,
                null,
                scale);

            var mSize = new float[2] { _mScreenRect.Width / (float)graphics.GraphicsDevice.Viewport.Width, _mScreenRect.Height / (float)graphics.GraphicsDevice.Viewport.Height };

            spriteBatch.Draw(_mTrans, graphics.GraphicsDevice.Viewport.Bounds, Color.White);

            spriteBatch.Draw(_mTitle, new Rectangle(_mScreenRect.Center.X - (int)(_mTitle.Width * mSize[0]) / 2, _mScreenRect.Top, (int)(_mTitle.Width * mSize[0]), (int)(_mTitle.Height * mSize[1])), Color.White);

            var currentLocation = new Vector2(_mScreenRect.Left, _mScreenRect.Top + (int)(_mTitle.Height * mSize[1]));
            var height = _mScreenRect.Height - (int)(_mTitle.Height * mSize[1]);
            height -= ((int)(_mItems[0].Height * mSize[1]) + (int)(_mItems[1].Height * mSize[1]) + (int)(_mItems[2].Height * mSize[1]));
            height /= 2;
            currentLocation.Y += height;
            for (var i = 0; i < NumOptions; i++)
            {
                spriteBatch.Draw(_mItems[i], new Rectangle(_mScreenRect.Center.X - ((int)(_mItems[i].Width * mSize[0]) / 2), (int)currentLocation.Y, (int)(_mItems[i].Width * mSize[0]), (int)(_mItems[i].Height * mSize[1])), Color.White);
                currentLocation.Y += (int)(_mItems[i].Height * mSize[1]);
            }

            spriteBatch.End();
        }
开发者ID:DizWARE,项目名称:Mr-Gravity,代码行数:38,代码来源:AfterScore.cs


示例13: RectangleProjection

 public RectangleProjection(RectangleF rectangle, Matrix transform)
 {
     Vertices[0] = Vector2.Transform(rectangle.TopLeft, transform);
     Vertices[1] = Vector2.Transform(rectangle.TopRight, transform);
     Vertices[2] = Vector2.Transform(rectangle.BottomLeft, transform);
     Vertices[3] = Vector2.Transform(rectangle.BottomRight, transform);
 }
开发者ID:victorMoneratto,项目名称:infinite-island,代码行数:7,代码来源:RectangleProjection.cs


示例14: Transform

        public void Transform()
        {
            // STANDART OVERLOADS TEST

            var expectedResult1 = new Vector3(51, 58, 65);
            var expectedResult2 = new Vector3(33, -14, -1);

            var v1 = new Vector3(1, 2, 3);
            var m1 = new Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);

            var v2 = new Vector3(1, 2, 3);
            var q1 = new Quaternion(2, 3, 4, 5);

            Vector3 result1;
            Vector3 result2;

            Assert.That(expectedResult1, Is.EqualTo(Vector3.Transform(v1, m1)).Using(Vector3Comparer.Epsilon));
            Assert.That(expectedResult2, Is.EqualTo(Vector3.Transform(v2, q1)).Using(Vector3Comparer.Epsilon));

            // OUTPUT OVERLOADS TEST

            Vector3.Transform(ref v1, ref m1, out result1);
            Vector3.Transform(ref v2, ref q1, out result2);

            Assert.That(expectedResult1, Is.EqualTo(result1).Using(Vector3Comparer.Epsilon));
            Assert.That(expectedResult2, Is.EqualTo(result2).Using(Vector3Comparer.Epsilon));
        }
开发者ID:Zodge,项目名称:MonoGame,代码行数:27,代码来源:Vector3Test.cs


示例15: Draw

        public override void Draw(GameTime gameTime)
        {
            Vector3 cameraPosition = MathConverter.Convert(_manager.Camera.Position);

            Matrix[] transforms = new Matrix[_model.Bones.Count];
            _model.CopyAbsoluteBoneTransformsTo(transforms);
            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    if (_texture != null)
                    {
                        effect.TextureEnabled = true;
                        effect.Texture = _texture;
                    }
                    effect.EnableDefaultLighting();
                    effect.Projection = MathConverter.Convert(_manager.Camera.ProjectionMatrix);
                    effect.View = MathConverter.Convert(_manager.Camera.ViewMatrix);
                    effect.World = Matrix.CreateScale(3000) * Matrix.CreateTranslation(cameraPosition.X, cameraPosition.Y, cameraPosition.Z);
                }

                mesh.Draw();
            }

            base.Draw(gameTime);
        }
开发者ID:boddie,项目名称:AsteroidDestroyer,代码行数:26,代码来源:Skybox.cs


示例16: Draw

        protected override void Draw(Matrix worldTransform, Color overlayColor, float overlayColorWeight, bool tryCull)
        {
            BoundingBox[,] transformedBoundingBoxes = new BoundingBox[mBoundingBoxes.GetLength(0), mBoundingBoxes.GetLength(1)];
            for (int row = 0; row < mBoundingBoxes.GetLength(0); ++row)
            {
                for (int col = 0; col < mBoundingBoxes.GetLength(1); ++col)
                {
                    transformedBoundingBoxes[row, col] = new BoundingBox(Vector3.Transform(mBoundingBoxes[row, col].Min, worldTransform), Vector3.Transform(mBoundingBoxes[row, col].Max, worldTransform));
                }
            }

            TerrainRenderer.TerrainParameters parameters = new TerrainRenderer.TerrainParameters();
            parameters.BoundingBoxes = transformedBoundingBoxes;
            parameters.DrawCursor = DrawCursor;
            parameters.CursorPosition = CursorPosition;
            parameters.CursorInnerRadius = CursorInnerRadius;
            parameters.CursorOuterRadius = CursorOuterRadius;
            parameters.Name = Name;
            parameters.OverlayColor = overlayColor;
            parameters.OverlayWeight = overlayColorWeight;
            parameters.TextureMask = LayerMask;
            parameters.TryCull = tryCull;
            parameters.World = worldTransform;

            GraphicsManager.EnqueueRenderable(parameters, RendererType);
        }
开发者ID:thormme,项目名称:Chimera,代码行数:26,代码来源:TerrainRenderable.cs


示例17: ComputeMatrix

        public static Matrix ComputeMatrix(Vector2 size, Vector2 ptUL, Vector2 ptUR, 
                                                         Vector2 ptLL, Vector2 ptLR)
        {
            // Scale transform
            Matrix S = Matrix.CreateScale(1 / size.X, 1 / size.Y, 1);

            // Affine transform
            Matrix A = ComputeAffineTransform(ptUL, ptUR, ptLL);

            // Non-Affine transform
            Matrix B = new Matrix();
            float den = A.M11 * A.M22 - A.M12 * A.M21;
            float a = (A.M22 * ptLR.X - A.M21 * ptLR.Y +
                       A.M21 * A.M42 - A.M22 * A.M41) / den;

            float b = (A.M11 * ptLR.Y - A.M12 * ptLR.X +
                       A.M12 * A.M41 - A.M11 * A.M42) / den;

            B.M11 = a / (a + b - 1);
            B.M22 = b / (a + b - 1);
            B.M33 = 1;
            B.M14 = B.M11 - 1;
            B.M24 = B.M22 - 1;
            B.M44 = 1;

            // Product of three transforms
            return S * B * A;
        }
开发者ID:uhealin,项目名称:asskicker,代码行数:28,代码来源:MatrixHelper.cs


示例18: BaseCamera

 /// <summary>
 /// Simply set the matrices.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="projection">The bad.</param>
 public BaseCamera(Matrix view, Matrix projection)
 {
     this.View = view;
     this.Projection = projection;
     if (ProjectionChanged != null)
         ProjectionChanged(this);
 }
开发者ID:koenbollen,项目名称:canyon,代码行数:12,代码来源:BaseCamera.cs


示例19: RebootPOSTEffect

 public RebootPOSTEffect()
   : base("RebootPOSTEffect")
 {
   this.texture = new SemanticMappedTexture(this.effect.Parameters, "BaseTexture");
   this.pseudoWorldMatrix = new SemanticMappedMatrix(this.effect.Parameters, "PseudoWorldMatrix");
   this.PseudoWorld = Matrix.Identity;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:7,代码来源:RebootPOSTEffect.cs


示例20: Draw

        /// <summary>
        /// 
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            Game.GraphicsDevice.RenderState.DepthBufferWriteEnable = true;
            Game.GraphicsDevice.RenderState.DepthBufferEnable = true;
            Game.GraphicsDevice.RenderState.AlphaBlendEnable = false;
            Game.GraphicsDevice.RenderState.AlphaTestEnable = false;

            var transforms = new Matrix[_cube.Bones.Count];
            _cube.CopyAbsoluteBoneTransformsTo(transforms);

            const int cols = 10, rows = 10;

            for (int z = -rows/2; z < rows/2; z++)
                for (int x = -cols/2; x < cols/2; x++)
                {
                    foreach (ModelMesh mesh in _cube.Meshes)
                    {
                        foreach (BasicEffect effect in mesh.Effects)
                        {
                            effect.EnableDefaultLighting();
                            effect.View = _basicEffect.View;
                            effect.Projection = _basicEffect.Projection;
                            effect.World = transforms[mesh.ParentBone.Index]*
                                           Matrix.CreateScale(0.01f, 0.005f, 0.01f)*
                                           Matrix.CreateTranslation(x/1.0f, -0.5f, z/1.0f);
                        }
                        mesh.Draw();
                    }
                }

            base.Draw(gameTime);
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:36,代码来源:Ground.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Framework.Point类代码示例发布时间:2022-05-26
下一篇:
C# Framework.GraphicsDeviceManager类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap