1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2017, assimp team
6 
7 All rights reserved.
8 
9 Redistribution and use of this software in source and binary forms,
10 with or without modification, are permitted provided that the
11 following conditions are met:
12 
13 * Redistributions of source code must retain the above
14   copyright notice, this list of conditions and the
15   following disclaimer.
16 
17 * Redistributions in binary form must reproduce the above
18   copyright notice, this list of conditions and the
19   following disclaimer in the documentation and/or other
20   materials provided with the distribution.
21 
22 * Neither the name of the assimp team, nor the names of its
23   contributors may be used to endorse or promote products
24   derived from this software without specific prior
25   written permission of the assimp team.
26 
27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 ----------------------------------------------------------------------
40 */
41 
42 /** @file  FBXNoteAttribute.cpp
43  *  @brief Assimp::FBX::NodeAttribute (and subclasses) implementation
44  */
45 
46 #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
47 
48 #include "FBXParser.h"
49 #include "FBXDocument.h"
50 #include "FBXImporter.h"
51 #include "FBXDocumentUtil.h"
52 
53 namespace Assimp {
54 namespace FBX {
55 
56 using namespace Util;
57 
58 // ------------------------------------------------------------------------------------------------
NodeAttribute(uint64_t id,const Element & element,const Document & doc,const std::string & name)59 NodeAttribute::NodeAttribute(uint64_t id, const Element& element, const Document& doc, const std::string& name)
60 : Object(id,element,name)
61 , props()
62 {
63     const Scope& sc = GetRequiredScope(element);
64 
65     const std::string& classname = ParseTokenAsString(GetRequiredToken(element,2));
66 
67     // hack on the deriving type but Null/LimbNode attributes are the only case in which
68     // the property table is by design absent and no warning should be generated
69     // for it.
70     const bool is_null_or_limb = !strcmp(classname.c_str(), "Null") || !strcmp(classname.c_str(), "LimbNode");
71     props = GetPropertyTable(doc,"NodeAttribute.Fbx" + classname,element,sc, is_null_or_limb);
72 }
73 
74 
75 // ------------------------------------------------------------------------------------------------
~NodeAttribute()76 NodeAttribute::~NodeAttribute()
77 {
78     // empty
79 }
80 
81 
82 // ------------------------------------------------------------------------------------------------
CameraSwitcher(uint64_t id,const Element & element,const Document & doc,const std::string & name)83 CameraSwitcher::CameraSwitcher(uint64_t id, const Element& element, const Document& doc, const std::string& name)
84     : NodeAttribute(id,element,doc,name)
85 {
86     const Scope& sc = GetRequiredScope(element);
87     const Element* const CameraId = sc["CameraId"];
88     const Element* const CameraName = sc["CameraName"];
89     const Element* const CameraIndexName = sc["CameraIndexName"];
90 
91     if(CameraId) {
92         cameraId = ParseTokenAsInt(GetRequiredToken(*CameraId,0));
93     }
94 
95     if(CameraName) {
96         cameraName = GetRequiredToken(*CameraName,0).StringContents();
97     }
98 
99     if(CameraIndexName && CameraIndexName->Tokens().size()) {
100         cameraIndexName = GetRequiredToken(*CameraIndexName,0).StringContents();
101     }
102 }
103 
104 // ------------------------------------------------------------------------------------------------
~CameraSwitcher()105 CameraSwitcher::~CameraSwitcher()
106 {
107     // empty
108 }
109 
110 // ------------------------------------------------------------------------------------------------
Camera(uint64_t id,const Element & element,const Document & doc,const std::string & name)111 Camera::Camera(uint64_t id, const Element& element, const Document& doc, const std::string& name)
112 : NodeAttribute(id,element,doc,name)
113 {
114     // empty
115 }
116 
117 // ------------------------------------------------------------------------------------------------
~Camera()118 Camera::~Camera()
119 {
120     // empty
121 }
122 
123 // ------------------------------------------------------------------------------------------------
Light(uint64_t id,const Element & element,const Document & doc,const std::string & name)124 Light::Light(uint64_t id, const Element& element, const Document& doc, const std::string& name)
125 : NodeAttribute(id,element,doc,name)
126 {
127     // empty
128 }
129 
130 
131 // ------------------------------------------------------------------------------------------------
~Light()132 Light::~Light()
133 {
134 }
135 
136 
137 // ------------------------------------------------------------------------------------------------
Null(uint64_t id,const Element & element,const Document & doc,const std::string & name)138 Null::Null(uint64_t id, const Element& element, const Document& doc, const std::string& name)
139 : NodeAttribute(id,element,doc,name)
140 {
141 
142 }
143 
144 
145 // ------------------------------------------------------------------------------------------------
~Null()146 Null::~Null()
147 {
148 
149 }
150 
151 
152 // ------------------------------------------------------------------------------------------------
LimbNode(uint64_t id,const Element & element,const Document & doc,const std::string & name)153 LimbNode::LimbNode(uint64_t id, const Element& element, const Document& doc, const std::string& name)
154 : NodeAttribute(id,element,doc,name)
155 {
156 
157 }
158 
159 
160 // ------------------------------------------------------------------------------------------------
~LimbNode()161 LimbNode::~LimbNode()
162 {
163 
164 }
165 
166 }
167 }
168 
169 #endif
170