Jump to content
  • Advertisement
Sign in to follow this  
Wurzt

OpenGL [C++] [OpenGL] Animation in Assimp

This topic is 3166 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

This is the rendering code from the only sample code Assimp gives out, slightly edited, ( probably for the worse) and what I want to know is how I add animation!
void render(const struct aiScene *sc, const struct aiNode* nd)
{
	int i;
	unsigned int n = 0, t;
	struct aiMatrix4x4 m = nd->mTransformation;

	// update transform
	aiTransposeMatrix4(&m);
	glPushMatrix();
	glMultMatrixf((float*)&m);

	// draw all meshes assigned to this node
	for (; n < nd->mNumMeshes; ++n)
	{
		const struct aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D,texture);

		for (t = 0; t < mesh->mNumFaces; ++t)
		{
			const struct aiFace* face = &mesh->mFaces[t];
			GLenum face_mode;

			switch(face->mNumIndices)
			{
				case 1: face_mode = GL_POINTS; break;
				case 2: face_mode = GL_LINES; break;
				case 3: face_mode = GL_TRIANGLES; break;
				default: face_mode = GL_POLYGON; break;
			}

			glBegin(face_mode);

			for(i = 0; i < (int)face->mNumIndices; i++)
			{
				int index = face->mIndices;

				glTexCoord2f(mesh->mTextureCoords[0][index].x,mesh->mTextureCoords[0][index].y);

				float meh = 0;

				glVertex3fv(&mesh->mVertices[index].x);
			}

			glEnd();
		}
		glDisable(GL_TEXTURE_2D);

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

	glPopMatrix();

}

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!