示例#1
0
        public static Runtime.GLTF SinglePlane()
        {
            List <Vector3> planePositions = new List <Vector3>()
            {
                new Vector3(0.5f, -0.5f, 0.0f),
                new Vector3(-0.5f, -0.5f, 0.0f),
                new Vector3(-0.5f, 0.5f, 0.0f),
                new Vector3(0.5f, 0.5f, 0.0f)
            };

            // 1:1 UV mapping
            List <List <Vector2> > planeTextureCoordSets = new List <List <Vector2> >
            {
                new List <Vector2>
                {
                    new Vector2(1.0f, 1.0f),
                    new Vector2(0.0f, 1.0f),
                    new Vector2(0.0f, 0.0f),
                    new Vector2(1.0f, 0.0f)
                },
            };

            List <int> PlaneIndices = new List <int>
            {
                1, 0, 3, 1, 3, 2
            };

            Runtime.GLTF          wrapper  = new Runtime.GLTF();
            Runtime.Scene         scene    = new Runtime.Scene();
            Runtime.Mesh          mesh     = new Runtime.Mesh();
            Runtime.MeshPrimitive meshPrim = new Runtime.MeshPrimitive
            {
                Indices          = PlaneIndices,
                Positions        = planePositions,
                TextureCoordSets = planeTextureCoordSets
            };
            mesh.MeshPrimitives = new List <Runtime.MeshPrimitive>
            {
                meshPrim
            };
            scene.Nodes = new List <Runtime.Node>
            {
                new Runtime.Node
                {
                    Mesh = mesh
                }
            };

            wrapper.Scenes.Add(scene);

            return(wrapper);
        }
