Exemplo n.º 1
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            foreach (var mesh in ModelBlocks)
                mesh.WrtieToStream(writer);
        }
        //public List<CIwVec3> Vertices = new List<CIwVec3>();
        //public List<Cb4aCollisionMeshSoupEdge> Edges = new List<Cb4aCollisionMeshSoupEdge>();
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);
            writer.WriteKeyVal("num_planes", Planes.Count);
            foreach (var v in Planes)
                writer.WriteArray("plane", new int[] { v.v.x, v.v.y, v.v.z,v.k });
            //writer.WriteKeyVal("num_vertices", Vertices.Count);
            //foreach (var v in Vertices)
            //    writer.WriteVec3("v",v);
            //writer.WriteKeyVal("num_edges", Edges.Count);
            //foreach (var e in Edges)
            //{
            //    CIwVec3 d = e.V1 - e.V0;

            //    writer.BeginWriteLine();
            //    writer.Write(string.Format(CultureInfo.InvariantCulture, "e {0}",d.Length));
            //    writer.Write(string.Format(CultureInfo.InvariantCulture, " {{{0},{1},{2}}}", e.V0.x, e.V0.y, e.V0.z));
            //    writer.Write(string.Format(CultureInfo.InvariantCulture, " {{{0},{1},{2}}}", d.x, d.y, d.z));
            //    writer.EndWriteLine();
            //}
            writer.WriteKeyVal("num_faces", Faces.Count);
            foreach (var f in Faces)
            {
                writer.WriteArray("face ", new int[] { f.startPlane,f.numPlanes });
                //writer.WriteLine("next_face");
                //writer.WriteArray("face_p", new int[] { f.Normal.x, f.Normal.y, f.Normal.z, f.Distance });
                //writer.WriteKeyVal("num_face_edges", f.edges.Count);
                //foreach (var e in f.edges)
                //{
                //    writer.WriteArray("edge_p", new int[] { e.Normal.x, e.Normal.y, e.Normal.z, e.Distance });
                //}
            }
        }
Exemplo n.º 3
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            if (Clusters.Count > 0)
            {
                writer.WriteKeyVal("num_visible_clusters", Clusters.Count);
                writer.BeginWriteLine();
                writer.Write("visible_clusters");
                foreach (var l in Clusters)
                {
                    writer.Write(string.Format(" {0}", l));
                }
                writer.EndWriteLine();
            }
            if (VisibleLeaves.Count > 0)
            {
                writer.WriteKeyVal("num_visible_leaves", VisibleLeaves.Count);
                writer.BeginWriteLine();
                writer.Write("visible_leaves");
                foreach (var l in VisibleLeaves)
                {
                    writer.Write(string.Format(" {0}", l));
                }
                writer.EndWriteLine();
            }
            foreach (var l in Colliders)
            {
                ((CIwParseable)l).WrtieToStream(writer);
            }
        }
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     writer.WriteKeyVal("num_planes", Planes.Count);
     foreach (var v in Planes)
         writer.WriteArray("plane", new int[] { v.v.x, v.v.y, v.v.z, v.k });
 }
Exemplo n.º 5
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            writer.WriteString("bone", bone);
            writer.WriteVec3("pos", pos);
            writer.WriteQuat("rot", rot);
        }
Exemplo n.º 6
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     if (!string.IsNullOrEmpty(parent))
         writer.WriteString("parent", parent);
     writer.WriteVec3("pos", pos);
     writer.WriteQuat("rot", rot);
 }
Exemplo n.º 7
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            writer.WriteKeyVal("numBones",Bones.Count);
            foreach (var bone in Bones)
                bone.WrtieToStream(writer);
        }
Exemplo n.º 8
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);
            writer.WriteKeyVal("time", time);

            foreach (var bone in bones)
                bone.WrtieBodyToStream(writer);
        }
Exemplo n.º 9
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     writer.WriteString("classname", classname);
     writer.WriteVec3("origin", origin);
     foreach (var val in values)
     {
         writer.WriteString(val.Key, val.Value);
     }
 }
 internal void WrtieBodyToStream(CTextWriter writer)
 {
     writer.BeginWriteLine();
     writer.Write("vertWeights {");
     writer.Write(Vertex.ToString());
     foreach (var w in Weights)
         writer.Write(string.Format(CultureInfo.InvariantCulture, ",{0}", w));
     writer.Write("}");
     writer.EndWriteLine();
 }
Exemplo n.º 11
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     //writer.WriteArray("plane", new int[]{PlaneNormal.x,(int)PlaneNormal.y,(int)PlaneNormal.z, (int)(PlaneDistance * AirplaySDKMath.IW_GEOM_ONE)});
     writer.WriteKeyVal("plane", Plane);
     writer.WriteKeyVal("is_front_leaf", IsFrontLeaf);
     writer.WriteKeyVal("front", Front);
     writer.WriteKeyVal("is_back_leaf", IsBackLeaf);
     writer.WriteKeyVal("back", Back);
 }
