int Model::processNode(FbxNode *node, int level, Data &model) { const char* nodeName = node->GetName(); FbxDouble3 translation = node->LclTranslation.Get(); FbxDouble3 rotation = node->LclRotation.Get(); FbxDouble3 scaling = node->LclScaling.Get(); LOG(INFO) << "Node " << nodeName << " Postion " << translation[0] << " " << translation[1] << " " << translation[2] << " " << " Rotation " << rotation[0] << " " << rotation[1] << " " << rotation[2] << " " << " Scale " << scaling[0] << " " << scaling[1] << " " << scaling[2]; level++; model.model.push_back(new Data()); // Print the node's attributes. for (int i = 0; i < node->GetNodeAttributeCount(); i++) { processAttribute(node->GetNodeAttributeByIndex(i), level, model); } // Recursively print the children. for (int j = 0; j < node->GetChildCount(); j++) processNode(node->GetChild(j), level, model); level--; return level; }
void processNode(FbxNode *node,GameObject *rootGo) { PrintTabs(); const char* nodeName = node->GetName(); FbxDouble3 translation = node->LclTranslation.Get(); FbxDouble3 rotation = node->LclRotation.Get(); FbxDouble3 scaling = node->LclScaling.Get(); std::cout << "Node " << nodeName << " Postion " << translation[0] << " " << translation[1] << " " << translation[2] << " " << " Rotation " << rotation[0] << " " << rotation[1] << " " << rotation[2] << " " << " Scale " << scaling[0] << " " << scaling[1] << " " << scaling[2] << std::endl; level++; GameObject * go = new GameObject(); go->setTransform(new Transform()); rootGo->addChild(go); // Print the node's attributes. for (int i = 0; i < node->GetNodeAttributeCount(); i++){ processAttribute(node->GetNodeAttributeByIndex(i), go); } // Recursively print the children. for (int j = 0; j < node->GetChildCount(); j++) processNode(node->GetChild(j), rootGo); level--; PrintTabs(); }
/** * Method that can be used from within processFile() to look at each * attribute that a file may have. This will call the processAttribute() * method (which you must implement) on each of the attributes in the file. * @param fs_file file details * @param path full path of parent directory * @returns STOP if the file system processing should stop and not process more files or OK. */ TSK_RETVAL_ENUM TskAuto::processAttributes(TSK_FS_FILE * fs_file, const char *path) { int count = tsk_fs_file_attr_getsize(fs_file), i; for (i = 0; i < count; i++) { TSK_RETVAL_ENUM retval = processAttribute(fs_file, tsk_fs_file_attr_get_idx(fs_file, i), path); if ((retval == TSK_STOP) || (m_stopAllProcessing)) return TSK_STOP; } return TSK_OK; }
static qp_result processContainedAttributes( c_iter attributes, qp_parseContext ctx) { qp_result result = QP_RESULT_OK; cf_attribute attribute; assert(ctx); while ((attribute = (cf_attribute) c_iterTakeFirst(attributes)) != NULL && result == QP_RESULT_OK) { result = processAttribute(attribute, ctx); } c_iterFree(attributes); return result; }
bool IWORKParser::parse() { const shared_ptr<xmlTextReader> sharedReader(xmlReaderForIO(readFromStream, closeStream, m_input.get(), "", nullptr, 0), xmlFreeTextReader); if (!sharedReader) return false; xmlTextReaderPtr reader = sharedReader.get(); assert(reader); const IWORKTokenizer &tokenizer = getTokenizer(); stack<IWORKXMLContextPtr_t> contextStack; int ret = xmlTextReaderRead(reader); contextStack.push(createDocumentContext()); bool keynoteDocTypeChecked=false; char const *defaultNS=nullptr; while ((1 == ret)) { switch (xmlTextReaderNodeType(reader)) { case XML_READER_TYPE_ELEMENT: { if (!keynoteDocTypeChecked) { // check for keynote 1 file with doctype node and not a namespace in first node keynoteDocTypeChecked=true; if (xmlTextReaderNodeType(reader)==XML_READER_TYPE_ELEMENT && xmlTextReaderConstNamespaceUri(reader)==nullptr) defaultNS="http://developer.apple.com/schemas/APXL"; } const int id = tokenizer.getQualifiedId(char_cast(xmlTextReaderConstLocalName(reader)), defaultNS ? defaultNS : char_cast(xmlTextReaderConstNamespaceUri(reader))); IWORKXMLContextPtr_t newContext = contextStack.top()->element(id); if (!newContext) newContext = createDiscardContext(); const bool isEmpty = xmlTextReaderIsEmptyElement(reader); newContext->startOfElement(); if (xmlTextReaderHasAttributes(reader)) { ret = xmlTextReaderMoveToFirstAttribute(reader); while (1 == ret) { processAttribute(reader, newContext, tokenizer); ret = xmlTextReaderMoveToNextAttribute(reader); } } if (isEmpty) newContext->endOfElement(); else contextStack.push(newContext); break; } case XML_READER_TYPE_END_ELEMENT: { contextStack.top()->endOfElement(); contextStack.pop(); break; } case XML_READER_TYPE_CDATA : { const xmlChar *text = xmlTextReaderConstValue(reader); if (text) contextStack.top()->CDATA(char_cast(text)); break; } case XML_READER_TYPE_TEXT : { xmlChar *const text = xmlTextReaderReadString(reader); contextStack.top()->text(char_cast(text)); xmlFree(text); break; } default: break; } ret = xmlTextReaderRead(reader); } while (!contextStack.empty()) // finish parsing in case of broken XML { contextStack.top()->endOfElement(); contextStack.pop(); } xmlTextReaderClose(reader); return true; }
bool IWORKParser::parse() { const shared_ptr<xmlTextReader> sharedReader(xmlReaderForIO(readFromStream, closeStream, m_input.get(), "", 0, 0), xmlFreeTextReader); if (!sharedReader) return false; xmlTextReaderPtr reader = sharedReader.get(); assert(reader); const IWORKTokenizer &tokenizer = getTokenizer(); stack<IWORKXMLContextPtr_t> contextStack; int ret = xmlTextReaderRead(reader); contextStack.push(createDocumentContext()); while ((1 == ret)) { switch (xmlTextReaderNodeType(reader)) { case XML_READER_TYPE_ELEMENT: { const int id = tokenizer.getQualifiedId(char_cast(xmlTextReaderConstLocalName(reader)), char_cast(xmlTextReaderConstNamespaceUri(reader))); IWORKXMLContextPtr_t newContext = contextStack.top()->element(id); if (!newContext) newContext = createDiscardContext(); const bool isEmpty = xmlTextReaderIsEmptyElement(reader); newContext->startOfElement(); if (xmlTextReaderHasAttributes(reader)) { ret = xmlTextReaderMoveToFirstAttribute(reader); while (1 == ret) { processAttribute(reader, newContext, tokenizer); ret = xmlTextReaderMoveToNextAttribute(reader); } } if (isEmpty) newContext->endOfElement(); else contextStack.push(newContext); break; } case XML_READER_TYPE_END_ELEMENT: { contextStack.top()->endOfElement(); contextStack.pop(); break; } case XML_READER_TYPE_TEXT : { xmlChar *const text = xmlTextReaderReadString(reader); contextStack.top()->text(char_cast(text)); xmlFree(text); break; } default: break; } ret = xmlTextReaderRead(reader); } while (!contextStack.empty()) // finish parsing in case of broken XML { contextStack.top()->endOfElement(); contextStack.pop(); } xmlTextReaderClose(reader); return true; }
void ShadingNetworkExporter::createShader(const MObject& node) { MStatus status; MFnDependencyNode depNodeFn(node); const OSLShaderInfo *shaderInfo = ShadingNodeRegistry::getShaderInfo(depNodeFn.typeName()); if(!shaderInfo) { std::cout << "Skipping unsupported shader: " << depNodeFn.typeName() << "\n"; return; } if(m_shadersExported.count(depNodeFn.name()) != 0) { std::cout << "Skipping already exported shader: " << depNodeFn.name() << "\n"; return; } m_shadersExported.insert(depNodeFn.name()); asr::ParamArray shaderParams; for(int i = 0, e = shaderInfo->paramInfo.size(); i < e; ++i) { const OSLParamInfo& paramInfo = shaderInfo->paramInfo[i]; // Skip output attributes. if(paramInfo.isOutput) { std::cout << "Skipping output attribute: " << "\n"; std::cout << paramInfo << std::endl; continue; } if(!paramInfo.validDefault) { std::cout << "Skipping attribute without valid default: " << "\n"; std::cout << paramInfo << std::endl; continue; } if(paramInfo.isArray) { std::cout << "Skipping array attribute: " << "\n"; std::cout << paramInfo << std::endl; continue; } MPlug plug = depNodeFn.findPlug(paramInfo.mayaAttributeName, &status); if(!status) { std::cout << "Skipping unknown attribute: " << paramInfo.mayaAttributeName << std::endl; continue; } if(plug.isConnected()) { MObject srcNode; if(AttributeUtils::get(plug, srcNode)) createShader(srcNode); continue; } if(plug.isCompound() && plug.numConnectedChildren() != 0) { std::cout << "Skipping connected compound attribute: " << plug.name() << "\n"; continue; } if(plug.isArray() && plug.numConnectedElements() != 0) { std::cout << "Skipping connected array attribute: " << plug.name() << "\n"; continue; } processAttribute(plug, paramInfo, shaderParams); } m_shaderGroup->add_shader( shaderInfo->shaderType.asChar(), shaderInfo->shaderName.asChar(), depNodeFn.name().asChar(), shaderParams); }