示例#2
0
        /// <summary>
        /// Creates a triangle model using the glTF wrapper
        /// </summary>
        /// <param name="gltf"></param>
        /// <param name="geometryData"></param>
        /// <returns>GLTFWrapper object</returns>
        public static Runtime.GLTF SingleTriangle()
        {
            List <Vector3> trianglePositions = new List <Vector3>()
            {
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(-1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f)
            };
            List <Vector3> triangleNormals = new List <Vector3>()
            {
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f)
            };
            List <List <Vector2> > triangleTextureCoordSets = new List <List <Vector2> >
            {
                new List <Vector2>
                {
                    new Vector2(0.0f, 1.0f),
                    new Vector2(0.5f, 1.0f),
                    new Vector2(0.25f, 0.0f)
                },
                new List <Vector2>
                {
                    new Vector2(0.5f, 1.0f),
                    new Vector2(1.0f, 1.0f),
                    new Vector2(0.75f, 0.0f)
                }
            };

            Runtime.GLTF          wrapper  = new Runtime.GLTF();
            Runtime.Scene         scene    = new Runtime.Scene();
            Runtime.Mesh          mesh     = new Runtime.Mesh();
            Runtime.MeshPrimitive meshPrim = new Runtime.MeshPrimitive
            {
                Positions        = trianglePositions,
                Normals          = triangleNormals,
                TextureCoordSets = triangleTextureCoordSets
            };
            mesh.MeshPrimitives.Add(meshPrim);
            scene.Nodes = new List <Runtime.Node> {
                new Runtime.Node
                {
                    Mesh = mesh
                }
            };
            wrapper.Scenes.Add(scene);

            return(wrapper);
        }
        public Animation_NodeMisc(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Cube");

            // There are no common properties in this model group that are reported in the readme.

            Model CreateModel(Action <List <Property>, List <Runtime.AnimationChannel>, List <Runtime.Node>, List <Runtime.Animation> > setProperties)
            {
                var properties        = new List <Property>();
                var cubeMeshPrimitive = MeshPrimitive.CreateCube();

                // Apply the common properties to the gltf.
                cubeMeshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.Texture {
                            Source = baseColorTextureImage
                        },
                    },
                };
                var channels = new List <Runtime.AnimationChannel>
                {
                    new Runtime.AnimationChannel()
                };
                var nodes = new List <Runtime.Node>
                {
                    new Runtime.Node(),
                };
                var animations = new List <Runtime.Animation>
                {
                    new Runtime.Animation
                    {
                        Channels = channels
                    }
                };

                // Apply the properties that are specific to this gltf.
                setProperties(properties, channels, nodes, animations);

                // Create the gltf object.
                foreach (var node in nodes)
                {
                    node.Mesh = new Runtime.Mesh
                    {
                        MeshPrimitives = new List <Runtime.MeshPrimitive>
                        {
                            cubeMeshPrimitive
                        }
                    };
                }
                Runtime.GLTF gltf = CreateGLTF(() => new Runtime.Scene
                {
                    Nodes = nodes
                });
                gltf.Animations = animations;
                return(new Model
                {
                    Properties = properties,
                    GLTF = gltf,
                    Animated = true,
                });
            }

            void SetTranslationChannelTarget(Runtime.AnimationChannel channel, Runtime.Node node)
            {
                channel.Target = new Runtime.AnimationChannelTarget
                {
                    Node = node,
                    Path = Runtime.AnimationChannelTarget.PathEnum.TRANSLATION,
                };
            }

            void SetRotationChannelTarget(Runtime.AnimationChannel channel, Runtime.Node node)
            {
                channel.Target = new Runtime.AnimationChannelTarget
                {
                    Node = node,
                    Path = Runtime.AnimationChannelTarget.PathEnum.ROTATION,
                };
            }

            void SetLinearSamplerForTranslation(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                    2.0f,
                    4.0f,
                },
                    new[]
                {
                    new Vector3(-0.1f, 0.0f, 0.0f),
                    new Vector3(0.1f, 0.0f, 0.0f),
                    new Vector3(-0.1f, 0.0f, 0.0f),
                }
                                  );
            }

            void SetLinearSamplerForHorizontalRotation(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                },
                    new[]
                {
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                }
                                  );
            }

            void SetLinearSamplerForVerticalRotation(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                },
                    new[]
                {
                    Quaternion.CreateFromYawPitchRoll(0.0f, FloatMath.ToRadians(90.0f), 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(0.0f, FloatMath.ToRadians(-90.0f), 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(0.0f, FloatMath.ToRadians(90.0f), 0.0f),
                }
                                  );
            }

            void SetLinearSamplerForConstantRotation(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    0.0f,
                    6.0f,
                },
                    new[]
                {
                    Quaternion.CreateFromYawPitchRoll(-FloatMath.Pi / 3.0f, 0.0f, 0.0f),
                    Quaternion.CreateFromYawPitchRoll(-FloatMath.Pi / 3.0f, 0.0f, 0.0f),
                }
                                  );
            }

            void SetLinearSamplerForTranslationStartsAboveZero(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    2.0f,
                    4.0f,
                    6.0f,
                },
                    new[]
                {
                    new Vector3(0.0f, -0.1f, 0.0f),
                    new Vector3(0.0f, 0.1f, 0.0f),
                    new Vector3(0.0f, -0.1f, 0.0f),
                }
                                  );
            }

            void SetLinearSamplerWithOneKey(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                },
                    new[]
                {
                    new Vector3(-0.1f, 0.0f, 0.0f),
                }
                                  );
            }

            void SetLinearSamplerForRotationThatStartsAboveZero(Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                    5.0f,
                },
                    new[]
                {
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                }
                                  );
            }

            void CreateMultipleChannelsWithUniqueTargets(List <Runtime.AnimationChannel> channels, Runtime.Node node)
            {
                // The first channel is already added as a common property.
                channels.Add(new Runtime.AnimationChannel());

                SetTranslationChannelTarget(channels[0], node);
                SetRotationChannelTarget(channels[1], node);

                var samplerPropertiesList = new List <Property>();

                SetLinearSamplerForTranslation(channels[0]);
                SetLinearSamplerForHorizontalRotation(channels[1]);
            }

            void CreateMultipleChannelsWithDifferentTimes(List <Runtime.AnimationChannel> channels, Runtime.Node node)
            {
                // The first channel is already added as a common property.
                channels.Add(new Runtime.AnimationChannel());

                SetTranslationChannelTarget(channels[0], node);
                SetRotationChannelTarget(channels[1], node);

                SetLinearSamplerForTranslationStartsAboveZero(channels[0]);
                SetLinearSamplerForRotationThatStartsAboveZero(channels[1]);
            }

            void CreateMultipleChannelsForDifferentNodes(List <Runtime.AnimationChannel> channels, Runtime.Node node0, Runtime.Node node1)
            {
                // The first channel is already added as a common property.
                channels.Add(new Runtime.AnimationChannel());

                SetRotationChannelTarget(channels[0], node0);
                SetRotationChannelTarget(channels[1], node1);

                SetLinearSamplerForHorizontalRotation(channels[0]);
                SetLinearSamplerForVerticalRotation(channels[1]);
            }

            Models = new List <Model>
            {
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Multiple channels
                    CreateMultipleChannelsWithUniqueTargets(channels, nodes[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There are two channels. The first channel targets translation. The second channel targets rotation. The start and end times of both channels are `0.0` and `4.0` respectively."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Curve that doesn't start at zero
                    SetRotationChannelTarget(channels[0], nodes[0]);
                    SetLinearSamplerForRotationThatStartsAboveZero(channels[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There is one channel with a non-zero start time. The channel targets rotation. The start time is `1.0`."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Two channels with different start/end times
                    CreateMultipleChannelsWithDifferentTimes(channels, nodes[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There are two channels with different start and end times. The first channel targets translation with start and end times of `2.0` and `6.0` respectively. The second channel targets rotation with start and end times of `1.0` and `5.0` respectively."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Has only one key
                    SetTranslationChannelTarget(channels[0], nodes[0]);
                    SetLinearSamplerWithOneKey(channels[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There is one channel with only one keyframe. The channel targets translation with a value of <code>[-0.1,&nbsp;0.0,&nbsp;0.0]</code>."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Creates a second node based on the existing node, and applies a transform to help differentiate them.
                    nodes.Add(DeepCopy.CloneObject(nodes[0]));
                    nodes[0].Translation = new Vector3(-0.2f, 0.0f, 0.0f);
                    nodes[1].Translation = new Vector3(0.2f, 0.0f, 0.0f);
                    nodes[0].Scale       = new Vector3(0.5f, 0.5f, 0.5f);
                    nodes[1].Scale       = new Vector3(0.5f, 0.5f, 0.5f);

                    // One animation, two channels for two nodes.
                    CreateMultipleChannelsForDifferentNodes(channels, nodes[0], nodes[1]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There are two channels with different nodes. The first channel targets the left node and rotation along the X axis. The second channel targets the right node and rotation along the Y axis."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Rotate the model, and then apply the same target animation to it (Animation overrides)
                    nodes[0].Rotation = Quaternion.CreateFromYawPitchRoll(FloatMath.Pi / 3.0f, 0.0f, 0.0f);
                    SetRotationChannelTarget(channels[0], nodes[0]);
                    SetLinearSamplerForConstantRotation(channels[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There is one channel that targets a node. The node has a rotation of <code>[0.0,&nbsp;0.5,&nbsp;0.0,&nbsp;0.866]</code>. The channel overrides the rotation of the node to a different constant value of <code>[0.0,&nbsp;-0.5,&nbsp;0.0,&nbsp;0.866]</code>."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Rotate the model, and then apply an translation animation to it (Animation doesn't override rotation)
                    nodes[0].Rotation = Quaternion.CreateFromYawPitchRoll(FloatMath.Pi / 3.0f, 0.0f, 0.0f);
                    SetTranslationChannelTarget(channels[0], nodes[0]);
                    SetLinearSamplerForTranslation(channels[0]);
                    properties.Add(new Property(PropertyName.Description,
                                                "There is one channel that targets a node. The node has a rotation of <code>[0.0,&nbsp;0.5,&nbsp;0.0,&nbsp;0.866]</code>. The channel targets the translation of the node."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Two animations. One rotates, the other translates. They should not interact or bleed across.
                    var channel = new Runtime.AnimationChannel();
                    SetTranslationChannelTarget(channel, nodes[0]);
                    SetLinearSamplerForTranslation(channel);
                    animations.Add(new Runtime.Animation
                    {
                        Channels = new[]
                        {
                            channel
                        }
                    });

                    // The first animation is already added as an empty common property.
                    SetRotationChannelTarget(channels[0], nodes[0]);
                    SetLinearSamplerForHorizontalRotation(channels[0]);

                    properties.Add(new Property(PropertyName.Description,
                                                "There are two animations, each with one channel. The first animation's channel targets rotation. The second animation's channel targets translation."));
                }),
                CreateModel((properties, channels, nodes, animations) =>
                {
                    // Multiple channels, but one omits node (the channel with no target node is ignored per the spec).
                    CreateMultipleChannelsForDifferentNodes(channels, null, nodes[0]);

                    properties.Add(new Property(PropertyName.Description,
                                                "There are two channels. The first channel has a rotation along the X axis but does not specify a node. The second channel does target the node and has a rotation along the Y axis."));
                }),
            };

            GenerateUsedPropertiesList();
        }
示例#4
0
        public Animation_Node(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Cube");

            // There are no common properties in this model group that are reported in the readme.

            Model CreateModel(Action <List <Property>, List <Runtime.AnimationChannel>, Runtime.Node> setProperties)
            {
                var properties        = new List <Property>();
                var cubeMeshPrimitive = MeshPrimitive.CreateCube();

                // Apply the common properties to the gltf.
                cubeMeshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.Texture {
                            Source = baseColorTextureImage
                        },
                    },
                };
                var channels = new List <Runtime.AnimationChannel>
                {
                    new Runtime.AnimationChannel()
                };
                var node = new Runtime.Node();

                // Apply the properties that are specific to this gltf.
                setProperties(properties, channels, node);

                // Create the gltf object.
                node.Mesh = new Runtime.Mesh
                {
                    MeshPrimitives = new[]
                    {
                        cubeMeshPrimitive
                    }
                };
                Runtime.GLTF gltf = CreateGLTF(() => new Runtime.Scene()
                {
                    Nodes = new[]
                    {
                        node
                    },
                });
                gltf.Animations = new[]
                {
                    new Runtime.Animation
                    {
                        Channels = channels
                    }
                };
                return(new Model
                {
                    Properties = properties,
                    GLTF = gltf,
                    Animated = true,
                });
            }

            void SetTranslationChannelTarget(List <Property> properties, Runtime.AnimationChannel channel, Runtime.Node node)
            {
                channel.Target = new Runtime.AnimationChannelTarget
                {
                    Node = node,
                    Path = Runtime.AnimationChannelTarget.PathEnum.TRANSLATION,
                };
                properties.Add(new Property(PropertyName.Target, "Translation"));
            }

            void SetRotationChannelTarget(List <Property> properties, Runtime.AnimationChannel channel, Runtime.Node node)
            {
                channel.Target = new Runtime.AnimationChannelTarget
                {
                    Node = node,
                    Path = Runtime.AnimationChannelTarget.PathEnum.ROTATION,
                };
                properties.Add(new Property(PropertyName.Target, "Rotation"));
            }

            void SetScaleChannelTarget(List <Property> properties, Runtime.AnimationChannel channel, Runtime.Node node)
            {
                channel.Target = new Runtime.AnimationChannelTarget
                {
                    Node = node,
                    Path = Runtime.AnimationChannelTarget.PathEnum.SCALE,
                };
                properties.Add(new Property(PropertyName.Target, "Scale"));
            }

            void SetLinearSamplerForTranslation(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                },
                    new[]
                {
                    new Vector3(-0.1f, 0.0f, 0.0f),
                    new Vector3(0.1f, 0.0f, 0.0f),
                    new Vector3(-0.1f, 0.0f, 0.0f),
                }
                                  );

                properties.Add(new Property(PropertyName.Interpolation, "Linear"));
            }

            void SetLinearSamplerForScale(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                },
                    new[]
                {
                    new Vector3(0.8f, 0.8f, 0.8f),
                    new Vector3(1.2f, 1.2f, 1.2f),
                    new Vector3(0.8f, 0.8f, 0.8f),
                }
                                  );

                properties.Add(new Property(PropertyName.Interpolation, "Linear"));
            }

            void SetLinearSamplerForRotation(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                },
                    new[]
                {
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                    Quaternion.Identity,
                    Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                }
                                  );

                properties.Add(new Property(PropertyName.Interpolation, "Linear"));
            }

            void SetStepSamplerForTranslation(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.StepAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                },
                    new[]
                {
                    new Vector3(-0.1f, 0.0f, 0.0f),
                    new Vector3(0.0f, 0.0f, 0.0f),
                    new Vector3(0.1f, 0.0f, 0.0f),
                    new Vector3(0.0f, 0.0f, 0.0f),
                    new Vector3(-0.1f, 0.0f, 0.0f),
                }
                                  );

                properties.Add(new Property(PropertyName.Interpolation, "Step"));
            }

            void SetCubicSplineSamplerForTranslation(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.CubicSplineAnimationSampler <Vector3>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                },
                    new[]
                {
                    new Runtime.CubicSplineAnimationSampler <Vector3> .Key
                    {
                        InTangent  = new Vector3(0.0f, 0.0f, 0.0f),
                        Value      = new Vector3(-0.1f, 0.0f, 0.0f),
                        OutTangent = new Vector3(0.0f, 0.0f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Vector3> .Key
                    {
                        InTangent  = new Vector3(0.0f, 0.0f, 0.0f),
                        Value      = new Vector3(0.1f, 0.0f, 0.0f),
                        OutTangent = new Vector3(0.0f, -0.3f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Vector3> .Key
                    {
                        InTangent  = new Vector3(0.0f, 0.0f, 0.0f),
                        Value      = new Vector3(-0.1f, 0.0f, 0.0f),
                        OutTangent = new Vector3(0.0f, 0.0f, 0.0f)
                    }
                }
                                  );

                properties.Add(new Property(PropertyName.Interpolation, "Cubic Spline"));
            }

            void CreateCubicSplineSamplerForRotation(List <Property> properties, Runtime.AnimationChannel channel)
            {
                channel.Sampler = new Runtime.CubicSplineAnimationSampler <Quaternion>
                                  (
                    new[]
                {
                    0.0f,
                    1.0f,
                    2.0f,
                    3.0f,
                    4.0f,
                },
                    new[]
                {
                    new Runtime.CubicSplineAnimationSampler <Quaternion> .Key
                    {
                        InTangent  = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f),
                        Value      = Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                        OutTangent = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Quaternion> .Key
                    {
                        InTangent  = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f),
                        Value      = Quaternion.Identity,
                        OutTangent = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Quaternion> .Key
                    {
                        InTangent  = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f),
                        Value      = Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                        OutTangent = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Quaternion> .Key
                    {
                        InTangent  = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f),
                        Value      = Quaternion.Identity,
                        OutTangent = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)
                    },
                    new Runtime.CubicSplineAnimationSampler <Quaternion> .Key
                    {
                        InTangent  = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f),
                        Value      = Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                        OutTangent = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f)
                    },
                }
                                  );
                properties.Add(new Property(PropertyName.Interpolation, "Cubic Spline"));
            }

            Models = new List <Model>
            {
                CreateModel((properties, channels, node) =>
                {
                    SetTranslationChannelTarget(properties, channels[0], node);
                    SetLinearSamplerForTranslation(properties, channels[0]);
                }),
                CreateModel((properties, channels, node) =>
                {
                    SetRotationChannelTarget(properties, channels[0], node);
                    SetLinearSamplerForRotation(properties, channels[0]);
                }),
                CreateModel((properties, channels, node) =>
                {
                    SetScaleChannelTarget(properties, channels[0], node);
                    SetLinearSamplerForScale(properties, channels[0]);
                }),
                CreateModel((properties, channels, node) =>
                {
                    SetTranslationChannelTarget(properties, channels[0], node);
                    SetStepSamplerForTranslation(properties, channels[0]);
                }),
                CreateModel((properties, channels, node) =>
                {
                    SetTranslationChannelTarget(properties, channels[0], node);
                    SetCubicSplineSamplerForTranslation(properties, channels[0]);
                }),
                CreateModel((properties, channels, node) =>
                {
                    SetRotationChannelTarget(properties, channels[0], node);
                    CreateCubicSplineSamplerForRotation(properties, channels[0]);
                }),
            };

            GenerateUsedPropertiesList();
        }