Exemplo n.º 12
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            useBones.WrtieBodyToStream(writer);
            writer.WriteKeyVal("numVerts", vertWeights.Count);
            foreach (var vw in vertWeights)
            {
                vw.WrtieBodyToStream(writer);
            }
        }
Exemplo n.º 13
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);
            if (skeleton != null)
                writer.WriteString("skeleton", skeleton.Name);
            if (model != null)
                writer.WriteString("model", model.Name);

            foreach (var skinSet in SkinSets)
                skinSet.WrtieToStream(writer);
        }
Exemplo n.º 14
0
 public void Convert(string modelFilePath, string groupFilePath)
 {
     var doc = ModelDocument.Load(modelFilePath);
     var group = new CIwResGroup();
     group.Name = doc.Name;
     Convert(doc, group);
     using (var w = new CTextWriter(groupFilePath))
     {
         group.WrtieToStream(w);
         w.Close();
     }
 }
Exemplo n.º 15
0
 internal void WrtieBodyToStream(CTextWriter writer)
 {
     writer.BeginWriteLine();
     writer.Write("useBones { ");
     if (Bones != null)
     {
         foreach (var w in Bones)
             writer.Write(string.Format(CultureInfo.InvariantCulture, "{0} ", w));
     }
     writer.Write("}");
     writer.EndWriteLine();
 }
Exemplo n.º 16
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     writer.WriteString("skeleton", skeleton.Name);
     if (KeyFrames.Count == 0)
     {
         (new CIwAnimKeyFrame()).WrtieToStream(writer);
     }
     else
     {
         foreach (var bone in KeyFrames)
             bone.WrtieToStream(writer);
     }
 }
Exemplo n.º 17
0
        public override void WrtieToStream(CTextWriter writer)
        {
            string filePath = Path.Combine(Path.GetDirectoryName(writer.FileName), FilePath);
            if (Bitmap != null)
            {
                Bitmap.Save(filePath);
                writer.WriteLine(string.Format("\"{0}\"", FilePath.Replace("\"", "\\\"")));
            }
            else
            {
                if (File.Exists(filePath))
                    writer.WriteLine(string.Format("\"{0}\"", FilePath.Replace("\"", "\\\"")));
                else
                    writer.WriteLine(string.Format("#\"{0}\"", FilePath.Replace("\"", "\\\"")));

            }
        }
Exemplo n.º 18
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     writer.WriteKeyVal("num_materials", Materials.Count);
     foreach (var l in Materials)
     {
         l.WrtieToStream(writer);
     }
     if (Planes.Count > 0)
     {
         writer.WriteKeyVal("num_planes", Planes.Count);
         foreach (var l in Planes)
         {
             writer.WriteArray("plane", new int[] { (int)l.v.x, (int)l.v.y, (int)l.v.z, (int)(l.k * AirplaySDKMath.IW_GEOM_ONE) });
         }
     }
     writer.WriteKeyVal("num_vbs", VertexBuffers.Count);
     foreach (var l in VertexBuffers)
     {
         l.WrtieToStream(writer);
     }
     writer.WriteKeyVal("num_clusters", subclusters.Count);
     foreach (var l in subclusters)
     {
         l.WrtieToStream(writer);
     }
     writer.WriteKeyVal("num_leaves", Leaves.Count);
     foreach (var l in Leaves)
     {
         l.WrtieToStream(writer);
     }
     writer.WriteKeyVal("num_nodes", Nodes.Count);
     foreach (var l in Nodes)
     {
         l.WrtieToStream(writer);
     }
     writer.WriteKeyVal("num_entities", Entities.Count);
     foreach (var l in Entities)
     {
         l.WrtieToStream(writer);
     }
 }
Exemplo n.º 19
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     writer.WriteVec3("mins", mins);
     writer.WriteVec3("maxs", maxs);
 }
Exemplo n.º 20
0
 public override void WrtieBodyToStream(CTextWriter writer)
 {
     base.WrtieBodyToStream(writer);
     if (this.Name != null)
         writer.WriteString("name", this.Name);
 }
