Gday everyone
I found a pice of code a while ago somewhere in this forum about fake lighting & i can't remember who posted it. I have been playing around with it & am trying to write a fake lighting include file.
so far i have managed to write a function that sets a fake ambient lighting effect to a mesh.
copy this & save as fakelight_include1
What i would like to know is. Is there a way i could write a function so if i had 100 diferent objects in a scene i wouldn't have to code the ( TFormPoint & LightMesh ) a billion times?
I have had a try & havn't had much luck. Any help would be much appreciated.
I found a pice of code a while ago somewhere in this forum about fake lighting & i can't remember who posted it. I have been playing around with it & am trying to write a fake lighting include file.
so far i have managed to write a function that sets a fake ambient lighting effect to a mesh.
copy this & save as fakelight_include1
Type fklitentity Field entity Field fx Field ambientr Field ambientg Field ambientb End Type Type fklight Field entity Field light Field red Field green Field blue Field range Field x Field y Field z End Type Function fklitentity(entity,ambientr,ambientg,ambientb) p.fklitentity=New fklitentity p\entity=entity LightMesh p\entity,-255,-255,-255 p\ambientr=ambientr p\ambientg=ambientg p\ambientb=ambientb LightMesh p\entity,p\ambientr,p\ambientg,p\ambientb End Function
Graphics3D 640,480,16,2 Include "fakelight_include1.bb" light=CreateSphere() ScaleEntity light,.1,.1,.1 PositionEntity light,-4,-4,-4 EntityColor light,0,255,0 light1=CreateSphere() ScaleEntity light1,.1,.1,.1 PositionEntity light1,4,-4,-4 EntityColor light1,255,0,0 cube=CreateCube() PositionEntity cube,0,0,0 EntityFX cube,3 cone=CreateCone(20) PositionEntity cone,-5,0,0 EntityFX cone,3 cyl=CreateCylinder(20) PositionEntity cyl,5,0,0 EntityFX cyl,3 piv=CreatePivot() PositionEntity piv,EntityX(cube),EntityY(cube),EntityZ(cube) light2=CreateSphere(10,piv) ScaleEntity light2,.1,.1,.1 PositionEntity light2,0,7,0 EntityColor light2,0,0,255 camera=CreateCamera() PositionEntity camera,0,2,-10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While Not KeyDown(1) PointEntity camera,cube TurnEntity piv,1,0,0 TurnEntity cube,0,.5,.5 TurnEntity cone,-.5,.5,0 TurnEntity cyl,-.5,-.5,0 ;;;;;;;;;;;;;;;;;Sets the ambient light level of objects;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; fklitentity(cube,10,10,10) fklitentity(cone,10,10,10) fklitentity(cyl,10,10,10) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; TFormPoint 0,0,0,light,cube LightMesh cube,0,255,0,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light,cone LightMesh cone,0,255,0,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light1,cube LightMesh cube,255,0,0,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light2,cube LightMesh cube,0,0,255,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light2,cone LightMesh cone,0,0,255,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light1,cyl LightMesh cyl,255,0,0,10,TFormedX(),TFormedY(),TFormedZ() TFormPoint 0,0,0,light2,cyl LightMesh cyl,0,0,255,10,TFormedX(),TFormedY(),TFormedZ() UpdateWorld RenderWorld Flip Wend End
What i would like to know is. Is there a way i could write a function so if i had 100 diferent objects in a scene i wouldn't have to code the ( TFormPoint & LightMesh ) a billion times?
I have had a try & havn't had much luck. Any help would be much appreciated.