How to rotate vertex normals?

Blitz3D Forums/Blitz3D Programming/How to rotate vertex normals?

Gabriel(Posted 2003) [#1]
This is related to my other question about the fastest method of rotating vertices. I've gone ahead with the TFormPoint and a pivot method ( shown below ) and it seems marginally faster than Sin() and Cos() which is nice.

However, I was hoping that I could rotate vertex normals with the same method, and that bit isn't working.

To rotate vertices I'm doing this: ( I've spread it over a few more lines to make it more readable )

axis=CreatePivot()
RotateEntity axis,pitchchange#,yawchange#,rollchange#

For vcount=1 to numverts
     vx#=VertexX#(surf,vcount)-xpos#
     vy#=VertexY#(surf,vcount)-ypos#
     vz#=VertexZ#(surf,vcount)-zpos#
     TFormPoint vx#,vy#,vz#,axis,0
     vx# = TFormedX#()+xpos#
     vy# = TFormedY#()+ypos#
     vz# = TFormedZ#()+zpos#
     VertexCoords(surf,vcount,vx#,vy#,vz#)
Next




xpos,ypos & zpos are the offsets to the centre of rotation.

Anyway, that works fine, and seems to be pretty quick.

But the following code, supposed to rotate the vertex normals, doesn't.

     vnx#=VertexNX#(surf,vcount)
     vny#=VertexNY#(surf,vcount)
     vnz#=VertexNZ#(surf,vcount)
     TFormNormal vnx#,vny#,vnz#,axis,0
     vnx# = TFormedX#()
     vny# = TFormedY#()
     vnz# = TFormedZ#()
     VertexNormal(surf,vcount,vnx#,vny#,vnz#)



I've left out the loop and pivot creation because it just goes in the loop after the vertex rotation part.

Have I made an error or is it not possible to do it this way?


Stickman(Posted 2003) [#2]
Im not sure but your using Rotateentity( )
Try using RotateMesh( ) as for entity is not the Mesh,and its the mesh that will hold the normals ( I think,havent tryed it )


Gabriel(Posted 2003) [#3]
Using RotateEntity() and RotateMesh() yields exactly the same results. The vertices still rotate correctly and the normals still don't.

The pivot is only being rotated so that TFormPoint has a set of object coordinates to use.


marksibly(Posted 2003) [#4]
Hi,

Use TFormVector - normals are just a direction.