angered-ghandi / OpenAOE

An open source reimplementation of Age of Empires (1997)
Other
66 stars 6 forks source link

Data dump: Calculating world position of ramp corners #36

Closed phrohdoh closed 8 years ago

phrohdoh commented 8 years ago

Here is a thought+data dump regarding getting the world-position of the ramp corners.

let top    = cell_center_in_world_space + Vector3<i32>::new(0, -ramp_height, 0); // N
let right  = cell_center_in_world_space + Vector3<i32>::new(ramp_height, 0, 0); // E
let bottom = cell_center_in_world_space + Vector3<i32>::new(0, ramp_height, 0); // S
let left   = cell_center_in_world_space + Vector3<i32>::new(-ramp_height, 0, 0); // W

For each of those new world positions we'll need to add a vec3 with a z component for the associated corner on the particular tile.

Looking at the data we spit out from empires.dat I cannot come up with a way to create these associations automatically:

Terrain {
    id: TerrainId(0),
    enabled: true,
    name: "Grass",
    short_name: "g_gr2",
    slp_id: Some(
        SlpFileId(15001)
    ),
    sound_group_id: Some(
        SoundGroupId(95)
    ),
    colors: [
        99,
        100,
        101
    ],
    cliff_colors: [
        157,
        159
    ],
    pass_terrain_id: Some(
        TerrainId(0)
    ),
    impass_terrain_id: Some(
        TerrainId(16)
    ),
    animated: false,
    animation_frames: 0,
    pause_frames: 0,
    frame_interval: 0,
    pause_between_loops: 0,
    frame: 0,
    draw_frame: 0,
    animate_last: 0,
    frame_changed: 0,
    elevation_graphics: [
        TerrainFrameData {
        frame_count: 9,
        angle_count: 1,
        frame_id: SlpFrameId(0)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(9)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(10)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(11)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(12)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(13)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(14)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(15)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(16)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(17)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(18)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(19)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(20)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(21)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(22)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(23)
        },
        TerrainFrameData {
        frame_count: 1,
        angle_count: 1,
        frame_id: SlpFrameId(24)
        },
        TerrainFrameData {
        frame_count: 0,
        angle_count: 0,
        frame_id: SlpFrameId(25)
        },
        TerrainFrameData {
        frame_count: 0,
        angle_count: 0,
        frame_id: SlpFrameId(25)
        }
    ],
    terrain_to_draw: None,
    terrain_width: 3,
    terrain_height: 3,
    terrain_borders: [
        TerrainBorderId(0),
        TerrainBorderId(3),
        TerrainBorderId(6),
        TerrainBorderId(0),
        TerrainBorderId(3),
        TerrainBorderId(0),
        TerrainBorderId(6),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(6),
        TerrainBorderId(0),
        TerrainBorderId(6),
        TerrainBorderId(6),
        TerrainBorderId(3),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0),
        TerrainBorderId(0)
    ],
    terrain_units: [
        TerrainUnit {
        unit_id: UnitId(168),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(177),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(167),
        density: 0,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(170),
        density: 0,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(171),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(172),
        density: 0,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(173),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(174),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(175),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(176),
        density: 3,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(186),
        density: 1,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(304),
        density: 1,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(305),
        density: 1,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(306),
        density: 1,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(310),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(311),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(312),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(313),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(332),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(333),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(334),
        density: 0,
        priority: 1
        },
        TerrainUnit {
        unit_id: UnitId(134),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(136),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(140),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(141),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(144),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(146),
        density: 1,
        priority: 0
        },
        TerrainUnit {
        unit_id: UnitId(56),
        density: 1,
        priority: 0
        }
    ]
},

The first TerrainFrameData contains all of the flat frames. All of the following are ramps, some of which contain duplicate image data (so we could perhaps make a small optimization here if necessary, but that makes this more complex than necessary).

spritesheet

match frame_index {
  0..8 => flat,
     9 => N,
    10 => S,
    11 => E,
    12 => W,

    13 => NE,
    14 => SE,
    15 => NW,
    16 => SW,

    17 => N,
    18 => S,
    19 => E,
    20 => W,

    21 => N,
    22 => S,
    23 => W,
    24 => E,
}

ref #33