Author Topic: Pathfinding. And Other Stuff  (Read 3339 times)

MoLAoS

  • Ornithopter
  • *****
  • Posts: 433
    • View Profile
Pathfinding. And Other Stuff
« on: 21 July 2012, 18:51:40 »
...
« Last Edit: 26 July 2012, 00:11:20 by MoLAoS »

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Pathfinding. And Other Stuff
« Reply #1 on: 21 July 2012, 19:52:00 »
As far as swapping different weapons and such, the way 0 A.D. does this is to make each unit a collection of collada models, and uses bones as attachment points.  So for example, here's the XML file for the basic Iberian swordsman:
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<actor version="1">
  <castshadow/>
  <group>
    <variant frequency="1" name="Base">
      <animations>
        <animation file="biped/inf_sword_ready_a.dae" name="Idle" speed="105"/>
        <animation file="biped/inf_sword_ready_a.dae" name="Idle" speed="90"/>
        <animation file="biped/inf_sword_ready_b.dae" name="Idle" speed="95"/>
        <animation event="0.5" file="infantry/sword/attack/isw_s_off_03.psa" name="melee" speed="150"/>
        <animation event="0.5" file="infantry/sword/attack/isw_s_off_05.psa" name="melee" speed="150"/>
        <animation file="biped/walk_spearshield.psa" name="Walk" speed="120"/>
        <animation file="infantry/sword/move/run/isw_s_off_01.psa" name="Run" speed="20"/>
        <animation file="infantry/sword/move/run/isw_s_def_02.psa" name="Run" speed="30"/>
        <animation file="infantry/sword/move/run/isw_s_em_03.psa" name="Run" speed="30"/>
        <animation file="biped/walk_spearshield.psa" name="carry_food" speed="120"/>
        <animation file="biped/walk_spearshield.psa" name="carry_meat" speed="120"/>
        <animation file="biped/walk_spearshield.psa" name="carry_wood" speed="120"/>
        <animation file="biped/walk_spearshield.psa" name="carry_stone" speed="120"/>
        <animation file="biped/walk_spearshield.psa" name="carry_metal" speed="120"/>
        <animation event="0.23" file="infantry/general/chop.psa" name="gather_tree" speed="250"/>
        <animation file="biped/hoe.psa" name="gather_grain" speed="300"/>
        <animation file="infantry/general/forage.psa" name="gather_fruit" speed="110"/>
        <animation file="infantry/general/forage.psa" name="gather_meat" speed="110"/>
        <animation event="0.43" file="infantry/general/mine.psa" name="gather_rock" speed="250"/>
        <animation event="0.43" file="infantry/general/mine.psa" name="gather_ore" speed="250"/>
        <animation event="0.43" file="infantry/general/mine.psa" name="gather_ruins" speed="250"/>
        <animation event="0.6" file="infantry/general/dude/dudebuild.psa" name="Build" speed="220"/>
        <animation file="infantry/general/death/inf_01.psa" name="Death" speed="400"/>
        <animation file="infantry/general/death/inf_02.psa" name="Death" speed="700"/>
        <animation file="infantry/general/death/inf_03.psa" name="Death" speed="500"/>
        <animation file="infantry/general/death/inf_04.psa" name="Death" speed="400"/>
        <animation file="infantry/general/death/inf_06.psa" name="Death" speed="500"/>
        <animation file="infantry/general/death/inf_07.psa" name="Death" speed="400"/>
        <animation file="biped/inf_salute_c.psa" name="Promotion" speed="288"/>
      </animations>
      <mesh>skeletal/m_tunic_short.dae</mesh>
      <props>
        <prop actor="props/units/heads/head_iber_basic.xml" attachpoint="head"/>
        <prop actor="props/units/shields/iberian_buckler_basic.xml" attachpoint="shield"/>
        <prop actor="props/units/weapons/falcata.xml" attachpoint="r_hand"/>
      </props>
    </variant>
  </group>
  <group>
    <variant frequency="1" name="tunic-gold">
      <texture>skeletal/iber_isw_b_1.dds</texture>
    </variant>
    <variant frequency="1" name="tunic-brown">
      <texture>skeletal/iber_isw_b_2.dds</texture>
    </variant>
    <variant frequency="2" name="tunic-beige">
      <texture>skeletal/iber_isw_b_3.dds</texture>
    </variant>
  </group>
  <group>
    <variant frequency="1" name="Idle"/>
    <variant name="Melee">
      <props>
        <prop actor="props/units/weapons/falcata.xml" attachpoint="r_hand"/>
      </props>
    </variant>
    <variant name="gather_tree">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop actor="props/units/tools/axe.xml" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_grain">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop actor="props/units/tools/hoe.xml" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_fruit">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop attachpoint="l_hand"/>
        <prop actor="props/units/tools/basket.xml" attachpoint="l_leg"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_meat">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop attachpoint="l_hand"/>
        <prop actor="props/units/tools/basket.xml" attachpoint="l_leg"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_rock">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop actor="props/units/tools/pick.xml" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_ore">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop actor="props/units/tools/pick.xml" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="gather_ruins">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="r_hand"/>
        <prop actor="props/units/tools/pick.xml" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="Build">
      <props>
        <prop attachpoint="shield"/>
        <prop attachpoint="l_hand"/>
        <prop actor="props/units/tools/mallet.xml" attachpoint="r_hand"/>
        <prop attachpoint="helmet"/>
      </props>
    </variant>
    <variant name="carry_food">
      <props>
        <prop actor="props/units/shuttle_basket.xml" attachpoint="r_hand"/>
        <prop attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
        <prop attachpoint="shield"/>
      </props>
    </variant>
    <variant name="carry_meat">
      <props>
        <prop actor="props/units/shuttle_meat.xml" attachpoint="r_hand"/>
        <prop attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
        <prop attachpoint="shield"/>
      </props>
    </variant>
    <variant name="carry_wood">
      <props>
        <prop actor="props/units/shuttle_wood.xml" attachpoint="r_hand"/>
        <prop actor="" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
        <prop attachpoint="shield"/>
      </props>
    </variant>
    <variant name="carry_stone">
      <props>
        <prop actor="props/units/shuttle_stone.xml" attachpoint="r_hand"/>
        <prop actor="" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
        <prop attachpoint="shield"/>
      </props>
    </variant>
    <variant name="carry_metal">
      <props>
        <prop actor="props/units/shuttle_metal.xml" attachpoint="r_hand"/>
        <prop actor="" attachpoint="l_hand"/>
        <prop attachpoint="helmet"/>
        <prop attachpoint="shield"/>
      </props>
    </variant>
  </group>
  <material>player_trans.xml</material>
