IUriLoader.cs
Reads bytes itno the gltf for passed Uri's (relative urls)
///
/// Returns the contents of the passed uri as a decoded image.
/// Should raise NotSupportedException if not supported.
///
/// The relative uri to load
RawImage LoadAsImage(string uri);
/// Returns the contents of the passed uri as a Texture2D such that
/// AssetDatabase.Contains(tex) == true; or null on failure.
/// Possible causes of failure are:
/// - uri lies outside of Assets/
/// - uri does not reference a texture
MathUtils.cs
// May pertain to scaling, and vertex3 issues (may relate to -1/1 requirement)
IntRange.cs
// sets a partially open range for IntRange
GltfSchemaCommon.cs
// checks gltfVersion, raises exceptions if json is bad
// Converts json vectors
// sets up the gltf matrix
//? WriteJson gives NotImplementedException?
// Sets up mesh data for unity
// Sorts GLTF1 and GLTF2 Classes
// GltfAccessorBase: Serializable, may be missing a sequence number? =5124?
`
[Serializable] public enum ComponentType {
BYTE = 5120, UNSIGNED_BYTE = 5121, SHORT = 5122, UNSIGNED_SHORT = 5123,
UNSIGNED_INT = 5125,
FLOAT = 5126
`
Does some lazy triangle things for large gltf primitives
handles structures for nodes, mesh, children
ImportGltf.cs
Distinguishes multiple types of gltf formats based on source (tiltbrush upload, tiltbrush export, blocks, poly, sketchfab, tb toolkit, poly toolkit)
//Processes unity materials into gltf material lookups
//checks bounding box and vector magnitutde, tolerates loose normals
//distinguishes internal and externalGltf
//tracks state data of the import process and geometry adjustments
// Sets gltf version defaults
//collects materials, version, and gltfstring to import gltf models
// sets and sanity checks scale factors
// changes attributes of TEXCOORD to unity supported
// Checks app and version that generated the gltf file
// URI handling, doesn't like absolute URIs, converts materials
// Scaling notes indicate that extreme scales may have issues (potential issue with unlocked scales?)
// Sets up Mesh precursors
// converts to usable unit objects
// Crates game objects marks non-exportable models
// Applies translations
// organizes primitives in mesh
// Reorganizes geometry that is too small for unity to handle
// some hack that checks validity of model geometry (comment suggests some codem may need to be excised)
// Topology (triangle) management works for TB topology but not arbitrary meshes
// converts gltf matrixunity (scale, uv)
// Noted that TBT shaders are different from TB shaders
// handling of gltf accessors when data is missing in the file (creates empty elements to preserve structure)
//(1062) Tangent/VertexID some data not hooked up, webgl comments
//(1114) Handles invalid normals. Lets Unity Regenerate them [unclear if successful]
//(1369) Color Space handling (tiltbrush internals and shaders use srgb...
// bounding box things
GLTFMaterialConverter.cs
///
/// Information about a Unity material corresponding to a Gltf node.
///
/// Converts "Necessary" textures textures found in the gltf file.
/// Coroutine must be fully consumed before generating materials.
/// Gets (or creates) the Unity material corresponding to the given glTF material.
///
/// Returns a list of new materials that were created as part of the material
/// conversion process.
/// true if there is a global material corresponding to the given glTF material,
/// false if a material needs to be created for this material.
/// Looks up a built-in global material that corresponds to the given GLTF material.
/// This will NOT create new materials; it will only look up global ones.
///
/// The material to look up.
/// The guid parsed from the material name, or Guid.None
/// The global material that corresponds to the given GLTF material,
//Handles gltf1/gltf2, blocks/tbPBR
//Doesn't support metallicRoughness
/// Converts the given GLTF 2 material to a Unity Material.
/// This is "best effort": we only interpret SOME, but not all GLTF material parameters.
Possible trouble with single sided materials
/// Converts the given GLTF 2 material to a Unity Material.
/// This is "best effort": we only interpret SOME, but not all GLTF material parameters.
Returns templated information, guid information, some material data, brush descriptor if found otherwise null,
if template returns template descriptor
GltfImportOptions.cs
//sets options on how to import various assets
//converts scales, axis conventions, bounding cubes, centers ojbects in bounding object to coincide with center of game object
Gltf2Schema.cs
ublic sealed class Gltf2Root : GltfRootBase {
public List buffers;
public List accessors;
public List bufferViews;
public List meshes;
public List materials;
public List nodes;
public List scenes;
public List textures;
public List images;
public int scene;
private bool disposed;
..
Maps gltfIndexValues (int indices etc) to the names of objects referred to
leaves buffer data null for some uri things
Dereferences all incixes
pointer dictionary key/values transfer (meshjes)
Gltf materials dereferenced 9emissive, normal, pbrMetalicRoughness,SpecularGlossiness) last two where apply
handles indices and pointer for materail info
Enumerates Alphamodes (opaque, mask, blend)
Ienumarables for TextureInfos and referenced Textures
Sets up node base children
Gltf1Schema.cs
Handles gltf1 information, sets up kepairs, buffers, primitives,indexes, materials
Tries to replicate GLTF2 type functionality for pbr like materials in naming conventions
Won't handle multiple node to mesh relationships
GlbParser.cs
/// Parses glb versions 1 and 2
// has binary cheat sheet in notes for json, and structure
// handles parsing errors for glb/json length mismatches
// Errors noted if glb path reading erors
// Identifies files which don't look like binary glb files
Version.cs
// confirms TiltBrushToolkit versions
TbtSettings.cs
// checks TB instance
// If not tiltbrush looks at brushmanifest
// serializes single/double sided opaque and blends
Returns null if cant find Guid in BrushCatalog, otherwise [checks] return m_BrushManifest.BrushesByGuid.TryGetValue(guid, out desc);
public bool TryGetBrush(Guid guid, out BrushDescriptor desc) {
desc = TiltBrush.BrushCatalog.m_Instance.GetBrush(guid);
return (desc != null);
//Requires a material or a descriptor to be checked, if both sanity checks them
checks shader url
checks for materials conflicts
Looks up surface shader or if not found returns null
SubStream.cs
/// A read-only, seekable stream.
/// The underlying stream must also be readable and seekable.
// handles info stream and lets base stream handle error checking,
// handles offsets
//ToolkitBrushDescriptor.cs
//Declarations for m_guuid, m_Material, m_IsParticle... uvs, normals, normals set Texcoord1
//CreateAndSerialize
// Pulls brushDescriptor desc, Guid materialGuid, string AssetName, out string meta
// defines ToolkitBrushDescripror and serializes for yamsl
//Transfers the data [private static ToolkitBrushDescriptor CreateFrom(BrushDescriptor desc)]
//Sets up temp asset paths for serialized assets and meta documents
*creates a lot of weirdness if pulling data from a lot of places and may create something of a mired structure depending on what's connected to what
ToolkitUtils.cs (some are out of sequence)
// Lots going on here.
// Export failed eceptions, dictionaries, URIs for windows applications
// quite a few 'shortcuts' or compromises appear to have been made according to in file documentation
// Passes data to unityProjectRoot (directory that contains asset folder)
// Export failed conditions
// Loads asset paths in environments,
// Copies hash strings and collected assets
/ /Creates and appends assets
// ExportToToolkit_Brush
// has issues with PBR materials and EnvironmentalDiffusion
// Sets up a container directory with brush subdirectories, assigns materials path
// Takes the TBGuid and assigns to Unity Guid
// Sets up a brush descripor and path, makes metas
// Some sort of uncoment mechanism for new brushes
// Checks legacy brushes for keys (pre-M14
// Appends to collected assets, creates environment, handles lights, camera, rendersettings, cubemap/skybox
// Copies sourceProjectRoot / asset to targetDirectory / asset
// targetDirectory must be a subdirectory of targetProjectRoot
// If any includes are found, they're added to moreAssets.
// Stores the scene
Copies Shared Assets
(IF COPIES MORE THAN 20 TIMES GIVES TOO MANY ITERATIONS AND BREAKS
m_ProgressRange = new Vector2(m_ProgressRange.y, .95f);
Exports to target directory (may hang unity)
Returns name used for TBT assets (created per bursh)
Notes about durable names and possible changes to desc.name
* tries to load manifest assets, fails if missing kManifestAssetPath
*stores paths to descriptors, direct references get lost
GetSubdirForBrush(BrushDescriptor desc)
* may have some structural requirements in file placement to read correctly
m_ProgressRange = new Vector2(m_ProgressRange.y, .95f);
* Has an iterator that fails if more than 20 instances (brushes or shaders)? may impair additional brushes?
* Clears strings that aren't marked "Paid" and ignores them (around 813)
(701)Creates an absolute path and rewrites the relative URI, I think things may break down here
(798) Template does weird things to handle guid creation, including making a placeholder(?) then fixes guid and synchronous import