vrshoot

view libs/assimp/LWSLoader.h @ 3:c179c72369be

rename candy->vr
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 03 Feb 2014 08:52:13 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
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:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
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.
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.
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.
38 ----------------------------------------------------------------------
39 */
41 /** @file LWSLoader.h
42 * @brief Declaration of the LightWave scene importer class.
43 */
44 #ifndef AI_LWSLOADER_H_INCLUDED
45 #define AI_LWSLOADER_H_INCLUDED
47 #include "LWOFileData.h"
48 #include "SceneCombiner.h"
50 namespace Assimp {
51 namespace LWS {
53 // ---------------------------------------------------------------------------
54 /** Represents an element in a LWS file.
55 *
56 * This can either be a single data line - <name> <value> or a data
57 * group - { name <data_line0> ... n }
58 */
59 class Element
60 {
61 public:
62 Element()
63 {}
65 // first: name, second: rest
66 std::string tokens[2];
67 std::list<Element> children;
69 //! Recursive parsing function
70 void Parse (const char*& buffer);
71 };
73 #define AI_LWS_MASK (0xffffffff >> 4u)
75 // ---------------------------------------------------------------------------
76 /** Represents a LWS scenegraph element
77 */
78 struct NodeDesc
79 {
80 NodeDesc()
81 : number (0)
82 , parent (0)
83 , name ("")
84 , isPivotSet (false)
85 , lightColor (1.f,1.f,1.f)
86 , lightIntensity (1.f)
87 , lightType (0)
88 , lightFalloffType (0)
89 , lightConeAngle (45.f)
90 , parent_resolved (NULL)
91 {}
93 enum {
95 OBJECT = 1,
96 LIGHT = 2,
97 CAMERA = 3,
98 BONE = 4
99 } type; // type of node
101 // if object: path
102 std::string path;
103 unsigned int id;
105 // number of object
106 unsigned int number;
108 // index of parent index
109 unsigned int parent;
111 // lights & cameras & dummies: name
112 const char* name;
114 // animation channels
115 std::list< LWO::Envelope > channels;
117 // position of pivot point
118 aiVector3D pivotPos;
119 bool isPivotSet;
123 // color of light source
124 aiColor3D lightColor;
126 // intensity of light source
127 float lightIntensity;
129 // type of light source
130 unsigned int lightType;
132 // falloff type of light source
133 unsigned int lightFalloffType;
135 // cone angle of (spot) light source
136 float lightConeAngle;
138 // soft cone angle of (spot) light source
139 float lightEdgeAngle;
143 // list of resolved children
144 std::list< NodeDesc* > children;
146 // resolved parent node
147 NodeDesc* parent_resolved;
150 // for std::find()
151 bool operator == (unsigned int num) const {
152 if (!num)
153 return false;
154 unsigned int _type = num >> 28u;
156 return _type == static_cast<unsigned int>(type) && (num & AI_LWS_MASK) == number;
157 }
158 };
160 } // end namespace LWS
162 // ---------------------------------------------------------------------------
163 /** LWS (LightWave Scene Format) importer class.
164 *
165 * This class does heavily depend on the LWO importer class. LWS files
166 * contain mainly descriptions how LWO objects are composed together
167 * in a scene.
168 */
169 class LWSImporter : public BaseImporter
170 {
171 public:
172 LWSImporter();
173 ~LWSImporter();
176 public:
178 // -------------------------------------------------------------------
179 // Check whether we can read a specific file
180 bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
181 bool checkSig) const;
183 protected:
185 // -------------------------------------------------------------------
186 // Get list of supported extensions
187 const aiImporterDesc* GetInfo () const;
189 // -------------------------------------------------------------------
190 // Import file into given scene data structure
191 void InternReadFile( const std::string& pFile, aiScene* pScene,
192 IOSystem* pIOHandler);
194 // -------------------------------------------------------------------
195 // Setup import properties
196 void SetupProperties(const Importer* pImp);
198 private:
201 // -------------------------------------------------------------------
202 // Read an envelope description
203 void ReadEnvelope(const LWS::Element& dad, LWO::Envelope& out );
205 // -------------------------------------------------------------------
206 // Read an envelope description for the older LW file format
207 void ReadEnvelope_Old(std::list< LWS::Element >::const_iterator& it,
208 const std::list< LWS::Element >::const_iterator& end,
209 LWS::NodeDesc& nodes,
210 unsigned int version);
212 // -------------------------------------------------------------------
213 // Setup a nice name for a node
214 void SetupNodeName(aiNode* nd, LWS::NodeDesc& src);
216 // -------------------------------------------------------------------
217 // Recursively build the scenegraph
218 void BuildGraph(aiNode* nd,
219 LWS::NodeDesc& src,
220 std::vector<AttachmentInfo>& attach,
221 BatchLoader& batch,
222 aiCamera**& camOut,
223 aiLight**& lightOut,
224 std::vector<aiNodeAnim*>& animOut);
226 // -------------------------------------------------------------------
227 // Try several dirs until we find the right location of a LWS file.
228 std::string FindLWOFile(const std::string& in);
230 private:
232 bool configSpeedFlag;
233 IOSystem* io;
235 double first,last,fps;
237 bool noSkeletonMesh;
238 };
240 } // end of namespace Assimp
242 #endif // AI_LWSIMPORTER_H_INC