Skip to content

Commit

Permalink
Improves humans.
Browse files Browse the repository at this point in the history
- Add a 'Gender' parameter in /data/humans.ini
- Body shape now depends of weight and gender (very basic Body Mass Index use)
- Up to 4 assistants instead of 1 per victim
- Victim and assistant(s) can now be any of defined human, and not only blue/red and green guys
- Documentation updated
  • Loading branch information
jmbau committed Aug 13, 2023
1 parent f0db1d5 commit 734a077
Show file tree
Hide file tree
Showing 15 changed files with 759 additions and 268 deletions.
283 changes: 214 additions & 69 deletions data/human.ini
Original file line number Diff line number Diff line change
@@ -1,69 +1,214 @@
# SAR Human Presets
#
# Introduction
# ------------
#
# Contains a list of preset human values describing height, mass, color,
# and other attributes relating to a defined preset human name.
#
#
# Notes
# -----
#
# All color values have arguments in the order of rgba.
#
# Height specifies the height of the human from toe to head in meters.
#

# First entry is always the default, it may be used whenever nothing
# in particular is requested.
PresetAdd = default
Height = 1.9
Mass = 54.0
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.00
ColorHair = 0.30 0.24 0.19 1.00
ColorTorso = 0.95 0.22 0.18 1.00
ColorHips = 0.20 0.20 0.20 1.00
ColorLegs = 0.80 0.78 0.75 1.00
ColorFeet = 0.30 0.30 0.30 1.00
ColorArms = 0.20 0.20 1.00 1.00
ColorHands = 0.847 0.615 0.447 1.00

# Diver (used for drawing at end of hoist rope).
PresetAdd = diver
Height = 1.9
Mass = 54.0
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.00
ColorHair = 0.10 0.20 0.60 1.00
ColorTorso = 0.10 0.20 0.60 1.00
ColorHips = 0.10 0.20 0.60 1.00
ColorLegs = 0.10 0.20 0.60 1.00
ColorFeet = 0.10 0.20 0.60 1.00
ColorArms = 0.10 0.20 0.60 1.00
ColorHands = 0.847 0.615 0.447 1.00

# Victim intended to be on a streatcher with one assisting human.
PresetAdd = victim_streatcher_assisted
Height = 1.9
Mass = 54.0
AssistingHumans = 1
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.00
ColorHair = 0.30 0.24 0.19 1.00
ColorTorso = 0.95 0.22 0.18 1.00
ColorHips = 0.20 0.20 0.20 1.00
ColorLegs = 0.80 0.78 0.75 1.00
ColorFeet = 0.30 0.30 0.30 1.00
ColorArms = 0.20 0.20 1.00 1.00
ColorHands = 0.847 0.615 0.447 1.00
ColorPaletteSelect = AssistingHuman
ColorFace = 0.847 0.615 0.447 1.00
ColorHair = 0.30 0.24 0.19 1.00
ColorTorso = 0.21 0.95 0.20 1.00
ColorHips = 0.70 0.70 0.70 1.00
ColorLegs = 0.70 0.70 0.70 1.00
ColorFeet = 0.30 0.30 0.30 1.00
ColorArms = 0.21 0.95 0.20 1.00
ColorHands = 0.94 0.92 0.9 1.00
# SAR Human Presets
#
# Introduction
# ------------
#
# Contains a list of preset human values describing height, mass, color,
# and other attributes relating to a defined preset human name.
#
#
# Notes
# -----
#
# All color values have arguments in the order of rgba.
#
# Height specifies the height of the human from toe to head in meters.
# Human drawing "size" is relative to height and mass. Note that drawing
# is -of course- approximative, and sometimes it needs to "cheat"
# on one parameter to obtain better drawing (example: baby_1 mass).
# If not set, default gender is male. If gender is female, a breast
# is drawn on human torso.
#

# File version number.
Version = 1 1

# First entry is always the default, it may be used whenever nothing
# in particular is requested.
PresetAdd = default
Height = 1.9
Mass = 90.0
Gender = Male
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.300 0.240 0.190 1.0
ColorTorso = 0.950 0.220 0.180 1.0
ColorHips = 0.200 0.200 0.200 1.0
ColorLegs = 0.800 0.780 0.750 1.0
ColorFeet = 0.300 0.300 0.300 1.0
ColorArms = 0.200 0.200 1.000 1.0
ColorHands = 0.847 0.615 0.447 1.0

