gametechmods

Robot Arena => Modifications => Topic started by: Serge on January 24, 2010, 04:25:14 PM

Title: Serge's random modding utilities
Post by: Serge on January 24, 2010, 04:25:14 PM
I noticed I write a lot of little python scripts when I do some modding (RA2 or not), in order to simplify some common tasks. I'll gradually keep posting them when I come up with new ones. Let's get started:


Camera Angles Calculator
Python script. Give it coordinates to the camera body and what the camera is looking at, and it'll spit out the angles needed in the .py
Useful for creating / modding arenas.
Save as calcangles.py and double click (download Python if you haven't done so already).
Title: Re: Serge's random modding utilities
Post by: Madiaba on January 24, 2010, 04:34:06 PM
Yea, that's one of the major complaints moving from 3dsMax to RA2....
Useful snipet...
Title: Re: Serge's random modding utilities
Post by: JoeBlo on January 24, 2010, 06:30:50 PM
sounds useful, thanks Serge
Title: Re: Serge's random modding utilities
Post by: Trovaner on January 24, 2010, 08:30:22 PM
Thanks for the script. Although I had the coding in one of my arenas, I would have never thought to use it for determining the camera angles.

I'm really looking forward to seeing more of your work.
Title: Re: Serge's random modding utilities
Post by: Clickbeetle on January 27, 2010, 10:22:58 PM
Tweaking the cameras just became less of a pain.  Thanks for this.
Title: Re: Serge's random modding utilities
Post by: kill343gs on January 28, 2010, 02:12:12 PM
Pinned this topic as it will likely become a chapter in the RA2 modder's handbook.
Title: Re: Serge's random modding utilities
Post by: G.K. on February 26, 2010, 03:42:44 PM
Serge, does your compiler do reflection maps or is it only FB's that does?
Title: Re: Serge's random modding utilities
Post by: Clickbeetle on February 27, 2010, 06:32:19 PM
Only FB's does.


Oh, and Serge I used your camera angles calculator for programming the new intro in the BBEANS arena.  Mostly it works great but occasionally it will return angles that are rotated 90 or 180 degrees.  Not hard to get the correct angles if it does that, but something to consider.  I haven't noticed any pattern to it.  Maybe something to do with the fact that it's on an animated camera?
Title: Re: Serge's random modding utilities
Post by: zekillengha on September 25, 2011, 05:39:10 AM
awesome :D
Title: Re: Serge's random modding utilities
Post by: kill343gs on September 25, 2011, 10:38:49 AM
inb4 everyone jumps on him for bumping.
Title: Re: Serge's random modding utilities
Post by: Naryar on September 25, 2011, 05:48:21 PM
inb4 everyone jumps on him for bumping.

Now that you did called it, no one will :P And the bumpfags fear you so much that they would not dare do this in a Kill-watched thread.

...Well manipulated, dear sir. My villain hat goes to you.

I thought it was a new thread, and found it interesting anyways.

Oh, and inb4 our discussion confuses him and he asks what the heck is bumping.
Title: Re: Serge's random modding utilities
Post by: System32 on September 25, 2011, 06:02:02 PM
awesome :D
OMFG STOP BUNPING
Copy the link and make a new thread.
Title: Re: Serge's random modding utilities
Post by: Naryar on September 25, 2011, 06:06:43 PM
awesome :D
OMFG STOP BUNPING
Copy 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 !
Title: Re: Serge's random modding utilities
Post by: System32 on September 26, 2011, 12:43:06 PM
awesome :D
OMFG STOP BUNPING
Copy 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 !
no u
Title: Re: Serge's random modding utilities
Post by: Serge on September 05, 2016, 06:29:44 PM
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!
Title: Re: Serge's random modding utilities
Post by: R01 on September 06, 2016, 03:08:32 PM
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:
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!
I've seen some of it in the discord and only have one thing to say about it:
OMG YES!
Seriously, this is amazing and having a blender im/exporter(so we have full compatibility of getting the parts back and easily creating new ones without paying for that expensive 3ds max license would be a dream come true(also pyra2 seems to be really outdated and barely working, you might remember the thread I made about it), thanks for doing this so much and once the exporters get into alpha, I'd love to test them out and later create a full RA2 mod that uses only new created parts.