private void Run( )
    {
        this.IsDone       = false;
        this.properties70 = new Dictionary <string, Properties70> ();
        var indexes = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"NodeAttribute::\", \"Light\" {")).ToList();

        string[] data = new string[0];
        for (int i = 0; i < indexes.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexes[i];
            data        = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id   = data[1].Trim();
            prop70.name = data[5].Trim();

            for (int k = j; k < (j + 5); k++)
            {
                if (UniFBX.list[k].Contains("\"Color\""))
                {
                    data           = UniFBX.list[k].Split(',');
                    prop70.color.r = float.Parse(data[data.Length - 3]);
                    prop70.color.g = float.Parse(data[data.Length - 2]);
                    prop70.color.b = float.Parse(data[data.Length - 1]);
                    prop70.color.a = 1.0f;
                }
                else if (UniFBX.list[k].Contains("\"LightType\""))
                {
                    data            = UniFBX.list[k].Split(',');
                    prop70.lighType = int.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("\"Intensity\""))
                {
                    data         = UniFBX.list[k].Split(',');
                    prop70.range = float.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("\"CastShadows\""))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.castShadow = int.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("\"OuterAngle\""))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.outerAngle = float.Parse(data[data.Length - 1]);
                    break;
                }
            }

            this.properties70.Add(prop70.id, prop70);
        }
        this.IsDone = true;
    }
Beispiel #2
0
    private void Run( )
    {
        this.IsDone       = false;
        this.properties70 = new Dictionary <string, Properties70> ();

        var indexes = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"Material::")).ToList();

        string[] data = new string[0];
        for (int i = 0; i < indexes.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexes[i];
            data        = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id   = data[1].Trim();
            prop70.name = data[5].Trim();

            for (int k = j; k < (j + 10); k++)
            {
                if (UniFBX.list[k].Contains("\"EmissiveColor\""))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.emissiveColor.r = float.Parse(data[data.Length - 3]);
                    prop70.emissiveColor.g = float.Parse(data[data.Length - 2]);
                    prop70.emissiveColor.b = float.Parse(data[data.Length - 1]);
                    prop70.emissiveColor.a = 1.0f;
                }
                else if (UniFBX.list[k].Contains("\"DiffuseColor\""))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.diffuseColor.r = float.Parse(data[data.Length - 3]);
                    prop70.diffuseColor.g = float.Parse(data[data.Length - 2]);
                    prop70.diffuseColor.b = float.Parse(data[data.Length - 1]);
                    prop70.diffuseColor.a = 1.0f;
                    break;
                }
            }

            this.properties70.Add(prop70.id, prop70);
            UniFBXStads.AddMaterial();
        }
        this.IsDone = true;
    }
