#camera angles calculator#blablah copyright 2010 sergebimport mathimport osprint "Warning! This program uses 3dsmax coordinates.\nSwap Y with Z if you use .py coordinates."cx = input("Camera X: ")cy = input("Camera Y: ")cz = input("Camera Z: ")tx = input("Target X: ")ty = input("Target Y: ")tz = input("Target Z: ")dx = (cx - tx)dy = (cy - ty)dz = (cz - tz)dxy = math.sqrt(dx**2 + dy**2)if dy == 0: # target --<--<-- camera (x+ ->) if dx > 0: yaw = math.pi / -2 # camera -->-->-- target (x+ ->) else: yaw = math.pi / 2elif dx == 0: # camera # | (y+ ^) # V # target if dy > 0: yaw = 0 # target # ^ (y+ ^) # | # camera else: yaw = math.pi * 2else: yaw = math.atan(dx/dy)pitch = math.atan(dz/dxy)print "camera angles tuple:"print "(", pitch, ",", yaw, ")"os.system("pause")
For once the mods did something right
inb4 everyone jumps on him for bumping.
awesome :D
Quote from: zekillengha on September 25, 2011, 05:39:10 AMawesome :DOMFG STOP BUNPINGCopy the link and make a new thread.
Quote from: System32 on September 25, 2011, 06:02:02 PMQuote from: zekillengha on September 25, 2011, 05:39:10 AMawesome :DOMFG STOP BUNPINGCopy the link and make a new thread.Hahaha you did it wrong, you wrote "buNping" rather than "bumping" so Kill's statement still counts - nobody criticized him for bumping !
class Material(_NodeType): TYPE_NAME = 'MATERIAL' TYPE_ID = 0x08 ref_no = _FieldInt('MATERIAL_REF_NO') name = _FieldString('MATERIAL_NAME') cls = _FieldString('MATERIAL_CLASS') ambient = _FieldInt('MATERIAL_AMBIENT', asciirepr='hex') diffuse = _FieldInt('MATERIAL_DIFFUSE', asciirepr='hex') specular = _FieldInt('MATERIAL_SPECULAR', asciirepr='hex') shine = _FieldFloat('MATERIAL_SHINE') shinestrength = _FieldFloat('MATERIAL_SHINESTRENGTH') transparency = _FieldFloat('MATERIAL_TRANSPARENCY') wiresize = _FieldFloat('MATERIAL_WIRESIZE') shading = _FieldInt('MATERIAL_SHADING') xp_fallof = _FieldFloat('MATERIAL_XP_FALLOFF') selfillum = _FieldFloat('MATERIAL_SELFILLUM') fallof = _FieldInt('MATERIAL_FALLOF') xp_type = _FieldInt('MATERIAL_XP_TYPE') texture_list = _FieldSubnode('TEXTURE_LIST', TextureList, optional=True) material_list = _FieldSubnode('MATERIAL_LIST', MaterialList, optional=True)
with open('/home/q3k/Games/RA2/Robot Arena 2 v1.4/Components/cannon/cannon.gmf', 'rb') as f: g = GMI() g.from_binary(f) print('Scene information:') print(g.scene) print('Materials:') for material in g.material_list.materials: print("-> " + str(material)) if material.texture_list: print(" Has textures:") for texture in material.texture_list.textures: print(" -> " + str(texture)) else: print(" No textures.") if material.material_list: print(" Has submaterials:") for submaterial in material.material_list.materials: print(" -> " + str(submaterial)) else: print(" No submaterials.")
q3k@anathema ~/Projects/pyra25/pyra25 $ python gmf.py Scene information:<pyra25.SCENE: SCENE_FILENAME=cannonMapped.max, SCENE_FIRSTFRAME=0, SCENE_LASTFRAME=100...>Materials:-> <pyra25.MATERIAL: MATERIAL_REF_NO=0, MATERIAL_NAME=11 - Default, MATERIAL_CLASS=Standard...> No textures. No submaterials.-> <pyra25.MATERIAL: MATERIAL_REF_NO=1, MATERIAL_NAME=6 - Default, MATERIAL_CLASS=Standard...> Has textures: -> <pyra25.TEXTURE: MAP_NAME=Map #10, MAP_CLASS=Bitmap, BITMAP=cannon.tga...> No submaterials.-> <pyra25.MATERIAL: MATERIAL_REF_NO=2, MATERIAL_NAME=5 - Default, MATERIAL_CLASS=Standard...> Has textures: -> <pyra25.TEXTURE: MAP_NAME=Map #9, MAP_CLASS=Bitmap, BITMAP=cannonball.tga...> No submaterials.
Started working on what I for now call `pyra25`. It's basically what pyra2 was, but sprinkled with not-invented-here syndrome and Python 3 compatibility. Hopefully it could be used for wonderful things like bot exchanges or Blender exporters. It's what GMFClass (remember that? :P) would have been if I knew what I was doing 8 years ago.I'm at the point where I'm experimenting with what kind of API I want to see, and I'm implementing a basic GMF parser. Definition of a GMI node type currently looks as follows: Code: [Select]class Material(_NodeType): TYPE_NAME = 'MATERIAL' TYPE_ID = 0x08 ref_no = _FieldInt('MATERIAL_REF_NO') name = _FieldString('MATERIAL_NAME') cls = _FieldString('MATERIAL_CLASS') ambient = _FieldInt('MATERIAL_AMBIENT', asciirepr='hex') diffuse = _FieldInt('MATERIAL_DIFFUSE', asciirepr='hex') specular = _FieldInt('MATERIAL_SPECULAR', asciirepr='hex') shine = _FieldFloat('MATERIAL_SHINE') shinestrength = _FieldFloat('MATERIAL_SHINESTRENGTH') transparency = _FieldFloat('MATERIAL_TRANSPARENCY') wiresize = _FieldFloat('MATERIAL_WIRESIZE') shading = _FieldInt('MATERIAL_SHADING') xp_fallof = _FieldFloat('MATERIAL_XP_FALLOFF') selfillum = _FieldFloat('MATERIAL_SELFILLUM') fallof = _FieldInt('MATERIAL_FALLOF') xp_type = _FieldInt('MATERIAL_XP_TYPE') texture_list = _FieldSubnode('TEXTURE_LIST', TextureList, optional=True) material_list = _FieldSubnode('MATERIAL_LIST', MaterialList, optional=True)And the API for loading a binary GMF and iterating over some materials looks like this:Code: [Select]with open('/home/q3k/Games/RA2/Robot Arena 2 v1.4/Components/cannon/cannon.gmf', 'rb') as f: g = GMI() g.from_binary(f) print('Scene information:') print(g.scene) print('Materials:') for material in g.material_list.materials: print("-> " + str(material)) if material.texture_list: print(" Has textures:") for texture in material.texture_list.textures: print(" -> " + str(texture)) else: print(" No textures.") if material.material_list: print(" Has submaterials:") for submaterial in material.material_list.materials: print(" -> " + str(submaterial)) else: print(" No submaterials.")That would display:Code: [Select]q3k@anathema ~/Projects/pyra25/pyra25 $ python gmf.py Scene information:<pyra25.SCENE: SCENE_FILENAME=cannonMapped.max, SCENE_FIRSTFRAME=0, SCENE_LASTFRAME=100...>Materials:-> <pyra25.MATERIAL: MATERIAL_REF_NO=0, MATERIAL_NAME=11 - Default, MATERIAL_CLASS=Standard...> No textures. No submaterials.-> <pyra25.MATERIAL: MATERIAL_REF_NO=1, MATERIAL_NAME=6 - Default, MATERIAL_CLASS=Standard...> Has textures: -> <pyra25.TEXTURE: MAP_NAME=Map #10, MAP_CLASS=Bitmap, BITMAP=cannon.tga...> No submaterials.-> <pyra25.MATERIAL: MATERIAL_REF_NO=2, MATERIAL_NAME=5 - Default, MATERIAL_CLASS=Standard...> Has textures: -> <pyra25.TEXTURE: MAP_NAME=Map #9, MAP_CLASS=Bitmap, BITMAP=cannonball.tga...> No submaterials.No idea when this will be done. I'm at the boring part where I'm going over all node types and implementing them. Nice part is that once this is done, we can hopefully autogenerate some pretty concise documentation on the GMF/GMA file format!