Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make characters (player avatars) moddable #2942

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
cd74b32
separated character animations to upper/lower body.
ohlidalp Jun 29, 2022
ebf89bc
Moved character simbuffer to SimBuffers.h
ohlidalp Jun 29, 2022
82f90b4
Character: improved upper/lower body anims
ohlidalp Sep 19, 2022
f07c519
New UI: CharacterPoseUtil - displays anim states
ohlidalp Sep 19, 2022
281c0d4
CharacterPoseUtil UI: added manual posing mode
ohlidalp Sep 19, 2022
8cc8be4
Character: added state & situation flag system.
ohlidalp Sep 23, 2022
54ae8bf
Proof of concept: character anim config system.
ohlidalp Sep 23, 2022
8a22acb
Character anims: added auto-restart option
ohlidalp Sep 24, 2022
d72d08e
Fixed duplicate sidestep anim, conflicting with turn.
ohlidalp Sep 24, 2022
86e9b8e
Added CharacterPoseUtil/"Game anims" debug UI.
ohlidalp Sep 24, 2022
66842b7
Added game anim inline display to CharacterPoseUtil UI.
ohlidalp Sep 24, 2022
f8cd9be
Created custom character file format.
ohlidalp Sep 25, 2022
334393b
Character: fixed ACTION_SIDESTEP_RIGHT (typo)
ohlidalp Sep 25, 2022
540c0f6
Character: added custom action and mode slots.
ohlidalp Sep 25, 2022
40b367f
CharacterPose UI: Tolerate missing anims
ohlidalp Oct 1, 2022
919017f
Character: added option `force_animblend`
ohlidalp Sep 30, 2022
e5cd710
Character: added bone blend masks.
ohlidalp Oct 12, 2022
1060d63
Character (RoRbot) is now a mod type (select in Settings UI).
ohlidalp Nov 3, 2022
1e0d812
Character modding: bugfixes, new param `mesh_scale`
ohlidalp Nov 13, 2022
7c1c53c
Deleted now defunct 'config/classic.character'
ohlidalp Nov 14, 2022
b3a9b9f
Moddable character: final touches
ohlidalp Nov 15, 2022
c7c8c52
Codechange: clarified character modding terminology.
ohlidalp Jun 2, 2023
a8a96ca
Polished the character-modding system.
ohlidalp Jun 2, 2023
577a7b8
Custom characters now work over multiplayer
ohlidalp Jun 4, 2023
42a2228
FIXUP - fixed character always appearing in SelectorUI
ohlidalp Jun 4, 2023
2fe96af
.character: `author`, `material_override`, `character_description`
ohlidalp Jun 4, 2023
27bd05c
Added skinzip support to characters.
ohlidalp Jun 5, 2023
74f536a
Fixed SelectorUI glitches with character/terrain.
ohlidalp Jun 7, 2023
f3d2493
Fixed player colors and mod/skin lookup bugs.
ohlidalp Jun 7, 2023
791c288
Fixed mixup in character skin names vs. filenames.
ohlidalp Jun 20, 2023
b36a4a3
Fixed MP crashes related to new character system
ohlidalp Jun 25, 2023
e9adc5e
Bumped RoRnet because of new character system
ohlidalp Jun 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * from "managed_mats.material"

material tracks/character: RoR/Managed_Mats/Base
material character: RoR/Managed_Mats/Base
{
technique BaseTechnique
{
Expand All @@ -12,19 +12,21 @@ material tracks/character: RoR/Managed_Mats/Base
texture character.dds
}
}

// The multiplayer colorization pass - must be named "ColorChange"
pass ColorChange
{
scene_blend alpha_blend
// The alpha mask texture unit - name doesn't matter.
texture_unit
{
texture character-alpha.png
}
texture_unit
// The color texture unit - must be named "PlayerColor"
texture_unit "PlayerColor"
{
colour_op_ex blend_current_alpha src_manual src_current 0 0 0
}
}
}
}


}
File renamed without changes.
File renamed without changes.
200 changes: 200 additions & 0 deletions resources/default_character/default.character
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
; The default character (aka RoRbot)
; -----------------------------------------------------------------------------
;
; This file format lets you compose 'actions' from one or more
; skeletal animations exported from a 3D modelling tool,
; by responding to SITUATION_ and CONTROL_ flags sent by the game.
; NOTE each 'action' is evaluated separately, there is no either-or relation,
; so you must always blacklist all non-conforming flags to avoid conflicts.
;
; For explanation of individual parameters,
; see file source/main/resources/character_fileformat/CharacterFileFormat.h
; NOTE ON TERMINOLOGY: 'anim' always means skeletal animation, not the 'action'.
;
; For authoritative list of SITUATION_ and CONTROL_ flags, see file RoRnet.h
;
; Tip: in game, use 'Pose Util' UI panel,
; open it from top menubar >> Tools >> Character pose util.
;
; -----------------------------------------------------------------------------

; Name displayed in the Selector UI - required
character_name "Default character"

