Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#ActualKrauser

Posted 13 May 2013 - 09:16 AM

I'm trying to load a mesh in my application using assimp. But this work well only with the format .stl, but with other format only a part of mesh is displayed. This is my code:

 

bool ModelClass::LoadModel(char* filename)
{
	Assimp::Importer m_LocalImporter;

	// Important! Makes sure that if the angle between two face normals is > 80 they are not smoothed together.
	// Since the angle between a cubes face normals is 90 the lighting looks very bad if we don't specify this.
	m_LocalImporter.SetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, 80.0f);	
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 1);
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE);

	const aiScene* scene = NULL;
	UINT NumMeshes;
	UINT NumFaces;
	scene = m_LocalImporter.ReadFile(filename,
	aiProcess_CalcTangentSpace |
	aiProcess_Triangulate |
	aiProcess_GenSmoothNormals |
	aiProcess_SplitLargeMeshes |
	aiProcess_ConvertToLeftHanded |
	aiProcess_SortByPType);
 

	if(scene)
	{
		NumMeshes = scene->mNumMeshes;

			for(DWORD nMesh=0; nMesh < NumMeshes; nMesh++)
			{
				aiMesh* mesh = scene->mMeshes[nMesh];

				for(DWORD nVertex = 0; nVertex < mesh->mNumVertices; nVertex++)
				{
					VertexType vertex;
					vertex.position.x = mesh->mVertices[nVertex].x;
					vertex.position.y = mesh->mVertices[nVertex].y;
					vertex.position.z = mesh->mVertices[nVertex].z;

					vertex.normal.x = mesh->mNormals[nVertex].x;
					vertex.normal.y = mesh->mNormals[nVertex].y;
					vertex.normal.z = mesh->mNormals[nVertex].z;

					if(mesh->HasTextureCoords(0))
					{
						vertex.texture.x = mesh->mTextureCoords[0][nVertex].x;
						vertex.texture.y = mesh->mTextureCoords[0][nVertex].y;
					}

					vVertices.push_back(vertex);
				}

				for(DWORD nFaces = 0; nFaces < mesh->mNumFaces; nFaces++)
				for(int nIndex = 0; nIndex < mesh->mFaces[nFaces].mNumIndices; nIndex++)
				vIndices.push_back(mesh->mFaces[nFaces].mIndices[nIndex]);
		
		}

	}
	else
	{
		return false;
	}

	return true;
}

Screen:

OBJ format:

1el0eq.png

 

STL format:

2dlu7ax.png

 

My obj file:

http://rs513p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1246163158&filename=Car.obj&cookie=D43D984F2E4AAF9B40F185DD2D28279357615E833B8E80DC2D92A141C94A16B373D0E30E4AE683200DF2331CE0130B0B&directstart=1


#3Krauser

Posted 13 May 2013 - 09:16 AM

I'm trying to load a mesh in my application using assimp. But this work well only with the format .stl, but with other format only a part of mesh is displayed. This is my code:

 

bool ModelClass::LoadModel(char* filename)
{
	Assimp::Importer m_LocalImporter;

	// Important! Makes sure that if the angle between two face normals is > 80 they are not smoothed together.
	// Since the angle between a cubes face normals is 90 the lighting looks very bad if we don't specify this.
	m_LocalImporter.SetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, 80.0f);	
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 1);
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE);

	const aiScene* scene = NULL;
	UINT NumMeshes;
	UINT NumFaces;
	scene = m_LocalImporter.ReadFile(filename,
	aiProcess_CalcTangentSpace |
	aiProcess_Triangulate |
	aiProcess_GenSmoothNormals |
	aiProcess_SplitLargeMeshes |
	aiProcess_ConvertToLeftHanded |
	aiProcess_SortByPType);
 

	if(scene)
	{
		NumMeshes = scene->mNumMeshes;

			for(DWORD nMesh=0; nMesh < NumMeshes; nMesh++)
			{
				aiMesh* mesh = scene->mMeshes[nMesh];

				for(DWORD nVertex = 0; nVertex < mesh->mNumVertices; nVertex++)
				{
					VertexType vertex;
					vertex.position.x = mesh->mVertices[nVertex].x;
					vertex.position.y = mesh->mVertices[nVertex].y;
					vertex.position.z = mesh->mVertices[nVertex].z;

					vertex.normal.x = mesh->mNormals[nVertex].x;
					vertex.normal.y = mesh->mNormals[nVertex].y;
					vertex.normal.z = mesh->mNormals[nVertex].z;

					if(mesh->HasTextureCoords(0))
					{
						vertex.texture.x = mesh->mTextureCoords[0][nVertex].x;
						vertex.texture.y = mesh->mTextureCoords[0][nVertex].y;
					}

					vVertices.push_back(vertex);
				}

				for(DWORD nFaces = 0; nFaces < mesh->mNumFaces; nFaces++)
				for(int nIndex = 0; nIndex < mesh->mFaces[nFaces].mNumIndices; nIndex++)
				vIndices.push_back(mesh->mFaces[nFaces].mIndices[nIndex]);
		
		}

	}
	else
	{
		return false;
	}

	return true;
}

Screen:

OBJ format:

1el0eq.png

 

STL format:

2dlu7ax.png

 

My obj file:

http://rs513p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1246163158&filename=Car.obj&cookie=D43D984F2E4AAF9B40F185DD2D28279357615E833B8E80DC2D92A141C94A16B373D0E30E4AE683200DF2331CE0130B0B&directstart=1


