assimp-ruby 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +170 -0
- data/Rakefile +66 -0
- data/generator/generate.rb +297 -0
- data/generator/layout_probe.c +288 -0
- data/generator/verify_layout.rb +33 -0
- data/lib/assimp/animation.rb +27 -0
- data/lib/assimp/animation_copier.rb +50 -0
- data/lib/assimp/embedded_texture.rb +23 -0
- data/lib/assimp/errors.rb +9 -0
- data/lib/assimp/import_source.rb +54 -0
- data/lib/assimp/importer.rb +54 -0
- data/lib/assimp/material.rb +73 -0
- data/lib/assimp/material_copier.rb +148 -0
- data/lib/assimp/math.rb +36 -0
- data/lib/assimp/mesh.rb +51 -0
- data/lib/assimp/mesh_copier.rb +150 -0
- data/lib/assimp/native/generated.rb +475 -0
- data/lib/assimp/native/platform.rb +67 -0
- data/lib/assimp/native/types.rb +60 -0
- data/lib/assimp/native.rb +148 -0
- data/lib/assimp/native_reader.rb +25 -0
- data/lib/assimp/node.rb +29 -0
- data/lib/assimp/post_process.rb +35 -0
- data/lib/assimp/raw_scene.rb +97 -0
- data/lib/assimp/scene.rb +42 -0
- data/lib/assimp/scene_copier.rb +46 -0
- data/lib/assimp/texture_copier.rb +17 -0
- data/lib/assimp/version.rb +5 -0
- data/lib/assimp.rb +46 -0
- data/rakelib/native_package.rake +187 -0
- data/script/smoke_gem.rb +25 -0
- data/script/verify_release.rb +33 -0
- metadata +90 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/* Generated from Assimp 5.4 headers by generator/generate.rb. */
|
|
2
|
+
/* Do not edit this file directly. */
|
|
3
|
+
#include <stddef.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <assimp/cimport.h>
|
|
6
|
+
#include <assimp/scene.h>
|
|
7
|
+
|
|
8
|
+
int main(void) {
|
|
9
|
+
printf("S\taiBuffer\t%zu\n", sizeof(struct aiBuffer));
|
|
10
|
+
printf("F\taiBuffer\tdata\t%zu\n", offsetof(struct aiBuffer, data));
|
|
11
|
+
printf("F\taiBuffer\tend\t%zu\n", offsetof(struct aiBuffer, end));
|
|
12
|
+
printf("S\taiColor3D\t%zu\n", sizeof(struct aiColor3D));
|
|
13
|
+
printf("F\taiColor3D\tr\t%zu\n", offsetof(struct aiColor3D, r));
|
|
14
|
+
printf("F\taiColor3D\tg\t%zu\n", offsetof(struct aiColor3D, g));
|
|
15
|
+
printf("F\taiColor3D\tb\t%zu\n", offsetof(struct aiColor3D, b));
|
|
16
|
+
printf("S\taiColor4D\t%zu\n", sizeof(struct aiColor4D));
|
|
17
|
+
printf("F\taiColor4D\tr\t%zu\n", offsetof(struct aiColor4D, r));
|
|
18
|
+
printf("F\taiColor4D\tg\t%zu\n", offsetof(struct aiColor4D, g));
|
|
19
|
+
printf("F\taiColor4D\tb\t%zu\n", offsetof(struct aiColor4D, b));
|
|
20
|
+
printf("F\taiColor4D\ta\t%zu\n", offsetof(struct aiColor4D, a));
|
|
21
|
+
printf("S\taiFace\t%zu\n", sizeof(struct aiFace));
|
|
22
|
+
printf("F\taiFace\tnum_indices\t%zu\n", offsetof(struct aiFace, mNumIndices));
|
|
23
|
+
printf("F\taiFace\tindices\t%zu\n", offsetof(struct aiFace, mIndices));
|
|
24
|
+
printf("S\taiImporterDesc\t%zu\n", sizeof(struct aiImporterDesc));
|
|
25
|
+
printf("F\taiImporterDesc\tname\t%zu\n", offsetof(struct aiImporterDesc, mName));
|
|
26
|
+
printf("F\taiImporterDesc\tauthor\t%zu\n", offsetof(struct aiImporterDesc, mAuthor));
|
|
27
|
+
printf("F\taiImporterDesc\tmaintainer\t%zu\n", offsetof(struct aiImporterDesc, mMaintainer));
|
|
28
|
+
printf("F\taiImporterDesc\tcomments\t%zu\n", offsetof(struct aiImporterDesc, mComments));
|
|
29
|
+
printf("F\taiImporterDesc\tflags\t%zu\n", offsetof(struct aiImporterDesc, mFlags));
|
|
30
|
+
printf("F\taiImporterDesc\tmin_major\t%zu\n", offsetof(struct aiImporterDesc, mMinMajor));
|
|
31
|
+
printf("F\taiImporterDesc\tmin_minor\t%zu\n", offsetof(struct aiImporterDesc, mMinMinor));
|
|
32
|
+
printf("F\taiImporterDesc\tmax_major\t%zu\n", offsetof(struct aiImporterDesc, mMaxMajor));
|
|
33
|
+
printf("F\taiImporterDesc\tmax_minor\t%zu\n", offsetof(struct aiImporterDesc, mMaxMinor));
|
|
34
|
+
printf("F\taiImporterDesc\tfile_extensions\t%zu\n", offsetof(struct aiImporterDesc, mFileExtensions));
|
|
35
|
+
printf("S\taiLogStream\t%zu\n", sizeof(struct aiLogStream));
|
|
36
|
+
printf("F\taiLogStream\tcallback\t%zu\n", offsetof(struct aiLogStream, callback));
|
|
37
|
+
printf("F\taiLogStream\tuser\t%zu\n", offsetof(struct aiLogStream, user));
|
|
38
|
+
printf("S\taiMaterial\t%zu\n", sizeof(struct aiMaterial));
|
|
39
|
+
printf("F\taiMaterial\tproperties\t%zu\n", offsetof(struct aiMaterial, mProperties));
|
|
40
|
+
printf("F\taiMaterial\tnum_properties\t%zu\n", offsetof(struct aiMaterial, mNumProperties));
|
|
41
|
+
printf("F\taiMaterial\tnum_allocated\t%zu\n", offsetof(struct aiMaterial, mNumAllocated));
|
|
42
|
+
printf("S\taiMatrix3x3\t%zu\n", sizeof(struct aiMatrix3x3));
|
|
43
|
+
printf("F\taiMatrix3x3\ta1\t%zu\n", offsetof(struct aiMatrix3x3, a1));
|
|
44
|
+
printf("F\taiMatrix3x3\ta2\t%zu\n", offsetof(struct aiMatrix3x3, a2));
|
|
45
|
+
printf("F\taiMatrix3x3\ta3\t%zu\n", offsetof(struct aiMatrix3x3, a3));
|
|
46
|
+
printf("F\taiMatrix3x3\tb1\t%zu\n", offsetof(struct aiMatrix3x3, b1));
|
|
47
|
+
printf("F\taiMatrix3x3\tb2\t%zu\n", offsetof(struct aiMatrix3x3, b2));
|
|
48
|
+
printf("F\taiMatrix3x3\tb3\t%zu\n", offsetof(struct aiMatrix3x3, b3));
|
|
49
|
+
printf("F\taiMatrix3x3\tc1\t%zu\n", offsetof(struct aiMatrix3x3, c1));
|
|
50
|
+
printf("F\taiMatrix3x3\tc2\t%zu\n", offsetof(struct aiMatrix3x3, c2));
|
|
51
|
+
printf("F\taiMatrix3x3\tc3\t%zu\n", offsetof(struct aiMatrix3x3, c3));
|
|
52
|
+
printf("S\taiMatrix4x4\t%zu\n", sizeof(struct aiMatrix4x4));
|
|
53
|
+
printf("F\taiMatrix4x4\ta1\t%zu\n", offsetof(struct aiMatrix4x4, a1));
|
|
54
|
+
printf("F\taiMatrix4x4\ta2\t%zu\n", offsetof(struct aiMatrix4x4, a2));
|
|
55
|
+
printf("F\taiMatrix4x4\ta3\t%zu\n", offsetof(struct aiMatrix4x4, a3));
|
|
56
|
+
printf("F\taiMatrix4x4\ta4\t%zu\n", offsetof(struct aiMatrix4x4, a4));
|
|
57
|
+
printf("F\taiMatrix4x4\tb1\t%zu\n", offsetof(struct aiMatrix4x4, b1));
|
|
58
|
+
printf("F\taiMatrix4x4\tb2\t%zu\n", offsetof(struct aiMatrix4x4, b2));
|
|
59
|
+
printf("F\taiMatrix4x4\tb3\t%zu\n", offsetof(struct aiMatrix4x4, b3));
|
|
60
|
+
printf("F\taiMatrix4x4\tb4\t%zu\n", offsetof(struct aiMatrix4x4, b4));
|
|
61
|
+
printf("F\taiMatrix4x4\tc1\t%zu\n", offsetof(struct aiMatrix4x4, c1));
|
|
62
|
+
printf("F\taiMatrix4x4\tc2\t%zu\n", offsetof(struct aiMatrix4x4, c2));
|
|
63
|
+
printf("F\taiMatrix4x4\tc3\t%zu\n", offsetof(struct aiMatrix4x4, c3));
|
|
64
|
+
printf("F\taiMatrix4x4\tc4\t%zu\n", offsetof(struct aiMatrix4x4, c4));
|
|
65
|
+
printf("F\taiMatrix4x4\td1\t%zu\n", offsetof(struct aiMatrix4x4, d1));
|
|
66
|
+
printf("F\taiMatrix4x4\td2\t%zu\n", offsetof(struct aiMatrix4x4, d2));
|
|
67
|
+
printf("F\taiMatrix4x4\td3\t%zu\n", offsetof(struct aiMatrix4x4, d3));
|
|
68
|
+
printf("F\taiMatrix4x4\td4\t%zu\n", offsetof(struct aiMatrix4x4, d4));
|
|
69
|
+
printf("S\taiMemoryInfo\t%zu\n", sizeof(struct aiMemoryInfo));
|
|
70
|
+
printf("F\taiMemoryInfo\ttextures\t%zu\n", offsetof(struct aiMemoryInfo, textures));
|
|
71
|
+
printf("F\taiMemoryInfo\tmaterials\t%zu\n", offsetof(struct aiMemoryInfo, materials));
|
|
72
|
+
printf("F\taiMemoryInfo\tmeshes\t%zu\n", offsetof(struct aiMemoryInfo, meshes));
|
|
73
|
+
printf("F\taiMemoryInfo\tnodes\t%zu\n", offsetof(struct aiMemoryInfo, nodes));
|
|
74
|
+
printf("F\taiMemoryInfo\tanimations\t%zu\n", offsetof(struct aiMemoryInfo, animations));
|
|
75
|
+
printf("F\taiMemoryInfo\tcameras\t%zu\n", offsetof(struct aiMemoryInfo, cameras));
|
|
76
|
+
printf("F\taiMemoryInfo\tlights\t%zu\n", offsetof(struct aiMemoryInfo, lights));
|
|
77
|
+
printf("F\taiMemoryInfo\ttotal\t%zu\n", offsetof(struct aiMemoryInfo, total));
|
|
78
|
+
printf("S\taiMeshKey\t%zu\n", sizeof(struct aiMeshKey));
|
|
79
|
+
printf("F\taiMeshKey\ttime\t%zu\n", offsetof(struct aiMeshKey, mTime));
|
|
80
|
+
printf("F\taiMeshKey\tvalue\t%zu\n", offsetof(struct aiMeshKey, mValue));
|
|
81
|
+
printf("S\taiMeshMorphKey\t%zu\n", sizeof(struct aiMeshMorphKey));
|
|
82
|
+
printf("F\taiMeshMorphKey\ttime\t%zu\n", offsetof(struct aiMeshMorphKey, mTime));
|
|
83
|
+
printf("F\taiMeshMorphKey\tvalues\t%zu\n", offsetof(struct aiMeshMorphKey, mValues));
|
|
84
|
+
printf("F\taiMeshMorphKey\tweights\t%zu\n", offsetof(struct aiMeshMorphKey, mWeights));
|
|
85
|
+
printf("F\taiMeshMorphKey\tnum_values_and_weights\t%zu\n", offsetof(struct aiMeshMorphKey, mNumValuesAndWeights));
|
|
86
|
+
printf("S\taiMetadata\t%zu\n", sizeof(struct aiMetadata));
|
|
87
|
+
printf("F\taiMetadata\tnum_properties\t%zu\n", offsetof(struct aiMetadata, mNumProperties));
|
|
88
|
+
printf("F\taiMetadata\tkeys\t%zu\n", offsetof(struct aiMetadata, mKeys));
|
|
89
|
+
printf("F\taiMetadata\tvalues\t%zu\n", offsetof(struct aiMetadata, mValues));
|
|
90
|
+
printf("S\taiMetadataEntry\t%zu\n", sizeof(struct aiMetadataEntry));
|
|
91
|
+
printf("F\taiMetadataEntry\ttype\t%zu\n", offsetof(struct aiMetadataEntry, mType));
|
|
92
|
+
printf("F\taiMetadataEntry\tdata\t%zu\n", offsetof(struct aiMetadataEntry, mData));
|
|
93
|
+
printf("S\taiPlane\t%zu\n", sizeof(struct aiPlane));
|
|
94
|
+
printf("F\taiPlane\ta\t%zu\n", offsetof(struct aiPlane, a));
|
|
95
|
+
printf("F\taiPlane\tb\t%zu\n", offsetof(struct aiPlane, b));
|
|
96
|
+
printf("F\taiPlane\tc\t%zu\n", offsetof(struct aiPlane, c));
|
|
97
|
+
printf("F\taiPlane\td\t%zu\n", offsetof(struct aiPlane, d));
|
|
98
|
+
printf("S\taiPropertyStore\t%zu\n", sizeof(struct aiPropertyStore));
|
|
99
|
+
printf("F\taiPropertyStore\tsentinel\t%zu\n", offsetof(struct aiPropertyStore, sentinel));
|
|
100
|
+
printf("S\taiQuaternion\t%zu\n", sizeof(struct aiQuaternion));
|
|
101
|
+
printf("F\taiQuaternion\tw\t%zu\n", offsetof(struct aiQuaternion, w));
|
|
102
|
+
printf("F\taiQuaternion\tx\t%zu\n", offsetof(struct aiQuaternion, x));
|
|
103
|
+
printf("F\taiQuaternion\ty\t%zu\n", offsetof(struct aiQuaternion, y));
|
|
104
|
+
printf("F\taiQuaternion\tz\t%zu\n", offsetof(struct aiQuaternion, z));
|
|
105
|
+
printf("S\taiString\t%zu\n", sizeof(struct aiString));
|
|
106
|
+
printf("F\taiString\tlength\t%zu\n", offsetof(struct aiString, length));
|
|
107
|
+
printf("F\taiString\tdata\t%zu\n", offsetof(struct aiString, data));
|
|
108
|
+
printf("S\taiTexel\t%zu\n", sizeof(struct aiTexel));
|
|
109
|
+
printf("F\taiTexel\tb\t%zu\n", offsetof(struct aiTexel, b));
|
|
110
|
+
printf("F\taiTexel\tg\t%zu\n", offsetof(struct aiTexel, g));
|
|
111
|
+
printf("F\taiTexel\tr\t%zu\n", offsetof(struct aiTexel, r));
|
|
112
|
+
printf("F\taiTexel\ta\t%zu\n", offsetof(struct aiTexel, a));
|
|
113
|
+
printf("S\taiVector2D\t%zu\n", sizeof(struct aiVector2D));
|
|
114
|
+
printf("F\taiVector2D\tx\t%zu\n", offsetof(struct aiVector2D, x));
|
|
115
|
+
printf("F\taiVector2D\ty\t%zu\n", offsetof(struct aiVector2D, y));
|
|
116
|
+
printf("S\taiVector3D\t%zu\n", sizeof(struct aiVector3D));
|
|
117
|
+
printf("F\taiVector3D\tx\t%zu\n", offsetof(struct aiVector3D, x));
|
|
118
|
+
printf("F\taiVector3D\ty\t%zu\n", offsetof(struct aiVector3D, y));
|
|
119
|
+
printf("F\taiVector3D\tz\t%zu\n", offsetof(struct aiVector3D, z));
|
|
120
|
+
printf("S\taiVertexWeight\t%zu\n", sizeof(struct aiVertexWeight));
|
|
121
|
+
printf("F\taiVertexWeight\tvertex_id\t%zu\n", offsetof(struct aiVertexWeight, mVertexId));
|
|
122
|
+
printf("F\taiVertexWeight\tweight\t%zu\n", offsetof(struct aiVertexWeight, mWeight));
|
|
123
|
+
printf("S\taiAABB\t%zu\n", sizeof(struct aiAABB));
|
|
124
|
+
printf("F\taiAABB\tmin\t%zu\n", offsetof(struct aiAABB, mMin));
|
|
125
|
+
printf("F\taiAABB\tmax\t%zu\n", offsetof(struct aiAABB, mMax));
|
|
126
|
+
printf("S\taiAnimMesh\t%zu\n", sizeof(struct aiAnimMesh));
|
|
127
|
+
printf("F\taiAnimMesh\tname\t%zu\n", offsetof(struct aiAnimMesh, mName));
|
|
128
|
+
printf("F\taiAnimMesh\tvertices\t%zu\n", offsetof(struct aiAnimMesh, mVertices));
|
|
129
|
+
printf("F\taiAnimMesh\tnormals\t%zu\n", offsetof(struct aiAnimMesh, mNormals));
|
|
130
|
+
printf("F\taiAnimMesh\ttangents\t%zu\n", offsetof(struct aiAnimMesh, mTangents));
|
|
131
|
+
printf("F\taiAnimMesh\tbitangents\t%zu\n", offsetof(struct aiAnimMesh, mBitangents));
|
|
132
|
+
printf("F\taiAnimMesh\tcolors\t%zu\n", offsetof(struct aiAnimMesh, mColors));
|
|
133
|
+
printf("F\taiAnimMesh\ttexture_coords\t%zu\n", offsetof(struct aiAnimMesh, mTextureCoords));
|
|
134
|
+
printf("F\taiAnimMesh\tnum_vertices\t%zu\n", offsetof(struct aiAnimMesh, mNumVertices));
|
|
135
|
+
printf("F\taiAnimMesh\tweight\t%zu\n", offsetof(struct aiAnimMesh, mWeight));
|
|
136
|
+
printf("S\taiAnimation\t%zu\n", sizeof(struct aiAnimation));
|
|
137
|
+
printf("F\taiAnimation\tname\t%zu\n", offsetof(struct aiAnimation, mName));
|
|
138
|
+
printf("F\taiAnimation\tduration\t%zu\n", offsetof(struct aiAnimation, mDuration));
|
|
139
|
+
printf("F\taiAnimation\tticks_per_second\t%zu\n", offsetof(struct aiAnimation, mTicksPerSecond));
|
|
140
|
+
printf("F\taiAnimation\tnum_channels\t%zu\n", offsetof(struct aiAnimation, mNumChannels));
|
|
141
|
+
printf("F\taiAnimation\tchannels\t%zu\n", offsetof(struct aiAnimation, mChannels));
|
|
142
|
+
printf("F\taiAnimation\tnum_mesh_channels\t%zu\n", offsetof(struct aiAnimation, mNumMeshChannels));
|
|
143
|
+
printf("F\taiAnimation\tmesh_channels\t%zu\n", offsetof(struct aiAnimation, mMeshChannels));
|
|
144
|
+
printf("F\taiAnimation\tnum_morph_mesh_channels\t%zu\n", offsetof(struct aiAnimation, mNumMorphMeshChannels));
|
|
145
|
+
printf("F\taiAnimation\tmorph_mesh_channels\t%zu\n", offsetof(struct aiAnimation, mMorphMeshChannels));
|
|
146
|
+
printf("S\taiBone\t%zu\n", sizeof(struct aiBone));
|
|
147
|
+
printf("F\taiBone\tname\t%zu\n", offsetof(struct aiBone, mName));
|
|
148
|
+
printf("F\taiBone\tnum_weights\t%zu\n", offsetof(struct aiBone, mNumWeights));
|
|
149
|
+
printf("F\taiBone\tarmature\t%zu\n", offsetof(struct aiBone, mArmature));
|
|
150
|
+
printf("F\taiBone\tnode\t%zu\n", offsetof(struct aiBone, mNode));
|
|
151
|
+
printf("F\taiBone\tweights\t%zu\n", offsetof(struct aiBone, mWeights));
|
|
152
|
+
printf("F\taiBone\toffset_matrix\t%zu\n", offsetof(struct aiBone, mOffsetMatrix));
|
|
153
|
+
printf("S\taiCamera\t%zu\n", sizeof(struct aiCamera));
|
|
154
|
+
printf("F\taiCamera\tname\t%zu\n", offsetof(struct aiCamera, mName));
|
|
155
|
+
printf("F\taiCamera\tposition\t%zu\n", offsetof(struct aiCamera, mPosition));
|
|
156
|
+
printf("F\taiCamera\tup\t%zu\n", offsetof(struct aiCamera, mUp));
|
|
157
|
+
printf("F\taiCamera\tlook_at\t%zu\n", offsetof(struct aiCamera, mLookAt));
|
|
158
|
+
printf("F\taiCamera\thorizontal_fov\t%zu\n", offsetof(struct aiCamera, mHorizontalFOV));
|
|
159
|
+
printf("F\taiCamera\tclip_plane_near\t%zu\n", offsetof(struct aiCamera, mClipPlaneNear));
|
|
160
|
+
printf("F\taiCamera\tclip_plane_far\t%zu\n", offsetof(struct aiCamera, mClipPlaneFar));
|
|
161
|
+
printf("F\taiCamera\taspect\t%zu\n", offsetof(struct aiCamera, mAspect));
|
|
162
|
+
printf("F\taiCamera\torthographic_width\t%zu\n", offsetof(struct aiCamera, mOrthographicWidth));
|
|
163
|
+
printf("S\taiLight\t%zu\n", sizeof(struct aiLight));
|
|
164
|
+
printf("F\taiLight\tname\t%zu\n", offsetof(struct aiLight, mName));
|
|
165
|
+
printf("F\taiLight\ttype\t%zu\n", offsetof(struct aiLight, mType));
|
|
166
|
+
printf("F\taiLight\tposition\t%zu\n", offsetof(struct aiLight, mPosition));
|
|
167
|
+
printf("F\taiLight\tdirection\t%zu\n", offsetof(struct aiLight, mDirection));
|
|
168
|
+
printf("F\taiLight\tup\t%zu\n", offsetof(struct aiLight, mUp));
|
|
169
|
+
printf("F\taiLight\tattenuation_constant\t%zu\n", offsetof(struct aiLight, mAttenuationConstant));
|
|
170
|
+
printf("F\taiLight\tattenuation_linear\t%zu\n", offsetof(struct aiLight, mAttenuationLinear));
|
|
171
|
+
printf("F\taiLight\tattenuation_quadratic\t%zu\n", offsetof(struct aiLight, mAttenuationQuadratic));
|
|
172
|
+
printf("F\taiLight\tcolor_diffuse\t%zu\n", offsetof(struct aiLight, mColorDiffuse));
|
|
173
|
+
printf("F\taiLight\tcolor_specular\t%zu\n", offsetof(struct aiLight, mColorSpecular));
|
|
174
|
+
printf("F\taiLight\tcolor_ambient\t%zu\n", offsetof(struct aiLight, mColorAmbient));
|
|
175
|
+
printf("F\taiLight\tangle_inner_cone\t%zu\n", offsetof(struct aiLight, mAngleInnerCone));
|
|
176
|
+
printf("F\taiLight\tangle_outer_cone\t%zu\n", offsetof(struct aiLight, mAngleOuterCone));
|
|
177
|
+
printf("F\taiLight\tsize\t%zu\n", offsetof(struct aiLight, mSize));
|
|
178
|
+
printf("S\taiMaterialProperty\t%zu\n", sizeof(struct aiMaterialProperty));
|
|
179
|
+
printf("F\taiMaterialProperty\tkey\t%zu\n", offsetof(struct aiMaterialProperty, mKey));
|
|
180
|
+
printf("F\taiMaterialProperty\tsemantic\t%zu\n", offsetof(struct aiMaterialProperty, mSemantic));
|
|
181
|
+
printf("F\taiMaterialProperty\tindex\t%zu\n", offsetof(struct aiMaterialProperty, mIndex));
|
|
182
|
+
printf("F\taiMaterialProperty\tdata_length\t%zu\n", offsetof(struct aiMaterialProperty, mDataLength));
|
|
183
|
+
printf("F\taiMaterialProperty\ttype\t%zu\n", offsetof(struct aiMaterialProperty, mType));
|
|
184
|
+
printf("F\taiMaterialProperty\tdata\t%zu\n", offsetof(struct aiMaterialProperty, mData));
|
|
185
|
+
printf("S\taiMeshAnim\t%zu\n", sizeof(struct aiMeshAnim));
|
|
186
|
+
printf("F\taiMeshAnim\tname\t%zu\n", offsetof(struct aiMeshAnim, mName));
|
|
187
|
+
printf("F\taiMeshAnim\tnum_keys\t%zu\n", offsetof(struct aiMeshAnim, mNumKeys));
|
|
188
|
+
printf("F\taiMeshAnim\tkeys\t%zu\n", offsetof(struct aiMeshAnim, mKeys));
|
|
189
|
+
printf("S\taiMeshMorphAnim\t%zu\n", sizeof(struct aiMeshMorphAnim));
|
|
190
|
+
printf("F\taiMeshMorphAnim\tname\t%zu\n", offsetof(struct aiMeshMorphAnim, mName));
|
|
191
|
+
printf("F\taiMeshMorphAnim\tnum_keys\t%zu\n", offsetof(struct aiMeshMorphAnim, mNumKeys));
|
|
192
|
+
printf("F\taiMeshMorphAnim\tkeys\t%zu\n", offsetof(struct aiMeshMorphAnim, mKeys));
|
|
193
|
+
printf("S\taiNode\t%zu\n", sizeof(struct aiNode));
|
|
194
|
+
printf("F\taiNode\tname\t%zu\n", offsetof(struct aiNode, mName));
|
|
195
|
+
printf("F\taiNode\ttransformation\t%zu\n", offsetof(struct aiNode, mTransformation));
|
|
196
|
+
printf("F\taiNode\tparent\t%zu\n", offsetof(struct aiNode, mParent));
|
|
197
|
+
printf("F\taiNode\tnum_children\t%zu\n", offsetof(struct aiNode, mNumChildren));
|
|
198
|
+
printf("F\taiNode\tchildren\t%zu\n", offsetof(struct aiNode, mChildren));
|
|
199
|
+
printf("F\taiNode\tnum_meshes\t%zu\n", offsetof(struct aiNode, mNumMeshes));
|
|
200
|
+
printf("F\taiNode\tmeshes\t%zu\n", offsetof(struct aiNode, mMeshes));
|
|
201
|
+
printf("F\taiNode\tmeta_data\t%zu\n", offsetof(struct aiNode, mMetaData));
|
|
202
|
+
printf("S\taiNodeAnim\t%zu\n", sizeof(struct aiNodeAnim));
|
|
203
|
+
printf("F\taiNodeAnim\tnode_name\t%zu\n", offsetof(struct aiNodeAnim, mNodeName));
|
|
204
|
+
printf("F\taiNodeAnim\tnum_position_keys\t%zu\n", offsetof(struct aiNodeAnim, mNumPositionKeys));
|
|
205
|
+
printf("F\taiNodeAnim\tposition_keys\t%zu\n", offsetof(struct aiNodeAnim, mPositionKeys));
|
|
206
|
+
printf("F\taiNodeAnim\tnum_rotation_keys\t%zu\n", offsetof(struct aiNodeAnim, mNumRotationKeys));
|
|
207
|
+
printf("F\taiNodeAnim\trotation_keys\t%zu\n", offsetof(struct aiNodeAnim, mRotationKeys));
|
|
208
|
+
printf("F\taiNodeAnim\tnum_scaling_keys\t%zu\n", offsetof(struct aiNodeAnim, mNumScalingKeys));
|
|
209
|
+
printf("F\taiNodeAnim\tscaling_keys\t%zu\n", offsetof(struct aiNodeAnim, mScalingKeys));
|
|
210
|
+
printf("F\taiNodeAnim\tpre_state\t%zu\n", offsetof(struct aiNodeAnim, mPreState));
|
|
211
|
+
printf("F\taiNodeAnim\tpost_state\t%zu\n", offsetof(struct aiNodeAnim, mPostState));
|
|
212
|
+
printf("S\taiQuatKey\t%zu\n", sizeof(struct aiQuatKey));
|
|
213
|
+
printf("F\taiQuatKey\ttime\t%zu\n", offsetof(struct aiQuatKey, mTime));
|
|
214
|
+
printf("F\taiQuatKey\tvalue\t%zu\n", offsetof(struct aiQuatKey, mValue));
|
|
215
|
+
printf("F\taiQuatKey\tinterpolation\t%zu\n", offsetof(struct aiQuatKey, mInterpolation));
|
|
216
|
+
printf("S\taiRay\t%zu\n", sizeof(struct aiRay));
|
|
217
|
+
printf("F\taiRay\tpos\t%zu\n", offsetof(struct aiRay, pos));
|
|
218
|
+
printf("F\taiRay\tdir\t%zu\n", offsetof(struct aiRay, dir));
|
|
219
|
+
printf("S\taiScene\t%zu\n", sizeof(struct aiScene));
|
|
220
|
+
printf("F\taiScene\tflags\t%zu\n", offsetof(struct aiScene, mFlags));
|
|
221
|
+
printf("F\taiScene\troot_node\t%zu\n", offsetof(struct aiScene, mRootNode));
|
|
222
|
+
printf("F\taiScene\tnum_meshes\t%zu\n", offsetof(struct aiScene, mNumMeshes));
|
|
223
|
+
printf("F\taiScene\tmeshes\t%zu\n", offsetof(struct aiScene, mMeshes));
|
|
224
|
+
printf("F\taiScene\tnum_materials\t%zu\n", offsetof(struct aiScene, mNumMaterials));
|
|
225
|
+
printf("F\taiScene\tmaterials\t%zu\n", offsetof(struct aiScene, mMaterials));
|
|
226
|
+
printf("F\taiScene\tnum_animations\t%zu\n", offsetof(struct aiScene, mNumAnimations));
|
|
227
|
+
printf("F\taiScene\tanimations\t%zu\n", offsetof(struct aiScene, mAnimations));
|
|
228
|
+
printf("F\taiScene\tnum_textures\t%zu\n", offsetof(struct aiScene, mNumTextures));
|
|
229
|
+
printf("F\taiScene\ttextures\t%zu\n", offsetof(struct aiScene, mTextures));
|
|
230
|
+
printf("F\taiScene\tnum_lights\t%zu\n", offsetof(struct aiScene, mNumLights));
|
|
231
|
+
printf("F\taiScene\tlights\t%zu\n", offsetof(struct aiScene, mLights));
|
|
232
|
+
printf("F\taiScene\tnum_cameras\t%zu\n", offsetof(struct aiScene, mNumCameras));
|
|
233
|
+
printf("F\taiScene\tcameras\t%zu\n", offsetof(struct aiScene, mCameras));
|
|
234
|
+
printf("F\taiScene\tmeta_data\t%zu\n", offsetof(struct aiScene, mMetaData));
|
|
235
|
+
printf("F\taiScene\tname\t%zu\n", offsetof(struct aiScene, mName));
|
|
236
|
+
printf("F\taiScene\tnum_skeletons\t%zu\n", offsetof(struct aiScene, mNumSkeletons));
|
|
237
|
+
printf("F\taiScene\tskeletons\t%zu\n", offsetof(struct aiScene, mSkeletons));
|
|
238
|
+
printf("F\taiScene\tprivate\t%zu\n", offsetof(struct aiScene, mPrivate));
|
|
239
|
+
printf("S\taiSkeleton\t%zu\n", sizeof(struct aiSkeleton));
|
|
240
|
+
printf("F\taiSkeleton\tname\t%zu\n", offsetof(struct aiSkeleton, mName));
|
|
241
|
+
printf("F\taiSkeleton\tnum_bones\t%zu\n", offsetof(struct aiSkeleton, mNumBones));
|
|
242
|
+
printf("F\taiSkeleton\tbones\t%zu\n", offsetof(struct aiSkeleton, mBones));
|
|
243
|
+
printf("S\taiSkeletonBone\t%zu\n", sizeof(struct aiSkeletonBone));
|
|
244
|
+
printf("F\taiSkeletonBone\tparent\t%zu\n", offsetof(struct aiSkeletonBone, mParent));
|
|
245
|
+
printf("F\taiSkeletonBone\tarmature\t%zu\n", offsetof(struct aiSkeletonBone, mArmature));
|
|
246
|
+
printf("F\taiSkeletonBone\tnode\t%zu\n", offsetof(struct aiSkeletonBone, mNode));
|
|
247
|
+
printf("F\taiSkeletonBone\tnumn_weights\t%zu\n", offsetof(struct aiSkeletonBone, mNumnWeights));
|
|
248
|
+
printf("F\taiSkeletonBone\tmesh_id\t%zu\n", offsetof(struct aiSkeletonBone, mMeshId));
|
|
249
|
+
printf("F\taiSkeletonBone\tweights\t%zu\n", offsetof(struct aiSkeletonBone, mWeights));
|
|
250
|
+
printf("F\taiSkeletonBone\toffset_matrix\t%zu\n", offsetof(struct aiSkeletonBone, mOffsetMatrix));
|
|
251
|
+
printf("F\taiSkeletonBone\tlocal_matrix\t%zu\n", offsetof(struct aiSkeletonBone, mLocalMatrix));
|
|
252
|
+
printf("S\taiTexture\t%zu\n", sizeof(struct aiTexture));
|
|
253
|
+
printf("F\taiTexture\twidth\t%zu\n", offsetof(struct aiTexture, mWidth));
|
|
254
|
+
printf("F\taiTexture\theight\t%zu\n", offsetof(struct aiTexture, mHeight));
|
|
255
|
+
printf("F\taiTexture\tformat_hint\t%zu\n", offsetof(struct aiTexture, achFormatHint));
|
|
256
|
+
printf("F\taiTexture\tdata\t%zu\n", offsetof(struct aiTexture, pcData));
|
|
257
|
+
printf("F\taiTexture\tfilename\t%zu\n", offsetof(struct aiTexture, mFilename));
|
|
258
|
+
printf("S\taiUVTransform\t%zu\n", sizeof(struct aiUVTransform));
|
|
259
|
+
printf("F\taiUVTransform\ttranslation\t%zu\n", offsetof(struct aiUVTransform, mTranslation));
|
|
260
|
+
printf("F\taiUVTransform\tscaling\t%zu\n", offsetof(struct aiUVTransform, mScaling));
|
|
261
|
+
printf("F\taiUVTransform\trotation\t%zu\n", offsetof(struct aiUVTransform, mRotation));
|
|
262
|
+
printf("S\taiVectorKey\t%zu\n", sizeof(struct aiVectorKey));
|
|
263
|
+
printf("F\taiVectorKey\ttime\t%zu\n", offsetof(struct aiVectorKey, mTime));
|
|
264
|
+
printf("F\taiVectorKey\tvalue\t%zu\n", offsetof(struct aiVectorKey, mValue));
|
|
265
|
+
printf("F\taiVectorKey\tinterpolation\t%zu\n", offsetof(struct aiVectorKey, mInterpolation));
|
|
266
|
+
printf("S\taiMesh\t%zu\n", sizeof(struct aiMesh));
|
|
267
|
+
printf("F\taiMesh\tprimitive_types\t%zu\n", offsetof(struct aiMesh, mPrimitiveTypes));
|
|
268
|
+
printf("F\taiMesh\tnum_vertices\t%zu\n", offsetof(struct aiMesh, mNumVertices));
|
|
269
|
+
printf("F\taiMesh\tnum_faces\t%zu\n", offsetof(struct aiMesh, mNumFaces));
|
|
270
|
+
printf("F\taiMesh\tvertices\t%zu\n", offsetof(struct aiMesh, mVertices));
|
|
271
|
+
printf("F\taiMesh\tnormals\t%zu\n", offsetof(struct aiMesh, mNormals));
|
|
272
|
+
printf("F\taiMesh\ttangents\t%zu\n", offsetof(struct aiMesh, mTangents));
|
|
273
|
+
printf("F\taiMesh\tbitangents\t%zu\n", offsetof(struct aiMesh, mBitangents));
|
|
274
|
+
printf("F\taiMesh\tcolors\t%zu\n", offsetof(struct aiMesh, mColors));
|
|
275
|
+
printf("F\taiMesh\ttexture_coords\t%zu\n", offsetof(struct aiMesh, mTextureCoords));
|
|
276
|
+
printf("F\taiMesh\tnum_uv_components\t%zu\n", offsetof(struct aiMesh, mNumUVComponents));
|
|
277
|
+
printf("F\taiMesh\tfaces\t%zu\n", offsetof(struct aiMesh, mFaces));
|
|
278
|
+
printf("F\taiMesh\tnum_bones\t%zu\n", offsetof(struct aiMesh, mNumBones));
|
|
279
|
+
printf("F\taiMesh\tbones\t%zu\n", offsetof(struct aiMesh, mBones));
|
|
280
|
+
printf("F\taiMesh\tmaterial_index\t%zu\n", offsetof(struct aiMesh, mMaterialIndex));
|
|
281
|
+
printf("F\taiMesh\tname\t%zu\n", offsetof(struct aiMesh, mName));
|
|
282
|
+
printf("F\taiMesh\tnum_anim_meshes\t%zu\n", offsetof(struct aiMesh, mNumAnimMeshes));
|
|
283
|
+
printf("F\taiMesh\tanim_meshes\t%zu\n", offsetof(struct aiMesh, mAnimMeshes));
|
|
284
|
+
printf("F\taiMesh\tmethod\t%zu\n", offsetof(struct aiMesh, mMethod));
|
|
285
|
+
printf("F\taiMesh\taabb\t%zu\n", offsetof(struct aiMesh, mAABB));
|
|
286
|
+
printf("F\taiMesh\ttexture_coords_names\t%zu\n", offsetof(struct aiMesh, mTextureCoordsNames));
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../lib/assimp/native/generated"
|
|
4
|
+
|
|
5
|
+
probe = ARGV.fetch(0)
|
|
6
|
+
actual_sizes = {}
|
|
7
|
+
actual_offsets = Hash.new { |hash, key| hash[key] = {} }
|
|
8
|
+
|
|
9
|
+
IO.foreach(probe) do |line|
|
|
10
|
+
kind, struct_name, field_name, value = line.chomp.split("\t")
|
|
11
|
+
if kind == "S"
|
|
12
|
+
actual_sizes[struct_name] = Integer(field_name)
|
|
13
|
+
else
|
|
14
|
+
actual_offsets[struct_name][field_name.to_sym] = Integer(value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
failures = Assimp::Native::HEADER_LAYOUTS.filter_map do |name, (expected_size, expected_offsets)|
|
|
19
|
+
klass_name = name == "aiString" ? "StringValue" : name.delete_prefix("ai")
|
|
20
|
+
klass = Assimp::Native.const_get(klass_name)
|
|
21
|
+
ffi_offsets = expected_offsets.to_h { |field, _offset| [field, klass.offset_of(field)] }
|
|
22
|
+
next if actual_sizes[name] == expected_size &&
|
|
23
|
+
klass.size == expected_size &&
|
|
24
|
+
actual_offsets[name] == expected_offsets &&
|
|
25
|
+
ffi_offsets == expected_offsets
|
|
26
|
+
|
|
27
|
+
"#{name}: C=#{[actual_sizes[name], actual_offsets[name]].inspect} " \
|
|
28
|
+
"Clang=#{[expected_size, expected_offsets].inspect} " \
|
|
29
|
+
"FFI=#{[klass.size, ffi_offsets].inspect}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
abort "FFI layout mismatch:\n#{failures.join("\n")}" unless failures.empty?
|
|
33
|
+
puts "Verified #{Assimp::Native::HEADER_LAYOUTS.length} FFI struct layouts"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
Channel = Data.define(:node_name, :position_keys, :rotation_keys, :scaling_keys)
|
|
5
|
+
|
|
6
|
+
class Animation
|
|
7
|
+
DEFAULT_TICKS_PER_SECOND = 25.0
|
|
8
|
+
|
|
9
|
+
attr_reader :name, :duration_ticks, :ticks_per_second, :channels
|
|
10
|
+
|
|
11
|
+
def initialize(name:, duration_ticks:, ticks_per_second:, channels:)
|
|
12
|
+
@name = String(name).dup.freeze
|
|
13
|
+
@duration_ticks = Float(duration_ticks)
|
|
14
|
+
@ticks_per_second = Float(ticks_per_second)
|
|
15
|
+
@channels = channels.freeze
|
|
16
|
+
freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def effective_ticks_per_second
|
|
20
|
+
ticks_per_second.positive? ? ticks_per_second : DEFAULT_TICKS_PER_SECOND
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def duration_seconds
|
|
24
|
+
duration_ticks / effective_ticks_per_second
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
class AnimationCopier
|
|
5
|
+
def initialize(native: Native)
|
|
6
|
+
current_keys = native.version[1] >= 4
|
|
7
|
+
@vector_key_type = current_keys ? Native::VectorKey : Native::LegacyVectorKey
|
|
8
|
+
@quaternion_key_type = current_keys ? Native::QuatKey : Native::LegacyQuatKey
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def copy(pointer)
|
|
12
|
+
source = Native::Animation.new(pointer)
|
|
13
|
+
channels = NativeReader.pointers(source[:channels], source[:num_channels]).map do |channel_pointer|
|
|
14
|
+
copy_channel(channel_pointer)
|
|
15
|
+
end.freeze
|
|
16
|
+
Animation.new(
|
|
17
|
+
name: source[:name].to_s,
|
|
18
|
+
duration_ticks: source[:duration],
|
|
19
|
+
ticks_per_second: source[:ticks_per_second],
|
|
20
|
+
channels:
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def copy_channel(pointer)
|
|
27
|
+
source = Native::NodeAnim.new(pointer)
|
|
28
|
+
Channel.new(
|
|
29
|
+
node_name: source[:node_name].to_s.freeze,
|
|
30
|
+
position_keys: vector_keys(source[:position_keys], source[:num_position_keys]),
|
|
31
|
+
rotation_keys: quaternion_keys(source[:rotation_keys], source[:num_rotation_keys]),
|
|
32
|
+
scaling_keys: vector_keys(source[:scaling_keys], source[:num_scaling_keys])
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def vector_keys(pointer, count)
|
|
37
|
+
count.times.map do |index|
|
|
38
|
+
key = NativeReader.struct_at(pointer, @vector_key_type, index)
|
|
39
|
+
[key[:time], Vec3.new(*key[:value].to_a)].freeze
|
|
40
|
+
end.freeze
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def quaternion_keys(pointer, count)
|
|
44
|
+
count.times.map do |index|
|
|
45
|
+
key = NativeReader.struct_at(pointer, @quaternion_key_type, index)
|
|
46
|
+
[key[:time], Quat.new(*key[:value].to_a)].freeze
|
|
47
|
+
end.freeze
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
class EmbeddedTexture
|
|
5
|
+
attr_reader :width, :height, :format_hint, :filename, :bytes
|
|
6
|
+
|
|
7
|
+
def initialize(width:, height:, format_hint:, filename:, bytes:)
|
|
8
|
+
@width = Integer(width)
|
|
9
|
+
@height = Integer(height)
|
|
10
|
+
@format_hint = String(format_hint).dup.freeze
|
|
11
|
+
@filename = String(filename).dup.freeze
|
|
12
|
+
@bytes = String(bytes).dup.force_encoding(Encoding::BINARY).freeze
|
|
13
|
+
expected = compressed? ? @width : @width * @height * 4
|
|
14
|
+
raise ArgumentError, "texture has #{@bytes.bytesize} bytes, expected #{expected}" unless @bytes.bytesize == expected
|
|
15
|
+
|
|
16
|
+
freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def compressed?
|
|
20
|
+
height.zero?
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
class ImportSource
|
|
5
|
+
MAX_MEMORY_SIZE = (2**32) - 1
|
|
6
|
+
|
|
7
|
+
attr_reader :path, :bytes, :hint
|
|
8
|
+
|
|
9
|
+
def initialize(source, hint:)
|
|
10
|
+
@hint = normalize_hint(hint)
|
|
11
|
+
if path_source?(source)
|
|
12
|
+
@path = source.respond_to?(:to_path) ? source.to_path : source
|
|
13
|
+
else
|
|
14
|
+
@bytes = read_bytes(source)
|
|
15
|
+
raise ArgumentError, "hint is required for memory imports" unless @hint
|
|
16
|
+
raise ArgumentError, "memory source cannot be empty" if @bytes.empty?
|
|
17
|
+
raise ArgumentError, "memory import exceeds Assimp's 32-bit size limit" if @bytes.bytesize > MAX_MEMORY_SIZE
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def path?
|
|
22
|
+
!path.nil?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def path_source?(source)
|
|
28
|
+
return true if source.respond_to?(:to_path)
|
|
29
|
+
return false unless source.is_a?(String)
|
|
30
|
+
return false if source.include?("\0")
|
|
31
|
+
return true if File.file?(source)
|
|
32
|
+
|
|
33
|
+
hint.nil?
|
|
34
|
+
rescue SystemCallError
|
|
35
|
+
hint.nil?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def read_bytes(source)
|
|
39
|
+
value = source.respond_to?(:read) ? source.read : source
|
|
40
|
+
raise ArgumentError, "memory source must be a String or respond to #read" unless value.is_a?(String)
|
|
41
|
+
|
|
42
|
+
value.dup.force_encoding(Encoding::BINARY).freeze
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def normalize_hint(value)
|
|
46
|
+
return nil if value.nil?
|
|
47
|
+
|
|
48
|
+
normalized = value.to_s.delete_prefix(".").downcase
|
|
49
|
+
raise ArgumentError, "hint cannot be empty" if normalized.empty?
|
|
50
|
+
|
|
51
|
+
normalized.freeze
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
class Importer
|
|
5
|
+
def initialize(native: Native)
|
|
6
|
+
@native = native
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def import(source, process: :realtime, hint: nil)
|
|
10
|
+
with_native_scene(source, process:, hint:) { |pointer| SceneCopier.new(native: @native).copy(pointer) }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def open(source, process: :realtime, hint: nil)
|
|
14
|
+
raise ArgumentError, "Assimp.open requires a block" unless block_given?
|
|
15
|
+
|
|
16
|
+
raw = nil
|
|
17
|
+
with_native_scene(source, process:, hint:) do |pointer|
|
|
18
|
+
raw = RawScene.new(pointer)
|
|
19
|
+
yield raw
|
|
20
|
+
ensure
|
|
21
|
+
raw&.invalidate!
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def with_native_scene(source, process:, hint:)
|
|
28
|
+
input = ImportSource.new(source, hint:)
|
|
29
|
+
flags = PostProcess.flags(process)
|
|
30
|
+
@native.load!
|
|
31
|
+
pointer, input_memory = acquire(input, flags)
|
|
32
|
+
begin
|
|
33
|
+
if pointer.null?
|
|
34
|
+
message = @native.aiGetErrorString
|
|
35
|
+
raise ImportError, message.nil? || message.empty? ? "Assimp import failed" : message
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
yield pointer
|
|
39
|
+
ensure
|
|
40
|
+
@native.aiReleaseImport(pointer) unless pointer.null?
|
|
41
|
+
input_memory&.free
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def acquire(input, flags)
|
|
46
|
+
return [@native.aiImportFile(input.path, flags), nil] if input.path?
|
|
47
|
+
|
|
48
|
+
memory = FFI::MemoryPointer.new(:char, input.bytes.bytesize)
|
|
49
|
+
memory.autorelease = false
|
|
50
|
+
memory.put_bytes(0, input.bytes)
|
|
51
|
+
[@native.aiImportFileFromMemory(memory, input.bytes.bytesize, flags, input.hint), memory]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Assimp
|
|
4
|
+
TextureRef = Data.define(:path, :embedded_index, :uv_index, :wrap)
|
|
5
|
+
|
|
6
|
+
class Material
|
|
7
|
+
attr_reader :name, :base_color, :metallic, :roughness, :shininess, :opacity
|
|
8
|
+
|
|
9
|
+
def initialize(name:, base_color:, metallic:, roughness:, shininess:, opacity:, two_sided:,
|
|
10
|
+
textures:, properties:)
|
|
11
|
+
@name = String(name).dup.freeze
|
|
12
|
+
@base_color = base_color&.map { |value| Float(value) }&.freeze
|
|
13
|
+
@metallic = metallic.nil? ? nil : Float(metallic)
|
|
14
|
+
@roughness = roughness.nil? ? nil : Float(roughness)
|
|
15
|
+
@shininess = shininess.nil? ? nil : Float(shininess)
|
|
16
|
+
@opacity = opacity.nil? ? nil : Float(opacity)
|
|
17
|
+
@two_sided = !!two_sided
|
|
18
|
+
@textures = textures.freeze
|
|
19
|
+
@properties = properties.freeze
|
|
20
|
+
freeze
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def two_sided?
|
|
24
|
+
@two_sided
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def texture(type, index: 0)
|
|
28
|
+
kind = type.to_sym
|
|
29
|
+
texture_index = Integer(index)
|
|
30
|
+
direct = @textures[[kind, texture_index]]
|
|
31
|
+
return direct if direct
|
|
32
|
+
|
|
33
|
+
fallback_types(kind).each do |fallback|
|
|
34
|
+
reference = @textures[[fallback, texture_index]]
|
|
35
|
+
return reference if reference
|
|
36
|
+
end
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def textures(type = nil)
|
|
41
|
+
return @textures.dup.freeze unless type
|
|
42
|
+
|
|
43
|
+
kind = type.to_sym
|
|
44
|
+
@textures.each_with_object([]) do |((texture_type, _index), texture), matches|
|
|
45
|
+
matches << texture if texture_type == kind
|
|
46
|
+
end.freeze
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def [](key, semantic: 0, index: 0)
|
|
50
|
+
@properties[[String(key), Integer(semantic), Integer(index)]]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def properties
|
|
54
|
+
@properties.dup.freeze
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def fallback_types(type)
|
|
60
|
+
case type
|
|
61
|
+
when :diffuse then [:base_color]
|
|
62
|
+
when :base_color then [:diffuse]
|
|
63
|
+
when :emissive then [:emission_color]
|
|
64
|
+
when :emission_color then [:emissive]
|
|
65
|
+
when :normal then %i[normals normal_camera]
|
|
66
|
+
when :normals then [:normal_camera]
|
|
67
|
+
when :metallic then [:metalness]
|
|
68
|
+
when :ambient_occlusion then %i[ao lightmap]
|
|
69
|
+
else []
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|