Egg Octree

oh i see. thanks for the pictures, i got the idea of the octree now.

hmm i tried to do the python code (im totally new to python :laughing: ), but i need some guidance on how to use the eggoctree correctly.

correct me if im wrong (i dont think im right :laughing: )
this is how i did: i placed the class EggOctree into a python file called EggOctree.py, and then i created a new python file called OctreeBuilder, which i imported the EggOctree class (from EggOctree import EggOctree).

then i tried to run the ‘use’ code, something like this:

[size=75]

from pandac.PandaModules import *
import direct.directbase.DirectStart
from pandac.PandaModules import CollisionTraverser,CollisionNode
from pandac.PandaModules import CollisionHandlerQueue,CollisionRay
from pandac.PandaModules import Filename
from pandac.PandaModules import PandaNode,NodePath,Camera,TextNode
from pandac.PandaModules import Vec3,Vec4,BitMask32
from direct.gui.OnscreenText import OnscreenText
from direct.actor.Actor import Actor
from direct.task.Task import Task
from direct.showbase.DirectObject import DirectObject
import random, sys, os, math
import thread

from EggOctree import EggOctree

import math 

class World(DirectObject):
   def __init__(self):
      self.config()

   def config(self):
      self.np = render.attachNewNode('np')
      egg = EggData() 
      egg.read(Filename('Map_Tutorial_Level.egg'))       
      egg.getFirstChild() 
      sourceNode = egg.getNextChild() # the sourcenode must contain a VertexPool and a list of Polygons 
      if self.np != None : 
         self.np.removeNode() 
         self.np = None
      
   def mainloop(self, task):

      ed = EggData() 
      ed.setCoordinateSystem(egg.getCoordinateSystem())
      print 'Been Here'

      # Here, it's a quadtree since there will be only 1 leaf along the Y axis 
      self.octree.build(sourceNode, ed, Vec3D(3, 100, 3))


      ed.writeEgg(Filename('Map_Tutorial_Level_octree.egg')) 
      ed = None 

      self.np = loader.loadModel('Map_Tutorial_Level_octree.egg') 
      self.np.reparentTo(render) 
      return task.cont
   
w = World()
run()

[/size]

i referenced most of the stuff from roaming ralph & the octree demo, but im not sure how to apply it in python correctly, so i will need some help on this. thanks in advance :smiley: