wow_wmo/lib.rs
1//! # World of Warcraft WMO (World Map Object) Parser
2//!
3//! This library provides comprehensive support for parsing, editing, validating, and converting
4//! World of Warcraft WMO files across all game expansions from Classic to The War Within.
5//!
6//! ## Features
7//!
8//! - **Parsing**: Read WMO root and group files with full chunk support
9//! - **Validation**: Verify file integrity and format compliance
10//! - **Conversion**: Convert between different WoW expansion formats
11//! - **Editing**: Modify WMO properties, geometry, and metadata
12//! - **Export**: Export to common 3D formats (OBJ/MTL)
13//! - **Type Safety**: Strongly typed structures for all WMO components
14//!
15//! ## Quick Start
16//!
17//! ```no_run
18//! use std::fs::File;
19//! use std::io::BufReader;
20//! use wow_wmo::{parse_wmo, ParsedWmo};
21//!
22//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
23//! // Parse a WMO file
24//! let file = File::open("example.wmo")?;
25//! let mut reader = BufReader::new(file);
26//! let wmo = parse_wmo(&mut reader)?;
27//!
28//! // Access WMO data based on type
29//! match &wmo {
30//! ParsedWmo::Root(root) => {
31//! println!("Root file - Version: {}", root.version);
32//! println!("Groups: {}", root.n_groups);
33//! println!("Materials: {}", root.n_materials);
34//! }
35//! ParsedWmo::Group(group) => {
36//! println!("Group file - Version: {}", group.version);
37//! println!("Vertices: {}", group.n_vertices);
38//! println!("Triangles: {}", group.n_triangles);
39//! }
40//! }
41//! # Ok(())
42//! # }
43//! ```
44//!
45//! ## Example: Validating a WMO File
46//!
47//! ```no_run
48//! use std::fs::File;
49//! use std::io::BufReader;
50//! use wow_wmo::{WmoParser, WmoValidator};
51//!
52//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
53//! // Parse the WMO
54//! let file = File::open("building.wmo")?;
55//! let mut reader = BufReader::new(file);
56//! let wmo = WmoParser::new().parse_root(&mut reader)?;
57//!
58//! // Validate it
59//! let validator = WmoValidator::new();
60//! let report = validator.validate_root(&wmo)?;
61//!
62//! if !report.errors.is_empty() {
63//! println!("Validation errors found:");
64//! for error in &report.errors {
65//! println!(" - {:?}", error);
66//! }
67//! }
68//!
69//! if !report.warnings.is_empty() {
70//! println!("Validation warnings:");
71//! for warning in &report.warnings {
72//! println!(" - {:?}", warning);
73//! }
74//! }
75//! # Ok(())
76//! # }
77//! ```
78//!
79//! ## Modules
80//!
81//! - [`chunk`]: Low-level chunk reading/writing functionality
82//! - [`parser`]: WMO root file parser
83//! - [`group_parser`]: WMO group file parser
84//! - [`types`]: Common data types (Vec3, Color, BoundingBox, etc.)
85//! - [`wmo_types`]: WMO root file structures
86//! - [`wmo_group_types`]: WMO group file structures
87//! - [`validator`]: File validation and integrity checking
88//! - [`converter`]: Version conversion between expansions
89//! - [`editor`]: High-level editing API
90//! - [`writer`]: Binary serialization
91//! - [`visualizer`]: 3D export functionality
92//! - [`version`]: Version detection and feature support
93//! - [`error`]: Error types and handling
94//!
95//! ## Supported Formats
96//!
97//! This library supports WMO files from all World of Warcraft expansions:
98//! - Classic (1.12)
99//! - The Burning Crusade (2.4.3)
100//! - Wrath of the Lich King (3.3.5)
101//! - Cataclysm (4.3.4)
102//! - Mists of Pandaria (5.4.8)
103//! - Warlords of Draenor (6.2.4)
104//! - Legion (7.3.5)
105//! - Battle for Azeroth (8.3.7)
106//! - Shadowlands (9.2.7)
107//! - Dragonflight (10.2.0)
108//! - The War Within (11.0+)
109
110pub mod api;
111pub mod bsp;
112pub mod chunk;
113pub mod chunk_discovery;
114pub mod chunk_header;
115pub mod chunk_id;
116pub mod chunks;
117pub mod converter;
118pub mod error;
119pub mod file_type;
120pub mod group_parser;
121pub mod parser;
122pub mod portal;
123pub mod root_parser;
124pub mod types;
125pub mod validator;
126pub mod version;
127pub mod version_detection;
128pub mod wmo_group_types;
129pub mod wmo_types;
130pub mod writer;
131
132// Additional modules
133pub mod editor;
134pub mod visualizer;
135
136// Test modules (only compiled for tests)
137// #[cfg(test)]
138// mod tests; // Temporarily disabled while refactoring
139#[cfg(test)]
140mod missing_chunks_test;
141
142pub use converter::WmoConverter;
143pub use editor::WmoEditor;
144pub use error::{Result, WmoError};
145pub use group_parser::WmoGroupParser;
146pub use parser::WmoParser;
147pub use types::{BoundingBox, Color, Vec3};
148pub use validator::{ValidationError, ValidationReport, ValidationWarning, WmoValidator};
149pub use version::{WmoFeature, WmoVersion};
150pub use visualizer::WmoVisualizer;
151// Re-export all types from wmo_types
152pub use wmo_types::{
153 WmoConvexVolumePlane, WmoConvexVolumePlanes, WmoDoodadDef, WmoDoodadSet, WmoFlags,
154 WmoGroupInfo, WmoHeader, WmoLight, WmoLightProperties, WmoLightType, WmoMaterial,
155 WmoMaterialFlags, WmoPortal, WmoPortalReference, WmoRoot,
156};
157
158// Re-export all types from wmo_group_types (except WmoGroupFlags which conflicts)
159pub use wmo_group_types::{
160 TexCoord, WmoBatch, WmoBspNode, WmoGroup, WmoGroupFlags, WmoGroupHeader, WmoLiquid,
161 WmoLiquidVertex, WmoMaterialInfo, WmoPlane,
162};
163pub use writer::WmoWriter;
164
165// Portal culling exports
166pub use portal::{
167 AABB, Axis, ConvexHull, GroupLocationData, GroupPortalInfo, Plane, Portal, PortalCuller,
168 PortalRef, VisibilityResult, WmoGroupLocator,
169};
170
171// BSP tree exports
172pub use bsp::{BspAxisType, BspNodeExt, BspTree, point_in_group};
173
174/// Re-export of chunk-related types
175pub use chunk::Chunk;
176pub use chunk_header::ChunkHeader;
177pub use chunk_id::ChunkId;
178
179/// Re-export API types from our binrw implementation
180pub use api::{ParseResult, ParsedWmo, discover_wmo_chunks, parse_wmo, parse_wmo_with_metadata};
181
182// Internal parsers are accessed via the ParsedWmo enum from api module
183
184// Validation and conversion functionality will use the new parser
185// These can be implemented later when the legacy structures are removed