Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Exporting Vertex and Index Data - sObject* and Memblocks

Author
Message
Red Eye
11
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st May 2012 17:45 Edited at: 1st May 2012 17:52
Hello there!

I ran into some troubles while converting objects, loaded into the sObject struct, toan irrXML readable version.

First of all my code to get the data from the memblock:



I used the memblock because I couldn't figure out how the sObject stores the vertex data, there is a pointer (BYTE*) pointing to the original vertex data (pOriginalVertexData), but can't copy the memory to an array.

But maybe a better question is: am I reading the memblock the right way?

The FVF is: XYZ | NORMAL | DIFFUSE | TEX0

That's that, but how about the Indices, how do I extract it's ids corresponding with the vertices. Can I just give them id's, 0 1 2 3 4 5 6 7 ... etc?

This is the first 4 iterations of couting the data i got from the memblock:



The XYZ seems alright, if 100 stands for 1 (thus, devided by 100 it looks normal), same for normals?

I couted the diffuse color as:

file << hex << dwColor;

With this I am attempting to convert it to and irrXML file format.
And because this http://www.irrlicht3d.org/download/example.irrmesh example works, I used it as a template. All goes well till the real meat, vertices & indices. It crashes upon loading without errors.

Thank you,

Leo

PS: I am wondering where the memblock get's all the data from the mesh. sObject->sObjectData->ppMeshList->sMeshDraw->pVertexData and pIndexData are all blank, I am wondering how it does it magic when it converts the normal object to an memblock (which i guess lies in the pBlock), but that's an exact copy of the sObject...

Cheers,

WLGfx
12
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 1st May 2012 19:47
I'm at that point myself so I'll keep an eye on this thread. I've managed to create a blank object with a set amount of verts and indices ready for me to copy my mesh data directly into it. As far as I know you have to 'lock vertex data' before you can access it.

If I come up with anything in the meantime I will post it here.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Matty H
11
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 1st May 2012 20:17
Quote: "sObject->sObjectData->ppMeshList->sMeshDraw->pVertexData and pIndexData are all blank"


Try calling dbSync() at least once and see if they are still empty.

Red Eye
11
Years of Service
User Offline
Joined: 15th Oct 2008
Location:
Posted: 1st May 2012 22:31 Edited at: 1st May 2012 22:32
Matty H, I understand it now! For sMeshDraw to get it filled in, it has to be rendered once, because the sMeshDraw struct is used when rendering the scene. To retrieve those values darkgdk uses we have to call dbSync() at least once, indeed. The vertex commands now work too, thus they use the same struct to get it's data from then. Is this correct?

Thank you sir! Very cool to see this working.

PS: Now I see how amazing alot of garbage the first version was spitting out.

Here is a codesnippet of the first 4 iterations:


Seems legit.

Gonna try to figure out the rest. And see if 2Texture Coords are available. I believe dbGetVertexDataU/V() accepts an extra parameter to tell the coordinates of all textures, I am not certain on this one, gonna test it out.

Cheers,

Login to post a reply

Server time is: 2020-02-26 07:32:24
Your offset time is: 2020-02-26 07:32:24