本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}