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


C++ Importer::SetPropertyBool方法代码示例

本文整理汇总了C++中assimp::Importer::SetPropertyBool方法的典型用法代码示例。如果您正苦于以下问题:C++ Importer::SetPropertyBool方法的具体用法?C++ Importer::SetPropertyBool怎么用?C++ Importer::SetPropertyBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assimp::Importer的用法示例。


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

示例1: main

// ------------------------------------------------------------------------------
// Application entry point
int main (int argc, char* argv[])
{
	if (argc <= 1)	{
		printf("assimp: No command specified. Use \'assimp help\' for a detailed command list\n");
		return 0;
	}

	// assimp version
	// Display version information
	if (! strcmp(argv[1], "version")) {
		const unsigned int flags = aiGetCompileFlags();
		printf(AICMD_MSG_ABOUT,
			aiGetVersionMajor(),
			aiGetVersionMinor(),
			(flags & ASSIMP_CFLAGS_DEBUG ?			"-debug "   : ""),
			(flags & ASSIMP_CFLAGS_NOBOOST ?		"-noboost " : ""),
			(flags & ASSIMP_CFLAGS_SHARED ?			"-shared "  : ""),
			(flags & ASSIMP_CFLAGS_SINGLETHREADED ? "-st "      : ""),
			(flags & ASSIMP_CFLAGS_STLPORT ?		"-stlport " : ""),
			aiGetVersionRevision());

		return 0;
	}

	// assimp help
	// Display some basic help (--help and -h work as well 
	// because people could try them intuitively)
	if (!strcmp(argv[1], "help") || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
		printf("%s",AICMD_MSG_HELP);
		return 0;
	}

	// assimp cmpdump
	// Compare two mini model dumps (regression suite) 
	if (! strcmp(argv[1], "cmpdump")) {
		return Assimp_CompareDump (&argv[2],argc-2);
	}

	// construct global importer and exporter instances
	Assimp::Importer imp;
	imp.SetPropertyBool("GLOB_MEASURE_TIME",true);
	globalImporter = &imp;

#ifndef ASSIMP_BUILD_NO_EXPORT
	// 
	Assimp::Exporter exp;
	globalExporter = &exp;
#endif

	// assimp listext
	// List all file extensions supported by Assimp
	if (! strcmp(argv[1], "listext")) {
		aiString s;
		imp.GetExtensionList(s);

		printf("%s\n",s.data);
		return 0;
	}

#ifndef ASSIMP_BUILD_NO_EXPORT
	// assimp listexport
	// List all export file formats supported by Assimp (not the file extensions, just the format identifiers!)
	if (! strcmp(argv[1], "listexport")) {
		aiString s;
		
		for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
			const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
			s.Append( e->id );
			if (i!=end-1) {
				s.Append("\n");
			}
		}

		printf("%s\n",s.data);
		return 0;
	}


	// assimp exportinfo
	// stat an export format
	if (! strcmp(argv[1], "exportinfo")) {
		aiString s;

		if (argc<3) {
			printf("Expected file format id\n");
			return -11;
		}

		for(size_t i = 0, end = exp.GetExportFormatCount(); i < end; ++i) {
			const aiExportFormatDesc* const e = exp.GetExportFormatDescription(i);
			if (!strcmp(e->id,argv[2])) {
				printf("%s\n%s\n%s\n",e->id,e->fileExtension,e->description);
				return 0;
			}
		}
		
		printf("Unknown file format id: \'%s\'\n",argv[2]);
		return -12;
//.........这里部分代码省略.........
开发者ID:JamesLupiani,项目名称:assimp,代码行数:101,代码来源:Main.cpp

示例2: Init

void ManageAnimation::Init(const char *filename, float xRotateCorrection, bool normalize) {
	this->fRotateXCorrection = xRotateCorrection;
	// Create an instance of the Importer class
	Assimp::Importer importer;

	unsigned int flags = aiProcess_JoinIdenticalVertices|aiProcess_Triangulate|aiProcess_FixInfacingNormals|aiProcess_ValidateDataStructure|
	                     aiProcess_GenNormals|aiProcess_LimitBoneWeights;
	// |aiProcess_OptimizeMeshes
	if (normalize)
		flags |= aiProcess_PreTransformVertices; // This flag will remove all bones.
	importer.SetPropertyBool(AI_CONFIG_PP_PTV_NORMALIZE, true); // TODO: This is only used for aiProcess_PreTransformVertices
	importer.SetPropertyInteger(AI_CONFIG_PP_LBW_MAX_WEIGHTS, 3); // The shader can only handle three weights for each vertice.
	const aiScene* scene = importer.ReadFile( filename, flags);
	if (scene == 0) {
		ErrorDialog("assimp loading %s: %s\n", filename, importer.GetErrorString());
		return;
	}

	// Number of vertices and number of indices
	int vertexSize = 0, indexSize = 0;
	if (gVerbose) {
		printf("\nScene: %s (%s)*******************\n", scene->mRootNode->mName.data, filename);
		printf("%d materials, %d meshes, %d animations, %d textures\n", scene->mNumMaterials, scene->mNumMeshes, scene->mNumAnimations, scene->mNumTextures);
	}

	//**********************************************************************
	// Count how much data is needed. All indices and vetices are saved in
	// the same buffer.
	//**********************************************************************

	fMeshData.reset(new Mesh[scene->mNumMeshes]);
	fNumMeshes = scene->mNumMeshes;
	for (unsigned int i=0; i<scene->mNumMeshes; i++) {
		aiMesh *m = scene->mMeshes[i];
		if (m->mNumBones > 0)
			this->fUsingBones = true; // True if any mesh uses bones
		aiMaterial *mat = scene->mMaterials[m->mMaterialIndex];
		aiColor3D c (0.f,0.f,0.f);
		mat->Get(AI_MATKEY_COLOR_DIFFUSE, c);
		fMeshData[i].colour = glm::vec4(c.r, c.g, c.b, 1.0f);
		indexSize += m->mNumFaces * 3; // Always 3 indices for each face (triangle).
		vertexSize += m->mNumVertices;
		if (gVerbose)
			printf("\tMesh %d ('%s'): %d faces, %d vertices\n", i, m->mName.data, m->mNumFaces, m->mNumVertices);

		// Find all animation bones in all meshes. They may have been seen in another mesh already.
		fMeshData[i].bones.resize(m->mNumBones);
		for (unsigned int j=0; j < m->mNumBones; j++) {
			aiBone *aib = m->mBones[j];
			// Add the bone to the global list of bones if it isn't already there.
			boneindexIT_t it = fBoneIndex.find(aib->mName.data);
			unsigned int jointIndex = fBoneIndex.size();
			if (it == fBoneIndex.end())
				fBoneIndex[aib->mName.data] = jointIndex;
			else
				jointIndex = it->second;

			fMeshData[i].bones[j].jointIndex = jointIndex;
			CopyaiMat(&aib->mOffsetMatrix, fMeshData[i].bones[j].offset);
		}
	}
	if (gVerbose)
		printf("Total vertices needed: %d, index count %d\n", vertexSize, indexSize);

	// Find all mesh transformations and update the bones matrix dependency on parents
	glm::mat4 meshmatrix[scene->mNumMeshes];
	FindMeshTransformations(0, meshmatrix, glm::mat4(1), scene->mRootNode);
	if (gVerbose)
		DumpNodeTree(0, scene->mRootNode);

	// Copy all vertex data into one big buffer and all index data into another buffer
	VertexDataf vertexData[vertexSize];
	unsigned short indexData[indexSize];
	int vertexOffset = 0, indexOffset = 0;
	int previousOffset = 0; // The index offset for the current mesh

	// Skinning data. Allocate even if not using bones.
	char numWeights[vertexSize];
	memset(numWeights, 0, sizeof numWeights);
	glm::vec3 weights[vertexSize];
	float joints[vertexSize*3]; // Up to 4 joints per vertex, but only three are used.
	memset(joints, 0, sizeof joints);

	//**********************************************************************
	// Traverse the meshes again, generating the vertex data
	//**********************************************************************

	for (unsigned int i=0; i<scene->mNumMeshes; i++) {
		aiMesh *m = scene->mMeshes[i];
		if (gVerbose)
			printf("Mesh %d: %d faces, %d vertices, mtl index %d\n", i, m->mNumFaces, m->mNumVertices, m->mMaterialIndex);
#if 1
		if (gVerbose) {
#if 0
			printf("Indices:\n");
			for (unsigned int face=0; face < m->mNumFaces; face++) {
				printf("%d:(", m->mFaces[face].mNumIndices);
				for (unsigned int ind=0; ind < m->mFaces[face].mNumIndices; ind++)
					printf("%d,", m->mFaces[face].mIndices[ind]);
				printf("),");
//.........这里部分代码省略.........
开发者ID:errato,项目名称:ephenation-client,代码行数:101,代码来源:manageanimation.cpp


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