structs.py 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  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 bone armature node - used for skeleton conversion
  449. # you must enable aiProcess_PopulateArmatureData to populate this
  450. ("mArmature", POINTER(Node)),
  451. # The bone node in the scene - used for skeleton conversion
  452. # you must enable aiProcess_PopulateArmatureData to populate this
  453. ("mNode", POINTER(Node)),
  454. # The vertices affected by this bone
  455. ("mWeights", POINTER(VertexWeight)),
  456. # Matrix that transforms from mesh space to bone space in bind pose
  457. ("mOffsetMatrix", Matrix4x4),
  458. ]
  459. class AnimMesh(Structure):
  460. """
  461. See 'mesh.h' for details.
  462. """
  463. AI_MAX_NUMBER_OF_TEXTURECOORDS = 0x8
  464. AI_MAX_NUMBER_OF_COLOR_SETS = 0x8
  465. _fields_ = [
  466. # Anim Mesh name
  467. ("mName", String),
  468. # Replacement for aiMesh::mVertices. If this array is non-NULL,
  469. # it *must* contain mNumVertices entries. The corresponding
  470. # array in the host mesh must be non-NULL as well - animation
  471. # meshes may neither add or nor remove vertex components (if
  472. # a replacement array is NULL and the corresponding source
  473. # array is not, the source data is taken instead)
  474. ("mVertices", POINTER(Vector3D)),
  475. # Replacement for aiMesh::mNormals.
  476. ("mNormals", POINTER(Vector3D)),
  477. # Replacement for aiMesh::mTangents.
  478. ("mTangents", POINTER(Vector3D)),
  479. # Replacement for aiMesh::mBitangents.
  480. ("mBitangents", POINTER(Vector3D)),
  481. # Replacement for aiMesh::mColors
  482. ("mColors", POINTER(Color4D) * AI_MAX_NUMBER_OF_COLOR_SETS),
  483. # Replacement for aiMesh::mTextureCoords
  484. ("mTextureCoords", POINTER(Vector3D) * AI_MAX_NUMBER_OF_TEXTURECOORDS),
  485. # The number of vertices in the aiAnimMesh, and thus the length of all
  486. # the member arrays.
  487. #
  488. # This has always the same value as the mNumVertices property in the
  489. # corresponding aiMesh. It is duplicated here merely to make the length
  490. # of the member arrays accessible even if the aiMesh is not known, e.g.
  491. # from language bindings.
  492. ("mNumVertices", c_uint),
  493. # Weight of the AnimMesh.
  494. ("mWeight", c_float),
  495. ]
  496. class Mesh(Structure):
  497. """
  498. See 'mesh.h' for details.
  499. """
  500. AI_MAX_FACE_INDICES = 0x7fff
  501. AI_MAX_BONE_WEIGHTS = 0x7fffffff
  502. AI_MAX_VERTICES = 0x7fffffff
  503. AI_MAX_FACES = 0x7fffffff
  504. AI_MAX_NUMBER_OF_COLOR_SETS = 0x8
  505. AI_MAX_NUMBER_OF_TEXTURECOORDS = 0x8
  506. _fields_ = [ # Bitwise combination of the members of the
  507. #aiPrimitiveType enum.
  508. # This specifies which types of primitives are present in the mesh.
  509. # The "SortByPrimitiveType"-Step can be used to make sure the
  510. # output meshes consist of one primitive type each.
  511. ("mPrimitiveTypes", c_uint),
  512. # The number of vertices in this mesh.
  513. # This is also the size of all of the per-vertex data arrays.
  514. # The maximum value for this member is
  515. #AI_MAX_VERTICES.
  516. ("mNumVertices", c_uint),
  517. # The number of primitives (triangles, polygons, lines) in this mesh.
  518. # This is also the size of the mFaces array.
  519. # The maximum value for this member is
  520. #AI_MAX_FACES.
  521. ("mNumFaces", c_uint),
  522. # Vertex positions.
  523. # This array is always present in a mesh. The array is
  524. # mNumVertices in size.
  525. ("mVertices", POINTER(Vector3D)),
  526. # Vertex normals.
  527. # The array contains normalized vectors, NULL if not present.
  528. # The array is mNumVertices in size. Normals are undefined for
  529. # point and line primitives. A mesh consisting of points and
  530. # lines only may not have normal vectors. Meshes with mixed
  531. # primitive types (i.e. lines and triangles) may have normals,
  532. # but the normals for vertices that are only referenced by
  533. # point or line primitives are undefined and set to QNaN (WARN:
  534. # qNaN compares to inequal to *everything*, even to qNaN itself.
  535. # Using code like this to check whether a field is qnan is:
  536. # @code
  537. #define IS_QNAN(f) (f != f)
  538. # @endcode
  539. # still dangerous because even 1.f == 1.f could evaluate to false! (
  540. # remember the subtleties of IEEE754 artithmetics). Use stuff like
  541. # @c fpclassify instead.
  542. # @note Normal vectors computed by Assimp are always unit-length.
  543. # However, this needn't apply for normals that have been taken
  544. # directly from the model file.
  545. ("mNormals", POINTER(Vector3D)),
  546. # Vertex tangents.
  547. # The tangent of a vertex points in the direction of the positive
  548. # X texture axis. The array contains normalized vectors, NULL if
  549. # not present. The array is mNumVertices in size. A mesh consisting
  550. # of points and lines only may not have normal vectors. Meshes with
  551. # mixed primitive types (i.e. lines and triangles) may have
  552. # normals, but the normals for vertices that are only referenced by
  553. # point or line primitives are undefined and set to qNaN. See
  554. # the
  555. #mNormals member for a detailed discussion of qNaNs.
  556. # @note If the mesh contains tangents, it automatically also
  557. # contains bitangents (the bitangent is just the cross product of
  558. # tangent and normal vectors).
  559. ("mTangents", POINTER(Vector3D)),
  560. # Vertex bitangents.
  561. # The bitangent of a vertex points in the direction of the positive
  562. # Y texture axis. The array contains normalized vectors, NULL if not
  563. # present. The array is mNumVertices in size.
  564. # @note If the mesh contains tangents, it automatically also contains
  565. # bitangents.
  566. ("mBitangents", POINTER(Vector3D)),
  567. # Vertex color sets.
  568. # A mesh may contain 0 to
  569. #AI_MAX_NUMBER_OF_COLOR_SETS vertex
  570. # colors per vertex. NULL if not present. Each array is
  571. # mNumVertices in size if present.
  572. ("mColors", POINTER(Color4D)*AI_MAX_NUMBER_OF_COLOR_SETS),
  573. # Vertex texture coords, also known as UV channels.
  574. # A mesh may contain 0 to AI_MAX_NUMBER_OF_TEXTURECOORDS per
  575. # vertex. NULL if not present. The array is mNumVertices in size.
  576. ("mTextureCoords", POINTER(Vector3D)*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  577. # Specifies the number of components for a given UV channel.
  578. # Up to three channels are supported (UVW, for accessing volume
  579. # or cube maps). If the value is 2 for a given channel n, the
  580. # component p.z of mTextureCoords[n][p] is set to 0.0f.
  581. # If the value is 1 for a given channel, p.y is set to 0.0f, too.
  582. # @note 4D coords are not supported
  583. ("mNumUVComponents", c_uint*AI_MAX_NUMBER_OF_TEXTURECOORDS),
  584. # The faces the mesh is constructed from.
  585. # Each face refers to a number of vertices by their indices.
  586. # This array is always present in a mesh, its size is given
  587. # in mNumFaces. If the
  588. #AI_SCENE_FLAGS_NON_VERBOSE_FORMAT
  589. # is NOT set each face references an unique set of vertices.
  590. ("mFaces", POINTER(Face)),
  591. # The number of bones this mesh contains.
  592. # Can be 0, in which case the mBones array is NULL.
  593. ("mNumBones", c_uint),
  594. # The bones of this mesh.
  595. # A bone consists of a name by which it can be found in the
  596. # frame hierarchy and a set of vertex weights.
  597. ("mBones", POINTER(POINTER(Bone))),
  598. # The material used by this mesh.
  599. # A mesh does use only a single material. If an imported model uses
  600. # multiple materials, the import splits up the mesh. Use this value
  601. # as index into the scene's material list.
  602. ("mMaterialIndex", c_uint),
  603. # Name of the mesh. Meshes can be named, but this is not a
  604. # requirement and leaving this field empty is totally fine.
  605. # There are mainly three uses for mesh names:
  606. # - some formats name nodes and meshes independently.
  607. # - importers tend to split meshes up to meet the
  608. # one-material-per-mesh requirement. Assigning
  609. # the same (dummy) name to each of the result meshes
  610. # aids the caller at recovering the original mesh
  611. # partitioning.
  612. # - Vertex animations refer to meshes by their names.
  613. ("mName", String),
  614. # The number of attachment meshes.
  615. # Currently known to work with loaders:
  616. # - Collada
  617. # - gltf
  618. ("mNumAnimMeshes", c_uint),
  619. # Attachment meshes for this mesh, for vertex-based animation.
  620. # Attachment meshes carry replacement data for some of the
  621. # mesh'es vertex components (usually positions, normals).
  622. # Currently known to work with loaders:
  623. # - Collada
  624. # - gltf
  625. ("mAnimMeshes", POINTER(POINTER(AnimMesh))),
  626. # Method of morphing when animeshes are specified.
  627. ("mMethod", c_uint),
  628. # The bounding box.
  629. ("mAABB", 2 * Vector3D),
  630. # Vertex UV stream names. Pointer to array of size AI_MAX_NUMBER_OF_TEXTURECOORDS
  631. ("mTextureCoordsNames", POINTER(POINTER(String)))
  632. ]
  633. class Camera(Structure):
  634. """
  635. See 'camera.h' for details.
  636. """
  637. _fields_ = [
  638. # The name of the camera.
  639. # There must be a node in the scenegraph with the same name.
  640. # This node specifies the position of the camera in the scene
  641. # hierarchy and can be animated.
  642. ("mName", String),
  643. # Position of the camera relative to the coordinate space
  644. # defined by the corresponding node.
  645. # The default value is 0|0|0.
  646. ("mPosition", Vector3D),
  647. # 'Up' - vector of the camera coordinate system relative to
  648. # the coordinate space defined by the corresponding node.
  649. # The 'right' vector of the camera coordinate system is
  650. # the cross product of the up and lookAt vectors.
  651. # The default value is 0|1|0. The vector
  652. # may be normalized, but it needn't.
  653. ("mUp", Vector3D),
  654. # 'LookAt' - vector of the camera coordinate system relative to
  655. # the coordinate space defined by the corresponding node.
  656. # This is the viewing direction of the user.
  657. # The default value is 0|0|1. The vector
  658. # may be normalized, but it needn't.
  659. ("mLookAt", Vector3D),
  660. # Half horizontal field of view angle, in radians.
  661. # The field of view angle is the angle between the center
  662. # line of the screen and the left or right border.
  663. # The default value is 1/4PI.
  664. ("mHorizontalFOV", c_float),
  665. # Distance of the near clipping plane from the camera.
  666. # The value may not be 0.f (for arithmetic reasons to prevent
  667. # a division through zero). The default value is 0.1f.
  668. ("mClipPlaneNear", c_float),
  669. # Distance of the far clipping plane from the camera.
  670. # The far clipping plane must, of course, be further away than the
  671. # near clipping plane. The default value is 1000.f. The ratio
  672. # between the near and the far plane should not be too
  673. # large (between 1000-10000 should be ok) to avoid floating-point
  674. # inaccuracies which could lead to z-fighting.
  675. ("mClipPlaneFar", c_float),
  676. # Screen aspect ratio.
  677. # This is the ration between the width and the height of the
  678. # screen. Typical values are 4/3, 1/2 or 1/1. This value is
  679. # 0 if the aspect ratio is not defined in the source file.
  680. # 0 is also the default value.
  681. ("mAspect", c_float),
  682. ]
  683. class VectorKey(Structure):
  684. """
  685. See 'anim.h' for details.
  686. """
  687. _fields_ = [
  688. # The time of this key
  689. ("mTime", c_double),
  690. # The value of this key
  691. ("mValue", Vector3D),
  692. ]
  693. class QuatKey(Structure):
  694. """
  695. See 'anim.h' for details.
  696. """
  697. _fields_ = [
  698. # The time of this key
  699. ("mTime", c_double),
  700. # The value of this key
  701. ("mValue", Quaternion),
  702. # The interpolation setting of this key
  703. ("mInterpolation", c_uint32)
  704. ]
  705. class MeshMorphKey(Structure):
  706. """
  707. See 'anim.h' for details.
  708. """
  709. _fields_ = [
  710. # The time of this key
  711. ("mTime", c_double),
  712. # The values and weights at the time of this key
  713. ("mValues", POINTER(c_uint)),
  714. ("mWeights", POINTER(c_double)),
  715. # The number of values and weights
  716. ("mNumValuesAndWeights", c_uint),
  717. ]
  718. class NodeAnim(Structure):
  719. """
  720. See 'anim.h' for details.
  721. """
  722. _fields_ = [
  723. # The name of the node affected by this animation. The node
  724. # must exist and it must be unique.
  725. ("mNodeName", String),
  726. # The number of position keys
  727. ("mNumPositionKeys", c_uint),
  728. # The position keys of this animation channel. Positions are
  729. # specified as 3D vector. The array is mNumPositionKeys in size.
  730. # If there are position keys, there will also be at least one
  731. # scaling and one rotation key.
  732. ("mPositionKeys", POINTER(VectorKey)),
  733. # The number of rotation keys
  734. ("mNumRotationKeys", c_uint),
  735. # The rotation keys of this animation channel. Rotations are
  736. # given as quaternions, which are 4D vectors. The array is
  737. # mNumRotationKeys in size.
  738. # If there are rotation keys, there will also be at least one
  739. # scaling and one position key.
  740. ("mRotationKeys", POINTER(QuatKey)),
  741. # The number of scaling keys
  742. ("mNumScalingKeys", c_uint),
  743. # The scaling keys of this animation channel. Scalings are
  744. # specified as 3D vector. The array is mNumScalingKeys in size.
  745. # If there are scaling keys, there will also be at least one
  746. # position and one rotation key.
  747. ("mScalingKeys", POINTER(VectorKey)),
  748. # Defines how the animation behaves before the first
  749. # key is encountered.
  750. # The default value is aiAnimBehaviour_DEFAULT (the original
  751. # transformation matrix of the affected node is used).
  752. ("mPreState", c_uint),
  753. # Defines how the animation behaves after the last
  754. # key was processed.
  755. # The default value is aiAnimBehaviour_DEFAULT (the original
  756. # transformation matrix of the affected node is taken).
  757. ("mPostState", c_uint),
  758. ]
  759. class MeshAnim(Structure):
  760. """
  761. See 'anim.h' for details.
  762. """
  763. _fields_ = [
  764. # Name of the mesh to be animated. An empty string is not allowed,
  765. # animated meshes need to be named (not necessarily uniquely,
  766. # the name can basically serve as wild-card to select a group
  767. # of meshes with similar animation setup)
  768. ("mName", String),
  769. # Size of the #mKeys array. Must be 1, at least.
  770. ("mNumKeys", c_uint),
  771. # Key frames of the animation. May not be NULL.
  772. ("mKeys", POINTER(MeshKey)),
  773. ]
  774. class MeshMorphAnim(Structure):
  775. """
  776. See 'anim.h' for details.
  777. """
  778. _fields_ = [
  779. # Name of the mesh to be animated. An empty string is not allowed,
  780. # animated meshes need to be named (not necessarily uniquely,
  781. # the name can basically serve as wildcard to select a group
  782. # of meshes with similar animation setup)
  783. ("mName", String),
  784. # Size of the #mKeys array. Must be 1, at least.
  785. ("mNumKeys", c_uint),
  786. # Key frames of the animation. May not be NULL.
  787. ("mKeys", POINTER(MeshMorphKey)),
  788. ]
  789. class Animation(Structure):
  790. """
  791. See 'anim.h' for details.
  792. """
  793. _fields_ = [
  794. # The name of the animation. If the modeling package this data was
  795. # exported from does support only a single animation channel, this
  796. # name is usually empty (length is zero).
  797. ("mName", String),
  798. # Duration of the animation in ticks.
  799. ("mDuration", c_double),
  800. # Ticks per second. 0 if not specified in the imported file
  801. ("mTicksPerSecond", c_double),
  802. # The number of bone animation channels. Each channel affects
  803. # a single node.
  804. ("mNumChannels", c_uint),
  805. # The node animation channels. Each channel affects a single node.
  806. # The array is mNumChannels in size.
  807. ("mChannels", POINTER(POINTER(NodeAnim))),
  808. # The number of mesh animation channels. Each channel affects
  809. # a single mesh and defines vertex-based animation.
  810. ("mNumMeshChannels", c_uint),
  811. # The mesh animation channels. Each channel affects a single mesh.
  812. # The array is mNumMeshChannels in size.
  813. ("mMeshChannels", POINTER(POINTER(MeshAnim))),
  814. # The number of mesh animation channels. Each channel affects
  815. # a single mesh and defines morphing animation.
  816. ("mNumMorphMeshChannels", c_uint),
  817. # The morph mesh animation channels. Each channel affects a single mesh.
  818. # The array is mNumMorphMeshChannels in size.
  819. ("mMorphMeshChannels", POINTER(POINTER(MeshMorphAnim))),
  820. ]
  821. class SkeletonBone(Structure):
  822. """
  823. See 'mesh.h' for details
  824. """
  825. _fields_ = [
  826. # The parent bone index, is -1 one if this bone represents the root bone.
  827. ("mParent", c_int),
  828. # The number of weights
  829. ("mNumnWeights", c_uint),
  830. # The mesh index, which will get influenced by the weight
  831. ("mMeshId", POINTER(Mesh)),
  832. # The influence weights of this bone, by vertex index.
  833. ("mWeights", POINTER(VertexWeight)),
  834. # Matrix that transforms from bone space to mesh space in bind pose.
  835. #
  836. # This matrix describes the position of the mesh
  837. # in the local space of this bone when the skeleton was bound.
  838. # Thus it can be used directly to determine a desired vertex position,
  839. # given the world-space transform of the bone when animated,
  840. # and the position of the vertex in mesh space.
  841. #
  842. # It is sometimes called an inverse-bind matrix,
  843. # or inverse bind pose matrix
  844. ("mOffsetMatrix", Matrix4x4),
  845. # Matrix that transforms the locale bone in bind pose.
  846. ("mLocalMatrix", Matrix4x4)
  847. ]
  848. class Skeleton(Structure):
  849. """
  850. See 'mesh.h' for details
  851. """
  852. _fields_ = [
  853. # Name
  854. ("mName", String),
  855. # Number of bones
  856. ("mNumBones", c_uint),
  857. # Bones
  858. ("mBones", POINTER(POINTER(SkeletonBone)))
  859. ]
  860. class ExportDataBlob(Structure):
  861. """
  862. See 'cexport.h' for details.
  863. Note that the '_fields_' definition is outside the class to allow the 'next' field to be recursive
  864. """
  865. pass
  866. ExportDataBlob._fields_ = [
  867. # Size of the data in bytes
  868. ("size", c_size_t),
  869. # The data.
  870. ("data", c_void_p),
  871. # Name of the blob. An empty string always
  872. # indicates the first (and primary) blob,
  873. # which contains the actual file data.
  874. # Any other blobs are auxiliary files produced
  875. # by exporters (i.e. material files). Existence
  876. # of such files depends on the file format. Most
  877. # formats don't split assets across multiple files.
  878. #
  879. # If used, blob names usually contain the file
  880. # extension that should be used when writing
  881. # the data to disc.
  882. ("name", String),
  883. # Pointer to the next blob in the chain or NULL if there is none.
  884. ("next", POINTER(ExportDataBlob)),
  885. ]
  886. class Scene(Structure):
  887. """
  888. See 'aiScene.h' for details.
  889. """
  890. AI_SCENE_FLAGS_INCOMPLETE = 0x1
  891. AI_SCENE_FLAGS_VALIDATED = 0x2
  892. AI_SCENE_FLAGS_VALIDATION_WARNING = 0x4
  893. AI_SCENE_FLAGS_NON_VERBOSE_FORMAT = 0x8
  894. AI_SCENE_FLAGS_TERRAIN = 0x10
  895. AI_SCENE_FLAGS_ALLOW_SHARED = 0x20
  896. _fields_ = [
  897. # Any combination of the AI_SCENE_FLAGS_XXX flags. By default
  898. # this value is 0, no flags are set. Most applications will
  899. # want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
  900. # bit set.
  901. ("mFlags", c_uint),
  902. # The root node of the hierarchy.
  903. # There will always be at least the root node if the import
  904. # was successful (and no special flags have been set).
  905. # Presence of further nodes depends on the format and content
  906. # of the imported file.
  907. ("mRootNode", POINTER(Node)),
  908. # The number of meshes in the scene.
  909. ("mNumMeshes", c_uint),
  910. # The array of meshes.
  911. # Use the indices given in the aiNode structure to access
  912. # this array. The array is mNumMeshes in size. If the
  913. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  914. # be at least ONE material.
  915. ("mMeshes", POINTER(POINTER(Mesh))),
  916. # The number of materials in the scene.
  917. ("mNumMaterials", c_uint),
  918. # The array of materials.
  919. # Use the index given in each aiMesh structure to access this
  920. # array. The array is mNumMaterials in size. If the
  921. # AI_SCENE_FLAGS_INCOMPLETE flag is not set there will always
  922. # be at least ONE material.
  923. ("mMaterials", POINTER(POINTER(Material))),
  924. # The number of animations in the scene.
  925. ("mNumAnimations", c_uint),
  926. # The array of animations.
  927. # All animations imported from the given file are listed here.
  928. # The array is mNumAnimations in size.
  929. ("mAnimations", POINTER(POINTER(Animation))),
  930. # The number of textures embedded into the file
  931. ("mNumTextures", c_uint),
  932. # The array of embedded textures.
  933. # Not many file formats embed their textures into the file.
  934. # An example is Quake's MDL format (which is also used by
  935. # some GameStudio versions)
  936. ("mTextures", POINTER(POINTER(Texture))),
  937. # The number of light sources in the scene. Light sources
  938. # are fully optional, in most cases this attribute will be 0
  939. ("mNumLights", c_uint),
  940. # The array of light sources.
  941. # All light sources imported from the given file are
  942. # listed here. The array is mNumLights in size.
  943. ("mLights", POINTER(POINTER(Light))),
  944. # The number of cameras in the scene. Cameras
  945. # are fully optional, in most cases this attribute will be 0
  946. ("mNumCameras", c_uint),
  947. # The array of cameras.
  948. # All cameras imported from the given file are listed here.
  949. # The array is mNumCameras in size. The first camera in the
  950. # array (if existing) is the default camera view into
  951. # the scene.
  952. ("mCameras", POINTER(POINTER(Camera))),
  953. # This data contains global metadata which belongs to the scene like
  954. # unit-conversions, versions, vendors or other model-specific data. This
  955. # can be used to store format-specific metadata as well.
  956. ("mMetadata", POINTER(Metadata)),
  957. # The name of the scene itself
  958. ("mName", String),
  959. # Number of skeletons
  960. ("mNumSkeletons", c_uint),
  961. # Skeletons
  962. ("mSkeletons", POINTER(POINTER(Skeleton))),
  963. # Internal data, do not touch
  964. ("mPrivate", POINTER(c_char)),
  965. ]
  966. assimp_structs_as_tuple = (Matrix4x4,
  967. Matrix3x3,
  968. Vector2D,
  969. Vector3D,
  970. Color3D,
  971. Color4D,
  972. Quaternion,
  973. Plane,
  974. Texel)