public static SkinnedMeshRendererCache.RigInfo Get(
     SkinnedMeshRenderer renderer)
 {
     SkinnedMeshRendererCache.RigInfo rigInfo;
     if (!SkinnedMeshRendererCache.dictionary.TryGetValue(renderer.get_sharedMesh(), out rigInfo))
     {
         rigInfo = new SkinnedMeshRendererCache.RigInfo();
         Transform   rootBone = renderer.get_rootBone();
         Transform[] bones    = renderer.get_bones();
         if (Object.op_Equality((Object)rootBone, (Object)null))
         {
             Debug.LogWarning((object)("Renderer without a valid root bone: " + ((Object)renderer).get_name() + " " + ((Object)renderer.get_sharedMesh()).get_name()), (Object)((Component)renderer).get_gameObject());
             return(rigInfo);
         }
         ((Component)renderer).get_transform().set_position(Vector3.get_zero());
         ((Component)renderer).get_transform().set_rotation(Quaternion.get_identity());
         ((Component)renderer).get_transform().set_localScale(Vector3.get_one());
         rigInfo.root          = ((Object)rootBone).get_name();
         rigInfo.rootHash      = rigInfo.root.GetHashCode();
         rigInfo.bones         = ((IEnumerable <Transform>)bones).Select <Transform, string>((Func <Transform, string>)(x => ((Object)x).get_name())).ToArray <string>();
         rigInfo.boneHashes    = ((IEnumerable <string>)rigInfo.bones).Select <string, int>((Func <string, int>)(x => x.GetHashCode())).ToArray <int>();
         rigInfo.transforms    = ((IEnumerable <Transform>)bones).Select <Transform, Matrix4x4>((Func <Transform, Matrix4x4>)(x => ((Component)x).get_transform().get_localToWorldMatrix())).ToArray <Matrix4x4>();
         rigInfo.rootTransform = ((Component)renderer.get_rootBone()).get_transform().get_localToWorldMatrix();
         SkinnedMeshRendererCache.dictionary.Add(renderer.get_sharedMesh(), rigInfo);
     }
     return(rigInfo);
 }
Ejemplo n.º 2
0
 private void HandleSkinnedMeshRendererInfo(GameObject go, ref int vertices, ref int skinnedMeshTriangles, ref int meshCount)
 {
     Component[] componentsInChildren = go.GetComponentsInChildren(typeof(SkinnedMeshRenderer));
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         SkinnedMeshRenderer renderer = componentsInChildren[i];
         vertices             += renderer.get_sharedMesh().get_vertexCount();
         skinnedMeshTriangles += renderer.get_sharedMesh().get_triangles().Length / 3;
         meshCount++;
     }
 }
Ejemplo n.º 3
0
    public static void GetRangeIndex(GameObject obj, out int[] rangeIndex)
    {
        rangeIndex = (int[])null;
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        List <int> intList    = new List <int>();
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            for (int index = 0; index < component1.get_sharedMesh().get_colors().Length; ++index)
            {
                if (component1.get_sharedMesh().get_colors()[index].r == 1.0)
                {
                    intList.Add(index);
                }
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (Object.op_Implicit((Object)component2))
            {
                for (int index = 0; index < component2.get_sharedMesh().get_colors().Length; ++index)
                {
                    if (component2.get_sharedMesh().get_colors()[index].r == 1.0)
                    {
                        intList.Add(index);
                    }
                }
            }
        }
        if (intList.Count != 0)
        {
            rangeIndex = new int[intList.Count];
            for (int index = 0; index < intList.Count; ++index)
            {
                rangeIndex[index] = intList[index];
            }
        }
        else
        {
            rangeIndex = (int[])null;
        }
    }
