def addChunkModel( self ): #If we are adding a model file, then simply #add the resource name to the chunk at the locator. bp = self.objInfo.getBrowsePath() if len(bp)>6 and bp[-6:] == ".model": d = ResMgr.DataSection( "model" ) d.writeString( "resource", bp ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 ) if ( group != None ): self.chunkItemAdded( d.name ); if len(bp)>4 and bp[-4:] == ".spt": d = ResMgr.DataSection( "speedtree" ) d.writeString( "spt", bp ) d.writeInt( "seed", 1 ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 ) if ( group != None ): self.chunkItemAdded( d.name ); # if it's a .xml file in the particles directory, add a ChunkParticles chunk item if bp.find("particles/") != -1 and (len(bp)>4 and bp[-4:] == ".xml"): d = ResMgr.DataSection( "particles" ) d.writeString( "resource", bp ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator, 2 ) if ( group != None ): self.chunkItemAdded( d.name ); #XML files represent completely generic additions to the chunk, #and so all the information must be deep-copied and added #to the chunk. elif len(bp)>4 and bp[-4:] == ".xml": s = ResMgr.openSection( bp ).values()[0] if ( s != None ): d = ResMgr.DataSection( s.name ) deepCopy( d, s ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator ) if ( group != None ): self.chunkItemAdded( d.name ); # If it's a .py file, add an entity with the same name elif len(bp)>3 and bp[-3:] == ".py": d = ResMgr.DataSection( "entity" ) d.writeString( "type", bp[ bp.rfind("/")+1 : -3 ] ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator ) if ( group != None ): self.chunkItemAdded( d.name ); # If it's a .def file, add an entity with the same name elif len(bp)>4 and bp[-4:] == ".def": if bp.find("user_data_object") == -1: d = ResMgr.DataSection( "entity" ) d.writeString( "type", bp[ bp.rfind("/")+1 : -4 ] ) else: d = ResMgr.DataSection( "UserDataObject" ) d.writeString( "type", bp[ bp.rfind("/")+1 : -4 ] ) group = WorldEditor.createChunkItem( d, self.mouseLocator.subLocator ) if ( group != None ): self.chunkItemAdded( d.name );