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


C# RenderHelper.RenderUserIndexedPrimitive方法代码示例

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


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

示例1: DebugDrawn

        /// <summary>
        /// Draw the physic world in debug mode.
        /// </summary>
        /// <param name="render">The render helper.</param>
        /// <param name="gt">The gt.</param>
        /// <param name="cam">The cam.</param>
        protected override void DebugDrawn(RenderHelper render, GameTime gt, ICamera cam)
        {
            if (BasicEffect == null)
            {
                BasicEffect = new BasicEffect(render.device);
                BasicEffect.VertexColorEnabled = true;
                BasicEffect.TextureEnabled = false;                
            }

            if (rasterizerState == null)
            {
                rasterizerState = new RasterizerState();
                rasterizerState.CullMode = CullMode.None;
                rasterizerState.FillMode = FillMode.WireFrame;
            }

            render.PushRasterizerState(rasterizerState);


            BasicEffect.View = cam.View;
            BasicEffect.Projection = cam.Projection;            

            foreach (var item in space.Entities)
            {
                if (item.CollisionInformation != null)
                {
                    if (!debugents.ContainsKey(item))
                    {
                            if (item.CollisionInformation.Shape is BoxShape)
                            {
                                debugents.Add(item, DisplayBox.GetDebugInfo(item, Color.Blue));
                            }

                            if (item.CollisionInformation.Shape is CapsuleShape)
                            {
                                debugents.Add(item, DisplayCapsule.GetDebugInfo(item, Color.Blue));
                            }
                            if (item.CollisionInformation.Shape is SphereShape)
                            {
                                debugents.Add(item, DisplaySphere.GetDebugInfo(item, Color.Blue));
                            }

                            if (item.CollisionInformation.Shape is ConeShape)
                            {
                                debugents.Add(item, DisplayCone.GetDebugInfo(item, Color.Blue));
                            }

                            if (item.CollisionInformation.Shape is CylinderShape)
                            {
                                debugents.Add(item, DisplayCylinder.GetDebugInfo(item, Color.Blue));
                            }

                            if (item.CollisionInformation.Shape is MobileMeshShape)
                            {
                                debugents.Add(item, DisplayMobileMesh.GetDebugInfo(item, Color.Blue));
                            }
                            if (item.CollisionInformation.Shape is WrappedShape)
                            {
                                debugents.Add(item, DisplayWrappedBody.GetDebugInfo(item, Color.Blue));
                            }
                            if (item.CollisionInformation.Shape is TransformableShape)
                            {
                                debugents.Add(item, DisplayTransformable.GetDebugInfo(item, Color.Blue));
                            }
                            if (item.CollisionInformation.Shape is MinkowskiSumShape)
                            {
                                debugents.Add(item, DisplayMinkowskiSum.GetDebugInfo(item, Color.Blue));
                            }
                            if (item.CollisionInformation.Shape is ConvexHullShape)
                            {
                                debugents.Add(item, DisplayConvexHull.GetDebugInfo(item, Color.Blue));
                            }
                    }

                    if (debugents.ContainsKey(item))
                    {
                        Vector3 translation = Matrix3X3.Transform(item.CollisionInformation.LocalPosition, item.BufferedStates.InterpolatedStates.OrientationMatrix);
                        translation += item.BufferedStates.InterpolatedStates.Position;
                        Matrix worldTransform = Matrix3X3.ToMatrix4X4(item.BufferedStates.InterpolatedStates.OrientationMatrix);
                        worldTransform.Translation = translation;
                        BasicEffect.World = worldTransform;

                        render.RenderUserIndexedPrimitive<VertexPositionColor>(BasicEffect, PrimitiveType.TriangleList, debugents[item].vertices, 0, debugents[item].vertices.Count(), debugents[item].indices, 0, debugents[item].indices.Count() / 3);
                    }
                }

            }
            render.PopRasterizerState();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:95,代码来源:BepuPhysicWorld.cs

示例2: Draw

        /// <summary>
        /// Draws the box.
        /// </summary>
        /// <param name="render">The render.</param>
        /// <param name="view">The viewing matrix.</param>
        /// <param name="projection">The projection matrix.</param>
        public void Draw(RenderHelper render, Matrix view, Matrix projection)
        {
            if (Visible)
            {                
                //// Setup the effect.                
                DebugBox.effect.View = view;
                DebugBox.effect.Projection = projection;

                Vector3[] corners = BoundingBox.GetCorners();
                for (int i = 0; i < 8; i++)
                {
                    verts[i].Position = corners[i];
                    verts[i].Color = Color;
                }                                                               
                
                render.RenderUserIndexedPrimitive<VertexPositionColor>(effect, PrimitiveType.LineList, verts, 0, verts.Count(), indices, 0, indices.Count() / 2);                                
            }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:24,代码来源:DebugBox.cs


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