fbxcel_dom/v7400/object/
typed.rs1use crate::v7400::object::{
4 deformer, geometry, material, model, nodeattribute, texture, video, ObjectHandle,
5};
6
7#[derive(Debug, Clone, Copy)]
9#[non_exhaustive]
10pub enum TypedObjectHandle<'a> {
11 Deformer(deformer::TypedDeformerHandle<'a>),
13 Geometry(geometry::TypedGeometryHandle<'a>),
15 Material(material::MaterialHandle<'a>),
17 Model(model::TypedModelHandle<'a>),
19 NodeAttribute(nodeattribute::TypedNodeAttributeHandle<'a>),
21 SubDeformer(deformer::TypedSubDeformerHandle<'a>),
23 Texture(texture::TextureHandle<'a>),
25 Video(video::TypedVideoHandle<'a>),
27 Unknown(ObjectHandle<'a>),
29}
30
31impl<'a> TypedObjectHandle<'a> {
32 pub(crate) fn new(obj: ObjectHandle<'a>) -> Self {
34 match obj.node().name() {
35 "Deformer" => match obj.class() {
36 "Deformer" => TypedObjectHandle::Deformer(deformer::TypedDeformerHandle::new(
37 deformer::DeformerHandle::new(obj),
38 )),
39 "SubDeformer" => TypedObjectHandle::SubDeformer(
40 deformer::TypedSubDeformerHandle::new(deformer::SubDeformerHandle::new(obj)),
41 ),
42 _ => TypedObjectHandle::Unknown(obj),
43 },
44 "Geometry" => TypedObjectHandle::Geometry(geometry::TypedGeometryHandle::new(
45 geometry::GeometryHandle::new(obj),
46 )),
47 "Material" => TypedObjectHandle::Material(material::MaterialHandle::new(obj)),
48 "Model" => {
49 TypedObjectHandle::Model(model::TypedModelHandle::new(model::ModelHandle::new(obj)))
50 }
51 "NodeAttribute" => {
52 TypedObjectHandle::NodeAttribute(nodeattribute::TypedNodeAttributeHandle::new(
53 nodeattribute::NodeAttributeHandle::new(obj),
54 ))
55 }
56 "Texture" => TypedObjectHandle::Texture(texture::TextureHandle::new(obj)),
57 "Video" => {
58 TypedObjectHandle::Video(video::TypedVideoHandle::new(video::VideoHandle::new(obj)))
59 }
60 _ => TypedObjectHandle::Unknown(obj),
61 }
62 }
63}
64
65impl<'a> std::ops::Deref for TypedObjectHandle<'a> {
66 type Target = ObjectHandle<'a>;
67
68 fn deref(&self) -> &Self::Target {
69 match self {
70 TypedObjectHandle::Deformer(o) => o,
71 TypedObjectHandle::Geometry(o) => o,
72 TypedObjectHandle::Material(o) => o,
73 TypedObjectHandle::Model(o) => o,
74 TypedObjectHandle::NodeAttribute(o) => o,
75 TypedObjectHandle::SubDeformer(o) => o,
76 TypedObjectHandle::Texture(o) => o,
77 TypedObjectHandle::Video(o) => o,
78 TypedObjectHandle::Unknown(o) => o,
79 }
80 }
81}