예제 #1
0
        public PieceContent FinishPiece()
        {
            PieceContent ret = new PieceContent(name_);

            ret.vertexArray = BuildVertexArray(ref ret.stride);
            ret.declaration = dataChannels.ToArray();
            ret.indexArray  = triangleList.ToArray();
            return(ret);
        }
예제 #2
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);
        }