コード例 #1
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaPolygons(ColladaRoot collada, XElement node)
            {
                foreach (XElement current in node.Elements(ColladaRoot.Namespace + "input"))
                {
                    Inputs.Add(new ColladaInput(collada, current));
                }
                int count = 0;

                foreach (ColladaInput i in Inputs)
                {
                    if (i.Offset > count)
                    {
                        count = i.Offset;
                    }
                }
                InputCount = count + 1;
                foreach (XElement current2 in node.Elements(ColladaRoot.Namespace + "vcount"))
                {
                    List <int>           arg_CC_0 = VCount;
                    IEnumerable <string> arg_C7_0 = current2.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                    arg_CC_0.AddRange(arg_C7_0.Select(s => int.Parse(s, CultureInfo.InvariantCulture)));
                }
                foreach (XElement current3 in node.Elements(ColladaRoot.Namespace + "p"))
                {
                    List <int>           arg_140_0 = P;
                    IEnumerable <string> arg_13B_0 = current3.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                    Func <string, int>   arg_13B_1;
                    if ((arg_13B_1 = ColladaPolygons.c.a__3_1) == null)
                    {
                        arg_13B_1 = (ColladaPolygons.c.a__3_1 = new Func <string, int>(ColladaPolygons.c.a.b__3_1));
                    }
                    arg_140_0.AddRange(arg_13B_0.Select(arg_13B_1));
                }
            }
コード例 #2
0
ファイル: Collada.cs プロジェクト: 1144822034/sc2.2mobile
        public static ModelData Load(Stream stream)
        {
            ModelData   modelData   = new ModelData();
            ColladaRoot colladaRoot = new ColladaRoot(XElement.Load(stream));

            if (colladaRoot.Scene.VisualScene.Nodes.Count > 1)
            {
                ModelBoneData modelBoneData = new ModelBoneData();
                modelData.Bones.Add(modelBoneData);
                modelBoneData.ParentBoneIndex = -1;
                modelBoneData.Name            = string.Empty;
                modelBoneData.Transform       = Matrix.Identity;
                foreach (ColladaNode node in colladaRoot.Scene.VisualScene.Nodes)
                {
                    LoadNode(modelData, modelBoneData, node, Matrix.CreateScale(colladaRoot.Asset.Meter));
                }
            }
            else
            {
                foreach (ColladaNode node2 in colladaRoot.Scene.VisualScene.Nodes)
                {
                    LoadNode(modelData, null, node2, Matrix.CreateScale(colladaRoot.Asset.Meter));
                }
            }
            foreach (ModelBuffersData buffer in modelData.Buffers)
            {
                IndexVertices(buffer.VertexDeclaration.VertexStride, buffer.Vertices, out buffer.Vertices, out buffer.Indices);
            }
            return(modelData);
        }
コード例 #3
0
ファイル: Collada.cs プロジェクト: Suceru/SCPAK
        public static ModelData Load(Stream stream)
        {
            ModelData   modelData   = new ModelData();
            ColladaRoot colladaRoot = new ColladaRoot(XElement.Load(stream));

            if (colladaRoot.Scene.VisualScene.Nodes.Count > 1)
            {
                ModelBoneData modelBoneData = new ModelBoneData();
                modelData.Bones.Add(modelBoneData);
                modelBoneData.ParentBoneIndex = -1;
                modelBoneData.Name            = string.Empty;
                modelBoneData.Transform       = Matrix.Identity;
                using (List <ColladaNode> .Enumerator enumerator = colladaRoot.Scene.VisualScene.Nodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ColladaNode current = enumerator.Current;
                        LoadNode(modelData, modelBoneData, current, colladaRoot.Asset.Meter);
                    }
                    goto IL_F7;
                }
            }
            foreach (ColladaNode current2 in colladaRoot.Scene.VisualScene.Nodes)
            {
                LoadNode(modelData, null, current2, colladaRoot.Asset.Meter);
            }
IL_F7:
            foreach (ModelBuffersData current3 in modelData.Buffers)
            {
                IndexVertices(current3.VertexDeclaration.VertexStride, current3.Vertices, out current3.Vertices, out current3.Indices);
            }
            return(modelData);
        }
コード例 #4
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaVertices(ColladaRoot collada, XElement node) : base(collada, node, "")
            {
                XElement xElement = node.Element(ColladaRoot.Namespace + "input");

                Semantic = xElement.Attribute("semantic").Value;
                Source   = (ColladaSource)collada.ObjectsById[xElement.Attribute("source").Value.Substring(1)];
            }
コード例 #5
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
 public ColladaVisualScene(ColladaRoot collada, XElement node) : base(collada, node, "-ColladaVisualScene")
 {
     foreach (XElement current in node.Elements(ColladaRoot.Namespace + "node"))
     {
         Nodes.Add(new ColladaNode(collada, current));
     }
 }
