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


C# Matrix4x4.ToXNA方法代码示例

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


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

示例1: Draw

		public static void Draw(GameTime gameTime, Matrix4x4 view, Matrix4x4 projection)
		{
            // Update our effect with the matrices.
            _effect.View = view.ToXNA();
            _effect.Projection = projection.ToXNA();

            // Calculate the total number of vertices we're going to be rendering.
            int vertexCount = 0;
            foreach (var shape in _activeShapes)
                vertexCount += shape.LineCount * 2;

            // If we have some vertices to draw
            if (vertexCount > 0)
			{
                // Make sure our array is large enough
                if (_verts.Length < vertexCount)
                {
                    // If we have to resize, we make our array twice as large as necessary so
                    // we hopefully won't have to resize it for a while.
                    _verts = new VertexPositionColor[vertexCount * 2];
                }

                // Now go through the shapes again to move the vertices to our array and
                // add up the number of lines to draw.
                int lineCount = 0;
                int vertIndex = 0;
                foreach (DebugShape shape in _activeShapes)
                {
                    lineCount += shape.LineCount;
                    int shapeVerts = shape.LineCount * 2;
                    for (int i = 0; i < shapeVerts; i++)
                        _verts[vertIndex++] = shape.Vertices[i];
                }

                // Start our effect to begin rendering.
				_effect.CurrentTechnique.Passes[0].Apply();

                // We draw in a loop because the Reach profile only supports 65,535 primitives. While it's
                // not incredibly likely, if a game tries to render more than 65,535 lines we don't want to
                // crash. We handle this by doing a loop and drawing as many lines as we can at a time, capped
                // at our limit. We then move ahead in our vertex array and draw the next set of lines.
                int vertexOffset = 0;
                while (lineCount > 0)
                {
                    // Figure out how many lines we're going to draw
                    int linesToDraw = Math.Min(lineCount, 65535);

                    // Draw the lines
                    _graphics.DrawUserPrimitives(PrimitiveType.LineList, _verts, vertexOffset, linesToDraw);

                    // Move our vertex offset ahead based on the lines we drew
                    vertexOffset += linesToDraw * 2;

                    // Remove these lines from our total line count
                    lineCount -= linesToDraw;
                }
			}

            // Go through our active shapes and retire any shapes that have expired to the
            // cache list. 
			bool resort = false;
			for (int i = _activeShapes.Count - 1; i >= 0; i--)
			{
				DebugShape s = _activeShapes[i];
                s.Lifetime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
				if (s.Lifetime <= 0)
				{
					_cachedShapes.Add(s);
					_activeShapes.RemoveAt(i);
					resort = true;
				}
			}

            // If we move any shapes around, we need to resort the cached list
            // to ensure that the smallest shapes are first in the list.
			if (resort)
				_cachedShapes.Sort(CachedShapesSort);
        }
开发者ID:xoxota99,项目名称:Myre,代码行数:78,代码来源:DebugShapeRenderer.cs

示例2: SetValue

        public static void SetValue(this EffectParameter collection, Matrix4x4 value)
        {
            Contract.Requires(collection != null);

            collection.SetValue(value.ToXNA());
        }
开发者ID:martindevans,项目名称:Myre,代码行数:6,代码来源:EffectParameterExtensions.cs

示例3: SetValue

 public static void SetValue(this EffectParameter collection, Matrix4x4 value)
 {
     collection.SetValue(value.ToXNA());
 }
开发者ID:xoxota99,项目名称:Myre,代码行数:4,代码来源:EffectParameterExtensions.cs


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