; required for skinning - use https://guidgenerator.com for your mods.
character_guid "baef1af5-2854-48c3-af05-5087da2d773b"

; Name of the mesh file - required.
mesh_name "character.mesh"

; Scaling factor of the mesh - optional, default is 1.0 on all axes.
; NOTE: the 0.02 factor used to be hardcoded because the default character mesh is oversized like that.
mesh_scale 0.02 0.02 0.02

begin_action
action_description "driving"
for_situation SITUATION_DRIVING
anim_name "Driving"
playback_time_ratio 0.f
playback_steering_ratio -1.f
anim_continuous false
source_percentual true
anim_neutral_mid true
playback_trim 0.01f
end_action

begin_action
action_description "swimming"
for_situation SITUATION_IN_DEEP_WATER
for_control CONTROL_MOVE_FORWARD
anim_name "Swim_loop"
playback_h_speed_ratio 1.f
playback_time_ratio 1.f
end_action

begin_action
action_description "swimming on spot"
for_situation SITUATION_IN_DEEP_WATER
except_control CONTROL_MOVE_FORWARD
anim_name "Spot_swim"
playback_time_ratio 1.f
end_action

begin_action
action_description "running"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_MOVE_FORWARD
for_control CONTROL_RUN
anim_name "Run"
playback_time_ratio 1.f
playback_h_speed_ratio 1.f
end_action

begin_action
action_description "walking forward"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_MOVE_FORWARD
except_control CONTROL_RUN
; when pressing both FORWARD+BACKWARD keys, FORWARD wins in game movement so let it win here also.
except_control CONTROL_MOVE_BACKWARD
anim_name "Walk"
playback_time_ratio 1.f
playback_h_speed_ratio 1.f
end_action

begin_action
action_description "walking backward"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_MOVE_BACKWARD
; Do not mix the walk animation into the run animation if user presses both RUN+MOVE_BACKWARDS.
except_control CONTROL_RUN
anim_name "Walk"
playback_time_ratio -1.f
playback_h_speed_ratio 1.f
end_action

begin_action
action_description "side stepping right"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_SIDESTEP_RIGHT
except_control CONTROL_MOVE_FORWARD
except_control CONTROL_MOVE_BACKWARD
; Pressing both SIDESTEP+TURN controls makes game combine the movements, so also combine the animations.
;except_control CONTROL_TURN_RIGHT
;except_control CONTROL_TURN_LEFT
except_control CONTROL_RUN
anim_name "Side_step"
playback_time_ratio 1.f
anim_autorestart true
end_action

begin_action
action_description "side stepping left"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_SIDESTEP_LEFT
except_control CONTROL_MOVE_FORWARD
except_control CONTROL_MOVE_BACKWARD
; Pressing both SIDESTEP+TURN controls makes game combine the movements, so also combine the animations.
;except_control CONTROL_TURN_RIGHT
;except_control CONTROL_TURN_LEFT
except_control CONTROL_RUN
anim_name "Side_step"
playback_time_ratio -1.f
anim_autorestart true
end_action

begin_action
action_description "turning left"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_TURN_LEFT
; Pressing both SIDESTEP+TURN controls makes game combine the movements, so also combine the animations.
;except_control CONTROL_SIDESTEP_LEFT
;except_control CONTROL_SIDESTEP_RIGHT
except_control CONTROL_MOVE_FORWARD
except_control CONTROL_MOVE_BACKWARD
except_control CONTROL_RUN
anim_name "Turn"
playback_time_ratio 1.f
anim_autorestart true
end_action

begin_action
action_description "turning right"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
for_control CONTROL_TURN_RIGHT
; Pressing both SIDESTEP+TURN controls makes game combine the movements, so also combine the animations.
;except_control CONTROL_SIDESTEP_LEFT
;except_control CONTROL_SIDESTEP_RIGHT
except_control CONTROL_MOVE_FORWARD
except_control CONTROL_MOVE_BACKWARD
except_control CONTROL_RUN
anim_name "Turn"
playback_time_ratio -1.f
anim_autorestart true
end_action

begin_action
action_description "idle standing"
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
except_situation SITUATION_CUSTOM_MODE_01
except_control CONTROL_TURN_RIGHT
except_control CONTROL_TURN_LEFT
except_control CONTROL_SIDESTEP_LEFT
except_control CONTROL_SIDESTEP_RIGHT
except_control CONTROL_MOVE_FORWARD
except_control CONTROL_MOVE_BACKWARD
except_control CONTROL_RUN
except_control CONTROL_CUSTOM_01
anim_name "Idle_sway"
playback_time_ratio 1.f
end_action

begin_action
action_description "custom action 01 test"
for_control CONTROL_CUSTOM_ACTION_01
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
except_situation SITUATION_CUSTOM_MODE_01
anim_name "Spot_swim"
playback_time_ratio 10.0
anim_continuous false
end_action