コード例 #6
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
 public ColladaLibraryGeometries(ColladaRoot collada, XElement node)
 {
     foreach (XElement current in node.Elements(ColladaRoot.Namespace + "geometry"))
     {
         Geometries.Add(new ColladaGeometry(collada, current));
     }
 }
コード例 #7
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
 public ColladaLibraryVisualScenes(ColladaRoot collada, XElement node)
 {
     foreach (XElement current in node.Elements(ColladaRoot.Namespace + "visual_scene"))
     {
         VisualScenes.Add(new ColladaVisualScene(collada, current));
     }
 }
コード例 #8
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
 public ColladaNode(ColladaRoot collada, XElement node) : base(collada, node, "")
 {
     foreach (XElement current in node.Elements())
     {
         if (current.Name == ColladaRoot.Namespace + "matrix")
         {
             IEnumerable <string> arg_91_0 = current.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
             Func <string, float> arg_91_1;
             if ((arg_91_1 = ColladaNode.c.a__3_0) == null)
             {
                 arg_91_1 = (ColladaNode.c.a__3_0 = new Func <string, float>(ColladaNode.c.a.b__3_0));
             }
             float[] array = arg_91_0.Select(arg_91_1).ToArray <float>();
             Transform = Matrix.Transpose(new Matrix(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15])) * Transform;
         }
         else if (current.Name == ColladaRoot.Namespace + "translate")
         {
             IEnumerable <string> arg_13B_0 = current.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
             Func <string, float> arg_13B_1;
             if ((arg_13B_1 = ColladaNode.c.a__3_1) == null)
             {
                 arg_13B_1 = (ColladaNode.c.a__3_1 = new Func <string, float>(ColladaNode.c.a.b__3_1));
             }
             float[] array2 = arg_13B_0.Select(arg_13B_1).ToArray <float>();
             Transform = Matrix.CreateTranslation(array2[0], array2[1], array2[2]) * Transform;
         }
         else if (current.Name == ColladaRoot.Namespace + "rotate")
         {
             IEnumerable <string> arg_1B2_0 = current.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
             Func <string, float> arg_1B2_1;
             if ((arg_1B2_1 = ColladaNode.c.a__3_2) == null)
             {
                 arg_1B2_1 = (ColladaNode.c.a__3_2 = new Func <string, float>(ColladaNode.c.a.b__3_2));
             }
             float[] array3 = arg_1B2_0.Select(arg_1B2_1).ToArray <float>();
             Transform = Matrix.CreateFromAxisAngle(new Vector3(array3[0], array3[1], array3[2]), MathUtils.DegToRad(array3[3])) * Transform;
         }
         else if (current.Name == ColladaRoot.Namespace + "scale")
         {
             IEnumerable <string> arg_238_0 = current.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
             Func <string, float> arg_238_1;
             if ((arg_238_1 = ColladaNode.c.a__3_3) == null)
             {
                 arg_238_1 = (ColladaNode.c.a__3_3 = new Func <string, float>(ColladaNode.c.a.b__3_3));
             }
             float[] array4 = arg_238_0.Select(arg_238_1).ToArray <float>();
             Transform = Matrix.CreateScale(array4[0], array4[1], array4[2]) * Transform;
         }
     }
     foreach (XElement current2 in node.Elements(ColladaRoot.Namespace + "node"))
     {
         Nodes.Add(new ColladaNode(collada, current2));
     }
     foreach (XElement current3 in node.Elements(ColladaRoot.Namespace + "instance_geometry"))
     {
         Geometries.Add((ColladaGeometry)collada.ObjectsById[current3.Attribute("url").Value.Substring(1)]);
     }
 }
コード例 #9
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaGeometry(ColladaRoot collada, XElement node) : base(collada, node, "")
            {
                XElement xElement = node.Element(ColladaRoot.Namespace + "mesh");

                if (xElement != null)
                {
                    Mesh = new ColladaMesh(collada, xElement);
                }
            }
コード例 #10
0
        /**
         * Specifies the Collada resource referenced by this placemark, or <code>null</code> if this placemark has no
         * resource.
         *
         * @param root the Collada resource referenced by this placemark. May be <code>null</code>.
         */
        protected void setColladaRoot(ColladaRoot root)
        {
            if (root != null)
            {
                this.configureColladaRoot(root);
            }

            this.colladaRoot.set(root);
        }
コード例 #11
0
        /** {@inheritDoc} */
        public void render(KMLTraversalContext tc, DrawContext dc)
        {
            ColladaRoot root = this.getColladaRoot();

            if (root != null)
            {
                this.colladaTraversalContext.initialize();
                root.render(this.colladaTraversalContext, dc);
            }
        }
