void ep::Plugin::startup() { if(m_initialized) return; // it initializes the Translator support for the TerraLib VP Qt Plugin //TE_ADD_TEXT_DOMAIN(TE_QT_PLUGIN_VP_TEXT_DOMAIN, TE_QT_PLUGIN_VP_TEXT_DOMAIN_DIR, "UTF-8"); //TE_LOG_TRACE(TE_TR("TerraLib Qt VP Plugin startup!")); QMenu* pluginMenu = te::qt::af::AppCtrlSingleton::getInstance().getMenu("Processing"); m_myAction = new QAction(pluginMenu); m_myAction->setText("Remove Clouds"); pluginMenu->addAction(m_myAction); //connect(m_myAction, SIGNAL(triggered(te::qt::af::evt::Event*)), SIGNAL(triggered(te::qt::af::evt::Event*))); connect(m_myAction, SIGNAL(triggered(bool)), this, SLOT(onActionActivated(bool))); // vp log startup std::string path = te::qt::af::AppCtrlSingleton::getInstance().getUserDataDir().toStdString(); path += "/log/externalplugin.log"; #if defined(TERRALIB_APACHE_LOG4CXX_ENABLED) && defined(TERRALIB_LOGGER_ENABLED) std::string layout = "%d{ISO8601} [%t] %-5p %c - %m%n"; log4cxx::LogString lString(layout.begin(), layout.end()); log4cxx::FileAppender* fileAppender = new log4cxx::RollingFileAppender(log4cxx::LayoutPtr(new log4cxx::PatternLayout(lString)), log4cxx::helpers::Transcoder::decode(path.c_str()), true); log4cxx::helpers::Pool p; fileAppender->activateOptions(p); log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(fileAppender)); log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug()); log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("vp"); logger->setAdditivity(false); logger->addAppender(fileAppender); #endif m_initialized = true; te::qt::af::AppCtrlSingleton::getInstance().addListener(this, te::qt::af::SENDER); }
bool FBXReader::loadScene(FbxManager* fbxManager, FbxDocument* scene, string fileName) { int lFileMajor, lFileMinor, lFileRevision; int lSDKMajor, lSDKMinor, lSDKRevision; //int lFileFormat = -1; int i, lAnimStackCount; bool lStatus; char lPassword[1024]; // Get the file version number generate by the FBX SDK. FbxManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision); // Create an importer. FbxImporter* lImporter = FbxImporter::Create(fbxManager, ""); // Initialize the importer by providing a filename. const bool lImportStatus = lImporter->Initialize(fileName.c_str(), -1, fbxManager->GetIOSettings()); lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if (!lImportStatus) { FbxString error = lImporter->GetStatus().GetErrorString(); FBXSDK_printf("Call to FbxImporter::Initialize() failed.\n"); FBXSDK_printf("Error returned: %s\n\n", error.Buffer()); if (lImporter->GetStatus().GetCode() == FbxStatus::eInvalidFileVersion) { FBXSDK_printf("FBX file format version for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); FBXSDK_printf("FBX file format version for file '%s' is %d.%d.%d\n\n", fileName, lFileMajor, lFileMinor, lFileRevision); } return false; } FBXSDK_printf("FBX file format version for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); if (lImporter->IsFBX()) { FBXSDK_printf("FBX file format version for file '%s' is %d.%d.%d\n\n", fileName, lFileMajor, lFileMinor, lFileRevision); // From this point, it is possible to access animation stack information without // the expense of loading the entire file. FBXSDK_printf("Animation Stack Information\n"); lAnimStackCount = lImporter->GetAnimStackCount(); FBXSDK_printf(" Number of Animation Stacks: %d\n", lAnimStackCount); FBXSDK_printf(" Current Animation Stack: \"%s\"\n", lImporter->GetActiveAnimStackName().Buffer()); FBXSDK_printf("\n"); for (i = 0; i < lAnimStackCount; i++) { FbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i); FBXSDK_printf(" Animation Stack %d\n", i); FBXSDK_printf(" Name: \"%s\"\n", lTakeInfo->mName.Buffer()); FBXSDK_printf(" Description: \"%s\"\n", lTakeInfo->mDescription.Buffer()); // Change the value of the import name if the animation stack should be imported // under a different name. FBXSDK_printf(" Import Name: \"%s\"\n", lTakeInfo->mImportName.Buffer()); // Set the value of the import state to false if the animation stack should be not // be imported. FBXSDK_printf(" Import State: %s\n", lTakeInfo->mSelect ? "true" : "false"); FBXSDK_printf("\n"); } // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOS_REF.SetBoolProp(IMP_FBX_MATERIAL, true); IOS_REF.SetBoolProp(IMP_FBX_TEXTURE, true); IOS_REF.SetBoolProp(IMP_FBX_LINK, true); IOS_REF.SetBoolProp(IMP_FBX_SHAPE, true); IOS_REF.SetBoolProp(IMP_FBX_GOBO, true); IOS_REF.SetBoolProp(IMP_FBX_ANIMATION, true); IOS_REF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } // Import the scene. lStatus = lImporter->Import(scene); if (lStatus == false && lImporter->GetStatus().GetCode() == FbxStatus::ePasswordError) { FBXSDK_printf("Please enter password: "******"%s", lPassword); FBXSDK_CRT_SECURE_NO_WARNING_END FbxString lString(lPassword); IOS_REF.SetStringProp(IMP_FBX_PASSWORD, lString); IOS_REF.SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true); lStatus = lImporter->Import(scene); if (lStatus == false && lImporter->GetStatus().GetCode() == FbxStatus::ePasswordError) { FBXSDK_printf("\nPassword is wrong, import aborted.\n"); } } // Destroy the importer. lImporter->Destroy(); return lStatus; }
void VoxGame::AddConsoleLabel(string message) { if (m_GUICreated == false) { m_vStringCache.push_back(message); return; } char lChatString[8192]; sprintf(lChatString, "%s", message.c_str()); string chatString = lChatString; int lCharIndex = 0; int lStartLineIndex = 0; int lPreviousSpaceIndex = 0; // Our position float lCurrentTextX = 0.0f; int newLineIndex = 1; int indexToUse = (int)m_vpConsoleLabels.size() + (int)m_vpConsoleLabels_Add.size(); while (lChatString[lCharIndex] != 0) { char lpChar = lChatString[lCharIndex]; char lpNextChar = lChatString[lCharIndex + 1]; // Check for spaces if (lpChar == ' ') { string lString(chatString.substr(lStartLineIndex, lCharIndex - lStartLineIndex)); int lTextLineWidth = m_pRenderer->GetFreeTypeTextWidth(m_defaultFont, "%s", lString.c_str()); // If the current X position, plus our new text length is greater than the width, then we know we will go out of bounds if (lCurrentTextX + lTextLineWidth > m_pConsoleScrollbar->GetScrollArea().m_width) { string lString(chatString.substr(lStartLineIndex, lPreviousSpaceIndex - lStartLineIndex)); Label* pNewLabel = new Label(m_pRenderer, m_defaultFont, lString.c_str(), Colour(1.0f, 1.0f, 1.0f)); int xPos = m_pConsoleScrollbar->GetScrollArea().m_x; int yPos = m_pConsoleScrollbar->GetScrollArea().m_y + m_pConsoleScrollbar->GetScrollArea().m_height - (indexToUse + newLineIndex) * 14; pNewLabel->SetLocation(xPos, yPos); m_vpConsoleLabels_Add.push_back(pNewLabel); // Skip over the new line, else we will detect it on the next loop lStartLineIndex = lPreviousSpaceIndex + 1; newLineIndex++; } lPreviousSpaceIndex = lCharIndex; } // Check for the end of the string if (lpNextChar == 0) { string lString(chatString.substr(lStartLineIndex, lCharIndex + 1 - lStartLineIndex)); int lTextLineWidth = m_pRenderer->GetFreeTypeTextWidth(m_defaultFont, "%s", lString.c_str()); Label* pNewLabel = new Label(m_pRenderer, m_defaultFont, lString.c_str(), Colour(1.0f, 1.0f, 1.0f)); int xPos = m_pConsoleScrollbar->GetScrollArea().m_x; int yPos = m_pConsoleScrollbar->GetScrollArea().m_y + m_pConsoleScrollbar->GetScrollArea().m_height - (indexToUse + newLineIndex) * 14; pNewLabel->SetLocation(xPos, yPos); m_vpConsoleLabels_Add.push_back(pNewLabel); } lCharIndex++; } }
bool Fbx::LoadScene( KFbxSdkManager* pSdkManager, KFbxDocument* pScene, const char* pFilename ) { int lFileMajor, lFileMinor, lFileRevision; int lSDKMajor, lSDKMinor, lSDKRevision; //int lFileFormat = -1; int i, lTakeCount; KString lCurrentTakeName; bool lStatus; char lPassword[1024]; // Get the file version number generate by the FBX SDK. KFbxSdkManager::GetFileFormatVersion(lSDKMajor, lSDKMinor, lSDKRevision); // Create an importer. KFbxImporter* lImporter = KFbxImporter::Create(pSdkManager,""); // Initialize the importer by providing a filename. const bool lImportStatus = lImporter->Initialize(pFilename); lImporter->GetFileVersion(lFileMajor, lFileMinor, lFileRevision); if( !lImportStatus ) { printf("Call to KFbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", lImporter->GetLastErrorString()); if (lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_YET || lImporter->GetLastErrorID() == KFbxIO::eFILE_VERSION_NOT_SUPPORTED_ANYMORE) { printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); } return false; } printf("FBX version number for this FBX SDK is %d.%d.%d\n", lSDKMajor, lSDKMinor, lSDKRevision); if (lImporter->IsFBX()) { printf("FBX version number for file %s is %d.%d.%d\n\n", pFilename, lFileMajor, lFileMinor, lFileRevision); // From this point, it is possible to access take information without // the expense of loading the entire file. printf("Take Information\n"); lTakeCount = lImporter->GetTakeCount(); printf(" Number of takes: %d\n", lTakeCount); printf(" Current take: \"%s\"\n", lImporter->GetCurrentTakeName()); printf("\n"); for(i = 0; i < lTakeCount; i++) { KFbxTakeInfo* lTakeInfo = lImporter->GetTakeInfo(i); printf(" Take %d\n", i); printf(" Name: \"%s\"\n", lTakeInfo->mName.Buffer()); printf(" Description: \"%s\"\n", lTakeInfo->mDescription.Buffer()); // Change the value of the import name if the take should be imported // under a different name. printf(" Import Name: \"%s\"\n", lTakeInfo->mImportName.Buffer()); // Set the value of the import state to false if the take should be not // be imported. printf(" Import State: %s\n", lTakeInfo->mSelect ? "true" : "false"); printf("\n"); } // Set the import states. By default, the import states are always set to // true. The code below shows how to change these states. IOSREF.SetBoolProp(IMP_FBX_MATERIAL, true); IOSREF.SetBoolProp(IMP_FBX_TEXTURE, true); IOSREF.SetBoolProp(IMP_FBX_LINK, true); IOSREF.SetBoolProp(IMP_FBX_SHAPE, true); IOSREF.SetBoolProp(IMP_FBX_GOBO, true); IOSREF.SetBoolProp(IMP_FBX_ANIMATION, true); IOSREF.SetBoolProp(IMP_FBX_GLOBAL_SETTINGS, true); } // Import the scene. lStatus = lImporter->Import(pScene); if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR) { printf("Please enter password: "******"%s", lPassword); KString lString(lPassword); IOSREF.SetStringProp(IMP_FBX_PASSWORD, lString); IOSREF.SetBoolProp(IMP_FBX_PASSWORD_ENABLE, true); lStatus = lImporter->Import(pScene); if(lStatus == false && lImporter->GetLastErrorID() == KFbxIO::ePASSWORD_ERROR) { printf("\nPassword is wrong, import aborted.\n"); } } // Destroy the importer. lImporter->Destroy(); return lStatus; }
//Read the custom file and reconstruct node hierarchy. bool FBXImporterReader::Read(KFbxDocument* pDocument, KFbxStreamOptions* pStreamOptions) { if (!pDocument) { GetError().SetLastErrorID(eINVALID_DOCUMENT_HANDLE); return false; } KFbxScene* lScene = KFbxCast<KFbxScene>(pDocument); bool lIsAScene = (lScene != NULL); bool lResult = false; if(lIsAScene) { KFbxNode* lRootNode = lScene->GetRootNode(); KFbxNodeAttribute * lRootNodeAttribute = KFbxNull::Create(mManager,""); lRootNode->SetNodeAttribute(lRootNodeAttribute); int lSize; char* lBuffer; if(mFilePointer != NULL) { //To obtain file size fseek (mFilePointer , 0 , SEEK_END); lSize = ftell (mFilePointer); rewind (mFilePointer); //Read file content to a string. lBuffer = (char*) malloc (sizeof(char)*lSize); size_t lRead = fread(lBuffer, 1, lSize, mFilePointer); lBuffer[lRead]='\0'; KString lString(lBuffer); //Parse the string to get name and relation of Nodes. KString lSubString, lChildName, lParentName; KFbxNode* lChildNode; KFbxNode* lParentNode; KFbxNodeAttribute* lChildAttribute; int lEndTokenCount = lString.GetTokenCount("\n"); for (int i = 0; i < lEndTokenCount; i++) { lSubString = lString.GetToken(i, "\n"); KString lNodeString; lChildName = lSubString.GetToken(0, "\""); lParentName = lSubString.GetToken(2, "\""); //Build node hierarchy. if(lParentName == "RootNode") { lChildNode = KFbxNode::Create(mManager,lChildName.Buffer()); lChildAttribute = KFbxNull::Create(mManager,""); lChildNode->SetNodeAttribute(lChildAttribute); lRootNode->AddChild(lChildNode); } else { lChildNode = KFbxNode::Create(mManager,lChildName.Buffer()); lChildAttribute = KFbxNull::Create(mManager,""); lChildNode->SetNodeAttribute(lChildAttribute); lParentNode = lRootNode->FindChild(lParentName.Buffer()); lParentNode->AddChild(lChildNode); } } } lResult = true; } return lResult; }