Tricky Geometry...

Blitz3D Forums/Blitz3D Programming/Tricky Geometry...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Well, I'm officially bad a maths but I recently needed to add a vertex to the centre of all tris in a mesh in order to do per-tri rotations. This is the code I came up with, where:

x0,y0,z0 = vert 0 coords.
x1,y1,z1 = vert 1 coords.
x2,y2,z2 = vert 2 coords.

; Calculate and add a lone 'centre of tri'
; vertex (needed for per-tri rotations).
tx# = x1 + ((x2-x1)/2)
ty# = y1 + ((y2-y1)/2)
tz# = z1 + ((z2-z1)/2)
cvx# = tx - ((tx-x0)/3)
cvy# = ty - ((ty-y0)/3)
cvz# = tz - ((tz-z0)/3)
AddVertex(d_surf,cvx,cvy,cvz)


It seemed to do the job. Appologies if this is no good (i.e. crap) or is a method you've already discussed - like I say, I'm not a maths person. ;)