コード例 #12
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaFloatArray(ColladaRoot collada, XElement node) : base(collada, node, "")
            {
                IEnumerable <string> arg_3A_0 = node.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                Func <string, float> arg_3A_1;

                if ((arg_3A_1 = ColladaFloatArray.c.a__1_0) == null)
                {
                    arg_3A_1 = (ColladaFloatArray.c.a__1_0 = new Func <string, float>(ColladaFloatArray.c.a.b__1_0));
                }
                Array = arg_3A_0.Select(arg_3A_1).ToArray <float>();
            }
コード例 #13
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaMesh(ColladaRoot collada, XElement node)
            {
                foreach (XElement current in node.Elements(ColladaRoot.Namespace + "source"))
                {
                    Sources.Add(new ColladaSource(collada, current));
                }
                XElement node2 = node.Element(ColladaRoot.Namespace + "vertices");

                Vertices = new ColladaVertices(collada, node2);
                foreach (XElement current2 in node.Elements(ColladaRoot.Namespace + "polygons").Concat(node.Elements(ColladaRoot.Namespace + "polylist")).Concat(node.Elements(ColladaRoot.Namespace + "triangles")))
                {
                    Polygons.Add(new ColladaPolygons(collada, current2));
                }
            }
コード例 #14
0
        /** {@inheritDoc} */
        public void preRender(KMLTraversalContext tc, DrawContext dc)
        {
            if (this.mustRetrieveResource())
            {
                this.requestResource(dc);
            }

            ColladaRoot root = this.getColladaRoot();

            if (root != null)
            {
                this.colladaTraversalContext.initialize();
                root.preRender(this.colladaTraversalContext, dc);
            }
        }
コード例 #15
0
        /**
         * Apply the model's position, orientation, and scale to a COLLADA root.
         *
         * @param root COLLADA root to configure.
         */
        protected void configureColladaRoot(ColladaRoot root)
        {
            root.setResourceResolver(this);

            Position refPosition = this.model.getLocation().getPosition();

            root.setPosition(refPosition);
            root.setAltitudeMode(KMLUtil.convertAltitudeMode(this.model.getAltitudeMode(), WorldWind.CLAMP_TO_GROUND)); // KML default

            KMLOrientation orientation = this.model.getOrientation();

            if (orientation != null)
            {
                Double d = orientation.getHeading();
                if (d != null)
                {
                    root.setHeading(Angle.fromDegrees(d));
                }

                d = orientation.getTilt();
                if (d != null)
                {
                    root.setPitch(Angle.fromDegrees(-d));
                }

                d = orientation.getRoll();
                if (d != null)
                {
                    root.setRoll(Angle.fromDegrees(-d));
                }
            }

            KMLScale scale = this.model.getScale();

            if (scale != null)
            {
                Double x = scale.getX();
                Double y = scale.getY();
                Double z = scale.getZ();

                Vec4 modelScale = new Vec4(
                    x != null ? x : 1.0,
                    y != null ? y : 1.0,
                    z != null ? z : 1.0);

                root.setModelScale(modelScale);
            }
        }
コード例 #16
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaAccessor(ColladaRoot collada, XElement node)
            {
                Source = (ColladaFloatArray)collada.ObjectsById[node.Attribute("source").Value.Substring(1)];
                XAttribute xAttribute = node.Attribute("offset");

                if (xAttribute != null)
                {
                    Offset = int.Parse(xAttribute.Value, CultureInfo.InvariantCulture);
                }
                XAttribute xAttribute2 = node.Attribute("stride");

                if (xAttribute2 != null)
                {
                    Stride = int.Parse(xAttribute2.Value, CultureInfo.InvariantCulture);
                }
            }
コード例 #17
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaNameId(ColladaRoot collada, XElement node, string idPostfix = "")
            {
                XAttribute xAttribute = node.Attribute("id");

                if (xAttribute != null)
                {
                    Id = xAttribute.Value + idPostfix;
                    collada.ObjectsById.Add(Id, this);
                }
                XAttribute xAttribute2 = node.Attribute("name");

                if (xAttribute2 != null)
                {
                    Name = xAttribute2.Value;
                }
            }
コード例 #18
0
ファイル: Collada.cs プロジェクト: 1144822034/sc2.2mobile
 public ColladaPolygons(ColladaRoot collada, XElement node)
 {
     foreach (XElement item in node.Elements(ColladaRoot.Namespace + "input"))
     {
         Inputs.Add(new ColladaInput(collada, item));
     }
     foreach (XElement item2 in node.Elements(ColladaRoot.Namespace + "vcount"))
     {
         VCount.AddRange(from s in item2.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                         select int.Parse(s, CultureInfo.InvariantCulture));
     }
     foreach (XElement item3 in node.Elements(ColladaRoot.Namespace + "p"))
     {
         P.AddRange(from s in item3.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                    select int.Parse(s, CultureInfo.InvariantCulture));
     }
 }
