当前位置: 首页>>代码示例>>C++>>正文


C++ Importer类代码示例

本文整理汇总了C++中Importer的典型用法代码示例。如果您正苦于以下问题:C++ Importer类的具体用法?C++ Importer怎么用?C++ Importer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Importer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_bImportExternal_clicked

void ResourceManager::on_bImportExternal_clicked()
{
    Importer *importer = new Importer;
    importer->exec();
    delete importer;
    buildResourceTree();
}
开发者ID:timdetering,项目名称:openrpgmaker,代码行数:7,代码来源:resourcemanager.cpp

示例2: validate

bool AutoImporter::validate(const DataDescriptor* pDescriptor,
                            const vector<const DataDescriptor*>& importedDescriptors,
                            string& errorMessage) const
{
    if (pDescriptor == NULL)
    {
        return NULL;
    }

    bool bValid = false;

    Importer* pImporter = const_cast<AutoImporter*>(this)->findImporter(pDescriptor);
    if (pImporter != NULL)
    {
        bValid = pImporter->validate(pDescriptor, importedDescriptors, errorMessage);
        if (errorMessage.empty() == false)
        {
            VERIFY(mpPlugIn != NULL);
            string importerName = mpPlugIn->getName();
            errorMessage.insert(0, importerName + ":\n");
        }
    }

    return bValid;
}
开发者ID:jonatho7,项目名称:opticks,代码行数:25,代码来源:AutoImporter.cpp

示例3: saveAndLoadMap

Map* FileFormatTest::saveAndLoadMap(Map* input, const FileFormat* format)
{
	try {
		QBuffer buffer;
		buffer.open(QIODevice::ReadWrite);
		
		Exporter* exporter = format->createExporter(&buffer, input, NULL);
		if (!exporter)
			return NULL;
		exporter->doExport();
		delete exporter;
		
		buffer.seek(0);
		
		Map* out = new Map;
		Importer* importer = format->createImporter(&buffer, out, NULL);
		if (!importer)
			return NULL;
		importer->doImport(false);
		importer->finishImport();
		delete importer;
		
		buffer.close();
		
		return out;
	}
	catch (std::exception& e)
	{
		return NULL;
	}
}
开发者ID:kshji,项目名称:mapper,代码行数:31,代码来源:file_format_t.cpp

示例4: register_protobuf_file

void register_protobuf_file(string filePath, string fileName, int proto_hadoop)
{
    if ( g_listPBFile.end() != find(g_listPBFile.begin(), g_listPBFile.end(), filePath + fileName ) )
    {
        return;
    }
    g_listPBFile.push_back( filePath + fileName );
      
    DiskSourceTree sourceTree;
    sourceTree.MapPath("", filePath);
    
    // keep the Descriptor data in memory  
    Importer* importer = new Importer(&sourceTree, NULL);
                
    const FileDescriptor* file = NULL;
    file = importer->Import(fileName);
    if (NULL == file)
    {
        return;
    }

    // recursive parse import file
    for (int iDependencyIndex = 0; iDependencyIndex < file->dependency_count(); iDependencyIndex++)
    {
        const FileDescriptor* dependencyFile = NULL;
        dependencyFile = file->dependency(iDependencyIndex);
        if (NULL == dependencyFile)
        {
            return;
        }

        register_protobuf_file(filePath, dependencyFile->name(), proto_hadoop);
    }
    
    // parse message
    for (int iMsgIndex = 0; iMsgIndex < file->message_type_count(); iMsgIndex++)
    {
        const Descriptor* message = file->message_type(iMsgIndex);
        register_protobuf_message(message, proto_hadoop);
    }
      
    // parse service
    for (int iServiceIndex = 0; iServiceIndex < file->service_count(); iServiceIndex++)
    {
        const ServiceDescriptor* service = file->service(iServiceIndex);
        for (int iMethodIndex = 0; iMethodIndex < service->method_count(); iMethodIndex++)
        {
            const MethodDescriptor* method = service->method(iMethodIndex);
            
            MethodInfo methodInfo;
            methodInfo.methodParamType = method->input_type()->full_name();
            methodInfo.methodReturnType = method->output_type()->full_name();
            
            g_mapMethod.insert(pair<string, MethodInfo>(method->name(), methodInfo));
        }
    } // end parse service
    
}
开发者ID:hsluoyz,项目名称:hadoop-wireshark,代码行数:58,代码来源:protobuf-handle.cpp

