Directional lights are easy, but I am still having problems getting a point light to work:
Function NormalMapMesh(mesh,x#=0,y#=0,z#=0) If EntityClass(mesh)="Mesh" temp=CreatePivot() PositionEntity temp,x,y,s For s=1 To CountSurfaces(mesh) surf=GetSurface(mesh,s) For v=0 To CountVertices(surf)-1 RotateEntity temp,0,0,0 TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),mesh,temp d#=PointDistance(TFormedX(),TFormedY(),TFormedZ(),0,0,0) range#=1024.0 If d<range d#=Sqr((range-d)/range) b#=d*255 Else b=0 EndIf AlignToVector temp,TFormedX(),TFormedY(),TFormedZ(),3 RotateEntity temp,EntityPitch(temp),EntityYaw(temp),EntityRoll(temp) TFormNormal VertexNX(surf,v),VertexNY(surf,v),VertexNZ(surf,v),mesh,temp r#=(1.0-TFormedX())*127.5 g#=(1.0-TFormedY())*127.5 If TFormedZ()>0 b=0 VertexColor surf,v,r,g,b Next Next FreeEntity temp EndIf For c=1 To CountChildren(mesh) normalmapmesh GetChild(mesh,c) Next End Function