I've tried recreating an old program of mine using the new vertex tweaking commands which 5.8 provides.
Pretty much everything is working, aside from generating the face normals. When viewing the mesh, there's no shading or lighting (indicative of a lack of normals). I can't decide if it's my code, or the "SET VERTEXDATA NORMAL" command. I've got the code spitting out the actual vertex normals and they look genuine (0.543534,0,0.32124 for example) which leads me to believe it's something else (other than the algorithm)....
Here's teh codez. For your information, getVertexID takes a vertex number for a tile (0,5) and a reference (x,y) and produces the actual vertex number.... This function works, before you ask
I'm only doing it on half the faces for simplicity's sake... (1-3 only, not 4-6).
Point 1 is opposite the hypotenuese... that means that the direction vectors are calculate by doing 2-1 and 3-1.
local dim points(6) as integer
points(1) = getVertexID(0,xtile,ytile)
points(2) = getVertexID(1,xtile,ytile)
points(3) = getVertexID(2,xtile,ytile)
null = make vector3(1)
null = make vector3(2)
null = make vector3(3)
lock vertexdata for limb iObjectID, 0
` -- calculate the two directional vectors for the adj and opp edges...
set vector3 1, get vertexdata position x(points(2)), get vertexdata position y(points(2)), get vertexdata position z(points(2))
set vector3 2, get vertexdata position x(points(1)), get vertexdata position y(points(1)), get vertexdata position z(points(1))
set vector3 3, get vertexdata position x(points(3)), get vertexdata position y(points(3)), get vertexdata position z(points(3))
subtract vector3 2, 2, 1
subtract vector3 3, 3, 1 ` -- vector 3 and 1 are now directional vectors
normalize vector3 2,2 ` -- normalize em
normalize vector3 3,3
cross product vector3 1, 2,3 ` -- use the origin vector (1) to store the face normal
normalize vector3 1,1
text 0,0,str$(x vector3(1))
text 0,20,str$(y vector3(1))
text 0,40,str$(z vector3(1))
sync
suspend for key
` -- set the normals for this face
SET VERTEXDATA NORMALS points(1), x vector3(1), y vector3(1), z vector3(1)
SET VERTEXDATA NORMALS points(2), x vector3(1), y vector3(1), z vector3(1)
SET VERTEXDATA NORMALS points(3), x vector3(1), y vector3(1), z vector3(1)
null = delete vector3(1)
null = delete vector3(2)
null = delete vector3(3)
unlock vertexdata
Err - hope someone can make sense of this. Or better yet has come across this...
Me? With my reputation?