[英]assimp fail to find the obj. file
I try to use Assimp::Importer.ReadFile() to load my obj.file but it turns out that assimp fail to find the file correctly.我尝试使用 Assimp::Importer.ReadFile() 加载我的 obj.file,但事实证明 assimp 无法正确找到该文件。
Here is a simple test这是一个简单的测试
#include<string>
#include<assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace std;
int main(){
Assimp::Importer importer;
string modelPath = "D:\\素材\\nanosuit\\nanosuit.obj";
const aiScene* scene = importer.ReadFile(modelPath, aiProcess_Triangulate | aiProcess_FlipUVs );
if (!scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) {
cout << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
}
else cout << scene;
and the output is following text和 output 是以下文字
ERROR::ASSIMP::Unable to open file "D:\素材\nanosuit\nanosuit.obj".
I haved tried to load different obj.file and it doesn't work too我曾尝试加载不同的 obj.file,但它也不起作用
This is a problem with the unicode name.这是 unicode 名称的问题。 You need to use a workaround to fix this.
您需要使用解决方法来解决此问题。 Use the Wi32-API-Call
使用 Wi32-API-Call
SetCurrentDirectory(L"D:\\素材\\nanosuit\\");
to open the folder and import the asset afterwards:打开文件夹并在之后导入资产:
const aiScene* scene = importer.ReadFile(L"nanosuit.obj", aiProcess_Triangulate | aiProcess_FlipUVs );
There is a design error in the Asset-Importer-Lib. Asset-Importer-Lib 中存在设计错误。 The imported name will be used to name the asset and the asset-name is using ASCII.
导入的名称将用于命名资产,资产名称使用 ASCII。 So unicode names will interpreted as ASCII-names and this will cause your error.
所以 unicode 名称将被解释为 ASCII 名称,这将导致您的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.