# Diver (only for drawing at end of hoist rope).
PresetAdd = diver
# Hard-coded data:
# Height = 1.9
# Mass = 90.0
# Gender = Male
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.100 0.200 0.600 1.0
ColorTorso = 0.100 0.200 0.600 1.0
ColorHips = 0.100 0.200 0.600 1.0
ColorLegs = 0.100 0.200 0.600 1.0
ColorFeet = 0.100 0.200 0.600 1.0
ColorArms = 0.100 0.200 0.600 1.0
ColorHands = 0.847 0.615 0.447 1.0

# For backward compatibility : victim intended to be on a stretcher with
# one assisting human. Note that only color can be be modified and will be
# applied to all (1 to 4) assisting humans.
PresetAdd = victim_streatcher_assisted
Height = 1.9
Mass = 90.0
AssistingHumans = 1
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.300 0.240 0.190 1.0
ColorTorso = 0.950 0.220 0.180 1.0
ColorHips = 0.200 0.200 0.200 1.0
ColorLegs = 0.800 0.780 0.750 1.0
ColorFeet = 0.300 0.300 0.300 1.0
ColorArms = 0.200 0.200 1.000 1.0
ColorHands = 0.847 0.615 0.447 1.0
ColorPaletteSelect = AssistingHuman
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.300 0.240 0.190 1.0
ColorTorso = 0.210 0.950 0.200 1.0
ColorHips = 0.700 0.700 0.700 1.0
ColorLegs = 0.700 0.700 0.700 1.0
ColorFeet = 0.300 0.300 0.300 1.0
ColorArms = 0.210 0.950 0.200 1.0
ColorHands = 0.940 0.920 0.900 1.0

# Default assisting human.
PresetAdd = assistant_1
Height = 1.9
Mass = 90.0
Gender = Male
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.300 0.240 0.190 1.0
ColorTorso = 0.210 0.950 0.200 1.0
ColorHips = 0.700 0.700 0.700 1.0
ColorLegs = 0.700 0.700 0.700 1.0
ColorFeet = 0.300 0.300 0.300 1.0
ColorArms = 0.210 0.950 0.200 1.0
ColorHands = 0.940 0.920 0.900 1.0

# An old black man, with hairs
PresetAdd = man_1
Height = 1.75
Mass = 80.0
Gender = Male
ColorPaletteSelect = Standard
ColorFace = 0.304 0.206 0.206 1.0
ColorHair = 0.900 0.900 0.900 1.0
ColorTorso = 0.900 0.900 0.900 1.0
ColorHips = 0.950 0.220 0.180 1.0
ColorLegs = 0.950 0.220 0.180 1.0
ColorFeet = 0.100 0.100 0.100 1.0
ColorArms = 0.900 0.900 0.900 1.0
ColorHands = 0.304 0.206 0.206 1.0

# An old white man, without hairs (ColorHair alpha value set to 0.0)
PresetAdd = man_2
Height = 1.90
Mass = 90.0
Gender = Male
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.900 0.900 0.900 0.0
ColorTorso = 0.576 0.174 0.724 1.0
ColorHips = 0.194 0.369 0.723 1.0
ColorLegs = 0.194 0.369 0.723 1.0
ColorFeet = 0.315 0.157 0.157 1.0
ColorArms = 0.576 0.174 0.724 1.0
ColorHands = 0.847 0.615 0.447 1.0

# A 10 years old white girl
# Note that if gender had been defined and set to Female, girl would have breast.
PresetAdd = girl_1
Height = 1.33
Mass = 28.0
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.932 0.938 0.548 1.0
ColorTorso = 0.900 0.900 0.900 1.0
ColorHips = 0.951 0.670 0.969 1.0
ColorLegs = 0.847 0.615 0.447 1.0
ColorFeet = 0.951 0.670 0.969 1.0
ColorArms = 0.847 0.615 0.447 1.0
ColorHands = 0.847 0.615 0.447 1.0

