Example #1
0
        public void LateUpdate()
        {
            if (!modelDirty || base.IsBusy)
            {
                return;
            }
            modelDirty = false;
            startWork();
            cleanup();
            partViews.Clear();
            List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > list = new List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > >();
            List <KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > > list2 = new List <KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > >();

            foreach (AvatarModel.Part item in Model.IterateParts())
            {
                ViewPart viewPart = new ViewPart();
                if (item.Equipment != null)
                {
                    EquipmentModelDefinition.Part eqPart = item.Equipment.Parts[item.Index];
                    list2.Add(AvatarView.CreatePartContent(Model, viewPart, item, eqPart));
                    if (item.Decals != null)
                    {
                        AvatarView.CreateDecalContent(viewPart, item, list);
                    }
                }
                else
                {
                    BodyViewDefinition bodyViewDefinition = Model.Definition.Slots[item.Index].LOD[Model.LodLevel];
                    bodyViewDefinition.ApplyToViewPart(viewPart);
                }
                partViews.Add(viewPart);
            }
            partsRequest  = outfitService.Load(list2, outfitService.EquipmentPartCache);
            decalsRequest = outfitService.Load(list, outfitService.DecalCache);
        }
Example #2
0
        public static void BakeTexture(List <ViewPart> parts, Rect[] atlasUVOffsets, BodyColorMaterialProperties bodyColor, RenderTexture atlasRenderTexture)
        {
            BakeMaterialProperties bakeMaterialProperties = new BakeMaterialProperties(null);
            RenderTexture          active = RenderTexture.active;

            RenderTexture.active = atlasRenderTexture;
            GL.Clear(true, true, new Color32(0, 0, 0, 0));
            for (int i = 0; i < parts.Count; i++)
            {
                ViewPart viewPart    = parts[i];
                Material material    = new Material(viewPart.HasMaterialProperties(typeof(EquipmentMaterialProperties)) ? AvatarService.EquipmentBakeShader : AvatarService.BodyBakeShader);
                Texture  maskTexture = viewPart.GetMaskTexture();
                viewPart.ApplyMaterialProperties(material);
                bodyColor.Apply(material);
                Rect rect = atlasUVOffsets[i];
                bakeMaterialProperties.AtlasOffsetU      = rect.x;
                bakeMaterialProperties.AtlasOffsetV      = rect.y;
                bakeMaterialProperties.AtlasOffsetScaleU = rect.width;
                bakeMaterialProperties.AtlasOffsetScaleV = rect.height;
                bakeMaterialProperties.Apply(material);
                atlasRenderTexture.DiscardContents();
                Graphics.Blit(maskTexture, atlasRenderTexture, material);
                Object.Destroy(material);
            }
            RenderTexture.active = active;
        }
Example #3
0
 public void LateUpdate()
 {
     if (this.modelDirty && !base.IsBusy)
     {
         this.modelDirty = false;
         base.startWork();
         this.cleanup();
         this.partViews.Clear();
         List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > list = new List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > >();
         List <KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > > list2 = new List <KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > >();
         foreach (AvatarModel.Part current in this.Model.IterateParts())
         {
             ViewPart viewPart = new ViewPart();
             if (current.Equipment != null)
             {
                 EquipmentModelDefinition.Part eqPart = current.Equipment.Parts[current.Index];
                 list2.Add(AvatarView.CreatePartContent(this.Model, viewPart, current, eqPart));
                 if (current.Decals != null)
                 {
                     AvatarView.CreateDecalContent(viewPart, current, list);
                 }
             }
             else
             {
                 BodyViewDefinition bodyViewDefinition = this.Model.Definition.Slots[current.Index].LOD[this.Model.LodLevel];
                 bodyViewDefinition.ApplyToViewPart(viewPart);
             }
             this.partViews.Add(viewPart);
         }
         this.partsRequest  = this.outfitService.Load <EquipmentViewDefinition>(list2, this.outfitService.EquipmentPartCache, null);
         this.decalsRequest = this.outfitService.Load <Texture2D>(list, this.outfitService.DecalCache, null);
     }
 }
Example #4
0
 private static void onPartDefinitionLoaded(ViewPart partView, EquipmentViewDefinition eq)
 {
     if (eq != null)
     {
         eq.ApplyToViewPart(partView);
     }
 }
