I have this written and it’s working well,
however there is some complex math I will need.
I have most of what is needed to “score” a light based on distance and angle,
but I don’t really know how to do it…
I want to populate closest few lights, and then a few mid range lights in the angle
lets say 6 lights…
how would you all do this?
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
LODlist=[]
len=-1
## get list of all objects with LOD
if 'LODList' not in own:
for objects in bge.logic.getCurrentScene().objects:
if 'LOD' in objects:
LODlist+=[objects]
len+=1
own['LODList']=LODlist
own['Len']=len
own['index']=0
else:
s = own['index']
x=0
##proccess 10 piece of the list per frame
while (x<10):
item = own['LODList'][own['index']]
V= own.getVectTo(item)
Distance = V[0]
##print(str(own['index'])+" Distance is "+str(Distance))
## set LOD if the unit is less then 100 units
if Distance<100:
## get angle offset from player axis if its a light
if 'Light' in item:
Ang = own.worldOrientation.col[2]-V[1]
Ang = Ang.magnitude
print(str(Ang))
if Distance > item['2']:
if item['LOD']!=3:
item.replaceMesh(item['Mesh3'],1,0)
item['LOD']=3
if Distance > item['1'] and Distance <= item['2']:
if item['LOD']!=2:
item.replaceMesh(item['Mesh2'],1,0)
item['LOD']=2
if Distance < item['1']:
if item['LOD']!=1:
item.replaceMesh(item['Mesh1'],1,0)
item['LOD']=1
else:
if item['LOD']!=4:
item.replaceMesh('Empty',1,0)
item['LOD']=4
own['index']+=1
if own['index']==s:
x=25
if own['index']>own['Len']:
own['index']=0
x+=1
main()
Attachments
LOD4GeoP2.blend (1.57 MB)