Rotate vertex mass

Blitz3D Forums/Blitz3D Programming/Rotate vertex mass

poopla(Posted 2003) [#1]
How would I rotate a buffer of stored vertices? The situation would probably call for them to be stored in a vertex buffer(array). I imagine it requres I find the center of the vertex mass, then move them with a sin()/cos() algo depending on the distance from the center? Thanks for any help.


big10p(Posted 2003) [#2]
I'm not sure I understand fully, but can you not just add the verts to a mesh and then RotateMesh?


poopla(Posted 2003) [#3]
Sure I could, but the situation may call for rotation of specific vertices.


Bot Builder(Posted 2003) [#4]
well, I know there's a way to find it using pure math, but one way is to position a pivot oriented in the direction amount you want rotated at the center of mass. Then Tformpoint vertexx,vertexy,vertexz,pivot,themesh for each vertex and tformedx,y,z will hold the new position of the verticex.


poopla(Posted 2003) [#5]
Thx bot builder, Ill look into that.


Gabriel(Posted 2003) [#6]
Sure I could, but the situation may call for rotation of specific vertices.


I think that's what Big10P was suggesting. Only add the vertices you want to rotate to the mesh. I seem to recall he did some testing with "scratch meshes" and found it to be the fastest way of rotating vertices. When I needed to do this, I did it BotBuilder's way but it's not all that fast.


jfk EO-11110(Posted 2003) [#7]
Probably this is useful:

original coords in x0,y0 and z0
result in xl3,yl3 and zl3
(everything is float, of course)

; rotate pitch#, yaw# and roll#
;---------------------------------
xl1#=z0*Sin(roll)+x0*Cos(roll)
yl1#=y0
zl1#=z0*Cos(roll)-x0*Sin(roll)

xl2#=xl1
yl2#=yl1*Cos(yaw)-zl1*Sin(yaw)
zl2#=yl1*Sin(yaw)+zl1*Cos(yaw)

xl3#=yl2*Sin(pitch)+xl2*Cos(pitch)
yl3#=yl2*Cos(pitch)-xl2*Sin(pitch)
zl3#=zl2
;---------------------------------


big10p(Posted 2003) [#8]
Yes, Sybixsus, that is what i meant ;)

...simply read the verts you want rotated into the scratch-pad mesh, do the rotations, then write the new verts back into your mesh-proper.

Bot Builders method using TFormPoint will also work but I expect it would become pretty slow if you wanted to rotate hundreds/thousands of verts as you'd have to individually TFormPoint each vert.

Either way, I'm sure you'd find doing the rotations in software (using sin/cos) MUCH slower as I assume using a scratch-pad mesh takes advantage of hardware T&L.