示例5: exporterTest

    virtual bool exporterTest() {
        Importer importer;
        Exporter exporter;
        const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube.ply", 0);
        EXPECT_NE(nullptr, scene);
        EXPECT_EQ(aiReturn_SUCCESS, exporter.Export(scene, "ply", ASSIMP_TEST_MODELS_DIR "/PLY/cube_test.ply"));

        return true;
    }
开发者ID:dellis1972,项目名称:assimp,代码行数:9,代码来源:utPLYImportExport.cpp

示例6: isProcessingLocationSupported

bool AutoImporter::isProcessingLocationSupported(ProcessingLocation location) const
{
    bool bSupported = false;

    Importer* pImporter = dynamic_cast<Importer*>(mpPlugIn);
    if (pImporter != NULL)
    {
        bSupported = pImporter->isProcessingLocationSupported(location);
    }

    return bSupported;
}
开发者ID:jonatho7,项目名称:opticks,代码行数:12,代码来源:AutoImporter.cpp

示例7: findImporter

vector<ImportDescriptor*> AutoImporter::getImportDescriptors(const string& filename)
{
    vector<ImportDescriptor*> descriptors;

    Importer* pImporter = findImporter(filename);
    if (pImporter != NULL)
    {
        descriptors = pImporter->getImportDescriptors(filename);
    }

    return descriptors;
}
开发者ID:jonatho7,项目名称:opticks,代码行数:12,代码来源:AutoImporter.cpp

示例8: instream

void PFImporterTest::scrubCommandsNew()
{
    platform = "pf";

    std::istringstream instream(
        openTestFile("test_data/pf-scrub-commands-new.conf"));

    Importer* imp = new PFImporter(lib, instream, logger, "test_fw");
    imp->setAddStandardCommentsFlag(true);
    CPPUNIT_ASSERT_NO_THROW( imp->run() );
    imp->finalize();

    compareResults(logger,
                   "test_data/pf-scrub-commands-new.output",
                   "pf-scrub-commands-new.output");
}
开发者ID:UNINETT,项目名称:fwbuilder,代码行数:16,代码来源:PFImporterTest.cpp

示例9:

Module * PackageMgr::loadModule(StringRef qname) {
  // First, attempt to search the modules already loaded.
  ModuleMap::iterator it = modules_.find(qname);
  if (it != modules_.end()) {
    if (ShowImports && it->second != NULL) {
      diag.debug() << "Import: Found module '" << qname << "' in module cache";
    }

    return it->second;
  }

  // If it's a regular file.
  Module * mod = NULL;

  // Search each element on the import path list.
  for (PathList::iterator it = importers_.begin(); it != importers_.end(); ++it) {
    Importer * imp = *it;
    if (imp->load(qname, mod)) {
      // If the module was there but failed to load (NULL) then we're done
      if (mod == NULL) {
        break;
      }
    }
  }

  if (!mod && ShowImports) {
    diag.debug() << "Import: module '" << qname << "' NOT FOUND";
  }

  // Regardless of whether the module was found, record this result in the map
  // so we don't have to look it up again.
  modules_[qname] = mod;

  // Do this *after* we add the module to the map, because createMembers() might
  // do other module lookups.
  if (mod != NULL) {
    mod->createMembers();
  }
  return mod;
}
开发者ID:afrog33k,项目名称:tart,代码行数:40,代码来源:PackageMgr.cpp

示例10: osre_error

