structs.py 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. #-*- coding: UTF-8 -*-
  2. from ctypes import POINTER, c_void_p, c_int, c_uint, c_char, c_float, Structure, c_char_p, c_double, c_ubyte, c_size_t, c_uint32
  3. class Vector2D(Structure):
  4. """
  5. See 'aiVector2D.h' for details.
  6. """
  7. _fields_ = [
  8. ("x", c_float),("y", c_float),
  9. ]
  10. class Matrix3x3(Structure):
  11. """
  12. See 'aiMatrix3x3.h' for details.
  13. """
  14. _fields_ = [
  15. ("a1", c_float),("a2", c_float),("a3", c_float),
  16. ("b1", c_float),("b2", c_float),("b3", c_float),
  17. ("c1", c_float),("c2", c_float),("c3", c_float),
  18. ]
  19. class Texel(Structure):
  20. """
  21. See 'aiTexture.h' for details.
  22. """
  23. _fields_ = [
  24. ("b", c_ubyte),("g", c_ubyte),("r", c_ubyte),("a", c_ubyte),
  25. ]
  26. class Color4D(Structure):
  27. """
  28. See 'aiColor4D.h' for details.
  29. """
  30. _fields_ = [
  31. # Red, green, blue and alpha color values
  32. ("r", c_float),("g", c_float),("b", c_float),("a", c_float),
  33. ]
  34. class Plane(Structure):
  35. """
  36. See 'aiTypes.h' for details.
  37. """
  38. _fields_ = [
  39. # Plane equation
  40. ("a", c_float),("b", c_float),("c", c_float),("d", c_float),
  41. ]
  42. class Color3D(Structure):
  43. """
  44. See 'aiTypes.h' for details.
  45. """
  46. _fields_ = [
  47. # Red, green and blue color values
  48. ("r", c_float),("g", c_float),("b", c_float),
  49. ]
  50. class String(Structure):
  51. """
  52. See 'aiTypes.h' for details.
  53. """
  54. MAXLEN = 1024
  55. _fields_ = [
  56. # Binary length of the string excluding the terminal 0. This is NOT the
  57. # logical length of strings containing UTF-8 multibyte sequences! It's
  58. # the number of bytes from the beginning of the string to its end.
  59. ("length", c_size_t),
  60. # String buffer. Size limit is MAXLEN
  61. ("data", c_char*MAXLEN),
  62. ]
  63. class MaterialPropertyString(Structure):
  64. """
  65. See 'aiTypes.h' for details.
  66. The size of length is truncated to 4 bytes on 64-bit platforms when used as a
  67. material property (see MaterialSystem.cpp aiMaterial::AddProperty() for details).
  68. """
  69. MAXLEN = 1024
  70. _fields_ = [
  71. # Binary length of the string excluding the terminal 0. This is NOT the
  72. # logical length of strings containing UTF-8 multibyte sequences! It's
  73. # the number of bytes from the beginning of the string to its end.
  74. ("length", c_uint32),
  75. # String buffer. Size limit is MAXLEN
  76. ("data", c_char*MAXLEN),
  77. ]
  78. class MemoryInfo(Structure):
  79. """
  80. See 'aiTypes.h' for details.
  81. """
  82. _fields_ = [
  83. # Storage allocated for texture data
  84. ("textures", c_uint),
  85. # Storage allocated for material data
  86. ("materials", c_uint),
  87. # Storage allocated for mesh data
  88. ("meshes", c_uint),
  89. # Storage allocated for node data
  90. ("nodes", c_uint),
  91. # Storage allocated for animation data
  92. ("animations", c_uint),
  93. # Storage allocated for camera data
  94. ("cameras", c_uint),
  95. # Storage allocated for light data
  96. ("lights", c_uint),
  97. # Total storage allocated for the full import.
  98. ("total", c_uint),
  99. ]
  100. class Quaternion(Structure):
  101. """
  102. See 'aiQuaternion.h' for details.
  103. """
  104. _fields_ = [
  105. # w,x,y,z components of the quaternion
  106. ("w", c_float),("x", c_float),("y", c_float),("z", c_float),
  107. ]
  108. class Face(Structure):
  109. """
  110. See 'aiMesh.h' for details.
  111. """
  112. _fields_ = [
  113. # Number of indices defining this face.
  114. # The maximum value for this member is
  115. #AI_MAX_FACE_INDICES.
  116. ("mNumIndices", c_uint),
  117. # Pointer to the indices array. Size of the array is given in numIndices.
  118. ("mIndices", POINTER(c_uint)),
  119. ]
  120. class VertexWeight(Structure):
  121. """
  122. See 'aiMesh.h' for details.
  123. """
  124. _fields_ = [
  125. # Index of the vertex which is influenced by the bone.
  126. ("mVertexId", c_uint),
  127. # The strength of the influence in the range (0...1).
  128. # The influence from all bones at one vertex amounts to 1.
  129. ("mWeight", c_float),
  130. ]
  131. class Matrix4x4(Structure):
  132. """
  133. See 'aiMatrix4x4.h' for details.
  134. """
  135. _fields_ = [
  136. ("a1", c_float),("a2", c_float),("a3", c_float),("a4", c_float),
  137. ("b1", c_float),("b2", c_float),("b3", c_float),("b4", c_float),
  138. ("c1", c_float),("c2", c_float),("c3", c_float),("c4", c_float),
  139. ("d1", c_float),("d2", c_float),("d3", c_float),("d4", c_float),
  140. ]
  141. class Vector3D(Structure):
  142. """
  143. See 'aiVector3D.h' for details.
  144. """
  145. _fields_ = [
  146. ("x", c_float),("y", c_float),("z", c_float),
  147. ]
  148. class MeshKey(Structure):
  149. """
  150. See 'aiAnim.h' for details.
  151. """
  152. _fields_ = [
  153. # The time of this key
  154. ("mTime", c_double),
  155. # Index into the aiMesh::mAnimMeshes array of the
  156. # mesh corresponding to the
  157. #aiMeshAnim hosting this
  158. # key frame. The referenced anim mesh is evaluated
  159. # according to the rules defined in the docs for
  160. #aiAnimMesh.
  161. ("mValue", c_uint),
  162. ]
  163. class MetadataEntry(Structure):
  164. """
  165. See 'metadata.h' for details
  166. """
  167. AI_BOOL = 0
  168. AI_INT32 = 1
  169. AI_UINT64 = 2
  170. AI_FLOAT = 3
  171. AI_DOUBLE = 4
  172. AI_AISTRING = 5
  173. AI_AIVECTOR3D = 6
  174. AI_META_MAX = 7
  175. _fields_ = [
  176. # The type field uniquely identifies the underlying type of the data field
  177. ("mType", c_uint),
  178. ("mData", c_void_p),
  179. ]
  180. class Metadata(Structure):
  181. """
  182. See 'metadata.h' for details
  183. """
  184. _fields_ = [
  185. # Length of the mKeys and mValues arrays, respectively
  186. ("mNumProperties", c_uint),
  187. # Arrays of keys, may not be NULL. Entries in this array may not be NULL
  188. # as well.
  189. ("mKeys", POINTER(String)),
  190. # Arrays of values, may not be NULL. Entries in this array may be NULL
  191. # if the corresponding property key has no assigned value.
  192. ("mValues", POINTER(MetadataEntry)),
  193. ]
  194. class Node(Structure):
  195. """
  196. See 'aiScene.h' for details.
  197. """
  198. Node._fields_ = [
  199. # The name of the node.
  200. # The name might be empty (length of zero) but all nodes which
  201. # need to be accessed afterwards by bones or anims are usually named.
  202. # Multiple nodes may have the same name, but nodes which are accessed
  203. # by bones (see
  204. #aiBone and
  205. #aiMesh::mBones) *must* be unique.
  206. # Cameras and lights are assigned to a specific node name - if there
  207. # are multiple nodes with this name, they're assigned to each of them.
  208. # <br>
  209. # There are no limitations regarding the characters contained in
  210. # this text. You should be able to handle stuff like whitespace, tabs,
  211. # linefeeds, quotation marks, ampersands, ... .
  212. ("mName", String),
  213. # The transformation relative to the node's parent.
  214. ("mTransformation", Matrix4x4),
  215. # Parent node. NULL if this node is the root node.
  216. ("mParent", POINTER(Node)),
  217. # The number of child nodes of this node.
  218. ("mNumChildren", c_uint),
  219. # The child nodes of this node. NULL if mNumChildren is 0.
  220. ("mChildren", POINTER(POINTER(Node))),
  221. # The number of meshes of this node.
  222. ("mNumMeshes", c_uint),
  223. # The meshes of this node. Each entry is an index into the mesh
  224. ("mMeshes", POINTER(c_uint)),
  225. # Metadata associated with this node or NULL if there is no metadata.
  226. # Whether any metadata is generated depends on the source file format.
  227. ("mMetadata", POINTER(POINTER(Metadata))),
  228. ]
  229. class Light(Structure):
  230. """
  231. See 'aiLight.h' for details.
  232. """
  233. _fields_ = [
  234. # The name of the light source.
  235. # There must be a node in the scenegraph with the same name.
  236. # This node specifies the position of the light in the scene
  237. # hierarchy and can be animated.
  238. ("mName", String),
  239. # The type of the light source.
  240. # aiLightSource_UNDEFINED is not a valid value for this member.
  241. ("mType", c_uint),
  242. # Position of the light source in space. Relative to the
  243. # transformation of the node corresponding to the light.
  244. # The position is undefined for directional lights.
  245. ("mPosition", Vector3D),
  246. # Direction of the light source in space. Relative to the
  247. # transformation of the node corresponding to the light.
  248. # The direction is undefined for point lights. The vector
  249. # may be normalized, but it needn't.
  250. ("mDirection", Vector3D),
  251. # Constant light attenuation factor.
  252. # The intensity of the light source at a given distance 'd' from
  253. # the light's position is
  254. # @code
  255. # Atten = 1/( att0 + att1
  256. # d + att2
  257. # d*d)
  258. # @endcode
  259. # This member corresponds to the att0 variable in the equation.
  260. # Naturally undefined for directional lights.
  261. ("mAttenuationConstant", c_float),
  262. # Linear light attenuation factor.
  263. # The intensity of the light source at a given distance 'd' from
  264. # the light's position is
  265. # @code
  266. # Atten = 1/( att0 + att1
  267. # d + att2
  268. # d*d)
  269. # @endcode
  270. # This member corresponds to the att1 variable in the equation.
  271. # Naturally undefined for directional lights.
  272. ("mAttenuationLinear", c_float),
  273. # Quadratic light attenuation factor.
  274. # The intensity of the light source at a given distance 'd' from
  275. # the light's position is
  276. # @code
  277. # Atten = 1/( att0 + att1
  278. # d + att2
  279. # d*d)
  280. # @endcode
  281. # This member corresponds to the att2 variable in the equation.
  282. # Naturally undefined for directional lights.
  283. ("mAttenuationQuadratic", c_float),
  284. # Diffuse color of the light source
  285. # The diffuse light color is multiplied with the diffuse
  286. # material color to obtain the final color that contributes
  287. # to the diffuse shading term.
  288. ("mColorDiffuse", Color3D),
  289. # Specular color of the light source
  290. # The specular light color is multiplied with the specular
  291. # material color to obtain the final color that contributes
  292. # to the specular shading term.
  293. ("mColorSpecular", Color3D),
  294. # Ambient color of the light source
  295. # The ambient light color is multiplied with the ambient
  296. # material color to obtain the final color that contributes
  297. # to the ambient shading term. Most renderers will ignore
  298. # this value it, is just a remaining of the fixed-function pipeline
  299. # that is still supported by quite many file formats.
  300. ("mColorAmbient", Color3D),
  301. # Inner angle of a spot light's light cone.
  302. # The spot light has maximum influence on objects inside this
  303. # angle. The angle is given in radians. It is 2PI for point
  304. # lights and undefined for directional lights.
  305. ("mAngleInnerCone", c_float),
  306. # Outer angle of a spot light's light cone.
  307. # The spot light does not affect objects outside this angle.
  308. # The angle is given in radians. It is 2PI for point lights and
  309. # undefined for directional lights. The outer angle must be
  310. # greater than or equal to the inner angle.
  311. # It is assumed that the application uses a smooth
  312. # interpolation between the inner and the outer cone of the
  313. # spot light.
  314. ("mAngleOuterCone", c_float),
  315. ]
  316. class Texture(Structure):
  317. """
  318. See 'aiTexture.h' for details.
  319. """
  320. _fields_ = [
  321. # Width of the texture, in pixels
  322. # If mHeight is zero the texture is compressed in a format
  323. # like JPEG. In this case mWidth specifies the size of the
  324. # memory area pcData is pointing to, in bytes.
  325. ("mWidth", c_uint),
  326. # Height of the texture, in pixels
  327. # If this value is zero, pcData points to an compressed texture
  328. # in any format (e.g. JPEG).
  329. ("mHeight", c_uint),
  330. # A hint from the loader to make it easier for applications
  331. # to determine the type of embedded compressed textures.
  332. # If mHeight != 0 this member is undefined. Otherwise it
  333. # is set set to '\\0\\0\\0\\0' if the loader has no additional
  334. # information about the texture file format used OR the
  335. # file extension of the format without a trailing dot. If there
  336. # are multiple file extensions for a format, the shortest
  337. # extension is chosen (JPEG maps to 'jpg', not to 'jpeg').
  338. # E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case.
  339. # The fourth character will always be '\\0'.
  340. ("achFormatHint", c_char*4),
  341. # Data of the texture.
  342. # Points to an array of mWidth
  343. # mHeight aiTexel's.
  344. # The format of the texture data is always ARGB8888 to
  345. # make the implementation for user of the library as easy
  346. # as possible. If mHeight = 0 this is a pointer to a memory
  347. # buffer of size mWidth containing the compressed texture
  348. # data. Good luck, have fun!
  349. ("pcData", POINTER(Texel)),
  350. ]
  351. class Ray(Structure):
  352. """
  353. See 'aiTypes.h' for details.
  354. """
  355. _fields_ = [
  356. # Position and direction of the ray
  357. ("pos", Vector3D),("dir", Vector3D),
  358. ]
  359. class UVTransform(Structure):
  360. """
  361. See 'aiMaterial.h' for details.
  362. """
  363. _fields_ = [
  364. # Translation on the u and v axes.
  365. # The default value is (0|0).
  366. ("mTranslation", Vector2D),
  367. # Scaling on the u and v axes.
  368. # The default value is (1|1).
  369. ("mScaling", Vector2D),
  370. # Rotation - in counter-clockwise direction.
  371. # The rotation angle is specified in radians. The
  372. # rotation center is 0.5f|0.5f. The default value
  373. # 0.f.
  374. ("mRotation", c_float),
  375. ]
  376. class MaterialProperty(Structure):
  377. """
  378. See 'aiMaterial.h' for details.
  379. """
  380. _fields_ = [
  381. # Specifies the name of the property (key)
  382. # Keys are generally case insensitive.
  383. ("mKey", String),
  384. # Textures: Specifies their exact usage semantic.
  385. # For non-texture properties, this member is always 0
  386. # (or, better-said,
  387. #aiTextureType_NONE).
  388. ("mSemantic", c_uint),
  389. # Textures: Specifies the index of the texture.
  390. # For non-texture properties, this member is always 0.
  391. ("mIndex", c_uint),
  392. # Size of the buffer mData is pointing to, in bytes.
  393. # This value may not be 0.
  394. ("mDataLength", c_uint),
  395. # Type information for the property.
  396. # Defines the data layout inside the data buffer. This is used
  397. # by the library internally to perform debug checks and to
  398. # utilize proper type conversions.
  399. # (It's probably a hacky solution, but it works.)
  400. ("mType", c_uint),
  401. # Binary buffer to hold the property's value.
  402. # The size of the buffer is always mDataLength.
  403. ("mData", POINTER(c_char)),
  404. ]
  405. class Material(Structure):
  406. """
  407. See 'aiMaterial.h' for details.
  408. """
  409. _fields_ = [
  410. # List of all material properties loaded.
  411. ("mProperties", POINTER(POINTER(MaterialProperty))),
  412. # Number of properties in the data base
  413. ("mNumProperties", c_uint),
  414. # Storage allocated
  415. ("mNumAllocated", c_uint),
  416. ]
  417. class Bone(Structure):
  418. """
  419. See 'aiMesh.h' for details.
  420. """
  421. _fields_ = [
  422. # The name of the bone.
  423. ("mName", String),
  424. # The number of vertices affected by this bone
  425. # The maximum value for this member is
  426. #AI_MAX_BONE_WEIGHTS.
  427. ("mNumWeights", c_uint),
  428. # The vertices affected by this bone
  429. ("mWeights", POINTER(VertexWeight)),
  430. # Matrix that transforms from mesh space to bone space in bind pose
  431. ("mOffsetMatrix", Matrix4x4),
  432. ]
  433. class Mesh(Structure):
  434. """
  435. See 'aiMesh.h' for details.
  436. """
  437. AI_MAX_FACE_INDICES = 0x7fff
  438. AI_MAX_BONE_WEIGHTS = 0x7fffffff
  439. AI_MAX_VERTICES = 0x7fffffff
  440. AI_MAX_FACES = 0x7fffffff
  441. AI_MAX_NUMBER_OF_COLOR_SETS = 0x8
  442. AI_MAX_NUMBER_OF_TEXTURECOORDS = 0x8
  443. _fields_ = [
  444. # Bitwise combination of the members of the
  445. #aiPrimitiveType enum.
  446. # This specifies which types of primitives are present in the mesh.
  447. # The "SortByPrimitiveType"-Step can be used to make sure the
  448. # output meshes consist of one primitive type each.
  449. ("mPrimitiveTypes", c_uint),
  450. # The number of vertices in this mesh.
  451. # This is also the size of all of the per-vertex data arrays.
  452. # The maximum value for this member is
  453. #AI_MAX_VERTICES.
  454. ("mNumVertices", c_uint),
  455. # The number of primitives (triangles, polygons, lines) in this mesh.
  456. # This is also the size of the mFaces array.
  457. # The maximum value for this member is
  458. #AI_MAX_FACES.
  459. ("mNumFaces", c_uint),
  460. # Vertex positions.
  461. # This array is always present in a mesh. The array is
  462. # mNumVertices in size.
  463. ("mVertices", POINTER(Vector3D)),
  464. # Vertex normals.
  465. # The array contains normalized vectors, NULL if not present.
  466. # The array is mNumVertices in size. Normals are undefined for
  467. # point and line primitives. A mesh consisting of points and
  468. # lines only may not have normal vectors. Meshes with mixed
  469. # primitive types (i.e. lines and triangles) may have normals,
  470. # but the normals for vertices that are only referenced by
  471. # point or line primitives are undefined and set to QNaN (WARN:
  472. # qNaN compares to inequal to *everything*, even to qNaN itself.
  473. # Using code like this to check whether a field is qnan is:
  474. # @code
  475. #define IS_QNAN(f) (f != f)
  476. # @endcode
  477. # still dangerous because even 1.f == 1.f could evaluate to false! (
  478. # remember the subtleties of IEEE754 artithmetics). Use stuff like
  479. # @c fpclassify instead.
  480. # @note Normal vectors computed by Assimp are always unit-length.
  481. # However, this needn't apply for normals that have been taken
  482. # directly from the model file.
  483. ("mNormals", POINTER(Vector3D)),
  484. # Vertex tangents.
  485. # The tangent of a vertex points in the direction of the positive
  486. # X texture axis. The array contains normalized vectors, NULL if
  487. # not present. The array is mNumVertices in size. A mesh consisting
  488. # of points and lines only may not have normal vectors. Meshes with
  489. # mixed primitive types (i.e. lines and triangles) may have
  490. # normals, but the normals for vertices that are only referenced by
  491. # point or line primitives are undefined and set to qNaN. See
  492. # the
  493. #mNormals member for a detailed discussion of qNaNs.
  494. # @note If the mesh contains tangents, it automatically also
  495. # contains bitangents (the bitangent is just the cross product of
  496. # tangent and normal vectors).
  497. ("mTangents", POINTER(Vector3D)),
  498. # Vertex bitangents.
  499. # The bitangent of a vertex points in the direction of the positive
  500. # Y texture axis. The array contains normalized vectors, NULL if not
  501. # present. The array is mNumVertices in size.
  502. # @note If the mesh contains tangents, it automatically also contains
  503. # bitangents.
  504. ("mBitangents", POINTER(Vector3D)),
  505. # Vertex color sets.
  506. # A mesh may contain 0 to
  507. #AI_MAX_NUMBER_OF_COLOR_SETS vertex
  508. # colors per vertex. NULL if not present. Each array is
  509. # mNumVertices in size if present.
  510. ("mColors", POINTER(Color4D)*AI_MAX_NUMBER_OF_COLOR_SETS),
  511. # Vertex texture coords, also known as UV channels.
  512. # A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
  513. # vertex. NULL if not present. The array is mNumVertices in size.
  514. ("mTextureCoords", POINTER(Vector3D)*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  515. # Specifies the number of components for a given UV channel.
  516. # Up to three channels are supported (UVW, for accessing volume
  517. # or cube maps). If the value is 2 for a given channel n, the
  518. # component p.z of mTextureCoords[n][p] is set to 0.0f.
  519. # If the value is 1 for a given channel, p.y is set to 0.0f, too.
  520. # @note 4D coords are not supported
  521. ("mNumUVComponents", c_uint*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  522. # The faces the mesh is constructed from.
  523. # Each face refers to a number of vertices by their indices.
  524. # This array is always present in a mesh, its size is given
  525. # in mNumFaces. If the
  526. #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
  527. # is NOT set each face references an unique set of vertices.
  528. ("mFaces", POINTER(Face)),
  529. # The number of bones this mesh contains.
  530. # Can be 0, in which case the mBones array is NULL.
  531. ("mNumBones", c_uint),
  532. # The bones of this mesh.
  533. # A bone consists of a name by which it can be found in the
  534. # frame hierarchy and a set of vertex weights.
  535. ("mBones", POINTER(POINTER(Bone))),
  536. # The material used by this mesh.
  537. # A mesh does use only a single material. If an imported model uses
  538. # multiple materials, the import splits up the mesh. Use this value
  539. # as index into the scene's material list.
  540. ("mMaterialIndex", c_uint),
  541. # Name of the mesh. Meshes can be named, but this is not a
  542. # requirement and leaving this field empty is totally fine.
  543. # There are mainly three uses for mesh names:
  544. # - some formats name nodes and meshes independently.
  545. # - importers tend to split meshes up to meet the
  546. # one-material-per-mesh requirement. Assigning
  547. # the same (dummy) name to each of the result meshes
  548. # aids the caller at recovering the original mesh
  549. # partitioning.
  550. # - Vertex animations refer to meshes by their names.
  551. ("mName", String),
  552. # NOT CURRENTLY IN USE. The number of attachment meshes
  553. ("mNumAnimMeshes", c_uint),
  554. # NOT CURRENTLY IN USE. Attachment meshes for this mesh, for vertex-based animation.
  555. # Attachment meshes carry replacement data for some of the
  556. # mesh'es vertex components (usually positions, normals).
  557. ]
  558. class Camera(Structure):
  559. """
  560. See 'aiCamera.h' for details.
  561. """
  562. _fields_ = [
  563. # The name of the camera.
  564. # There must be a node in the scenegraph with the same name.
  565. # This node specifies the position of the camera in the scene
  566. # hierarchy and can be animated.
  567. ("mName", String),
  568. # Position of the camera relative to the coordinate space
  569. # defined by the corresponding node.
  570. # The default value is 0|0|0.
  571. ("mPosition", Vector3D),
  572. # 'Up' - vector of the camera coordinate system relative to
  573. # the coordinate space defined by the corresponding node.
  574. # The 'right' vector of the camera coordinate system is
  575. # the cross product of the up and lookAt vectors.
  576. # The default value is 0|1|0. The vector
  577. # may be normalized, but it needn't.
  578. ("mUp", Vector3D),
  579. # 'LookAt' - vector of the camera coordinate system relative to
  580. # the coordinate space defined by the corresponding node.
  581. # This is the viewing direction of the user.
  582. # The default value is 0|0|1. The vector
  583. # may be normalized, but it needn't.
  584. ("mLookAt", Vector3D),
  585. # Half horizontal field of view angle, in radians.
  586. # The field of view angle is the angle between the center
  587. # line of the screen and the left or right border.
  588. # The default value is 1/4PI.
  589. ("mHorizontalFOV", c_float),
  590. # Distance of the near clipping plane from the camera.
  591. # The value may not be 0.f (for arithmetic reasons to prevent
  592. # a division through zero). The default value is 0.1f.
  593. ("mClipPlaneNear", c_float),
  594. # Distance of the far clipping plane from the camera.
  595. # The far clipping plane must, of course, be further away than the
  596. # near clipping plane. The default value is 1000.f. The ratio
  597. # between the near and the far plane should not be too
  598. # large (between 1000-10000 should be ok) to avoid floating-point
  599. # inaccuracies which could lead to z-fighting.
  600. ("mClipPlaneFar", c_float),
  601. # Screen aspect ratio.
  602. # This is the ration between the width and the height of the
  603. # screen. Typical values are 4/3, 1/2 or 1/1. This value is
  604. # 0 if the aspect ratio is not defined in the source file.
  605. # 0 is also the default value.
  606. ("mAspect", c_float),
  607. ]
  608. class VectorKey(Structure):
  609. """
  610. See 'aiAnim.h' for details.
  611. """
  612. _fields_ = [
  613. # The time of this key
  614. ("mTime", c_double),
  615. # The value of this key
  616. ("mValue", Vector3D),
  617. ]
  618. class QuatKey(Structure):
  619. """
  620. See 'aiAnim.h' for details.
  621. """
  622. _fields_ = [
  623. # The time of this key
  624. ("mTime", c_double),
  625. # The value of this key
  626. ("mValue", Quaternion),
  627. ]
  628. class NodeAnim(Structure):
  629. """
  630. See 'aiAnim.h' for details.
  631. """
  632. _fields_ = [
  633. # The name of the node affected by this animation. The node
  634. # must exist and it must be unique.
  635. ("mNodeName", String),
  636. # The number of position keys
  637. ("mNumPositionKeys", c_uint),
  638. # The position keys of this animation channel. Positions are
  639. # specified as 3D vector. The array is mNumPositionKeys in size.
  640. # If there are position keys, there will also be at least one
  641. # scaling and one rotation key.
  642. ("mPositionKeys", POINTER(VectorKey)),
  643. # The number of rotation keys
  644. ("mNumRotationKeys", c_uint),
  645. # The rotation keys of this animation channel. Rotations are
  646. # given as quaternions, which are 4D vectors. The array is
  647. # mNumRotationKeys in size.
  648. # If there are rotation keys, there will also be at least one
  649. # scaling and one position key.
  650. ("mRotationKeys", POINTER(QuatKey)),
  651. # The number of scaling keys
  652. ("mNumScalingKeys", c_uint),
  653. # The scaling keys of this animation channel. Scalings are
  654. # specified as 3D vector. The array is mNumScalingKeys in size.
  655. # If there are scaling keys, there will also be at least one
  656. # position and one rotation key.
  657. ("mScalingKeys", POINTER(VectorKey)),
  658. # Defines how the animation behaves before the first
  659. # key is encountered.
  660. # The default value is aiAnimBehaviour_DEFAULT (the original
  661. # transformation matrix of the affected node is used).
  662. ("mPreState", c_uint),
  663. # Defines how the animation behaves after the last
  664. # key was processed.
  665. # The default value is aiAnimBehaviour_DEFAULT (the original
  666. # transformation matrix of the affected node is taken).
  667. ("mPostState", c_uint),
  668. ]
  669. class Animation(Structure):
  670. """
  671. See 'aiAnim.h' for details.
  672. """
  673. _fields_ = [
  674. # The name of the animation. If the modeling package this data was
  675. # exported from does support only a single animation channel, this
  676. # name is usually empty (length is zero).
  677. ("mName", String),
  678. # Duration of the animation in ticks.
  679. ("mDuration", c_double),
  680. # Ticks per second. 0 if not specified in the imported file
  681. ("mTicksPerSecond", c_double),
  682. # The number of bone animation channels. Each channel affects
  683. # a single node.
  684. ("mNumChannels", c_uint),
  685. # The node animation channels. Each channel affects a single node.
  686. # The array is mNumChannels in size.
  687. ("mChannels", POINTER(POINTER(NodeAnim))),
  688. # The number of mesh animation channels. Each channel affects
  689. # a single mesh and defines vertex-based animation.
  690. ("mNumMeshChannels", c_uint),
  691. # The mesh animation channels. Each channel affects a single mesh.
  692. # The array is mNumMeshChannels in size.
  693. ]
  694. class Scene(Structure):
  695. """
  696. See 'aiScene.h' for details.
  697. """
  698. AI_SCENE_FLAGS_INCOMPLETE = 0x1
  699. AI_SCENE_FLAGS_VALIDATED = 0x2
  700. AI_SCENE_FLAGS_VALIDATION_WARNING = 0x4
  701. AI_SCENE_FLAGS_NON_VERBOSE_FORMAT = 0x8
  702. AI_SCENE_FLAGS_TERRAIN = 0x10
  703. _fields_ = [
  704. # Any combination of the AI_SCENE_FLAGS_XXX flags. By default
  705. # this value is 0, no flags are set. Most applications will
  706. # want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
  707. # bit set.
  708. ("mFlags", c_uint),
  709. # The root node of the hierarchy.
  710. # There will always be at least the root node if the import
  711. # was successful (and no special flags have been set).
  712. # Presence of further nodes depends on the format and content
  713. # of the imported file.
  714. ("mRootNode", POINTER(Node)),
  715. # The number of meshes in the scene.
  716. ("mNumMeshes", c_uint),
  717. # The array of meshes.
  718. # Use the indices given in the aiNode structure to access
  719. # this array. The array is mNumMeshes in size. If the
  720. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  721. # be at least ONE material.
  722. ("mMeshes", POINTER(POINTER(Mesh))),
  723. # The number of materials in the scene.
  724. ("mNumMaterials", c_uint),
  725. # The array of materials.
  726. # Use the index given in each aiMesh structure to access this
  727. # array. The array is mNumMaterials in size. If the
  728. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  729. # be at least ONE material.
  730. ("mMaterials", POINTER(POINTER(Material))),
  731. # The number of animations in the scene.
  732. ("mNumAnimations", c_uint),
  733. # The array of animations.
  734. # All animations imported from the given file are listed here.
  735. # The array is mNumAnimations in size.
  736. ("mAnimations", POINTER(POINTER(Animation))),
  737. # The number of textures embedded into the file
  738. ("mNumTextures", c_uint),
  739. # The array of embedded textures.
  740. # Not many file formats embed their textures into the file.
  741. # An example is Quake's MDL format (which is also used by
  742. # some GameStudio versions)
  743. ("mTextures", POINTER(POINTER(Texture))),
  744. # The number of light sources in the scene. Light sources
  745. # are fully optional, in most cases this attribute will be 0
  746. ("mNumLights", c_uint),
  747. # The array of light sources.
  748. # All light sources imported from the given file are
  749. # listed here. The array is mNumLights in size.
  750. ("mLights", POINTER(POINTER(Light))),
  751. # The number of cameras in the scene. Cameras
  752. # are fully optional, in most cases this attribute will be 0
  753. ("mNumCameras", c_uint),
  754. # The array of cameras.
  755. # All cameras imported from the given file are listed here.
  756. # The array is mNumCameras in size. The first camera in the
  757. # array (if existing) is the default camera view into
  758. # the scene.
  759. ("mCameras", POINTER(POINTER(Camera))),
  760. # This data contains global metadata which belongs to the scene like
  761. # unit-conversions, versions, vendors or other model-specific data. This
  762. # can be used to store format-specific metadata as well.
  763. ("mMetadata", POINTER(POINTER(Metadata))),
  764. ]
  765. assimp_structs_as_tuple = (Matrix4x4,
  766. Matrix3x3,
  767. Vector2D,
  768. Vector3D,
  769. Color3D,
  770. Color4D,
  771. Quaternion,
  772. Plane,
  773. Texel)