The Faces module
The faces module is used for creating face images for comms screens.
Faces are based off of a set of image textures with a grid of cell images.
The set of images is defined in allFaceFiles.txt. This file defines a key name for the texture and an image in the data\graphics folder. Cells are 512x512 and the total images must be a valid DirectX12 pixel size.
This set of images can be extended with new textures added to allFacesFiles.txt
Face generation functions
The faces module has a set of functions to generate random faces for the base set of face image textures provided by Artemis Cosmos.
=== "python"
self.face_desc = random_skaraan()
There are also function to make it easier to create specific faces by passing indexes to define indexes that represent cells containing know art images for things like hair, eyes, mouth etc.
It may take some experimentation to find the values for your character, but this is a simplified way to create repeatable characters.
Other ways to create consistent faces is to use one of the predefined class:
~sbs_utils.faces.Characters or hand code a face string.
self.face_desc = skaraan(0, 1,2,1,3)
Character Faces
The class class:
~sbs_utils.faces.Characters has a list of predefined face strings.
These are a good examples for creating a face string by hand.
The faces string syntax
Face string is a set of layers that reference a cell in a texture separated by a semi-colon. The first layer is the lowest layer.
the texture tag specified in allFaceFiles.txt a Tint to add to the layer. e.g. changing skin tone the cell's col the cell's row
optional to offset the layer in x optional to offset the layer in y
API: faces module
Characters
A set of predefined faces
arvonian(face_id, eye_id, mouth_id, crown_id, collar_id)
Create an arvonian face
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int
|
The index of the face 0 |
required |
eye_id
|
int
|
The index of the eyes 0-4 |
required |
mouth_id
|
int
|
The index of the mouth 0-4 |
required |
crown_id
|
int | None
|
The index of the crown 0-4 or None |
required |
collar_id
|
int | None
|
The index of the collar 0-4 or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
clear_face(ship_id)
Removes a face string for a specified ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_id
|
Agent | int
|
The id of the ship/object |
required |
get_face(ship_id)
Returns a face string for a specified ID
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_id
|
Agent | int
|
The id of the ship/object |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
A Face string |
get_face_from_data(race)
Deprecated in v1.1.0.
Use random_race instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
race
|
_type_
|
description |
required |
Returns:
| Name | Type | Description |
|---|---|---|
_type_ |
description |
kralien(face_id, eye_id, mouth_id, scalp_id, extra_id)
Create an kralien face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int
|
The index of the face 0 |
required |
eye_id
|
int
|
The index of the eyes 0-4 |
required |
mouth_id
|
int
|
The index of the mouth 0-4 |
required |
scalp_id
|
int | None
|
The index of the scalp 0-4 or None |
required |
extra_id
|
int | None
|
The index of the extra 0-4 or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
probably(chance)
Will compare a float with a random float between 0 and 1. If the provided number is larger than the random number, will return True. Args: chance (float): A float between 0 and 1.
random_arvonian()
Create a random arvonian face.
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_face(race=None)
Returns a random face for the specified race.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
race
|
str
|
The Race Terran, Torgoth etc. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
The Face String |
random_kralien()
Create a random kralien face.
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_skaraan()
Create a random skaraan face.
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_terran(face=None, civilian=None)
Create a random terran face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face
|
int | None
|
The index of the hair 0=male,1=female,2=fluid male, 3=fluid female or None= random |
None
|
civilian
|
boolean | None
|
The force this to be a civilian=True, For non-civilian=False or None= random |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_terran_female(civilian=None)
Create a random terran female face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
civilian
|
boolean
|
The force this to be a civilian=True, For non-civilian=False or None= random. Default is None. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_terran_fluid(civilian=None)
Create a random fluid terran face i.e. may have male or female features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
civilian
|
boolean
|
The force this to be a civilian=True, For non-civilian=False or None= random. Default is None. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_terran_male(civilian=None)
Create a random terran male face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
civilian
|
boolean
|
The force this to be a civilian=True, For non-civilian=False, or None= random. Default is None. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_torgoth()
Create a random torgoth face.
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
random_ximni()
Create a random ximni face.
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
set_face(ship_id, face)
Sets a face string for a specified ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ship_id
|
Agent | int
|
The id of the ship/object |
required |
face
|
str
|
A Face string |
required |
skaraan(face_id, eye_id, mouth_id, horn_id, hat_id)
Create a skaraan face
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int
|
The index of the face 0 |
required |
eye_id
|
int
|
The index of the eyes 0-4 |
required |
mouth_id
|
int
|
The index of the mouth 0-4 |
required |
horn_id
|
int | None
|
The index of the horn 0-4 or None |
required |
hat_id
|
int | None
|
The index of the hat 0-4 or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
terran(face_id, eye_id, mouth_id, hair_id, longhair_id, facial_id, extra_id, uniform_id, skintone, hairtone)
Create a terran face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int | None
|
The index of the face 0=male, 1=female, 2=fluid_male, 3=fluid_female |
required |
eye_id
|
int | None
|
The index of the eyes 0-9 |
required |
mouth_id
|
int
|
The index of the mouth 0-9 |
required |
hair_id
|
int | None
|
The index of the hair 0-9 or None |
required |
longhair_id
|
int | None
|
The index of the hair 0-7 or None |
required |
facial_id
|
int | None
|
The index of the hair 0-11 or None |
required |
extra_id
|
int | None
|
The index of the extra 0-5 or None |
required |
uniform_id
|
int | None
|
The index of the uniform 0 or None. None = civilian |
required |
skintone
|
int | str | None
|
The index of the skintone 0-??, string = color string or None. |
required |
hairtone
|
int | str | None
|
The index of the skintone 0-??, string = color string or None. |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
torgoth(face_id, eye_id, mouth_id, hair_id, extra_id, hat_id)
Create a torgoth face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int
|
The index of the face 0 |
required |
eye_id
|
int
|
The index of the eyes 0-4 |
required |
mouth_id
|
int
|
The index of the mouth 0-4 |
required |
hair_id
|
int | None
|
The index of the hair 0-4 or None |
required |
extra_id
|
int | None
|
The index of the extra 0-4 or None |
required |
hat_id
|
int | None
|
The index of the hat 0 or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |
ximni(face_id, eye_id, mouth_id, horns_id, mask_id, collar_id)
Create an ximni face
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
face_id
|
int
|
The index of the face 0 |
required |
eye_id
|
int
|
The index of the eyes 0-4 |
required |
mouth_id
|
int
|
The index of the mouth 0-4 |
required |
horns_id
|
int | None
|
The index of the horns 0-4 or None |
required |
mask_id
|
int | None
|
The index of the mask 0-4 or None |
required |
collar_id
|
int | None
|
The index of the collar 0 or None |
required |
Returns:
| Type | Description |
|---|---|
str
|
A Face string |