void WriteConstructs()
        {
            FixConstructor fix = null;
            RevConstructor rev = null;
            PrisConstructor pris = null;
            SphereConstructor sphere = null;

            foreach (var p in vmsModel.AllParts)
            {
                var con = p.Construct;
                if (con is FixConstruct)
                {
                    if (fix == null) fix = new FixConstructor();
                    fix.Add((FixConstruct)con);
                }
                else if (con is RevConstruct)
                {
                    if (rev == null) rev = new RevConstructor();
                    rev.Add((RevConstruct)con);
                }
                else if (con is PrisConstruct)
                {
                    if (pris == null) pris = new PrisConstructor();
                    pris.Add((PrisConstruct)con);
                }
                else if (con is SphereConstruct)
                {
                    if (sphere == null) sphere = new SphereConstructor();
                    sphere.Add((SphereConstruct)con);
                }
            }

            hprefs.Cons.Children = new List<LUtfNode>();
            if(fix != null) {
                hprefs.Cons.Children.Add(new LUtfNode() {
                    Name = "Fix", Parent = hprefs.Cons, Data = fix.GetData()
                });
            }
            if(rev != null) {
                hprefs.Cons.Children.Add(new LUtfNode() {
                    Name = "Rev", Parent = hprefs.Cons, Data = rev.GetData()
                });
            }
            if(pris != null) {
                hprefs.Cons.Children.Add(new LUtfNode() {
                    Name = "Pris", Parent = hprefs.Cons, Data = pris.GetData()
                });
            }
            if(sphere != null) {
                hprefs.Cons.Children.Add(new LUtfNode() {
                    Name = "Sphere", Parent = hprefs.Cons, Data = sphere.GetData()
                });
            }
        }
Пример #2
0
        void ProcessConstruct(string parentName, OutModel mdl, LUtfNode cmpnd, FixConstructor fix, string suffix, ref int index)
        {
            cmpnd.Children.Add(CmpndNode(cmpnd, "PART_" + mdl.Name, mdl.Name + suffix, mdl.Name, index++));
            if(mdl.Transform == true) {
                fix.Add(parentName, mdl.Name, mdl.Def.Transform);
            } else {
                fix.Add(parentName, mdl.Name, Matrix4x4.Identity);
            }
            foreach (var child in mdl.Children)
                ProcessConstruct(mdl.Name, child, cmpnd, fix, suffix, ref index);

        }
Пример #3
0
        bool Finish(out EditableUtf result)
        {
            result = null;
            var utf = new EditableUtf();
            //Vanity
            var expv = new LUtfNode()
            {
                Name = "Exporter Version", Parent = utf.Root
            };

            expv.Data = System.Text.Encoding.UTF8.GetBytes(EXPORTER_VERSION);
            utf.Root.Children.Add(expv);
            //Apply Material names
            foreach (var mdl in output)
            {
                ApplyMatNames(mdl);
            }
            //Actual stuff
            if (output.Count == 1)
            {
                var modelName = modelNameBuffer.GetText();
                if (string.IsNullOrEmpty(modelName))
                {
                    modelName = modelNameDefault;
                }
                if (output[0].Children.Count == 0)
                {
                    Export3DB(modelName, utf.Root, output[0]);
                }
                else
                {
                    var suffix = (new Random().Next()) + ".3db";
                    var vmslib = new LUtfNode()
                    {
                        Name = "VMeshLibrary", Parent = utf.Root, Children = new List <LUtfNode>()
                    };
                    utf.Root.Children.Add(vmslib);
                    var cmpnd = new LUtfNode()
                    {
                        Name = "Cmpnd", Parent = utf.Root, Children = new List <LUtfNode>()
                    };
                    utf.Root.Children.Add(cmpnd);
                    ExportModels(modelName, utf.Root, suffix, vmslib, output[0]);
                    int            cmpndIndex = 1;
                    FixConstructor fix        = new FixConstructor();
                    cmpnd.Children.Add(CmpndNode(cmpnd, "Root", output[0].Name + suffix, "Root", 0));
                    foreach (var child in output[0].Children)
                    {
                        ProcessConstruct("Root", child, cmpnd, fix, suffix, ref cmpndIndex);
                    }
                    var cons = new LUtfNode()
                    {
                        Name = "Cons", Parent = cmpnd, Children = new List <LUtfNode>()
                    };
                    var trs = new LUtfNode()
                    {
                        Name = "Fix", Parent = cons, Data = fix.GetData()
                    };
                    cons.Children.Add(trs);
                    cmpnd.Children.Add(cons);
                }
                if (generateMaterials)
                {
                    List <string> materials = new List <string>();
                    foreach (var mdl in output)
                    {
                        IterateMaterials(materials, mdl);
                    }
                    var mats = new LUtfNode()
                    {
                        Name = "material library", Parent = utf.Root
                    };
                    mats.Children = new List <LUtfNode>();
                    int i = 0;
                    foreach (var mat in materials)
                    {
                        mats.Children.Add(DefaultMaterialNode(mats, mat, i++));
                    }
                    var txms = new LUtfNode()
                    {
                        Name = "texture library", Parent = utf.Root
                    };
                    txms.Children = new List <LUtfNode>();
                    foreach (var mat in materials)
                    {
                        txms.Children.Add(DefaultTextureNode(txms, mat));
                    }
                    utf.Root.Children.Add(mats);
                    utf.Root.Children.Add(txms);
                }
                result = utf;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        void WriteConstructs()
        {
            var               cmp    = (CmpFile)drawable;
            FixConstructor    fix    = null;
            RevConstructor    rev    = null;
            PrisConstructor   pris   = null;
            SphereConstructor sphere = null;

            foreach (var con in cmp.Constructs)
            {
                if (con is FixConstruct)
                {
                    if (fix == null)
                    {
                        fix = new FixConstructor();
                    }
                    fix.Add((FixConstruct)con);
                }
                else if (con is RevConstruct)
                {
                    if (rev == null)
                    {
                        rev = new RevConstructor();
                    }
                    rev.Add((RevConstruct)con);
                }
                else if (con is PrisConstruct)
                {
                    if (pris == null)
                    {
                        pris = new PrisConstructor();
                    }
                    pris.Add((PrisConstruct)con);
                }
                else if (con is SphereConstruct)
                {
                    if (sphere == null)
                    {
                        sphere = new SphereConstructor();
                    }
                    sphere.Add((SphereConstruct)con);
                }
            }

            hprefs.Cons.Children = new List <LUtfNode>();
            if (fix != null)
            {
                hprefs.Cons.Children.Add(new LUtfNode()
                {
                    Name = "Fix", Parent = hprefs.Cons, Data = fix.GetData()
                });
            }
            if (rev != null)
            {
                hprefs.Cons.Children.Add(new LUtfNode()
                {
                    Name = "Rev", Parent = hprefs.Cons, Data = rev.GetData()
                });
            }
            if (pris != null)
            {
                hprefs.Cons.Children.Add(new LUtfNode()
                {
                    Name = "Pris", Parent = hprefs.Cons, Data = pris.GetData()
                });
            }
            if (sphere != null)
            {
                hprefs.Cons.Children.Add(new LUtfNode()
                {
                    Name = "Sphere", Parent = hprefs.Cons, Data = sphere.GetData()
                });
            }
        }