Esempio n. 1
0
        internal MyMaterialMergeGroup(MyMeshTableSRV meshTable, MyMeshMaterialId matId, int index)
        {
            m_mergeGroup     = new MyMergeInstancing(meshTable);
            m_rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;
            Index            = index;

            m_actors       = new Dictionary <uint, MyActor>();
            m_actorIndices = new Dictionary <MyActor, int>();
        }
Esempio n. 2
0
        internal static MyMaterialProxyId GetProxyId(MyMeshMaterialId id)
        {
            if (MaterialProxyIndex.ContainsKey(id))
            {
                return(MaterialProxyIndex[id]);
            }

            MyRender11.Log.WriteLine("MeshMaterialId missing");

            return(MaterialProxyIndex[DebugMaterialId]);
        }
Esempio n. 3
0
        internal static MyMeshMaterialId GetMaterialId(ref MyMeshMaterialInfo desc, string assetFile = null)
        {
            var rk = CalculateRK(ref desc);

            if (!MaterialRkIndex.ContainsKey(rk))
            {
                var id = MaterialRkIndex[rk] = new MyMeshMaterialId {
                    Index = MaterialsPool.Allocate()
                };

                desc.Id = id;
                desc.RepresentationKey = rk;

                MaterialsPool.Data[id.Index] = desc;
                MaterialProxyIndex[id]       = MyMaterials1.AllocateProxy();

                MaterialQueryResourcesTable.Add(id);

                var nameIndex = desc.Name;

                if (MERGABLE_MATERIAL_NAMES.Contains(nameIndex))
                {
                    MergableRKs.Add(desc.RepresentationKey);
                }

                if (!MaterialNameIndex.ContainsKey(nameIndex))
                {
                    MaterialNameIndex[nameIndex] = id;
                }
                else if (assetFile != null)
                {
                    VRageRender.MyRender11.Log.WriteLine(String.Format("Asset {0} tries to overrwrite material {1} with different textures", assetFile, desc.Name.ToString()));
                }

                return(id);
            }

            return(MaterialRkIndex[rk]);
        }
Esempio n. 4
0
        internal MyMaterialMergeGroup(MyMeshTableSRV meshTable, MyMeshMaterialId matId, int index)
        {
            m_mergeGroup = new MyMergeInstancing(meshTable);
            m_rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;
            m_index = index;

            m_actors = new HashSet<MyActor>();
        }
Esempio n. 5
0
        internal static void CreateCommonMaterials()
        {
            var nullMatDesc = new MyMeshMaterialInfo
            {
                Name = X.TEXT("__NULL_MATERIAL"),
                ColorMetal_Texture = MyStringId.NullOrEmpty,
                NormalGloss_Texture = MyStringId.NullOrEmpty,
                Extensions_Texture = MyStringId.NullOrEmpty,
                Alphamask_Texture = MyStringId.NullOrEmpty,
                Technique = "MESH"
            };
            NullMaterialId = GetMaterialId(ref nullMatDesc);

            var debugMatDesc = new MyMeshMaterialInfo
            {
                Name = X.TEXT("__DEBUG_MATERIAL"),
                ColorMetal_Texture = MyRender11.DebugMode ? X.TEXT("Pink") : MyStringId.NullOrEmpty,
                NormalGloss_Texture = MyStringId.NullOrEmpty,
                Extensions_Texture = MyStringId.NullOrEmpty,
                Alphamask_Texture = MyStringId.NullOrEmpty,
                Technique = "MESH"
            };
            DebugMaterialId = GetMaterialId(ref debugMatDesc);
        }
Esempio n. 6
0
        internal static MyMeshMaterialId GetMaterialId(ref MyMeshMaterialInfo desc, string assetFile = null)
        {
            var rk = CalculateRK(ref desc);

            if(!MaterialRkIndex.ContainsKey(rk))
            {
                var id = MaterialRkIndex[rk] = new MyMeshMaterialId { Index = MaterialsPool.Allocate() };

                desc.Id = id;
                desc.RepresentationKey = rk;

                MaterialsPool.Data[id.Index] = desc;
                MaterialProxyIndex[id] = MyMaterials1.AllocateProxy();

                MaterialQueryResourcesTable.Add(id);

                var nameIndex = desc.Name;

                if(MERGABLE_MATERIAL_NAMES.Contains(nameIndex))
                {
                    MergableRKs.Add(desc.RepresentationKey);
                }

                if(!MaterialNameIndex.ContainsKey(nameIndex))
                {
                    MaterialNameIndex[nameIndex] = id;
                }
                else if(assetFile != null)
                {
                    VRageRender.MyRender11.Log.WriteLine(String.Format("Asset {0} tries to overrwrite material {1} with different textures", assetFile, desc.Name.ToString()));
                }

                return id;
            }

            return MaterialRkIndex[rk];
        }
Esempio n. 7
0
        internal static MyMaterialProxyId GetProxyId(MyMeshMaterialId id)
        {
            if (MaterialProxyIndex.ContainsKey(id))
            {
                return MaterialProxyIndex[id];
            }

            MyRender11.Log.WriteLine("MeshMaterialId missing");
            
            return MaterialProxyIndex[DebugMaterialId];
        }
Esempio n. 8
0
        public MyMaterialMergeGroup GetMaterialGroup(MyMeshMaterialId matId)
        {
            int rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;

            return(m_materialGroups[rootMaterialRK]);
        }
 public MyMaterialMergeGroup GetMaterialGroup(MyMeshMaterialId matId)
 {
     int rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;
     return m_materialGroups[rootMaterialRK];
 }
Esempio n. 10
0
        internal MyMaterialMergeGroup(MyMeshTableSRV meshTable, MyMeshMaterialId matId, int index)
        {
            m_mergeGroup = new MyMergeInstancing(meshTable);
            m_rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;
            Index = index;

            m_actors = new Dictionary<uint, MyActor>();
            m_actorIndices = new Dictionary<MyActor, int>();
        }
Esempio n. 11
0
 internal void Clear()
 {
     WorldMatrix = MatrixD.Zero;
     CommonObjectData = default(MyObjectDataCommon);
     NonVoxelObjectData = MyObjectDataNonVoxel.Invalid;
     VoxelCommonObjectData = MyObjectDataVoxelCommon.Invalid;
     Mesh = LodMeshId.NULL;
     MergedMesh = MyMergedLodMeshId.NULL;
     Instancing = InstancingId.NULL;
     DepthShaders = MyMaterialShadersBundleId.NULL;
     Shaders = MyMaterialShadersBundleId.NULL;
     ForwardShaders = MyMaterialShadersBundleId.NULL;
     DrawSubmesh = default(MyDrawSubmesh);
     PerMaterialIndex = 0;
     SectionSubmeshes = null;
     InstanceCount = 0;
     StartInstance = 0;
     SkinningMatrices = null;
     Type = MyMaterialType.OPAQUE;
     Flags = 0;
     Lod = 0;
     ObjectBuffer = null;
     Parent = null;
     Material = MyMeshMaterialId.NULL;
     UnusedMaterials = UnusedMaterials ?? new HashSet<string>();
     UnusedMaterials.Clear();
 }
Esempio n. 12
0
 internal static MyMaterialProxyId GetProxyId(MyMeshMaterialId id)
 {
     return(MaterialProxyIndex[id]);
 }
Esempio n. 13
0
        internal static MyMeshMaterialId GetMaterialId(ref MyMeshMaterialInfo desc)
        {
            var rk = CalculateRK(ref desc);

            if(!MaterialRkIndex.ContainsKey(rk))
            {
                var id = MaterialRkIndex[rk] = new MyMeshMaterialId { Index = MaterialsPool.Allocate() };

                desc.Id = id;
                desc.RepresentationKey = rk;

                MaterialsPool.Data[id.Index] = desc;
                MaterialProxyIndex[id] = MyMaterials1.AllocateProxy();

                MaterialQueryResourcesTable.Add(id);

                var nameIndex = desc.Name;

                if(MERGABLE_MATERIAL_NAMES.Contains(nameIndex))
                {
                    MergableRKs.Add(desc.RepresentationKey);
                }

                MaterialNameIndex[nameIndex] = id;

                return id;
            }

            return MaterialRkIndex[rk];
        }
Esempio n. 14
0
 internal static MyMaterialProxyId GetProxyId(MyMeshMaterialId id)
 {
     return MaterialProxyIndex[id];
 }
Esempio n. 15
0
        public bool TryGetMaterialGroup(MyMeshMaterialId matId, out MyMaterialMergeGroup group)
        {
            int rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;

            return(m_materialGroups.TryGetValue(rootMaterialRK, out group));
        }
Esempio n. 16
0
 static void DebugRecordMeshPartCommands(MeshId model, int sectionIndex, MyMeshMaterialId material)
 {
     Debug.Assert(false, "DebugRecordMeshPartCommands2: Call Francesco");
     MyLog.Default.WriteLine("DebugRecordMeshPartCommands2");
     MyLog.Default.WriteLine("sectionIndex: " + sectionIndex);
     MyLog.Default.WriteLine("model.Info.Name: " + model.Info.Name);
     MyLog.Default.WriteLine("material.Info.Name: " + material.Info.Name);
 }
Esempio n. 17
0
 internal static bool IsMergable(MyMeshMaterialId matId)
 {
     return(MergableRKs.Contains(Table[matId.Index].RepresentationKey));
 }
Esempio n. 18
0
 public bool TryGetMaterialGroup(MyMeshMaterialId matId, out MyMaterialMergeGroup group)
 {
     int rootMaterialRK = MyMeshMaterials1.Table[matId.Index].RepresentationKey;
     return m_materialGroups.TryGetValue(rootMaterialRK, out group);
 }
Esempio n. 19
0
 internal static void InvalidateMaterial(MyMeshMaterialId id)
 {
     MaterialQueryResourcesTable.Add(id);
 }
Esempio n. 20
0
 internal static bool IsMergable(MyMeshMaterialId matId)
 {
     return MergableRKs.Contains(Table[matId.Index].RepresentationKey);
 }