Author Topic: Serge's random modding utilities  (Read 7125 times)

Offline Serge

  • *
  • Posts: 1530
  • Rep: 13
    • View Profile
    • http://www.q3k.org/
    • Awards
Serge's random modding utilities
« 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).
home | twitter | yt | gmf de/compiler | component freedom | xmpp: q3k@q3k.org | email: q3k@q3k.org

Offline Madiaba

Re: Serge's random modding utilities
« Reply #1 on: January 24, 2010, 04:34:06 PM »
Yea, that's one of the major complaints moving from 3dsMax to RA2....
Useful snipet...
Input is appreciated. :)
-Arrogance is a quantity devoid of quality...
-As a client once told me "This is my story, and it's sticking to me!"
-Relationships these days are like the 'Arrival' section of the airport: a lot of baggage is being revealed in one place, and not a lot of it is being correlated to its real owners...

Offline JoeBlo

Re: Serge's random modding utilities
« Reply #2 on: January 24, 2010, 06:30:50 PM »
sounds useful, thanks Serge

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #3 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.

Offline Clickbeetle

  • *
  • Posts: 3375
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
Re: Serge's random modding utilities
« Reply #4 on: January 27, 2010, 10:22:58 PM »
Tweaking the cameras just became less of a pain.  Thanks for this.

To lack feeling is to be dead, but to act on every feeling is to be a child.
-Brandon Sanderson, The Way of Kings

Offline kill343gs

Re: Serge's random modding utilities
« Reply #5 on: January 28, 2010, 02:12:12 PM »
Pinned this topic as it will likely become a chapter in the RA2 modder's handbook.


For once the mods did something right
#MakeGTMGreatAgain

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #6 on: February 26, 2010, 03:42:44 PM »
Serge, does your compiler do reflection maps or is it only FB's that does?
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline Clickbeetle

  • *
  • Posts: 3375
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
Re: Serge's random modding utilities
« Reply #7 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?

To lack feeling is to be dead, but to act on every feeling is to be a child.
-Brandon Sanderson, The Way of Kings

Offline zekillengha

  • New Member
  • Posts: 1
  • Rep: 0
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #8 on: September 25, 2011, 05:39:10 AM »
awesome :D

Offline kill343gs

Re: Serge's random modding utilities
« Reply #9 on: September 25, 2011, 10:38:49 AM »
inb4 everyone jumps on him for bumping.


For once the mods did something right
#MakeGTMGreatAgain

Offline Naryar

  • Posts: 23283
  • Rep: 21
  • hybrids oui oui
    • http://www.youtube.com/us
  • Awards BOTM Winner
    • View Profile
    • Awards
  • Skype: TheMightyNaryar
Re: Serge's random modding utilities
« Reply #10 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.

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #11 on: September 25, 2011, 06:02:02 PM »
awesome :D
OMFG STOP BUNPING
Copy the link and make a new thread.
Put this onto your signature if you were part of this crappy fad in '03.

Offline Naryar

  • Posts: 23283
  • Rep: 21
  • hybrids oui oui
    • http://www.youtube.com/us
  • Awards BOTM Winner
    • View Profile
    • Awards
  • Skype: TheMightyNaryar
Re: Serge's random modding utilities
« Reply #12 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 !

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #13 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
Put this onto your signature if you were part of this crappy fad in '03.

Offline Serge

  • *
  • Posts: 1530
  • Rep: 13
    • View Profile
    • http://www.q3k.org/
    • Awards
Re: Serge's random modding utilities
« Reply #14 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!
home | twitter | yt | gmf de/compiler | component freedom | xmpp: q3k@q3k.org | email: q3k@q3k.org

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: Serge's random modding utilities
« Reply #15 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.
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0