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


C# Camera.BatchRender方法代码示例

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


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

示例1: Draw

        public override void Draw(GraphicsDevice device, Camera cam)
        {
            if (filter == null)
            {
                return;
            }

            Mesh mesh = filter.meshToRender;
            BoundingSphere sphere = new BoundingSphere(transform.TransformPoint(filter.boundingSphere.Center), filter.boundingSphere.Radius * Math.Max(transform.lossyScale.x, Math.Max(transform.lossyScale.y, transform.lossyScale.z)));
            bool cull = cam.DoFrustumCulling(ref sphere);
            if (cull)
            {
            #if DEBUG
                if (Camera.logRenderCalls)
                {
                    Debug.LogFormat("VP cull mesh {0} with center {1} radius {2} cam {3} at {4}", gameObject, sphere.Center, sphere.Radius, cam.gameObject, cam.transform.position);
                }
            #endif
                return;
            }

            if (filter.CanBatch())
            {
                cam.BatchRender(filter.meshToRender, sharedMaterials, transform);
            }
        }
开发者ID:iamjianxin,项目名称:FFWD,代码行数:26,代码来源:MeshRenderer.cs

示例2: Draw

        public override int Draw(GraphicsDevice device, Camera cam)
        {
            if (filter == null)
            {
                return 0;
            }

            BoundingSphere sphere = new BoundingSphere((Microsoft.Xna.Framework.Vector3)transform.position + filter.boundingSphere.Center, filter.boundingSphere.Radius * transform.lossyScale.sqrMagnitude);
            if (cam.DoFrustumCulling(ref sphere))
            {
            #if DEBUG
                if (Camera.logRenderCalls)
                {
                    Debug.LogFormat("VP cull {0} with radius {1} pos {2} cam {3} at {4}", gameObject, filter.boundingSphere.Radius, transform.position, cam.gameObject, cam.transform.position);
                }
            #endif
                return 0;
            }

            // NOTE: I don't want to look at this now... Use the old rendering method.
            if (false /*vBuffer != null */)
            {
                device.SetVertexBuffer(vBuffer);
                IndexBuffer iBuffer = filter.mesh.GetIndexBuffer();
                device.Indices = iBuffer;
                if (material != null)
                {
                    Render(device, cam, material, vBuffer.VertexCount, iBuffer.IndexCount / 3);
                    //for (int i = 1; i < sharedMaterials.Length; i++)
                    //{
                    //    sharedMaterials[i].Render(vBuffer, iBuffer);
                    //}
                }
                else
                {
                    Debug.LogFormat("We have no material for {0}, so it is not rendered", this);
                }
            }
            else
            {
                if (filter.CanBatch())
                {
                    return cam.BatchRender(filter.meshToRender, sharedMaterials, transform);
                }
            }

            return 0;
        }
开发者ID:CodeHelix,项目名称:FFWD,代码行数:48,代码来源:MeshRenderer.cs

示例3: Draw

        public override void Draw(GraphicsDevice device, Camera cam)
        {
            if (filter == null)
            {
                return;
            }

            BoundingSphere sphere = new BoundingSphere((Microsoft.Xna.Framework.Vector3)transform.position + filter.boundingSphere.Center, filter.boundingSphere.Radius * transform.lossyScale.sqrMagnitude);
            if (cam.DoFrustumCulling(ref sphere))
            {
            #if DEBUG
                if (Camera.logRenderCalls)
                {
                    Debug.LogFormat("VP cull {0} with radius {1} pos {2} cam {3} at {4}", gameObject, filter.boundingSphere.Radius, transform.position, cam.gameObject, cam.transform.position);
                }
            #endif
                return;
            }

            if (filter.CanBatch())
            {
                cam.BatchRender(filter.meshToRender, sharedMaterials, transform);
            }
        }
开发者ID:gamekingdom,项目名称:FFWD,代码行数:24,代码来源:MeshRenderer.cs

示例4: Draw

        public override void Draw(GraphicsDevice device, Camera cam)
        {
            if (sharedMesh == null)
            {
                return;
            }

            // Check the frustum of the camera
            BoundingSphere sphere = new BoundingSphere(transform.TransformPoint(sharedMesh.bounds.boundingSphere.Center), sharedMesh.bounds.boundingSphere.Radius * Math.Abs(Math.Max(transform.lossyScale.x, Math.Max(transform.lossyScale.y, transform.lossyScale.z))));
            if (cam.DoFrustumCulling(ref sphere))
            {
            #if DEBUG
                if (Camera.logRenderCalls)
                {
                    Debug.LogFormat("VP cull skinned {0} with radius {1} pos {2} cam {3} at {4}", gameObject, sphere.Radius, sphere.Center, cam.gameObject, cam.transform.position);
                }
            #endif
                return;
            }

            if (sharedMesh.boneWeights != null)
            {
                // This is the rendering of data gotten directly from Unity
                //Matrix world = transform.world;
                Matrix world = Matrix.Identity;
                // Find the current bone data from the bone Transform.
                for (int i = 0; i < bones.Length; i++)
                {
                    bindPoses[i] = Matrix.Identity;
                    //bindPoses[i] = bones[i].world * Matrix.Invert(transform.world);
                    bindPoses[i] = sharedMesh.bindPoses[i] * bones[i].world;
                    //Debug.Log(bones[i].name + " : " + bones[i].localPosition);
                }

                // We have blended parts that does not come from a bone structure
                for (int i = 0; i < sharedMesh._vertices.Length; i++)
                {
                    CpuSkinningHelpers.SkinVertex(
                        bindPoses,
                        ref sharedMesh._vertices[i],
                        ref sharedMesh._normals[i],
                        ref world,
                        ref sharedMesh.boneWeights[i],
                        out mesh._vertices[i],
                        out mesh._normals[i]);
                }
                cam.BatchRender(mesh, sharedMaterials, null);
            }
        }
开发者ID:Joelone,项目名称:FFWD,代码行数:49,代码来源:SkinnedMeshRenderer.cs


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