/// <returns>True if the section was found</returns> static void RecordMeshSectionCommands(MeshId model, MyRenderableComponent rendercomp, MyRenderLod renderLod, MyHighlightDesc desc) { MeshSectionId sectionId; bool found = MyMeshes.TryGetMeshSection(model, rendercomp.CurrentLod, desc.SectionName, out sectionId); if (!found) { return; } WriteHighlightConstants(ref desc); MyMeshSectionInfo1 section = sectionId.Info; MyMeshSectionPartInfo1[] meshes = section.Meshes; for (int idx = 0; idx < meshes.Length; idx++) { MyMeshSectionPartInfo1 sectionInfo = meshes[idx]; if (renderLod.RenderableProxies.Length <= sectionInfo.PartIndex) { DebugRecordMeshPartCommands(model, desc.SectionName, rendercomp, renderLod, meshes, idx); return; } MyRenderableProxy proxy = renderLod.RenderableProxies[sectionInfo.PartIndex]; MyHighlightPass.Instance.RecordCommands(proxy, sectionInfo.PartSubmeshIndex, desc.InstanceId); } }
/// <returns>True if the section was found</returns> private static bool RecordMeshSectionCommands(MeshId model, LodMeshId lodModelId, MyRenderableComponent rendercomp, MyRenderLod renderLod, MyOutlineDesc desc, ref OutlineConstantsLayout constants, ref float maxThickness) { MeshSectionId sectionId; bool found = MyMeshes.TryGetMeshSection(model, rendercomp.CurrentLod, desc.SectionIndex, out sectionId); if (!found) { return(false); } MyMeshSectionInfo1 section = sectionId.Info; MyMeshSectionPartInfo1[] meshes = section.Meshes; for (int idx = 0; idx < meshes.Length; idx++) { maxThickness = Math.Max(desc.Thickness, maxThickness); constants.Color = desc.Color.ToVector4(); var mapping = MyMapping.MapDiscard(MyCommon.OutlineConstants); mapping.WriteAndPosition(ref constants); mapping.Unmap(); RC.BindShaders(renderLod.HighlightShaders[meshes[idx].PartIndex]); MyRenderableProxy proxy = renderLod.RenderableProxies[meshes[idx].PartIndex]; MyOutlinePass.Instance.RecordCommands(proxy, meshes[idx].PartSubmeshIndex); } return(true); }
private static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group, MyCullProxy_2 proxy, MyOutlineDesc desc, ref float maxThickness) { MeshSectionId sectionId; bool found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionIndex, out sectionId); if (!found) { return; } OutlineConstantsLayout constants = new OutlineConstantsLayout(); maxThickness = Math.Max(desc.Thickness, maxThickness); constants.Color = desc.Color.ToVector4(); if (desc.PulseTimeInFrames > 0) { constants.Color.W *= (float)Math.Pow((float)Math.Cos(2.0 * Math.PI * (float)MyRender11.Settings.GameplayFrame / (float)desc.PulseTimeInFrames), 2.0); } MyMeshSectionInfo1 section = sectionId.Info; MyMeshSectionPartInfo1[] meshes = section.Meshes; for (int idx = 0; idx < meshes.Length; idx++) { MyMaterialMergeGroup materialGroup; found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup); if (!found) { DebugRecordMeshPartCommands(model, desc.SectionIndex, meshes[idx].Material); return; } int actorIndex; found = materialGroup.TryGetActorIndex(actor, out actorIndex); if (!found) { return; } var mapping = MyMapping.MapDiscard(MyCommon.OutlineConstants); mapping.WriteAndPosition(ref constants); mapping.Unmap(); MyOutlinePass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex); } }
/// <returns>True if the section was found</returns> private static void RecordMeshSectionCommands(MeshId model, LodMeshId lodModelId, MyRenderableComponent rendercomp, MyRenderLod renderLod, MyOutlineDesc desc, ref float maxThickness) { MeshSectionId sectionId; bool found = MyMeshes.TryGetMeshSection(model, rendercomp.CurrentLod, desc.SectionIndex, out sectionId); if (!found) { return; } OutlineConstantsLayout constants = new OutlineConstantsLayout(); MyMeshSectionInfo1 section = sectionId.Info; MyMeshSectionPartInfo1[] meshes = section.Meshes; for (int idx = 0; idx < meshes.Length; idx++) { MyMeshSectionPartInfo1 sectionInfo = meshes[idx]; if (renderLod.RenderableProxies.Length <= sectionInfo.PartIndex) { DebugRecordMeshPartCommands(model, desc.SectionIndex, rendercomp, renderLod, meshes, idx); return; } maxThickness = Math.Max(desc.Thickness, maxThickness); constants.Color = desc.Color.ToVector4(); if (desc.PulseTimeInFrames > 0) { constants.Color.W *= (float)Math.Pow((float)Math.Cos(2.0 * Math.PI * (float)MyRender11.Settings.GameplayFrame / (float)desc.PulseTimeInFrames), 2.0); } var mapping = MyMapping.MapDiscard(MyCommon.OutlineConstants); mapping.WriteAndPosition(ref constants); mapping.Unmap(); RC.BindShaders(renderLod.HighlightShaders[sectionInfo.PartIndex]); MyRenderableProxy proxy = renderLod.RenderableProxies[sectionInfo.PartIndex]; MyOutlinePass.Instance.RecordCommands(proxy, sectionInfo.PartSubmeshIndex, desc.InstanceId); } return; }
static void RecordMeshPartCommands(MeshId model, MyActor actor, MyGroupRootComponent group, MyCullProxy_2 proxy, MyHighlightDesc desc) { MeshSectionId sectionId; bool found = MyMeshes.TryGetMeshSection(model, 0, desc.SectionName, out sectionId); if (!found) { return; } WriteHighlightConstants(ref desc); MyMeshSectionInfo1 section = sectionId.Info; MyMeshSectionPartInfo1[] meshes = section.Meshes; for (int idx = 0; idx < meshes.Length; idx++) { MyMaterialMergeGroup materialGroup; found = group.TryGetMaterialGroup(meshes[idx].Material, out materialGroup); if (!found) { DebugRecordMeshPartCommands(model, desc.SectionName, meshes[idx].Material); return; } int actorIndex; found = materialGroup.TryGetActorIndex(actor, out actorIndex); if (!found) { return; } MyHighlightPass.Instance.RecordCommands(ref proxy.Proxies[materialGroup.Index], actorIndex, meshes[idx].PartIndex); } }