// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 using System; using GLTFast.Schema; using Unity.Collections; using UnityEngine; using Material = UnityEngine.Material; namespace GLTFast { /// /// glTF root (de-serialized glTF JSON) class type public interface IGltfReadable : IGltfReadable where TRoot : RootBase { /// /// Get source root (de-serialized glTF JSON). /// This is intended for read-only access. Changes might corrupt data /// and break subsequent scene instantiation. /// /// De-serialized glTF root object TRoot GetSourceRoot(); } /// /// Provides read-only access to a glTF (schema and imported Unity resources) /// public interface IGltfReadable : IMaterialProvider { /// /// Number of materials /// int MaterialCount { get; } /// /// Number of images /// int ImageCount { get; } /// /// Number of textures /// int TextureCount { get; } /// /// Get a Unity Material by its glTF material index /// /// glTF material index /// Corresponding Unity Material Material GetMaterial(int index = 0); /// /// Returns a fallback material to be used when no material was /// assigned (provided by the ) /// /// Default material Material GetDefaultMaterial(); /// /// Get texture by glTF image index /// /// glTF image index /// Loaded Unity texture Texture2D GetImage(int index = 0); /// /// Get texture by glTF texture index /// /// glTF texture index /// Loaded Unity texture Texture2D GetTexture(int index = 0); /// /// Evaluates if the texture's vertical orientation conforms to Unity's default. /// If it's not aligned (=true; =flipped), the texture has to be applied mirrored vertically. /// /// glTF texture index /// True if the vertical orientation is flipped, false otherwise bool IsTextureYFlipped(int index = 0); /// /// Get source (de-serialized glTF) camera /// /// glTF camera index /// De-serialized glTF camera CameraBase GetSourceCamera(uint index); /// /// Get source (de-serialized glTF) material /// /// glTF material index /// De-serialized glTF material MaterialBase GetSourceMaterial(int index = 0); /// /// Get source (de-serialized glTF) mesh. /// /// glTF mesh index. /// De-serialized glTF mesh. MeshBase GetSourceMesh(int meshIndex); /// /// Get source (de-serialized glTF) mesh primitive /// /// glTF mesh index. /// glTF primitive index within mesh. /// De-serialized glTF mesh primitive MeshPrimitiveBase GetSourceMeshPrimitive(int meshIndex, int primitiveIndex); /// /// Get source (de-serialized glTF) node /// /// glTF node index /// De-serialized glTF node NodeBase GetSourceNode(int index = 0); /// /// Get source (de-serialized glTF) scene /// /// glTF scene index /// De-serialized glTF scene Scene GetSourceScene(int index = 0); /// /// Get source (de-serialized glTF) texture /// /// glTF texture index /// De-serialized glTF texture TextureBase GetSourceTexture(int index = 0); /// /// Get source (de-serialized glTF) image /// /// glTF image index /// De-serialized glTF image Image GetSourceImage(int index = 0); /// /// Get source (de-serialized glTF) light /// /// glTF light index /// De-serialized glTF light LightPunctual GetSourceLightPunctual(uint index); /// /// Returns an array of inverse bone matrices representing a skin's /// bind pose suitable for use with UnityEngine.Mesh.bindposes by glTF /// skin index. /// /// glTF skin index /// Corresponding bind poses Matrix4x4[] GetBindPoses(int skinId); /// /// Creates a generic byte-array view into an accessor. /// Only available during loading phase as underlying buffers are disposed right afterward. /// /// glTF accessor index /// Valid byte-slice view into accessor's data if parameter was correct and buffers are available. /// Zero-length slice otherwise. [Obsolete("This is going to be removed and replaced with an improved way to access accessors' data in a future release.")] NativeSlice GetAccessor(int accessorIndex); /// /// Creates a generic byte-array view into an accessor. /// Only available during loading phase as underlying buffers are disposed right afterward. /// /// glTF accessor index /// Valid byte-slice view into accessor's data if parameter was correct and buffers are available. /// Zero-length slice otherwise. [Obsolete("This is going to be removed and replaced with an improved way to access accessors' data in a future release.")] NativeSlice GetAccessorData(int accessorIndex); } }