Ejemplo n.º 1
0
        public GLTFExporter(Transform[] rootTransforms)
        {
            _rootTransforms = rootTransforms;
            _root           = new GLTFRoot {
                Accessors = new List <Accessor>(),
                Asset     = new Asset {
                    Version = "2.0"
                },
                Buffers     = new List <Buffer>(),
                BufferViews = new List <BufferView>(),
                Images      = new List <Image>(),
                Materials   = new List <Material>(),
                Meshes      = new List <Mesh>(),
                Nodes       = new List <Node>(),
                Samplers    = new List <Sampler>(),
                Scenes      = new List <Scene>(),
                Textures    = new List <Texture>(),
            };

            _images = new List <Texture2D>();

            _buffer   = new Buffer();
            _bufferId = new BufferId {
                Id   = _root.Buffers.Count,
                Root = _root
            };
            _root.Buffers.Add(_buffer);
        }
Ejemplo n.º 2
0
        public static BufferView Deserialize(GLTFRoot root, JsonReader reader)
        {
            var bufferView = new BufferView();

            while (reader.Read() && reader.TokenType == JsonToken.PropertyName)
            {
                var curProp = reader.Value.ToString();

                switch (curProp)
                {
                case "buffer":
                    bufferView.Buffer = BufferId.Deserialize(root, reader);
                    break;

                case "byteOffset":
                    bufferView.ByteOffset = reader.ReadAsInt32().Value;
                    break;

                case "byteLength":
                    bufferView.ByteLength = reader.ReadAsInt32().Value;
                    break;

                case "byteStride":
                    bufferView.ByteStride = reader.ReadAsInt32().Value;
                    break;

                case "target":
                    bufferView.Target = (BufferViewTarget)reader.ReadAsInt32().Value;
                    break;

                default:
                    bufferView.DefaultPropertyDeserializer(root, reader);
                    break;
                }
            }

            return(bufferView);
        }