bool AssimpWrapper::importAsset( const IO::Uri &file, ui32 flags ) {
    if ( !file.isValid() ) {
        osre_error( Tag, "URI " + file.getUri() + " is invalid " );
        return false;
    }

    unsigned int importFlags = aiProcess_CalcTangentSpace
        | aiProcess_GenSmoothNormals
        | aiProcess_JoinIdenticalVertices
        | aiProcess_ImproveCacheLocality
        | aiProcess_LimitBoneWeights
        | aiProcess_RemoveRedundantMaterials
        | aiProcess_SplitLargeMeshes
        | aiProcess_Triangulate
        | aiProcess_GenUVCoords
        | aiProcess_SortByPType;
    flags = importFlags;

    m_root = AssetRegistry::getPath( "media" );
    m_absPathWithFile = AssetRegistry::resolvePathFromUri( file );

    String filename;
    Directory::getDirectoryAndFile(m_absPathWithFile, m_root, filename);
    filename = m_root + filename;
    Importer myImporter;
    const aiScene *scene = myImporter.ReadFile( filename, flags );
    if ( nullptr == scene ) {
        m_root = "";
        m_absPathWithFile = "";
        return false;
    }
    convertSceneToModel( scene );
    m_model->setMeshArray( m_meshArray );

    return true;
}
开发者ID:kimkulling,项目名称:osre,代码行数:36,代码来源:AssimpWrapper.cpp

