Skip to main content

modelio/
sdk_constants.rs

1use crate::ffi;
2use crate::util::take_string;
3
4const UTTYPE_ALEMBIC: u32 = 1;
5const UTTYPE_3D_OBJECT: u32 = 2;
6const UTTYPE_POLYGON: u32 = 3;
7const UTTYPE_STEREOLITHOGRAPHY: u32 = 4;
8const UTTYPE_UNIVERSAL_SCENE_DESCRIPTION: u32 = 5;
9const UTTYPE_UNIVERSAL_SCENE_DESCRIPTION_MOBILE: u32 = 6;
10const VERTEX_ATTRIBUTE_ANISOTROPY: u32 = 101;
11const VERTEX_ATTRIBUTE_BINORMAL: u32 = 102;
12const VERTEX_ATTRIBUTE_BITANGENT: u32 = 103;
13const VERTEX_ATTRIBUTE_COLOR: u32 = 104;
14const VERTEX_ATTRIBUTE_EDGE_CREASE: u32 = 105;
15const VERTEX_ATTRIBUTE_JOINT_INDICES: u32 = 106;
16const VERTEX_ATTRIBUTE_JOINT_WEIGHTS: u32 = 107;
17const VERTEX_ATTRIBUTE_NORMAL: u32 = 108;
18const VERTEX_ATTRIBUTE_OCCLUSION_VALUE: u32 = 109;
19const VERTEX_ATTRIBUTE_POSITION: u32 = 110;
20const VERTEX_ATTRIBUTE_SHADING_BASIS_U: u32 = 111;
21const VERTEX_ATTRIBUTE_SHADING_BASIS_V: u32 = 112;
22const VERTEX_ATTRIBUTE_SUBDIVISION_STENCIL: u32 = 113;
23const VERTEX_ATTRIBUTE_TANGENT: u32 = 114;
24const VERTEX_ATTRIBUTE_TEXTURE_COORDINATE: u32 = 115;
25
26fn sdk_constant(code: u32) -> Option<String> {
27    // SAFETY: FFI call is safe with the provided arguments.
28    take_string(unsafe { ffi::mdl_sdk_constant_string(code) })
29}
30
31/// Groups helper APIs for the corresponding Model I/O ut type symbols.
32pub mod ut_type {
33    use super::{
34        sdk_constant, UTTYPE_3D_OBJECT, UTTYPE_ALEMBIC, UTTYPE_POLYGON, UTTYPE_STEREOLITHOGRAPHY,
35        UTTYPE_UNIVERSAL_SCENE_DESCRIPTION, UTTYPE_UNIVERSAL_SCENE_DESCRIPTION_MOBILE,
36    };
37
38    #[must_use]
39    /// Returns the corresponding Model I/O helper for ut type.
40    pub fn alembic() -> Option<String> {
41        sdk_constant(UTTYPE_ALEMBIC)
42    }
43
44    #[must_use]
45    /// Returns the corresponding Model I/O helper for ut type.
46    pub fn object_3d() -> Option<String> {
47        sdk_constant(UTTYPE_3D_OBJECT)
48    }
49
50    #[must_use]
51    /// Returns the corresponding Model I/O helper for ut type.
52    pub fn polygon() -> Option<String> {
53        sdk_constant(UTTYPE_POLYGON)
54    }
55
56    #[must_use]
57    /// Returns the corresponding Model I/O helper for ut type.
58    pub fn stereolithography() -> Option<String> {
59        sdk_constant(UTTYPE_STEREOLITHOGRAPHY)
60    }
61
62    #[must_use]
63    /// Returns the corresponding Model I/O helper for ut type.
64    pub fn universal_scene_description() -> Option<String> {
65        sdk_constant(UTTYPE_UNIVERSAL_SCENE_DESCRIPTION)
66    }
67
68    #[must_use]
69    /// Returns the corresponding Model I/O helper for ut type.
70    pub fn universal_scene_description_mobile() -> Option<String> {
71        sdk_constant(UTTYPE_UNIVERSAL_SCENE_DESCRIPTION_MOBILE)
72    }
73}
74
75/// Groups helper APIs for the corresponding Model I/O vertex attribute name symbols.
76pub mod vertex_attribute_name {
77    use super::{
78        sdk_constant, VERTEX_ATTRIBUTE_ANISOTROPY, VERTEX_ATTRIBUTE_BINORMAL,
79        VERTEX_ATTRIBUTE_BITANGENT, VERTEX_ATTRIBUTE_COLOR, VERTEX_ATTRIBUTE_EDGE_CREASE,
80        VERTEX_ATTRIBUTE_JOINT_INDICES, VERTEX_ATTRIBUTE_JOINT_WEIGHTS, VERTEX_ATTRIBUTE_NORMAL,
81        VERTEX_ATTRIBUTE_OCCLUSION_VALUE, VERTEX_ATTRIBUTE_POSITION,
82        VERTEX_ATTRIBUTE_SHADING_BASIS_U, VERTEX_ATTRIBUTE_SHADING_BASIS_V,
83        VERTEX_ATTRIBUTE_SUBDIVISION_STENCIL, VERTEX_ATTRIBUTE_TANGENT,
84        VERTEX_ATTRIBUTE_TEXTURE_COORDINATE,
85    };
86
87    #[must_use]
88    /// Returns the corresponding Model I/O helper for vertex attribute name.
89    pub fn anisotropy() -> Option<String> {
90        sdk_constant(VERTEX_ATTRIBUTE_ANISOTROPY)
91    }
92    #[must_use]
93    /// Returns the corresponding Model I/O helper for vertex attribute name.
94    pub fn binormal() -> Option<String> {
95        sdk_constant(VERTEX_ATTRIBUTE_BINORMAL)
96    }
97    #[must_use]
98    /// Returns the corresponding Model I/O helper for vertex attribute name.
99    pub fn bitangent() -> Option<String> {
100        sdk_constant(VERTEX_ATTRIBUTE_BITANGENT)
101    }
102    #[must_use]
103    /// Returns the corresponding Model I/O helper for vertex attribute name.
104    pub fn color() -> Option<String> {
105        sdk_constant(VERTEX_ATTRIBUTE_COLOR)
106    }
107    #[must_use]
108    /// Returns the corresponding Model I/O helper for vertex attribute name.
109    pub fn edge_crease() -> Option<String> {
110        sdk_constant(VERTEX_ATTRIBUTE_EDGE_CREASE)
111    }
112    #[must_use]
113    /// Returns the corresponding Model I/O helper for vertex attribute name.
114    pub fn joint_indices() -> Option<String> {
115        sdk_constant(VERTEX_ATTRIBUTE_JOINT_INDICES)
116    }
117    #[must_use]
118    /// Returns the corresponding Model I/O helper for vertex attribute name.
119    pub fn joint_weights() -> Option<String> {
120        sdk_constant(VERTEX_ATTRIBUTE_JOINT_WEIGHTS)
121    }
122    #[must_use]
123    /// Returns the corresponding Model I/O helper for vertex attribute name.
124    pub fn normal() -> Option<String> {
125        sdk_constant(VERTEX_ATTRIBUTE_NORMAL)
126    }
127    #[must_use]
128    /// Returns the corresponding Model I/O helper for vertex attribute name.
129    pub fn occlusion_value() -> Option<String> {
130        sdk_constant(VERTEX_ATTRIBUTE_OCCLUSION_VALUE)
131    }
132    #[must_use]
133    /// Returns the corresponding Model I/O helper for vertex attribute name.
134    pub fn position() -> Option<String> {
135        sdk_constant(VERTEX_ATTRIBUTE_POSITION)
136    }
137    #[must_use]
138    /// Returns the corresponding Model I/O helper for vertex attribute name.
139    pub fn shading_basis_u() -> Option<String> {
140        sdk_constant(VERTEX_ATTRIBUTE_SHADING_BASIS_U)
141    }
142    #[must_use]
143    /// Returns the corresponding Model I/O helper for vertex attribute name.
144    pub fn shading_basis_v() -> Option<String> {
145        sdk_constant(VERTEX_ATTRIBUTE_SHADING_BASIS_V)
146    }
147    #[must_use]
148    /// Returns the corresponding Model I/O helper for vertex attribute name.
149    pub fn subdivision_stencil() -> Option<String> {
150        sdk_constant(VERTEX_ATTRIBUTE_SUBDIVISION_STENCIL)
151    }
152    #[must_use]
153    /// Returns the corresponding Model I/O helper for vertex attribute name.
154    pub fn tangent() -> Option<String> {
155        sdk_constant(VERTEX_ATTRIBUTE_TANGENT)
156    }
157    #[must_use]
158    /// Returns the corresponding Model I/O helper for vertex attribute name.
159    pub fn texture_coordinate() -> Option<String> {
160        sdk_constant(VERTEX_ATTRIBUTE_TEXTURE_COORDINATE)
161    }
162}