123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #include "FBXDocument.h"
- #include "FBXDocumentUtil.h"
- #include "FBXMeshGeometry.h"
- #include "FBXParser.h"
- namespace FBXDocParser {
- using namespace Util;
- Model::Model(uint64_t id, const ElementPtr element, const Document &doc, const std::string &name) :
- Object(id, element, name), shading("Y") {
- const ScopePtr sc = GetRequiredScope(element);
- const ElementPtr Shading = sc->GetElement("Shading");
- const ElementPtr Culling = sc->GetElement("Culling");
- if (Shading) {
- shading = GetRequiredToken(Shading, 0)->StringContents();
- }
- if (Culling) {
- culling = ParseTokenAsString(GetRequiredToken(Culling, 0));
- }
- props = GetPropertyTable(doc, "Model.FbxNode", element, sc);
- ResolveLinks(element, doc);
- }
- Model::~Model() {
- if (props != nullptr) {
- delete props;
- props = nullptr;
- }
- }
- ModelLimbNode::ModelLimbNode(uint64_t id, const ElementPtr element, const Document &doc, const std::string &name) :
- Model(id, element, doc, name){
- };
- ModelLimbNode::~ModelLimbNode() {
- }
- void Model::ResolveLinks(const ElementPtr element, const Document &doc) {
- const char *const arr[] = { "Geometry", "Material", "NodeAttribute" };
-
- const std::vector<const Connection *> &conns = doc.GetConnectionsByDestinationSequenced(ID(), arr, 3);
- materials.reserve(conns.size());
- geometry.reserve(conns.size());
- attributes.reserve(conns.size());
- for (const Connection *con : conns) {
-
- if (con->PropertyName().length()) {
- continue;
- }
- const Object *const ob = con->SourceObject();
- if (!ob) {
-
- continue;
- }
- const Material *const mat = dynamic_cast<const Material *>(ob);
- if (mat) {
- materials.push_back(mat);
- continue;
- }
- const Geometry *const geo = dynamic_cast<const Geometry *>(ob);
- if (geo) {
- geometry.push_back(geo);
- continue;
- }
- const NodeAttribute *const att = dynamic_cast<const NodeAttribute *>(ob);
- if (att) {
- attributes.push_back(att);
- continue;
- }
- DOMWarning("source object for model link is neither Material, NodeAttribute nor Geometry, ignoring", element);
- continue;
- }
- }
- bool Model::IsNull() const {
- const std::vector<const NodeAttribute *> &attrs = GetAttributes();
- for (const NodeAttribute *att : attrs) {
- const Null *null_tag = dynamic_cast<const Null *>(att);
- if (null_tag) {
- return true;
- }
- }
- return false;
- }
- }
|