# A 10 years old black boy
PresetAdd = boy_1
Height = 1.33
Mass = 28.0
ColorPaletteSelect = Standard
ColorFace = 0.304 0.206 0.206 1.0
ColorHair = 0.123 0.123 0.123 1.0
ColorTorso = 1.000 0.554 0.000 1.0
ColorHips = 0.194 0.369 0.723 1.0
ColorLegs = 0.194 0.369 0.723 1.0
ColorFeet = 0.900 0.900 0.900 1.0
ColorArms = 1.000 0.554 0.000 1.0
ColorHands = 0.304 0.206 0.206 1.0

# A black woman
PresetAdd = woman_1
Height = 1.70
Mass = 60.0
Gender = Female
ColorPaletteSelect = Standard
ColorFace = 0.304 0.206 0.206 1.0
ColorHair = 0.123 0.123 0.123 1.0
ColorTorso = 0.900 0.900 0.900 1.0
ColorHips = 0.900 0.900 0.900 1.0
ColorLegs = 0.900 0.900 0.900 1.0
ColorFeet = 0.950 0.220 0.180 1.0
ColorArms = 0.304 0.206 0.206 1.0
ColorHands = 0.304 0.206 0.206 1.0

# A white woman
PresetAdd = woman_2
Height = 1.65
Mass = 56.0
Gender = Female
ColorPaletteSelect = Standard
ColorFace = 0.847 0.615 0.447 1.0
ColorHair = 0.919 0.292 0.191 1.0
ColorTorso = 0.335 0.198 0.210 1.0
ColorHips = 0.335 0.198 0.210 1.0
ColorLegs = 0.847 0.615 0.447 1.0
ColorFeet = 0.335 0.198 0.210 1.0
ColorArms = 0.847 0.615 0.447 1.0
ColorHands = 0.847 0.615 0.447 1.0

# A white baby
PresetAdd = baby_1
Height = 0.50
Mass = 7.0
ColorPaletteSelect = Standard
ColorFace = 0.980 0.820 0.733 1.0
ColorHair = 0.304 0.206 0.206 1.0
ColorTorso = 0.460 0.773 0.796 1.0
ColorHips = 0.460 0.773 0.796 1.0
ColorLegs = 0.460 0.773 0.796 1.0
ColorFeet = 0.980 0.820 0.733 1.0
ColorArms = 0.460 0.773 0.796 1.0
ColorHands = 0.980 0.820 0.733 1.0

# A fat boy with a turquoise cap and yellow gloves
PresetAdd = Boy_2
Height = 1.20
Mass = 60.0
ColorPaletteSelect = Standard
ColorFace = 0.992 0.859 0.706 1.0
ColorHair = 0.294 0.710 0.749 1.0
ColorTorso = 0.843 0.125 0.250 1.0
ColorHips = 0.843 0.125 0.250 1.0
ColorLegs = 0.470 0.278 0.227 1.0
ColorFeet = 0.192 0.188 0.208 1.0
ColorArms = 0.843 0.125 0.250 1.0
ColorHands = 0.969 0.882 0.039 1.0
8 changes: 4 additions & 4 deletions docs/sar2ParmsBook/sar2ParmsDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,8 @@ __Creates a human.\
__ARGUMENTS\
__<b>type_name</b> <hr>\
__default default human. May be used whenever nothing in particular is requested.\
__victim_streatcher_assisted male victim intended to be on a stretcher with 1 assisting human. Warning: this type name is deprecated.\
__.........(other&nbsp;type&nbsp;name)......... Warning: <b>SaR II > 2.5.0 only!</b> See data/human.ini file for other preset human types.\
__.......(other&nbsp;type&nbsp;name)....... See data/human.ini file for other allowed preseted names.\
__victim_streatcher_assisted Warning: this type name is deprecated. Victim intended to be on a stretcher with 1 assisting human.\
__<b>flags</b> <hr>\
__need_rescue this human needs to be rescued (player has to take him aboard).\
__sit_up human is drawn sitting 'like on a chair', feet on the floor.\
Expand All @@ -801,7 +801,7 @@ __alert human is alert (is awake) and moves his arms to draw attention.\
__aware human is aware (knows of surroundings).\
__in_water human swims (moves his arms to float).\
__on_stretcher if this flag is specified, a stretcher is drawn below the human.\
__assisted&nbsp;&nbsp;n&nbsp;&nbsp;type_name(s) Warning: <b>SaR II > 2.5.0 only!</b> human is assisted (surrounded) by 'n' (1 to 4) humans. Number 'n' must be followed by 'n' human type names.\
__assisted&nbsp;&nbsp;n&nbsp;&nbsp;type_name(s) Warning: <b>SaR II > 2.6.0 only!</b> human is assisted (surrounded) by 'n' (1 to 4) humans. Number 'n' must be followed by 'n' human type names.\
__CONTEXT\
__mis scn\
__EXAMPLE\
Expand All @@ -811,7 +811,7 @@ __# Human position.\
__# If human 'z' position is greater than the ground / water / object which is under him, human will 'fall' until he comes into contact.\
__translate 30000.0 41020.0 0.0\
__...\
__# Warning: <b>SaR II > 2.5.0 only!</b> Human lying on a strecher, with 2 assisting humans.\
__# Warning: <b>SaR II > 2.6.0 only!</b> Human lying on a strecher, with 2 assisting humans.\
__create_human boy_1 need_rescue lying on_stretcher assisted 2 assistant_1 woman_1\
__translate 20000.0 41020.0 0.0\
__...\
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ to the fullest extent of the law."
*/
#define SAR_HUMAN_PRESET_NAME_STANDARD "standard"
#define SAR_HUMAN_PRESET_NAME_DIVER "diver"
#define SAR_HUMAN_PRESET_NAME_ASSISTING_HUMAN "assistant_1"