begin_action
action_description "custom mode 01 test"
for_situation SITUATION_CUSTOM_MODE_01
except_situation SITUATION_IN_DEEP_WATER
except_situation SITUATION_DRIVING
anim_name "Driving"
playback_time_ratio 2.0
end_action


23 changes: 0 additions & 23 deletions resources/meshes/character.material

This file was deleted.

4 changes: 4 additions & 0 deletions source/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ CVar* sim_no_self_collisions;
CVar* sim_gearbox_mode;
CVar* sim_soft_reset_mode;
CVar* sim_quickload_dialog;
CVar* sim_player_character;
CVar* sim_player_character_skin;

// Multiplayer
CVar* mp_state;
Expand All @@ -122,6 +124,8 @@ CVar* mp_server_password;
CVar* mp_player_name;
CVar* mp_player_token;
CVar* mp_api_url;
CVar* mp_override_character;
CVar* mp_override_character_skin;

// New remote API
CVar* remote_query_url;
Expand Down
8 changes: 7 additions & 1 deletion source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

#define ROR_ASSERT(_EXPR) assert(_EXPR)

#define CHARACTER_ANIM_NAME_LEN 10 // Restricted for networking
#define DEFAULT_CHARACTER_FILE "default.character" // Located in file 'resources/default_character.zip'

// Legacy macros
#define TOSTRING(x) Ogre::StringConverter::toString(x)
Expand Down Expand Up @@ -251,6 +251,8 @@ enum VisibilityMasks
enum LoaderType //!< Operation mode for GUI::MainSelector
{
LT_None,
LT_Character, // No script alias, invoked from Settings UI.
LT_CharacterMP,// No script alias, invoked from Multiplayer Lobby UI.
LT_Terrain, // Invocable from GUI; No script alias, used in main menu
LT_Vehicle, // Script "vehicle", ext: truck car
LT_Truck, // Script "truck", ext: truck car
Expand Down Expand Up @@ -303,6 +305,8 @@ extern CVar* sim_no_self_collisions;
extern CVar* sim_gearbox_mode;
extern CVar* sim_soft_reset_mode;
extern CVar* sim_quickload_dialog;
extern CVar* sim_player_character;
extern CVar* sim_player_character_skin;

// Multiplayer
extern CVar* mp_state;
Expand All @@ -317,6 +321,8 @@ extern CVar* mp_server_password;
extern CVar* mp_player_name;
extern CVar* mp_player_token;
extern CVar* mp_api_url;
extern CVar* mp_override_character; // If empty, use `sim_default_character`
extern CVar* mp_override_character_skin;

// New remote API
extern CVar* remote_query_url;
Expand Down
4 changes: 4 additions & 0 deletions source/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(SOURCE_FILES
gfx/DustPool.{h,cpp}
gfx/EnvironmentMap.{h,cpp}
gfx/GfxActor.{h,cpp}
gfx/GfxCharacter.{h,cpp}
gfx/GfxData.h
gfx/GfxScene.{h,cpp}
gfx/HydraxWater.{h,cpp}
Expand Down Expand Up @@ -114,6 +115,7 @@ set(SOURCE_FILES
gui/imgui/imstb_textedit.h
gui/imgui/imstb_truetype.h
gui/panels/GUI_AngelScriptExamples.{h,cpp}
gui/panels/GUI_CharacterPoseUtil.{h,cpp}
gui/panels/GUI_CollisionsDebug.{h,cpp}
gui/panels/GUI_ConsoleView.{h,cpp}
gui/panels/GUI_ConsoleWindow.{h,cpp}
Expand Down Expand Up @@ -191,6 +193,7 @@ set(SOURCE_FILES
resources/skin_fileformat/SkinFileFormat.{h,cpp}
resources/terrn2_fileformat/Terrn2FileFormat.{h,cpp}
resources/tobj_fileformat/TObjFileFormat.{h,cpp}
resources/character_fileformat/CharacterFileFormat.{h,cpp}
system/AppCommandLine.cpp
system/AppConfig.cpp
system/Console.{h,cpp}
Expand Down Expand Up @@ -341,6 +344,7 @@ target_include_directories(${BINNAME} PRIVATE
physics/utils
physics/water
resources
resources/character_fileformat
resources/odef_fileformat/
resources/otc_fileformat/
resources/rig_def_fileformat
Expand Down
3 changes: 3 additions & 0 deletions source/main/ForwardDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ namespace RoR
typedef int ScriptUnitId_t; //!< Unique sequentially generated ID of a loaded and running scriptin session. Use `ScriptEngine::getScriptUnit()`
static const ScriptUnitId_t SCRIPTUNITID_INVALID = -1;

typedef int CharacterActionID_t; //!< Index to `CharacterDocument::actions`, use `CHARACTERACTIONID_INVALID` as empty value.
static const CharacterActionID_t CHARACTERACTIONID_INVALID = -1;

typedef int PointidID_t; //!< index to `PointColDetector::hit_pointid_list`, use `RoR::POINTIDID_INVALID` as empty value.
static const PointidID_t POINTIDID_INVALID = -1;

Expand Down
Loading