RootAdt

Struct RootAdt 

Source
pub struct RootAdt {
Show 20 fields pub version: AdtVersion, pub mhdr: MhdrChunk, pub mcin: McinChunk, pub textures: Vec<String>, pub models: Vec<String>, pub model_indices: Vec<u32>, pub wmos: Vec<String>, pub wmo_indices: Vec<u32>, pub doodad_placements: Vec<DoodadPlacement>, pub wmo_placements: Vec<WmoPlacement>, pub mcnk_chunks: Vec<McnkChunk>, pub flight_bounds: Option<MfboChunk>, pub water_data: Option<Mh2oChunk>, pub texture_flags: Option<MtxfChunk>, pub texture_amplifier: Option<MampChunk>, pub texture_params: Option<MtxpChunk>, pub blend_mesh_headers: Option<MbmhChunk>, pub blend_mesh_bounds: Option<MbbbChunk>, pub blend_mesh_vertices: Option<MbnvChunk>, pub blend_mesh_indices: Option<MbmiChunk>,
}
Expand description

Parsed root ADT file (main terrain file for all versions).

Contains all terrain data for a single 16×16 yard area:

  • Heightmaps and vertex normals
  • Texture layers and alpha blending
  • Object placements (M2 models and WMOs)
  • Version-specific features (water, flight bounds, etc.)

§Guarantees

  • version correctly identifies format version
  • All required chunks present (MHDR, MCIN, MTEX, MCNK)
  • Version-specific chunks only present for compatible versions
  • All indices valid within their respective arrays
  • MCNK count ∈ [1, 256]

§Example

use wow_adt::api::{parse_adt, ParsedAdt};
use std::fs::File;

let mut file = File::open("terrain.adt")?;
let adt = parse_adt(&mut file)?;

if let ParsedAdt::Root(root) = adt {
    println!("Version: {:?}", root.version);
    println!("Terrain chunks: {}", root.mcnk_chunks.len());

    if let Some(water) = &root.water_data {
        // Access water data by chunk index
        for (idx, entry) in water.entries.iter().enumerate() {
            if entry.header.has_liquid() {
                let row = idx / 16;
                let col = idx % 16;
                println!("Chunk ({}, {}) has {} water layer(s)",
                    row, col, entry.instances.len());
            }
        }
    }
}

Fields§

§version: AdtVersion

Detected ADT version

§mhdr: MhdrChunk

MHDR - Header with chunk offsets

§mcin: McinChunk

MCIN - MCNK chunk index (256 entries)

§textures: Vec<String>

Texture filenames from MTEX chunk

§models: Vec<String>

M2 model filenames from MMDX chunk

§model_indices: Vec<u32>

M2 model filename offsets from MMID chunk

§wmos: Vec<String>

WMO filenames from MWMO chunk

§wmo_indices: Vec<u32>

WMO filename offsets from MWID chunk

§doodad_placements: Vec<DoodadPlacement>

M2 model placements from MDDF chunk

§wmo_placements: Vec<WmoPlacement>

WMO placements from MODF chunk

§mcnk_chunks: Vec<McnkChunk>

MCNK terrain chunks (1-256 chunks)

§flight_bounds: Option<MfboChunk>

MFBO - Flight boundaries (TBC+)

§water_data: Option<Mh2oChunk>

MH2O - Advanced water system (WotLK+)

Contains 256 entries (one per MCNK chunk) with liquid layer data. Each entry has header, instances, and optional attributes.

§texture_flags: Option<MtxfChunk>

MTXF - Texture flags (WotLK 3.x+)

Rendering flags for each texture controlling specularity, environment mapping, and animation.

§texture_amplifier: Option<MampChunk>

MAMP - Texture amplifier (Cataclysm+)

§texture_params: Option<MtxpChunk>

MTXP - Texture parameters (MoP+)

§blend_mesh_headers: Option<MbmhChunk>

MBMH - Blend mesh headers (MoP 5.x+)

Headers describing blend mesh batches for smooth texture transitions. Each entry contains map_object_id, texture_id, and index/vertex ranges.

§blend_mesh_bounds: Option<MbbbChunk>

MBBB - Blend mesh bounding boxes (MoP 5.x+)

Bounding boxes for visibility culling of blend meshes. Each entry has map_object_id and min/max coordinates.

§blend_mesh_vertices: Option<MbnvChunk>

MBNV - Blend mesh vertices (MoP 5.x+)

Vertex data for blend mesh system with position, normal, UV coordinates, and 3 RGBA color channels for texture blending.

§blend_mesh_indices: Option<MbmiChunk>

MBMI - Blend mesh indices (MoP 5.x+)

Triangle indices (u16) referencing MBNV vertex array. MCBB chunks in MCNK reference ranges within this array.

Implementations§

Source§

impl RootAdt

Source

pub fn has_water(&self) -> bool

Check if this ADT has water data.

Source

pub fn has_flight_bounds(&self) -> bool

Check if this ADT has flight boundaries.

Source

pub fn terrain_chunk_count(&self) -> usize

Get number of terrain chunks.

Source

pub fn texture_count(&self) -> usize

Get number of textures.

Source

pub fn model_count(&self) -> usize

Get number of M2 models.

Source

pub fn wmo_count(&self) -> usize

Get number of WMO objects.

Source

pub fn textures_mut(&mut self) -> &mut Vec<String>

Get mutable access to textures for replacement workflows.

Use this to modify texture filenames in place. After modification, serialize using AdtBuilder::from_parsed().

§Example
use wow_adt::api::parse_adt;
root.textures_mut()[0] = "terrain/grass_new.blp".to_string();
Source

pub fn models_mut(&mut self) -> &mut Vec<String>

Get mutable access to M2 model filenames.

Source

pub fn wmos_mut(&mut self) -> &mut Vec<String>

Get mutable access to WMO filenames.

Source

pub fn doodad_placements_mut(&mut self) -> &mut Vec<DoodadPlacement>

Get mutable access to M2 model placements.

Use this to add, remove, or modify doodad placements.

§Example
use wow_adt::api::parse_adt;
root.doodad_placements_mut()[0].position[2] += 10.0; // Z coordinate
Source

pub fn wmo_placements_mut(&mut self) -> &mut Vec<WmoPlacement>

Get mutable access to WMO placements.

Source

pub fn mcnk_chunks_mut(&mut self) -> &mut Vec<McnkChunk>

Get mutable access to MCNK terrain chunks.

Use this to modify terrain geometry, heights, textures, etc.

§Example
use wow_adt::api::parse_adt;
if let Some(heights) = &mut root.mcnk_chunks_mut()[0].heights {
    for height in &mut heights.heights {
        *height += 5.0;
    }
}
Source

pub fn water_data_mut(&mut self) -> Option<&mut Mh2oChunk>

Get mutable access to water data (WotLK+).

Returns None if this ADT has no water data.

Source

pub fn flight_bounds_mut(&mut self) -> Option<&mut MfboChunk>

Get mutable access to flight boundaries (TBC+).

Returns None if this ADT has no flight bounds.

Source

pub fn texture_flags_mut(&mut self) -> Option<&mut MtxfChunk>

Get mutable access to texture flags (WotLK+).

Source

pub fn texture_amplifier_mut(&mut self) -> Option<&mut MampChunk>

Get mutable access to texture amplifier (Cataclysm+).

Source

pub fn texture_params_mut(&mut self) -> Option<&mut MtxpChunk>

Get mutable access to texture parameters (MoP+).

Trait Implementations§

Source§

impl Clone for RootAdt

Source§

fn clone(&self) -> RootAdt

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RootAdt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.