Class | CWrp::File8WVR
In: | ../lib/roller/CWRP.rb
Parent: | Object

A file contining island information. It can be read from an OFP (4WVR) or ArmA (8WVR) formatted WRP file. It can be exported to WRP (8WVR only), XYZ or object template files.

### Methods

apply_bumpiness export_satellite_mask height_at increment_progress info init_gui is_arma? map_size new object_names raise_sea_level random_sector_position read_wrp replace_forests replace_objects replace_textures reset_progress resize_terrain_grid rotate set_edge_height terrain_cell_size terrain_grid_size texture_grid_size unused_texture_indexes write_object_template write_wrp write_xyz

### Included Modules

BinaryIO

### Constants

FOREST_BLOCK_OBJECT_WIDTH | = | 50.0 |  | Width of a forest block object in metres.
ARMA_MAGIC | = | "8WVR"
OFP_MAGIC | = | "4WVR"
OFP_CELL_SIZE | = | 50.0 |  | 50m texture and terrain cell sizes are assumed in OFP.
OFP_NUM_TEXTURES | = | 512 |  | Total number of textures in every OFP map.
OFP_TO_ARMA_HEIGHT_FACTOR | = | 0.045 |  | OFP file heights are integers and much larger than they should be so scale them down appropriately.
FOREST_CELL_WIDTH | = | 32 |  | Size of cells when calculating satellite mask forested areas.
LEGAL_GRID_SIZES | = | [16, 32, 64, 128, 256, 512, 1024, 2048, 4096] |  | ArmA only supports certain grid sizes, from 16x16 to 4096x4096.
OBJECTS_PER_PROGRESS | = | 100 |  | Number of objects to wait before applying a progress increment.

### Public Class methods

new(stream, show_progress)

Loads 4WVR or 8WVR format WRP file.

`stream`: | input stream
`show_progress`: | True to use a gui to show progress.

### Public Instance methods

apply_bumpiness(bumpiness)

Applies bumpiness factor across the whole height-map.

`bumpiness`: | Maximum deviation of each new point from standard.

TODO: Use a better algorithm for generating noise.

export_satellite_mask(filename, cell_width, config)

`filename`: | File to export
`cell_width`: | Width of mask pixels in metres.
`config`: | YAML config to base mask on.

height_at(x, y)

Gives the height, in metres, at a given x/y position. If between grid points, an interpolated value will be given.

x: | x position in m
y: | y position in m

info()

Dump of information about the map.

is_arma?()
map_size()

Width and height of the map in metres.

object_names()

List of unique object names.

raise_sea_level(amount)

Raise sea level by an amount.

`amount`: | Amount by which to raise sea level

replace_forests(replacements)

Replace OFP forest block objects with individual trees and bushes.

replacements: | Hash of name-to-replace => replacement data

returns: [Number of forest replaced, number of new objects created]

replace_objects(replacements)

Globally replace objects with new object p3ds and model-based offsets.

replace_textures(replacements)

replacements is a hash where the key is the name of names to replace and the value is an array of names to replace it with (will pick a random one if the array has more than one element).

replacements: | Hash of texture-to-replace => array of replacement textures

resize_terrain_grid(cell_size)

Decreases the terrain cell size, thus increasing the number of grid points.

`cell_size`: | The new size of terrain cells. This must be an positive integer divisor of the current cell size.

set_edge_height(height)

Set the height along all four edges to a specific value.

`height`: | New height along edges.

terrain_cell_size()

Size of a terrain cell in metres.

terrain_grid_size()

Number of terrain grid points across the map.

texture_grid_size()

Number of texture grid points across the map.

unused_texture_indexes()

List of those texture indexes that are actually never referenced. Returns an array of indexes that are never referenced (not counting index 0 which is never used)

write_object_template(stream)

Writes an object template file using the format, "p3d-filename";x;y;z;angle; "ace_island_objects\m\bush\ace_dd_bush01";4830;9682;0;161.015;

stream: | output stream

write_wrp(stream)

Only write in 8WVR format

stream: | output stream

write_xyz(stream)

Writes an XYZ file, using the format

           x         y         z
         0.0    2940.0    -48.13

stream: | output stream

### Protected Instance methods

increment_progress()

Moves progress bar along by a single step.

init_gui()

Initialise the GUI application.

random_sector_position(sectors)

Find an appropriate random position within N, E, W, S sectors.

      ______
     |\ N  /|
     | \  / |
     |W \/ E|
     |  /\  |
     | /  \ |
     |/_S__\|

sectors: | Array of sectors that are acceptable for the position.

read_wrp(stream)

stream: | input stream

reset_progress(title, total)

Resets progress bar ready for another item.

`title`: | Title for the progress bar.
`total`: | Total value to count to in the progress meter.

rotate(x, y, by)

x: | X position
y: | Y position
by: | Number of degrees to rotate the position by.

[Validate]