6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: MDL7 skinpoints
[Re: jcl]
#284053
08/11/09 13:07
08/11/09 13:07
|
Joined: Jul 2006
Posts: 783 London, UK
sheefo
OP
User
|
OP
User
Joined: Jul 2006
Posts: 783
London, UK
|
I think I am too stupid to figure it out. I used an std::map<int, std::set<int>> object to store the vertices and their corrisponding skinpoints and it gave the correct number of vertices needed but I cannot seem to figure out how to store the vertex pos and normals or fill the index buffer with the new vertex values.
Since the verts and tris need to be read from seperate loops I need to store everything for access in a single loop. I got that done but storing unique vertices is proving tricky (for me).
EDIT: I have managed to create a list of all needed vertices but for some reason the list is not in the same order as the 3DGS vertex buffer. I made sure no sorting is done on the list by not using std::set.
Last edited by sheefo; 08/11/09 15:28.
|
|
|
Re: MDL7 skinpoints
[Re: amy]
#284310
08/12/09 17:50
08/12/09 17:50
|
Joined: Jul 2006
Posts: 783 London, UK
sheefo
OP
User
|
OP
User
Joined: Jul 2006
Posts: 783
London, UK
|
I have re-written the vertex code to work just like the example above. The vertex buffer seems to be correct because I rendered the points in world space and they form a box (and other model shapes I have tested). The only thing left is the index buffer. I don't understand how to calculate the new indices. In the index buffer I loop through each triangle but then I don't know how to look up the value of the new index. The code below is my setup, although it uses old indices.
for (unsigned i = 0; i < dwNumTris; i++) {
MD7_TRIANGLE tr;
memcpy(&tr, &pTriangles[i], sizeof(MD7_TRIANGLE));
// triangle
pIndexBuffer[i*3+0] = tr.v_index[0]; // old index
pIndexBuffer[i*3+1] = tr.v_index[1]; // old index
pIndexBuffer[i*3+2] = tr.v_index[2]; // old index
}
|
|
|
Re: MDL7 skinpoints
[Re: sheefo]
#284325
08/12/09 19:40
08/12/09 19:40
|
Joined: Feb 2007
Posts: 353
amy
Senior Member
|
Senior Member
Joined: Feb 2007
Posts: 353
|
Your second loop will look almost like the first pseudo code loop I posted above but instead of adding to the hashed data structure you do an index look-up. The details depend on what data structure you use but here is some pseudo code again:
// first loop
vertices = set()
foreach triangle:
foreach vertex of triangle:
vertices.add(vertex.x, vertex.y, vertex.z, vertex.nx, vertex.ny, vertex.nz, vertex.u, vertex.v)
// second loop
indices = array()
foreach triangle:
foreach vertex of triangle:
indices.add(vertices.indexof(vertex.x, vertex.y, vertex.z, vertex.nx, vertex.ny, vertex.nz, vertex.u, vertex.v))
I hope you get the idea now? I think it also would be possible to do the whole job in one loop but then it gets a bit more complicated and I don't think it would have much performance advantage.
|
|
|
|