Ejemplo n.º 4
0
    private void ChangeMesh(string part, string item)
    {
        this.SetCurrentMesh(part, item);
        SkinnedMeshRenderer component = this.data.get_Item(part).get_Item(item).GetComponent <SkinnedMeshRenderer>();
        List <Transform>    list      = new List <Transform>();

        Transform[] bones = component.get_bones();
        for (int i = 0; i < bones.Length; i++)
        {
            Transform   transform = bones[i];
            Transform[] array     = this.targetHips;
            for (int j = 0; j < array.Length; j++)
            {
                Transform transform2 = array[j];
                if (!(transform2.get_name() != transform.get_name()))
                {
                    list.Add(transform2);
                    break;
                }
            }
        }
        this.targetSmr.get_Item(part).set_sharedMesh(component.get_sharedMesh());
        this.targetSmr.get_Item(part).set_bones(list.ToArray());
        Material[] materials = new Material[]
        {
            component.get_materials()[0]
        };
        this.targetSmr.get_Item(part).set_materials(materials);
    }
Ejemplo n.º 5
0
    public static void GetNormalData(GameObject obj, List <Vector3> normal)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            foreach (Vector3 normal1 in component1.get_sharedMesh().get_normals())
            {
                normal.Add(normal1);
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (!Object.op_Implicit((Object)component2))
            {
                return;
            }
            foreach (Vector3 normal1 in component2.get_sharedMesh().get_normals())
            {
                normal.Add(normal1);
            }
        }
    }
    public static ResourceObject Get(RESOURCE_CATEGORY category, string name, Object obj)
    {
        //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
        //IL_00aa: Unknown result type (might be due to invalid IL or missing references)
        //IL_00af: Expected O, but got Unknown
        //IL_00d8: Unknown result type (might be due to invalid IL or missing references)
        //IL_00dd: Expected O, but got Unknown
        //IL_0101: Unknown result type (might be due to invalid IL or missing references)
        //IL_0106: Expected O, but got Unknown
        ResourceObject resourceObject = rymTPool <ResourceObject> .Get();

        resourceObject._refCount = 0;
        resourceObject.category  = category;
        resourceObject.obj       = obj;
        resourceObject.name      = name;
        switch (resourceObject.category)
        {
        case RESOURCE_CATEGORY.EFFECT_TEX:
        case RESOURCE_CATEGORY.PLAYER_HIGH_RESO_TEX:
        case RESOURCE_CATEGORY.SOUND_VOICE:
            willReleaseList.Add(resourceObject.obj);
            break;

        case RESOURCE_CATEGORY.PLAYER_ARM:
        case RESOURCE_CATEGORY.PLAYER_BDY:
        case RESOURCE_CATEGORY.PLAYER_FACE:
        case RESOURCE_CATEGORY.PLAYER_HEAD:
        case RESOURCE_CATEGORY.PLAYER_LEG:
        case RESOURCE_CATEGORY.PLAYER_WEAPON:
        {
            GameObject val = resourceObject.obj as GameObject;
            if (val != null)
            {
                Renderer componentInChildren = val.GetComponentInChildren <Renderer>();
                willReleaseList.Add(componentInChildren.get_sharedMaterial().get_mainTexture());
                if (componentInChildren is MeshRenderer)
                {
                    MeshFilter component = componentInChildren.GetComponent <MeshFilter>();
                    if (component != null)
                    {
                        willReleaseList.Add(component.get_sharedMesh());
                    }
                }
                else if (componentInChildren is SkinnedMeshRenderer)
                {
                    SkinnedMeshRenderer val2 = componentInChildren as SkinnedMeshRenderer;
                    willReleaseList.Add(val2.get_sharedMesh());
                }
            }
            break;
        }
        }
        if (willReleaseList.Count > 0)
        {
            resourceObject.willReleaseObjs = willReleaseList.ToArray();
            willReleaseList.Clear();
        }
        return(resourceObject);
    }
