home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 5080 / tutorial.7z / template_script.py < prev    next >
Encoding:
Python Source  |  2012-02-17  |  1.3 KB  |  48 lines

  1. '''rapi model template'''
  2.  
  3. from inc_noesis import *
  4. import noesis
  5. import rapi
  6.  
  7. def registerNoesisTypes():
  8.     '''Register the plugin. Just change the Game name and extension.'''
  9.     
  10.     handle = noesis.register("Game", ".ext")
  11.     noesis.setHandlerTypeCheck(handle, noepyCheckType)
  12.     noesis.setHandlerLoadModel(handle, noepyLoadModel)
  13.     return 1
  14.  
  15. def noepyCheckType(data):
  16.     '''Verify that the format is supported by this plugin. Default yes'''
  17.     
  18.     return 1
  19.  
  20. def noepyLoadModel(data, mdlList):
  21.     '''Build the model, set materials, bones, and animations. You do not
  22.     need all of them as long as they are empty lists (they are by default)'''
  23.     
  24.     ctx = rapi.rpgCreateContext()
  25.     parser = ModelParser(data)
  26.     parser.parse_file()
  27.     mdl = rapi.rpgConstructModel()
  28.     mdl.setModelMaterials(NoeModelMaterials(parser.texList, parser.matList))
  29.     mdl.setBones(parser.boneList)
  30.     mdl.setAnims(parser.animList)
  31.     mdlList.append(mdl)
  32.     return 1
  33.  
  34. class ModelParser(object):
  35.     
  36.     def __init__(self, data):    
  37.         '''Initialize some data'''
  38.         
  39.         self.inFile = NoeBitStream(data)
  40.         self.animList = []
  41.         self.texList = []
  42.         self.matList = []
  43.         self.boneList = []
  44.         
  45.     def parse_file(self):
  46.         '''Main parser method'''
  47.         
  48.         pass