vrshoot
view libs/assimp/FBXDeformer.cpp @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +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 FBXNoteAttribute.cpp
42 * @brief Assimp::FBX::NodeAttribute (and subclasses) implementation
43 */
44 #include "AssimpPCH.h"
46 #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
48 #include "FBXParser.h"
49 #include "FBXDocument.h"
50 #include "FBXImporter.h"
51 #include "FBXImportSettings.h"
52 #include "FBXDocumentUtil.h"
53 #include "FBXProperties.h"
55 namespace Assimp {
56 namespace FBX {
58 using namespace Util;
60 // ------------------------------------------------------------------------------------------------
61 Deformer::Deformer(uint64_t id, const Element& element, const Document& doc, const std::string& name)
62 : Object(id,element,name)
63 {
64 const Scope& sc = GetRequiredScope(element);
66 const std::string& classname = ParseTokenAsString(GetRequiredToken(element,2));
67 props = GetPropertyTable(doc,"Deformer.Fbx" + classname,element,sc,true);
68 }
71 // ------------------------------------------------------------------------------------------------
72 Deformer::~Deformer()
73 {
75 }
78 // ------------------------------------------------------------------------------------------------
79 Cluster::Cluster(uint64_t id, const Element& element, const Document& doc, const std::string& name)
80 : Deformer(id,element,doc,name)
81 , node()
82 {
83 const Scope& sc = GetRequiredScope(element);
85 const Element* const Indexes = sc["Indexes"];
86 const Element* const Weights = sc["Weights"];
88 const Element& Transform = GetRequiredElement(sc,"Transform",&element);
89 const Element& TransformLink = GetRequiredElement(sc,"TransformLink",&element);
91 transform = ReadMatrix(Transform);
92 transformLink = ReadMatrix(TransformLink);
94 // it is actually possible that there be Deformer's with no weights
95 if (!!Indexes != !!Weights) {
96 DOMError("either Indexes or Weights are missing from Cluster",&element);
97 }
99 if(Indexes) {
100 ParseVectorDataArray(indices,*Indexes);
101 ParseVectorDataArray(weights,*Weights);
102 }
104 if(indices.size() != weights.size()) {
105 DOMError("sizes of index and weight array don't match up",&element);
106 }
108 // read assigned node
109 const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"Model");
110 BOOST_FOREACH(const Connection* con, conns) {
111 const Model* const mod = ProcessSimpleConnection<Model>(*con, false, "Model -> Cluster", element);
112 if(mod) {
113 node = mod;
114 break;
115 }
116 }
118 if (!node) {
119 DOMError("failed to read target Node for Cluster",&element);
120 }
121 }
124 // ------------------------------------------------------------------------------------------------
125 Cluster::~Cluster()
126 {
128 }
131 // ------------------------------------------------------------------------------------------------
132 Skin::Skin(uint64_t id, const Element& element, const Document& doc, const std::string& name)
133 : Deformer(id,element,doc,name)
134 {
135 const Scope& sc = GetRequiredScope(element);
137 const Element* const Link_DeformAcuracy = sc["Link_DeformAcuracy"];
138 if(Link_DeformAcuracy) {
139 accuracy = ParseTokenAsFloat(GetRequiredToken(*Link_DeformAcuracy,0));
140 }
142 // resolve assigned clusters
143 const std::vector<const Connection*>& conns = doc.GetConnectionsByDestinationSequenced(ID(),"Deformer");
145 clusters.reserve(conns.size());
146 BOOST_FOREACH(const Connection* con, conns) {
148 const Cluster* const cluster = ProcessSimpleConnection<Cluster>(*con, false, "Cluster -> Skin", element);
149 if(cluster) {
150 clusters.push_back(cluster);
151 continue;
152 }
153 }
154 }
157 // ------------------------------------------------------------------------------------------------
158 Skin::~Skin()
159 {
161 }
165 }
166 }
168 #endif