Sign in to follow this  
danto

cal3d texture issue

Recommended Posts

I looked through the developers forum and did not find an answer to this. I have a problem retrieving the userdata from the calcorematerial for texture mapping. I'm using the code from the miniviewer for cal3d ...it's layed out very differently but the same code. I've error tested and I am getting the texture filename and loading in the texture and getting and setting a valid id in the userdata. It's when I try to retrieve it in the render loop from the model instance (calRenderer) that I have problems. The renderer returns 0 for getMapCount for the selected mesh. I'm not sure exactly what I'm doing wrong. Thanks for any assistance. edit: After further testing it seems that the pCalRenderer->getMapUserData(0) line is not getting the user data of the currently selected mesh correctly in the render loop. I manually just grabbed the coreMaterial of the first mesh and got it's user data and there was the correct texture id of the first mesh. I'm still in a bit of a jam as there are more meshes than materials so I can't just use the mesh id to get the material...and I rather feel like I'm trying to re-write on my side what cal3d should already be doing. So I'm still not sure what I'm doing wrong here. [Edited by - danto on November 26, 2005 7:04:36 PM]

Share this post


Link to post
Share on other sites
Further Investigation:

Alright I've narrowed down the problem, but again I don't know why the problem is occuring.

This line is used to grab the stored texture id of the current submesh which is not working.
pCalRenderer->getMapUserData(0)

Looking under the hood it uses the following way of getting the coreMaterial:
pCoreMaterial = m_pModel->getCoreModel()->getCoreMaterial(m_pSelectedSubmesh->getCoreMaterialId());

The problem seems to be in the m_pSelectedSubmesh->getCoreMaterialId() as I've used the following line to get a corematerial and it works fine:

CalCoreMaterial* calCoreMat = curr->getModelInstance()->getCoreModel()->getCoreMaterial(0);

Now this only gets the first material, but it does work if I replace the user data line with:

calCoreMat->getMapUserData(0)

It will then get the texture data and I can map it properly to my model. So it would seem that the calsubmesh is not storing the material id properly. I've been digging through the cal3d code trying to find where the material id is assigned to the submesh, but no luck yet.

Everything else works fine...I can render the model and it's animation just fine...just can't get these damn textures assigned. Well...back to digging.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this