/*
Expand Down
41 changes: 30 additions & 11 deletions src/human.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ int SARHumanCreate(
sar_scene_struct *scene,
sar_object_struct ***object, int *total_objects,
sar_obj_flags_t human_flags,
int assisting_humans,
const char *assisting_human_preset_name[SAR_ASSISTING_HUMANS_MAX],
const char *name
);
void SARHumanSetObjectPreset(
Expand Down Expand Up @@ -177,6 +179,8 @@ int SARHumanCreate(
sar_scene_struct *scene,
sar_object_struct ***object, int *total_objects,
sar_obj_flags_t human_flags,
int assisting_humans,
const char *assisting_human_preset_name[SAR_ASSISTING_HUMANS_MAX],
const char *name
)
{
Expand Down Expand Up @@ -237,7 +241,14 @@ int SARHumanCreate(
human->intercepting_object_distance3d = 0.0;

/* Number of assisting humans */
human->assisting_humans = 0;
human->assisting_humans = assisting_humans;

/* Assisting humans preset(s) */
if (human->assisting_humans)
{
for(int i = 0; i < human->assisting_humans; i++)
human->assisting_human_preset_name[i] = assisting_human_preset_name[i];
}

/* Model human object values to preset values from the human
* data presets.
Expand Down Expand Up @@ -291,19 +302,27 @@ void SARHumanSetObjectPreset(

/* Height in meters */
human->height = entry->height;

/* Weight in kg */
human->mass = entry->mass;

/* Gender */
if(entry->preset_entry_flags & SAR_HUMAN_FLAG_GENDER_FEMALE)
human->flags |= SAR_HUMAN_FLAG_GENDER_FEMALE;

/* Number of assisting humans. Do not overwrite if assisting_humans
* number has been defined earlier by a create_human parameter.
*/
if(human->assisting_humans == 0)
human->assisting_humans = entry->assisting_humans;

/* Color palette for assisting humans */
memcpy(
&human->assisting_human_color[0],
&entry->assisting_human_color[0],
SAR_HUMAN_COLORS_MAX * sizeof(sar_color_struct)
);

/* Number of assisting humans */
human->assisting_humans = entry->assisting_humans;

/* Color palette for assisting humans */
memcpy(
&human->assisting_human_color[0],
&entry->assisting_human_color[0],
SAR_HUMAN_COLORS_MAX * sizeof(sar_color_struct)
);


/* Add support for other things that need to be coppied here */
Expand Down
Loading

0 comments on commit 734a077

Please sign in to comment.