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