#2Krauser

Posted 13 May 2013 - 09:15 AM

I'm trying to load a mesh in my application using assimp. But this work well only with the format .stl, but with other format only a part of mesh is displayed. This is my code:

 

bool ModelClass::LoadModel(char* filename)
{
	Assimp::Importer m_LocalImporter;

	// Important! Makes sure that if the angle between two face normals is > 80 they are not smoothed together.
	// Since the angle between a cubes face normals is 90 the lighting looks very bad if we don't specify this.
	m_LocalImporter.SetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, 80.0f);	
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 1);
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE);

	const aiScene* scene = NULL;
	UINT NumMeshes;
	UINT NumFaces;
	scene = m_LocalImporter.ReadFile(filename,
	aiProcess_CalcTangentSpace |
	aiProcess_Triangulate |
	aiProcess_GenSmoothNormals |
	aiProcess_SplitLargeMeshes |
	aiProcess_ConvertToLeftHanded |
	aiProcess_SortByPType);
 

	if(scene)
	{
		NumMeshes = scene->mNumMeshes;

			for(DWORD nMesh=0; nMesh < NumMeshes; nMesh++)
			{
				aiMesh* mesh = scene->mMeshes[nMesh];

				for(DWORD nVertex = 0; nVertex < mesh->mNumVertices; nVertex++)
				{
					VertexType vertex;
					vertex.position.x = mesh->mVertices[nVertex].x;
					vertex.position.y = mesh->mVertices[nVertex].y;
					vertex.position.z = mesh->mVertices[nVertex].z;

					vertex.normal.x = mesh->mNormals[nVertex].x;
					vertex.normal.y = mesh->mNormals[nVertex].y;
					vertex.normal.z = mesh->mNormals[nVertex].z;

					if(mesh->HasTextureCoords(0))
					{
						vertex.texture.x = mesh->mTextureCoords[0][nVertex].x;
						vertex.texture.y = mesh->mTextureCoords[0][nVertex].y;
					}

					vVertices.push_back(vertex);
				}

				for(DWORD nFaces = 0; nFaces < mesh->mNumFaces; nFaces++)
				for(int nIndex = 0; nIndex < mesh->mFaces[nFaces].mNumIndices; nIndex++)
				vIndices.push_back(mesh->mFaces[nFaces].mIndices[nIndex]);
		
		}

	}
	else
	{
		return false;
	}

	return true;
}

Screen:

OBJ format:

1el0eq.png

 

STL format:

2dlu7ax.png

 

My obj file:

http://Direct link: http://rs513p2.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1246163158&filename=Car.obj&cookie=D43D984F2E4AAF9B40F185DD2D28279357615E833B8E80DC2D92A141C94A16B373D0E30E4AE683200DF2331CE0130B0B&directstart=1


#1Krauser

Posted 12 May 2013 - 08:40 AM

I'm trying to load a mesh in my application using assimp. But this work well only with the format .stl, but with other format only a part of mesh is displayed. This is my code:

 

bool ModelClass::LoadModel(char* filename)
{
	Assimp::Importer m_LocalImporter;

	// Important! Makes sure that if the angle between two face normals is > 80 they are not smoothed together.
	// Since the angle between a cubes face normals is 90 the lighting looks very bad if we don't specify this.
	m_LocalImporter.SetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE, 80.0f);	
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_IMPORT_TER_MAKE_UVS, 1);
	m_LocalImporter.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE);

	const aiScene* scene = NULL;
	UINT NumMeshes;
	UINT NumFaces;
	scene = m_LocalImporter.ReadFile(filename,
	aiProcess_CalcTangentSpace |
	aiProcess_Triangulate |
	aiProcess_GenSmoothNormals |
	aiProcess_SplitLargeMeshes |
	aiProcess_ConvertToLeftHanded |
	aiProcess_SortByPType);
 

	if(scene)
	{
		NumMeshes = scene->mNumMeshes;

			for(DWORD nMesh=0; nMesh < NumMeshes; nMesh++)
			{
				aiMesh* mesh = scene->mMeshes[nMesh];

				for(DWORD nVertex = 0; nVertex < mesh->mNumVertices; nVertex++)
				{
					VertexType vertex;
					vertex.position.x = mesh->mVertices[nVertex].x;
					vertex.position.y = mesh->mVertices[nVertex].y;
					vertex.position.z = mesh->mVertices[nVertex].z;

					vertex.normal.x = mesh->mNormals[nVertex].x;
					vertex.normal.y = mesh->mNormals[nVertex].y;
					vertex.normal.z = mesh->mNormals[nVertex].z;

					if(mesh->HasTextureCoords(0))
					{
						vertex.texture.x = mesh->mTextureCoords[0][nVertex].x;
						vertex.texture.y = mesh->mTextureCoords[0][nVertex].y;
					}

					vVertices.push_back(vertex);
				}

				for(DWORD nFaces = 0; nFaces < mesh->mNumFaces; nFaces++)
				for(int nIndex = 0; nIndex < mesh->mFaces[nFaces].mNumIndices; nIndex++)
				vIndices.push_back(mesh->mFaces[nFaces].mIndices[nIndex]);
		
		}

	}
	else
	{
		return false;
	}

	return true;
}

Screen:

OBJ format:

1el0eq.png

 

STL format:

2dlu7ax.png


PARTNERS