Ejemplo n.º 7
0
    public void CalculateBlendShape()
    {
        if (this.FBSTarget.Length == 0)
        {
            return;
        }
        float num1 = Mathf.Lerp(this.OpenMin, (double)this.correctOpenMax >= 0.0 ? this.correctOpenMax : this.OpenMax, this.openRate);

        if (0.0 <= (double)this.FixedRate)
        {
            num1 = this.FixedRate;
        }
        float num2 = 0.0f;

        if (this.blendTimeCtrl != null)
        {
            num2 = this.blendTimeCtrl.Calculate();
        }
        foreach (FBSTargetInfo fbsTargetInfo in this.FBSTarget)
        {
            SkinnedMeshRenderer     skinnedMeshRenderer = fbsTargetInfo.GetSkinnedMeshRenderer();
            Dictionary <int, float> toRelease           = DictionaryPool <int, float> .Get();

            for (int index = 0; index < fbsTargetInfo.PtnSet.Length; ++index)
            {
                toRelease[fbsTargetInfo.PtnSet[index].Close] = 0.0f;
                toRelease[fbsTargetInfo.PtnSet[index].Open]  = 0.0f;
            }
            int num3 = (int)Mathf.Clamp(num1 * 100f, 0.0f, 100f);
            if ((double)num2 != 1.0)
            {
                foreach (int key in this.dictBackFace.Keys)
                {
                    toRelease[fbsTargetInfo.PtnSet[key].Close] = toRelease[fbsTargetInfo.PtnSet[key].Close] + (float)((double)this.dictBackFace[key] * (double)(100 - num3) * (1.0 - (double)num2));
                    toRelease[fbsTargetInfo.PtnSet[key].Open]  = toRelease[fbsTargetInfo.PtnSet[key].Open] + (float)((double)this.dictBackFace[key] * (double)num3 * (1.0 - (double)num2));
                }
            }
            foreach (int key in this.dictNowFace.Keys)
            {
                toRelease[fbsTargetInfo.PtnSet[key].Close] = toRelease[fbsTargetInfo.PtnSet[key].Close] + this.dictNowFace[key] * (float)(100 - num3) * num2;
                toRelease[fbsTargetInfo.PtnSet[key].Open]  = toRelease[fbsTargetInfo.PtnSet[key].Open] + this.dictNowFace[key] * (float)num3 * num2;
            }
            foreach (KeyValuePair <int, float> keyValuePair in toRelease)
            {
                if (keyValuePair.Key == -1)
                {
                    Debug.LogError((object)(((Object)skinnedMeshRenderer.get_sharedMesh()).get_name() + ": 多分、名前が間違ったデータがある"));
                }
                else
                {
                    skinnedMeshRenderer.SetBlendShapeWeight(keyValuePair.Key, keyValuePair.Value);
                }
            }
            DictionaryPool <int, float> .Release(toRelease);
        }
    }