Example #5
0
 public static Rect[] CalculateAtlasLayout(List <ViewPart> parts, out int curSize)
 {
     Rect[] array = new Rect[parts.Count];
     for (int i = 0; i < parts.Count; i++)
     {
         ViewPart viewPart = parts[i];
         float    y        = viewPart.GetTextureSize().y;
         y = ((y > 0f) ? y : 16f);
         ref Rect reference = ref array[i];
         reference = new Rect(0f, 0f, y, y);
     }
 public static void CreateDecalContent(ViewPart partView, AvatarModel.Part modelPart, List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > decalContent)
 {
     partView.InitDecalProps(modelPart.Decals.Length);
     for (int i = 0; i < modelPart.Decals.Length; i++)
     {
         AvatarView.__c__DisplayClass4 __c__DisplayClass = new AvatarView.__c__DisplayClass4();
         DCustomEquipmentDecal         decal             = modelPart.Decals[i];
         __c__DisplayClass.decalMatProp = new DecalMaterialProperties(decal.Index);
         __c__DisplayClass.decalMatProp.Import(decal, null);
         partView.SetDecalProps(i, __c__DisplayClass.decalMatProp);
         TypedAssetContentKey <Texture2D> key = AvatarView.CreateDecalKey(decal);
         decalContent.Add(new KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> >(key, new Action <Texture2D>(__c__DisplayClass._CreateDecalContent_b__3)));
     }
 }
Example #7
0
 public static void CreateDecalContent(ViewPart partView, AvatarModel.Part modelPart, List <KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> > > decalContent)
 {
     partView.InitDecalProps(modelPart.Decals.Length);
     for (int i = 0; i < modelPart.Decals.Length; i++)
     {
         DCustomEquipmentDecal   decal        = modelPart.Decals[i];
         DecalMaterialProperties decalMatProp = new DecalMaterialProperties(decal.Index);
         decalMatProp.Import(decal);
         partView.SetDecalProps(i, decalMatProp);
         TypedAssetContentKey <Texture2D> key = CreateDecalKey(decal);
         decalContent.Add(new KeyValuePair <TypedAssetContentKey <Texture2D>, Action <Texture2D> >(key, delegate(Texture2D decalTex)
         {
             decalMatProp.Texture = decalTex;
         }));
     }
 }
Example #8
0
 public static Rect[] CalculateAtlasLayout(List <ViewPart> parts, out int curSize)
 {
     Rect[] array = new Rect[parts.Count];
     for (int i = 0; i < parts.Count; i++)
     {
         ViewPart viewPart = parts[i];
         float    num      = viewPart.GetTextureSize().y;
         num      = ((num > 0f) ? num : 16f);
         array[i] = new Rect(0f, 0f, num, num);
     }
     curSize = Combine.Pack(array, 0);
     for (int j = 0; j < array.Length; j++)
     {
         Rect rect = new Rect(array[j].x / (float)curSize, array[j].y / (float)curSize, array[j].width / (float)curSize, array[j].height / (float)curSize);
         array[j] = rect;
     }
     return(array);
 }
Example #9
0
 public override void ApplyToViewPart(ViewPart partView)
 {
     partView.SetMeshDefinition(this.SkinnedMesh);
     partView.InitMaterialProps();
     partView.AddMaterialProps(this.BodyMaterial);
 }
 public abstract void ApplyToViewPart(ViewPart partView);
Example #11
0
 public override void ApplyToViewPart(ViewPart partView)
 {
     base.ApplyToViewPart(partView);
     partView.SetDefaultProps(DecalMaterials);
     partView.AddMaterialProps(EquipmentMaterial);
 }
Example #12
0
        public static KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > CreatePartContent(AvatarModel model, ViewPart partView, AvatarModel.Part modelPart, EquipmentModelDefinition.Part eqPart)
        {
            TypedAssetContentKey <EquipmentViewDefinition> key = model.Definition.CreatePartKey(modelPart.Equipment, eqPart, model.LodLevel);

            return(new KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >(key, delegate(EquipmentViewDefinition eq)
            {
                onPartDefinitionLoaded(partView, eq);
            }));
        }
        public static KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> > CreatePartContent(AvatarModel model, ViewPart partView, AvatarModel.Part modelPart, EquipmentModelDefinition.Part eqPart)
        {
            AvatarView.__c__DisplayClass1 __c__DisplayClass = new AvatarView.__c__DisplayClass1();
            __c__DisplayClass.partView = partView;
            TypedAssetContentKey <EquipmentViewDefinition> key = model.Definition.CreatePartKey(modelPart.Equipment, eqPart, model.LodLevel);

            return(new KeyValuePair <TypedAssetContentKey <EquipmentViewDefinition>, Action <EquipmentViewDefinition> >(key, new Action <EquipmentViewDefinition>(__c__DisplayClass._CreatePartContent_b__0)));
        }