示例#5
0
        public static Runtime.GLTF MultiNode()
        {
            List <Vector3> vertexPositions = new List <Vector3>()
            {
                new Vector3(2.500000f, 2.500000f, 2.500000f),
                new Vector3(-2.500000f, 2.500000f, 2.500000f),
                new Vector3(-2.500000f, -2.500000f, 2.500000f),
                new Vector3(2.500000f, -2.500000f, 2.500000f),
                new Vector3(0.000000f, 2.500000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, 2.500000f),
                new Vector3(2.500000f, 2.500000f, 2.500000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(0.000000f, 7.500000f, 0.000000f),
                new Vector3(0.000000f, 7.500000f, -2.500000f),
                new Vector3(-2.500000f, 7.500000f, 0.000000f),
                new Vector3(-2.500000f, 7.500000f, -2.500000f),
                new Vector3(2.500000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 0.000000f, -7.500000f),
                new Vector3(-2.500000f, 0.000000f, -7.500000f),
                new Vector3(-2.500000f, 2.500000f, -7.500000f),
                new Vector3(0.000000f, 2.500000f, -7.500000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(2.500000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, -2.500000f, -2.500000f),
                new Vector3(2.500000f, -2.500000f, -2.500000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(2.500000f, -2.500000f, 2.500000f),
                new Vector3(-2.500000f, -2.500000f, 2.500000f),
                new Vector3(-2.500000f, -2.500000f, -2.500000f),
                new Vector3(2.500000f, -2.500000f, -2.500000f),
                new Vector3(2.500000f, 2.500000f, 2.500000f),
                new Vector3(2.500000f, -2.500000f, 2.500000f),
                new Vector3(2.500000f, 2.500000f, -2.500000f),
                new Vector3(2.500000f, -2.500000f, -2.500000f),
                new Vector3(-2.500000f, -2.500000f, -2.500000f),
                new Vector3(-2.500000f, -2.500000f, 2.500000f),
                new Vector3(-2.500000f, 0.000000f, 0.000000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, 2.500000f),
                new Vector3(-7.500000f, 2.500000f, 0.000000f),
                new Vector3(-7.500000f, 0.000000f, -2.500000f),
                new Vector3(-7.500000f, 0.000000f, 0.000000f),
                new Vector3(-7.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(-7.500000f, 0.000000f, 0.000000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, 0.000000f, 0.000000f),
                new Vector3(-7.500000f, 0.000000f, -2.500000f),
                new Vector3(-7.500000f, 2.500000f, 0.000000f),
                new Vector3(-2.500000f, 0.000000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(-7.500000f, 0.000000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-7.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(-7.500000f, 2.500000f, 0.000000f),
                new Vector3(-7.500000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(-7.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 7.500000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(0.000000f, 7.500000f, 0.000000f),
                new Vector3(0.000000f, 2.500000f, 0.000000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 7.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, 0.000000f),
                new Vector3(0.000000f, 7.500000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 7.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 7.500000f, -2.500000f),
                new Vector3(-2.500000f, 7.500000f, 0.000000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, 0.000000f),
                new Vector3(-2.500000f, 7.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, -7.500000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, -7.500000f),
                new Vector3(0.000000f, 0.000000f, -2.500000f),
                new Vector3(0.000000f, 0.000000f, -7.500000f),
                new Vector3(0.000000f, 2.500000f, -2.500000f),
                new Vector3(0.000000f, 2.500000f, -7.500000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, 0.000000f, -7.500000f),
                new Vector3(0.000000f, 0.000000f, -2.500000f),
                new Vector3(0.000000f, 0.000000f, -7.500000f),
                new Vector3(-2.500000f, 2.500000f, -2.500000f),
                new Vector3(-2.500000f, 2.500000f, -7.500000f),
                new Vector3(-2.500000f, 0.000000f, -2.500000f),
                new Vector3(-2.500000f, 0.000000f, -7.500000f),
                new Vector3(3.000000f, -1.000000f, 3.000000f),
                new Vector3(-7.500000f, -1.000000f, 7.500000f),
                new Vector3(3.000000f, -1.000000f, 7.500000f),
                new Vector3(-7.500000f, -1.000000f, 3.000000f),
                new Vector3(7.500000f, -1.000000f, 7.500000f),
                new Vector3(7.500000f, -1.000000f, 3.000000f),
                new Vector3(7.500000f, -1.000000f, -7.500000f),
                new Vector3(3.000000f, -1.000000f, -7.500000f),
            };


            List <List <Vector2> > textureCoordSets = new List <List <Vector2> >
            {
                new List <Vector2>
                {
                    new Vector2(0.788554f, 0.205935f),
                    new Vector2(0.584720f, 0.205900f),
                    new Vector2(0.584685f, 0.409734f),
                    new Vector2(0.788519f, 0.409769f),
                    new Vector2(0.471918f, 0.880496f),
                    new Vector2(0.369983f, 0.982396f),
                    new Vector2(0.573817f, 0.982430f),
                    new Vector2(0.370001f, 0.880479f),
                    new Vector2(0.232172f, 0.857846f),
                    new Vector2(0.232064f, 0.959100f),
                    new Vector2(0.333426f, 0.857955f),
                    new Vector2(0.333317f, 0.959208f),
                    new Vector2(0.573852f, 0.778596f),
                    new Vector2(0.471935f, 0.778579f),
                    new Vector2(0.249236f, 0.325688f),
                    new Vector2(0.249140f, 0.426797f),
                    new Vector2(0.350249f, 0.426892f),
                    new Vector2(0.350345f, 0.325783f),
                    new Vector2(0.573870f, 0.676679f),
                    new Vector2(0.573852f, 0.778596f),
                    new Vector2(0.675786f, 0.676697f),
                    new Vector2(0.777721f, 0.574797f),
                    new Vector2(0.777686f, 0.778631f),
                    new Vector2(0.675804f, 0.574780f),
                    new Vector2(0.777652f, 0.982465f),
                    new Vector2(0.981486f, 0.982500f),
                    new Vector2(0.981520f, 0.778666f),
                    new Vector2(0.777686f, 0.778631f),
                    new Vector2(0.573817f, 0.982430f),
                    new Vector2(0.777652f, 0.982465f),
                    new Vector2(0.573852f, 0.778596f),
                    new Vector2(0.777686f, 0.778631f),
                    new Vector2(0.380851f, 0.409699f),
                    new Vector2(0.584685f, 0.409734f),
                    new Vector2(0.482785f, 0.307799f),
                    new Vector2(0.380868f, 0.307782f),
                    new Vector2(0.584720f, 0.205900f),
                    new Vector2(0.225056f, 0.327032f),
                    new Vector2(0.124248f, 0.226196f),
                    new Vector2(0.124234f, 0.327018f),
                    new Vector2(0.225070f, 0.226211f),
                    new Vector2(0.482803f, 0.205882f),
                    new Vector2(0.023427f, 0.226182f),
                    new Vector2(0.124277f, 0.024553f),
                    new Vector2(0.023455f, 0.024539f),
                    new Vector2(0.124248f, 0.226196f),
                    new Vector2(0.325892f, 0.226224f),
                    new Vector2(0.426742f, 0.024595f),
                    new Vector2(0.325920f, 0.024581f),
                    new Vector2(0.426714f, 0.226239f),
                    new Vector2(0.225098f, 0.024567f),
                    new Vector2(0.225070f, 0.226211f),
                    new Vector2(0.325920f, 0.024581f),
                    new Vector2(0.325892f, 0.226224f),
                    new Vector2(0.124248f, 0.226196f),
                    new Vector2(0.225098f, 0.024567f),
                    new Vector2(0.124277f, 0.024553f),
                    new Vector2(0.225070f, 0.226211f),
                    new Vector2(0.333426f, 0.857955f),
                    new Vector2(0.333643f, 0.655447f),
                    new Vector2(0.232172f, 0.857846f),
                    new Vector2(0.232389f, 0.655338f),
                    new Vector2(0.131136f, 0.655230f),
                    new Vector2(0.130919f, 0.857737f),
                    new Vector2(0.232389f, 0.655338f),
                    new Vector2(0.232172f, 0.857846f),
                    new Vector2(0.029882f, 0.655121f),
                    new Vector2(0.029664f, 0.857629f),
                    new Vector2(0.131136f, 0.655230f),
                    new Vector2(0.130919f, 0.857737f),
                    new Vector2(0.333426f, 0.857955f),
                    new Vector2(0.434897f, 0.655555f),
                    new Vector2(0.333643f, 0.655447f),
                    new Vector2(0.434680f, 0.858063f),
                    new Vector2(0.451167f, 0.629205f),
                    new Vector2(0.451358f, 0.426988f),
                    new Vector2(0.350058f, 0.629110f),
                    new Vector2(0.350249f, 0.426892f),
                    new Vector2(0.552276f, 0.629301f),
                    new Vector2(0.552467f, 0.427083f),
                    new Vector2(0.451167f, 0.629205f),
                    new Vector2(0.451358f, 0.426988f),
                    new Vector2(0.248950f, 0.629014f),
                    new Vector2(0.249140f, 0.426797f),
                    new Vector2(0.147841f, 0.628919f),
                    new Vector2(0.148031f, 0.426701f),
                    new Vector2(0.350058f, 0.629110f),
                    new Vector2(0.350249f, 0.426892f),
                    new Vector2(0.248950f, 0.629014f),
                    new Vector2(0.249140f, 0.426797f),
                    new Vector2(0.820246f, 0.187538f),
                    new Vector2(0.979596f, 0.559354f),
                    new Vector2(0.979596f, 0.187538f),
                    new Vector2(0.820247f, 0.559354f),
                    new Vector2(0.979596f, 0.028188f),
                    new Vector2(0.820247f, 0.028188f),
                    new Vector2(0.448431f, 0.028188f),
                    new Vector2(0.448431f, 0.187538f),
                },
            };

            List <Vector3> vertexNormals = new List <Vector3>()
            {
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(0.000000f, 0.000000f, 1.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(0.000000f, 0.000000f, -1.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(1.000000f, 0.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(0.000000f, -1.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(-1.000000f, 0.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
                new Vector3(0.000000f, 1.000000f, 0.000000f),
            };

            List <Vector4> vertexTangents = new List <Vector4>()
            {
                new Vector4(1.000000f, 0.000170f, 0.000000f, 1.000000f),
                new Vector4(1.000000f, 0.000171f, 0.000000f, 1.000000f),
                new Vector4(1.000000f, 0.000172f, 0.000000f, 1.000000f),
                new Vector4(1.000000f, 0.000171f, 0.000000f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000170f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000170f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000170f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000171f, 1.000000f),
                new Vector4(-0.999999f, 0.000000f, 0.001072f, 1.000000f),
                new Vector4(-0.999999f, 0.000000f, 0.001072f, 1.000000f),
                new Vector4(-0.999999f, 0.000000f, 0.001071f, 1.000000f),
                new Vector4(-0.999999f, 0.000000f, 0.001072f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000171f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000171f, 1.000000f),
                new Vector4(0.000947f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000947f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000947f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000947f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000172f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000171f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000171f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000170f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000169f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.000172f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000169f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000170f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000171f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000170f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000170f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000171f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000169f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000170f, 1.000000f),
                new Vector4(0.000000f, 0.000169f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000172f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000170f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000168f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000172f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000140f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000141f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000140f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000140f, 1.000000f),
                new Vector4(0.000000f, 0.000170f, 1.000000f, 1.000000f),
                new Vector4(0.000140f, 0.000000f, -1.000000f, 1.000000f),
                new Vector4(0.000142f, 0.000000f, -1.000000f, 1.000000f),
                new Vector4(0.000141f, 0.000000f, -1.000000f, 1.000000f),
                new Vector4(0.000141f, 0.000000f, -1.000000f, 1.000000f),
                new Vector4(0.000140f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000140f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000140f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000140f, -1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000139f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000138f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000140f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000139f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000141f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000138f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000140f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(0.000140f, 1.000000f, 0.000000f, 1.000000f),
                new Vector4(-0.999999f, -0.001071f, 0.000000f, 1.000000f),
                new Vector4(-0.999999f, -0.001071f, 0.000000f, 1.000000f),
                new Vector4(-0.999999f, -0.001071f, 0.000000f, 1.000000f),
                new Vector4(-0.999999f, -0.001071f, 0.000000f, 1.000000f),
                new Vector4(0.000000f, -0.001073f, 0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001075f, 0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001071f, 0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001073f, 0.999999f, 1.000000f),
                new Vector4(0.999999f, -0.001073f, 0.000000f, 1.000000f),
                new Vector4(0.999999f, -0.001072f, 0.000000f, 1.000000f),
                new Vector4(0.999999f, -0.001074f, 0.000000f, 1.000000f),
                new Vector4(0.999999f, -0.001073f, 0.000000f, 1.000000f),
                new Vector4(0.000000f, -0.001071f, -0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001074f, -0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001073f, -0.999999f, 1.000000f),
                new Vector4(0.000000f, -0.001073f, -0.999999f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000942f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000943f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000941f, 1.000000f),
                new Vector4(1.000000f, 0.000000f, -0.000942f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000944f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000943f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000946f, 1.000000f),
                new Vector4(0.000000f, -1.000000f, -0.000944f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000941f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000941f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000942f, 1.000000f),
                new Vector4(-1.000000f, 0.000000f, -0.000941f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000946f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000947f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000945f, 1.000000f),
                new Vector4(0.000000f, 1.000000f, -0.000946f, 1.000000f),
                new Vector4(0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(-0.000001f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(-0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(-0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000000f, 1.000000f, 1.000000f),
                new Vector4(0.000000f, 0.000000f, 1.000000f, 1.000000f),
            };

            List <int> indices0 = new List <int>
            {
                90, 91, 92, 91, 90, 93, 94, 95, 92, 92, 95, 90, 96, 90, 95, 90, 96, 97,
            };
            List <int> indices1 = new List <int>
            {
                0, 1, 2, 0, 2, 3, 4, 5, 6, 5, 4, 7, 8, 9, 10, 10, 9, 11, 6, 12, 4, 4, 12, 13, 14, 15, 16, 14, 16, 17, 18, 19,
                20, 21, 20, 22, 20, 21, 23, 20, 19, 22, 24, 25, 26, 24, 26, 27, 28, 29, 30, 29, 31, 30, 32, 33, 34, 32, 34, 35,
                33, 36, 34, 37, 38, 39, 38, 37, 40, 34, 36, 41, 42, 43, 44, 43, 42, 45, 46, 47, 48, 47, 46, 49, 50, 51, 52, 53,
                52, 51, 54, 55, 56, 55, 54, 57, 58, 59, 60, 60, 59, 61, 62, 63, 64, 65, 64, 63, 66, 67, 68, 68, 67, 69, 70, 71,
                72, 71, 70, 73, 74, 75, 76, 76, 75, 77, 78, 79, 80, 80, 79, 81, 82, 83, 84, 84, 83, 85, 86, 87, 88, 88, 87, 89,
            };


            Runtime.GLTF  wrapper = new Runtime.GLTF();
            Runtime.Scene scene   = new Runtime.Scene();
            Runtime.Mesh  mesh0   = new Runtime.Mesh();
            Runtime.Mesh  mesh1   = new Runtime.Mesh();
            scene.Nodes = new List <Runtime.Node>();

            Runtime.MeshPrimitive meshPrim0 = new Runtime.MeshPrimitive
            {
                Positions        = vertexPositions,
                TextureCoordSets = textureCoordSets,
                Normals          = vertexNormals,
                Tangents         = vertexTangents,
                Indices          = indices0,
            };
            mesh0.MeshPrimitives = new List <Runtime.MeshPrimitive> {
                meshPrim0
            };
            scene.Nodes.Add(
                new Runtime.Node
            {
                Mesh = mesh0,
                Name = "Node0"
            });

            Runtime.MeshPrimitive meshPrim1 = new Runtime.MeshPrimitive
            {
                Positions        = vertexPositions,
                TextureCoordSets = textureCoordSets,
                Normals          = vertexNormals,
                Tangents         = vertexTangents,
                Indices          = indices1,
            };
            mesh1.MeshPrimitives = new List <Runtime.MeshPrimitive> {
                meshPrim1
            };
            scene.Nodes[0].Children = new List <Runtime.Node>();
            scene.Nodes[0].Children.Add(
                new Runtime.Node
            {
                Mesh = mesh1,
                Name = "Node1"
            });

            wrapper.Scenes.Add(scene);

            return(wrapper);
        }
示例#6
0
        public static Runtime.GLTF SingleCube()
        {
            List <Vector3> cubePositions = new List <Vector3>()
            {
                new Vector3(-0.5f, -0.5f, -0.5f),
                new Vector3(-0.5f, -0.5f, 0.5f),
                new Vector3(-0.5f, 0.5f, 0.5f),
                new Vector3(-0.5f, 0.5f, -0.5f),
                new Vector3(-0.5f, -0.5f, 0.5f),
                new Vector3(0.5f, -0.5f, 0.5f),
                new Vector3(0.5f, 0.5f, 0.5f),
                new Vector3(-0.5f, 0.5f, 0.5f),
                new Vector3(0.5f, -0.5f, 0.5f),
                new Vector3(0.5f, -0.5f, -0.5f),
                new Vector3(0.5f, 0.5f, -0.5f),
                new Vector3(0.5f, 0.5f, 0.5f),
                new Vector3(-0.5f, 0.5f, 0.5f),
                new Vector3(0.5f, 0.5f, 0.5f),
                new Vector3(0.5f, 0.5f, -0.5f),
                new Vector3(-0.5f, 0.5f, -0.5f),
                new Vector3(-0.5f, 0.5f, -0.5f),
                new Vector3(0.5f, 0.5f, -0.5f),
                new Vector3(0.5f, -0.5f, -0.5f),
                new Vector3(-0.5f, -0.5f, -0.5f),
                new Vector3(-0.5f, -0.5f, -0.5f),
                new Vector3(0.5f, -0.5f, -0.5f),
                new Vector3(0.5f, -0.5f, 0.5f),
                new Vector3(-0.5f, -0.5f, 0.5f)
            };
            List <Vector3> cubeNormals = new List <Vector3>()
            {
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(0.0f, 0.0f, 1.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(1.0f, 0.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 1.0f, 0.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, 0.0f, -1.0f),
                new Vector3(0.0f, -1.0f, 0.0f),
                new Vector3(0.0f, -1.0f, 0.0f),
                new Vector3(0.0f, -1.0f, 0.0f),
                new Vector3(0.0f, -1.0f, 0.0f)
            };

            List <List <Vector2> > cubeTextureCoordSets = new List <List <Vector2> >
            {
                new List <Vector2>
                {
                    new Vector2(0.125f, 1.0f),
                    new Vector2(0.375f, 1.0f),
                    new Vector2(0.375f, 0.75f),
                    new Vector2(0.125f, 0.75f),
                    new Vector2(0.375f, 1.00f),
                    new Vector2(0.625f, 1.00f),
                    new Vector2(0.625f, 0.75f),
                    new Vector2(0.375f, 0.75f),
                    new Vector2(0.625f, 1.00f),
                    new Vector2(0.875f, 1.00f),
                    new Vector2(0.875f, 0.75f),
                    new Vector2(0.625f, 0.75f),
                    new Vector2(0.375f, 0.75f),
                    new Vector2(0.625f, 0.75f),
                    new Vector2(0.625f, 0.5f),
                    new Vector2(0.375f, 0.5f),
                    new Vector2(0.375f, 0.5f),
                    new Vector2(0.625f, 0.5f),
                    new Vector2(0.625f, 0.25f),
                    new Vector2(0.375f, 0.25f),
                    new Vector2(0.375f, 0.25f),
                    new Vector2(0.625f, 0.25f),
                    new Vector2(0.625f, 0.0f),
                    new Vector2(0.375f, 0.0f)
                },
            };
            List <int> cubeIndices = new List <int>
            {
                0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
            };

            Runtime.GLTF          wrapper  = new Runtime.GLTF();
            Runtime.Scene         scene    = new Runtime.Scene();
            Runtime.Mesh          mesh     = new Runtime.Mesh();
            Runtime.MeshPrimitive meshPrim = new Runtime.MeshPrimitive
            {
                Positions        = cubePositions,
                Normals          = cubeNormals,
                TextureCoordSets = cubeTextureCoordSets,
                Indices          = cubeIndices
            };
            mesh.MeshPrimitives = new List <Runtime.MeshPrimitive> {
                meshPrim
            };
            scene.Nodes = new List <Runtime.Node>
            {
                new Runtime.Node
                {
                    Mesh = mesh
                }
            };
            wrapper.Scenes.Add(scene);

            return(wrapper);
        }
示例#7
0
        private static void Main(string[] args)
        {
            Stopwatch.StartNew();

            Assembly        executingAssembly       = Assembly.GetExecutingAssembly();
            string          executingAssemblyFolder = Path.GetDirectoryName(executingAssembly.Location);
            string          outputFolder            = Path.GetFullPath(Path.Combine(executingAssemblyFolder, @"..\..\..\..\Output"));
            List <Manifest> manifestMaster          = new List <Manifest>();

            // Make an inventory of what images there are
            var textures = FileHelper.FindImageFiles(executingAssembly, "Textures");
            var figures  = FileHelper.FindImageFiles(executingAssembly, "Figures");

            // Uses Reflection to create a list containing one instance of each group of models
            List <dynamic> allModelGroups = new List <dynamic>();

            foreach (var type in executingAssembly.GetTypes())
            {
                var modelGroupAttribute = type.GetCustomAttribute <ModelGroupAttribute>();
                if (modelGroupAttribute != null)
                {
                    ConstructorInfo ctor       = type.GetConstructor(new Type[] { typeof(List <string>), typeof(List <string>) });
                    dynamic         modelGroup = ctor.Invoke(new dynamic[] { textures, figures });
                    allModelGroups.Add(modelGroup);
                }
            }

            foreach (var modelGroup in allModelGroups)
            {
                List <List <Property> > combos = ComboHelper.AttributeCombos(modelGroup);

                ReadmeBuilder readme   = new ReadmeBuilder();
                Manifest      manifest = new Manifest(modelGroup.modelGroupName);

                string assetFolder = Path.Combine(outputFolder, modelGroup.modelGroupName.ToString());

                FileHelper.ClearOldFiles(outputFolder, assetFolder);
                Directory.CreateDirectory(assetFolder);

                // Copy all of the images used by the model group into that model group's output directory
                FileHelper.CopyImageFiles(executingAssembly, assetFolder, modelGroup.usedTextures, useThumbnails: true);
                FileHelper.CopyImageFiles(executingAssembly, assetFolder, modelGroup.usedFigures);


                readme.SetupHeader(modelGroup);

                int numCombos = combos.Count;
                for (int comboIndex = 0; comboIndex < numCombos; comboIndex++)
                {
                    string[] name = ReadmeStringHelper.GenerateName(combos[comboIndex]);

                    var asset = new Runtime.Asset
                    {
                        Generator = "glTF Asset Generator",
                        Version   = "2.0",
                        Extras    = new Runtime.Extras
                        {
                            // Inserts a string into the .gltf containing the properties that are set for a given model, for debug.
                            Attributes = String.Join(" - ", name)
                        }
                    };

                    var gltf = new glTFLoader.Schema.Gltf
                    {
                        Asset = asset.ConvertToSchema()
                    };

                    var dataList = new List <Data>();

                    var geometryData = new Data(modelGroup.modelGroupName.ToString() + "_" + comboIndex.ToString("00") + ".bin");
                    dataList.Add(geometryData);

                    Runtime.GLTF wrapper = Common.SinglePlane();

                    wrapper.Asset = asset;

                    Runtime.Material mat = new Runtime.Material();

                    // Takes the current combo and uses it to bundle together the data for the desired properties
                    wrapper = modelGroup.SetModelAttributes(wrapper, mat, combos[comboIndex], ref gltf);

                    // Passes the desired properties to the runtime layer, which then coverts that data into
                    // a gltf loader object, ready to create the model
                    Runtime.GLTFConverter.ConvertRuntimeToSchema(wrapper, ref gltf, geometryData);

                    // Makes last second changes to the model that bypass the runtime layer
                    // in order to add 'features that don't really exist otherwise
                    modelGroup.PostRuntimeChanges(combos[comboIndex], ref gltf);

                    // Creates the .gltf file and writes the model's data to it
                    var filename  = modelGroup.modelGroupName.ToString() + "_" + comboIndex.ToString("00") + ".gltf";
                    var assetFile = Path.Combine(assetFolder, filename);
                    glTFLoader.Interface.SaveModel(gltf, assetFile);

                    // Creates the .bin file and writes the model's data to it
                    foreach (var data in dataList)
                    {
                        data.Writer.Flush();

                        var dataFile = Path.Combine(assetFolder, data.Name);
                        File.WriteAllBytes(dataFile, ((MemoryStream)data.Writer.BaseStream).ToArray());
                    }

                    readme.SetupTable(modelGroup, comboIndex, combos);
                    manifest.files.Add(filename);
                }

                readme.WriteOut(executingAssembly, modelGroup, assetFolder);
                manifestMaster.Add(manifest);

                // Write out the manifest JSON specific to this model group
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(manifest, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(Path.Combine(assetFolder, "Manifest.json"), json);
            }

            // Write out the master manifest JSON containing all of the model groups
            string jsonMaster = Newtonsoft.Json.JsonConvert.SerializeObject(manifestMaster.ToArray(), Newtonsoft.Json.Formatting.Indented);

            File.WriteAllText(Path.Combine(outputFolder, "Manifest.json"), jsonMaster);

            // Update the main readme
            ReadmeBuilder.UpdateMainReadme(executingAssembly, outputFolder, manifestMaster);

            // Create reference images
            ReferenceImages.Create(executingAssembly, outputFolder, manifestMaster);

            Console.WriteLine("Model Creation Complete!");
            Console.WriteLine("Completed in : " + TimeSpan.FromTicks(Stopwatch.GetTimestamp()).ToString());
        }
        public Animation_SamplerType(List <string> imageList)
        {
            Runtime.Image baseColorTextureImage = UseTexture(imageList, "BaseColor_Cube");

            CommonProperties.Add(new Property(PropertyName.Target, "Rotation"));
            CommonProperties.Add(new Property(PropertyName.Interpolation, "Linear"));

            Model CreateModel(AnimationSampler.ComponentTypeEnum samplerOutputComponentType, string samplerOutputComponentTypeDisplayValue)
            {
                var properties        = new List <Property>();
                var cubeMeshPrimitive = MeshPrimitive.CreateCube();

                // Apply the common properties to the gltf.
                cubeMeshPrimitive.Material = new Runtime.Material
                {
                    MetallicRoughnessMaterial = new Runtime.PbrMetallicRoughness
                    {
                        BaseColorTexture = new Runtime.Texture {
                            Source = baseColorTextureImage
                        },
                    },
                };
                var node = new Runtime.Node
                {
                    Mesh = new Runtime.Mesh
                    {
                        MeshPrimitives = new[]
                        {
                            cubeMeshPrimitive
                        }
                    }
                };
                var channel = new Runtime.AnimationChannel
                {
                    Target = new Runtime.AnimationChannelTarget
                    {
                        Node = node,
                        Path = Runtime.AnimationChannelTarget.PathEnum.ROTATION,
                    },
                    Sampler = new Runtime.LinearAnimationSampler <Quaternion>
                              (
                        new[]
                    {
                        0.0f,
                        1.0f,
                        2.0f,
                        3.0f,
                        4.0f,
                    },
                        new[]
                    {
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                        Quaternion.Identity,
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(-90.0f), 0.0f, 0.0f),
                        Quaternion.Identity,
                        Quaternion.CreateFromYawPitchRoll(FloatMath.ToRadians(90.0f), 0.0f, 0.0f),
                    },
                        outputComponentType: samplerOutputComponentType
                              )
                };

                // Apply the properties that are specific to this gltf.
                properties.Add(new Property(PropertyName.SamplerOutputComponentType, samplerOutputComponentTypeDisplayValue));

                // Create the gltf object.
                Runtime.GLTF gltf = CreateGLTF(() => new Runtime.Scene
                {
                    Nodes = new[]
                    {
                        node
                    },
                });
                gltf.Animations = new[]
                {
                    new Runtime.Animation
                    {
                        Channels = new List <Runtime.AnimationChannel>
                        {
                            channel
                        }
                    }
                };
                return(new Model
                {
                    Properties = properties,
                    GLTF = gltf,
                    Animated = true,
                });
            }

            Models = new List <Model>
            {
                CreateModel(AnimationSampler.ComponentTypeEnum.FLOAT, "Float"),
                CreateModel(AnimationSampler.ComponentTypeEnum.NORMALIZED_BYTE, "Byte"),
                CreateModel(AnimationSampler.ComponentTypeEnum.NORMALIZED_SHORT, "Short"),
            };

            GenerateUsedPropertiesList();
        }