Ejemplo n.º 8
0
    public void Process(GameObject obj, float Seed)
    {
        List <SkinnedMeshRenderer> list = (List <SkinnedMeshRenderer>)Pool.GetList <SkinnedMeshRenderer>();

        obj.GetComponentsInChildren <SkinnedMeshRenderer>(true, (List <M0>)list);
        using (List <SkinnedMeshRenderer> .Enumerator enumerator = list.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                SkinnedMeshRenderer current = enumerator.Current;
                if (!Object.op_Equality((Object)current.get_sharedMesh(), (Object)null) && !Object.op_Equality((Object)((Renderer)current).get_sharedMaterial(), (Object)null))
                {
                    string name1 = ((Object)current.get_sharedMesh()).get_name();
                    string name2 = ((Object)((Renderer)current).get_sharedMaterial()).get_name();
                    for (int index = 0; index < this.MeshReplacements.Length; ++index)
                    {
                        if (this.MeshReplacements[index].Test(name1))
                        {
                            SkinnedMeshRenderer skinnedMeshRenderer = this.MeshReplacements[index].Get(Seed);
                            current.set_sharedMesh(skinnedMeshRenderer.get_sharedMesh());
                            current.set_rootBone(skinnedMeshRenderer.get_rootBone());
                            current.set_bones(skinnedMeshRenderer.get_bones());
                        }
                    }
                    for (int index = 0; index < this.MaterialReplacements.Length; ++index)
                    {
                        if (this.MaterialReplacements[index].Test(name2))
                        {
                            ((Renderer)current).set_sharedMaterial(this.MaterialReplacements[index].Get(Seed));
                        }
                    }
                }
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <SkinnedMeshRenderer>((List <M0>&) ref list);
    }
Ejemplo n.º 9
0
    private void DoChangeSMR(ref SkinnedMeshRenderer dst_smr, ref SkinnedMeshRenderer src_smr)
    {
        dst_smr.set_sharedMesh(src_smr.get_sharedMesh());
        List <Transform> list = new List <Transform>();

        for (int i = 0; i < src_smr.get_bones().Length; i++)
        {
            Transform transform = XUtility.RecursiveFindTransform(base.get_transform(), src_smr.get_bones()[i].get_name());
            list.Add(transform);
        }
        dst_smr.set_bones(list.ToArray());
        dst_smr.set_shadowCastingMode(0);
        dst_smr.set_receiveShadows(false);
        dst_smr.set_useLightProbes(false);
    }
    private void Start()
    {
        FadeInOutShaderFloat component1 = (FadeInOutShaderFloat)((Component)this).GetComponent <FadeInOutShaderFloat>();

        if (Object.op_Equality((Object)component1, (Object)null))
        {
            return;
        }
        Transform           parent     = ((Component)this).get_transform().get_parent();
        SkinnedMeshRenderer component2 = (SkinnedMeshRenderer)((Component)parent).GetComponent <SkinnedMeshRenderer>();
        Mesh sharedMesh;

        if (Object.op_Inequality((Object)component2, (Object)null))
        {
            sharedMesh = component2.get_sharedMesh();
        }
        else
        {
            MeshFilter component3 = (MeshFilter)((Component)parent).GetComponent <MeshFilter>();
            if (Object.op_Equality((Object)component3, (Object)null))
            {
                return;
            }
            sharedMesh = component3.get_sharedMesh();
        }
        if (!sharedMesh.get_isReadable())
        {
            component1.MaxFloat = 0.0f;
        }
        else
        {
            int length = sharedMesh.get_triangles().Length;
            if (length >= 1000)
            {
                return;
            }
            if (length > 500)
            {
                component1.MaxFloat = (float)((double)length / 1000.0 - 0.5);
            }
            else
            {
                component1.MaxFloat = 0.0f;
            }
        }
    }
Ejemplo n.º 11
0
    public static void GetMeshInfo(GameObject selObj, bool bInChildren, out int nVertices, out int nTriangles, out int nMeshCount)
    {
        nVertices  = 0;
        nTriangles = 0;
        nMeshCount = 0;
        if (selObj == null)
        {
            return;
        }
        Component[] array;
        Component[] array2;
        if (bInChildren)
        {
            array  = selObj.GetComponentsInChildren(typeof(SkinnedMeshRenderer));
            array2 = selObj.GetComponentsInChildren(typeof(MeshFilter));
        }
        else
        {
            array  = selObj.GetComponents(typeof(SkinnedMeshRenderer));
            array2 = selObj.GetComponents(typeof(MeshFilter));
        }
        ArrayList arrayList = new ArrayList(array2.Length + array.Length);

        for (int i = 0; i < array2.Length; i++)
        {
            MeshFilter meshFilter = (MeshFilter)array2[i];
            arrayList.Add(meshFilter.get_sharedMesh());
        }
        for (int j = 0; j < array.Length; j++)
        {
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)array[j];
            arrayList.Add(skinnedMeshRenderer.get_sharedMesh());
        }
        for (int k = 0; k < arrayList.get_Count(); k++)
        {
            Mesh mesh = (Mesh)arrayList.get_Item(k);
            if (mesh != null)
            {
                nVertices  += mesh.get_vertexCount();
                nTriangles += mesh.get_triangles().Length / 3;
                nMeshCount++;
            }
        }
    }
    private static int get_sharedMesh(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            SkinnedMeshRenderer skinnedMeshRenderer = (SkinnedMeshRenderer)obj;
            Mesh sharedMesh = skinnedMeshRenderer.get_sharedMesh();
            ToLua.Push(L, sharedMesh);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index sharedMesh on a nil value");
        }
        return(result);
    }
