Ejemplo n.º 1
0
 public static void AddMeshes(ModelContent mc, PieceBuilder mb)
 {
     foreach (ModelMeshContent mmc in mc.Meshes)
     {
         FlattenTransform(mmc.SourceMesh);
         mb.StartMesh(mmc);
         foreach (ModelMeshPartContent mmpc in mmc.MeshParts)
         {
             mb.AddMesh(mmpc);
         }
     }
 }
Ejemplo n.º 2
0
        public unsafe static byte[] ByteArray(ushort[] data)
        {
            byte[] ret = new byte[data.Length * 2];
            fixed(byte *dst = ret)
            {
                fixed(ushort *src = data)
                {
                    PieceBuilder.Copy((byte *)src, dst, ret.Length);
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
        public override List <KiloWatt.Pipeline.PieceContent> Process(System.String input, ContentProcessorContext context)
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(input);
            List <PieceContent> pieceList = new List <PieceContent>();

            foreach (XmlNode xn in xd.SelectNodes("//Model"))
            {
                string relPath = xn.InnerText;
                int    lio     = relPath.LastIndexOf('/');
                string path    = "";
                string pattern = "";
                if (lio == -1)
                {
                    pattern = relPath;
                }
                else
                {
                    path    = relPath.Substring(0, lio);
                    pattern = relPath.Substring(lio + 1);
                }
                string[] fileNames = System.IO.Directory.GetFiles(path, pattern);
                foreach (string fileName in fileNames)
                {
                    context.Logger.LogMessage("Importing model {0}");
                    ModelContent mc = context.BuildAndLoadAsset <NodeContent, ModelContent>(
                        new ExternalReference <NodeContent>(System.IO.Path.Combine(path, fileName)), "Dxt5ModelProcessor");
                    //  1) bake material into color channel, if not existing
                    //  2) bake to identity transform
                    //  3) add as a node to the mesh builder
                    PieceBuilder mb = PieceBuilder.NewPiece(System.IO.Path.GetFileNameWithoutExtension(xn.InnerText));
                    AddMeshes(mc, mb);
                    PieceContent pc = mb.FinishPiece();
                    pieceList.Add(pc);
                }
            }
            return(pieceList);
        }