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