Beispiel #3
0
    private void Run( )
    {
        this.IsDone                  = false;
        this.properties70            = new Dictionary <string, Properties70> ();
        this.materials               = new Dictionary <string, Material> ();
        this.layeredTextureMaterials = new Dictionary <string, string> ();
        var indexes = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"LayeredTexture::")).ToList();

        string[] data = new string[0];
        for (int i = 0; i < indexes.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexes[i];
            data            = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id       = data[1].Trim();
            prop70.name     = data[5].Trim();
            prop70.property = data[6].Trim();

            this.properties70.Add(prop70.id, prop70);
        }
        this.IsDone = true;
    }
    private void Run( )
    {
        this.IsDone       = false;
        this.properties70 = new Dictionary <string, Properties70> ();
        var indexes = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"NodeAttribute::\", \"Camera\" {")).ToList();

        string[] data = new string[0];
        for (int i = 0; i < indexes.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexes[i];
            data        = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id   = data[1].Trim();
            prop70.name = data[5].Trim();

            for (int k = j; k < (j + 12); k++)
            {
                if (UniFBX.list[k].Contains("Up"))
                {
                    data        = UniFBX.list[k].Split(',');
                    prop70.up.x = float.Parse(data[data.Length - 3]);
                    prop70.up.y = float.Parse(data[data.Length - 2]);
                    prop70.up.z = float.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("UpVector"))
                {
                    data            = UniFBX.list[k].Split(',');
                    prop70.lookAt.x = float.Parse(data[data.Length - 3]);
                    prop70.lookAt.y = float.Parse(data[data.Length - 2]);
                    prop70.lookAt.z = float.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("FieldOfView"))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.fieldOfView = float.Parse(data[data.Length - 1]);
                    break;
                }
            }

            this.properties70.Add(prop70.id, prop70);
        }
        this.IsDone = true;

        //this.IsDone = false;

        //int f = UniFBX.list.FindIndex (x => x.Contains ("\"NodeAttribute::") && x.Contains ("\"Camera\""));
        //if (f == -1) {
        //    this.IsDone = true;
        //    return;
        //}
        //this.properties70 = new Dictionary<string, Properties70> ();

        //string[] data = new string[0];
        //for (int i = f; i < list.Count; i++) {
        //    if (list[i].Contains ("\"NodeAttribute::") && list[i].Contains("\"Camera\"")) {
        //        Properties70 prop70 = new Properties70 ();
        //        data = list[i].Split (new char[] { ':', ',', '\"' });
        //        prop70.id = data[1].Trim ();
        //        prop70.name = data[5].Trim ();

        //        for (int j = i; j < (i + 12); j++) {
        //            if (UniFBX.list[j].Contains ("Up")) {
        //                data = UniFBX.list[j].Split (',');
        //                prop70.up.x = float.Parse (data[data.Length - 3]);
        //                prop70.up.y = float.Parse (data[data.Length - 2]);
        //                prop70.up.z = float.Parse (data[data.Length - 1]);
        //            }
        //            else if (UniFBX.list[j].Contains ("UpVector")) {
        //                data = UniFBX.list[j].Split (',');
        //                prop70.lookAt.x = float.Parse (data[data.Length - 3]);
        //                prop70.lookAt.y = float.Parse (data[data.Length - 2]);
        //                prop70.lookAt.z = float.Parse (data[data.Length - 1]);
        //            }
        //            else if (UniFBX.list[j].Contains ("FieldOfView")) {
        //                data = UniFBX.list[j].Split (',');
        //                prop70.fieldOfView = float.Parse (data[data.Length - 1]);
        //                break;
        //            }
        //        }
        //        this.properties70.Add (prop70.id, prop70);
        //        i = i + 12;
        //    }
        //    else if (
        //        list[i].Contains ("\"Model::") ||
        //        list[i].Contains ("\"Material::") ||
        //        list[i].Contains ("\"AnimStack::") ||
        //        list[i].Contains ("Connections:  {")
        //        ) {
        //        this.IsDone = true;
        //        return;
        //    }
        //}
    }
