您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

758 行
18 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file BlenderScene.h
  34. * @brief Intermediate representation of a BLEND scene.
  35. */
  36. #ifndef INCLUDED_AI_BLEND_SCENE_H
  37. #define INCLUDED_AI_BLEND_SCENE_H
  38. namespace Assimp {
  39. namespace Blender {
  40. // Minor parts of this file are extracts from blender data structures,
  41. // declared in the ./source/blender/makesdna directory.
  42. // Stuff that is not used by Assimp is commented.
  43. // NOTE
  44. // this file serves as input data to the `./scripts/genblenddna.py`
  45. // script. This script generates the actual binding code to read a
  46. // blender file with a possibly different DNA into our structures.
  47. // Only `struct` declarations are considered and the following
  48. // rules must be obeyed in order for the script to work properly:
  49. //
  50. // * C++ style comments only
  51. //
  52. // * Structures may include the primitive types char, int, short,
  53. // float, double. Signedness specifiers are not allowed on
  54. // integers. Enum types are allowed, but they must have been
  55. // defined in this header.
  56. //
  57. // * Structures may aggregate other structures, unless not defined
  58. // in this header.
  59. //
  60. // * Pointers to other structures or primitive types are allowed.
  61. // No references or double pointers or arrays of pointers.
  62. // A pointer to a T is normally written as boost::shared_ptr, while a
  63. // pointer to an array of elements is written as boost::
  64. // shared_array. To avoid cyclic pointers, use raw pointers in
  65. // one direction.
  66. //
  67. // * Arrays can have maximally two-dimensions. Any non-pointer
  68. // type can form them.
  69. //
  70. // * Multiple fields can be declare in a single line (i.e `int a,b;`)
  71. // provided they are neither pointers nor arrays.
  72. //
  73. // * One of WARN, FAIL can be appended to the declaration (
  74. // prior to the semiolon to specifiy the error handling policy if
  75. // this field is missing in the input DNA). If none of those
  76. // is specified the default policy is to subtitute a default
  77. // value for the field.
  78. //
  79. #define WARN // warn if field is missing, substitute default value
  80. #define FAIL // fail the import if the field does not exist
  81. struct Object;
  82. struct MTex;
  83. struct Image;
  84. #define AI_BLEND_MESH_MAX_VERTS 2000000000L
  85. // -------------------------------------------------------------------------------
  86. struct ID : ElemBase {
  87. char name[24] WARN;
  88. short flag;
  89. };
  90. // -------------------------------------------------------------------------------
  91. struct ListBase : ElemBase {
  92. boost::shared_ptr<ElemBase> first;
  93. boost::shared_ptr<ElemBase> last;
  94. };
  95. // -------------------------------------------------------------------------------
  96. struct PackedFile : ElemBase {
  97. int size WARN;
  98. int seek WARN;
  99. boost::shared_ptr< FileOffset > data WARN;
  100. };
  101. // -------------------------------------------------------------------------------
  102. struct GroupObject : ElemBase {
  103. boost::shared_ptr<GroupObject> prev,next FAIL;
  104. boost::shared_ptr<Object> ob;
  105. };
  106. // -------------------------------------------------------------------------------
  107. struct Group : ElemBase {
  108. ID id FAIL;
  109. int layer;
  110. boost::shared_ptr<GroupObject> gobject;
  111. };
  112. // -------------------------------------------------------------------------------
  113. struct World : ElemBase {
  114. ID id FAIL;
  115. };
  116. // -------------------------------------------------------------------------------
  117. struct MVert : ElemBase {
  118. float co[3] FAIL;
  119. float no[3] FAIL;
  120. char flag;
  121. int mat_nr WARN;
  122. int bweight;
  123. };
  124. // -------------------------------------------------------------------------------
  125. struct MEdge : ElemBase {
  126. int v1, v2 FAIL;
  127. char crease, bweight;
  128. short flag;
  129. };
  130. // -------------------------------------------------------------------------------
  131. struct MLoop : ElemBase {
  132. int v, e;
  133. };
  134. // -------------------------------------------------------------------------------
  135. struct MLoopUV : ElemBase {
  136. float uv[2];
  137. int flag;
  138. };
  139. // -------------------------------------------------------------------------------
  140. // Note that red and blue are not swapped, as with MCol
  141. struct MLoopCol : ElemBase {
  142. char r, g, b, a;
  143. };
  144. // -------------------------------------------------------------------------------
  145. struct MPoly : ElemBase {
  146. int loopstart;
  147. int totloop;
  148. short mat_nr;
  149. char flag;
  150. };
  151. // -------------------------------------------------------------------------------
  152. struct MTexPoly : ElemBase {
  153. Image* tpage;
  154. char flag, transp;
  155. short mode, tile, pad;
  156. };
  157. // -------------------------------------------------------------------------------
  158. struct MCol : ElemBase {
  159. char r,g,b,a FAIL;
  160. };
  161. // -------------------------------------------------------------------------------
  162. struct MFace : ElemBase {
  163. int v1,v2,v3,v4 FAIL;
  164. int mat_nr FAIL;
  165. char flag;
  166. };
  167. // -------------------------------------------------------------------------------
  168. struct TFace : ElemBase {
  169. float uv[4][2] FAIL;
  170. int col[4] FAIL;
  171. char flag;
  172. short mode;
  173. short tile;
  174. short unwrap;
  175. };
  176. // -------------------------------------------------------------------------------
  177. struct MTFace : ElemBase {
  178. float uv[4][2] FAIL;
  179. char flag;
  180. short mode;
  181. short tile;
  182. short unwrap;
  183. // boost::shared_ptr<Image> tpage;
  184. };
  185. // -------------------------------------------------------------------------------
  186. struct MDeformWeight : ElemBase {
  187. int def_nr FAIL;
  188. float weight FAIL;
  189. };
  190. // -------------------------------------------------------------------------------
  191. struct MDeformVert : ElemBase {
  192. vector<MDeformWeight> dw WARN;
  193. int totweight;
  194. };
  195. // -------------------------------------------------------------------------------
  196. struct Material : ElemBase {
  197. ID id FAIL;
  198. float r,g,b WARN;
  199. float specr,specg,specb WARN;
  200. short har;
  201. float ambr,ambg,ambb WARN;
  202. float mirr,mirg,mirb;
  203. float emit WARN;
  204. float alpha WARN;
  205. float ref;
  206. float translucency;
  207. float roughness;
  208. float darkness;
  209. float refrac;
  210. boost::shared_ptr<Group> group;
  211. short diff_shader WARN;
  212. short spec_shader WARN;
  213. boost::shared_ptr<MTex> mtex[18];
  214. };
  215. // -------------------------------------------------------------------------------
  216. struct Mesh : ElemBase {
  217. ID id FAIL;
  218. int totface FAIL;
  219. int totedge FAIL;
  220. int totvert FAIL;
  221. int totloop;
  222. int totpoly;
  223. short subdiv;
  224. short subdivr;
  225. short subsurftype;
  226. short smoothresh;
  227. vector<MFace> mface FAIL;
  228. vector<MTFace> mtface;
  229. vector<TFace> tface;
  230. vector<MVert> mvert FAIL;
  231. vector<MEdge> medge WARN;
  232. vector<MLoop> mloop;
  233. vector<MLoopUV> mloopuv;
  234. vector<MLoopCol> mloopcol;
  235. vector<MPoly> mpoly;
  236. vector<MTexPoly> mtpoly;
  237. vector<MDeformVert> dvert;
  238. vector<MCol> mcol;
  239. vector< boost::shared_ptr<Material> > mat FAIL;
  240. };
  241. // -------------------------------------------------------------------------------
  242. struct Library : ElemBase {
  243. ID id FAIL;
  244. char name[240] WARN;
  245. char filename[240] FAIL;
  246. boost::shared_ptr<Library> parent WARN;
  247. };
  248. // -------------------------------------------------------------------------------
  249. struct Camera : ElemBase {
  250. enum Type {
  251. Type_PERSP = 0
  252. ,Type_ORTHO = 1
  253. };
  254. ID id FAIL;
  255. // struct AnimData *adt;
  256. Type type,flag WARN;
  257. float angle WARN;
  258. //float passepartalpha, angle;
  259. //float clipsta, clipend;
  260. //float lens, ortho_scale, drawsize;
  261. //float shiftx, shifty;
  262. //float YF_dofdist, YF_aperture;
  263. //short YF_bkhtype, YF_bkhbias;
  264. //float YF_bkhrot;
  265. };
  266. // -------------------------------------------------------------------------------
  267. struct Lamp : ElemBase {
  268. enum FalloffType {
  269. FalloffType_Constant = 0x0
  270. ,FalloffType_InvLinear = 0x1
  271. ,FalloffType_InvSquare = 0x2
  272. //,FalloffType_Curve = 0x3
  273. //,FalloffType_Sliders = 0x4
  274. };
  275. enum Type {
  276. Type_Local = 0x0
  277. ,Type_Sun = 0x1
  278. ,Type_Spot = 0x2
  279. ,Type_Hemi = 0x3
  280. ,Type_Area = 0x4
  281. //,Type_YFPhoton = 0x5
  282. };
  283. ID id FAIL;
  284. //AnimData *adt;
  285. Type type FAIL;
  286. short flags;
  287. //int mode;
  288. short colormodel, totex;
  289. float r,g,b,k WARN;
  290. //float shdwr, shdwg, shdwb;
  291. float energy, dist, spotsize, spotblend;
  292. //float haint;
  293. float att1, att2;
  294. //struct CurveMapping *curfalloff;
  295. FalloffType falloff_type;
  296. //float clipsta, clipend, shadspotsize;
  297. //float bias, soft, compressthresh;
  298. //short bufsize, samp, buffers, filtertype;
  299. //char bufflag, buftype;
  300. //short ray_samp, ray_sampy, ray_sampz;
  301. //short ray_samp_type;
  302. //short area_shape;
  303. //float area_size, area_sizey, area_sizez;
  304. //float adapt_thresh;
  305. //short ray_samp_method;
  306. //short texact, shadhalostep;
  307. //short sun_effect_type;
  308. //short skyblendtype;
  309. //float horizon_brightness;
  310. //float spread;
  311. float sun_brightness;
  312. //float sun_size;
  313. //float backscattered_light;
  314. //float sun_intensity;
  315. //float atm_turbidity;
  316. //float atm_inscattering_factor;
  317. //float atm_extinction_factor;
  318. //float atm_distance_factor;
  319. //float skyblendfac;
  320. //float sky_exposure;
  321. //short sky_colorspace;
  322. // int YF_numphotons, YF_numsearch;
  323. // short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;
  324. // float YF_causticblur, YF_ltradius;
  325. // float YF_glowint, YF_glowofs;
  326. // short YF_glowtype, YF_pad2;
  327. //struct Ipo *ipo;
  328. //struct MTex *mtex[18];
  329. // short pr_texture;
  330. //struct PreviewImage *preview;
  331. };
  332. // -------------------------------------------------------------------------------
  333. struct ModifierData : ElemBase {
  334. enum ModifierType {
  335. eModifierType_None = 0,
  336. eModifierType_Subsurf,
  337. eModifierType_Lattice,
  338. eModifierType_Curve,
  339. eModifierType_Build,
  340. eModifierType_Mirror,
  341. eModifierType_Decimate,
  342. eModifierType_Wave,
  343. eModifierType_Armature,
  344. eModifierType_Hook,
  345. eModifierType_Softbody,
  346. eModifierType_Boolean,
  347. eModifierType_Array,
  348. eModifierType_EdgeSplit,
  349. eModifierType_Displace,
  350. eModifierType_UVProject,
  351. eModifierType_Smooth,
  352. eModifierType_Cast,
  353. eModifierType_MeshDeform,
  354. eModifierType_ParticleSystem,
  355. eModifierType_ParticleInstance,
  356. eModifierType_Explode,
  357. eModifierType_Cloth,
  358. eModifierType_Collision,
  359. eModifierType_Bevel,
  360. eModifierType_Shrinkwrap,
  361. eModifierType_Fluidsim,
  362. eModifierType_Mask,
  363. eModifierType_SimpleDeform,
  364. eModifierType_Multires,
  365. eModifierType_Surface,
  366. eModifierType_Smoke,
  367. eModifierType_ShapeKey
  368. };
  369. boost::shared_ptr<ElemBase> next WARN;
  370. boost::shared_ptr<ElemBase> prev WARN;
  371. int type, mode;
  372. char name[32];
  373. };
  374. // -------------------------------------------------------------------------------
  375. struct SubsurfModifierData : ElemBase {
  376. enum Type {
  377. TYPE_CatmullClarke = 0x0,
  378. TYPE_Simple = 0x1
  379. };
  380. enum Flags {
  381. // some omitted
  382. FLAGS_SubsurfUV =1<<3
  383. };
  384. ModifierData modifier FAIL;
  385. short subdivType WARN;
  386. short levels FAIL;
  387. short renderLevels ;
  388. short flags;
  389. };
  390. // -------------------------------------------------------------------------------
  391. struct MirrorModifierData : ElemBase {
  392. enum Flags {
  393. Flags_CLIPPING =1<<0,
  394. Flags_MIRROR_U =1<<1,
  395. Flags_MIRROR_V =1<<2,
  396. Flags_AXIS_X =1<<3,
  397. Flags_AXIS_Y =1<<4,
  398. Flags_AXIS_Z =1<<5,
  399. Flags_VGROUP =1<<6
  400. };
  401. ModifierData modifier FAIL;
  402. short axis, flag;
  403. float tolerance;
  404. boost::shared_ptr<Object> mirror_ob;
  405. };
  406. // -------------------------------------------------------------------------------
  407. struct Object : ElemBase {
  408. ID id FAIL;
  409. enum Type {
  410. Type_EMPTY = 0
  411. ,Type_MESH = 1
  412. ,Type_CURVE = 2
  413. ,Type_SURF = 3
  414. ,Type_FONT = 4
  415. ,Type_MBALL = 5
  416. ,Type_LAMP = 10
  417. ,Type_CAMERA = 11
  418. ,Type_WAVE = 21
  419. ,Type_LATTICE = 22
  420. };
  421. Type type FAIL;
  422. float obmat[4][4] WARN;
  423. float parentinv[4][4] WARN;
  424. char parsubstr[32] WARN;
  425. Object* parent WARN;
  426. boost::shared_ptr<Object> track WARN;
  427. boost::shared_ptr<Object> proxy,proxy_from,proxy_group WARN;
  428. boost::shared_ptr<Group> dup_group WARN;
  429. boost::shared_ptr<ElemBase> data FAIL;
  430. ListBase modifiers;
  431. };
  432. // -------------------------------------------------------------------------------
  433. struct Base : ElemBase {
  434. Base* prev WARN;
  435. boost::shared_ptr<Base> next WARN;
  436. boost::shared_ptr<Object> object WARN;
  437. };
  438. // -------------------------------------------------------------------------------
  439. struct Scene : ElemBase {
  440. ID id FAIL;
  441. boost::shared_ptr<Object> camera WARN;
  442. boost::shared_ptr<World> world WARN;
  443. boost::shared_ptr<Base> basact WARN;
  444. ListBase base;
  445. };
  446. // -------------------------------------------------------------------------------
  447. struct Image : ElemBase {
  448. ID id FAIL;
  449. char name[240] WARN;
  450. //struct anim *anim;
  451. short ok, flag;
  452. short source, type, pad, pad1;
  453. int lastframe;
  454. short tpageflag, totbind;
  455. short xrep, yrep;
  456. short twsta, twend;
  457. //unsigned int bindcode;
  458. //unsigned int *repbind;
  459. boost::shared_ptr<PackedFile> packedfile;
  460. //struct PreviewImage * preview;
  461. float lastupdate;
  462. int lastused;
  463. short animspeed;
  464. short gen_x, gen_y, gen_type;
  465. };
  466. // -------------------------------------------------------------------------------
  467. struct Tex : ElemBase {
  468. // actually, the only texture type we support is Type_IMAGE
  469. enum Type {
  470. Type_CLOUDS = 1
  471. ,Type_WOOD = 2
  472. ,Type_MARBLE = 3
  473. ,Type_MAGIC = 4
  474. ,Type_BLEND = 5
  475. ,Type_STUCCI = 6
  476. ,Type_NOISE = 7
  477. ,Type_IMAGE = 8
  478. ,Type_PLUGIN = 9
  479. ,Type_ENVMAP = 10
  480. ,Type_MUSGRAVE = 11
  481. ,Type_VORONOI = 12
  482. ,Type_DISTNOISE = 13
  483. ,Type_POINTDENSITY = 14
  484. ,Type_VOXELDATA = 15
  485. };
  486. enum ImageFlags {
  487. ImageFlags_INTERPOL = 1
  488. ,ImageFlags_USEALPHA = 2
  489. ,ImageFlags_MIPMAP = 4
  490. ,ImageFlags_IMAROT = 16
  491. ,ImageFlags_CALCALPHA = 32
  492. ,ImageFlags_NORMALMAP = 2048
  493. ,ImageFlags_GAUSS_MIP = 4096
  494. ,ImageFlags_FILTER_MIN = 8192
  495. ,ImageFlags_DERIVATIVEMAP = 16384
  496. };
  497. ID id FAIL;
  498. // AnimData *adt;
  499. //float noisesize, turbul;
  500. //float bright, contrast, rfac, gfac, bfac;
  501. //float filtersize;
  502. //float mg_H, mg_lacunarity, mg_octaves, mg_offset, mg_gain;
  503. //float dist_amount, ns_outscale;
  504. //float vn_w1;
  505. //float vn_w2;
  506. //float vn_w3;
  507. //float vn_w4;
  508. //float vn_mexp;
  509. //short vn_distm, vn_coltype;
  510. //short noisedepth, noisetype;
  511. //short noisebasis, noisebasis2;
  512. //short flag;
  513. ImageFlags imaflag;
  514. Type type FAIL;
  515. //short stype;
  516. //float cropxmin, cropymin, cropxmax, cropymax;
  517. //int texfilter;
  518. //int afmax;
  519. //short xrepeat, yrepeat;
  520. //short extend;
  521. //short fie_ima;
  522. //int len;
  523. //int frames, offset, sfra;
  524. //float checkerdist, nabla;
  525. //float norfac;
  526. //ImageUser iuser;
  527. //bNodeTree *nodetree;
  528. //Ipo *ipo;
  529. boost::shared_ptr<Image> ima WARN;
  530. //PluginTex *plugin;
  531. //ColorBand *coba;
  532. //EnvMap *env;
  533. //PreviewImage * preview;
  534. //PointDensity *pd;
  535. //VoxelData *vd;
  536. //char use_nodes;
  537. };
  538. // -------------------------------------------------------------------------------
  539. struct MTex : ElemBase {
  540. enum Projection {
  541. Proj_N = 0
  542. ,Proj_X = 1
  543. ,Proj_Y = 2
  544. ,Proj_Z = 3
  545. };
  546. enum Flag {
  547. Flag_RGBTOINT = 0x1
  548. ,Flag_STENCIL = 0x2
  549. ,Flag_NEGATIVE = 0x4
  550. ,Flag_ALPHAMIX = 0x8
  551. ,Flag_VIEWSPACE = 0x10
  552. };
  553. enum BlendType {
  554. BlendType_BLEND = 0
  555. ,BlendType_MUL = 1
  556. ,BlendType_ADD = 2
  557. ,BlendType_SUB = 3
  558. ,BlendType_DIV = 4
  559. ,BlendType_DARK = 5
  560. ,BlendType_DIFF = 6
  561. ,BlendType_LIGHT = 7
  562. ,BlendType_SCREEN = 8
  563. ,BlendType_OVERLAY = 9
  564. ,BlendType_BLEND_HUE = 10
  565. ,BlendType_BLEND_SAT = 11
  566. ,BlendType_BLEND_VAL = 12
  567. ,BlendType_BLEND_COLOR = 13
  568. };
  569. enum MapType {
  570. MapType_COL = 1
  571. ,MapType_NORM = 2
  572. ,MapType_COLSPEC = 4
  573. ,MapType_COLMIR = 8
  574. ,MapType_REF = 16
  575. ,MapType_SPEC = 32
  576. ,MapType_EMIT = 64
  577. ,MapType_ALPHA = 128
  578. ,MapType_HAR = 256
  579. ,MapType_RAYMIRR = 512
  580. ,MapType_TRANSLU = 1024
  581. ,MapType_AMB = 2048
  582. ,MapType_DISPLACE = 4096
  583. ,MapType_WARP = 8192
  584. };
  585. // short texco, maptoneg;
  586. MapType mapto;
  587. BlendType blendtype;
  588. boost::shared_ptr<Object> object;
  589. boost::shared_ptr<Tex> tex;
  590. char uvname[32];
  591. Projection projx,projy,projz;
  592. char mapping;
  593. float ofs[3], size[3], rot;
  594. int texflag;
  595. short colormodel, pmapto, pmaptoneg;
  596. //short normapspace, which_output;
  597. //char brush_map_mode;
  598. float r,g,b,k WARN;
  599. //float def_var, rt;
  600. //float colfac, varfac;
  601. float norfac;
  602. //float dispfac, warpfac;
  603. float colspecfac, mirrfac, alphafac;
  604. float difffac, specfac, emitfac, hardfac;
  605. //float raymirrfac, translfac, ambfac;
  606. //float colemitfac, colreflfac, coltransfac;
  607. //float densfac, scatterfac, reflfac;
  608. //float timefac, lengthfac, clumpfac;
  609. //float kinkfac, roughfac, padensfac;
  610. //float lifefac, sizefac, ivelfac, pvelfac;
  611. //float shadowfac;
  612. //float zenupfac, zendownfac, blendfac;
  613. };
  614. }
  615. }
  616. #endif