Exemplo n.º 21
0
        public override void WrtieBodyToStream(CTextWriter writer)
        {
            base.WrtieBodyToStream(writer);

            writer.WriteLine("shared true");

            var materials = new List<CIwMaterial>();
            var geos = new List<CIwModel>();
            var textures = new List<CIwTexture>();
            var others = new List<CIwManaged>();
            foreach (var l in list)
            {
                if (l is CIwMaterial)
                    materials.Add((CIwMaterial)l);
                else if (l is CIwModel)
                    geos.Add((CIwModel)l);
                else if (l is CIwTexture)
                    textures.Add((CIwTexture)l);
                else
                    others.Add((CIwManaged)l);
            }
            string name = Path.GetFileNameWithoutExtension(writer.FileName);
            string subdir = Path.Combine(writer.FileDirectory, name);
            if (textures.Count > 0)
            {
                foreach (var l in textures)
                {
                    l.WrtieToStream(writer);
                }
            }
            if (materials.Count > 0)
            {
                writer.WriteLine(string.Format("\"./{0}.mtl\"", name));
                using (CTextWriter subWriter = new CTextWriter(Path.Combine(writer.FileDirectory, name + ".mtl")))
                {
                    foreach (var l in materials)
                    {
                        l.WrtieToStream(subWriter);
                    }
                    subWriter.Close();
                }
            }
            if (geos.Count > 0)
            {
                foreach (var l in geos)
                {
                    var geoFileName = l.Name;
                    foreach (var c in Path.GetInvalidFileNameChars())
                        geoFileName = geoFileName.Replace(c, '_');
                    writer.WriteLine(string.Format("\"./{0}.geo\"", geoFileName));

                    string fullGeoFileName = Path.Combine(writer.FileDirectory, geoFileName + ".geo");

                    using (CTextWriter subWriter = new CTextWriter(fullGeoFileName))
                    {
                        l.WrtieToStream(subWriter);
                        subWriter.Close();
                    }

                    if (l.Skin != null)
                    {
                        if (l.Skin.skeleton != null)
                        {
                            writer.WriteLine(string.Format("\"./{0}.skel\"", geoFileName));
                            fullGeoFileName = Path.ChangeExtension(fullGeoFileName, ".skel");
                            using (CTextWriter subWriter = new CTextWriter(fullGeoFileName))
                            {
                                l.Skin.skeleton.WrtieToStream(subWriter);
                                subWriter.Close();
                            }
                        }

                        writer.WriteLine(string.Format("\"./{0}.skin\"", geoFileName));
                        fullGeoFileName = Path.ChangeExtension(fullGeoFileName, ".skin");
                        using (CTextWriter subWriter = new CTextWriter(fullGeoFileName))
                        {
                            l.Skin.WrtieToStream(subWriter);
                            subWriter.Close();
                        }
                        if (l.Skin.Animations != null)
                        {
                            var fullAnimFileName = Path.Combine(Path.Combine(Path.GetDirectoryName(fullGeoFileName), ".."), "animations");
                            if (!Directory.Exists(fullAnimFileName))
                                Directory.CreateDirectory(fullAnimFileName);
                            fullAnimFileName = Path.Combine(fullAnimFileName, geoFileName);
                            if (!Directory.Exists(fullAnimFileName))
                                Directory.CreateDirectory(fullAnimFileName);
                            foreach (var a in l.Skin.Animations)
                            {
                                string animationName = a.Name;
                                foreach (var c in Path.GetInvalidFileNameChars())
                                    animationName = animationName.Replace(c, '_');

                                writer.WriteLine(string.Format("\"../animations/{0}/{1}.anim\"", geoFileName, animationName));
                                fullGeoFileName = Path.Combine(fullAnimFileName, animationName+".anim");
                                using (CTextWriter subWriter = new CTextWriter(fullGeoFileName))
                                {
                                    a.WrtieToStream(subWriter);
                                    subWriter.Close();
                                }
                            }
                        }
                    }
                }
            }
            //if (geos.Count > 0)
            //{
            //    if (!string.IsNullOrEmpty(subdir) && !Directory.Exists(subdir))
            //        Directory.CreateDirectory(subdir);
            //    foreach (var l in geos)
            //    {
            //        var geoFileName = l.Name;
            //        foreach (var c in Path.GetInvalidFileNameChars())
            //            geoFileName = geoFileName.Replace(c,'_');
            //        writer.WriteLine(string.Format("\"./{0}/{1}.geo\"", Path.GetFileName(subdir),geoFileName));
            //        using (CTextWriter subWriter = new CTextWriter(Path.Combine(subdir, geoFileName + ".geo")))
            //        {
            //            l.WrtieToStream(subWriter);
            //            subWriter.Close();
            //        }
            //    }
            //}
            foreach (var l in others)
            {
                l.WrtieToStream(writer);
            }
        }
Exemplo n.º 22
0
 public virtual void WrtieBodyToStream(CTextWriter writer)
 {
 }
Exemplo n.º 23
0
 public virtual void WrtieToStream(CTextWriter writer)
 {
     writer.OpenChild(this.GetType().Name);
     WrtieBodyToStream(writer);
     writer.CloseChild();
 }