Ejemplo n.º 1
0
        /// <summary>
        /// Creates a .x File for all Models stored in the GMDC
        /// </summary>
        /// <param name="models">List of all P3Models you want to export</param>
        /// <returns>The content of the x File</returns>
        public MemoryStream GenerateX(GmdcGroups models)
        {
            IGmdcExporter exporter = ExporterLoader.FindExporterByExtension(".x");

            if (exporter == null)
            {
                throw new Exception("No valid Direct X Exporter plugin was found!");
            }

            exporter.Component.Sorting = ElementSorting.Preview;
            exporter.Process(this, models);
            return((MemoryStream)exporter.FileContent.BaseStream);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public GeometryDataContainer(Rcol parent) : base(parent)
        {
            sgres = new SGResource(null);

            version = 0x04;
            BlockID = 0xAC4F8687;

            elements = new GmdcElements();
            links    = new GmdcLinks();
            groups   = new GmdcGroups();

            model = new GmdcModel(this);

            joints = new GmdcJoints();
            tried  = false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="gmdc">The Gmdc File the Export is based on</param>
 /// <param name="groups">The list of Groups you want to export</param>
 /// <remarks><see cref="AbstractGmdcExporter.FileContent"/> will contain the Exported .x File</remarks>
 public GmdcExportToXSI(GeometryDataContainer gmdc, GmdcGroups groups) : base(gmdc, groups)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="gmdc">The Gmdc File the Export is based on</param>
 /// <param name="groups">The list of Groups you want to export</param>
 /// <remarks><see cref="AbstractGmdcExporter.FileContent"/> will contain the Exported .txt File</remarks>
 public GmdcExportToMilkShapeAscii(GeometryDataContainer gmdc, GmdcGroups groups) : base(gmdc, groups)
 {
 }
Ejemplo n.º 5
0
        public Ambertation.Scenes.Scene GetScene(GmdcGroups groups, string absimgpath, string imgfolder, ElementOrder component)
        {
            if (absimgpath != null)
            {
                if (imgfolder == null)
                {
                    imgfolder = absimgpath;
                }
                imgfolder = imgfolder.Trim();
                if (imgfolder.Length > 0 && !imgfolder.EndsWith(@"\"))
                {
                    imgfolder += @"\";
                }

                if (!System.IO.Directory.Exists(absimgpath))
                {
                    System.IO.Directory.CreateDirectory(absimgpath);
                }
            }

            Scene scn = new Scene();

            Hashtable jointmap = new Hashtable();

            try
            {
                jointmap = AddJointsToScene(scn, component);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }


            TextureLocator tl = new TextureLocator(gmdc.Parent.Package);

            System.Collections.Hashtable txmts = tl.FindMaterials(gmdc.Parent);
            foreach (string key in txmtmap.Keys)
            {
                object o = txmtmap[key];
                if (o != null)
                {
                    txmts[key] = txmtmap[key];
                }
            }


            Hashtable txtrs = tl.FindReferencedTXTR(txmts, null);

            foreach (string key in txtrmap.Keys)
            {
                object o = txtrmap[key];
                if (o != null)
                {
                    txtrs[key] = o;
                }
            }

            txtrs = tl.GetLargestImages(txtrs);
            txmts = tl.GetMaterials(txmts, scn);
            tl.Dispose();

            foreach (GmdcGroup g in groups)
            {
                Ambertation.Scenes.Material mat = txmts[g.Name] as Ambertation.Scenes.Material;
                if (mat == null)
                {
                    mat = scn.CreateMaterial("mat_" + g.Name);
                }
                else
                {
                    mat.Name = "mat_" + g.Name;
                }
                System.IO.MemoryStream s = txtrs[g.Name] as System.IO.MemoryStream;
                if (s != null)
                {
                    try
                    {
                        System.Drawing.Image img = System.Drawing.Image.FromStream(s);
                        if (absimgpath != null)
                        {
                            img.Save(System.IO.Path.Combine(absimgpath, g.Name + ".png"), System.Drawing.Imaging.ImageFormat.Png);
                        }
                        mat.Texture.FileName     = imgfolder + g.Name + ".png";
                        mat.Texture.Size         = img.Size;
                        mat.Texture.TextureImage = img;
                    }
                    catch {}
                }
                Ambertation.Scenes.Mesh m = scn.CreateMesh(g.Name, mat);

                GmdcElement vertexe = g.Link.FindElementType(ElementIdentity.Vertex);
                //	GmdcElement vertexme = g.Link.FindElementType(ElementIdentity.MorphVertexDelta);
                GmdcElement normale    = g.Link.FindElementType(ElementIdentity.Normal);
                GmdcElement texte      = g.Link.FindElementType(ElementIdentity.UVCoordinate);
                GmdcElement bonee      = g.Link.FindElementType(ElementIdentity.BoneAssignment);
                GmdcElement bonewighte = g.Link.FindElementType(ElementIdentity.BoneWeights);
                GmdcElement bumpnormal = g.Link.FindElementType(ElementIdentity.BumpMapNormal);

                int nr = g.Link.GetElementNr(vertexe);
                //	int mnr = g.Link.GetElementNr(vertexme);
                for (int i = 0; i < g.Link.ReferencedSize; i++)
                {
                    Vector3f v = new Vector3f(g.Link.GetValue(nr, i).Data[0], g.Link.GetValue(nr, i).Data[1], g.Link.GetValue(nr, i).Data[2]);

                    /*Vector3f vm = new Vector3f(g.Link.GetValue(mnr, i).Data[0], g.Link.GetValue(mnr, i).Data[1], g.Link.GetValue(mnr, i).Data[2]);
                     * v += vm;*/
                    v = component.TransformScaled(v);

                    m.Vertices.Add(v.X, v.Y, v.Z);
                }

                if (normale != null)
                {
                    nr = g.Link.GetElementNr(normale);
                    for (int i = 0; i < g.Link.ReferencedSize; i++)
                    {
                        Vector3f v = new Vector3f(g.Link.GetValue(nr, i).Data[0], g.Link.GetValue(nr, i).Data[1], g.Link.GetValue(nr, i).Data[2]);
                        v = component.TransformNormal(v);
                        m.Normals.Add(v.X, v.Y, v.Z);
                    }
                }

                if (bumpnormal != null)
                {
                    nr = g.Link.GetElementNr(bumpnormal);
                    for (int i = 0; i < g.Link.ReferencedSize; i++)
                    {
                        Vector3f v = new Vector3f(g.Link.GetValue(nr, i).Data[0], g.Link.GetValue(nr, i).Data[1], g.Link.GetValue(nr, i).Data[2]);
                        v = component.TransformNormal(v);
                        m.BumpMapNormalDelta.Add(v.X, v.Y, v.Z);
                    }
                }

                if (texte != null)
                {
                    nr = g.Link.GetElementNr(texte);
                    for (int i = 0; i < g.Link.ReferencedSize; i++)
                    {
                        Vector2f v = new Vector2f(g.Link.GetValue(nr, i).Data[0], g.Link.GetValue(nr, i).Data[1]);
                        m.TextureCoordinates.Add(v.X, 1 - v.Y);
                    }
                }

                for (int i = 0; i < g.Faces.Count - 2; i += 3)
                {
                    m.FaceIndices.Add(g.Faces[i], g.Faces[i + 1], g.Faces[i + 2]);
                }

                AddEnvelopes(g, m, bonee, bonewighte, jointmap);
            }

            return(scn);
        }
Ejemplo n.º 6
0
 public Ambertation.Scenes.Scene GetScene(GmdcGroups groups, string absimgpath, ElementOrder component)
 {
     return(GetScene(groups, absimgpath, null, component));
 }
Ejemplo n.º 7
0
 public Ambertation.Scenes.Scene GetScene(GmdcGroups groups, ElementOrder component)
 {
     return(GetScene(groups, null, null, component));
 }