Ejemplo n.º 13
0
 public void GetUpdateMesh()
 {
     for (int index = 0; index < 2; ++index)
     {
         if (!Object.op_Equality((Object)null, (Object)this.objUpdate[index]))
         {
             MeshFilter meshFilter = new MeshFilter();
             MeshFilter component1 = this.objUpdate[index].GetComponent(typeof(MeshFilter)) as MeshFilter;
             if (Object.op_Implicit((Object)component1))
             {
                 this.meshUpdate[index] = component1.get_sharedMesh();
             }
             else
             {
                 SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
                 SkinnedMeshRenderer component2          = this.objUpdate[index].GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                 this.meshUpdate[index] = component2.get_sharedMesh();
             }
         }
     }
 }
Ejemplo n.º 14
0
 public void Init()
 {
     if (Object.op_Equality((Object)null, (Object)this.objUpdate[0]) || Object.op_Equality((Object)null, (Object)this.objUpdate[1]) || Object.op_Equality((Object)null, (Object)this.ObjRange))
     {
         return;
     }
     Mesh[]       meshArray     = new Mesh[2];
     List <int>[] intListArray1 = new List <int> [2];
     for (int index = 0; index < 2; ++index)
     {
         intListArray1[index] = new List <int>();
     }
     List <int>[] intListArray2 = new List <int> [2];
     for (int index1 = 0; index1 < 2; ++index1)
     {
         intListArray2[index1] = new List <int>();
         MeshFilter meshFilter = new MeshFilter();
         MeshFilter component1 = this.objUpdate[index1].GetComponent(typeof(MeshFilter)) as MeshFilter;
         if (Object.op_Implicit((Object)component1))
         {
             meshArray[index1] = component1.get_sharedMesh();
         }
         else
         {
             SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
             SkinnedMeshRenderer component2          = this.objUpdate[index1].GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
             meshArray[index1] = component2.get_sharedMesh();
         }
         if (Object.op_Inequality((Object)null, (Object)meshArray[index1]))
         {
             if (Object.op_Implicit((Object)this.ObjRange))
             {
                 for (int index2 = 0; index2 < meshArray[index1].get_vertexCount(); ++index2)
                 {
                     if ((double)Vector3.Distance(this.ObjRange.get_transform().get_position(), this.objUpdate[index1].get_transform().TransformPoint(meshArray[index1].get_vertices()[index2])) < (double)this.Range)
                     {
                         intListArray2[index1].Add(index2);
                     }
                 }
             }
             else
             {
                 for (int index2 = 0; index2 < meshArray[index1].get_vertexCount(); ++index2)
                 {
                     intListArray2[index1].Add(index2);
                 }
             }
         }
     }
     if (!Object.op_Inequality((Object)null, (Object)meshArray[0]) || !Object.op_Inequality((Object)null, (Object)meshArray[1]))
     {
         return;
     }
     for (int index1 = 0; index1 < intListArray2[0].Count; ++index1)
     {
         for (int index2 = 0; index2 < intListArray2[1].Count; ++index2)
         {
             int index3 = intListArray2[0][index1];
             int index4 = intListArray2[1][index2];
             if (Vector3.op_Equality(this.objUpdate[0].get_transform().TransformPoint(meshArray[0].get_vertices()[index3]), this.objUpdate[1].get_transform().TransformPoint(meshArray[1].get_vertices()[index4])))
             {
                 intListArray1[0].Add(index3);
                 intListArray1[1].Add(index4);
                 break;
             }
         }
     }
     this.calcIndexA = new int[intListArray1[0].Count];
     this.calcIndexB = new int[intListArray1[1].Count];
     for (int index = 0; index < intListArray1[0].Count; ++index)
     {
         this.calcIndexA[index] = intListArray1[0][index];
         this.calcIndexB[index] = intListArray1[1][index];
     }
 }
