void RenderExclusionZone(CommandBuffer buffer, ExclusionZone ex) { if (ex.Shell == null) return; Vector3 sz = Vector3.Zero; //Only render ellipsoid and sphere exteriors if (Nebula.Zone.Shape is ZoneEllipsoid) sz = ((ZoneEllipsoid)Nebula.Zone.Shape).Size / 2; //we want radius instead of diameter else if (Nebula.Zone.Shape is ZoneSphere) sz = new Vector3(((ZoneSphere)Nebula.Zone.Shape).Radius); else return; sz *= (1 / ex.Shell.GetRadius()); var world = Matrix4.CreateScale(ex.ShellScalar * sz) * ex.Zone.RotationMatrix * Matrix4.CreateTranslation(ex.Zone.Position); var shell = (ModelFile)ex.Shell; //Calculate Alpha var alpha = ex.ShellMaxAlpha * CalculateTransition(ex.Zone); //Set all render materials. We don't want LOD for this Mesh. var l0 = shell.Levels[0]; for (int i = l0.StartMesh; (i < l0.StartMesh + l0.MeshCount); i++) { var mat = (BasicMaterial)l0.Mesh.Meshes[i].Material.Render; mat.Oc = alpha; mat.OcEnabled = true; mat.AlphaEnabled = true; mat.Dc = new Color4(ex.ShellTint, 1) * (Nebula.AmbientColor ?? Color4.White); } //Render l0.Update(camera, TimeSpan.Zero); l0.DrawBuffer(buffer, world, ref Lighting.Empty, null); }
void RenderExclusionZone(CommandBuffer buffer, ExclusionZone ex) { if (ex.Shell == null) { return; } if (ex.ShellModel == null) { var file = (IRigidModelFile)ex.Shell.LoadFile(resman); file.Initialize(resman); ex.ShellModel = file.CreateRigidModel(true); } Vector3 sz = Vector3.Zero; //Only render ellipsoid and sphere exteriors if (Nebula.Zone.Shape is ZoneEllipsoid) { sz = ((ZoneEllipsoid)Nebula.Zone.Shape).Size / 2; //we want radius instead of diameter } else if (Nebula.Zone.Shape is ZoneSphere) { sz = new Vector3(((ZoneSphere)Nebula.Zone.Shape).Radius); } else { return; } sz *= (1 / ex.ShellModel.GetRadius()); var world = Matrix4x4.CreateScale(ex.ShellScalar * sz) * ex.Zone.RotationMatrix * Matrix4x4.CreateTranslation(ex.Zone.Position); //var shell = (ModelFile)ex.Shell; //Calculate Alpha var alpha = ex.ShellMaxAlpha * CalculateTransition(ex.Zone); //Set all render materials. We don't want LOD for this Mesh. foreach (var pt in ex.ShellModel.AllParts) { foreach (var dc in pt.Mesh.Levels[0]) { var mat = dc.GetMaterial(resman)?.Render; if (mat is BasicMaterial basic) { basic.Oc = alpha; basic.OcEnabled = true; basic.AlphaEnabled = true; basic.Dc = new Color4(ex.ShellTint, alpha) * (Nebula.AmbientColor ?? Color4.White); } } } ex.ShellModel.Update(camera, 0.0, resman); ex.ShellModel.DrawBuffer(0, buffer, resman, world, ref Lighting.Empty); }