Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

243 Zeilen
6.2 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 LWSLoader.h
  34. * @brief Declaration of the LightWave scene importer class.
  35. */
  36. #ifndef AI_LWSLOADER_H_INCLUDED
  37. #define AI_LWSLOADER_H_INCLUDED
  38. #include "LWOFileData.h"
  39. #include "SceneCombiner.h"
  40. namespace Assimp {
  41. namespace LWS {
  42. // ---------------------------------------------------------------------------
  43. /** Represents an element in a LWS file.
  44. *
  45. * This can either be a single data line - <name> <value> or a data
  46. * group - { name <data_line0> ... n }
  47. */
  48. class Element
  49. {
  50. public:
  51. Element()
  52. {}
  53. // first: name, second: rest
  54. std::string tokens[2];
  55. std::list<Element> children;
  56. //! Recursive parsing function
  57. void Parse (const char*& buffer);
  58. };
  59. #define AI_LWS_MASK (0xffffffff >> 4u)
  60. // ---------------------------------------------------------------------------
  61. /** Represents a LWS scenegraph element
  62. */
  63. struct NodeDesc
  64. {
  65. NodeDesc()
  66. : number (0)
  67. , parent (0)
  68. , name ("")
  69. , isPivotSet (false)
  70. , lightColor (1.f,1.f,1.f)
  71. , lightIntensity (1.f)
  72. , lightType (0)
  73. , lightFalloffType (0)
  74. , lightConeAngle (45.f)
  75. , parent_resolved (NULL)
  76. {}
  77. enum {
  78. OBJECT = 1,
  79. LIGHT = 2,
  80. CAMERA = 3,
  81. BONE = 4
  82. } type; // type of node
  83. // if object: path
  84. std::string path;
  85. unsigned int id;
  86. // number of object
  87. unsigned int number;
  88. // index of parent index
  89. unsigned int parent;
  90. // lights & cameras & dummies: name
  91. const char* name;
  92. // animation channels
  93. std::list< LWO::Envelope > channels;
  94. // position of pivot point
  95. aiVector3D pivotPos;
  96. bool isPivotSet;
  97. // color of light source
  98. aiColor3D lightColor;
  99. // intensity of light source
  100. float lightIntensity;
  101. // type of light source
  102. unsigned int lightType;
  103. // falloff type of light source
  104. unsigned int lightFalloffType;
  105. // cone angle of (spot) light source
  106. float lightConeAngle;
  107. // soft cone angle of (spot) light source
  108. float lightEdgeAngle;
  109. // list of resolved children
  110. std::list< NodeDesc* > children;
  111. // resolved parent node
  112. NodeDesc* parent_resolved;
  113. // for std::find()
  114. bool operator == (unsigned int num) const {
  115. if (!num)
  116. return false;
  117. unsigned int _type = num >> 28u;
  118. return _type == static_cast<unsigned int>(type) && (num & AI_LWS_MASK) == number;
  119. }
  120. };
  121. } // end namespace LWS
  122. // ---------------------------------------------------------------------------
  123. /** LWS (LightWave Scene Format) importer class.
  124. *
  125. * This class does heavily depend on the LWO importer class. LWS files
  126. * contain mainly descriptions how LWO objects are composed together
  127. * in a scene.
  128. */
  129. class LWSImporter : public BaseImporter
  130. {
  131. public:
  132. LWSImporter();
  133. ~LWSImporter();
  134. public:
  135. // -------------------------------------------------------------------
  136. // Check whether we can read a specific file
  137. bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
  138. bool checkSig) const;
  139. protected:
  140. // -------------------------------------------------------------------
  141. // Get list of supported extensions
  142. const aiImporterDesc* GetInfo () const;
  143. // -------------------------------------------------------------------
  144. // Import file into given scene data structure
  145. void InternReadFile( const std::string& pFile, aiScene* pScene,
  146. IOSystem* pIOHandler);
  147. // -------------------------------------------------------------------
  148. // Setup import properties
  149. void SetupProperties(const Importer* pImp);
  150. private:
  151. // -------------------------------------------------------------------
  152. // Read an envelope description
  153. void ReadEnvelope(const LWS::Element& dad, LWO::Envelope& out );
  154. // -------------------------------------------------------------------
  155. // Read an envelope description for the older LW file format
  156. void ReadEnvelope_Old(std::list< LWS::Element >::const_iterator& it,
  157. const std::list< LWS::Element >::const_iterator& end,
  158. LWS::NodeDesc& nodes,
  159. unsigned int version);
  160. // -------------------------------------------------------------------
  161. // Setup a nice name for a node
  162. void SetupNodeName(aiNode* nd, LWS::NodeDesc& src);
  163. // -------------------------------------------------------------------
  164. // Recursively build the scenegraph
  165. void BuildGraph(aiNode* nd,
  166. LWS::NodeDesc& src,
  167. std::vector<AttachmentInfo>& attach,
  168. BatchLoader& batch,
  169. aiCamera**& camOut,
  170. aiLight**& lightOut,
  171. std::vector<aiNodeAnim*>& animOut);
  172. // -------------------------------------------------------------------
  173. // Try several dirs until we find the right location of a LWS file.
  174. std::string FindLWOFile(const std::string& in);
  175. private:
  176. bool configSpeedFlag;
  177. IOSystem* io;
  178. double first,last,fps;
  179. bool noSkeletonMesh;
  180. };
  181. } // end of namespace Assimp
  182. #endif // AI_LWSIMPORTER_H_INC