Latest Posts

Changes in AboutColors

Editor Comment

Updated.


Revision Differences of Revision 4

## Colors ¶

### Introduction ¶

This document describes the principle of player colors. ¶


### What are player colors (playercolor)? ¶

Imagine a game with 3 players. Each player has it's unique color (like blue, red and green). It would be terribly difficult if the units would look all the same. Imagine a fight between two soldiers; one soldier is owned by the green player, one by the red, but both soldiers look the same. So each unit (and building) should have a player color. ¶

Now, it would be very hard to draw each unit with each player color; therefore Widelands takes a different approach: each unit is drawn (usually in Blender) using a single "Player Color" material of a light neutral hue (like white) assigned to certain objects or vertex groups on the unit. When the unit's pic or animation frames are rendered, a python script is available to simultaneously generate a mask for each rendered frame to identify the playercolor areas or objects within the frame. The mask image file has the same name as the image file but with "_pc" at the end of its name. (Example: the Player Color mask file for idle_00.png would be named idle_00_pc.png) When Widelands draws now a unit for a specific player, it will replace the masked area(s) in the image(s) with the correct color for the player. ¶

### So Whow does it work? ¶

This depends o
n what you want to do: an animation/pic with its own config file or onmes without. ¶
Examples
for animations abund graphics with config-file are workers, bobs, critters, buildings.... ¶
Exam
ples for animationsg without config-files arend flags, frontiers... ¶
For a
bunimations/pics with outf a _pco.pnfig file the "playercolor" variable is Wincludelands with a vallue of "true" in the section(s) where the guraphic files for the unit are identified wiuth oma "ptics" or "dirpics" variablley in its pharent config file (the world/conf or tribe/conf file). ¶
Otherwi
se you have to plook at thyer conf file fors. If the animation/pic (or create one based on a similar file from another animation/_pic). Fipnd theg vafilid section(s), (liket ~np~[idle],[walk]~/np~s and so on). Thsumere you'll find (or thave to add) the following command: ¶

pl
imayercolor=true ¶

Th
is will sigonal theas presence of player color mask files and Widelands will draw the unit with appropriate colors. ¶