Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

ASSIMP lib and rendering function setup

This topic is 3264 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

UPdate: Code below works with VAR's
void recursive_render (const aiNode* nd)
{
	unsigned int n = 0;
	aiMatrix4x4 m = nd->mTransformation;
	
	// update transform
	aiTransposeMatrix4(&m);
	glMultMatrixf((float*)&m);
	
	// draw all meshes assigned to this node
	for(; n < nd->mNumMeshes; ++n) 
	{
		const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
		glVertexPointer(3, GL_FLOAT, 0, mesh->mVertices);
		glNormalPointer(GL_FLOAT, 0, mesh->mNormals);
		glTexCoordPointer(3, GL_FLOAT, 0, &mesh->mTextureCoords[0][0]);
		glVertexAttribPointer(uniformVariable[0], 3, GL_FLOAT, GL_FALSE, 0, mesh->mTangents);
		glVertexAttribPointer(uniformVariable[1], 3, GL_FLOAT, GL_FALSE, 0, mesh->mBitangents);
		 
		for(unsigned int t = 0; t < mesh->mNumFaces; ++t)
		{
			const aiFace* face = &mesh->mFaces[t];
			indices.push_back(face->mIndices[0]);
			indices.push_back(face->mIndices[1]);
			indices.push_back(face->mIndices[2]);
		}
		glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, &indices[0]);
		indices.clear();

	}
	// draw all children
	for(n = 0; n < nd->mNumChildren; ++n)
		recursive_render(nd->mChildren[n]);
}






[Edited by - MARS_999 on October 16, 2009 8:56:07 AM]

Share this post


Link to post
Share on other sites
Advertisement
You apparently ignore the transformations stored in the scene. Meshes don't exist on their own, they're always indexed by a aiNode which specifies a transformation in relation to the other nodes. You need to iterate over the nodes and render the meshes using the accumulated transformation from the nodes.

Have a look at the Assimp/trunk/samples/SimpleOpenGL directory, there's a rather minimal aiScene renderer for you to look at.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!