bool FArchiveXML::LoadExtraNode(FCDObject* object, xmlNode* customNode) { FCDENode* fcdenode = (FCDENode*)object; bool status = true; // Read in the node's name and children fcdenode->SetName((const char*) customNode->name); FArchiveXML::LoadExtraNodeChildren(fcdenode, customNode); // If there are no child nodes, we have a tree leaf: parse in the content and its animation if (fcdenode->GetChildNodeCount() == 0) { fstring content = TO_FSTRING(ReadNodeContentFull(customNode)); if (!content.empty()) fcdenode->SetContent(content); } FArchiveXML::LinkAnimatedCustom(fcdenode->GetAnimated(), customNode); // Read in the node's attributes for (xmlAttr* a = customNode->properties; a != NULL; a = a->next) { fcdenode->AddAttribute((const char*) a->name, (a->children != NULL) ? TO_FSTRING((const char*) (a->children->content)) : FS("")); } fcdenode->SetDirtyFlag(); return status; }
bool FArchiveXML::LoadEntity(FCDObject* object, xmlNode* entityNode) { FCDEntity* entity = (FCDEntity*)object; bool status = true; fm::string fileId = FUDaeParser::ReadNodeId(entityNode); if (!fileId.empty()) entity->SetDaeId(fileId); else entity->RemoveDaeId(); entity->SetName(TO_FSTRING(FUDaeParser::ReadNodeName(entityNode))); if (entity->GetName().empty()) entity->SetName(TO_FSTRING(fileId)); // Read in the asset information. xmlNode* assetNode = FindChildByType(entityNode, DAE_ASSET_ELEMENT); if (assetNode != NULL) FArchiveXML::LoadAsset(entity->GetAsset(), assetNode); // Read in the extra nodes xmlNodeList extraNodes; FindChildrenByType(entityNode, DAE_EXTRA_ELEMENT, extraNodes); for (xmlNodeList::iterator it = extraNodes.begin(); it != extraNodes.end(); ++it) { xmlNode* extraNode = (*it); FArchiveXML::LoadExtra(entity->GetExtra(), extraNode); // Look for an extra node at this level and a valid technique FCDETechnique* mayaTechnique = entity->GetExtra()->GetDefaultType()->FindTechnique(DAEMAYA_MAYA_PROFILE); FCDETechnique* maxTechnique = entity->GetExtra()->GetDefaultType()->FindTechnique(DAEMAX_MAX_PROFILE); FCDETechnique* fcTechnique = entity->GetExtra()->GetDefaultType()->FindTechnique(DAE_FCOLLADA_PROFILE); // Read in all the extra parameters StringList parameterNames; FCDENodeList parameterNodes; if (mayaTechnique != NULL) mayaTechnique->FindParameters(parameterNodes, parameterNames); if (maxTechnique != NULL) maxTechnique->FindParameters(parameterNodes, parameterNames); if (fcTechnique != NULL) fcTechnique->FindParameters(parameterNodes, parameterNames); // Look for the note and user-properties, which is the only parameter currently supported at this level size_t parameterCount = parameterNodes.size(); for (size_t i = 0; i < parameterCount; ++i) { FCDENode* parameterNode = parameterNodes[i]; const fm::string& parameterName = parameterNames[i]; if (parameterName == DAEMAX_USERPROPERTIES_NODE_PARAMETER || parameterName == DAEMAYA_NOTE_PARAMETER) { entity->SetNote(parameterNode->GetContent()); SAFE_RELEASE(parameterNode); } } } entity->SetDirtyFlag(); return status; }
FUUri FCDEntityReference::GetUri() const { fstring path; if (placeHolder != NULL) { FUUri uri(placeHolder->GetFileUrl()); path = uri.GetAbsoluteUri(); } path.append(FC("#")); if (entity != NULL) path.append(TO_FSTRING(entity->GetDaeId())); else path.append(TO_FSTRING(entityId)); return FUUri(path); }
bool FArchiveXML::LoadEntityInstance(FCDObject* object, xmlNode* instanceNode) { FCDEntityInstance* entityInstance = (FCDEntityInstance*)object; bool status = true; FUUri uri = ReadNodeUrl(instanceNode); entityInstance->GetEntityReference()->SetUri(uri); if (!entityInstance->IsExternalReference() && entityInstance->GetEntity() == NULL) { FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_INST_ENTITY_MISSING, instanceNode->line); } entityInstance->SetWantedSubId(TO_STRING(ReadNodeSid(instanceNode))); entityInstance->SetName(TO_FSTRING(ReadNodeName(instanceNode))); // Read in the extra nodes xmlNodeList extraNodes; FindChildrenByType(instanceNode, DAE_EXTRA_ELEMENT, extraNodes); for (xmlNodeList::iterator it = extraNodes.begin(); it != extraNodes.end(); ++it) { xmlNode* extraNode = (*it); FArchiveXML::LoadExtra(entityInstance->GetExtra(), extraNode); } entityInstance->SetDirtyFlag(); return status; }
void ProcessCommandLine(int argc, char* argv[]) { // Remove the first argument: the current application name... --argc; ++argv; while (argc > 0) { if (argv[0][0] == '-' || argv[0][0] == '/') { ++(argv[0]); if (strcmp(argv[0], "-v") && argc >= 2) { isVerbose = FUStringConversion::ToBoolean(argv[1]); argc -= 2; argv += 2; } else { // unknown flag ShowHelp(); break; } } else if (argc == 1) { logFilename = TO_FSTRING((const char*) *(argv++)); --argc; } else { ShowHelp(); break; } } }
bool FUTestBed::RunTestbed(FUTestSuite* headTestSuite) { if (headTestSuite == NULL) return false; testPassed = testFailed = 0; RunTestSuite(headTestSuite); if (isVerbose) { fileOut.WriteLine("---------------------------------"); fileOut.WriteLine("Tests passed: %u.", (uint32) testPassed); fileOut.WriteLine("Tests failed: %u.", (uint32) testFailed); fileOut.WriteLine(""); fileOut.Flush(); #ifdef _WIN32 char sz[1024]; snprintf(sz, 1024, "Testbed score: [%zu/%zu]", testPassed, testFailed + testPassed); sz[1023] = 0; size_t returnCode = IDOK; returnCode = MessageBox(NULL, TO_FSTRING(sz).c_str(), FC("Testbed"), MB_OKCANCEL); if (returnCode == IDCANCEL) { const fm::string filenameUtf8 = FUStringConversion::ToString(filename); snprintf(sz, 1024, "write %s ", filenameUtf8.c_str()); sz[1023] = 0; system(sz); return false; } #endif } return true; }
int main(int argc, const char* argv[], char* envp[]) { #ifdef WIN32 _environ = envp; #else //LINUX environ = envp; #endif //WIN32 and LINUX if (argc != 3) { std::cout << "Expecting two arguments:" << std::endl; std::cout << "FCExport.exe <input_filename> <output_filename>" <<std::endl; exit(-1); } fstring inputFilename = TO_FSTRING(argv[1]); fstring outputFilename = TO_FSTRING(argv[2]); // Create an empty COLLADA document and import the given file. FCollada::Initialize(); FCDocument* document = FCollada::NewTopDocument(); FUErrorSimpleHandler errorHandler; FCollada::LoadDocumentFromFile(document, inputFilename.c_str()); if (errorHandler.IsSuccessful()) { // Write out the COLLADA document. std::cout << "Exporting: "; FCollada::SaveDocument(document, outputFilename.c_str()); if (errorHandler.IsSuccessful()) { std::cout << "Done." << std::endl; } else { std::cout << errorHandler.GetErrorString(); std::cout << std::endl << std::endl; } } else { std::cout << errorHandler.GetErrorString(); std::cout << std::endl << std::endl; } SAFE_DELETE(document); FCollada::Release(); return 0; }
// Search for a profile of a given type and platform const FCDEffectProfile* FCDEffect::FindProfileByTypeAndPlatform(FUDaeProfileType::Type type, const fm::string& platform) const { for (const FCDEffectProfile** itR = profiles.begin(); itR != profiles.end(); ++itR) { if ((*itR)->GetType() == type) { if (((FCDEffectProfileFX*)(*itR))->GetPlatform() == TO_FSTRING(platform)) return (*itR); } } return NULL; }
FCDMaterialInstance* FCDGeometryInstance::AddMaterialInstance(FCDMaterial* material, FCDGeometryPolygons* polygons) { FCDMaterialInstance* instance = AddMaterialInstance(); instance->SetMaterial(material); if (polygons != NULL) { const fstring& semantic = polygons->GetMaterialSemantic(); if (!semantic.empty()) { instance->SetSemantic(polygons->GetMaterialSemantic()); } else { // Generate a semantic. fstring semantic = TO_FSTRING(material->GetDaeId()) + TO_FSTRING(polygons->GetFaceOffset()); polygons->SetMaterialSemantic(semantic); instance->SetSemantic(semantic); } } return instance; }
bool FArchiveXML::LoadAssetContributor(FCDObject* object, xmlNode* contributorNode) { FCDAssetContributor* assetContributor = (FCDAssetContributor*)object; bool status = true; for (xmlNode* child = contributorNode->children; child != NULL; child = child->next) { if (child->type != XML_ELEMENT_NODE) continue; fm::string content = ReadNodeContentFull(child); if (IsEquivalent(child->name, DAE_AUTHOR_ASSET_PARAMETER)) { assetContributor->SetAuthor(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_AUTHORINGTOOL_ASSET_PARAMETER)) { assetContributor->SetAuthoringTool(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_COMMENTS_ASSET_PARAMETER)) { assetContributor->SetComments(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_COPYRIGHT_ASSET_PARAMETER)) { assetContributor->SetCopyright(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_SOURCEDATA_ASSET_PARAMETER)) { assetContributor->SetSourceData(TO_FSTRING(content)); } else { FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_UNKNOWN_AC_CHILD_ELEMENT, child->line); } } assetContributor->SetDirtyFlag(); return status; }
bool FArchiveXML::LoadControllerInstance(FCDObject* object, xmlNode* instanceNode) { if (!FArchiveXML::LoadGeometryInstance(object, instanceNode)) return false; bool status = true; FCDControllerInstance* controllerInstance = (FCDControllerInstance*)object; xmlNodeList skeletonList; FUDaeParser::FindChildrenByType(instanceNode, DAE_SKELETON_ELEMENT, skeletonList); size_t numRoots = skeletonList.size(); controllerInstance->GetSkeletonRoots().resize(numRoots); for (size_t i = 0; i < numRoots; ++i) { controllerInstance->GetSkeletonRoots()[i] = FUUri(TO_FSTRING(FUDaeParser::ReadNodeContentDirect(skeletonList[i]))); } return status; }
FUFileManager::FUFileManager() { #ifdef __PPU__ // Push on the stack the default home path pathStack.push_back(FC("/app_home")); #else // Push on the stack the original root path char fullPath[MAX_PATH]; _getcwd(fullPath, MAX_PATH); size_t length = strlen(fullPath); if (length < MAX_PATH - 2 && fullPath[length-1] != '/' && fullPath[length-1] != '\\') { fullPath[length] = '/'; fullPath[length + 1] = 0; } pathStack.push_back(TO_FSTRING((const char*) fullPath)); #endif // __PPU__ forceAbsolute = false; }
bool FArchiveXML::LoadMaterialInstance(FCDObject* object, xmlNode* instanceNode) { FCDMaterialInstance* materialInstance = (FCDMaterialInstance*)object; // This is not loaded the same as the FCDEntityInstance ones. // Load it first, otherwise FCDEntityInstance will ASSERT (with no Uri) fm::string uri = ReadNodeProperty(instanceNode, DAE_TARGET_ATTRIBUTE); AddAttribute(instanceNode, DAE_URL_ATTRIBUTE, uri); if (!FArchiveXML::LoadEntityInstance(object, instanceNode)) return false; materialInstance->SetSemantic(TO_FSTRING(ReadNodeProperty(instanceNode, DAE_SYMBOL_ATTRIBUTE))); // Read in the ColladaFX bindings while (materialInstance->GetBindingCount() != 0) materialInstance->GetBinding(materialInstance->GetBindingCount() - 1)->Release(); xmlNodeList bindNodes; FindChildrenByType(instanceNode, DAE_BIND_ELEMENT, bindNodes); for (xmlNodeList::iterator itB = bindNodes.begin(); itB != bindNodes.end(); ++itB) { fm::string semantic = ReadNodeSemantic(*itB); fm::string target = ReadNodeProperty(*itB, DAE_TARGET_ATTRIBUTE); materialInstance->AddBinding(semantic, target); } // Read in the ColladaFX vertex inputs xmlNodeList bindVertexNodes; while (materialInstance->GetVertexInputBindingCount() != 0) materialInstance->GetVertexInputBinding(materialInstance->GetVertexInputBindingCount() - 1)->Release(); FindChildrenByType(instanceNode, DAE_BIND_VERTEX_INPUT_ELEMENT, bindVertexNodes); for (xmlNodeList::iterator itB = bindVertexNodes.begin(); itB != bindVertexNodes.end(); ++itB) { fm::string inputSet = ReadNodeProperty(*itB, DAE_INPUT_SET_ATTRIBUTE); fm::string inputSemantic = ReadNodeProperty(*itB, DAE_INPUT_SEMANTIC_ATTRIBUTE); materialInstance->AddVertexInputBinding(ReadNodeSemantic(*itB).c_str(), FUDaeGeometryInput::FromString(inputSemantic.c_str()), FUStringConversion::ToInt32(inputSet)); } materialInstance->SetDirtyFlag(); return true; }
// Parse the Url attribute off a node FUUri ReadNodeUrl(xmlNode* node, const char* attribute) { fm::string uriString = ReadNodeProperty(node, attribute); return FUUri(TO_FSTRING(uriString)); }
bool FArchiveXML::LoadAnimationChannel(FCDObject* object, xmlNode* channelNode) { FCDAnimationChannel* animationChannel = (FCDAnimationChannel*)object; FCDAnimationChannelData& data = FArchiveXML::documentLinkDataMap[animationChannel->GetDocument()].animationChannelData[animationChannel]; bool status = true; // Read the channel-specific ID fm::string daeId = ReadNodeId(channelNode); fm::string samplerId = ReadNodeSource(channelNode); ReadNodeTargetProperty(channelNode, data.targetPointer, data.targetQualifier); #ifdef DONT_DEFINE_THIS FCDAnimation* anim = animationChannel->GetParent(); FCDExtra* extra = anim->GetExtra(); extra->SetTransientFlag(); // Dont save this, its wasted whatever it is. FCDEType* type = extra->AddType("AnimTargets"); FCDETechnique* teq = type->AddTechnique("TEMP"); teq->AddChildNode("pointer")->SetContent(TO_FSTRING(data.targetPointer)); teq->AddChildNode("pointer")->SetContent(TO_FSTRING(data.targetQualifier)); #endif xmlNode* samplerNode = FArchiveXML::FindChildByIdFCDAnimation(animationChannel->GetParent(), samplerId); if (samplerNode == NULL || !IsEquivalent(samplerNode->name, DAE_SAMPLER_ELEMENT)) { FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_MISSING_ELEMENT, channelNode->line); return false; } // Find and process the sources xmlNode* inputSource = NULL, * outputSource = NULL, * inTangentSource = NULL, * outTangentSource = NULL, * tcbSource = NULL, * easeSource = NULL, * interpolationSource = NULL; xmlNodeList samplerInputNodes; fm::string inputDriver; FindChildrenByType(samplerNode, DAE_INPUT_ELEMENT, samplerInputNodes); for (size_t i = 0; i < samplerInputNodes.size(); ++i) // Don't use iterator here because we are possibly appending source nodes in the loop { xmlNode* inputNode = samplerInputNodes[i]; fm::string sourceId = ReadNodeSource(inputNode); xmlNode* sourceNode = FArchiveXML::FindChildByIdFCDAnimation(animationChannel->GetParent(), sourceId); fm::string sourceSemantic = ReadNodeSemantic(inputNode); if (sourceSemantic == DAE_INPUT_ANIMATION_INPUT) inputSource = sourceNode; else if (sourceSemantic == DAE_OUTPUT_ANIMATION_INPUT) outputSource = sourceNode; else if (sourceSemantic == DAE_INTANGENT_ANIMATION_INPUT) inTangentSource = sourceNode; else if (sourceSemantic == DAE_OUTTANGENT_ANIMATION_INPUT) outTangentSource = sourceNode; else if (sourceSemantic == DAEFC_TCB_ANIMATION_INPUT) tcbSource = sourceNode; else if (sourceSemantic == DAEFC_EASE_INOUT_ANIMATION_INPUT) easeSource = sourceNode; else if (sourceSemantic == DAE_INTERPOLATION_ANIMATION_INPUT) interpolationSource = sourceNode; else if (sourceSemantic == DAEMAYA_DRIVER_INPUT) inputDriver = sourceId; } if (inputSource == NULL || outputSource == NULL) { FUError::Error(FUError::ERROR_LEVEL, FUError::ERROR_MISSING_INPUT, samplerNode->line); return false; } // Calculate the number of curves that in contained by this channel xmlNode* outputAccessor = FindTechniqueAccessor(outputSource); fm::string accessorStrideString = ReadNodeProperty(outputAccessor, DAE_STRIDE_ATTRIBUTE); uint32 curveCount = FUStringConversion::ToUInt32(accessorStrideString); if (curveCount == 0) curveCount = 1; // Create the animation curves for (uint32 i = 0; i < curveCount; ++i) { animationChannel->AddCurve(); } // Read in the animation curves // The input keys and interpolations are shared by all the curves FloatList inputs; ReadSource(inputSource, inputs); size_t keyCount = inputs.size(); if (keyCount == 0) return true; // Valid although very boring channel. UInt32List interpolations; interpolations.reserve(keyCount); ReadSourceInterpolation(interpolationSource, interpolations); if (interpolations.size() < keyCount) { // Not enough interpolation types provided, so append BEZIER as many times as needed. interpolations.insert(interpolations.end(), keyCount - interpolations.size(), FUDaeInterpolation::FromString("")); } // Read in the interleaved outputs as floats fm::vector<FloatList> tempFloatArrays; tempFloatArrays.resize(curveCount); fm::pvector<FloatList> outArrays(curveCount); for (uint32 i = 0; i < curveCount; ++i) outArrays[i] = &tempFloatArrays[i]; ReadSourceInterleaved(outputSource, outArrays); for (uint32 i = 0; i < curveCount; ++i) { // Fill in the output array with zeroes, if it was not large enough. if (tempFloatArrays[i].size() < keyCount) { tempFloatArrays[i].insert(tempFloatArrays[i].end(), keyCount - tempFloatArrays[i].size(), 0.0f); } // Create all the keys, on the curves, according to the interpolation types. for (size_t j = 0; j < keyCount; ++j) { FCDAnimationKey* key = animationChannel->GetCurve(i)->AddKey((FUDaeInterpolation::Interpolation) interpolations[j]); key->input = inputs[j]; key->output = tempFloatArrays[i][j]; // Set the default values for Bezier/TCB interpolations. if (key->interpolation == FUDaeInterpolation::BEZIER) { FCDAnimationKeyBezier* bkey = (FCDAnimationKeyBezier*) key; float previousInput = (j == 0) ? inputs[j] - 1.0f : inputs[j-1]; float nextInput = (j == keyCount - 1) ? inputs[j] + 1.0f : inputs[j+1]; bkey->inTangent.x = (previousInput + 2.0f * bkey->input) / 3.0f; bkey->outTangent.x = (nextInput + 2.0f * bkey->input) / 3.0f; bkey->inTangent.y = bkey->outTangent.y = bkey->output; } else if (key->interpolation == FUDaeInterpolation::TCB) { FCDAnimationKeyTCB* tkey = (FCDAnimationKeyTCB*) key; tkey->tension = tkey->continuity = tkey->bias = 0.5f; tkey->easeIn = tkey->easeOut = 0.0f; } } } tempFloatArrays.clear(); // Read in the interleaved in_tangent source. if (inTangentSource != NULL) { fm::vector<FMVector2List> tempVector2Arrays; tempVector2Arrays.resize(curveCount); fm::pvector<FMVector2List> arrays(curveCount); for (uint32 i = 0; i < curveCount; ++i) arrays[i] = &tempVector2Arrays[i]; uint32 stride = ReadSourceInterleaved(inTangentSource, arrays); if (stride == curveCount) { // Backward compatibility with 1D tangents. // Remove the relativity from the 1D tangents and calculate the second-dimension. for (uint32 i = 0; i < curveCount; ++i) { FMVector2List& inTangents = tempVector2Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(inTangents.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::BEZIER) { FCDAnimationKeyBezier* bkey = (FCDAnimationKeyBezier*) keys[j]; bkey->inTangent.y = bkey->output - inTangents[j].x; } } } } else if (stride == curveCount * 2) { // This is the typical, 2D tangent case. for (uint32 i = 0; i < curveCount; ++i) { FMVector2List& inTangents = tempVector2Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(inTangents.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::BEZIER) { FCDAnimationKeyBezier* bkey = (FCDAnimationKeyBezier*) keys[j]; bkey->inTangent = inTangents[j]; } } } } } // Read in the interleaved out_tangent source. if (outTangentSource != NULL) { fm::vector<FMVector2List> tempVector2Arrays; tempVector2Arrays.resize(curveCount); fm::pvector<FMVector2List> arrays(curveCount); for (uint32 i = 0; i < curveCount; ++i) arrays[i] = &tempVector2Arrays[i]; uint32 stride = ReadSourceInterleaved(outTangentSource, arrays); if (stride == curveCount) { // Backward compatibility with 1D tangents. // Remove the relativity from the 1D tangents and calculate the second-dimension. for (uint32 i = 0; i < curveCount; ++i) { FMVector2List& outTangents = tempVector2Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(outTangents.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::BEZIER) { FCDAnimationKeyBezier* bkey = (FCDAnimationKeyBezier*) keys[j]; bkey->outTangent.y = bkey->output + outTangents[j].x; } } } } else if (stride == curveCount * 2) { // This is the typical, 2D tangent case. for (uint32 i = 0; i < curveCount; ++i) { FMVector2List& outTangents = tempVector2Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(outTangents.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::BEZIER) { FCDAnimationKeyBezier* bkey = (FCDAnimationKeyBezier*) keys[j]; bkey->outTangent = outTangents[j]; } } } } } if (tcbSource != NULL) { //Process TCB parameters fm::vector<FMVector3List> tempVector3Arrays; tempVector3Arrays.resize(curveCount); fm::pvector<FMVector3List> arrays(curveCount); for (uint32 i = 0; i < curveCount; ++i) arrays[i] = &tempVector3Arrays[i]; ReadSourceInterleaved(tcbSource, arrays); for (uint32 i = 0; i < curveCount; ++i) { FMVector3List& tcbs = tempVector3Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(tcbs.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::TCB) { FCDAnimationKeyTCB* tkey = (FCDAnimationKeyTCB*) keys[j]; tkey->tension = tcbs[j].x; tkey->continuity = tcbs[j].y; tkey->bias = tcbs[j].z; } } } } if (easeSource != NULL) { //Process Ease-in and ease-out data fm::vector<FMVector2List> tempVector2Arrays; tempVector2Arrays.resize(curveCount); fm::pvector<FMVector2List> arrays(curveCount); for (uint32 i = 0; i < curveCount; ++i) arrays[i] = &tempVector2Arrays[i]; ReadSourceInterleaved(easeSource, arrays); for (uint32 i = 0; i < curveCount; ++i) { FMVector2List& eases = tempVector2Arrays[i]; FCDAnimationKey** keys = animationChannel->GetCurve(i)->GetKeys(); size_t end = min(eases.size(), keyCount); for (size_t j = 0; j < end; ++j) { if (keys[j]->interpolation == FUDaeInterpolation::TCB) { FCDAnimationKeyTCB* tkey = (FCDAnimationKeyTCB*) keys[j]; tkey->easeIn = eases[j].x; tkey->easeOut = eases[j].y; } } } } // Read in the pre/post-infinity type xmlNodeList mayaParameterNodes; StringList mayaParameterNames; xmlNode* mayaTechnique = FindTechnique(inputSource, DAEMAYA_MAYA_PROFILE); FindParameters(mayaTechnique, mayaParameterNames, mayaParameterNodes); size_t parameterCount = mayaParameterNodes.size(); for (size_t i = 0; i < parameterCount; ++i) { xmlNode* parameterNode = mayaParameterNodes[i]; const fm::string& paramName = mayaParameterNames[i]; const char* content = ReadNodeContentDirect(parameterNode); if (paramName == DAEMAYA_PREINFINITY_PARAMETER) { size_t curveCount = animationChannel->GetCurveCount(); for (size_t c = 0; c < curveCount; ++c) { animationChannel->GetCurve(c)->SetPreInfinity(FUDaeInfinity::FromString(content)); } } else if (paramName == DAEMAYA_POSTINFINITY_PARAMETER) { size_t curveCount = animationChannel->GetCurveCount(); for (size_t c = 0; c < curveCount; ++c) { animationChannel->GetCurve(c)->SetPostInfinity(FUDaeInfinity::FromString(content)); } } else { // Look for driven-key input target if (paramName == DAE_INPUT_ELEMENT) { fm::string semantic = ReadNodeSemantic(parameterNode); if (semantic == DAEMAYA_DRIVER_INPUT) { inputDriver = ReadNodeSource(parameterNode); } } } } if (!inputDriver.empty()) { const char* driverTarget = FUDaeParser::SkipPound(inputDriver); if (driverTarget != NULL) { fm::string driverQualifierValue; FUStringConversion::SplitTarget(driverTarget, data.driverPointer, driverQualifierValue); data.driverQualifier = FUStringConversion::ParseQualifier(driverQualifierValue); if (data.driverQualifier < 0) data.driverQualifier = 0; } } animationChannel->SetDirtyFlag(); return status; }
static void DebugString(const char* message) { fstring str = TO_FSTRING(message); DebugString(str); }
void AddNodeSid(xmlNode* node, fstring& subId) { fm::string _subId = TO_STRING(subId); _subId = AddNodeSid(node, _subId.c_str()); subId = TO_FSTRING(_subId); }
bool FArchiveXML::LoadAsset(FCDObject* object, xmlNode* assetNode) { FCDAsset* asset = (FCDAsset*)object; bool status = true; for (xmlNode* child = assetNode->children; child != NULL; child = child->next) { if (child->type != XML_ELEMENT_NODE) continue; fm::string content = ReadNodeContentFull(child); if (IsEquivalent(child->name, DAE_CONTRIBUTOR_ASSET_ELEMENT)) { FCDAssetContributor* contributor = asset->AddContributor(); status &= FArchiveXML::LoadAssetContributor(contributor, child); } else if (IsEquivalent(child->name, DAE_CREATED_ASSET_PARAMETER)) { FUStringConversion::ToDateTime(content, asset->GetCreationDateTime()); } else if (IsEquivalent(child->name, DAE_KEYWORDS_ASSET_PARAMETER)) { asset->SetKeywords(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_MODIFIED_ASSET_PARAMETER)) { FUStringConversion::ToDateTime(content, asset->GetModifiedDateTime()); } else if (IsEquivalent(child->name, DAE_REVISION_ASSET_PARAMETER)) { asset->SetRevision(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_SUBJECT_ASSET_PARAMETER)) { asset->SetSubject(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_TITLE_ASSET_PARAMETER)) { asset->SetTitle(TO_FSTRING(content)); } else if (IsEquivalent(child->name, DAE_UNITS_ASSET_PARAMETER)) { asset->SetUnitName(TO_FSTRING(ReadNodeName(child))); asset->SetUnitConversionFactor(FUStringConversion::ToFloat(ReadNodeProperty(child, DAE_METERS_ATTRIBUTE))); if (asset->GetUnitName().empty()) asset->SetUnitName(FC("UNKNOWN")); if (IsEquivalent(asset->GetUnitConversionFactor(), 0.0f) || asset->GetUnitConversionFactor() < 0.0f) asset->SetUnitConversionFactor(1.0f); } else if (IsEquivalent(child->name, DAE_UPAXIS_ASSET_PARAMETER)) { if (IsEquivalent(content, DAE_X_UP)) asset->SetUpAxis(FMVector3::XAxis); else if (IsEquivalent(content, DAE_Y_UP)) asset->SetUpAxis(FMVector3::YAxis); else if (IsEquivalent(content, DAE_Z_UP)) asset->SetUpAxis(FMVector3::ZAxis); } else { FUError::Error(FUError::WARNING_LEVEL, FUError::WARNING_UNKNOWN_CHILD_ELEMENT, child->line); } } asset->SetDirtyFlag(); return status; }
int main(int argc, const char* argv[], char* envp[]) { #ifdef WIN32 _environ = envp; #else //LINUX environ = envp; #endif //WIN32 and LINUX if (argc != 3) { std::cout << "Expecting two arguments:" << std::endl; std::cout << "FCProcessImages.exe <input_filename> <output_filename>" <<std::endl; exit(-1); } fstring inputFilename = TO_FSTRING(argv[1]); fstring outputFilename = TO_FSTRING(argv[2]); // Create an empty COLLADA document and import the given file. FCollada::Initialize(); FUErrorSimpleHandler errorHandler; FCDocument* document = FCollada::NewTopDocument(); FCollada::LoadDocumentFromFile(document, inputFilename.c_str()); std::cout << argv[1] << std::endl; if (errorHandler.IsSuccessful()) { std::cout << "Import: Done." << std::endl; // Initialize DevIL. ilInit(); iluInit(); // Process the image library ProcessImageLibrary(document->GetImageLibrary()); // Shutdown DevIL ilShutDown(); // It is common practice for tools to add a new contributor to identify that they were run // on a COLLADA document. FCDAssetContributor* contributor = document->GetAsset()->AddContributor(); const char* userName = getenv("USER"); if (userName == NULL) userName = getenv("USERNAME"); if (userName != NULL) contributor->SetAuthor(TO_FSTRING(userName)); contributor->SetSourceData(inputFilename); char authoringTool[1024]; snprintf(authoringTool, 1024, "FCProcessImages sample for FCollada v%d.%02d", FCOLLADA_VERSION >> 16, FCOLLADA_VERSION & 0xFFFF); authoringTool[1023] = 0; contributor->SetAuthoringTool(TO_FSTRING((const char*)authoringTool)); // Write out the processed COLLADA document. FCollada::SaveDocument(document, outputFilename.c_str()); if (errorHandler.IsSuccessful()) { std::cout << "Export: Done." << std::endl; } else { std::cout << errorHandler.GetErrorString(); std::cout << std::endl << std::endl; } }
void FUPluginManager::LoadPluginsInFolderName(const fstring& folderName, const fchar* _filter) { // Append the wanted extension for the plugins. FUStringBuilder pluginFolder(folderName); fchar lastChar = folderName[pluginFolder.length() - 1]; if (lastChar != '\\' && lastChar != '/') pluginFolder.append((fchar) '/'); pluginFolder.append(FC("Plugins/")); pluginFolderName = pluginFolder.ToString(); if (_filter == NULL || _filter[0] == 0) _filter = FC("*.*"); do { const fchar* nextFilter = fstrchr(_filter, '|'); fstring filter(_filter); if (nextFilter != NULL) { filter.erase(nextFilter - _filter); ++nextFilter; // skip the pipe. } _filter = nextFilter; // Windows-only for now. #if defined(WIN32) size_t filterLength = filter.length(); // Iterate over all the filtered files within the given folder. ffinddata folderIterator; fstring searchString = pluginFolderName + filter; intptr_t folderHandle = ffindfirst(searchString.c_str(), &folderIterator); if (folderHandle != -1L) { int32 isDone = FALSE; while (isDone == FALSE) { bool keep = false; PluginLibrary* library = new PluginLibrary(); library->filename = pluginFolderName + folderIterator.name; // work around for wildcards and 3 letter extensions that pick up 3+ letter extensions // e.g. "dir *.fvp" in command prompt on a directory with "a.fvp", "a.fvpa", and "a.dll" returns // "a.fvp" and "a.fvpa" bool checkModule = true; if (filterLength > 3) { if ((filter.at(filterLength-4) == FC('.')) && (filter.at(filterLength-3) != FC('*')) && (filter.at(filterLength-2) != FC('*')) && (filter.at(filterLength-1) != FC('*'))) { size_t filepathLength = fstrlen(folderIterator.name); checkModule = (folderIterator.name[filepathLength-4] == filter.at(filterLength-4)) && (folderIterator.name[filepathLength-3] == filter.at(filterLength-3)) && (folderIterator.name[filepathLength-2] == filter.at(filterLength-2)) && (folderIterator.name[filepathLength-1] == filter.at(filterLength-1)); } } library->module = LoadLibrary(library->filename.c_str()); if (checkModule && (library->module != NULL)) { // Retrieve the necessary callbacks library->getPluginCount = (GetPluginCount) GetProcAddress(library->module, "GetPluginCount"); library->getPluginType = (GetPluginType) GetProcAddress(library->module, "GetPluginType"); library->createPlugin = (CreatePlugin) GetProcAddress(library->module, "CreatePlugin"); keep = library->createPlugin != NULL && library->getPluginType != NULL && library->getPluginCount != NULL; } // This is a valid library. if (keep) loadedLibraries.push_back(library); else { SAFE_DELETE(library); } isDone = ffindnext(folderHandle, &folderIterator); } ffindclose(folderHandle); } #elif defined(__APPLE__) || defined(LINUX) fm::string s_filter = TO_STRING(filter); if (s_filter.length() > 0 && s_filter.front() == '*') s_filter.erase(0, 1); if (s_filter.length() > 0 && s_filter.back() == '*') s_filter.pop_back(); DIR* directory = opendir(TO_STRING(pluginFolderName).c_str()); if (directory == NULL) continue; dirent* directoryEntry; while ((directoryEntry = readdir(directory)) != NULL) { if (directoryEntry->d_type == DT_DIR) continue; // skip sub-folders. if (strstr((const char*) directoryEntry->d_name, s_filter.c_str()) != NULL) { // We have a match. bool keep = false; PluginLibrary* library = new PluginLibrary(); library->filename = pluginFolderName + TO_FSTRING((const char*) directoryEntry->d_name); fm::string libraryModuleFilename = TO_STRING(library->filename); DEBUG_OUT("Found dynamic library: %s\n", libraryModuleFilename.c_str()); library->module = dlopen(libraryModuleFilename.c_str(), RTLD_NOW); if (library->module != NULL) { // Retrieve the necessary callbacks library->getPluginCount = (GetPluginCount) dlsym(library->module, "GetPluginCount"); library->getPluginType = (GetPluginType) dlsym(library->module, "GetPluginType"); library->createPlugin = (CreatePlugin) dlsym(library->module, "CreatePlugin"); keep = library->createPlugin != NULL && library->getPluginType != NULL && library->getPluginCount != NULL; } // This is a valid library. if (keep) loadedLibraries.push_back(library); else { SAFE_DELETE(library); } } } closedir(directory); #endif // WIN32 } while (_filter != NULL); }