Ejemplo n.º 15
0
    public void ChangeFace(Dictionary <int, float> dictFace, bool blend)
    {
        bool  flag = false;
        byte  num1 = 0;
        float num2 = 0.0f;

        foreach (FBSTargetInfo fbsTargetInfo in this.FBSTarget)
        {
            SkinnedMeshRenderer skinnedMeshRenderer = fbsTargetInfo.GetSkinnedMeshRenderer();
            foreach (int key in dictFace.Keys)
            {
                if (skinnedMeshRenderer.get_sharedMesh().get_blendShapeCount() <= fbsTargetInfo.PtnSet[key].Close)
                {
                    num1 = (byte)1;
                    break;
                }
                if (skinnedMeshRenderer.get_sharedMesh().get_blendShapeCount() <= fbsTargetInfo.PtnSet[key].Open)
                {
                    num1 = (byte)1;
                    break;
                }
                num2 += dictFace[key];
            }
            if (num1 == (byte)0)
            {
                if (!flag && (double)num2 > 1.0)
                {
                    num1 = (byte)2;
                    break;
                }
                flag = true;
            }
            else
            {
                break;
            }
        }
        if (num1 == (byte)1)
        {
            Debug.LogError((object)"ブレンドシェイプ番号が範囲外");
        }
        else if (num1 == (byte)2)
        {
            Debug.LogError((object)"合成の割合が100%を超えています");
        }
        else
        {
            this.dictBackFace.Clear();
            foreach (int key in this.dictNowFace.Keys)
            {
                this.dictBackFace[key] = this.dictNowFace[key];
            }
            this.dictNowFace.Clear();
            foreach (int key in dictFace.Keys)
            {
                this.dictNowFace[key] = dictFace[key];
            }
            if (!blend)
            {
                this.blendTimeCtrl.End();
            }
            else
            {
                this.blendTimeCtrl.Start();
            }
        }
    }
Ejemplo n.º 16
0
    public void Process(
        PlayerModelHair playerModelHair,
        HairDyeCollection dyeCollection,
        HairDye dye,
        MaterialPropertyBlock block)
    {
        List <SkinnedMeshRenderer> list = (List <SkinnedMeshRenderer>)Pool.GetList <SkinnedMeshRenderer>();

        ((Component)playerModelHair).get_gameObject().GetComponentsInChildren <SkinnedMeshRenderer>(true, (List <M0>)list);
        using (List <SkinnedMeshRenderer> .Enumerator enumerator = list.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                SkinnedMeshRenderer current = enumerator.Current;
                if (!Object.op_Equality((Object)current.get_sharedMesh(), (Object)null) && !Object.op_Equality((Object)((Renderer)current).get_sharedMaterial(), (Object)null))
                {
                    string name = ((Object)current.get_sharedMesh()).get_name();
                    ((Object)((Renderer)current).get_sharedMaterial()).get_name();
                    if (!((Component)current).get_gameObject().get_activeSelf())
                    {
                        ((Component)current).get_gameObject().SetActive(true);
                    }
                    for (int index = 0; index < this.MeshReplacements.Length; ++index)
                    {
                        if (this.MeshReplacements[index].Test(name))
                        {
                            SkinnedMeshRenderer replace = this.MeshReplacements[index].Replace;
                            if (Object.op_Equality((Object)replace, (Object)null))
                            {
                                ((Component)current).get_gameObject().SetActive(false);
                            }
                            else
                            {
                                current.set_sharedMesh(replace.get_sharedMesh());
                                current.set_rootBone(replace.get_rootBone());
                                current.set_bones(this.MeshReplacements[index].GetBones());
                            }
                        }
                    }
                    PlayerModelHair.RendererMaterials rendererMaterials;
                    if (playerModelHair.Materials.TryGetValue((Renderer)current, out rendererMaterials))
                    {
                        Array.Copy((Array)rendererMaterials.original, (Array)rendererMaterials.replacement, rendererMaterials.original.Length);
                        for (int index1 = 0; index1 < rendererMaterials.original.Length; ++index1)
                        {
                            for (int index2 = 0; index2 < this.MaterialReplacements.Length; ++index2)
                            {
                                if (this.MaterialReplacements[index2].Test(rendererMaterials.names[index1]))
                                {
                                    rendererMaterials.replacement[index1] = this.MaterialReplacements[index2].Replace;
                                }
                            }
                        }
                        ((Renderer)current).set_sharedMaterials(rendererMaterials.replacement);
                    }
                    else
                    {
                        Debug.LogWarning((object)("[HairSet.Process] Missing cached renderer materials in " + ((Object)playerModelHair).get_name()));
                    }
                    if (dye != null && ((Component)current).get_gameObject().get_activeSelf())
                    {
                        dye.Apply(dyeCollection, block);
                    }
                }
            }
        }
        // ISSUE: cast to a reference type
        Pool.FreeList <SkinnedMeshRenderer>((List <M0>&) ref list);
    }
