Rotate a Mesh like an Entity?

Blitz3D Forums/Blitz3D Programming/Rotate a Mesh like an Entity?

CopperCircle(Posted 2005) [#1]
Hi, I need to rotate a mesh in the same way RotateEntity works, but I can't get it to work.

The code bellow shows the problem, if you rotate just the Yaw it's fine, but add the other angles and it goes out of sync with the rotated entity.

I know the pitch/roll values jump in Bltz after 90/180 but the mesh goes out before then.

Anyone else made a function to do this?

Thanks,




_PJ_(Posted 2005) [#2]
TurnEntity, RotateEntity

have

TurnMesh, RotateMesh counterparts.

TFormPoint may help in this... Im not too sure...


Beaker(Posted 2005) [#3]
This might help:
http://www.blitzbasic.com/codearcs/codearcs.php?code=978


CopperCircle(Posted 2005) [#4]
Thanks, TFormPoint does the job.

Function TransformMesh(mesh,entity)
msurface=GetSurface(mesh,1)
esurface=GetSurface(entity,1)
numverts=CountVertices(msurface)
For i=0 To numverts-1
TFormPoint VertexX(esurface,i),VertexY(esurface,i),VertexZ(esurface,i),entity,0
VertexCoords msurface,i,TFormedX(),TFormedY(),TFormedZ()
TFormNormal VertexNX(esurface,i),VertexNY(esurface,i),VertexNZ(esurface,i),entity,0
VertexNormal msurface,i,TFormedX(),TFormedY(),TFormedZ()
Next
End Function


Stevie G(Posted 2005) [#5]
You could do something like this ... but vertex manipulation is slow.

Note that each time you rotate a mesh the yaw, pitch and roll are always zeroised. Perhaps if you rotatemesh each axis separately this will work for you .. I doubt it though.

Oops .. too slow but same idea!!