Extracting information from the vertex buffer

Extracting information from the vertex buffer

Portrait de samaursa

I am trying to extract information from the vertex buffer (for example, the position, texture, normal values) but I can't seem to figure out how to get the arrays for each of the desired elements. Through another thread post, I got the following code

desiredElems.pushBack ( hkxVertexDescription::HKX_DU_POSITION );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_NORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TANGENT );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_BINORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_COLOR );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TEXCOORD );

const hkClass* pClass = hkxVertexDescription::getBuiltInVertexClass(desiredElems, classElems);

Now I don't know what to do with pClass. Do I cast it some other class? How do I know what class that is? The other thread's started said something about hkxVertexP4N4T4B4C1T2 class. I get the name of the new hkClass as that, but how do I get each of the arrays (position, texture, normal) from the hkclass? I tried to use getDeclaredMember(i) but don't know what to do with the variant. I am still looking over other functions in the hkclass to see if one of them will return the data. I searched the documenation and there is nothing relating to this problem.

Any help would be appreciated. Thanks in advance.

6 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de samaursa
Quoting - samaursa I am trying to extract information from the vertex buffer (for example, the position, texture, normal values) but I can't seem to figure out how to get the arrays for each of the desired elements. Through another thread post, I got the following code

desiredElems.pushBack ( hkxVertexDescription::HKX_DU_POSITION );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_NORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TANGENT );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_BINORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_COLOR );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TEXCOORD );

const hkClass* pClass = hkxVertexDescription::getBuiltInVertexClass(desiredElems, classElems);

Now I don't know what to do with pClass. Do I cast it some other class? How do I know what class that is? The other thread's started said something about hkxVertexP4N4T4B4C1T2 class. I get the name of the new hkClass as that, but how do I get each of the arrays (position, texture, normal) from the hkclass? I tried to use getDeclaredMember(i) but don't know what to do with the variant. I am still looking over other functions in the hkclass to see if one of them will return the data. I searched the documenation and there is nothing relating to this problem.

Any help would be appreciated. Thanks in advance.

nobody??

I am completely stuck with this problem. It is actually very frustrating to see hkxVertexP4N4T4B4C1T.h class right infront of you but having no clue as to how to access each vertex from the vertex buffer through that class.

If somebody can point me in the right direction, I would really appreciate it

Portrait de samaursa
Quoting - samaursa I am trying to extract information from the vertex buffer (for example, the position, texture, normal values) but I can't seem to figure out how to get the arrays for each of the desired elements. Through another thread post, I got the following code

desiredElems.pushBack ( hkxVertexDescription::HKX_DU_POSITION );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_NORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TANGENT );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_BINORMAL );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_COLOR );
desiredElems.pushBack ( hkxVertexDescription::HKX_DU_TEXCOORD );

const hkClass* pClass = hkxVertexDescription::getBuiltInVertexClass(desiredElems, classElems);

Now I don't know what to do with pClass. Do I cast it some other class? How do I know what class that is? The other thread's started said something about hkxVertexP4N4T4B4C1T2 class. I get the name of the new hkClass as that, but how do I get each of the arrays (position, texture, normal) from the hkclass? I tried to use getDeclaredMember(i) but don't know what to do with the variant. I am still looking over other functions in the hkclass to see if one of them will return the data. I searched the documenation and there is nothing relating to this problem.

Any help would be appreciated. Thanks in advance.

After hours of being stuck with this problem I have finally found a solution which I am posting here. Hopefully someone will find this helpful and will spare them the frustration I went through =)

The first thing you need to do is get the vertex description from the vertex buffer. From the description you can now get the the individual element offsets by .getElementByteOffset(hkxVertexDescription, 0) , 0 because we want to start from the first vertex. Get the number of vertices (so that we know how many to go through) from vertex buffer as well.

Get the vertex data and store it in a hkInt8 (get this from vertex buffer getVertexData()). Get the stride value from the description (the 'size' of the information of each vertex) which is a member variable of vertex description.

Now loop through the number of of vertices and extract the serialized data from hkInt8 (the vertex data) by doing this:

for (int i = 0; i < numberOfVertices; i++)
{
float* extractedData = reinterpret_castvertexData + (stride * i) + offset; //where offset is the offset of the desired data i.e. position, normal etc.
}

Now here's the interesting part, and I never knew float pointer had this information. Suport extractedData has position information. To extract the x,y,z from the newly casted float, do this

hkVector4 newPosData(extractedData[0], extractedData[1], extractedData[2])

and you got yourself position data. Same for all the other elements.

If you have the same problem and have run across this thread I hope this has helped you.

Portrait de danothom

Old post but useful stuff. Legend! Thanks.

Portrait de aresthegod

damn dawg nice find!

Portrait de danothom

I know right! Its basically EXACTLY what I was looking for at the same time. I found it near the same exact time as I got the info I needed from my other post. Better late than never I guess.

Connectez-vous pour laisser un commentaire.