structs.py 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  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
  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. 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 MAXLEN
  61. ("data", c_char*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. 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 '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. Note! Currently only works with Collada loader.
  609. ("mNumAnimMeshes", c_uint),
  610. # Attachment meshes for this mesh, for vertex-based animation.
  611. # Attachment meshes carry replacement data for some of the
  612. # mesh'es vertex components (usually positions, normals).
  613. # Note! Currently only works with Collada loader.
  614. ("mAnimMeshes", POINTER(POINTER(AnimMesh))),
  615. # Method of morphing when animeshes are specified.
  616. ("mMethod", c_uint),
  617. ]
  618. class Camera(Structure):
  619. """
  620. See 'camera.h' for details.
  621. """
  622. _fields_ = [
  623. # The name of the camera.
  624. # There must be a node in the scenegraph with the same name.
  625. # This node specifies the position of the camera in the scene
  626. # hierarchy and can be animated.
  627. ("mName", String),
  628. # Position of the camera relative to the coordinate space
  629. # defined by the corresponding node.
  630. # The default value is 0|0|0.
  631. ("mPosition", Vector3D),
  632. # 'Up' - vector of the camera coordinate system relative to
  633. # the coordinate space defined by the corresponding node.
  634. # The 'right' vector of the camera coordinate system is
  635. # the cross product of the up and lookAt vectors.
  636. # The default value is 0|1|0. The vector
  637. # may be normalized, but it needn't.
  638. ("mUp", Vector3D),
  639. # 'LookAt' - vector of the camera coordinate system relative to
  640. # the coordinate space defined by the corresponding node.
  641. # This is the viewing direction of the user.
  642. # The default value is 0|0|1. The vector
  643. # may be normalized, but it needn't.
  644. ("mLookAt", Vector3D),
  645. # Half horizontal field of view angle, in radians.
  646. # The field of view angle is the angle between the center
  647. # line of the screen and the left or right border.
  648. # The default value is 1/4PI.
  649. ("mHorizontalFOV", c_float),
  650. # Distance of the near clipping plane from the camera.
  651. # The value may not be 0.f (for arithmetic reasons to prevent
  652. # a division through zero). The default value is 0.1f.
  653. ("mClipPlaneNear", c_float),
  654. # Distance of the far clipping plane from the camera.
  655. # The far clipping plane must, of course, be further away than the
  656. # near clipping plane. The default value is 1000.f. The ratio
  657. # between the near and the far plane should not be too
  658. # large (between 1000-10000 should be ok) to avoid floating-point
  659. # inaccuracies which could lead to z-fighting.
  660. ("mClipPlaneFar", c_float),
  661. # Screen aspect ratio.
  662. # This is the ration between the width and the height of the
  663. # screen. Typical values are 4/3, 1/2 or 1/1. This value is
  664. # 0 if the aspect ratio is not defined in the source file.
  665. # 0 is also the default value.
  666. ("mAspect", c_float),
  667. ]
  668. class VectorKey(Structure):
  669. """
  670. See 'anim.h' for details.
  671. """
  672. _fields_ = [
  673. # The time of this key
  674. ("mTime", c_double),
  675. # The value of this key
  676. ("mValue", Vector3D),
  677. ]
  678. class QuatKey(Structure):
  679. """
  680. See 'anim.h' for details.
  681. """
  682. _fields_ = [
  683. # The time of this key
  684. ("mTime", c_double),
  685. # The value of this key
  686. ("mValue", Quaternion),
  687. ]
  688. class MeshMorphKey(Structure):
  689. """
  690. See 'anim.h' for details.
  691. """
  692. _fields_ = [
  693. # The time of this key
  694. ("mTime", c_double),
  695. # The values and weights at the time of this key
  696. ("mValues", POINTER(c_uint)),
  697. ("mWeights", POINTER(c_double)),
  698. # The number of values and weights
  699. ("mNumValuesAndWeights", c_uint),
  700. ]
  701. class NodeAnim(Structure):
  702. """
  703. See 'anim.h' for details.
  704. """
  705. _fields_ = [
  706. # The name of the node affected by this animation. The node
  707. # must exist and it must be unique.
  708. ("mNodeName", String),
  709. # The number of position keys
  710. ("mNumPositionKeys", c_uint),
  711. # The position keys of this animation channel. Positions are
  712. # specified as 3D vector. The array is mNumPositionKeys in size.
  713. # If there are position keys, there will also be at least one
  714. # scaling and one rotation key.
  715. ("mPositionKeys", POINTER(VectorKey)),
  716. # The number of rotation keys
  717. ("mNumRotationKeys", c_uint),
  718. # The rotation keys of this animation channel. Rotations are
  719. # given as quaternions, which are 4D vectors. The array is
  720. # mNumRotationKeys in size.
  721. # If there are rotation keys, there will also be at least one
  722. # scaling and one position key.
  723. ("mRotationKeys", POINTER(QuatKey)),
  724. # The number of scaling keys
  725. ("mNumScalingKeys", c_uint),
  726. # The scaling keys of this animation channel. Scalings are
  727. # specified as 3D vector. The array is mNumScalingKeys in size.
  728. # If there are scaling keys, there will also be at least one
  729. # position and one rotation key.
  730. ("mScalingKeys", POINTER(VectorKey)),
  731. # Defines how the animation behaves before the first
  732. # key is encountered.
  733. # The default value is aiAnimBehaviour_DEFAULT (the original
  734. # transformation matrix of the affected node is used).
  735. ("mPreState", c_uint),
  736. # Defines how the animation behaves after the last
  737. # key was processed.
  738. # The default value is aiAnimBehaviour_DEFAULT (the original
  739. # transformation matrix of the affected node is taken).
  740. ("mPostState", c_uint),
  741. ]
  742. class MeshAnim(Structure):
  743. """
  744. See 'anim.h' for details.
  745. """
  746. _fields_ = [
  747. # Name of the mesh to be animated. An empty string is not allowed,
  748. # animated meshes need to be named (not necessarily uniquely,
  749. # the name can basically serve as wild-card to select a group
  750. # of meshes with similar animation setup)
  751. ("mName", String),
  752. # Size of the #mKeys array. Must be 1, at least.
  753. ("mNumKeys", c_uint),
  754. # Key frames of the animation. May not be NULL.
  755. ("mKeys", POINTER(MeshKey)),
  756. ]
  757. class MeshMorphAnim(Structure):
  758. """
  759. See 'anim.h' for details.
  760. """
  761. _fields_ = [
  762. # Name of the mesh to be animated. An empty string is not allowed,
  763. # animated meshes need to be named (not necessarily uniquely,
  764. # the name can basically serve as wildcard to select a group
  765. # of meshes with similar animation setup)
  766. ("mName", String),
  767. # Size of the #mKeys array. Must be 1, at least.
  768. ("mNumKeys", c_uint),
  769. # Key frames of the animation. May not be NULL.
  770. ("mKeys", POINTER(MeshMorphKey)),
  771. ]
  772. class Animation(Structure):
  773. """
  774. See 'anim.h' for details.
  775. """
  776. _fields_ = [
  777. # The name of the animation. If the modeling package this data was
  778. # exported from does support only a single animation channel, this
  779. # name is usually empty (length is zero).
  780. ("mName", String),
  781. # Duration of the animation in ticks.
  782. ("mDuration", c_double),
  783. # Ticks per second. 0 if not specified in the imported file
  784. ("mTicksPerSecond", c_double),
  785. # The number of bone animation channels. Each channel affects
  786. # a single node.
  787. ("mNumChannels", c_uint),
  788. # The node animation channels. Each channel affects a single node.
  789. # The array is mNumChannels in size.
  790. ("mChannels", POINTER(POINTER(NodeAnim))),
  791. # The number of mesh animation channels. Each channel affects
  792. # a single mesh and defines vertex-based animation.
  793. ("mNumMeshChannels", c_uint),
  794. # The mesh animation channels. Each channel affects a single mesh.
  795. # The array is mNumMeshChannels in size.
  796. ("mMeshChannels", POINTER(POINTER(MeshAnim))),
  797. # The number of mesh animation channels. Each channel affects
  798. # a single mesh and defines morphing animation.
  799. ("mNumMorphMeshChannels", c_uint),
  800. # The morph mesh animation channels. Each channel affects a single mesh.
  801. # The array is mNumMorphMeshChannels in size.
  802. ("mMorphMeshChannels", POINTER(POINTER(MeshMorphAnim))),
  803. ]
  804. class ExportDataBlob(Structure):
  805. """
  806. See 'cexport.h' for details.
  807. Note that the '_fields_' definition is outside the class to allow the 'next' field to be recursive
  808. """
  809. pass
  810. ExportDataBlob._fields_ = [
  811. # Size of the data in bytes
  812. ("size", c_size_t),
  813. # The data.
  814. ("data", c_void_p),
  815. # Name of the blob. An empty string always
  816. # indicates the first (and primary) blob,
  817. # which contains the actual file data.
  818. # Any other blobs are auxiliary files produced
  819. # by exporters (i.e. material files). Existence
  820. # of such files depends on the file format. Most
  821. # formats don't split assets across multiple files.
  822. #
  823. # If used, blob names usually contain the file
  824. # extension that should be used when writing
  825. # the data to disc.
  826. ("name", String),
  827. # Pointer to the next blob in the chain or NULL if there is none.
  828. ("next", POINTER(ExportDataBlob)),
  829. ]
  830. class Scene(Structure):
  831. """
  832. See 'aiScene.h' for details.
  833. """
  834. AI_SCENE_FLAGS_INCOMPLETE = 0x1
  835. AI_SCENE_FLAGS_VALIDATED = 0x2
  836. AI_SCENE_FLAGS_VALIDATION_WARNING = 0x4
  837. AI_SCENE_FLAGS_NON_VERBOSE_FORMAT = 0x8
  838. AI_SCENE_FLAGS_TERRAIN = 0x10
  839. AI_SCENE_FLAGS_ALLOW_SHARED = 0x20
  840. _fields_ = [
  841. # Any combination of the AI_SCENE_FLAGS_XXX flags. By default
  842. # this value is 0, no flags are set. Most applications will
  843. # want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
  844. # bit set.
  845. ("mFlags", c_uint),
  846. # The root node of the hierarchy.
  847. # There will always be at least the root node if the import
  848. # was successful (and no special flags have been set).
  849. # Presence of further nodes depends on the format and content
  850. # of the imported file.
  851. ("mRootNode", POINTER(Node)),
  852. # The number of meshes in the scene.
  853. ("mNumMeshes", c_uint),
  854. # The array of meshes.
  855. # Use the indices given in the aiNode structure to access
  856. # this array. The array is mNumMeshes in size. If the
  857. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  858. # be at least ONE material.
  859. ("mMeshes", POINTER(POINTER(Mesh))),
  860. # The number of materials in the scene.
  861. ("mNumMaterials", c_uint),
  862. # The array of materials.
  863. # Use the index given in each aiMesh structure to access this
  864. # array. The array is mNumMaterials in size. If the
  865. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  866. # be at least ONE material.
  867. ("mMaterials", POINTER(POINTER(Material))),
  868. # The number of animations in the scene.
  869. ("mNumAnimations", c_uint),
  870. # The array of animations.
  871. # All animations imported from the given file are listed here.
  872. # The array is mNumAnimations in size.
  873. ("mAnimations", POINTER(POINTER(Animation))),
  874. # The number of textures embedded into the file
  875. ("mNumTextures", c_uint),
  876. # The array of embedded textures.
  877. # Not many file formats embed their textures into the file.
  878. # An example is Quake's MDL format (which is also used by
  879. # some GameStudio versions)
  880. ("mTextures", POINTER(POINTER(Texture))),
  881. # The number of light sources in the scene. Light sources
  882. # are fully optional, in most cases this attribute will be 0
  883. ("mNumLights", c_uint),
  884. # The array of light sources.
  885. # All light sources imported from the given file are
  886. # listed here. The array is mNumLights in size.
  887. ("mLights", POINTER(POINTER(Light))),
  888. # The number of cameras in the scene. Cameras
  889. # are fully optional, in most cases this attribute will be 0
  890. ("mNumCameras", c_uint),
  891. # The array of cameras.
  892. # All cameras imported from the given file are listed here.
  893. # The array is mNumCameras in size. The first camera in the
  894. # array (if existing) is the default camera view into
  895. # the scene.
  896. ("mCameras", POINTER(POINTER(Camera))),
  897. # This data contains global metadata which belongs to the scene like
  898. # unit-conversions, versions, vendors or other model-specific data. This
  899. # can be used to store format-specific metadata as well.
  900. ("mMetadata", POINTER(Metadata)),
  901. # Internal data, do not touch
  902. ("mPrivate", POINTER(c_char)),
  903. ]
  904. assimp_structs_as_tuple = (Matrix4x4,
  905. Matrix3x3,
  906. Vector2D,
  907. Vector3D,
  908. Color3D,
  909. Color4D,
  910. Quaternion,
  911. Plane,
  912. Texel)