</actor>

You can see it specifies a mesh for the torso, the head, the sword, the shield, etc., and then several animations, all saved as collada files.  Additionally, when using a uniform armature, the animations can be applied to multiple units, so an Iberian spearman and a Persian one might use the same animations.

Now, regarding pathfinding, that's something I know nothing about, so here's a thread link: https://forum.megaglest.org/index.php?topic=4618

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Pathfinding. And Other Stuff
« Reply #2 on: 21 July 2012, 23:09:27 »
Yeah I actually read through their forums to see how they were doing it since it seemed like the premier open source RTS since Glest isn't really developed anymore. I am going to do something similar, though I would like to try and do some things better.

How much do you know about what they did? I was thinking of just restarting from their code base because they spent a lot more work on it and it seems more powerful. They have superior modeling, they have a wall system in place, and a lot of other stuff. Although I like to deal with the abstract math of graphics and pathfinding and such I really only like the programming of game logic.
Just from talking to some of the devs about modding capabilities on IRC, it sounds like 0 A.D.'s engine is indeed much more powerful, and a ton of things can be done through javascript without having to actually touch the engine.  I've even been toying with the idea of porting my borderline-vaporware Solunar mod from GAE to Pyrogenesis because of that and the more active development, which is what got me talking to the devs in the first place.

They don't have walkable walls, but their wall system does work pretty well in the SVN version (barring one or two little things that I'm sure they're in the process of working out), and even has working gates (finally!).  You can't have units on top of the walls, but you can garrison them inside the tower junctions, which is something at least.  As far as pathfinding goes, my understanding is that Glest is on a Cartesian (x,y,z) grid while Pyrogenesis uses polar coordinates, which is why their buildings can be rotated arbitrarily.  In Glest/GAE, wouldn't walls only be able to be bent at right angles?

On top of that, their AI is much more configurable and different AIs can be assigned to different sides in a match, whereas Glest/GAE's seems to be pretty intrinsic to the engine.

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Pathfinding. And Other Stuff
« Reply #3 on: 22 July 2012, 19:17:55 »
I do wanna talk to them about some things like maybe being allowed to use some of their code so I don't have to do it myself.
It's GPL, just like Glest.

John.d.h

  • Moderator
  • Airship
  • ********
  • Posts: 3,757
  • I have to go now. My planet needs me.
    • View Profile
Re: Pathfinding. And Other Stuff
« Reply #4 on: 22 July 2012, 21:51:04 »
I have no idea if that would work or cause the engine to explode or something like that, but it certainly is permissible, as long as you abide by the GPL (which you have to do when using the Glest engine anyway).  I don't really have any experience with using GPL-derived stuff, but I think the standard practice would be the put the attribution somewhere in the credits or licensing documentation.  For example "Some portions (c) Wildfire Games, released under GPL v 2.0+".

 

anything