Beispiel #5
0
    private void Run( )
    {
        this.IsDone                  = false;
        this.properties70            = new Dictionary <string, Properties70> ();
        this.materials               = new Dictionary <string, Material> ();
        this.textureMaterials        = new Dictionary <string, string> ();
        this.layeredTextureMaterials = new Dictionary <string, string> ();

        var indexesTextures = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"Texture::")).ToList();

        string[] data = new string[0];

        for (int i = 0; i < indexesTextures.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexesTextures[i];
            data            = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id       = data[1].Trim();
            prop70.filename = data[5].Trim();

            Vector2 v = Vector2.zero;
            for (int k = j; k < (j + 16); k++)
            {
                if (UniFBX.list[k].Contains("\"Translation\""))
                {
                    data          = UniFBX.list[k].Split(',');
                    v.x           = float.Parse(data[data.Length - 3]);
                    v.y           = float.Parse(data[data.Length - 2]);
                    prop70.offset = v;
                }
                else if (UniFBX.list[k].Contains("\"Scaling\""))
                {
                    data           = UniFBX.list[k].Split(',');
                    v.x            = float.Parse(data[data.Length - 3]);
                    v.y            = float.Parse(data[data.Length - 2]);
                    prop70.scaling = v;
                }
                else if (UniFBX.list[k].Contains("FileName: "))
                {
                    data            = UniFBX.list[k].Split(':');
                    data            = data[data.Length - 1].Split('\\');
                    prop70.filename = data[data.Length - 1].Replace("\"", "").Trim();
                }
            }

            if (!this.properties70.ContainsKey(prop70.id))
            {
                this.properties70.Add(prop70.id, prop70);
            }
        }

        var indexesVideos = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("Content: ,")).ToList();

        if (indexesVideos.Count > 0)
        {
            this.embeddedTextures = new Dictionary <string, byte[]> ();
            for (int i = 0; i < indexesVideos.Count; i++)
            {
                int j = indexesVideos[i];
                data = UniFBX.list[j - 1].Split(new char[] { '\"', '\\' });
                string filename = data[data.Length - 2];
                if (!this.embeddedTextures.ContainsKey(filename))
                {
                    string        s   = "";
                    List <string> str = new List <string> ();
                    j = j + 1;
                    while (!UniFBX.list[j].Contains("}"))
                    {
                        s += UniFBX.list[j].Trim();
                        j++;
                    }
                    if (s != "")
                    {
                        s = s.Replace("\"", "");
                        s = s.Replace(",", "");
                        this.embeddedTextures.Add(filename, System.Convert.FromBase64String(s));
                    }
                }
            }
            this.IsEmbedded = true;
#if UNITY_EDITOR
            Debug.Log("Embedded textures!");
#endif
        }
        else
        {
            this.IsEmbedded = false;
        }

        this.IsDone = true;
    }
    private void Run( )
    {
        this.IsDone       = false;
        this.properties70 = new Dictionary <string, Properties70> ();
        this.nameObjects  = new List <string> ();
        this.LclTransform = new List <Properties70> ();

        var indexes = Enumerable.Range(0, UniFBX.list.Count).Where(x => UniFBX.list[x].Contains("\"Model::")).ToList();

        string[] data = new string[0];
        for (int i = 0; i < indexes.Count; i++)
        {
            Properties70 prop70 = new Properties70();
            var          j      = indexes[i];
            data        = UniFBX.list[j].Split(new char[] { ':', ',', '\"' });
            prop70.id   = data[1].Trim();
            prop70.name = data[5].Trim();
            Vector3    p = Vector3.zero;
            Vector3    r = Vector3.zero;
            Quaternion q = Quaternion.identity;

            for (int k = (j + 1); k < (j + 25); k++)
            {
                if (UniFBX.list[k].Contains("Lcl Translation"))
                {
                    data = UniFBX.list[k].Split(',');
                    p.x  = -float.Parse(data[data.Length - 3]);
                    p.y  = float.Parse(data[data.Length - 2]);
                    p.z  = float.Parse(data[data.Length - 1]);
                    p   *= this.setting.meshes.scaleFactor;
                    prop70.LclPosition = p;
                }
                else if (UniFBX.list[k].Contains("Lcl Rotation"))
                {
                    data = UniFBX.list[k].Split(',');
                    r.x  = float.Parse(data[data.Length - 3]);
                    r.y  = -float.Parse(data[data.Length - 2]);
                    r.z  = -float.Parse(data[data.Length - 1]);
                    if (r.x == 0)
                    {
                        //YZX sequence
                        q  = Quaternion.Euler(Vector3.up * r.y);
                        q *= Quaternion.Euler(Vector3.forward * r.z);
                        q *= Quaternion.Euler(Vector3.right * r.x);
                    }
                    else
                    {
                        //ZYX sequence
                        q  = Quaternion.Euler(Vector3.forward * r.z);
                        q *= Quaternion.Euler(Vector3.up * r.y);
                        q *= Quaternion.Euler(Vector3.right * r.x);
                    }
                    prop70.LclRotation = q;
                }
                else if (UniFBX.list[k].Contains("Lcl Scaling"))
                {
                    data = UniFBX.list[k].Split(',');
                    prop70.LclScaling.x = float.Parse(data[data.Length - 3]);
                    prop70.LclScaling.y = float.Parse(data[data.Length - 2]);
                    prop70.LclScaling.z = float.Parse(data[data.Length - 1]);
                }
                else if (UniFBX.list[k].Contains("Shading:"))
                {
                    break;
                }
                else if (UniFBX.list[k].Contains("Connections:  {"))
                {
                    this.IsDone = true;
                    return;
                }
            }

            this.properties70.Add(prop70.id, prop70);
            this.LclTransform.Add(prop70);
            this.nameObjects.Add(prop70.name);
        }
        this.IsDone = true;
    }