I am new to using the FBX SDK and I am trying to convert an OBJ file to an FBX ASCII file in C++. However, when running the following code it outputs a Binary FBX file and the file seems to be incorrect/"corrupted." The reason I say it is corrupted is because when I insert it into the FBX conversion program that Autodesk provides, it says the input binary file I got as an output from my program is corrupted. Can anyone help me solve this issue please? Thank you in advance.
//Creates a SDK manager
FbxManager* fbxmanager = FbxManager::Create();
//Set the Input/Output Settings for the SDK Manager
//EXP_ = export settings; IMP_ = import setting
FbxIOSettings* ios_settings = FbxIOSettings::Create(fbxmanager, IOSROOT);
ios_settings->SetBoolProp(EXP_ASCIIFBX, true);
fbxmanager->SetIOSettings(ios_settings);
//Creates a Scene
FbxScene* fbxscene = FbxScene::Create(fbxmanager, "");
//Creates an importer object
FbxImporter* fbximporter = FbxImporter::Create(fbxmanager, "");
//Path to the obj file
const char* obj_path = "objs/airboat.obj";
//Path to the saved fbx file
const char* fbx_path = "fbxs/global_mesh.fbx";
//Initilaize the Importer Object with the path and name of the file
bool import_stat = fbximporter->Initialize(obj_path, -1, fbxmanager->GetIOSettings());
import_stat = fbximporter->Import(fbxscene);
//Creates an exporter object
FbxExporter* fbxexporter = FbxExporter::Create(fbxmanager, "");
//Initilaize the Exporter Object with the path and name of the file
bool export_stat = fbxexporter->Initialize(fbx_path, -1,fbxmanager->GetIOSettings());
export_stat = fbxexporter->Export(fbxscene);
EDIT: Sorry forgot to provide debugging output:
All boolean functions result in true.
Related
I am creating an FBX file through Assimp which makes too much size.
Sample source code:
scene->mRootNode = new aiNode();
scene->mMaterials = new aiMaterial*[1];
scene->mMaterials[0] = nullptr;
scene->mNumMaterials = 1;
scene->mMaterials[0] = new aiMaterial();
scene->mMeshes = new aiMesh*[numMesh];
scene->mNumMeshes = numMesh;
scene->mRootNode->mMeshes = new unsigned int[numMesh];
scene->mRootNode->mNumMeshes = numMesh;
Please let me know if anyone has encountered the same problem.
I'm trying to use log4cxx to log my application using RollingFileAppender on a Windows C++ console application. I would like to create a new log file every time the size reaches 1MB. Furthermore, when the desired size is reached, the file should be zipped automatically. The maximum number of files created must be 10; after which older files should be overwritten.
I'm using:
apache-log4cxx-0.10.0
apr-util-1.6.1
apr-1.7.0
This is my code:
log4cxx::rolling::RollingFileAppender* fileAppender1 = new log4cxx::rolling::RollingFileAppender();
fileAppender1->setLayout(log4cxx::LayoutPtr(new log4cxx::PatternLayout(L"[%d{ISO8601}{GMT}] %-4r [%t] %c | %-5p | %m%n")));
fileAppender1->setAppend(true);
log4cxx::helpers::Pool p;
fileAppender1->activateOptions(p);
log4cxx::rolling::FixedWindowRollingPolicy* rollingPolicy = new log4cxx::rolling::FixedWindowRollingPolicy();
rollingPolicy->setMinIndex(1);
rollingPolicy->setMaxIndex(10);
rollingPolicy->setFileNamePattern(L"j_log_%i.log");
log4cxx::rolling::SizeBasedTriggeringPolicy* triggerPolicy = new log4cxx::rolling::SizeBasedTriggeringPolicy();
triggerPolicy->setMaxFileSize(1024*1024);
fileAppender1->setRollingPolicy(rollingPolicy);
fileAppender1->setTriggeringPolicy(triggerPolicy);
LoggerPtr logger(Logger::getLogger("LogConsole1"));
logger->addAppender(fileAppender1);
logger->setLevel(log4cxx::Level::getTrace());
for (int i = 0; i < 10000; i++)
{
LOG4CXX_INFO(logger, "Created FileAppender appender");
LOG4CXX_INFO(logger, "LOGGER1");
}
The result obtained is a file named ".1" (without any extension) with such content (it seems ok):
[2019-09-13 07:44:58,619] 21063 [0x00003e14] LogConsole1 | INFO | Created FileAppender appender
[2019-09-13 07:44:58,622] 21066 [0x00003e14] LogConsole1 | INFO | LOGGER1
The problems are:
The file does not have the proper name
The file does not roll over (only one file is created also if its size exceeds 1MB)
On the application console I see many exceptions like: "log4cxx: Exception during rollover"
What am I doing wrong?
I do not completely understand your file pattern but the docs do not use the "L" char in their Pattern.
In my projects is use
rollingPolicy->setFileNamePattern("file.%i.log");
sometimes with a string variable which works good.
I can not find the configuration in your code snipped.
As far as i know, you have to setup the appender by using the BasicConfiguration object.
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(yourAppenderPointer));
this will append your appender to the root logger and works for my case.
Here is my full code snippet of my initialize.
void someclass::initLogger(std::string fileName) {
std::string::size_type found = fileName.find(".log");
std::string strippedFileName;
if (found != std::string::npos)
{
strippedFileName = fileName.substr(0, found);
}
else
{
strippedFileName = fileName;
fileName = fileName + ".log";
}
//initializes for rolling file appenders
rollingFileAppender = new log4cxx::rolling::RollingFileAppender();
rollingPolicy = new log4cxx::rolling::FixedWindowRollingPolicy();
rollingPolicy->setMinIndex(1);
rollingPolicy->setMaxIndex(3);
log4cxx::LogString fileNamePattern = strippedFileName + ".%i.log";
rollingPolicy->setFileNamePattern(fileNamePattern);
trigger = new log4cxx::rolling::SizeBasedTriggeringPolicy();
trigger->setMaxFileSize(1024);
rollingFileAppender->setRollingPolicy(rollingPolicy);
rollingFileAppender->setTriggeringPolicy(trigger);
rollingFileAppender->setLayout(log4cxx::LayoutPtr(new log4cxx::PatternLayout(LOGFILE_LAYOUT_PATTERN)));
rollingFileAppender->setFile(fileName);
rollingFileAppender->setAppend(true);
//initializes for a console appender
consoleAppender = new log4cxx::ConsoleAppender(log4cxx::LayoutPtr(new log4cxx::PatternLayout(LOGFILE_LAYOUT_PATTERN)));
log4cxx::helpers::Pool p;
rollingFileAppender->activateOptions(p);
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(consoleAppender));
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(rollingFileAppender));
}
This code prints to a specified file via a rolling file appender and also prints to the terminal using the consoleAppender
This prints file one file with fileName.log and up to three more with fileName.i.log
I want to load a saved .rssdk file as input to my realsense application. I saw the below code from examples.
pxcCHAR fileName[1024] = { 0 };
PXCSenseManager *psm = PXCSenseManager::CreateInstance();
PXCCaptureManager* captureManager = psm->QueryCaptureManager();
captureManager->SetFileName(fileName, false);
psm->QueryCaptureManager()->SetRealtime(false);
But my problem is how to give my file name (suppose "out.rssdk") to this pxcCHAR fileName??
pxcCHAR is just a wchar:
typedef wchar_t pxcCHAR;
so you can just use a wchar literal:
pxcCHAR fileName[1024] = L"out.rssdk";
and other wchar stuff like std::wstring.
I would like to access files which are inside Resources in app bundle. Unfortunately i cannot use QT resorces, as i'm using CascadeClassifier from opencv. My current paths are
const std::string FACE_CLASIFIER_PATH = "/Resources/haarcascade_frontalface_default.xml";
const std::string EYES_CLASIFIER_PATH = "/Resources/haarcascade_mcs_eyepair_big.xml";
I also tried
const std::string FACE_CLASIFIER_PATH = "../Resources/haarcascade_frontalface_default.xml";
const std::string EYES_CLASIFIER_PATH = "../Resources/haarcascade_mcs_eyepair_big.xml";
But nether of them work. As for config both files are present inside MyApp.app/Contents/Resources, i include them using qmake
mac {
APP_XML_FILES.files = ../haarcascade_frontalface_default.xml ../haarcascade_mcs_eyepair_big.xml
APP_XML_FILES.path = Contents/Resources
QMAKE_BUNDLE_DATA += APP_XML_FILES
}
I would appreciate any help with this issue
You don't say what you want to do with the files, though that could be due to my lack of knowledge of opencv. However you can use the Core Foundation classes to get paths to files in the resources folder: -
CFURLRef appUrlRef;
appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("somefile"), NULL, NULL);
// do something with the file
//...
// Ensure you release the reference
CFRelease(appUrlRef);
With a CFURLRef, you can use Apple's documentation to get what you need from it.
For example, if you want a file path: -
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
// Always release items retrieved with a function that has "create or "copy" in its name
CFRelease(filePathRef);
From the file path, we can get a char* to the path: -
const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
So, putting it all together, if you want to get a char* path to haarcascade_mcs_eyepair_big.xml: -
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("haarcascade_mcs_eyepair_big.xml"), NULL, NULL);
CFStringRef filePathRef = CFURLCopyPath(appUrlRef);
const char* filePath = CFStringGetCStringPtr(filePathRef, kCFStringEncodingUTF8);
// Release references
CFRelease(filePathRef);
CFRelease(appUrlRef);
i am trying to create an ARFF file using ArffSaver. (i am actually converting an non-arff file that is very large.)
i am trying to write the file incrementally using the writeIncremental(Instance insntance) method. unfortunately, each call to writeIncremental() results in data being written to System.out -- not to the designated file.
here is a clip of my code:
FileOutputStream out = new FileOutputStream(outFilename);
ArffSaver saver = new ArffSaver();
saver.setDestination(out);
saver.setRetrieval(Saver.INCREMENTAL);
saver.setStructure(instances);
String s = null;
while ((s = in.readLine()) != null) {
Instance instance = toInstance(s, instances);
saver.writeIncremental(instance);
}
saver.writeIncremental(null);
any ideas on how i can get the ArffSaver to write incrementally to the file?
I'm using this and works fine:
saver.setFile(new File(outputFile));
saver.setDestination(new File(outputFile));