public void DrawBuffer(CommandBuffer buffer, Matrix4 world, ref Lighting lighting, Material overrideMat = null) { if (SideMaterials.Length < 6) { return; } if (ready) { for (int i = 0; i < SideMaterials.Length; i++) { if (SideMaterials[i] != null && !SideMaterials[i].Loaded) { SideMaterials[i].Loaded = false; } } for (int i = 0; i < 6; i++) { int start, count; Vector3 pos; sphere.GetDrawParameters(faces[i], out start, out count, out pos); if (SideMaterials[i] == null) { SideMaterials[i] = library.FindMaterial(CrcTool.FLModelCrc(sideMaterialNames[i])); } var mat = SideMaterials[i] ?? defaultMaterial; mat = overrideMat ?? mat; mat.Render.Camera = _camera; var transform = Matrix4.CreateScale(Radius) * world; buffer.AddCommand( mat.Render, null, transform, lighting, sphere.VertexBuffer, PrimitiveTypes.TriangleList, 0, start, count, SortLayers.OBJECT ); } //Draw atmosphere if (SideMaterials.Length > 6 && overrideMat == null) { if (SideMaterials[6] == null) { SideMaterials[6] = library.FindMaterial(CrcTool.FLModelCrc(sideMaterialNames[6])); if (SideMaterials[6] == null) { return; } } var mat = (AtmosphereMaterial)SideMaterials[6].Render; var transform = Matrix4.CreateScale(Radius * mat.Scale) * world; for (int i = 0; i < 6; i++) { int start, count; Vector3 pos; sphere.GetDrawParameters(faces[i], out start, out count, out pos); SideMaterials[6].Render.Camera = _camera; buffer.AddCommand( SideMaterials[6].Render, null, transform, lighting, sphere.VertexBuffer, PrimitiveTypes.TriangleList, 0, start, count, SortLayers.OBJECT, RenderHelpers.GetZ(transform, _camera.Position, pos) ); } } } else { throw new Exception(); } }
public Material FindMaterial(uint materialId) { return(additionalLibrary.FindMaterial(materialId)); }