コード例 #1
0
        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 = group.GetMaterialGroup(meshes[idx].Material);
                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);
            }
        }