public void Setup() { renderData = Substitute.For <IRenderData>(); renderHexMeshData = new RenderHexMeshData(); renderOperations = new RenderOperations( renderData, renderHexMeshData ); }
public void PrepareRenderOperations(Vector3 position, float radius, RenderOperations operations, bool shadowCastersOnly = false) { var zero = Vector3.Zero; Vector3 meshPosition; for (var i = 0; i < Meshes.Count; i++) { var meshInstance = Meshes[i]; var subMeshes = meshInstance.Mesh.SubMeshes; Vector3.Transform(ref zero, ref meshInstance.World, out meshPosition); if (!meshInstance.Mesh.IsLoaded()) continue; if ((!shadowCastersOnly || meshInstance.CastShadows) && Math.Intersections.SphereToSphere(ref position, radius, ref meshPosition, meshInstance.Mesh.BoundingSphereRadius)) { for (var j = 0; j < subMeshes.Length; j++) { var subMesh = subMeshes[j]; operations.Add(subMesh.Handle, meshInstance.World, subMesh.Material, meshInstance.Skeleton, false, meshInstance.CastShadows); } } } }
public void PrepareRenderOperations(Matrix4 viewMatrix, RenderOperations operations, bool shadowCastersOnly = false, bool frustumCull = true) { Frustum.Matrix = viewMatrix; var sphere = new BoundingSphere(); var zero = Vector3.Zero; for (var i = 0; i < Meshes.Count; i++) { var meshInstance = Meshes[i]; var subMeshes = meshInstance.Mesh.SubMeshes; if (!meshInstance.Mesh.IsLoaded()) continue; if (!meshInstance.CastShadows && shadowCastersOnly) continue; Vector3.Transform(ref zero, ref meshInstance.World, out sphere.Center); for (var j = 0; j < subMeshes.Length; j++) { var subMesh = subMeshes[j]; sphere.Radius = subMesh.BoundingSphereRadius; if (!frustumCull || Frustum.Intersects(sphere)) { operations.Add(subMesh.Handle, meshInstance.World, subMesh.Material, meshInstance.Skeleton, false, meshInstance.CastShadows); } } } }