Re: [Pipmak-Users] lens effects in Pipmak with Lua
Status: Alpha
Brought to you by:
cwalther
From: Andrea V. <and...@gm...> - 2007-11-22 15:24:16
|
Hello, This is just a track to how implements lens flare effect in Pipmak using only lua programming . You needs only six image for your scene plus 2 trasparent PNG: a) sun.png (could be simply a white circle with transparent background) b) effect.png (a white pentagon rotated (30 degrees?) on transparent background) This works, but it must be improved, because I have placed effects with an empirical method.... 1) We need a formula for describing the position of pentagons starting from azimuth and elevation of the view. 2) Drawing of effects must done with a loop, so we could pass as parameter the number of the pentagons... Who want improve this code? --------------------------------------- cubic { "front.png", --front "front.png", --right "front.png", --back "front.png", --left "ceil.png", --top "floor.png" --bottom } pipmak.setverticalfov(70) p0=patch {face=2, x=320-40, y=80 , w=80, h=80,image="sun.png",visible=true } p1=patch {face=2, x=320-25, y=100, w=50, h=50,image="effect.png",visible=true } p2=patch {face=2, x=320-15, y=120, w=30, h=30,image="effect.png",visible=true } p3=patch {face=2, x=320-20, y=140, w=40, h=40,image="effect.png",visible=true } p4=patch {face=2, x=320-10, y=170, w=20, h=20,image="effect.png",visible=true } p5=patch {face=2, x=320-8, y=200, w=16, h=16,image="effect.png",visible=true } p1:setcolor(1,1,1,0.4) p2:setcolor(1,1,0,0.6) p3:setcolor(1,0,1,0.4) p4:setcolor(1,0,0,0.5) p5:setcolor(0,0,1,0.4) onenternode( function() pipmak.schedule(0.1, function() az,el=pipmak.getviewdirection() --pipmak.printinplace(az.." "..el) x,y,f=p1:location() x=320-25+(90-az)*2 y=100+(15-el)*2 p1:moveto(x,y,f) x,y,f=p2:location() x=320-15+(90-az)*3 y=120+(15-el)*2.5 p2:moveto(x,y,f) x,y,f=p3:location() x=320-20+(90-az)*4.5 y=140+(15-el)*6 p3:moveto(x,y,f) x,y,f=p3:location() x=320-10+(90-az)*6 y=170+(15-el)*8 p4:moveto(x,y,f) x,y,f=p3:location() x=320-8+(90-az)*10 y=200+(15-el)*12 p5:moveto(x,y,f) return 0.1 end) end) -------------------------------------- Bye. Andrea |