I have now written a completely new Function for applying vertexcolors....
I used Fredborgs code as base so the Function for dot3 light creation and the function for applying lightrange to this lights are still fredborgs... I also used his Type-Field for the lights..
But the important code, the update-function, is completely new...
Lightrange is now regarded by the function that applies vertex colors...
This code is slower than fredborg's... i still work on getting it faster...
As this code could be interesting for somebody i post the functions here:
@ Ross C: I know... but i wondered what the variables red2, grn2 and blu2 were for in fredborgs original code...
they don't actually affect they vertexcolor as they're set to 0..
He could have used "vertexcolor surf, v, red, grn, blu" instead...
I'd really like feedbeack ^^
I used Fredborgs code as base so the Function for dot3 light creation and the function for applying lightrange to this lights are still fredborgs... I also used his Type-Field for the lights..
But the important code, the update-function, is completely new...
Lightrange is now regarded by the function that applies vertex colors...
This code is slower than fredborg's... i still work on getting it faster...
As this code could be interesting for somebody i post the functions here:
Type Dot3Light Field ent Field rng# End Type Function graphics_Dot3_CreateLight(typ=1,parent=0) d3l.Dot3Light = New Dot3Light d3l\ent = CreateLight(typ,parent) d3l\rng = 1 Return d3l\ent End Function Function graphics_Dot3_LightRange(ent,range#) For d3l.dot3light = Each dot3light If d3l\ent = ent If Lower$(EntityClass(d3l\ent))="light" LightRange d3l\ent,range d3l\rng = range Return End If End If Next End Function Global red# Global green# Global blue# Function graphics_Dot3_UpdateNormalmap(mesh) bumpVec=CreatePivot() surf = GetSurface(mesh, 1) For v=0 To CountVertices(surf)-1 red=0 blue=0 green=0 For d3l.dot3light=Each dot3light vx#=VertexX(surf,v) vy#=VertexY(surf,v) vz#=VertexZ(surf,v) TFormPoint vx,vy,vz,mesh,0 vx=TFormedX() vy=TFormedY() vz=TFormedZ() PositionEntity bumpVec,vx,vy,vz d#=EntityDistance(d3l\ent,bumpVec) PointEntity bumpVec,d3l\ent m#=1+(((d-0.15)*-1)/(d3l\rng-0.15)) If m>1 Then m=1 If m<0 Then m=0 MoveEntity bumpVec,0,0,m red=red+(EntityX(bumpVec)-vx) blue=blue+(EntityY(bumpVec)-vy) green=green+(EntityZ(bumpVec)-vz) Next red2=((red+1)*255)/2 green2=((green-1)*255)/-2 blue2=((blue+1)*255)/2 VertexColor surf,v,red2,green2,blue2 Next End Function
@ Ross C: I know... but i wondered what the variables red2, grn2 and blu2 were for in fredborgs original code...
they don't actually affect they vertexcolor as they're set to 0..
He could have used "vertexcolor surf, v, red, grn, blu" instead...
I'd really like feedbeack ^^