NURBS AutoLOD

On my way to the far goal of making a NURBS-based terrain-system I made a simple dynamic-LOD class for dinoint’s Sheet:

class AutoLOD:
    '''
    Automatic subdivision for Sheets: just add the instances to taskMgr
    '''
    def __init__(self, sheetNP, minsub, maxsub, skal):
        self.sheetNP=sheetNP
        self.maxsub=maxsub
        self.minsub=minsub
        self.sub=1
        self.skal=skal
    def __call__(self,task):
        d=self.sheetNP.getPos(base.camera).length()
        if d==0:
            sub=self.minsub
        else:
            sub= int(min(self.maxsub,self.skal/d))+self.minsub
            if sub!=self.sub:
                self.resub(sub)
        return task.cont
    def resub(self,sub):
        self.sheetNP.sheetNode.setNumUSubdiv(sub)
        self.sheetNP.sheetNode.setNumVSubdiv(sub)
        self.sub=sub
        ##self.sheetNP.recompute() not needed

there is propably quite a lot of room for improvement but it’s a beginning.

edit: last line in code was not needed…

Cool. I am fascinated by nerbs style modeling since i watched the tool demos for game called “love”.

quelsolaar.com/loq_airou/screen_shots.html