示例11: load

			shared_ptr<drawBasement::IModel> load(drawBasement::IDrawFactory* df,IFileService* ff,shared_ptr<IFile> fi){
				using namespace Assimp;
				Importer Imp;
				u32 size = fi->getFileSize();
				void* buf = malloc(size);
				fi->read((char*)buf,size);
				const aiScene* pScene = Imp.ReadFile(fi->getAbsolutePath().c_str(),aiProcess_Triangulate | aiProcess_GenSmoothNormals);
				free(buf);

				const aiVector3D Zero3D(0.0f, 0.0f, 0.0f);
				auto model = new drawBasement::CModel;
				model->modelPath = fi->getAbsolutePath();
				//骨骼动画初始化
				if(pScene->HasAnimations()){
					model->mBoneAnimator = shared_ptr<drawBasement::CBoneAnimator>(new drawBasement::CBoneAnimator);
					buildBoneAnimations(pScene->mAnimations[0],pScene->mRootNode,model);
					model->mBoneAnimator->mMaxFrames = pScene->mAnimations[0]->mDuration;
					model->mBoneAnimator->mFramePerSecond = pScene->mAnimations[0]->mTicksPerSecond;
				}
				mat4 zeroMat;
				ZeroMemory(&zeroMat,sizeof(mat4));
				//模型数据初始化
				for(unsigned int i=0;i<pScene->mNumMeshes;++i){
					const aiMesh* paiMesh = pScene->mMeshes[i];
					auto vbuf = df->createVertexBuffer();
					vbuf->setElemtSize(3);
					vbuf->reSizeBuffer(sizeof(vector3df)*paiMesh->mNumVertices);
					vector3df* vb = (vector3df*)vbuf->lock();

					auto nbuf = df->createVertexBuffer();
					nbuf->setElemtSize(3);
					nbuf->reSizeBuffer(sizeof(vector3df)*paiMesh->mNumVertices);
					vector3df* nb = (vector3df*)nbuf->lock();

					auto tbuf = df->createVertexBuffer();
					tbuf->setElemtSize(2);
					tbuf->reSizeBuffer(sizeof(vector2df)*paiMesh->mNumVertices);
					vector2df* tb = (vector2df*)tbuf->lock();
					
					for (unsigned int i = 0 ; i < paiMesh->mNumVertices ; i++) {
						const aiVector3D* pPos      = &(paiMesh->mVertices[i]);
						const aiVector3D* pNormal   = &(paiMesh->mNormals[i]);
						const aiVector3D* pTexCoord = paiMesh->HasTextureCoords(0) ? &(paiMesh->mTextureCoords[0][i]) : &Zero3D;
						vb[i].X=pPos->x;
						vb[i].Y=pPos->y;
						vb[i].Z=pPos->z;

						tb[i].X=pTexCoord->x;
						tb[i].Y=pTexCoord->y;

						nb[i].X=pNormal->x;
						nb[i].Y=pNormal->y;
						nb[i].Z=pNormal->z;
						
					}

					auto ibuf = df->createIndexBuffer();
					ibuf->setIndexNums(paiMesh->mNumFaces*3);
					ibuf->setPrimityType(drawBasement::EPT_TRIANGLES);
					ibuf->reSizeBuffer(paiMesh->mNumFaces*3*ibuf->getIndexType());
					u16* ib = (u16*)ibuf->lock();
					for (unsigned int i = 0 ; i < paiMesh->mNumFaces ; i++) {
						const aiFace& Face = paiMesh->mFaces[i];
						ib[i*3+0]=Face.mIndices[0];
						ib[i*3+1]=Face.mIndices[1];
						ib[i*3+2]=Face.mIndices[2];
					}
					tbuf->initialBuffer();
					nbuf->initialBuffer();
					vbuf->initialBuffer();
					ibuf->initialBuffer();
					u32 bsize = 4*sizeof(u32)*paiMesh->mNumVertices;
					shared_ptr<drawBasement::IDrawBuffer> bbuf = 0;
					shared_ptr<drawBasement::IDrawBuffer> bwbuf = 0;
					if(paiMesh->HasBones()){
						bbuf = df->createVertexBuffer();
						bwbuf = df->createVertexBuffer();
						bbuf->reSizeBuffer(bsize);
						bbuf->setElemtSize(4);
						bbuf->setDataType(drawBasement::EDT_UINT);
						bwbuf->reSizeBuffer(bsize);
						bwbuf->setElemtSize(4);


						u32* bb = (u32*)bbuf->lock();
						f32* bwb = (f32*)bwbuf->lock();
						ZeroMemory(bb,bsize);
						ZeroMemory(bwb,bsize);
						for(u32 i=0;i<paiMesh->mNumBones;++i){
							auto bone = model->mBoneAnimator->findBones(paiMesh->mBones[i]->mName.C_Str());
							if(((drawBasement::CBone*)bone.get())->isinitial){
								((drawBasement::CBone*)bone.get())->isinitial=false;
								memcpy(&((drawBasement::CBone*)bone.get())->boneOffset,&paiMesh->mBones[i]->mOffsetMatrix,sizeof(f32)*16);
								((drawBasement::CBone*)bone.get())->boneOffset=((drawBasement::CBone*)bone.get())->boneOffset.getTransposed();
							}
							u32 bid = bone->getBoneIdx();
							for(u32 bi=0;bi<paiMesh->mBones[i]->mNumWeights;++bi){
								u32 vid = paiMesh->mBones[i]->mWeights[bi].mVertexId;
								f32 vw = paiMesh->mBones[i]->mWeights[bi].mWeight;
								AddBoneData(bb+vid*4,bwb+vid*4,bid,vw);
//.........这里部分代码省略.........
开发者ID:skatebill,项目名称:MyEngineVersion3,代码行数:101,代码来源:CAssimpPhraser.cpp

示例12: nullVec

void DDEngine::ModelObject::loadGeometry(std::vector<Mesh>& meshes)
{
	Importer importer;
	const aiScene* scene = importer.ReadFile(modelPath,
		aiProcess_Triangulate |
		aiProcess_ConvertToLeftHanded |
		aiProcess_FlipUVs |
		aiProcess_SortByPType |
		aiProcess_OptimizeMeshes |
		aiProcess_OptimizeGraph |
		aiProcess_FixInfacingNormals |
		aiProcess_CalcTangentSpace
		);

	if (!scene) {
		Win32Utils::showMessage("Error during loading object.", importer.GetErrorString());
		return;
	}

	const aiVector3D nullVec(0.0f, 0.0f, 0.0f);

	for (size_t i = 0; i < scene->mNumMeshes; i++) {
		const aiMesh* mesh = scene->mMeshes[i];
		Mesh ddeMesh;

		for (size_t j = 0; j < mesh->mNumVertices; j++) {

			const aiVector3D* pos = &(mesh->mVertices[j]);
			const aiVector3D* nor = mesh->HasNormals() ? &(mesh->mNormals[j]) : &nullVec;
			const aiVector3D* tan = mesh->HasTangentsAndBitangents() ? &(mesh->mTangents[j]) : &nullVec;
			const aiVector3D* tex = mesh->HasTextureCoords(0) ? &(mesh->mTextureCoords[0][j]) : &nullVec;

			#define VB(x, y, z, u, v, nx, ny, nz, tx, ty, tz, tw) ddeMesh.VB(VertexPositionNormalTangentTexture(XMFLOAT3(x, y, z), XMFLOAT3(nx, ny, nz), XMFLOAT4(tx, ty, tz, tw), XMFLOAT2(u, v)))

			VB(
				pos->x, pos->y, pos->z,
				tex->x, tex->y,
				nor->x, nor->y, nor->z,
				tan->x, tan->y, tan->z, 0.0f
			);

			ddeMesh.materialIndex = mesh->mMaterialIndex;

		}

		for (size_t j = 0; j < mesh->mNumFaces; j++) {

			const aiFace& face = mesh->mFaces[j];

			switch (face.mNumIndices) {
				case 1: ddeMesh.topology = PrimitiveTopology::POINT_LIST; break;
				case 2: ddeMesh.topology = PrimitiveTopology::LINE_LIST; break;
				case 3: ddeMesh.topology = PrimitiveTopology::TRIANGLE_LIST; break;
				default: ddeMesh.topology = PrimitiveTopology::UNDEFINED; break;
			}

			for (size_t index = 0; index < face.mNumIndices; index++) {
				ddeMesh.IB(face.mIndices[index]);
			}

		}

		meshes.push_back(ddeMesh);
	}

	for (size_t i = 0; i < scene->mNumMaterials; i++) {
		const aiMaterial* material = scene->mMaterials[i];
		Material ddeMaterial;
		ddeMaterial.index = i;

		if (material->GetTextureCount(aiTextureType_DIFFUSE) > 0) {
			aiString Path;

			if (material->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, NULL, NULL) == AI_SUCCESS) {
				Texture tex;
				tex.type = Texture::TextureType::DIFFUSE;

				ShaderResourceView* texture = nullptr;

				std::string path = Path.data;
				std::size_t ext = path.find(".tga");
				ScratchImage image;
				HRESULT hr = -1;

				std::string currentPath = FileUtils::getPath(modelPath) + "/";
				tex.path = currentPath + path;

				if (ext != std::string::npos) {
					hr = LoadFromTGAFile(StringUtils::toWstring(currentPath + path).c_str(), nullptr, image);
				}
				else {
					texture = TextureUtils::createTexture(currentPath + path, *Ctx);
				}

				if (SUCCEEDED(hr)) {
					hr = CreateShaderResourceView(Ctx->device, image.GetImages(), image.GetImageCount(), image.GetMetadata(), &texture);
				}

				if (texture) {
					tex.texture = texture;
//.........这里部分代码省略.........
开发者ID:Toby91,项目名称:DDEngine,代码行数:101,代码来源:ModelObject.cpp

示例13: Import

bool CImporter::Import(const string& filename)
{
	unsigned int flags = aiProcess_JoinIdenticalVertices;
	flags |= aiProcess_FlipUVs;
	flags |= aiProcess_Triangulate;
	flags |= aiProcess_GenSmoothNormals;
	flags |= aiProcess_LimitBoneWeights;
	flags |= aiProcess_ValidateDataStructure;
	flags |= aiProcess_ImproveCacheLocality;
	flags |= aiProcess_RemoveRedundantMaterials;
	flags |= aiProcess_FixInfacingNormals;
	flags |= aiProcess_FindInvalidData;
	flags |= aiProcess_OptimizeMeshes;
	flags |= aiProcess_SplitByBoneCount;
	flags |= aiProcess_TransformUVCoords;
	flags |= aiProcess_SortByPType;
	flags |= aiProcess_RemoveComponent;
	flags |= aiProcess_MakeLeftHanded;
	//flags |= aiProcess_FlipWindingOrder;
	//flags |= aiProcess_OptimizeGraph;

	Importer importer;
	if (!importer.ValidateFlags(flags))
	{
		qCritical("Import flags not supported");
		return false;
	}

	if (!importer.IsExtensionSupported(('.' % GetExtension(filename)).toLocal8Bit().constData()))
	{
		qCritical("This file format isn't supported");
		return false;
	}

	importer.SetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS, 2);
	importer.SetPropertyInteger(AI_CONFIG_PP_SBBC_MAX_BONES, MAX_BONES);
	importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, aiComponent_TANGENTS_AND_BITANGENTS
		| aiComponent_COLORS
		| aiComponent_TEXTURES
		| aiComponent_LIGHTS
		| aiComponent_CAMERAS);

	m_scene = (aiScene*)importer.ReadFile(filename.toLocal8Bit().constData(), flags);
	if (!m_scene)
	{
		qCritical(importer.GetErrorString());
		return false;
	}

	if (!m_scene->HasMeshes() || !m_scene->mRootNode || m_scene->mRootNode->mNumChildren == 0)
	{
		qCritical("No meshes in this scene");
		return false;
	}

	m_obj3D = m_mesh->m_elements[0].obj = new CObject3D(m_mesh->m_device);
	m_obj3D->m_ID = _getNewID();

	const string filenameToLower = QFileInfo(filename).fileName().toLower();

	if (filenameToLower.startsWith("mvr")
		|| filenameToLower.startsWith("part")
		|| filenameToLower.startsWith("item"))
		m_externBones = true;

	_importScene();

	if (!m_obj3D->InitDeviceObjects())
	{
		qCritical(("Can't init object3D device objects '" % filename % "'").toLocal8Bit().data());
		return false;
	}

	importer.FreeScene();
	return true;
}
开发者ID:ServerGame,项目名称:ATools,代码行数:76,代码来源:Importer.cpp

示例14: remove_if

Importer* AutoImporter::findImporter(const string& filename)
{
    map<string, pair<string, unsigned char> >::iterator fileIter = mFilenames.find(filename);
    if (fileIter != mFilenames.end())
    {
        map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(fileIter->second.first);
        if (plugInIter != mPlugIns.end())
        {
            mpPlugIn = plugInIter->second;
            return dynamic_cast<Importer*>(mpPlugIn);
        }
    }

    mpPlugIn = NULL;

    if (filename.empty() == true)
    {
        return NULL;
    }

    // Create the list of importers to search
    vector<PlugInDescriptor*> importers = mpPlugInManager->getPlugInDescriptors(PlugInManagerServices::ImporterType());

    //remove self from list of importers
    vector<PlugInDescriptor*>::iterator newEnd =
        remove_if(importers.begin(), importers.end(), FindDescriptor(getName()));
    importers.erase(newEnd, importers.end());

    // Check importers first based on file extension
    list<PlugInDescriptor*> remainingImporters;
    PlugIn* pPlugIn = NULL;
    unsigned char maxFileAffinity = Importer::CAN_NOT_LOAD;

    for (vector<PlugInDescriptor*>::iterator iter = importers.begin(); iter != importers.end(); ++iter)
    {
        PlugInDescriptor* pDescriptor = *iter;
        if (pDescriptor == NULL)
        {
            continue;
        }

        if (checkExtension(pDescriptor, filename))
        {
            PlugIn* pCurrentPlugIn = NULL;
            const string& plugInName = pDescriptor->getName();

            map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(plugInName);
            if (plugInIter != mPlugIns.end())
            {
                pCurrentPlugIn = plugInIter->second;
            }
            else
            {
                PlugInResource pImporterRes(plugInName);
                pCurrentPlugIn = pImporterRes.release();
                if (pCurrentPlugIn != NULL)
                {
                    mPlugIns[plugInName] = pCurrentPlugIn;
                }
            }

            Importer* pImporter = dynamic_cast<Importer*>(pCurrentPlugIn);
            if (pImporter != NULL)
            {
                unsigned char fileAffinity = pImporter->getFileAffinity(filename);
                if (fileAffinity > maxFileAffinity)
                {
                    maxFileAffinity = fileAffinity;
                    pPlugIn = pCurrentPlugIn;
                }
            }
        }
        else
        {
            remainingImporters.push_back(pDescriptor);
        }
    }

    if ((pPlugIn != NULL) && (maxFileAffinity >= Importer::CAN_LOAD))
    {
        mpPlugIn = pPlugIn;
        mFilenames[filename] = make_pair(mpPlugIn->getName(), maxFileAffinity);
        return dynamic_cast<Importer*>(mpPlugIn);
    }

    // Check the remaining importers
    for (list<PlugInDescriptor*>::iterator iter = remainingImporters.begin(); iter != remainingImporters.end(); ++iter)
    {
        PlugInDescriptor* pDescriptor = *iter;
        if (pDescriptor == NULL)
        {
            continue;
        }

        PlugIn* pCurrentPlugIn = NULL;
        const string& plugInName = pDescriptor->getName();

        map<string, PlugIn*>::iterator plugInIter = mPlugIns.find(plugInName);
        if (plugInIter != mPlugIns.end())
        {
//.........这里部分代码省略.........
开发者ID:jonatho7,项目名称:opticks,代码行数:101,代码来源:AutoImporter.cpp

示例15: fin

Modell::Modell(glm::mat4& matrix, const char * modelpath)
{
	mat = matrix;

	Importer importer;
	const aiScene* scene = NULL;
	
	//gibt es die Datei
	std::ifstream fin(modelpath);
	if(!fin.fail()) {
		fin.close();
	}
	else{
		printf("Fehler beim laden des Modells: %s\n", modelpath);
		printf("%s\n", importer.GetErrorString());
		system("PAUSE");
		exit(EXIT_FAILURE);
	}

	scene = importer.ReadFile( modelpath,/* aiProcess_Triangulate | */aiProcessPreset_TargetRealtime_Quality);

	if( !scene)
	{
		printf("%s\n", importer.GetErrorString());
		system("PAUSE");
		exit(EXIT_FAILURE);
	}else{
		mesh = scene->mMeshes[0];

		int indexcount = mesh->mNumFaces * 3;
		int vertexcount = mesh->mNumVertices *3;
		int normcount = mesh->mNumVertices *3;
		int uvCoordcount = mesh->mNumVertices *2;

		for (unsigned int i = 0; i < mesh->mNumFaces; ++i) 
		{
            const aiFace* face = &mesh->mFaces[i];
			
			unsigned int index = face->mIndices[0];
			indices.push_back(index);

			index = face->mIndices[1];
			indices.push_back(index);

			index = face->mIndices[2];
			indices.push_back(index);
        }


		//index = 0;
		for (unsigned int i = 0; i < mesh->mNumVertices; ++i) 
		{
			glm::vec3 positions;

			positions.x = mesh->mVertices[i].x;
			positions.y = mesh->mVertices[i].y;
			positions.z = mesh->mVertices[i].z;

			pos.push_back(positions);

			glm::vec3 norm;
			norm.x = mesh->mNormals[i].x;
			norm.y = mesh->mNormals[i].y;
			norm.z = mesh->mNormals[i].z;

			normals.push_back(norm);

			glm::vec2 tex;
			//es koennten auch mehrere texturen am objekt sein. Wir supporten vorerst nur eine
			if (mesh->mTextureCoords[0]) 
			{
				tex.x = mesh->mTextureCoords[0][i].x;
				tex.y = mesh->mTextureCoords[0][i].y;

				uvs.push_back(tex);
			}
		}
		if (mesh->mMaterialIndex >= 0) {

		aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
		aiColor3D colorDIF (0.f,0.f,0.f);
		aiColor3D colorSPEC (0.f,0.f,0.f);
		material->Get(AI_MATKEY_COLOR_DIFFUSE,colorDIF);
		material->Get(AI_MATKEY_COLOR_DIFFUSE,colorSPEC);

		diffuseMAT.r = colorDIF.r;
		diffuseMAT.g = colorDIF.g;
		diffuseMAT.b = colorDIF.b;

		specularMAT.r = colorSPEC.r;
		specularMAT.g = colorSPEC.g;
		specularMAT.b = colorSPEC.b;

		Texture textureloader;
		diffuseMaps = textureloader.loadMaterialTextures(modelpath, material, aiTextureType_DIFFUSE, "diffuse");
		//textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());

		specularMaps = textureloader.loadMaterialTextures(modelpath, material, aiTextureType_SPECULAR, "specular");
		//textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
	}
//.........这里部分代码省略.........
开发者ID:Honesch,项目名称:ThrowIt,代码行数:101,代码来源:Modell.cpp


注:本文中的Importer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。