Hi,
I’ve been dealing with a conversion of a big egg file into octrees to optimize collision processing, and tried to use the script eggOctree.py
The issue is that if the egg file has a hierarchy of Groups and vertexPool this script doesn’t generate anything
example for such a rejected eggfile
<Group> pipo {
/* <Dart> { 1 } */
<Group> groundPlane_transform {}
<Collide> { Polyset keep descend }
<Group> Model {
<Group> Terrain1 {
<Group> Mesh1 {
<VertexPool> Mesh1Shape.verts {
.......
<Group> Mesh2 {
<VertexPool> Mesh2Shape.verts {
.......
<Group> Terrain2 {
.......
I’ve made some progress in pruning the eggfile in a hierarchical way. Here is the tentative code added to eggOctree.py
def findVertexPoolsIn(group,groupList,vertexPoolList):
for child in iterChildren(group):
if type(child) == EggGroup:
findVertexPoolsIn(child,groupList,vertexPoolList)
if type(child) == EggVertexPool:
groupList.append(group)
vertexPoolList.append(child)
def octreefy(infile,outfile):
"""
octreefy infile and write to outfile
using the buildOctree functions
"""
egg = EggData()
egg.read(Filename(infile))
eggStripTexture(egg)
# output eggdata
ed = EggData()
ed.setCoordinateSystem(egg.getCoordinateSystem())
### THIS IS BASICALLY WHERE THE MODIF OCCURS
# fill list of group and associated vertexPools
groupList = []
vertexPoolList = []
findVertexPoolsIn(egg,groupList,vertexPoolList)
# include vertexPools
for vertexPool in vertexPoolList:
ed.addChild(vertexPool)
# now for each embedded group let's octreefy
ref = 0 # will serve as a group identifier
for group in groupList:
ed.addChild(buildOctree(group,`ref`))
ref = ref + 1
# finalize: write new egg file
if listResultingEgg: eggLs(ed)
ed.writeEgg(Filename(outfile))
An output file is generated, but to be frank I don’t have a clue as to know if it is really optimized or not.
Could one of our Panda’s gurus give a quick look at it and state what is right or what is wrong.
Many thanks
Jean-Claude