Beispiel #1
0
        public static EquipmentShaderParams FromMaterial(Material material)
        {
            validateShader(material.shader);
            EquipmentShaderParams equipmentShaderParams = new EquipmentShaderParams();

            equipmentShaderParams.DiffuseTexture = material.GetTexture(DIFFUSE_TEX);
            if (material.shader.name == "CpRemix/Equipment Preview" || material.shader.name == "CpRemix/Equipment Bake")
            {
                equipmentShaderParams.Decals123OpacityTexture = material.GetTexture(DECALS_123_OPACITY_TEX);
                equipmentShaderParams.DecalRed1Texture        = material.GetTexture(DECAL_RED_1_TEX);
                equipmentShaderParams.DecalRed1Color          = material.GetColor(DECAL_RED_1_COLOR);
                equipmentShaderParams.DecalRed1Scale          = material.GetFloat(DECAL_RED_1_SCALE);
                equipmentShaderParams.DecalRed1UOffset        = material.GetFloat(DECAL_RED_1_U_OFFSET);
                equipmentShaderParams.DecalRed1VOffset        = material.GetFloat(DECAL_RED_1_V_OFFSET);
                equipmentShaderParams.DecalRed1Repeat         = material.GetFloat(DECAL_RED_1_REPEAT) == 1f;
                equipmentShaderParams.DecalRed1RotationRads   = material.GetFloat(DECAL_RED_1_ROTATION_RADS);
                equipmentShaderParams.DecalGreen2Texture      = material.GetTexture(DECAL_GREEN_2_TEX);
                equipmentShaderParams.DecalGreen2Color        = material.GetColor(DECAL_GREEN_2_COLOR);
                equipmentShaderParams.DecalGreen2Scale        = material.GetFloat(DECAL_GREEN_2_SCALE);
                equipmentShaderParams.DecalGreen2UOffset      = material.GetFloat(DECAL_GREEN_2_U_OFFSET);
                equipmentShaderParams.DecalGreen2VOffset      = material.GetFloat(DECAL_GREEN_2_V_OFFSET);
                equipmentShaderParams.DecalGreen2Repeat       = material.GetFloat(DECAL_GREEN_2_REPEAT) == 1f;
                equipmentShaderParams.DecalGreen2RotationRads = material.GetFloat(DECAL_GREEN_2_ROTATION_RADS);
                equipmentShaderParams.DecalBlue3Texture       = material.GetTexture(DECAL_BLUE_3_TEX);
                equipmentShaderParams.DecalBlue3Color         = material.GetColor(DECAL_BLUE_3_COLOR);
                equipmentShaderParams.DecalBlue3Scale         = material.GetFloat(DECAL_BLUE_3_SCALE);
                equipmentShaderParams.DecalBlue3UOffset       = material.GetFloat(DECAL_BLUE_3_U_OFFSET);
                equipmentShaderParams.DecalBlue3VOffset       = material.GetFloat(DECAL_BLUE_3_V_OFFSET);
                equipmentShaderParams.DecalBlue3Repeat        = material.GetFloat(DECAL_BLUE_3_REPEAT) == 1f;
                equipmentShaderParams.DecalBlue3RotationRads  = material.GetFloat(DECAL_BLUE_3_ROTATION_RADS);
                equipmentShaderParams.DecalRed4Texture        = material.GetTexture(DECAL_RED_4_TEX);
                equipmentShaderParams.DecalRed4Color          = material.GetColor(DECAL_RED_4_COLOR);
                equipmentShaderParams.DecalRed4Scale          = material.GetFloat(DECAL_RED_4_SCALE);
                equipmentShaderParams.DecalRed4UOffset        = material.GetFloat(DECAL_RED_4_U_OFFSET);
                equipmentShaderParams.DecalRed4VOffset        = material.GetFloat(DECAL_RED_4_V_OFFSET);
                equipmentShaderParams.DecalRed4Repeat         = material.GetFloat(DECAL_RED_4_REPEAT) == 1f;
                equipmentShaderParams.DecalRed4RotationRads   = material.GetFloat(DECAL_RED_4_ROTATION_RADS);
                equipmentShaderParams.DecalGreen5Texture      = material.GetTexture(DECAL_GREEN_5_TEX);
                equipmentShaderParams.DecalGreen5Color        = material.GetColor(DECAL_GREEN_5_COLOR);
                equipmentShaderParams.DecalGreen5Scale        = material.GetFloat(DECAL_GREEN_5_SCALE);
                equipmentShaderParams.DecalGreen5UOffset      = material.GetFloat(DECAL_GREEN_5_U_OFFSET);
                equipmentShaderParams.DecalGreen5VOffset      = material.GetFloat(DECAL_GREEN_5_V_OFFSET);
                equipmentShaderParams.DecalGreen5Repeat       = material.GetFloat(DECAL_GREEN_5_REPEAT) == 1f;
                equipmentShaderParams.DecalGreen5RotationRads = material.GetFloat(DECAL_GREEN_5_ROTATION_RADS);
                equipmentShaderParams.DecalBlue6Texture       = material.GetTexture(DECAL_BLUE_6_TEX);
                equipmentShaderParams.DecalBlue6Color         = material.GetColor(DECAL_BLUE_6_COLOR);
                equipmentShaderParams.DecalBlue6Scale         = material.GetFloat(DECAL_BLUE_6_SCALE);
                equipmentShaderParams.DecalBlue6UOffset       = material.GetFloat(DECAL_BLUE_6_U_OFFSET);
                equipmentShaderParams.DecalBlue6VOffset       = material.GetFloat(DECAL_BLUE_6_V_OFFSET);
                equipmentShaderParams.DecalBlue6Repeat        = material.GetFloat(DECAL_BLUE_6_REPEAT) == 1f;
                equipmentShaderParams.DecalBlue6RotationRads  = material.GetFloat(DECAL_BLUE_6_ROTATION_RADS);
                equipmentShaderParams.EmissiveColorTint       = material.GetColor(EMISSIVE_COLOR_TINT);
            }
            equipmentShaderParams.BodyColorsMaskTexture       = material.GetTexture(BODY_COLORS_MASK_TEX);
            equipmentShaderParams.BodyRedChannelColor         = material.GetColor(BODY_RED_CHANNEL_COLOR);
            equipmentShaderParams.BodyGreenChannelColor       = material.GetColor(BODY_GREEN_CHANNEL_COLOR);
            equipmentShaderParams.BodyBlueChannelColor        = material.GetColor(BODY_BLUE_CHANNEL_COLOR);
            equipmentShaderParams.DetailMatcapmaslEmissiveTex = material.GetTexture(DETAIL_MATCAPMASK_EMISSIVE_TEX);
            if (material.shader.name == "CpRemix/Equipment Bake" || material.shader.name == "CpRemix/Avatar Body Bake")
            {
                equipmentShaderParams.AtlasOffsetU = material.GetFloat(ATLAS_OFFSET_U);
                equipmentShaderParams.AtlasOffsetV = material.GetFloat(ATLAS_OFFSET_V);
                equipmentShaderParams.AtlasScaleU  = material.GetFloat(ATLAS_SCALE_U);
                equipmentShaderParams.AtlasScaleV  = material.GetFloat(ATLAS_SCALE_V);
            }
            return(equipmentShaderParams);
        }
        public static DCustomEquipment GetModelFromCustomizerChildList(List <CustomizerChild> customizerChildList, TemplateDefinition templateDefinition, IDictionary <string, int> decalDefinitionIds)
        {
            DCustomEquipment result = default(DCustomEquipment);

            result.Name         = templateDefinition.AssetName;
            result.DefinitionId = templateDefinition.Id;
            List <DCustomEquipmentPart> list = new List <DCustomEquipmentPart>();

            for (int i = 0; i < customizerChildList.Count; i++)
            {
                if (customizerChildList[i].gameObject.activeSelf && customizerChildList[i].HasEquipment)
                {
                    DCustomEquipmentPart item = default(DCustomEquipmentPart);
                    item.SlotIndex = customizerChildList[i].SlotIndex;
                    EquipmentShaderParams        equipmentShaderParams = EquipmentShaderParams.FromMaterial(customizerChildList[i].SharedMaterial);
                    List <DCustomEquipmentDecal> list2 = new List <DCustomEquipmentDecal>();
                    if (equipmentShaderParams.DecalRed1Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalRed1Texture.name))
                    {
                        DCustomEquipmentDecal item2 = default(DCustomEquipmentDecal);
                        item2.TextureName  = equipmentShaderParams.DecalRed1Texture.name;
                        item2.DefinitionId = decalDefinitionIds[item2.TextureName];
                        item2.Scale        = equipmentShaderParams.DecalRed1Scale;
                        item2.Uoffset      = equipmentShaderParams.DecalRed1UOffset;
                        item2.Voffset      = equipmentShaderParams.DecalRed1VOffset;
                        item2.Rotation     = equipmentShaderParams.DecalRed1RotationRads;
                        item2.Repeat       = equipmentShaderParams.DecalRed1Repeat;
                        item2.Type         = EquipmentDecalType.FABRIC;
                        item2.Index        = 0;
                        list2.Add(item2);
                    }
                    if (equipmentShaderParams.DecalGreen2Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalGreen2Texture.name))
                    {
                        DCustomEquipmentDecal item3 = default(DCustomEquipmentDecal);
                        item3.TextureName  = equipmentShaderParams.DecalGreen2Texture.name;
                        item3.DefinitionId = decalDefinitionIds[item3.TextureName];
                        item3.Scale        = equipmentShaderParams.DecalGreen2Scale;
                        item3.Uoffset      = equipmentShaderParams.DecalGreen2UOffset;
                        item3.Voffset      = equipmentShaderParams.DecalGreen2VOffset;
                        item3.Rotation     = equipmentShaderParams.DecalGreen2RotationRads;
                        item3.Repeat       = equipmentShaderParams.DecalGreen2Repeat;
                        item3.Type         = EquipmentDecalType.FABRIC;
                        item3.Index        = 1;
                        list2.Add(item3);
                    }
                    if (equipmentShaderParams.DecalBlue3Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalBlue3Texture.name))
                    {
                        DCustomEquipmentDecal item4 = default(DCustomEquipmentDecal);
                        item4.TextureName  = equipmentShaderParams.DecalBlue3Texture.name;
                        item4.DefinitionId = decalDefinitionIds[item4.TextureName];
                        item4.Scale        = equipmentShaderParams.DecalBlue3Scale;
                        item4.Uoffset      = equipmentShaderParams.DecalBlue3UOffset;
                        item4.Voffset      = equipmentShaderParams.DecalBlue3VOffset;
                        item4.Rotation     = equipmentShaderParams.DecalBlue3RotationRads;
                        item4.Repeat       = equipmentShaderParams.DecalBlue3Repeat;
                        item4.Type         = EquipmentDecalType.FABRIC;
                        item4.Index        = 2;
                        list2.Add(item4);
                    }
                    if (equipmentShaderParams.DecalRed4Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalRed4Texture.name))
                    {
                        DCustomEquipmentDecal item5 = default(DCustomEquipmentDecal);
                        item5.TextureName  = equipmentShaderParams.DecalRed4Texture.name;
                        item5.DefinitionId = decalDefinitionIds[item5.TextureName];
                        item5.Scale        = equipmentShaderParams.DecalRed4Scale;
                        item5.Uoffset      = equipmentShaderParams.DecalRed4UOffset;
                        item5.Voffset      = equipmentShaderParams.DecalRed4VOffset;
                        item5.Rotation     = equipmentShaderParams.DecalRed4RotationRads;
                        item5.Repeat       = equipmentShaderParams.DecalRed4Repeat;
                        item5.Type         = EquipmentDecalType.DECAL;
                        item5.Index        = 3;
                        list2.Add(item5);
                    }
                    if (equipmentShaderParams.DecalGreen5Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalGreen5Texture.name))
                    {
                        DCustomEquipmentDecal item6 = default(DCustomEquipmentDecal);
                        item6.TextureName  = equipmentShaderParams.DecalGreen5Texture.name;
                        item6.DefinitionId = decalDefinitionIds[item6.TextureName];
                        item6.Scale        = equipmentShaderParams.DecalGreen5Scale;
                        item6.Uoffset      = equipmentShaderParams.DecalGreen5UOffset;
                        item6.Voffset      = equipmentShaderParams.DecalGreen5VOffset;
                        item6.Rotation     = equipmentShaderParams.DecalGreen5RotationRads;
                        item6.Repeat       = equipmentShaderParams.DecalGreen5Repeat;
                        item6.Type         = EquipmentDecalType.DECAL;
                        item6.Index        = 4;
                        list2.Add(item6);
                    }
                    if (equipmentShaderParams.DecalBlue6Texture != null && !isIgnoredTexture(equipmentShaderParams.DecalBlue6Texture.name))
                    {
                        DCustomEquipmentDecal item7 = default(DCustomEquipmentDecal);
                        item7.TextureName  = equipmentShaderParams.DecalBlue6Texture.name;
                        item7.DefinitionId = decalDefinitionIds[item7.TextureName];
                        item7.Scale        = equipmentShaderParams.DecalBlue6Scale;
                        item7.Uoffset      = equipmentShaderParams.DecalBlue6UOffset;
                        item7.Voffset      = equipmentShaderParams.DecalBlue6VOffset;
                        item7.Rotation     = equipmentShaderParams.DecalBlue6RotationRads;
                        item7.Repeat       = equipmentShaderParams.DecalBlue6Repeat;
                        item7.Type         = EquipmentDecalType.DECAL;
                        item7.Index        = 5;
                        list2.Add(item7);
                    }
                    item.Decals = list2.ToArray();
                    list.Add(item);
                }
            }
            result.Parts = list.ToArray();
            return(result);
        }