Ejemplo n.º 17
0
    protected bool CreateCalcInfo(GameObject obj)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return(false);
        }
        MorphSetting component1 = (MorphSetting)obj.GetComponent("MorphSetting");

        if (Object.op_Equality((Object)null, (Object)component1))
        {
            return(false);
        }
        this.CalcInfo = (MorphCalcInfo[])null;
        GC.Collect();
        this.CalcInfo = new MorphCalcInfo[component1.MorphDataList.Count];
        int index1 = 0;

        foreach (MorphData morphData in component1.MorphDataList)
        {
            if (!Object.op_Equality((Object)null, (Object)morphData.TargetObj))
            {
                this.CalcInfo[index1]           = new MorphCalcInfo();
                this.CalcInfo[index1].TargetObj = morphData.TargetObj;
                MeshFilter meshFilter = new MeshFilter();
                MeshFilter component2 = morphData.TargetObj.GetComponent(typeof(MeshFilter)) as MeshFilter;
                if (Object.op_Implicit((Object)component2))
                {
                    this.CalcInfo[index1].OriginalMesh   = component2.get_sharedMesh();
                    this.CalcInfo[index1].OriginalPos    = component2.get_sharedMesh().get_vertices();
                    this.CalcInfo[index1].OriginalNormal = component2.get_sharedMesh().get_normals();
                    this.CalcInfo[index1].WeightFlags    = false;
                }
                else
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
                    SkinnedMeshRenderer component3          = morphData.TargetObj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                    this.CalcInfo[index1].OriginalMesh   = component3.get_sharedMesh();
                    this.CalcInfo[index1].OriginalPos    = component3.get_sharedMesh().get_vertices();
                    this.CalcInfo[index1].OriginalNormal = component3.get_sharedMesh().get_normals();
                    this.CalcInfo[index1].WeightFlags    = true;
                }
                int length1;
                if (Object.op_Equality((Object)null, (Object)morphData.MorphArea))
                {
                    length1 = this.CalcInfo[index1].OriginalMesh.get_vertices().Length;
                    this.CalcInfo[index1].UpdateIndex = new int[length1];
                    for (int index2 = 0; index2 < length1; ++index2)
                    {
                        this.CalcInfo[index1].UpdateIndex[index2] = index2;
                    }
                }
                else if (morphData.MorphArea.get_colors().Length != 0)
                {
                    List <int> source = new List <int>();
                    // ISSUE: object of a compiler-generated type is created
                    using (IEnumerator <\u003C\u003E__AnonType10 <Color, int> > enumerator = ((IEnumerable <Color>)morphData.MorphArea.get_colors()).Select <Color, \u003C\u003E__AnonType10 <Color, int> >((Func <Color, int, \u003C\u003E__AnonType10 <Color, int> >)((value, index) => new \u003C\u003E__AnonType10 <Color, int>(value, index))).GetEnumerator())
                    {
                        while (((IEnumerator)enumerator).MoveNext())
                        {
                            // ISSUE: variable of a compiler-generated type
                            \u003C\u003E__AnonType10 <Color, int> current = enumerator.Current;
                            if (Color.op_Equality(current.value, morphData.AreaColor))
                            {
                                source.Add(current.index);
                            }
                        }
                    }
                    this.CalcInfo[index1].UpdateIndex = new int[source.Count];
                    // ISSUE: object of a compiler-generated type is created
                    foreach (\u003C\u003E__AnonType10 <int, int> anonType10 in source.Select <int, \u003C\u003E__AnonType10 <int, int> >((Func <int, int, \u003C\u003E__AnonType10 <int, int> >)((value, index) => new \u003C\u003E__AnonType10 <int, int>(value, index))))
                    {
                        this.CalcInfo[index1].UpdateIndex[anonType10.index] = anonType10.value;
                    }
                    length1 = source.Count;
                }
                else
                {
                    length1 = this.CalcInfo[index1].OriginalMesh.get_vertices().Length;
                    this.CalcInfo[index1].UpdateIndex = new int[length1];
                    for (int index2 = 0; index2 < length1; ++index2)
                    {
                        this.CalcInfo[index1].UpdateIndex[index2] = index2;
                    }
                }
                int length2 = morphData.MorphMesh.Length;
                this.CalcInfo[index1].UpdateInfo = new MorphUpdateInfo[length2];
                for (int index2 = 0; index2 < length2; ++index2)
                {
                    this.CalcInfo[index1].UpdateInfo[index2]         = new MorphUpdateInfo();
                    this.CalcInfo[index1].UpdateInfo[index2].Pos     = new Vector3[length1];
                    this.CalcInfo[index1].UpdateInfo[index2].Normmal = new Vector3[length1];
                    if (Object.op_Equality((Object)null, (Object)morphData.MorphMesh[index2]))
                    {
                        for (int index3 = 0; index3 < length1; ++index3)
                        {
                            this.CalcInfo[index1].UpdateInfo[index2].Pos[index3]     = this.CalcInfo[index1].OriginalMesh.get_vertices()[this.CalcInfo[index1].UpdateIndex[index3]];
                            this.CalcInfo[index1].UpdateInfo[index2].Normmal[index3] = this.CalcInfo[index1].OriginalMesh.get_normals()[this.CalcInfo[index1].UpdateIndex[index3]];
                        }
                    }
                    else
                    {
                        for (int index3 = 0; index3 < length1; ++index3)
                        {
                            this.CalcInfo[index1].UpdateInfo[index2].Pos[index3]     = morphData.MorphMesh[index2].get_vertices()[this.CalcInfo[index1].UpdateIndex[index3]];
                            this.CalcInfo[index1].UpdateInfo[index2].Normmal[index3] = morphData.MorphMesh[index2].get_normals()[this.CalcInfo[index1].UpdateIndex[index3]];
                        }
                    }
                }
                ++index1;
            }
        }
        return(true);
    }
