mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Comprehensive documentation and working C++ examples for OpenUSD's Crate (USDC binary) format implementation. Documentation (crate-impl.md, 1249 lines): - Complete binary format specification with diagrams - File layout: Bootstrap, Value Data, Structural Sections, TOC - Key data structures: ValueRep (8 bytes), Spec, Field, TimeSamples - Type system: All 60 supported types documented - Reading implementation: 3 ByteStream backends (mmap/pread/asset) - Writing implementation: Packing, deduplication, async I/O - Compression: Integer/float/LZ4 algorithms detailed - Deduplication: 3-level system (structural/per-type/time arrays) - Version history: 13 versions (0.0.1 to 0.13.0) - Optimizations: Zero-copy arrays, parallel construction, etc. - Performance: Read/write speeds, memory usage, file sizes - Security: Bounds checking, recursion protection, validation C++ Examples (aousd/crate/): Three working programs demonstrating OpenUSD C++ API: 1. crate_reader (157 KB) - Read .usdc/.usda files - Traverse prim hierarchy - Display attributes and TimeSamples - Works with any USD file 2. crate_writer (329 KB) - Create animated USD scenes - Write TimeSamples for animation - Animated transforms and colors - Simple and complex scene modes 3. crate_internal_api (169 KB) - Inspect binary format (magic, version, TOC) - Analyze TimeSamples (uniform/non-uniform sampling) - Compare format sizes (ASCII vs binary) - Low-level format introspection Build Systems: - Makefile: Simple, fast Unix builds - CMake: Cross-platform, IDE integration - build.sh: Convenience wrapper script - Both monolithic and standard USD linking - Links against no-python OpenUSD builds Documentation: - README.md: Complete build/usage instructions - EXAMPLES_OUTPUT.md: Actual program outputs - Full API usage examples - Troubleshooting guide Verified Working: - Compiles with C++17 - Links against libusd_ms.so (monolithic) - Creates/reads .usdc files successfully - Binary format inspection working - TimeSamples encoding/decoding functional File sizes: ~660 KB total (all 3 programs) Binary compression: 50-60% smaller than ASCII 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
121 lines
3.2 KiB
Makefile
121 lines
3.2 KiB
Makefile
# Makefile for USD Crate Examples
|
|
# Supports both standard and monolithic USD builds
|
|
|
|
# Detect build type from environment or use standard by default
|
|
# Set MONOLITHIC=1 to use monolithic build
|
|
MONOLITHIC ?= 0
|
|
|
|
# USD installation paths
|
|
ifeq ($(MONOLITHIC), 1)
|
|
USD_ROOT ?= $(CURDIR)/../dist_nopython_monolithic
|
|
BUILD_TYPE = monolithic
|
|
else
|
|
USD_ROOT ?= $(CURDIR)/../dist_nopython
|
|
BUILD_TYPE = standard
|
|
endif
|
|
|
|
# Compiler settings
|
|
CXX ?= g++
|
|
CXXFLAGS = -std=c++17 -Wall -Wno-deprecated
|
|
INCLUDES = -I$(USD_ROOT)/include
|
|
LDFLAGS = -L$(USD_ROOT)/lib -Wl,-rpath,$(USD_ROOT)/lib
|
|
|
|
# USD libraries
|
|
ifeq ($(MONOLITHIC), 1)
|
|
# Monolithic build - single library
|
|
USD_LIBS = -lusd_ms -ltbb
|
|
else
|
|
# Standard build - multiple libraries
|
|
USD_LIBS = -lusd -lusdGeom -lsdf -ltf -lvt -lgf -lar -larch -lplug -ltrace -lwork -ltbb
|
|
endif
|
|
|
|
# System libraries
|
|
SYS_LIBS = -lpthread -ldl
|
|
|
|
# All libraries
|
|
LIBS = $(USD_LIBS) $(SYS_LIBS)
|
|
|
|
# Build directory
|
|
BUILD_DIR = build
|
|
SRC_DIR = src
|
|
|
|
# Source files
|
|
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
|
|
TARGETS = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%,$(SOURCES))
|
|
|
|
# Default target
|
|
all: check-usd $(BUILD_DIR) $(TARGETS)
|
|
@echo ""
|
|
@echo "========================================="
|
|
@echo "Build complete ($(BUILD_TYPE))!"
|
|
@echo "========================================="
|
|
@echo "Executables in: $(BUILD_DIR)/"
|
|
@echo " - crate_reader"
|
|
@echo " - crate_writer"
|
|
@echo " - crate_internal_api"
|
|
@echo ""
|
|
|
|
# Check if USD installation exists
|
|
check-usd:
|
|
@if [ ! -d "$(USD_ROOT)" ]; then \
|
|
echo "Error: USD installation not found at: $(USD_ROOT)"; \
|
|
echo "Please build OpenUSD first or set USD_ROOT"; \
|
|
exit 1; \
|
|
fi
|
|
@echo "========================================="
|
|
@echo "Building USD Crate Examples"
|
|
@echo "========================================="
|
|
@echo "USD_ROOT: $(USD_ROOT)"
|
|
@echo "Build type: $(BUILD_TYPE)"
|
|
@echo "Compiler: $(CXX)"
|
|
@echo ""
|
|
|
|
# Create build directory
|
|
$(BUILD_DIR):
|
|
@mkdir -p $(BUILD_DIR)
|
|
|
|
# Pattern rule for building executables
|
|
$(BUILD_DIR)/%: $(SRC_DIR)/%.cpp
|
|
@echo "Building $@ ..."
|
|
$(CXX) $(CXXFLAGS) $(INCLUDES) $< -o $@ $(LDFLAGS) $(LIBS)
|
|
|
|
# Individual targets
|
|
crate_reader: $(BUILD_DIR)/crate_reader
|
|
crate_writer: $(BUILD_DIR)/crate_writer
|
|
crate_internal_api: $(BUILD_DIR)/crate_internal_api
|
|
|
|
# Clean
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
rm -rf $(BUILD_DIR)
|
|
@echo "Clean complete"
|
|
|
|
# Help
|
|
help:
|
|
@echo "USD Crate Examples Makefile"
|
|
@echo ""
|
|
@echo "Usage:"
|
|
@echo " make - Build all examples (standard USD build)"
|
|
@echo " make MONOLITHIC=1 - Build with monolithic USD library"
|
|
@echo " make clean - Remove build artifacts"
|
|
@echo " make help - Show this help"
|
|
@echo ""
|
|
@echo "Individual targets:"
|
|
@echo " make crate_reader"
|
|
@echo " make crate_writer"
|
|
@echo " make crate_internal_api"
|
|
@echo ""
|
|
@echo "Environment variables:"
|
|
@echo " USD_ROOT - USD installation directory"
|
|
@echo " MONOLITHIC - Set to 1 for monolithic build"
|
|
@echo " CXX - C++ compiler (default: g++)"
|
|
@echo ""
|
|
@echo "Examples:"
|
|
@echo " make"
|
|
@echo " make MONOLITHIC=1"
|
|
@echo " make CXX=clang++"
|
|
@echo " make USD_ROOT=/custom/usd/path"
|
|
|
|
# Phony targets
|
|
.PHONY: all check-usd clean help crate_reader crate_writer crate_internal_api
|