I'm trying to generate backfaces (I believe that to be the correct term at least; what I want to do is make single-sided triangles double sided) for a mesh using the vertexdata commands. I've come up with the following function, which doesn't quite work, and was wondering if anybody could give me a nudge in the right direction.
function generateBackfaces(o as dword)
perform checklist for object limbs o
limbCount = checklist quantity()
empty checklist
lock vertexdata for limb o, 0
local dim vert(get vertexdata vertex count()) as vertexData
vMax = get vertexdata vertex count() - 1
for v = 0 to vMax
vert(v).pos.x = get vertexdata position x(v)
vert(v).pos.y = get vertexdata position y(v)
vert(v).pos.z = get vertexdata position z(v)
vert(v).normal.x = get vertexdata normals x(v)
vert(v).normal.y = get vertexdata normals y(v)
vert(v).normal.z = get vertexdata normals z(v)
vert(v).diffuse = get vertexdata diffuse(v)
vert(v).u = get vertexdata u(v)
vert(v).v = get vertexdata v(v)
next v
local dim vertIndex(get vertexdata index count()) as integer
iMax = get vertexdata index count() - 1
for i = 0 to iMax
vertIndex(i) = get indexdata(i)
next i
unlock vertexdata
delete object o
tmp = o
make object new tmp, vMax + 1, (iMax + 1) * 2, 338
lock vertexdata for limb tmp, 0, 2
for v = 0 to vMax
set vertexdata position v, vert(v).pos.x, vert(v).pos.y, vert(v).pos.z
set vertexdata normals v, vert(v).normal.x, vert(v).normal.y, vert(v).normal.z
set vertexdata diffuse v, vert(v).diffuse
set vertexdata uv v, vert(v).u, vert(v).v
next v
for i = 0 to iMax
set indexdata i, vertIndex(i)
next i
offset = iMax + 1
// Set backface index data
for i = 0 to iMax step 3
set indexdata offset + i, vertIndex(i + 2)
set indexdata offset + i + 1, vertIndex(i + 1)
set indexdata offset + i + 2, vertIndex(i)
next i
unlock vertexdata
endfunction
The reason I'm trying to achieve this is so that I can raycast from within a mesh to get its average size at certain points.
Thanks for any advice,
Rudolpho
"Why do programmers get Halloween and Christmas mixed up?" Because Oct(31) = Dec(25)