Mesh Import.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /******************************************************************************
  2. Use 'Import' functions to import data from external file formats.
  3. /******************************************************************************/
  4. struct XMaterial // Material stored in external formats
  5. {
  6. Bool cull , // enable face culling
  7. flip_normal_y; // if flip normal map Y channel
  8. MATERIAL_TECHNIQUE technique; // material technique
  9. Vec4 color ; // color (0,0,0,0) .. (1,1,1,1), default=(1,1,1,1)
  10. Vec ambient , // ambient (0,0,0) .. (1,1,1) , default=(0,0,0)
  11. specular ; // specular (0,0,0) .. (1,1,1) , default=(0,0,0)
  12. Flt sss , // sub-surface scattering 0 .. 1 , default=0
  13. glow , // glow amount 0 .. 1 , default=0
  14. rough , // roughness 0 .. 1 , default=1
  15. bump , // bumpiness 0 .. 0.09 , default=0.03
  16. tex_scale, // texture scale 0 .. Inf , default=1, this is used mainly for World terrain textures scaling
  17. det_scale, // detail scale 0 .. Inf , default=4
  18. det_power, // detail power 0 .. 1 , default=0.3
  19. reflection; // reflection 0 .. 1 , default=0.2
  20. Str color_map, // color texture file name
  21. alpha_map, // alpha texture file name
  22. bump_map, // bump texture file name
  23. glow_map, // glow texture file name
  24. light_map, // light texture file name
  25. normal_map, // normal texture file name
  26. specular_map, // specular texture file name
  27. reflection_map, // reflection texture file name
  28. detail_color_map, // detail color texture file name
  29. detail_bump_map, // detail bump texture file name
  30. detail_normal_map, // detail normal texture file name
  31. detail_specular_map, // detail specular texture file name
  32. name; // material name
  33. void createFrom (C Material &src ) ; // create from 'src' material
  34. void copyParamsTo( Material &mtrl)C; // copy parameters to 'mtrl' material (this does not copy textures)
  35. #if EE_PRIVATE
  36. void del();
  37. void fixPath(Str path);
  38. Bool save(File &f)C;
  39. Bool load(File &f) ;
  40. #endif
  41. XMaterial();
  42. };
  43. /******************************************************************************/
  44. struct XAnimation // Animation stored in external formats
  45. {
  46. Flt fps , // animation frames per second (0 if unknown)
  47. start; // animation start
  48. Str name ; // animation name
  49. Animation anim ; // animation data
  50. XAnimation() {fps=start=0;}
  51. #if EE_PRIVATE
  52. void del() {fps=start=0; name.del(); anim.del();}
  53. Bool save(File &f)C;
  54. Bool load(File &f);
  55. Bool save(C Str &name)C;
  56. Bool load(C Str &name);
  57. void save(MemPtr<TextNode> nodes)C; // save as text
  58. #endif
  59. };
  60. /******************************************************************************/
  61. // Collada - DAE
  62. Bool ImportDAE(C Str &name, Mesh *mesh, Skeleton *skeleton, XAnimation *animation, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from Collada .dae 'name' file, false on fail
  63. // Autodesk FilmBox - FBX
  64. void SetFbxDllPath(C Str &dll_32, C Str &dll_64); // set custom path to FBX DLL files (including path and file name) for 32-bit and 64-bit dll versions (default="Bin/FBX32.dll" and "Bin/FBX64.dll"), this function is used only on Windows platform
  65. Bool ImportFBX(C Str &name, Mesh *mesh, Skeleton *skeleton, MemPtr<XAnimation> animations, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index, MemPtr<Str> bone_names, Bool all_nodes_as_bones=false); // import data from FBX .fbx 'name' file, false on fail
  66. // Microsoft DirectX - X
  67. Bool ImportX(C Str &name, Mesh *mesh, Skeleton *skeleton, MemPtr<XAnimation> animations, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from DirectX .x 'name' file, false on fail
  68. // 3D Studio Max Ascii Scene Export - ASE
  69. Bool ImportASE(C Str &name, Mesh *mesh, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from Ascii Scene Export 'name' file, false on fail
  70. // Wavefront - OBJ
  71. Bool ImportOBJ(C Str &name, Mesh *mesh, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from Wavefront Obj 'name' file, false on fail
  72. Bool ExportOBJ(C Str &name, C MeshLod &mesh); // export to Wavefront Obj 'name' file
  73. // 3D Studio - 3DS
  74. Bool Import3DS(C Str &name, Mesh *mesh, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from 3D Studio 'name' file, false on fail
  75. // Blitz3D - B3D
  76. Bool ImportB3D(C Str &name, Mesh *mesh, Skeleton *skeleton, XAnimation *animation, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from Blitz3D 'name' file, false on fail
  77. // Biovision Motion Capture - BVH
  78. Bool ImportBVH(C Str &name, Skeleton *skeleton, XAnimation *animation); // import data from BVH 'name' file, false on fail
  79. // MilkShape 3D - MS3D
  80. Bool ImportMS3D(C Str &name, Mesh *mesh, Skeleton *skeleton, XAnimation *animation, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from MS3D 'name' file, false on fail
  81. // Unreal Engine Mesh - PSK
  82. Bool ImportPSK(C Str &name, Mesh *mesh, Skeleton *skeleton, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from PSK 'name' file, false on fail
  83. // Unreal Engine Animation - PSA
  84. Bool ImportPSA(C Str &name, Skeleton *skeleton, MemPtr<XAnimation> animations); // import data from PSA 'name' file, false on fail
  85. // Xna Posing Studio - XPS
  86. Bool ImportXPS(C Str &name, Mesh *mesh, Skeleton *skeleton, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index); // import data from XPS 'name' file, false on fail
  87. Bool Import(C Str &name, Mesh *mesh, Skeleton *skeleton, MemPtr<XAnimation> animations, MemPtr<XMaterial> materials, MemPtr<Int> part_material_index, MemPtr<Str> bone_names=null, Bool all_nodes_as_bones=false); // import data according to file extension, false on fail
  88. #if EE_PRIVATE
  89. void RemoveNubBones(Mesh *mesh, Skeleton &skeleton, C MemPtr<Animation*> &animations); // !! does not change mesh bone names !!
  90. void CleanMesh (Mesh &mesh);
  91. #endif
  92. /******************************************************************************/