Jump to content
  • Advertisement
Sign in to follow this  
terryeverlast

Loading Models With Assimp Directx 11

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

Advertisement

So far, i have:

Assimp::Importer importer;



    const aiScene * scene = importer.ReadFile("untitled.obj", aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);




Next steps?

Edited by terryeverlast

Share this post


Link to post
Share on other sites
 
  
std::vector<Vertex::Basic32> vertices(8);
	Assimp::Importer importer;



    const aiScene * scene = importer.ReadFile("untitled.obj", aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);

	aiMesh *mesh = scene->mMeshes[0]; 
	
   for(int i = 0;i<8;i++)
   {
	  
{
	
aiVector3D pos = mesh->mVertices[i];
 
vertices[i].Pos.x    =  pos.x;
vertices[i].Pos.y    =  pos.y;
vertices[i].Pos.z    =  pos.z;
	}
	

   }
   std::vector<UINT> indices;

 for (int i = 0; i < mesh->mNumFaces; i++) {
    const aiFace& Face = mesh->mFaces[i];
    if(Face.mNumIndices == 3) {
        indices.push_back(Face.mIndices[0]);
        indices.push_back(Face.mIndices[1]);
        indices.push_back(Face.mIndices[2]);

}

 }

My code now loads the cube and now need to load normal and texture....

 

Edited by terryeverlast

Share this post


Link to post
Share on other sites

There is no way to load texture via Assimp. Assimp will only hold the name of the texture for you. You must load those images with some other library, or write it yoursellf. 

STB image library is a good start.

Share this post


Link to post
Share on other sites

But what are these then.("mTextureCoords")

vec.x = mesh->mTextureCoords[0][i].x; 
vec.y = mesh->mTextureCoords[0][i].y;

I'm loading a .OBJ. So are these "mTextureCoords" are "vt" values?

 

I tested the mTextureCoords values in my debugger and they were different so just wondering.

Edited by terryeverlast

Share this post


Link to post
Share on other sites

Those are UV coordinates. I have never used Assimp, but have looked into its functionality. as imoogi already said, you will have to load the texture yourself using the texture path that Assimp gives you.

 

I can pretty much load any model. But cant find code to load textures.??

 

You shouldn't be trying to "find the code" to load a texture or for anything you want to accomplishing in programming. You should understand your tools, then use your accrued knowledge to put the pieces together yourself. It is usually boilerplate code that you will ever "need to find" which only sets you up, but does not accomplish your task. Read a book, take a class, LEARN to code, not copy/paste.

Edited by ExErvus

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!