lldaeloader.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. * @file lldaeloader.h
  3. * @brief LLDAELoader class definition
  4. *
  5. * $LicenseInfo:firstyear=2013&license=viewergpl$
  6. *
  7. * Copyright (c) 2013, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLDAELOADER_H
  33. #define LL_LLDAELOADER_H
  34. #include "llmodelloader.h"
  35. class DAE;
  36. class daeElement;
  37. class domProfile_COMMON;
  38. class domInstance_geometry;
  39. class domNode;
  40. class domTranslate;
  41. class domController;
  42. class domSkin;
  43. class domMesh;
  44. class LLDAELoader final : public LLModelLoader
  45. {
  46. public:
  47. typedef std::map<std::string, LLImportMaterial> material_map;
  48. typedef std::map<daeElement*, std::vector<LLPointer<LLModel> > > dae_model_map;
  49. dae_model_map mModelsMap;
  50. LLDAELoader(const std::string& filename, S32 lod,
  51. LLModelLoader::load_callback_t load_cb,
  52. LLModelLoader::joint_lookup_func_t joint_lookup_func,
  53. LLModelLoader::texture_load_func_t texture_load_func,
  54. LLModelLoader::state_callback_t state_cb, void* userdata,
  55. JointTransformMap& joint_transform_map,
  56. JointNameSet& joints_from_nodes,
  57. std::map<std::string, std::string>& joint_alias_map,
  58. U32 max_joints_per_mesh, U32 model_limit, bool preprocess);
  59. bool openFile(const std::string& filename) override;
  60. protected:
  61. void processElement(daeElement* element, bool& badElement, DAE* dae);
  62. void processDomModel(LLModel* modelp, DAE* dae, daeElement* rootp,
  63. domMesh* meshp, domSkin* skinp);
  64. material_map getMaterials(LLModel* model,
  65. domInstance_geometry* instance_geo, DAE* dae);
  66. LLImportMaterial profileToMaterial(domProfile_COMMON* material, DAE* dae);
  67. LLColor4 getDaeColor(daeElement* element);
  68. daeElement* getChildFromElement(daeElement* elementp,
  69. const std::string& name);
  70. bool isNodeAJoint(domNode* nodep);
  71. void processJointNode(domNode* nodep,
  72. std::map<std::string,LLMatrix4>& jointTransforms);
  73. void extractTranslation(domTranslate* translatep, LLMatrix4& transform);
  74. void extractTranslationViaElement(daeElement* translate_elemp,
  75. LLMatrix4& transform);
  76. void extractTranslationViaSID(daeElement* elementp, LLMatrix4& transform);
  77. void buildJointToNodeMappingFromScene(daeElement* rootp);
  78. void processJointToNodeMapping(domNode* nodep);
  79. void processChildJoints(domNode* parent_nodep);
  80. bool verifyCount(S32 expected, S32 result);
  81. // Verify that a controller matches vertex counts
  82. bool verifyController(domController* controllerp);
  83. static bool addVolumeFacesFromDomMesh(LLModel* modelp, domMesh* meshp,
  84. LLSD& log_msg);
  85. // Loads a mesh breaking it into one or more models as necessary to get
  86. // around volume face limitations while retaining > 8 materials
  87. bool loadModelsFromDomMesh(domMesh* meshp,
  88. std::vector<LLModel*>& models_out,
  89. U32 submodel_limit);
  90. static std::string getElementLabel(daeElement* elementp);
  91. static size_t getSuffixPosition(const std::string& label);
  92. static std::string getLodlessLabel(daeElement* elementp);
  93. static std::string preprocessDAE(const std::string& filename);
  94. private:
  95. // Attempt to limit amount of generated submodels
  96. U32 mGeneratedModelLimit;
  97. bool mPreprocessDAE;
  98. };
  99. #endif // LL_LLDAELLOADER_H