structs.py 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. #-*- coding: utf-8 -*-
  2. from ctypes import POINTER, c_void_p, c_uint, c_char, c_float, Structure, c_double, c_ubyte, c_size_t, c_uint32, c_int
  3. class Vector2D(Structure):
  4. """
  5. See 'vector2.h' for details.
  6. """
  7. _fields_ = [
  8. ("x", c_float),("y", c_float),
  9. ]
  10. class Matrix3x3(Structure):
  11. """
  12. See 'matrix3x3.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 'texture.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 'color4.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 'types.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 'types.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 'types.h' for details.
  53. """
  54. AI_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_uint32),
  60. # String buffer. Size limit is AI_MAXLEN
  61. ("data", c_char*AI_MAXLEN),
  62. ]
  63. class MaterialPropertyString(Structure):
  64. """
  65. See 'MaterialSystem.cpp' 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. AI_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 AI_MAXLEN
  76. ("data", c_char*AI_MAXLEN),
  77. ]
  78. class MemoryInfo(Structure):
  79. """
  80. See 'types.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 'quaternion.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 'mesh.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 'mesh.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 'matrix4x4.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 'vector3.h' for details.
  144. """
  145. _fields_ = [
  146. ("x", c_float),("y", c_float),("z", c_float),
  147. ]
  148. class MeshKey(Structure):
  149. """
  150. See 'anim.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 'scene.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(Metadata)),
  228. ]
  229. class Light(Structure):
  230. """
  231. See 'light.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. # Up direction of the light source in space. Relative to the
  252. # transformation of the node corresponding to the light.
  253. #
  254. # The direction is undefined for point lights. The vector
  255. # may be normalized, but it needn't.
  256. ("mUp", Vector3D),
  257. # Constant light attenuation factor.
  258. # The intensity of the light source at a given distance 'd' from
  259. # the light's position is
  260. # @code
  261. # Atten = 1/( att0 + att1
  262. # d + att2
  263. # d*d)
  264. # @endcode
  265. # This member corresponds to the att0 variable in the equation.
  266. # Naturally undefined for directional lights.
  267. ("mAttenuationConstant", c_float),
  268. # Linear light attenuation factor.
  269. # The intensity of the light source at a given distance 'd' from
  270. # the light's position is
  271. # @code
  272. # Atten = 1/( att0 + att1
  273. # d + att2
  274. # d*d)
  275. # @endcode
  276. # This member corresponds to the att1 variable in the equation.
  277. # Naturally undefined for directional lights.
  278. ("mAttenuationLinear", c_float),
  279. # Quadratic light attenuation factor.
  280. # The intensity of the light source at a given distance 'd' from
  281. # the light's position is
  282. # @code
  283. # Atten = 1/( att0 + att1
  284. # d + att2
  285. # d*d)
  286. # @endcode
  287. # This member corresponds to the att2 variable in the equation.
  288. # Naturally undefined for directional lights.
  289. ("mAttenuationQuadratic", c_float),
  290. # Diffuse color of the light source
  291. # The diffuse light color is multiplied with the diffuse
  292. # material color to obtain the final color that contributes
  293. # to the diffuse shading term.
  294. ("mColorDiffuse", Color3D),
  295. # Specular color of the light source
  296. # The specular light color is multiplied with the specular
  297. # material color to obtain the final color that contributes
  298. # to the specular shading term.
  299. ("mColorSpecular", Color3D),
  300. # Ambient color of the light source
  301. # The ambient light color is multiplied with the ambient
  302. # material color to obtain the final color that contributes
  303. # to the ambient shading term. Most renderers will ignore
  304. # this value it, is just a remaining of the fixed-function pipeline
  305. # that is still supported by quite many file formats.
  306. ("mColorAmbient", Color3D),
  307. # Inner angle of a spot light's light cone.
  308. # The spot light has maximum influence on objects inside this
  309. # angle. The angle is given in radians. It is 2PI for point
  310. # lights and undefined for directional lights.
  311. ("mAngleInnerCone", c_float),
  312. # Outer angle of a spot light's light cone.
  313. # The spot light does not affect objects outside this angle.
  314. # The angle is given in radians. It is 2PI for point lights and
  315. # undefined for directional lights. The outer angle must be
  316. # greater than or equal to the inner angle.
  317. # It is assumed that the application uses a smooth
  318. # interpolation between the inner and the outer cone of the
  319. # spot light.
  320. ("mAngleOuterCone", c_float),
  321. # Size of area light source.
  322. ("mSize", Vector2D),
  323. ]
  324. class Texture(Structure):
  325. """
  326. See 'texture.h' for details.
  327. """
  328. _fields_ = [
  329. # Width of the texture, in pixels
  330. # If mHeight is zero the texture is compressed in a format
  331. # like JPEG. In this case mWidth specifies the size of the
  332. # memory area pcData is pointing to, in bytes.
  333. ("mWidth", c_uint),
  334. # Height of the texture, in pixels
  335. # If this value is zero, pcData points to an compressed texture
  336. # in any format (e.g. JPEG).
  337. ("mHeight", c_uint),
  338. # A hint from the loader to make it easier for applications
  339. # to determine the type of embedded textures.
  340. #
  341. # If mHeight != 0 this member is show how data is packed. Hint will consist of
  342. # two parts: channel order and channel bitness (count of the bits for every
  343. # color channel). For simple parsing by the viewer it's better to not omit
  344. # absent color channel and just use 0 for bitness. For example:
  345. # 1. Image contain RGBA and 8 bit per channel, achFormatHint == "rgba8888";
  346. # 2. Image contain ARGB and 8 bit per channel, achFormatHint == "argb8888";
  347. # 3. Image contain RGB and 5 bit for R and B channels and 6 bit for G channel,
  348. # achFormatHint == "rgba5650";
  349. # 4. One color image with B channel and 1 bit for it, achFormatHint == "rgba0010";
  350. # If mHeight == 0 then achFormatHint is set set to '\\0\\0\\0\\0' if the loader has no additional
  351. # information about the texture file format used OR the
  352. # file extension of the format without a trailing dot. If there
  353. # are multiple file extensions for a format, the shortest
  354. # extension is chosen (JPEG maps to 'jpg', not to 'jpeg').
  355. # E.g. 'dds\\0', 'pcx\\0', 'jpg\\0'. All characters are lower-case.
  356. # The fourth character will always be '\\0'.
  357. ("achFormatHint", c_char*9),
  358. # Data of the texture.
  359. # Points to an array of mWidth
  360. # mHeight aiTexel's.
  361. # The format of the texture data is always ARGB8888 to
  362. # make the implementation for user of the library as easy
  363. # as possible. If mHeight = 0 this is a pointer to a memory
  364. # buffer of size mWidth containing the compressed texture
  365. # data. Good luck, have fun!
  366. ("pcData", POINTER(Texel)),
  367. # Texture original filename
  368. # Used to get the texture reference
  369. ("mFilename", String),
  370. ]
  371. class Ray(Structure):
  372. """
  373. See 'types.h' for details.
  374. """
  375. _fields_ = [
  376. # Position and direction of the ray
  377. ("pos", Vector3D),("dir", Vector3D),
  378. ]
  379. class UVTransform(Structure):
  380. """
  381. See 'material.h' for details.
  382. """
  383. _fields_ = [
  384. # Translation on the u and v axes.
  385. # The default value is (0|0).
  386. ("mTranslation", Vector2D),
  387. # Scaling on the u and v axes.
  388. # The default value is (1|1).
  389. ("mScaling", Vector2D),
  390. # Rotation - in counter-clockwise direction.
  391. # The rotation angle is specified in radians. The
  392. # rotation center is 0.5f|0.5f. The default value
  393. # 0.f.
  394. ("mRotation", c_float),
  395. ]
  396. class MaterialProperty(Structure):
  397. """
  398. See 'material.h' for details.
  399. """
  400. _fields_ = [
  401. # Specifies the name of the property (key)
  402. # Keys are generally case insensitive.
  403. ("mKey", String),
  404. # Textures: Specifies their exact usage semantic.
  405. # For non-texture properties, this member is always 0
  406. # (or, better-said,
  407. #aiTextureType_NONE).
  408. ("mSemantic", c_uint),
  409. # Textures: Specifies the index of the texture.
  410. # For non-texture properties, this member is always 0.
  411. ("mIndex", c_uint),
  412. # Size of the buffer mData is pointing to, in bytes.
  413. # This value may not be 0.
  414. ("mDataLength", c_uint),
  415. # Type information for the property.
  416. # Defines the data layout inside the data buffer. This is used
  417. # by the library internally to perform debug checks and to
  418. # utilize proper type conversions.
  419. # (It's probably a hacky solution, but it works.)
  420. ("mType", c_uint),
  421. # Binary buffer to hold the property's value.
  422. # The size of the buffer is always mDataLength.
  423. ("mData", POINTER(c_char)),
  424. ]
  425. class Material(Structure):
  426. """
  427. See 'material.h' for details.
  428. """
  429. _fields_ = [
  430. # List of all material properties loaded.
  431. ("mProperties", POINTER(POINTER(MaterialProperty))),
  432. # Number of properties in the data base
  433. ("mNumProperties", c_uint),
  434. # Storage allocated
  435. ("mNumAllocated", c_uint),
  436. ]
  437. class Bone(Structure):
  438. """
  439. See 'mesh.h' for details.
  440. """
  441. _fields_ = [
  442. # The name of the bone.
  443. ("mName", String),
  444. # The number of vertices affected by this bone
  445. # The maximum value for this member is
  446. #AI_MAX_BONE_WEIGHTS.
  447. ("mNumWeights", c_uint),
  448. # The vertices affected by this bone
  449. ("mWeights", POINTER(VertexWeight)),
  450. # Matrix that transforms from mesh space to bone space in bind pose
  451. ("mOffsetMatrix", Matrix4x4),
  452. ]
  453. class AnimMesh(Structure):
  454. """
  455. See 'mesh.h' for details.
  456. """
  457. AI_MAX_NUMBER_OF_TEXTURECOORDS = 0x8
  458. AI_MAX_NUMBER_OF_COLOR_SETS = 0x8
  459. _fields_ = [
  460. # Anim Mesh name
  461. ("mName", String),
  462. # Replacement for aiMesh::mVertices. If this array is non-NULL,
  463. # it *must* contain mNumVertices entries. The corresponding
  464. # array in the host mesh must be non-NULL as well - animation
  465. # meshes may neither add or nor remove vertex components (if
  466. # a replacement array is NULL and the corresponding source
  467. # array is not, the source data is taken instead)
  468. ("mVertices", POINTER(Vector3D)),
  469. # Replacement for aiMesh::mNormals.
  470. ("mNormals", POINTER(Vector3D)),
  471. # Replacement for aiMesh::mTangents.
  472. ("mTangents", POINTER(Vector3D)),
  473. # Replacement for aiMesh::mBitangents.
  474. ("mBitangents", POINTER(Vector3D)),
  475. # Replacement for aiMesh::mColors
  476. ("mColors", POINTER(Color4D) * AI_MAX_NUMBER_OF_COLOR_SETS),
  477. # Replacement for aiMesh::mTextureCoords
  478. ("mTextureCoords", POINTER(Vector3D) * AI_MAX_NUMBER_OF_TEXTURECOORDS),
  479. # The number of vertices in the aiAnimMesh, and thus the length of all
  480. # the member arrays.
  481. #
  482. # This has always the same value as the mNumVertices property in the
  483. # corresponding aiMesh. It is duplicated here merely to make the length
  484. # of the member arrays accessible even if the aiMesh is not known, e.g.
  485. # from language bindings.
  486. ("mNumVertices", c_uint),
  487. # Weight of the AnimMesh.
  488. ("mWeight", c_float),
  489. ]
  490. class Mesh(Structure):
  491. """
  492. See 'mesh.h' for details.
  493. """
  494. AI_MAX_FACE_INDICES = 0x7fff
  495. AI_MAX_BONE_WEIGHTS = 0x7fffffff
  496. AI_MAX_VERTICES = 0x7fffffff
  497. AI_MAX_FACES = 0x7fffffff
  498. AI_MAX_NUMBER_OF_COLOR_SETS = 0x8
  499. AI_MAX_NUMBER_OF_TEXTURECOORDS = 0x8
  500. _fields_ = [ # Bitwise combination of the members of the
  501. #aiPrimitiveType enum.
  502. # This specifies which types of primitives are present in the mesh.
  503. # The "SortByPrimitiveType"-Step can be used to make sure the
  504. # output meshes consist of one primitive type each.
  505. ("mPrimitiveTypes", c_uint),
  506. # The number of vertices in this mesh.
  507. # This is also the size of all of the per-vertex data arrays.
  508. # The maximum value for this member is
  509. #AI_MAX_VERTICES.
  510. ("mNumVertices", c_uint),
  511. # The number of primitives (triangles, polygons, lines) in this mesh.
  512. # This is also the size of the mFaces array.
  513. # The maximum value for this member is
  514. #AI_MAX_FACES.
  515. ("mNumFaces", c_uint),
  516. # Vertex positions.
  517. # This array is always present in a mesh. The array is
  518. # mNumVertices in size.
  519. ("mVertices", POINTER(Vector3D)),
  520. # Vertex normals.
  521. # The array contains normalized vectors, NULL if not present.
  522. # The array is mNumVertices in size. Normals are undefined for
  523. # point and line primitives. A mesh consisting of points and
  524. # lines only may not have normal vectors. Meshes with mixed
  525. # primitive types (i.e. lines and triangles) may have normals,
  526. # but the normals for vertices that are only referenced by
  527. # point or line primitives are undefined and set to QNaN (WARN:
  528. # qNaN compares to inequal to *everything*, even to qNaN itself.
  529. # Using code like this to check whether a field is qnan is:
  530. # @code
  531. #define IS_QNAN(f) (f != f)
  532. # @endcode
  533. # still dangerous because even 1.f == 1.f could evaluate to false! (
  534. # remember the subtleties of IEEE754 artithmetics). Use stuff like
  535. # @c fpclassify instead.
  536. # @note Normal vectors computed by Assimp are always unit-length.
  537. # However, this needn't apply for normals that have been taken
  538. # directly from the model file.
  539. ("mNormals", POINTER(Vector3D)),
  540. # Vertex tangents.
  541. # The tangent of a vertex points in the direction of the positive
  542. # X texture axis. The array contains normalized vectors, NULL if
  543. # not present. The array is mNumVertices in size. A mesh consisting
  544. # of points and lines only may not have normal vectors. Meshes with
  545. # mixed primitive types (i.e. lines and triangles) may have
  546. # normals, but the normals for vertices that are only referenced by
  547. # point or line primitives are undefined and set to qNaN. See
  548. # the
  549. #mNormals member for a detailed discussion of qNaNs.
  550. # @note If the mesh contains tangents, it automatically also
  551. # contains bitangents (the bitangent is just the cross product of
  552. # tangent and normal vectors).
  553. ("mTangents", POINTER(Vector3D)),
  554. # Vertex bitangents.
  555. # The bitangent of a vertex points in the direction of the positive
  556. # Y texture axis. The array contains normalized vectors, NULL if not
  557. # present. The array is mNumVertices in size.
  558. # @note If the mesh contains tangents, it automatically also contains
  559. # bitangents.
  560. ("mBitangents", POINTER(Vector3D)),
  561. # Vertex color sets.
  562. # A mesh may contain 0 to
  563. #AI_MAX_NUMBER_OF_COLOR_SETS vertex
  564. # colors per vertex. NULL if not present. Each array is
  565. # mNumVertices in size if present.
  566. ("mColors", POINTER(Color4D)*AI_MAX_NUMBER_OF_COLOR_SETS),
  567. # Vertex texture coords, also known as UV channels.
  568. # A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
  569. # vertex. NULL if not present. The array is mNumVertices in size.
  570. ("mTextureCoords", POINTER(Vector3D)*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  571. # Specifies the number of components for a given UV channel.
  572. # Up to three channels are supported (UVW, for accessing volume
  573. # or cube maps). If the value is 2 for a given channel n, the
  574. # component p.z of mTextureCoords[n][p] is set to 0.0f.
  575. # If the value is 1 for a given channel, p.y is set to 0.0f, too.
  576. # @note 4D coords are not supported
  577. ("mNumUVComponents", c_uint*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  578. # The faces the mesh is constructed from.
  579. # Each face refers to a number of vertices by their indices.
  580. # This array is always present in a mesh, its size is given
  581. # in mNumFaces. If the
  582. #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
  583. # is NOT set each face references an unique set of vertices.
  584. ("mFaces", POINTER(Face)),
  585. # The number of bones this mesh contains.
  586. # Can be 0, in which case the mBones array is NULL.
  587. ("mNumBones", c_uint),
  588. # The bones of this mesh.
  589. # A bone consists of a name by which it can be found in the
  590. # frame hierarchy and a set of vertex weights.
  591. ("mBones", POINTER(POINTER(Bone))),
  592. # The material used by this mesh.
  593. # A mesh does use only a single material. If an imported model uses
  594. # multiple materials, the import splits up the mesh. Use this value
  595. # as index into the scene's material list.
  596. ("mMaterialIndex", c_uint),
  597. # Name of the mesh. Meshes can be named, but this is not a
  598. # requirement and leaving this field empty is totally fine.
  599. # There are mainly three uses for mesh names:
  600. # - some formats name nodes and meshes independently.
  601. # - importers tend to split meshes up to meet the
  602. # one-material-per-mesh requirement. Assigning
  603. # the same (dummy) name to each of the result meshes
  604. # aids the caller at recovering the original mesh
  605. # partitioning.
  606. # - Vertex animations refer to meshes by their names.
  607. ("mName", String),
  608. # The number of attachment meshes.
  609. # Currently known to work with loaders:
  610. # - Collada
  611. # - gltf
  612. ("mNumAnimMeshes", c_uint),
  613. # Attachment meshes for this mesh, for vertex-based animation.
  614. # Attachment meshes carry replacement data for some of the
  615. # mesh'es vertex components (usually positions, normals).
  616. # Currently known to work with loaders:
  617. # - Collada
  618. # - gltf
  619. ("mAnimMeshes", POINTER(POINTER(AnimMesh))),
  620. # Method of morphing when animeshes are specified.
  621. ("mMethod", c_uint),
  622. # The bounding box.
  623. ("mAABB", 2 * Vector3D),
  624. # Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
  625. ("mTextureCoordsNames", POINTER(POINTER(String)))
  626. ]
  627. class Camera(Structure):
  628. """
  629. See 'camera.h' for details.
  630. """
  631. _fields_ = [
  632. # The name of the camera.
  633. # There must be a node in the scenegraph with the same name.
  634. # This node specifies the position of the camera in the scene
  635. # hierarchy and can be animated.
  636. ("mName", String),
  637. # Position of the camera relative to the coordinate space
  638. # defined by the corresponding node.
  639. # The default value is 0|0|0.
  640. ("mPosition", Vector3D),
  641. # 'Up' - vector of the camera coordinate system relative to
  642. # the coordinate space defined by the corresponding node.
  643. # The 'right' vector of the camera coordinate system is
  644. # the cross product of the up and lookAt vectors.
  645. # The default value is 0|1|0. The vector
  646. # may be normalized, but it needn't.
  647. ("mUp", Vector3D),
  648. # 'LookAt' - vector of the camera coordinate system relative to
  649. # the coordinate space defined by the corresponding node.
  650. # This is the viewing direction of the user.
  651. # The default value is 0|0|1. The vector
  652. # may be normalized, but it needn't.
  653. ("mLookAt", Vector3D),
  654. # Half horizontal field of view angle, in radians.
  655. # The field of view angle is the angle between the center
  656. # line of the screen and the left or right border.
  657. # The default value is 1/4PI.
  658. ("mHorizontalFOV", c_float),
  659. # Distance of the near clipping plane from the camera.
  660. # The value may not be 0.f (for arithmetic reasons to prevent
  661. # a division through zero). The default value is 0.1f.
  662. ("mClipPlaneNear", c_float),
  663. # Distance of the far clipping plane from the camera.
  664. # The far clipping plane must, of course, be further away than the
  665. # near clipping plane. The default value is 1000.f. The ratio
  666. # between the near and the far plane should not be too
  667. # large (between 1000-10000 should be ok) to avoid floating-point
  668. # inaccuracies which could lead to z-fighting.
  669. ("mClipPlaneFar", c_float),
  670. # Screen aspect ratio.
  671. # This is the ration between the width and the height of the
  672. # screen. Typical values are 4/3, 1/2 or 1/1. This value is
  673. # 0 if the aspect ratio is not defined in the source file.
  674. # 0 is also the default value.
  675. ("mAspect", c_float),
  676. ]
  677. class VectorKey(Structure):
  678. """
  679. See 'anim.h' for details.
  680. """
  681. _fields_ = [
  682. # The time of this key
  683. ("mTime", c_double),
  684. # The value of this key
  685. ("mValue", Vector3D),
  686. ]
  687. class QuatKey(Structure):
  688. """
  689. See 'anim.h' for details.
  690. """
  691. _fields_ = [
  692. # The time of this key
  693. ("mTime", c_double),
  694. # The value of this key
  695. ("mValue", Quaternion),
  696. ]
  697. class MeshMorphKey(Structure):
  698. """
  699. See 'anim.h' for details.
  700. """
  701. _fields_ = [
  702. # The time of this key
  703. ("mTime", c_double),
  704. # The values and weights at the time of this key
  705. ("mValues", POINTER(c_uint)),
  706. ("mWeights", POINTER(c_double)),
  707. # The number of values and weights
  708. ("mNumValuesAndWeights", c_uint),
  709. ]
  710. class NodeAnim(Structure):
  711. """
  712. See 'anim.h' for details.
  713. """
  714. _fields_ = [
  715. # The name of the node affected by this animation. The node
  716. # must exist and it must be unique.
  717. ("mNodeName", String),
  718. # The number of position keys
  719. ("mNumPositionKeys", c_uint),
  720. # The position keys of this animation channel. Positions are
  721. # specified as 3D vector. The array is mNumPositionKeys in size.
  722. # If there are position keys, there will also be at least one
  723. # scaling and one rotation key.
  724. ("mPositionKeys", POINTER(VectorKey)),
  725. # The number of rotation keys
  726. ("mNumRotationKeys", c_uint),
  727. # The rotation keys of this animation channel. Rotations are
  728. # given as quaternions, which are 4D vectors. The array is
  729. # mNumRotationKeys in size.
  730. # If there are rotation keys, there will also be at least one
  731. # scaling and one position key.
  732. ("mRotationKeys", POINTER(QuatKey)),
  733. # The number of scaling keys
  734. ("mNumScalingKeys", c_uint),
  735. # The scaling keys of this animation channel. Scalings are
  736. # specified as 3D vector. The array is mNumScalingKeys in size.
  737. # If there are scaling keys, there will also be at least one
  738. # position and one rotation key.
  739. ("mScalingKeys", POINTER(VectorKey)),
  740. # Defines how the animation behaves before the first
  741. # key is encountered.
  742. # The default value is aiAnimBehaviour_DEFAULT (the original
  743. # transformation matrix of the affected node is used).
  744. ("mPreState", c_uint),
  745. # Defines how the animation behaves after the last
  746. # key was processed.
  747. # The default value is aiAnimBehaviour_DEFAULT (the original
  748. # transformation matrix of the affected node is taken).
  749. ("mPostState", c_uint),
  750. ]
  751. class MeshAnim(Structure):
  752. """
  753. See 'anim.h' for details.
  754. """
  755. _fields_ = [
  756. # Name of the mesh to be animated. An empty string is not allowed,
  757. # animated meshes need to be named (not necessarily uniquely,
  758. # the name can basically serve as wild-card to select a group
  759. # of meshes with similar animation setup)
  760. ("mName", String),
  761. # Size of the #mKeys array. Must be 1, at least.
  762. ("mNumKeys", c_uint),
  763. # Key frames of the animation. May not be NULL.
  764. ("mKeys", POINTER(MeshKey)),
  765. ]
  766. class MeshMorphAnim(Structure):
  767. """
  768. See 'anim.h' for details.
  769. """
  770. _fields_ = [
  771. # Name of the mesh to be animated. An empty string is not allowed,
  772. # animated meshes need to be named (not necessarily uniquely,
  773. # the name can basically serve as wildcard to select a group
  774. # of meshes with similar animation setup)
  775. ("mName", String),
  776. # Size of the #mKeys array. Must be 1, at least.
  777. ("mNumKeys", c_uint),
  778. # Key frames of the animation. May not be NULL.
  779. ("mKeys", POINTER(MeshMorphKey)),
  780. ]
  781. class Animation(Structure):
  782. """
  783. See 'anim.h' for details.
  784. """
  785. _fields_ = [
  786. # The name of the animation. If the modeling package this data was
  787. # exported from does support only a single animation channel, this
  788. # name is usually empty (length is zero).
  789. ("mName", String),
  790. # Duration of the animation in ticks.
  791. ("mDuration", c_double),
  792. # Ticks per second. 0 if not specified in the imported file
  793. ("mTicksPerSecond", c_double),
  794. # The number of bone animation channels. Each channel affects
  795. # a single node.
  796. ("mNumChannels", c_uint),
  797. # The node animation channels. Each channel affects a single node.
  798. # The array is mNumChannels in size.
  799. ("mChannels", POINTER(POINTER(NodeAnim))),
  800. # The number of mesh animation channels. Each channel affects
  801. # a single mesh and defines vertex-based animation.
  802. ("mNumMeshChannels", c_uint),
  803. # The mesh animation channels. Each channel affects a single mesh.
  804. # The array is mNumMeshChannels in size.
  805. ("mMeshChannels", POINTER(POINTER(MeshAnim))),
  806. # The number of mesh animation channels. Each channel affects
  807. # a single mesh and defines morphing animation.
  808. ("mNumMorphMeshChannels", c_uint),
  809. # The morph mesh animation channels. Each channel affects a single mesh.
  810. # The array is mNumMorphMeshChannels in size.
  811. ("mMorphMeshChannels", POINTER(POINTER(MeshMorphAnim))),
  812. ]
  813. class SkeletonBone(Structure):
  814. """
  815. See 'mesh.h' for details
  816. """
  817. _fields_ = [
  818. # The parent bone index, is -1 one if this bone represents the root bone.
  819. ("mParent", c_int),
  820. # The number of weights
  821. ("mNumnWeights", c_uint),
  822. # The mesh index, which will get influenced by the weight
  823. ("mMeshId", POINTER(Mesh)),
  824. # The influence weights of this bone, by vertex index.
  825. ("mWeights", POINTER(VertexWeight)),
  826. # Matrix that transforms from bone space to mesh space in bind pose.
  827. #
  828. # This matrix describes the position of the mesh
  829. # in the local space of this bone when the skeleton was bound.
  830. # Thus it can be used directly to determine a desired vertex position,
  831. # given the world-space transform of the bone when animated,
  832. # and the position of the vertex in mesh space.
  833. #
  834. # It is sometimes called an inverse-bind matrix,
  835. # or inverse bind pose matrix
  836. ("mOffsetMatrix", Matrix4x4),
  837. # Matrix that transforms the locale bone in bind pose.
  838. ("mLocalMatrix", Matrix4x4)
  839. ]
  840. class Skeleton(Structure):
  841. """
  842. See 'mesh.h' for details
  843. """
  844. _fields_ = [
  845. # Name
  846. ("mName", String),
  847. # Number of bones
  848. ("mNumBones", c_uint),
  849. # Bones
  850. ("mBones", POINTER(POINTER(SkeletonBone)))
  851. ]
  852. class ExportDataBlob(Structure):
  853. """
  854. See 'cexport.h' for details.
  855. Note that the '_fields_' definition is outside the class to allow the 'next' field to be recursive
  856. """
  857. pass
  858. ExportDataBlob._fields_ = [
  859. # Size of the data in bytes
  860. ("size", c_size_t),
  861. # The data.
  862. ("data", c_void_p),
  863. # Name of the blob. An empty string always
  864. # indicates the first (and primary) blob,
  865. # which contains the actual file data.
  866. # Any other blobs are auxiliary files produced
  867. # by exporters (i.e. material files). Existence
  868. # of such files depends on the file format. Most
  869. # formats don't split assets across multiple files.
  870. #
  871. # If used, blob names usually contain the file
  872. # extension that should be used when writing
  873. # the data to disc.
  874. ("name", String),
  875. # Pointer to the next blob in the chain or NULL if there is none.
  876. ("next", POINTER(ExportDataBlob)),
  877. ]
  878. class Scene(Structure):
  879. """
  880. See 'aiScene.h' for details.
  881. """
  882. AI_SCENE_FLAGS_INCOMPLETE = 0x1
  883. AI_SCENE_FLAGS_VALIDATED = 0x2
  884. AI_SCENE_FLAGS_VALIDATION_WARNING = 0x4
  885. AI_SCENE_FLAGS_NON_VERBOSE_FORMAT = 0x8
  886. AI_SCENE_FLAGS_TERRAIN = 0x10
  887. AI_SCENE_FLAGS_ALLOW_SHARED = 0x20
  888. _fields_ = [
  889. # Any combination of the AI_SCENE_FLAGS_XXX flags. By default
  890. # this value is 0, no flags are set. Most applications will
  891. # want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
  892. # bit set.
  893. ("mFlags", c_uint),
  894. # The root node of the hierarchy.
  895. # There will always be at least the root node if the import
  896. # was successful (and no special flags have been set).
  897. # Presence of further nodes depends on the format and content
  898. # of the imported file.
  899. ("mRootNode", POINTER(Node)),
  900. # The number of meshes in the scene.
  901. ("mNumMeshes", c_uint),
  902. # The array of meshes.
  903. # Use the indices given in the aiNode structure to access
  904. # this array. The array is mNumMeshes in size. If the
  905. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  906. # be at least ONE material.
  907. ("mMeshes", POINTER(POINTER(Mesh))),
  908. # The number of materials in the scene.
  909. ("mNumMaterials", c_uint),
  910. # The array of materials.
  911. # Use the index given in each aiMesh structure to access this
  912. # array. The array is mNumMaterials in size. If the
  913. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  914. # be at least ONE material.
  915. ("mMaterials", POINTER(POINTER(Material))),
  916. # The number of animations in the scene.
  917. ("mNumAnimations", c_uint),
  918. # The array of animations.
  919. # All animations imported from the given file are listed here.
  920. # The array is mNumAnimations in size.
  921. ("mAnimations", POINTER(POINTER(Animation))),
  922. # The number of textures embedded into the file
  923. ("mNumTextures", c_uint),
  924. # The array of embedded textures.
  925. # Not many file formats embed their textures into the file.
  926. # An example is Quake's MDL format (which is also used by
  927. # some GameStudio versions)
  928. ("mTextures", POINTER(POINTER(Texture))),
  929. # The number of light sources in the scene. Light sources
  930. # are fully optional, in most cases this attribute will be 0
  931. ("mNumLights", c_uint),
  932. # The array of light sources.
  933. # All light sources imported from the given file are
  934. # listed here. The array is mNumLights in size.
  935. ("mLights", POINTER(POINTER(Light))),
  936. # The number of cameras in the scene. Cameras
  937. # are fully optional, in most cases this attribute will be 0
  938. ("mNumCameras", c_uint),
  939. # The array of cameras.
  940. # All cameras imported from the given file are listed here.
  941. # The array is mNumCameras in size. The first camera in the
  942. # array (if existing) is the default camera view into
  943. # the scene.
  944. ("mCameras", POINTER(POINTER(Camera))),
  945. # This data contains global metadata which belongs to the scene like
  946. # unit-conversions, versions, vendors or other model-specific data. This
  947. # can be used to store format-specific metadata as well.
  948. ("mMetadata", POINTER(Metadata)),
  949. # The name of the scene itself
  950. ("mName", String),
  951. # Number of skeletons
  952. ("mNumSkeletons", c_uint),
  953. # Skeletons
  954. ("mSkeletons", POINTER(POINTER(Skeleton))),
  955. # Internal data, do not touch
  956. ("mPrivate", POINTER(c_char)),
  957. ]
  958. assimp_structs_as_tuple = (Matrix4x4,
  959. Matrix3x3,
  960. Vector2D,
  961. Vector3D,
  962. Color3D,
  963. Color4D,
  964. Quaternion,
  965. Plane,
  966. Texel)