[][src]Enum bvh_anim::JointData

pub enum JointData {
    Root {
        name: JointName,
        offset: Vector3<f32>,
        channels: SmallVec<[Channel; 6]>,
    },
    Child {
        name: JointName,
        offset: Vector3<f32>,
        channels: SmallVec<[Channel; 3]>,
        end_site_offset: Option<Vector3<f32>>,
        // some fields omitted
    },
}

Internal representation of a joint.

Variants

Root

Root of the skeletal heirarchy.

Fields of Root

name: JointName

Name of the root Joint.

offset: Vector3<f32>

Positional offset of this Joint relative to the parent.

channels: SmallVec<[Channel; 6]>

The channels applicable to this Joint.

Child

A child joint in the skeleton.

Fields of Child

name: JointName

Name of the Joint.

offset: Vector3<f32>

Positional offset of this Joint relative to the parent.

channels: SmallVec<[Channel; 3]>

The channels applicable to this Joint.

end_site_offset: Option<Vector3<f32>>

End site offset.

Methods

impl JointData[src]

pub fn is_root(&self) -> bool[src]

Returns true if the Joint is the root Joint, or false if it isn't.

Examples

let bvh = bvh! {
    HIERARCHY
    ROOT Hips
    {
        OFFSET 0.0 0.0 0.0
        CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
        End Site {
            OFFSET 0.0 0.0 30.0
        }
    }
    MOTION
    Frames: 0
    Frame Time: 0.0333333
};

let root = bvh.root_joint().unwrap();
assert!(root.data().is_root());

pub fn is_child(&self) -> bool[src]

Returns true if the Joint is a child Joint, or false if it isn't.

Examples

let bvh = bvh! {
    // bvh hierarchy unspecified ..
};

for joint in bvh.joints().skip(1) {
    assert!(joint.data().is_child());
}

pub fn name(&self) -> &BStr[src]

Returns the name of the JointData.

Examples

let bvh = bvh! {
    HIERARCHY
    ROOT Hips
    {
        OFFSET 0.0 0.0 0.0
        CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
        // ...
    }
    MOTION
    // ...
};

let root = bvh.root_joint().unwrap();
assert_eq!(root.data().name(), "Hips");

pub fn offset(&self) -> &Vector3<f32>[src]

Returns the offset of the JointData if it exists, or None.

Examples

let bvh = bvh! {
    HIERARCHY
    ROOT Hips
    {
        OFFSET 1.2 3.4 5.6
        CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
        // ...
    }
    MOTION
    // ...
};

let root = bvh.root_joint().unwrap();
assert_eq!(root.data().offset(), &[1.2, 3.4, 5.6].into());

pub fn end_site(&self) -> Option<&Vector3<f32>>[src]

Returns the end_site position if this Joint has an end site, or None if it doesn't.

Examples

let bvh = bvh! {
    HIERARCHY
    ROOT Base
    {
        OFFSET 0.0 0.0 0.0
        CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
        JOINT Tip
        {
            OFFSET 0.0 0.0 5.0
            CHANNELS 3 Zrotation Xrotation Yrotation
            End Site
            {
                OFFSET 5.4 3.2 1.0
            }
        }
    }
    MOTION
    // ...
};
let mut joints = bvh.joints();
let base = joints.next().unwrap();
assert!(base.data().end_site().is_none());

let tip = joints.next().unwrap();
assert_eq!(tip.data().end_site(), Some([5.4, 3.2, 1.0].into()).as_ref());

pub fn has_end_site(&self) -> bool[src]

Returns true if the Joint has an end_site_offset, or false if it doesn't.

pub fn channels(&self) -> &[Channel][src]

Returns the ordered array of Channels of this JointData.

Examples

let bvh = bvh! {
    HIERARCHY
    ROOT Hips
    {
        OFFSET 0.0 0.0 0.0
        CHANNELS 6 Xposition Yposition Zposition Zrotation Xrotation Yrotation
        // ...
    }
    MOTION
    // ...
};

let root = bvh.root_joint().unwrap();
let expected_channels = &[
    ChannelType::PositionX,
    ChannelType::PositionY,
    ChannelType::PositionZ,
    ChannelType::RotationZ,
    ChannelType::RotationX,
    ChannelType::RotationY,
];

for (channel, &expected) in root
    .data()
    .channels()
    .iter()
    .map(|c| c.channel_type())
    .zip(expected_channels.iter())
{
    assert_eq!(channel, expected);
}

pub fn channels_mut(&mut self) -> &mut [Channel][src]

Returns a mutable reference to ordered array of Channels of this JointData.

pub fn num_channels(&self) -> usize[src]

Returns the total number of channels applicable to this JointData.

pub fn index(&self) -> usize[src]

Return the index of this Joint in the array.

pub fn parent_index(&self) -> Option<usize>[src]

Returns the index of the parent JointData, or None if this JointData is the root joint.

Trait Implementations

impl PartialEq<JointData> for JointData[src]

impl Clone for JointData[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for JointData[src]

Auto Trait Implementations

impl Send for JointData

impl Sync for JointData

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]