FBXDocument.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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 FBXDocument.cpp
  34. * @brief Implementation of the FBX DOM classes
  35. */
  36. #include "AssimpPCH.h"
  37. #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER
  38. #include <functional>
  39. #include "FBXParser.h"
  40. #include "FBXDocument.h"
  41. #include "FBXUtil.h"
  42. #include "FBXImporter.h"
  43. #include "FBXImportSettings.h"
  44. #include "FBXDocumentUtil.h"
  45. #include "FBXProperties.h"
  46. namespace Assimp {
  47. namespace FBX {
  48. namespace Util {
  49. // ------------------------------------------------------------------------------------------------
  50. // signal DOM construction error, this is always unrecoverable. Throws DeadlyImportError.
  51. void DOMError(const std::string& message, const Token& token)
  52. {
  53. throw DeadlyImportError(Util::AddTokenText("FBX-DOM",message,&token));
  54. }
  55. // ------------------------------------------------------------------------------------------------
  56. void DOMError(const std::string& message, const Element* element /*= NULL*/)
  57. {
  58. if(element) {
  59. DOMError(message,element->KeyToken());
  60. }
  61. throw DeadlyImportError("FBX-DOM " + message);
  62. }
  63. // ------------------------------------------------------------------------------------------------
  64. // print warning, do return
  65. void DOMWarning(const std::string& message, const Token& token)
  66. {
  67. if(DefaultLogger::get()) {
  68. DefaultLogger::get()->warn(Util::AddTokenText("FBX-DOM",message,&token));
  69. }
  70. }
  71. // ------------------------------------------------------------------------------------------------
  72. void DOMWarning(const std::string& message, const Element* element /*= NULL*/)
  73. {
  74. if(element) {
  75. DOMWarning(message,element->KeyToken());
  76. return;
  77. }
  78. if(DefaultLogger::get()) {
  79. DefaultLogger::get()->warn("FBX-DOM: " + message);
  80. }
  81. }
  82. // ------------------------------------------------------------------------------------------------
  83. // extract required compound scope
  84. const Scope& GetRequiredScope(const Element& el)
  85. {
  86. const Scope* const s = el.Compound();
  87. if(!s) {
  88. DOMError("expected compound scope",&el);
  89. }
  90. return *s;
  91. }
  92. // ------------------------------------------------------------------------------------------------
  93. // get token at a particular index
  94. const Token& GetRequiredToken(const Element& el, unsigned int index)
  95. {
  96. const TokenList& t = el.Tokens();
  97. if(index >= t.size()) {
  98. DOMError(Formatter::format( "missing token at index " ) << index,&el);
  99. }
  100. return *t[index];
  101. }
  102. // ------------------------------------------------------------------------------------------------
  103. // wrapper around ParseTokenAsID() with DOMError handling
  104. uint64_t ParseTokenAsID(const Token& t)
  105. {
  106. const char* err;
  107. const uint64_t i = ParseTokenAsID(t,err);
  108. if(err) {
  109. DOMError(err,t);
  110. }
  111. return i;
  112. }
  113. // ------------------------------------------------------------------------------------------------
  114. // wrapper around ParseTokenAsDim() with DOMError handling
  115. size_t ParseTokenAsDim(const Token& t)
  116. {
  117. const char* err;
  118. const size_t i = ParseTokenAsDim(t,err);
  119. if(err) {
  120. DOMError(err,t);
  121. }
  122. return i;
  123. }
  124. // ------------------------------------------------------------------------------------------------
  125. // wrapper around ParseTokenAsFloat() with DOMError handling
  126. float ParseTokenAsFloat(const Token& t)
  127. {
  128. const char* err;
  129. const float i = ParseTokenAsFloat(t,err);
  130. if(err) {
  131. DOMError(err,t);
  132. }
  133. return i;
  134. }
  135. // ------------------------------------------------------------------------------------------------
  136. // wrapper around ParseTokenAsInt() with DOMError handling
  137. int ParseTokenAsInt(const Token& t)
  138. {
  139. const char* err;
  140. const int i = ParseTokenAsInt(t,err);
  141. if(err) {
  142. DOMError(err,t);
  143. }
  144. return i;
  145. }
  146. // ------------------------------------------------------------------------------------------------
  147. // wrapper around ParseTokenAsString() with DOMError handling
  148. std::string ParseTokenAsString(const Token& t)
  149. {
  150. const char* err;
  151. const std::string& i = ParseTokenAsString(t,err);
  152. if(err) {
  153. DOMError(err,t);
  154. }
  155. return i;
  156. }
  157. // ------------------------------------------------------------------------------------------------
  158. // extract a required element from a scope, abort if the element cannot be found
  159. const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element /*= NULL*/)
  160. {
  161. const Element* el = sc[index];
  162. if(!el) {
  163. DOMError("did not find required element \"" + index + "\"",element);
  164. }
  165. return *el;
  166. }
  167. // ------------------------------------------------------------------------------------------------
  168. // read an array of float3 tuples
  169. void ReadVectorDataArray(std::vector<aiVector3D>& out, const Element& el)
  170. {
  171. out.clear();
  172. const TokenList& tok = el.Tokens();
  173. const size_t dim = ParseTokenAsDim(*tok[0]);
  174. // may throw bad_alloc if the input is rubbish, but this need
  175. // not to be prevented - importing would fail but we wouldn't
  176. // crash since assimp handles this case properly.
  177. out.reserve(dim);
  178. const Scope& scope = GetRequiredScope(el);
  179. const Element& a = GetRequiredElement(scope,"a",&el);
  180. if (a.Tokens().size() % 3 != 0) {
  181. DOMError("number of floats is not a multiple of three (3)",&el);
  182. }
  183. for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
  184. aiVector3D v;
  185. v.x = ParseTokenAsFloat(**it++);
  186. v.y = ParseTokenAsFloat(**it++);
  187. v.z = ParseTokenAsFloat(**it++);
  188. out.push_back(v);
  189. }
  190. }
  191. // ------------------------------------------------------------------------------------------------
  192. // read an array of color4 tuples
  193. void ReadVectorDataArray(std::vector<aiColor4D>& out, const Element& el)
  194. {
  195. out.clear();
  196. const TokenList& tok = el.Tokens();
  197. const size_t dim = ParseTokenAsDim(*tok[0]);
  198. // see notes in ReadVectorDataArray() above
  199. out.reserve(dim);
  200. const Scope& scope = GetRequiredScope(el);
  201. const Element& a = GetRequiredElement(scope,"a",&el);
  202. if (a.Tokens().size() % 4 != 0) {
  203. DOMError("number of floats is not a multiple of four (4)",&el);
  204. }
  205. for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
  206. aiColor4D v;
  207. v.r = ParseTokenAsFloat(**it++);
  208. v.g = ParseTokenAsFloat(**it++);
  209. v.b = ParseTokenAsFloat(**it++);
  210. v.a = ParseTokenAsFloat(**it++);
  211. out.push_back(v);
  212. }
  213. }
  214. // ------------------------------------------------------------------------------------------------
  215. // read an array of float2 tuples
  216. void ReadVectorDataArray(std::vector<aiVector2D>& out, const Element& el)
  217. {
  218. out.clear();
  219. const TokenList& tok = el.Tokens();
  220. const size_t dim = ParseTokenAsDim(*tok[0]);
  221. // see notes in ReadVectorDataArray() above
  222. out.reserve(dim);
  223. const Scope& scope = GetRequiredScope(el);
  224. const Element& a = GetRequiredElement(scope,"a",&el);
  225. if (a.Tokens().size() % 2 != 0) {
  226. DOMError("number of floats is not a multiple of two (2)",&el);
  227. }
  228. for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
  229. aiVector2D v;
  230. v.x = ParseTokenAsFloat(**it++);
  231. v.y = ParseTokenAsFloat(**it++);
  232. out.push_back(v);
  233. }
  234. }
  235. // ------------------------------------------------------------------------------------------------
  236. // read an array of ints
  237. void ReadVectorDataArray(std::vector<int>& out, const Element& el)
  238. {
  239. out.clear();
  240. const TokenList& tok = el.Tokens();
  241. const size_t dim = ParseTokenAsDim(*tok[0]);
  242. // see notes in ReadVectorDataArray()
  243. out.reserve(dim);
  244. const Scope& scope = GetRequiredScope(el);
  245. const Element& a = GetRequiredElement(scope,"a",&el);
  246. for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
  247. const int ival = ParseTokenAsInt(**it++);
  248. out.push_back(ival);
  249. }
  250. }
  251. // ------------------------------------------------------------------------------------------------
  252. // read an array of uints
  253. void ReadVectorDataArray(std::vector<unsigned int>& out, const Element& el)
  254. {
  255. out.clear();
  256. const TokenList& tok = el.Tokens();
  257. const size_t dim = ParseTokenAsDim(*tok[0]);
  258. // see notes in ReadVectorDataArray()
  259. out.reserve(dim);
  260. const Scope& scope = GetRequiredScope(el);
  261. const Element& a = GetRequiredElement(scope,"a",&el);
  262. for (TokenList::const_iterator it = a.Tokens().begin(), end = a.Tokens().end(); it != end; ) {
  263. const int ival = ParseTokenAsInt(**it++);
  264. if(ival < 0) {
  265. DOMError("encountered negative integer index");
  266. }
  267. out.push_back(static_cast<unsigned int>(ival));
  268. }
  269. }
  270. // ------------------------------------------------------------------------------------------------
  271. // fetch a property table and the corresponding property template
  272. boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
  273. const std::string& templateName,
  274. const Element &element,
  275. const Scope& sc)
  276. {
  277. const Element* const Properties70 = sc["Properties70"];
  278. boost::shared_ptr<const PropertyTable> templateProps = boost::shared_ptr<const PropertyTable>(
  279. static_cast<const PropertyTable*>(NULL));
  280. if(templateName.length()) {
  281. PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName);
  282. if(it != doc.Templates().end()) {
  283. templateProps = (*it).second;
  284. }
  285. }
  286. if(!Properties70) {
  287. DOMWarning("material property table (Properties70) not found",&element);
  288. if(templateProps) {
  289. return templateProps;
  290. }
  291. else {
  292. return boost::make_shared<const PropertyTable>();
  293. }
  294. }
  295. return boost::make_shared<const PropertyTable>(*Properties70,templateProps);
  296. }
  297. } // !Util
  298. using namespace Util;
  299. // ------------------------------------------------------------------------------------------------
  300. LazyObject::LazyObject(uint64_t id, const Element& element, const Document& doc)
  301. : doc(doc)
  302. , element(element)
  303. , id(id)
  304. {
  305. }
  306. // ------------------------------------------------------------------------------------------------
  307. LazyObject::~LazyObject()
  308. {
  309. }
  310. // ------------------------------------------------------------------------------------------------
  311. const Object* LazyObject::Get()
  312. {
  313. if (object.get()) {
  314. return object.get();
  315. }
  316. const Token& key = element.KeyToken();
  317. const TokenList& tokens = element.Tokens();
  318. if(tokens.size() < 3) {
  319. DOMError("expected at least 3 tokens: id, name and class tag",&element);
  320. }
  321. const char* err;
  322. const std::string name = ParseTokenAsString(*tokens[1],err);
  323. if (err) {
  324. DOMError(err,&element);
  325. }
  326. const std::string classtag = ParseTokenAsString(*tokens[2],err);
  327. if (err) {
  328. DOMError(err,&element);
  329. }
  330. // XXX prevent recursive calls
  331. // this needs to be relatively fast since it happens a lot,
  332. // so avoid constructing strings all the time.
  333. const char* obtype = key.begin();
  334. const size_t length = static_cast<size_t>(key.end()-key.begin());
  335. if (!strncmp(obtype,"Geometry",length)) {
  336. if (!strcmp(classtag.c_str(),"Mesh")) {
  337. object.reset(new MeshGeometry(id,element,name,doc));
  338. }
  339. }
  340. else if (!strncmp(obtype,"Model",length)) {
  341. object.reset(new Model(id,element,doc,name));
  342. }
  343. else if (!strncmp(obtype,"Material",length)) {
  344. object.reset(new Material(id,element,doc,name));
  345. }
  346. else if (!strncmp(obtype,"Texture",length)) {
  347. object.reset(new Texture(id,element,doc,name));
  348. }
  349. if (!object.get()) {
  350. //DOMError("failed to convert element to DOM object, class: " + classtag + ", name: " + name,&element);
  351. }
  352. return object.get();
  353. }
  354. // ------------------------------------------------------------------------------------------------
  355. Object::Object(uint64_t id, const Element& element, const std::string& name)
  356. : element(element)
  357. , name(name)
  358. , id(id)
  359. {
  360. }
  361. // ------------------------------------------------------------------------------------------------
  362. Object::~Object()
  363. {
  364. }
  365. // ------------------------------------------------------------------------------------------------
  366. Geometry::Geometry(uint64_t id, const Element& element, const std::string& name)
  367. : Object(id, element,name)
  368. {
  369. }
  370. // ------------------------------------------------------------------------------------------------
  371. Geometry::~Geometry()
  372. {
  373. }
  374. // ------------------------------------------------------------------------------------------------
  375. Document::Document(const Parser& parser, const ImportSettings& settings)
  376. : parser(parser)
  377. , settings(settings)
  378. {
  379. ReadPropertyTemplates();
  380. // this order is important, connections need parsed objects to check
  381. // whether connections are ok or not. Objects may not be evaluated yet,
  382. // though, since this may require valid connections.
  383. ReadObjects();
  384. ReadConnections();
  385. }
  386. // ------------------------------------------------------------------------------------------------
  387. Document::~Document()
  388. {
  389. BOOST_FOREACH(ObjectMap::value_type& v, objects) {
  390. delete v.second;
  391. }
  392. }
  393. // ------------------------------------------------------------------------------------------------
  394. void Document::ReadObjects()
  395. {
  396. // read ID objects from "Objects" section
  397. const Scope& sc = parser.GetRootScope();
  398. const Element* const eobjects = sc["Objects"];
  399. if(!eobjects || !eobjects->Compound()) {
  400. DOMError("no Objects dictionary found");
  401. }
  402. const Scope& sobjects = *eobjects->Compound();
  403. BOOST_FOREACH(const ElementMap::value_type& el, sobjects.Elements()) {
  404. // extract ID
  405. const TokenList& tok = el.second->Tokens();
  406. if (tok.empty()) {
  407. DOMError("expected ID after object key",el.second);
  408. }
  409. const char* err;
  410. const uint64_t id = ParseTokenAsID(*tok[0], err);
  411. if(err) {
  412. DOMError(err,el.second);
  413. }
  414. objects[id] = new LazyObject(id, *el.second, *this);
  415. }
  416. }
  417. // ------------------------------------------------------------------------------------------------
  418. void Document::ReadPropertyTemplates()
  419. {
  420. const Scope& sc = parser.GetRootScope();
  421. // read property templates from "Definitions" section
  422. const Element* const edefs = sc["Definitions"];
  423. if(!edefs || !edefs->Compound()) {
  424. DOMWarning("no Definitions dictionary found");
  425. return;
  426. }
  427. const Scope& sdefs = *edefs->Compound();
  428. const ElementCollection otypes = sdefs.GetCollection("ObjectType");
  429. for(ElementMap::const_iterator it = otypes.first; it != otypes.second; ++it) {
  430. const Element& el = *(*it).second;
  431. const Scope* sc = el.Compound();
  432. if(!sc) {
  433. DOMWarning("expected nested scope in ObjectType, ignoring",&el);
  434. continue;
  435. }
  436. const TokenList& tok = el.Tokens();
  437. if(tok.empty()) {
  438. DOMWarning("expected name for ObjectType element, ignoring",&el);
  439. continue;
  440. }
  441. const std::string& oname = ParseTokenAsString(*tok[0]);
  442. const ElementCollection templs = sc->GetCollection("PropertyTemplate");
  443. for(ElementMap::const_iterator it = templs.first; it != templs.second; ++it) {
  444. const Element& el = *(*it).second;
  445. const Scope* sc = el.Compound();
  446. if(!sc) {
  447. DOMWarning("expected nested scope in PropertyTemplate, ignoring",&el);
  448. continue;
  449. }
  450. const TokenList& tok = el.Tokens();
  451. if(tok.empty()) {
  452. DOMWarning("expected name for PropertyTemplate element, ignoring",&el);
  453. continue;
  454. }
  455. const std::string& pname = ParseTokenAsString(*tok[0]);
  456. const Element* Properties70 = (*sc)["Properties70"];
  457. if(Properties70) {
  458. boost::shared_ptr<const PropertyTable> props = boost::make_shared<const PropertyTable>(
  459. *Properties70,boost::shared_ptr<const PropertyTable>(static_cast<const PropertyTable*>(NULL))
  460. );
  461. templates[oname+"."+pname] = props;
  462. }
  463. }
  464. }
  465. }
  466. // ------------------------------------------------------------------------------------------------
  467. void Document::ReadConnections()
  468. {
  469. const Scope& sc = parser.GetRootScope();
  470. // read property templates from "Definitions" section
  471. const Element* const econns = sc["Connections"];
  472. if(!econns || !econns->Compound()) {
  473. DOMError("no Connections dictionary found");
  474. }
  475. uint64_t insertionOrder = 0l;
  476. const Scope& sconns = *econns->Compound();
  477. const ElementCollection conns = sconns.GetCollection("C");
  478. for(ElementMap::const_iterator it = conns.first; it != conns.second; ++it) {
  479. const Element& el = *(*it).second;
  480. const std::string& type = ParseTokenAsString(GetRequiredToken(el,0));
  481. const uint64_t src = ParseTokenAsID(GetRequiredToken(el,1));
  482. const uint64_t dest = ParseTokenAsID(GetRequiredToken(el,2));
  483. // OO = object-object connection
  484. // OP = object-property connection, in which case the destination property follows the object ID
  485. const std::string& prop = (type == "OP" ? ParseTokenAsString(GetRequiredToken(el,3)) : "");
  486. if(objects.find(src) == objects.end()) {
  487. DOMWarning("source object for connection does not exist",&el);
  488. continue;
  489. }
  490. // dest may be 0 (root node)
  491. if(dest && objects.find(dest) == objects.end()) {
  492. DOMWarning("destination object for connection does not exist",&el);
  493. continue;
  494. }
  495. // add new connection
  496. const Connection* const c = new Connection(insertionOrder++,src,dest,prop,*this);
  497. src_connections.insert(ConnectionMap::value_type(src,c));
  498. dest_connections.insert(ConnectionMap::value_type(dest,c));
  499. }
  500. }
  501. // ------------------------------------------------------------------------------------------------
  502. LazyObject* Document::GetObject(uint64_t id) const
  503. {
  504. ObjectMap::const_iterator it = objects.find(id);
  505. return it == objects.end() ? NULL : (*it).second;
  506. }
  507. // ------------------------------------------------------------------------------------------------
  508. std::vector<const Connection*> Document::GetConnectionsBySourceSequenced(uint64_t source) const
  509. {
  510. std::vector<const Connection*> temp;
  511. const std::pair<ConnectionMap::const_iterator,ConnectionMap::const_iterator> range =
  512. ConnectionsBySource().equal_range(source);
  513. temp.reserve(std::distance(range.first,range.second));
  514. for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) {
  515. temp.push_back((*it).second);
  516. }
  517. std::sort(temp.begin(), temp.end(), std::mem_fun(&Connection::CompareTo));
  518. return temp; // NRVO should handle this
  519. }
  520. // ------------------------------------------------------------------------------------------------
  521. std::vector<const Connection*> Document::GetConnectionsByDestinationSequenced(uint64_t dest) const
  522. {
  523. std::vector<const Connection*> temp;
  524. const std::pair<ConnectionMap::const_iterator,ConnectionMap::const_iterator> range =
  525. ConnectionsByDestination().equal_range(dest);
  526. temp.reserve(std::distance(range.first,range.second));
  527. for (ConnectionMap::const_iterator it = range.first; it != range.second; ++it) {
  528. temp.push_back((*it).second);
  529. }
  530. std::sort(temp.begin(), temp.end(), std::mem_fun(&Connection::CompareTo));
  531. return temp; // NRVO should handle this
  532. }
  533. // ------------------------------------------------------------------------------------------------
  534. Connection::Connection(uint64_t insertionOrder, uint64_t src, uint64_t dest, const std::string& prop, const Document& doc)
  535. : insertionOrder(insertionOrder)
  536. , src(src)
  537. , dest(dest)
  538. , prop(prop)
  539. , doc(doc)
  540. {
  541. ai_assert(doc.Objects().find(src) != doc.Objects().end());
  542. // dest may be 0 (root node)
  543. ai_assert(!dest || doc.Objects().find(dest) != doc.Objects().end());
  544. }
  545. // ------------------------------------------------------------------------------------------------
  546. Connection::~Connection()
  547. {
  548. }
  549. // ------------------------------------------------------------------------------------------------
  550. const Object* Connection::SourceObject() const
  551. {
  552. LazyObject* const lazy = doc.GetObject(src);
  553. ai_assert(lazy);
  554. return lazy->Get();
  555. }
  556. // ------------------------------------------------------------------------------------------------
  557. const Object* Connection::DestinationObject() const
  558. {
  559. LazyObject* const lazy = doc.GetObject(dest);
  560. ai_assert(lazy);
  561. return lazy->Get();
  562. }
  563. } // !FBX
  564. } // !Assimp
  565. #endif