UE Types Library for Rust
A Rust library providing common Unreal Engine data types optimized for game servers. Built on top of the high-performance glam math library with full serialization support.
Features
- Complete UE Type Coverage: Vector, Rotator, Transform, Colors, Bounding Volumes
- Multiple Serialization Formats: JSON (serde) and Binary (bincode)
- Display Formatting: Human-readable output for all types
- High Performance: Built on
glamfor optimal math operations - Type Safety: Leverages Rust's type system for safe game development
- UE Compatibility: Familiar API for Unreal Engine developers
Quick Start
Add to your Cargo.toml:
[]
= "0.1.0"
Basic usage:
use *;
// Create a transform
let transform = new;
// Display the transform
println!;
// Serialize to JSON
let json = to_string?;
// Serialize to binary
let binary_data = transform.to_binary?;
Type Overview
Vector Types
Vector(Vec3) - 3D position, velocity, directionVector2D(Vec2) - 2D coordinates, UI positionsVector4(Vec4) - 4D vectors, homogeneous coordinatesQuaternion(Quat) - Efficient 3D rotationsMatrix3,Matrix4- Transformation matrices
let position = new;
let direction = new;
// UE-style operations
println!;
println!;
Rotator
UE-style Euler angle rotation in degrees (Pitch, Yaw, Roll):
let rotation = new; // 30° pitch, 45° yaw
let forward = rotation.get_forward_vector;
let quaternion = rotation.to_quaternion;
println!; // "P=30.00° Y=45.00° R=0.00°"
Transform
Complete 3D transformation with location, rotation, and scale:
let transform = from_location_rotator_scale;
// Transform points and vectors
let point = new;
let transformed_point = transform.transform_point;
// Combine transforms
let combined = transform1.combine;
Colors
LinearColor (HDR, 0.0-1.0 range)
let color = new;
let from_hsv = from_hsv; // Green
let lerped = RED.lerp;
println!; // "LinearColor(R=0.800, G=0.400, B=0.200, A=1.000)"
Color (sRGB, 0-255 range)
let color = from_hex;
let linear = color.to_linear; // Convert to linear space
let back = from_linear; // Convert back to sRGB
println!; // "Color(R=255, G=128, B=64, A=255) [#FF8040FF]"
Bounding Volumes
BoundingBox (AABB)
let bbox = new;
let center = bbox.center;
let volume = bbox.volume;
let contains_point = bbox.contains_point;
// Transform the bounding box
let transformed_bbox = bbox.transform;
BoundingSphere
let sphere = new;
let intersects = sphere.intersects_box;
let distance = sphere.distance_to_point;
Serialization
All types support multiple serialization formats:
JSON Serialization (serde)
use serde_json;
let transform = from_location;
// Serialize
let json = to_string?;
let pretty_json = to_string_pretty?;
// Deserialize
let restored: Transform = from_str?;
Binary Serialization (bincode)
// All types implement BinarySerializable
let color = RED;
// Serialize to binary
let binary_data = color.to_binary?;
println!;
// Deserialize from binary
let restored = from_binary?;
Display Formatting
All types implement Display for human-readable output:
let transform = new;
println!;
// Output: "Location: (10.00, 20.00, 30.00), Rotation: P=45.00° Y=90.00° R=0.00°, Scale: (2.00, 2.00, 2.00)"
Game Server Example
use *;
use ;
Performance Considerations
- Built on glam: Leverages SIMD optimizations when available
- Zero-cost abstractions: Wrapper types compile to underlying glam types
- Efficient serialization: Binary format is compact and fast
- Memory layout: All types are
#[repr(C)]compatible where applicable
UE Compatibility Notes
- Coordinate system: Follows UE's left-handed coordinate system (X=Forward, Y=Right, Z=Up)
- Rotation order: Uses UE's YXZ Euler rotation order for Rotators
- Units: Distances in centimeters (UE default), rotations in degrees
- Color spaces: Proper sRGB ↔ Linear conversion with gamma correction
Feature Flags
[]
= { = "0.1.0", = ["serde"] }
Available features:
serde(default) - JSON serialization supportbinary(default) - Binary serialization support
License
MIT License - see LICENSE file for details.