M2Camera

Struct M2Camera 

Source
pub struct M2Camera {
    pub camera_type: u32,
    pub fov: f32,
    pub far_clip: f32,
    pub near_clip: f32,
    pub position_animation: M2AnimationBlock<C3Vector>,
    pub position_base: C3Vector,
    pub target_position_animation: M2AnimationBlock<C3Vector>,
    pub target_position_base: C3Vector,
    pub roll_animation: M2AnimationBlock<f32>,
    pub id: u32,
    pub flags: M2CameraFlags,
}
Expand description

Represents a camera in an M2 model

Camera structure layout:

  • Pre-WotLK (version < 264): 124 bytes
    • type(4) + fov/far/near(12) + pos_track(28) + pos_base(12)
      • target_track(28) + target_base(12) + roll_track(28)
  • WotLK+ (version >= 264): 108 bytes
    • type(4) + fov/far/near(12) + pos_track(20) + pos_base(12)
      • target_track(20) + target_base(12) + roll_track(20) + id(4) + flags(2) + pad(2)

Fields§

§camera_type: u32

Camera type (0=portrait, 1=character info, -1=default)

§fov: f32

Field of view (in radians)

§far_clip: f32

Far clip distance

§near_clip: f32

Near clip distance

§position_animation: M2AnimationBlock<C3Vector>

Camera position animation

§position_base: C3Vector

Camera position base (default position when not animated)

§target_position_animation: M2AnimationBlock<C3Vector>

Target position animation

§target_position_base: C3Vector

Target position base (default target when not animated)

§roll_animation: M2AnimationBlock<f32>

Roll animation (rotation around the view axis)

§id: u32

Camera ID (WotLK+ only)

§flags: M2CameraFlags

Camera flags (WotLK+ only)

Implementations§

Source§

impl M2Camera

Source

pub fn parse<R: Read + Seek>(reader: &mut R, version: u32) -> Result<Self>

Parse a camera from a reader based on the M2 version

Camera structure varies by version:

  • Pre-WotLK (< 264): 124 bytes - header + tracks + base values (no id/flags)
  • WotLK+ (>= 264): 108 bytes - smaller tracks + id/flags
Source

pub fn write<W: Write>(&self, writer: &mut W, version: u32) -> Result<()>

Write a camera to a writer based on the M2 version

Source

pub fn convert(&self, _target_version: M2Version) -> Self

Convert this camera to a different version (no version differences for cameras)

Source

pub fn new(id: u32) -> Self

Create a new camera with default values

Source

pub fn size(version: u32) -> usize

Returns the size of a camera in bytes for the given version

Trait Implementations§

Source§

impl Clone for M2Camera

Source§

fn clone(&self) -> M2Camera

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 M2Camera

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.