dot 3 lighting
Blitz3D Forums/Blitz3D Programming/dot 3 lighting
| ||
How can i make a Dot3 object be independent to the light? i meam, a cube is spinning but the light source it self stays where it is, but the normal light colours alter? |
| ||
You need to transpose it into the object's space. tformpoint lightX,lightY,lightZ,entityToLight,0 positionLight tformedX(),tformedY(),tformedZ() then get the vector from the tformed position.(Remember move the light back, or just work directly on the tform funcs.) |
| ||
any code? this could be SO cool to have DirectX 7 to do Some Dot3 stuff. only stuff like crates and pipes tho in the long run its prolly just as fast to make the polys in DX7! hehe but have you got any example code that would work? its 3am in the morning, my heads gone to sleep :( |
| ||
Function entityLight(entity,light,inten#=0.5,hull=False) ox#=EntityX(light) oy#=EntityY(light) oz#=EntityZ(light) inten =0.5 ;If Not hull inten=1.-inten tp=CreatePivot() PositionEntity tp,EntityX(light),EntityY(light),EntityZ(light) TFormPoint ox,oy,oz,tp,entity ;FreeEntity tp light=tp PositionEntity light,TFormedX(),TFormedY(),TFormedZ() ;Transpose light into dx# =(EntityX(light)-EntityX( entity));*inten dy# =(EntityY(light)-EntityY( entity));*inten dz# =(EntityZ(light)-EntityZ( entity));*inten nl#=Sqr(dx*dx+dy*dy+dz*dz) nx#=dx/nl ny#=dy/nl nz#=dz/nl nl#=(nl*10.-255.)/255. nl=1.-nl If nl>1. nl=1 If nl<0. nl=0 nl=in nx=nx;*inten ny=ny;*inten nz=nz;*inten ;nz=(Sgn(nz))+nz ;nx=(Sgn(nx))+nx ;ny=(Sgn(ny))+ny ;If nx<0 nx FreeEntity tp EntityColor entity,128.+(128.*nx),128.+(128.*nz),128.+(128.*ny) ;EntityColor entity,256+(256*nx),256.0+(256*ny),256.0+(256*nt) ;PositionEntity light,ox,oy,oz ;return light. End Function ripped it from some old code of mine..could do with cleaning up a little, but it worked fine for me. Light = light pivot, entity =entity to light, inten =light strength, hull=internal or exteneral. |
| ||
hmm, this seems to be working the oposite way, the light is in front of the object, and im getting the effect on the other side. also, its not working verywell on objects that move :( |
| ||
If the light's on the wrong side, just reverse the vector. As for not working on moving objects, it did for me way back when. Upload something simple showing me what you mean and i'll try to fix it anyway. |
| ||
here is the code im trying to grasp the concept, I got the normal mapping program from nvedia, Nice kit, so i need Blitz to utilise it properly. i'll be moving about the map and the boxes are bumped the media files are http://www.neomancer.co.uk/ibox_norm.zip |