Ejemplo n.º 18
0
    public static void GetUVData(GameObject obj, List <Vector2> uv, int index)
    {
        if (Object.op_Equality((Object)null, (Object)obj))
        {
            return;
        }
        MeshFilter meshFilter = new MeshFilter();
        MeshFilter component1 = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;

        if (Object.op_Inequality((Object)null, (Object)component1))
        {
            switch (index)
            {
            case 0:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv())
                {
                    uv.Add(vector2);
                }
                break;

            case 1:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv2())
                {
                    uv.Add(vector2);
                }
                break;

            case 2:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv3())
                {
                    uv.Add(vector2);
                }
                break;

            case 3:
                foreach (Vector2 vector2 in component1.get_sharedMesh().get_uv4())
                {
                    uv.Add(vector2);
                }
                break;
            }
        }
        else
        {
            SkinnedMeshRenderer skinnedMeshRenderer = new SkinnedMeshRenderer();
            SkinnedMeshRenderer component2          = obj.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
            if (!Object.op_Implicit((Object)component2))
            {
                return;
            }
            switch (index)
            {
            case 0:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv())
                {
                    uv.Add(vector2);
                }
                break;

            case 1:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv2())
                {
                    uv.Add(vector2);
                }
                break;

            case 2:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv3())
                {
                    uv.Add(vector2);
                }
                break;

            case 3:
                foreach (Vector2 vector2 in component2.get_sharedMesh().get_uv4())
                {
                    uv.Add(vector2);
                }
                break;
            }
        }
    }