コード例 #19
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaSource(ColladaRoot collada, XElement node) : base(collada, node, "")
            {
                XElement xElement = node.Element(ColladaRoot.Namespace + "float_array");

                if (xElement != null)
                {
                    FloatArray = new ColladaFloatArray(collada, xElement);
                }
                XElement xElement2 = node.Element(ColladaRoot.Namespace + "technique_common");

                if (xElement2 != null)
                {
                    XElement xElement3 = xElement2.Element(ColladaRoot.Namespace + "accessor");
                    if (xElement3 != null)
                    {
                        Accessor = new ColladaAccessor(collada, xElement3);
                    }
                }
            }
コード例 #20
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaInput(ColladaRoot collada, XElement node)
            {
                Offset   = int.Parse(node.Attribute("offset").Value, CultureInfo.InvariantCulture);
                Semantic = node.Attribute("semantic").Value;
                XAttribute xAttribute = node.Attribute("set");

                if (xAttribute != null)
                {
                    Set = int.Parse(xAttribute.Value, CultureInfo.InvariantCulture);
                }
                ColladaNameId colladaNameId = collada.ObjectsById[node.Attribute("source").Value.Substring(1)];

                if (colladaNameId is ColladaVertices)
                {
                    ColladaVertices colladaVertices = (ColladaVertices)colladaNameId;
                    Source   = colladaVertices.Source;
                    Semantic = colladaVertices.Semantic;
                    return;
                }
                Source = (ColladaSource)colladaNameId;
            }
コード例 #21
0
ファイル: Collada.cs プロジェクト: 1144822034/sc2.2mobile
 public ColladaNode(ColladaRoot collada, XElement node)
     : base(collada, node)
 {
     foreach (XElement item in node.Elements())
     {
         if (item.Name == ColladaRoot.Namespace + "matrix")
         {
             float[] array = (from s in item.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                              select float.Parse(s, CultureInfo.InvariantCulture)).ToArray();
             Transform = Matrix.Transpose(new Matrix(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15])) * Transform;
         }
         else if (item.Name == ColladaRoot.Namespace + "translate")
         {
             float[] array2 = (from s in item.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                               select float.Parse(s, CultureInfo.InvariantCulture)).ToArray();
             Transform = Matrix.CreateTranslation(array2[0], array2[1], array2[2]) * Transform;
         }
         else if (item.Name == ColladaRoot.Namespace + "rotate")
         {
             float[] array3 = (from s in item.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                               select float.Parse(s, CultureInfo.InvariantCulture)).ToArray();
             Transform = Matrix.CreateFromAxisAngle(new Vector3(array3[0], array3[1], array3[2]), MathUtils.DegToRad(array3[3])) * Transform;
         }
         else if (item.Name == ColladaRoot.Namespace + "scale")
         {
             float[] array4 = (from s in item.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
                               select float.Parse(s, CultureInfo.InvariantCulture)).ToArray();
             Transform = Matrix.CreateScale(array4[0], array4[1], array4[2]) * Transform;
         }
     }
     foreach (XElement item2 in node.Elements(ColladaRoot.Namespace + "node"))
     {
         Nodes.Add(new ColladaNode(collada, item2));
     }
     foreach (XElement item3 in node.Elements(ColladaRoot.Namespace + "instance_geometry"))
     {
         Geometries.Add((ColladaGeometry)collada.ObjectsById[item3.Attribute("url").Value.Substring(1)]);
     }
 }
コード例 #22
0
        public static AnimationImporter MakeFromFilename(string filename)
        {
            ColladaRoot root = (ColladaRoot)ColladaRoot.Serializer.Deserialize(File.OpenRead(filename));

            return(new AnimationImporter(root));
        }
コード例 #23
0
ファイル: Collada.cs プロジェクト: 1144822034/sc2.2mobile
 public ColladaFloatArray(ColladaRoot collada, XElement node)
     : base(collada, node)
 {
     Array = (from s in node.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries)
              select float.Parse(s, CultureInfo.InvariantCulture)).ToArray();
 }
コード例 #24
0
ファイル: Collada.cs プロジェクト: Lixue9jiu/SCPAK
            public ColladaScene(ColladaRoot collada, XElement node)
            {
                XElement xElement = node.Element(ColladaRoot.Namespace + "instance_visual_scene");

                VisualScene = (ColladaVisualScene)collada.ObjectsById[xElement.Attribute("url").Value.Substring(1) + "-ColladaVisualScene"];
            }
コード例 #25
0
 public AnimationImporter(ColladaRoot root)
 {
     this.root = root;
     LoadBindPoses();
     LoadAnimationPoses();
 }