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 / Building a mesh from vertex and index data

Author
Message
_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th Jun 2011 01:03
Hi folks,

My problem is this:
I have an array of vertex data (xyz, normal, color, uv) and an array of index/triangle data (vertex a,b,c). How can I construct a DarkGDK mesh from this data?

I tried it using a memblock, but it doesn't work properly. Maybe because I just filled the memblock with the vertex data (in the same order as stored in the array) and made a mesh from that? Didn't find any information about indices in memblock meshes...
Any ideas?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Jun 2011 01:37
I think you can set the index data at any time after you have created the model, using dbSetIndexData()(after locking etc). If it finds no index data then it draws it one way, if it finds index data it uses it.

You should be able to use a memblock, did you make sure the FVF format etc was set correctly?

_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th Jun 2011 01:50 Edited at: 10th Jun 2011 01:52
I think the FVF and all the memblock related things are correct (spend quite some time figuring it all out).
Here's my FVF, just in case you spot a mistake that I don't see



But thanks for the hint, I'll try manipulating the index data after the object is built.
Unfortunatly I'm not quite sure how to use it! Here is the function as it's in the header:



But I'm not quite sure what the parameters are for. I expected something like this:



Got any infos on that?

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Jun 2011 01:59
If I remember correctly you will set each triangle with 3 calls to the command:



So the first triangle will use vertices 32, 35, 36.

_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th Jun 2011 14:05 Edited at: 10th Jun 2011 14:06
Ok, didn't have much success with changing the index data after creating the mesh. But that doesn't mean that you were wrong or anything, just didn't try hard enough

That's because I have it working just using memblocks now. I just store all the vertices in a new vertex buffer array, where every vertex is stored in the correct order (according to the index data) and then written from the buffer to a memblock. Seems to work quite well.
I think I have more vertices created this way though (3 per triangle = 6 on a plane, instead of just the minimum required 4), but the polygon count is still correct.

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 11th Jun 2011 17:05
Thinking about it, I suppose that since you created the mesh there wont be any memory set aside for index data

There may be a way to turn it into an indexed mesh but I'm not sure. What you have done is a good solution, although the mesh wont be quite as efficient as there will be more vertices.

_Pauli_
AGK Developer
15
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 12th Jun 2011 16:02 Edited at: 12th Jun 2011 16:04
Quote: "the mesh wont be quite as efficient as there will be more vertices."


Yeah I know. I haven't found a proper solution, so I'll stick to this method for know...

But I think/hope that these extra vertices don't affect the performance that much, since vertices themselves are not visible, because only the polygon that they form is rendered.

Login to post a reply

Server time is: 2024-11-19 10:30:16
Your offset time is: 2024-11-19 10:30:16