本文整理汇总了C++中assimp::Importer类的典型用法代码示例。如果您正苦于以下问题:C++ Importer类的具体用法?C++ Importer怎么用?C++ Importer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Importer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LoadFromFileImport
bool AURenMesh::LoadFromFileImport( const std::string& strFilename )
{
#ifndef NO_ASSIMP
Assimp::Importer importer;
const aiScene* pScene = importer.ReadFile( strFilename, aiProcessPreset_TargetRealtime_Fast );
if (!pScene || pScene->mNumMeshes == 0)
{
return false;
}
ProcessScene(pScene);
return true;
#else
assert( false );
return false;
#endif
}
开发者ID:BobSmun,项目名称:RuntimeCompiledCPlusPlus,代码行数:20,代码来源:AURenMesh.cpp
示例2: loadModel
void Model::loadModel(std::string path) {
// Read file via ASSIMP
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(path,
aiProcess_Triangulate | aiProcess_FlipUVs
| aiProcess_CalcTangentSpace);
// Check for errors
if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE
|| !scene->mRootNode) // if is Not Zero
{
std::cout << "ERROR::ASSIMP:: " << importer.GetErrorString()
<< std::endl;
return;
}
// Retrieve the directory path of the filepath
this->directory = path.substr(0, path.find_last_of('/'));
// Process ASSIMP's root node recursively
this->processNode(scene->mRootNode, scene);
}
开发者ID:rmartella,项目名称:DIMyR,代码行数:20,代码来源:Model.cpp
示例3:
TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
float opacity;
aiScene *scene( TestModelFacttory::createDefaultTestModel( opacity ) );
Assimp::Importer importer;
Assimp::Exporter exporter;
std::string path = "dae";
const aiExportFormatDesc *desc( exporter.GetExportFormatDescription( 0 ) );
EXPECT_NE( desc, nullptr );
path.append( desc->fileExtension );
EXPECT_EQ( AI_SUCCESS, exporter.Export( scene, desc->id, path ) );
const aiScene *newScene( importer.ReadFile( path, 0 ) );
EXPECT_TRUE( NULL != newScene );
float newOpacity;
if ( newScene->mNumMaterials > 0 ) {
std::cout << "Desc = " << desc->description << "\n";
EXPECT_EQ( AI_SUCCESS, newScene->mMaterials[ 0 ]->Get( AI_MATKEY_OPACITY, newOpacity ) );
EXPECT_EQ( opacity, newOpacity );
}
}
开发者ID:mrcrr8614,项目名称:assimp,代码行数:20,代码来源:utIssues.cpp
示例4:
Model::Model(string file)
{
if (!Globals::File_Exists(FOLDER+file)) {
cout << "File " << FOLDER + file << " does not exist. Can not load model." << endl;
return;
}
path = FOLDER + file.substr(0, file.find_last_of('/')) + '/';
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(FOLDER + file, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenNormals | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
cout << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
return;
}
processNode(scene->mRootNode, scene);
}
开发者ID:Roxling,项目名称:smegod,代码行数:20,代码来源:models.cpp
示例5: aiImportFileFromMemoryWithProperties
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileFromMemoryWithProperties(
const char* pBuffer,
unsigned int pLength,
unsigned int pFlags,
const char* pHint,
const aiPropertyStore* props)
{
ai_assert(NULL != pBuffer && 0 != pLength);
const aiScene* scene = NULL;
ASSIMP_BEGIN_EXCEPTION_REGION();
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer();
// copy properties
if(props) {
const PropertyMap* pp = reinterpret_cast<const PropertyMap*>(props);
ImporterPimpl* pimpl = imp->Pimpl();
pimpl->mIntProperties = pp->ints;
pimpl->mFloatProperties = pp->floats;
pimpl->mStringProperties = pp->strings;
}
// and have it read the file from the memory buffer
scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint);
// if succeeded, store the importer in the scene and keep it alive
if( scene) {
ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
priv->mOrigImporter = imp;
}
else {
// if failed, extract error code and destroy the import
gLastErrorString = imp->GetErrorString();
delete imp;
}
// return imported data. If the import failed the pointer is NULL anyways
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
return scene;
}
开发者ID:etherealvisage,项目名称:kriti,代码行数:42,代码来源:Assimp.cpp
示例6: LoadMesh
Mesh * LoadMesh(const char * filename)
{
// Create an instance of the Importer class
Assimp::Importer importer;
// And have it read the given file with some example postprocessing
// Usually - if speed is not the most important aspect for you - you'll
// propably to request more postprocessing than we do in this example.
const aiScene* aiscene = importer.ReadFile( filename,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
// If the import failed, report it
if( !aiscene)
{
printf("%s \n", importer.GetErrorString());
return NULL;
}
aiMesh * aimesh;
Mesh * mesh = new Mesh();
std::vector<vec3> vertex;
std::vector<vec3> normal;
std::vector<vec3> tangent;
std::vector<vec2> texCoord;
// Now we can access the file's contents.
for(u32 i=0; i<aiscene->mNumMeshes(); ++i)
{
aimesh = aiscene->mMeshes[i];
if(aimesh->HasPositions())
{
}
}
return mesh;
}
开发者ID:scanberg,项目名称:gazpacho,代码行数:41,代码来源:LoadMesh.cpp
示例7: LoadFile
int SceneLoader::LoadFile(const char* filename)
{
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(filename, 0);
scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace | aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_JoinIdenticalVertices);
if (!scene)
{
std::stringstream oss;
oss << "ERROR - File: " << filename << " not found." << std::endl;
std::string debugMsg(oss.str());
OutputDebugStringA(debugMsg.c_str());
return false;
}
DrawableObject *newObject = new DrawableObject();
std::vector<Vertex> vertexList;
std::vector<UINT> indexList;
std::stringstream oss;
for (unsigned int i = 0; i < scene->mRootNode->mNumChildren; ++i)
{
bool successfulLoad = true;
aiNode* currentNode = scene->mRootNode->mChildren[i];
BuildShaders(d3dDevice, *newObject, mShaderManager);
for (unsigned int j = 0; j < currentNode->mNumMeshes; ++j)
{
ProcessMesh(d3dDevice, *scene->mMeshes[currentNode->mMeshes[j]], *newObject, vertexList, indexList, scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex - 1);
//LoadMaterials(d3dDevice, scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex, *newObject, scene);
oss << "MatIndex = " << scene->mMeshes[currentNode->mMeshes[j]]->mMaterialIndex << "\n";
}
}
std::string debugMsg(oss.str());
OutputDebugStringA(debugMsg.c_str());
for (unsigned int i = 0; i < scene->mNumMaterials; ++i)
{
LoadMaterials(d3dDevice, i, *newObject, scene);
}
newObject->GetMeshData()->Initialize(d3dDevice, vertexList, indexList);
mDrawableObjects.push_back(newObject);
return mDrawableObjects.size() - 1;
}
开发者ID:laurencerwong,项目名称:ITP-470-Deferred-Renderer,代码行数:41,代码来源:SceneLoader.cpp
示例8: aiImportFileEx
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileEx( const char* pFile, unsigned int pFlags,
aiFileIO* pFS)
{
ai_assert(NULL != pFile);
// create an Importer for this file
Assimp::Importer* imp = new Assimp::Importer;
// copy the global property lists to the Importer instance
// (we are a friend of Importer)
imp->pimpl->mIntProperties = gIntProperties;
imp->pimpl->mFloatProperties = gFloatProperties;
imp->pimpl->mStringProperties = gStringProperties;
// setup a custom IO system if necessary
if (pFS)
{
imp->SetIOHandler( new CIOSystemWrapper (pFS) );
}
// and have it read the file
const aiScene* scene = imp->ReadFile( pFile, pFlags);
// if succeeded, place it in the collection of active processes
if( scene)
{
#if (defined AI_C_THREADSAFE)
boost::mutex::scoped_lock lock(gMutex);
#endif
gActiveImports[scene] = imp;
}
else
{
// if failed, extract error code and destroy the import
gLastErrorString = imp->GetErrorString();
delete imp;
}
// return imported data. If the import failed the pointer is NULL anyways
return scene;
}
开发者ID:abc00,项目名称:adrian,代码行数:42,代码来源:Assimp.cpp
示例9: GetVertices
std::shared_ptr<Scene> SceneFactory::CreateFromFile(const std::string& filename) {
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(filename,
aiProcess_Triangulate |
aiProcess_GenNormals |
aiProcess_ImproveCacheLocality |
aiProcess_JoinIdenticalVertices |
aiProcess_PreTransformVertices);
if (scene == NULL) {
std::printf("\nImport failed:\n\t");
auto errorString = importer.GetErrorString();
std::printf(errorString);
std::printf("\n");
return nullptr;
}
Scene::vertexList vertices = GetVertices(scene);
Scene::triangleList faces = GetFaces(scene);
Scene::materialList materials = GetMaterials(scene);
return std::shared_ptr<Scene>(new Scene(vertices, faces, materials));
}
开发者ID:naavis,项目名称:remonttimies,代码行数:21,代码来源:SceneFactory.cpp
示例10:
std::shared_ptr<MeshData> RE::FileSystem::LoadModel(const std::wstring &filePath)
{
const std::string sFilePaths{ filePath.begin(), filePath.end() };
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(sFilePaths,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType |
aiProcess_ConvertToLeftHanded |
aiProcess_FixInfacingNormals
);
if (!scene)
{
Log::Get().Write(std::string("[FileSystem] Assimp importer could not read mesh file:") + importer.GetErrorString());
}
return std::make_shared<MeshData>(ProcessAssimpScene(scene->mRootNode, scene));
}
开发者ID:ArcEcho,项目名称:LearningDirectX11,代码行数:21,代码来源:FileSystem.cpp
示例11: Load
void Mesh::Load()
{
Clear();
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(sFilepath.c_str(),
aiProcess_Triangulate | aiProcess_GenSmoothNormals |
aiProcess_FlipUVs);
if(scene)
{
InitMesh(scene, sFilepath);
}
else
{
std::cout << "Cannot find " << sFilepath << " " << importer.GetErrorString() << std::endl;
//throw std::runtime_error(std::string("Error Parsing: ") + sFilepath +
//std::string("\n") + importer.GetErrorString());
}
}
开发者ID:HATtrick-games,项目名称:ICT311,代码行数:21,代码来源:Mesh.cpp
示例12: aiIsExtensionSupported
// ------------------------------------------------------------------------------------------------
// Returns the error text of the last failed import process.
aiBool aiIsExtensionSupported(const char* szExtension)
{
ai_assert(NULL != szExtension);
aiBool candoit=AI_FALSE;
ASSIMP_BEGIN_EXCEPTION_REGION();
#ifdef AI_C_THREADSAFE
boost::mutex::scoped_lock lock(gMutex);
#endif
if (!gActiveImports.empty()) {
return ((*(gActiveImports.begin())).second->IsExtensionSupported( szExtension )) ? AI_TRUE : AI_FALSE;
}
// fixme: no need to create a temporary Importer instance just for that ..
Assimp::Importer tmp;
candoit = tmp.IsExtensionSupported(std::string(szExtension)) ? AI_TRUE : AI_FALSE;
ASSIMP_END_EXCEPTION_REGION(aiBool);
return candoit;
}
开发者ID:paoletto,项目名称:space-blok-qt,代码行数:23,代码来源:Assimp.cpp
示例13: runtime_error
const std::vector<Mesh> & Mesh::loadModel(const std::string & modelName) {
static std::unordered_map<std::string, std::vector<Mesh>> meshMap;
if (meshMap.count(modelName) == 0) {
Assimp::Importer importer;
auto scene = importer.ReadFile(modelName,
aiProcess_GenNormals |
aiProcess_JoinIdenticalVertices |
aiProcess_Triangulate |
aiProcess_ImproveCacheLocality |
aiProcess_RemoveRedundantMaterials |
aiProcess_FlipUVs/* |
aiProcess_RemoveComponent*/);
if (!scene) {
throw std::runtime_error("Could not load model: " + modelName);
}
std::vector<Mesh> meshData;
loadMesh(modelName, meshData, scene->mRootNode, scene);
meshMap.emplace(modelName, std::move(meshData));
}
return meshMap[modelName];
}
开发者ID:Yelnats321,项目名称:AIShootyCooly,代码行数:21,代码来源:Mesh.cpp
示例14: fprintf
sceneLoader::sceneLoader(const char* filename)
{
Assimp::Importer importer;
//Initialize DevIL
initDevIL();
const aiScene* scene=importer.ReadFile(filename,
aiProcess_GenSmoothNormals|
aiProcess_Triangulate|
aiProcess_CalcTangentSpace|
aiProcess_FlipUVs);
if(scene->mFlags==AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
fprintf( stderr, "Couldn't load model, Error Importing Asset" );
return;
}
recursiveProcess(scene->mRootNode, scene);
}
开发者ID:alexff7,项目名称:COMP371-Project,代码行数:21,代码来源:sceneLoader.cpp
示例15: loadModel
void Model::loadModel(std::string path)
{
Assimp::Importer import;
//http://assimp.sourceforge.net/lib_html/postprocess_8h.html
//aiProcess_GenNormals
//aiProcess_GenSmoothNormals
// triangulate flip uv y avoid duplicate verts make norms if not make bitangent and tangent
const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices | aiProcess_GenNormals | aiProcess_CalcTangentSpace);
if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
std::string str = "ASSIMP ERROR: \""; str += path; str += "\" NOT LOADED;";
Logger::Log(str);
return;
}
int foundSlash = 0;
int foundDot = path.size()-1;
for (int i = 0; i != path.size() - 1; ++i)
{
if (path[i] == '/' || path[i] == '\\')
foundSlash = i+1;
if (path[i] == '.')
foundDot = i;
}
fileName = "";
for (int i = foundSlash; i != foundDot; ++i)
{
fileName += path[i];
}
this->directory = path.substr(0, path.find_last_of('/'));
this->processNode(scene->mRootNode, scene);
std::string str = "Model ASSIMP: \""; str += path; str += "\" LOADED;";
Logger::Log(str);
}
开发者ID:PieroGSadocco,项目名称:Graphics2v2,代码行数:40,代码来源:Model.cpp
示例16: LoadMesh
Resource* ResourceManager::LoadMesh(std::string filepath)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(filepath, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
// NOTE: Depending on what ReadFile returns, this may not work as intended
if (!scene)
{
#if DEBUG
Debug::LogError("[ResourceManager] Assimp importer could not read file.");
#endif
return 0;
}
MeshData data = AssimpProcessScene(scene->mRootNode, scene);
Mesh* mesh = new Mesh(data);
mesh->IncreaseReferenceCount();
resourceCollection[filepath] = mesh;
return dynamic_cast<Resource*>(mesh);
}
开发者ID:ariabonczek,项目名称:LuminaEngine_OLD,代码行数:22,代码来源:ResourceManager.cpp
示例17: Load
bool ModelLoader::Load( std::string filename, Vertex::VERTEX_TYPE type ) {
// reset extents
minX = minY = minZ = FLT_MAX;
maxX = maxY = maxZ = FLT_MIN;
Assimp::Importer importer;
std::string file = modelDir+filename;
Assimp::DefaultLogger::get()->info( "Importing: "+file );
scene = importer.ReadFile( file,
//aiProcess_CalcTangentSpace|
aiProcess_ImproveCacheLocality|
//aiProcess_MakeLeftHanded|
aiProcess_FlipWindingOrder|
aiProcess_Triangulate|
//aiProcess_JoinIdenticalVertices|
aiProcess_SortByPType|
aiProcess_FlipUVs
);
if( !scene ) {
Assimp::DefaultLogger::get()->error( importer.GetErrorString() );
return false;
}
if( !scene->HasMeshes() ) {
Assimp::DefaultLogger::get()->error( "File contains no mesh" );
return false;
}
aiMesh* sceneMesh = scene->mMeshes[0];
CreateVertexBuffer( sceneMesh, type );
CreateIndexBuffer( sceneMesh->mFaces, sceneMesh->mNumFaces );
if( scene->HasAnimations() ) {
CreateSkeleton( sceneMesh->mBones, sceneMesh->mNumBones );
CreateBoneHierarchy();
CreateAnimations();
}
return true;
}
开发者ID:bmay213,项目名称:GoblinBrawlT,代码行数:39,代码来源:ModelLoader.cpp
示例18: LoadMesh
bool Mesh::LoadMesh(const std::string& Filename)
{
Clear();
bool Ret = false;
Assimp::Importer Importer;
const aiScene* pScene = Importer.ReadFile(Filename.c_str(),
aiProcess_Triangulate | aiProcess_GenSmoothNormals|
aiProcess_FlipUVs);
if (pScene){
Ret = InitFromScene(pScene, Filename);
}
else {
printf("Error parsing '%s': '%s'\n", Filename.c_str(), Importer.GetErrorString());
}
return Ret;
}
开发者ID:trushton,项目名称:cs480Rushton,代码行数:22,代码来源:mesh.cpp
示例19: loadModel
void Model::loadModel(string path)
{
Assimp::Importer importer;
/*
aiProcess_FlipUVs: 基于y轴翻转纹理坐标(前面的教程中有)
aiProcess_Triangulate: 如果模型不是(全部)由三角形组成,应该转换所有的模型的原始几何形状为三角形。
aiProcess_GenNormals: 如果模型没有包含法线向量,就为每个顶点创建法线。
aiProcess_SplitLargeMeshes: 把大的网格成几个小的的下级网格,当你渲染有一个最大数量顶点的限制时或者只能处理小块网格时很有用。
aiProcess_OptimizeMeshes: 和上个选项相反,它把几个网格结合为一个更大的网格。以减少绘制函数调用的次数的方式来优化。
*/
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
cout << "ERROR::ASSIMP::" << importer.GetErrorString() << endl;
return;
}
this->directory = path.substr(0, path.find_last_of('/')) + "/";
this->processNode(scene->mRootNode, scene);
}
开发者ID:bingxue102685,项目名称:LearnOpenGL,代码行数:22,代码来源:model.cpp
示例20: ReadFile
int ModelImpAI::ReadFile(const std::string& file_path)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile( file_path,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices
);
assert(scene->mNumMeshes == 1); //only deals with one mesh per file(scene) for now
aiMesh* mesh = scene->mMeshes[0];
assert(mesh->HasNormals()); //assert for normals
assert(mesh->HasTextureCoords(0)); //assert for texture coordinates
for(int i=0; i<mesh->mNumFaces; i++)
{
const aiFace* face = &mesh->mFaces[i];
assert(face->mNumIndices == 3);
Triangle* t = new Triangle;
for(int j=0; j<face->mNumIndices; j++)
{
int index = face->mIndices[j];
t->vertices[j][0] = mesh->mVertices[index].x;
t->vertices[j][1] = mesh->mVertices[index].y;
t->vertices[j][2] = mesh->mVertices[index].z;
t->normals[j][0] = mesh->mNormals[index].x;
t->normals[j][1] = mesh->mNormals[index].y;
t->normals[j][2] = mesh->mNormals[index].z;
t->uvs[j][0] = mesh->mTextureCoords[0][index].x;
t->uvs[j][1] = mesh->mTextureCoords[0][index].y;
}
triangles_.push_back(t);
}
return 1;
}
开发者ID:myartings,项目名称:water_simulation,代码行数:39,代码来源:ModelImpAI.cpp
注:本文中的assimp::Importer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论