Sign in to follow this  

Getting certain verticies from mesh

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

Well, i looked around and found a sample on how to lock the mesh then get the data and it isnt working... The code is: D3DXVECTOR3 *pVertList; m_pMesh->LockVertexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK, (LPVOID*)&pVertList); intersectO.v1 = pVertList[dwFace * 3]; intersectO.v2 = pVertList[dwFace * 3 + 1]; intersectO.v3 = pVertList[dwFace * 3 + 2]; m_pMesh->UnlockVertexBuffer(); and it returns that on this line: m_pMesh->LockVertexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK, (LPVOID*)&pVertList); cannot convert parameter 2 from 'void ** ' to 'unsigned char ** ' so, i know there is a simple answer, but i just cant get it >.< anyone know how to go about this?

Share this post


Link to post
Share on other sites
It's not the pointer cast that is causing trouble, it's the type of pointer. you'd need (unsigned char**)&pVerts.

But I dont know why it should do that, LockVertexBuffer expects a void** not an unsigned char** ...

Share this post


Link to post
Share on other sites
Oops, I messed up there. Yeah, it expects a void**. Those damn LP keywords always mess me up.

Yeah, I don't see where the unsigned char part is even coming from.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Pirosan
well i tried (BYTE**)&pVertList) and it accepts it, though the program dies immediatly at startup... any ideas why this would be?




verify/validate the value of dwFace

Share this post


Link to post
Share on other sites
Nahh, there's something wrong. What SDK version are you using? I can't remember if the old stuff accepted char pointers or not.

In any case, if you're using version 9c (as I am), then I would shut down your computer and buy a cross to wear around your neck. But before that, make sure you're using the correct includes and libraries for your version of DirectX.

Share this post


Link to post
Share on other sites
Some older SDK's used BYTE (unsigned char) pointers. I'm thinking 8 did, I know 5 did...not much more than this I know. I agree with Jiia. I bet it's an include problem. Maybe you had a previous version of the SDK on your computer? Or you're using an old SDK and know it but looking at an example used with a newer SDK.

Chris

Share this post


Link to post
Share on other sites
i am using 8, and i know that all my includes are 8 compatable... I got the code to lock/unlock the mesh data from a forum here in gamedev... maybe i shouldnt use a D3DXVECTOR3 pointer list?

Ill check the face validity, but im pretty sure its correct

Share this post


Link to post
Share on other sites
Well, the error "cannot convert parameter 2 from 'void ** ' to 'unsigned char **" means that you tried to send a void pointer-pointer instead of what it wanted: an unsigned char**. So I expect that any other problems you have are unrelated. The way MS changes types in their SDK versions makes it very confusing in the forums.

They should have started with a void to begin with.

Share this post


Link to post
Share on other sites
The example you looked at is probably using DX 9 if it's using a VOID**. Just use a BYTE**. It could be crashing for any number of reasons. Check out the debug output. Also verify the lock worked:


D3DXVECTOR3 *pVertList = NULL;
m_pMesh->LockVertexBuffer(D3DLOCK_READONLY | D3DLOCK_NOSYSLOCK, (LPVOID*)&pVertList);

if (pVertList)
{
intersectO.v1 = pVertList[dwFace * 3];
intersectO.v2 = pVertList[dwFace * 3 + 1];
intersectO.v3 = pVertList[dwFace * 3 + 2];

m_pMesh->UnlockVertexBuffer();
}
else
throw ("Not Locked");



Chris

Share this post


Link to post
Share on other sites
uhhh wow that was an odd messup on my part. You see, i had a function that checked if it collided with each object in the scene, but it ONLY returns a face index IF it hits that object... it wasnt hitting one of my objects so it wasnt being given a face index... i was trying to access i think around the 32 millionth polygon, which basically didnt exist ^ ^

Thanks for your help you guys!


Chris

Share this post


Link to post
Share on other sites

This topic is 4840 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.

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