diff --git a/DivaGL.sln b/DivaGL.sln index cb4f4fc..ba3cef6 100644 --- a/DivaGL.sln +++ b/DivaGL.sln @@ -5,6 +5,12 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KKdLib", "src\KKdLib\KKdLib.vcxproj", "{65707AD3-568A-4FE9-A75E-BDBF3D5EFC88}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DivaGL", "src\DivaGL\DivaGL.vcxproj", "{4D949362-9095-4113-9423-7E0492618F16}" + ProjectSection(ProjectDependencies) = postProject + {65707AD3-568A-4FE9-A75E-BDBF3D5EFC88} = {65707AD3-568A-4FE9-A75E-BDBF3D5EFC88} + {BCF448EA-DCFF-49AF-97FF-361204C69358} = {BCF448EA-DCFF-49AF-97FF-361204C69358} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AFTModsShared", "src\AFTModsShared\AFTModsShared.vcxproj", "{BCF448EA-DCFF-49AF-97FF-361204C69358}" ProjectSection(ProjectDependencies) = postProject {65707AD3-568A-4FE9-A75E-BDBF3D5EFC88} = {65707AD3-568A-4FE9-A75E-BDBF3D5EFC88} EndProjectSection @@ -23,6 +29,10 @@ Global {4D949362-9095-4113-9423-7E0492618F16}.Debug|x64.Build.0 = Debug|x64 {4D949362-9095-4113-9423-7E0492618F16}.Release|x64.ActiveCfg = Release|x64 {4D949362-9095-4113-9423-7E0492618F16}.Release|x64.Build.0 = Release|x64 + {BCF448EA-DCFF-49AF-97FF-361204C69358}.Debug|x64.ActiveCfg = Debug|x64 + {BCF448EA-DCFF-49AF-97FF-361204C69358}.Debug|x64.Build.0 = Debug|x64 + {BCF448EA-DCFF-49AF-97FF-361204C69358}.Release|x64.ActiveCfg = Release|x64 + {BCF448EA-DCFF-49AF-97FF-361204C69358}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/AFTModsShared/AFTModsShared.rc b/src/AFTModsShared/AFTModsShared.rc new file mode 100644 index 0000000..a419af1 --- /dev/null +++ b/src/AFTModsShared/AFTModsShared.rc @@ -0,0 +1,37 @@ +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +#include "winres.h" +#undef APSTUDIO_READONLY_SYMBOLS + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,1,0,0 + PRODUCTVERSION 0,1,0,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000904b0" + BEGIN + VALUE "FileDescription", "Shared library for Mods for PDAFT 7.10" + VALUE "FileVersion", "0.1.0.0" + VALUE "InternalName", "AFTModsShared" + VALUE "LegalCopyright", "korenkonder (C) 2025" + VALUE "OriginalFilename", "AFTModsShared.dll" + VALUE "ProductName", "AFTModsShared" + VALUE "ProductVersion", "0.1.0.0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x9, 1200 + END +END diff --git a/src/AFTModsShared/AFTModsShared.vcxproj b/src/AFTModsShared/AFTModsShared.vcxproj new file mode 100644 index 0000000..620ec2d --- /dev/null +++ b/src/AFTModsShared/AFTModsShared.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {bcf448ea-dcff-49af-97ff-361204c69358} + Win32Proj + 10.0 + + + + StaticLibrary + false + v142 + Unicode + + + StaticLibrary + false + v142 + Unicode + + + + + + + + + + + + + + false + AFTModsShared + $(SolutionDir)lib\debug\ + $(SolutionDir)obj\debug\AFTModsShared\ + + + false + AFTModsShared + $(SolutionDir)lib\release\ + $(SolutionDir)obj\release\AFTModsShared\ + + + + NotUsing + Level3 + Disabled + WIN32;DEBUG;%(PreprocessorDefinitions) + $(SolutionDir)extern\src + true + ProgramDatabase + false + OnlyExplicitInline + FastCall + true + CompileAsCpp + $(IntDir)/%(RelativeDir) + MultiThreaded + 26812 + false + true + + + MachineX64 + DebugFull + Windows + $(SolutionDir)extern\lib;$(SolutionDir)lib\debugopt\ + detours.lib;syelog.lib;KKdLib.lib;%(AdditionalDependencies) + /ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions) + false + + + + + NotUsing + Level3 + MaxSpeed + WIN32;%(PreprocessorDefinitions) + $(SolutionDir)extern\src + true + false + ProgramDatabase + OnlyExplicitInline + true + FastCall + CompileAsCpp + + + $(IntDir)/%(RelativeDir) + Speed + + + false + MultiThreaded + 26812 + true + + + MachineX64 + true + Windows + $(SolutionDir)extern\lib;$(SolutionDir)lib\release\ + detours.lib;syelog.lib;KKdLib.lib;%(AdditionalDependencies) + true + /ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions) + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AFTModsShared/AFTModsShared.vcxproj.user b/src/AFTModsShared/AFTModsShared.vcxproj.user new file mode 100644 index 0000000..429333d --- /dev/null +++ b/src/AFTModsShared/AFTModsShared.vcxproj.user @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file diff --git a/src/DivaGL/auth_2d.cpp b/src/AFTModsShared/auth_2d.cpp similarity index 100% rename from src/DivaGL/auth_2d.cpp rename to src/AFTModsShared/auth_2d.cpp diff --git a/src/DivaGL/auth_2d.hpp b/src/AFTModsShared/auth_2d.hpp similarity index 100% rename from src/DivaGL/auth_2d.hpp rename to src/AFTModsShared/auth_2d.hpp diff --git a/src/AFTModsShared/auth_3d.cpp b/src/AFTModsShared/auth_3d.cpp new file mode 100644 index 0000000..06737d3 --- /dev/null +++ b/src/AFTModsShared/auth_3d.cpp @@ -0,0 +1,497 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "auth_3d.hpp" +#include "../KKdLib/hash.hpp" +#include "../AFTModsShared/canonical_properties.hpp" +#include "../AFTModsShared/file_handler.hpp" +#include "../AFTModsShared/types.hpp" +#include "mdl/disp_manager.hpp" +#include "rob/rob.hpp" +#include "sprite.hpp" +#include "texture.hpp" +#include + +struct struc_8 { + float_t max_frame; + void* data; + size_t data_size; + bool field_18; + CanonicalProperties CanProp; + int32_t field_60; + int32_t field_64; + int64_t field_68; + bool field_70; + void* binary_data; + size_t binary_size; + bool field_88; +}; + +static_assert(sizeof(struc_8) == 0x90, "\"struc_8\" struct should have a size of 0x90"); + +struct auth_3d_db_category { + prj::string name; + prj::vector uids; +}; + +static_assert(sizeof(auth_3d_db_category) == 0x38, "\"auth_3d_db_category\" struct should have a size of 0x38"); + +struct auth_3d_uid_file { + int32_t load_count; + int32_t uid; + prj::string file_name; + int32_t state; + struc_8 field_30; + const char* name; + void* farc; // auth_3d_farc +}; + +static_assert(sizeof(auth_3d_uid_file) == 0xD0, "\"auth_3d_uid_file\" struct should have a size of 0xD0"); + +#define AUTH_3D_DATA_COUNT 0x100 + +struct auth_3d_data_struct { + prj::map field_0; // struc_87 + prj::sorted_vector field_10; + prj::vector category; + prj::vector uid; + p_file_handler auth_3d_db_file_handler; + prj::vector db_file_handlers; + prj::sorted_vector field_A0; + int64_t field_E0; + p_file_handler auth_3d_setting_file_handler; + prj::vector farcs; // auth_3d_farc + prj::vector uid_files; + prj::vector loaded_ids; + auth_3d data[AUTH_3D_DATA_COUNT]; + int64_t field_C7938; +}; + +static_assert(sizeof(auth_3d_data_struct) == 0xC7940, "\"auth_3d_data_struct\" struct should have a size of 0xC7940"); + +int32_t(FASTCALL* auth_3d_data_get_uid_by_name)(const char* name) + = (int32_t(FASTCALL*)(const char* name)) 0x00000001401E7EA0; +bool (FASTCALL* auth_3d_data_check_category_loaded)(const char* category_name) + = (bool (FASTCALL*)(const char* category_name))0x00000001401CBE20; +void (FASTCALL* auth_3d_data_load_category)(const char* category_name) + = (void (FASTCALL*)(const char* category_name))0x00000001401CBE80; +void (FASTCALL* auth_3d_data_unload_category)(const char* category_name) + = (void (FASTCALL*)(const char* category_name))0x00000001401CBAB0; + +static auth_3d_data_struct* auth_3d_data = (auth_3d_data_struct*)0x0000000140EDA950; + +static int32_t auth_3d_get_auth_3d_object_index(auth_3d* auth, object_info object_info, int32_t instance); +static const mat4* auth_3d_get_auth_3d_object_mat(auth_3d* auth, size_t index); +static const mat4* auth_3d_get_auth_3d_object_hrc_bone_mats(auth_3d* auth, size_t index); +static int32_t auth_3d_get_auth_3d_object_hrc_index(auth_3d* auth, object_info obj_info, int32_t instance); + +auth_3d_id::auth_3d_id(int32_t uid) : id() { + ((auth_3d_id * (FASTCALL*)(auth_3d_id * This, int32_t uid))0x00000001401CDC80)(this, uid); +} + +auth_3d_id::auth_3d_id(const char* name) : id() { + ((auth_3d_id * (FASTCALL*)(auth_3d_id * This, int32_t uid))0x00000001401CDC80)( + this, auth_3d_data_get_uid_by_name(name)); +} + +bool auth_3d_id::check_not_empty() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->id != -1; + } + return false; +} + +bool auth_3d_id::check_loading() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->state == 1; + } + return false; +} + +bool auth_3d_id::check_loaded() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->state == 2; + } + return true; +} + +auth_3d* auth_3d_id::get_auth_3d() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth; + } + return 0; +} + +int32_t auth_3d_id::get_chara_id() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->chara_id; + } + return -1; +} + +const mat4* auth_3d_id::get_auth_3d_object_mat(size_t index, bool hrc) { + if (id < 0 || (id & 0x7FFF) >= AUTH_3D_DATA_COUNT) + return 0; + + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id != id || !auth->enable) + return 0; + + if (hrc) + return auth_3d_get_auth_3d_object_hrc_bone_mats(auth, index); + return auth_3d_get_auth_3d_object_mat(auth, index); +} + +bool auth_3d_id::get_enable() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->enable; + } + return false; +} + +bool auth_3d_id::get_ended() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->ended; + } + return true; +} + +float_t auth_3d_id::get_frame() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->frame; + } + return 0.0f; +} + +float_t auth_3d_id::get_frame_offset() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->frame_offset; + } + return 0.0f; +} + +float_t auth_3d_id::get_last_frame() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->last_frame; + } + return 0.0f; +} + +bool auth_3d_id::get_left_right_reverse() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->left_right_reverse; + } + return false; +} + +float_t auth_3d_id::get_play_control_begin() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->play_control.begin; + } + return 0.0f; +} + +float_t auth_3d_id::get_play_control_size() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->play_control.size; + } + return 0.0f; +} + +bool auth_3d_id::get_paused() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->paused; + } + return false; +} + +bool auth_3d_id::get_repeat() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->repeat; + } + return false; +} + +int32_t auth_3d_id::get_uid() { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + return auth->uid; + } + return -1; +} + +void auth_3d_id::read_file() { + ((void (FASTCALL*)(auth_3d_id * This))0x00000001401E0F80)(this); +} + +void auth_3d_id::set_alpha_obj_flags(float_t alpha, mdl::ObjFlags obj_flags) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) { + auth->alpha = alpha; + auth->obj_flags = obj_flags; + } + } +} + +void auth_3d_id::set_camera_root_update(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->camera_root_update = value; + } +} + +void auth_3d_id::set_chara_id(int32_t value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->chara_id = value; + } +} + +void auth_3d_id::set_chara_item(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->chara_item = value; + } +} + +void auth_3d_id::set_enable(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->enable = value; + } +} + +void auth_3d_id::set_frame_rate(FrameRateControl* value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + if (value) + auth->frame_rate = value; + else + auth->frame_rate = get_sys_frame_rate(); + } +} + +void auth_3d_id::set_last_frame(float_t value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->last_frame = value; + } +} + +void auth_3d_id::set_left_right_reverse(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->left_right_reverse = value; + } +} + +void auth_3d_id::set_mat(const mat4& value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->mat = value; + } +} + +void auth_3d_id::set_max_frame(float_t value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->max_frame = value; + } +} + +void auth_3d_id::set_paused(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->paused = value; + } +} + +void auth_3d_id::set_pos(int32_t value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->pos = value; + } +} + +void auth_3d_id::set_reflect(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->reflect = value; + } +} + +void auth_3d_id::set_repeat(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->repeat = value; + } +} + +void auth_3d_id::set_req_frame(float_t value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) { + auth->req_frame = value; + auth->frame_changed = true; + } + } +} + +void auth_3d_id::set_shadow(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->shadow = value; + } +} + +void auth_3d_id::set_src_dst_chara(int32_t src_chara, int32_t dst_chara) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) { + auth->src_chara = (chara_index)src_chara; + auth->dst_chara = (chara_index)dst_chara; + } + } +} + +void auth_3d_id::set_visibility(bool value) { + if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { + auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; + if (auth->id == id) + auth->visible = value; + } +} + +void auth_3d_id::unload() { + ((void (FASTCALL*)(auth_3d_id * This))0x00000001401D0190)(this); +} + +int32_t auth_3d_data_get_auth_3d_id(uint32_t uid, object_info obj_info, + int32_t* object_index, bool* hrc, int32_t instance) { + for (int32_t& i : auth_3d_data->loaded_ids) { + if (i < 0 || (i & 0x7FFF) >= AUTH_3D_DATA_COUNT) + continue; + + auth_3d* auth = &auth_3d_data->data[i & 0x7FFF]; + if (auth->id != i || !auth->enable) + continue; + + bool ret = false; + if (uid != -1) { + if (auth->uid != uid) + continue; + ret = true; + } + + int32_t obj_index = auth_3d_get_auth_3d_object_index(auth, obj_info, instance); + if (obj_index >= 0) { + if (object_index) + *object_index = obj_index; + if (hrc) + *hrc = false; + return i; + } + + int32_t obj_hrc_index = auth_3d_get_auth_3d_object_hrc_index(auth, obj_info, instance); + if (obj_hrc_index >= 0) { + if (object_index) + *object_index = obj_hrc_index; + if (hrc) + *hrc = true; + return i; + } + + if (ret) + return -1; + } + return -1; +} + +static int32_t auth_3d_get_auth_3d_object_index(auth_3d* auth, object_info object_info, int32_t instance) { + int32_t obj_instance = 0; + for (auth_3d_object& i : auth->object) + if (object_info == i.object_info) { + if (obj_instance == instance) + return (int32_t)(&i - auth->object.data()); + obj_instance++; + } + return -1; +} + +static const mat4* auth_3d_get_auth_3d_object_mat(auth_3d* auth, size_t index) { + if (index >= auth->object.size()) + return 0; + return &auth->object[index].model_transform.mat; +} + +static const mat4* auth_3d_get_auth_3d_object_hrc_bone_mats(auth_3d* auth, size_t index) { + if (index >= auth->object_hrc.size() || auth->object_hrc[index].node_bone_mats.size() < 1) + return 0; + return auth->object_hrc[index].node_bone_mats.data(); +} + +static int32_t auth_3d_get_auth_3d_object_hrc_index(auth_3d* auth, object_info obj_info, int32_t instance) { + if (instance < 0) { + for (auth_3d_object_hrc& i : auth->object_hrc) + if (obj_info == i.object_info) + return (int32_t)(&i - auth->object_hrc.data()); + } + else { + int32_t obj_instance = 0; + for (auth_3d_object_hrc& i : auth->object_hrc) + if (obj_info == i.object_info) { + if (obj_instance == instance) + return (int32_t)(&i - auth->object_hrc.data()); + obj_instance++; + } + } + return -1; +} diff --git a/src/AFTModsShared/auth_3d.hpp b/src/AFTModsShared/auth_3d.hpp new file mode 100644 index 0000000..c1952b4 --- /dev/null +++ b/src/AFTModsShared/auth_3d.hpp @@ -0,0 +1,590 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/mat.hpp" +#include "../KKdLib/vec.hpp" +#include "../AFTModsShared/light_param/fog.hpp" +#include "../AFTModsShared/light_param/light.hpp" +#include "../AFTModsShared/mdl/disp_manager.hpp" +#include "../AFTModsShared/rob/rob.hpp" +#include "../AFTModsShared/frame_rate_control.hpp" +#include "object.hpp" +#include "types.hpp" + +enum auth_3d_camera_auxiliary_flags { + AUTH_3D_CAMERA_AUXILIARY_EXPOSURE = 0x01, + AUTH_3D_CAMERA_AUXILIARY_GAMMA = 0x02, + AUTH_3D_CAMERA_AUXILIARY_SATURATE = 0x04, + AUTH_3D_CAMERA_AUXILIARY_AUTO_EXPOSURE = 0x08, +}; + +enum auth_3d_ep_type { + AUTH_3D_EP_NONE = 0x00, + AUTH_3D_EP_LINEAR = 0x01, + AUTH_3D_EP_CYCLE = 0x02, + AUTH_3D_EP_CYCLE_OFFSET = 0x03, +}; + +enum auth_3d_fog_flags { + AUTH_3D_FOG_DENSITY = 0x01, + AUTH_3D_FOG_START = 0x02, + AUTH_3D_FOG_END = 0x04, + AUTH_3D_FOG_COLOR = 0x08, +}; + +enum auth_3d_key_type { + AUTH_3D_KEY_NONE = 0x00, + AUTH_3D_KEY_STATIC = 0x01, + AUTH_3D_KEY_LINEAR = 0x02, + AUTH_3D_KEY_HERMITE = 0x03, + AUTH_3D_KEY_HOLD = 0x04, +}; + +enum auth_3d_light_flags { + AUTH_3D_LIGHT_AMBIENT = 0x01, + AUTH_3D_LIGHT_DIFFUSE = 0x02, + AUTH_3D_LIGHT_SPECULAR = 0x04, + AUTH_3D_LIGHT_TONE_CURVE = 0x08, +}; + +enum auth_3d_object_texture_transform_flags { + AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_U = 0x001, + AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_V = 0x002, + AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_U = 0x004, + AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_V = 0x008, + AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_U = 0x010, + AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_V = 0x020, + AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_U = 0x040, + AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_V = 0x080, + AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE_FRAME = 0x100, + AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE = 0x200, +}; + +enum auth_3d_post_process_flags { + AUTH_3D_POST_PROCESS_LENS_FLARE = 0x01, + AUTH_3D_POST_PROCESS_LENS_SHAFT = 0x02, + AUTH_3D_POST_PROCESS_LENS_GHOST = 0x04, + AUTH_3D_POST_PROCESS_RADIUS = 0x08, + AUTH_3D_POST_PROCESS_INTENSITY = 0x10, + AUTH_3D_POST_PROCESS_SCENE_FADE = 0x20, +}; + +struct kft3 { + float_t frame; + float_t value; + float_t tangent1; + float_t tangent2; +}; + +static_assert(sizeof(kft3) == 0x10, "\"kft3\" struct should have a size of 0x10"); + +struct auth_3d_key { + auth_3d_key_type type; + float_t value; + float_t max_frame; + auth_3d_ep_type ep_type_pre; + auth_3d_ep_type ep_type_post; + float_t frame_delta; + float_t value_delta; + prj::vector keys_vec; + size_t length; + kft3* keys; +}; + +static_assert(sizeof(auth_3d_key) == 0x48, "\"auth_3d_key\" struct should have a size of 0x48"); + +struct auth_3d_vec3 { + auth_3d_key x; + auth_3d_key y; + auth_3d_key z; +}; + +static_assert(sizeof(auth_3d_vec3) == 0xD8, "\"auth_3d_vec3\" struct should have a size of 0xD8"); + +struct auth_3d_rgba { + auth_3d_key r; + auth_3d_key g; + auth_3d_key b; + auth_3d_key a; + bool has_r; + bool has_g; + bool has_b; + bool has_a; + int32_t field_124; + vec4 value; + bool has_got[4]; +}; + +static_assert(sizeof(auth_3d_rgba) == 0x140, "\"auth_3d_rgba\" struct should have a size of 0x140"); + +struct auth_3d_model_transform { + mat4 mat; + auth_3d_vec3 scale; + auth_3d_vec3 rotation; + auth_3d_vec3 translation; + auth_3d_key visibility; + vec3 scale_value; + vec3 rotation_value; + vec3 translation_value; + bool visible; +}; + +static_assert(sizeof(auth_3d_model_transform) == 0x338, "\"auth_3d_model_transform\" struct should have a size of 0x338"); + +struct auth_3d_curve { + auth_3d_key curve; + prj::string name; + float_t value; + uint32_t type; // X +}; + +static_assert(sizeof(auth_3d_curve) == 0x70, "\"auth_3d_curve\" struct should have a size of 0x70"); + +struct auth_3d_object_curve { + auth_3d_curve* curve; + prj::string name; + float_t frame_offset; + float_t value; +}; + +static_assert(sizeof(auth_3d_object_curve) == 0x30, "\"auth_3d_object_curve\" struct should have a size of 0x30"); + +struct auth_3d_object_texture_pattern { + prj::string name; + int32_t texture_id; + auth_3d_object_curve pattern; +}; + +static_assert(sizeof(auth_3d_object_texture_pattern) == 0x58, "\"auth_3d_object_texture_pattern\" struct should have a size of 0x58"); + +struct auth_3d_object_texture_transform { + auth_3d_object_texture_transform_flags flags; + prj::string name; + int32_t texture_id; + auth_3d_key coverageU; + auth_3d_key coverageV; + auth_3d_key repeatU; + auth_3d_key repeatV; + auth_3d_key translateFrameU; + auth_3d_key translateFrameV; + auth_3d_key offsetU; + auth_3d_key offsetV; + auth_3d_key rotateFrame; + auth_3d_key rotate; + mat4 mat; + vec3 scale_value; + vec3 repeat_value; + vec3 rotate_value; + vec3 translateFrame_value; +}; + +static_assert(sizeof(auth_3d_object_texture_transform) == 0x370, "\"auth_3d_object_texture_transform\" struct should have a size of 0x370"); + +struct auth_3d_object_hrc; + +struct auth_3d_object { + auth_3d_model_transform model_transform; + int64_t field_338; + prj::string name; + prj::string uid_name; + prj::string parent_name; + prj::string parent_node; + auth_3d_object_curve pattern; + auth_3d_object_curve morph; + prj::vector texture_pattern; + prj::vectortexture_transform; + prj::vector children_object; + prj::vector children_object_hrc; + object_info object_info; + bool reflect; + bool refract; +}; + +static_assert(sizeof(auth_3d_object) == 0x488, "\"auth_3d_object\" struct should have a size of 0x488"); + +struct auth_3d_object_model_transform { + mat4 mat; + mat4 mat_inner; + auth_3d_vec3 translation; + auth_3d_vec3 rotation; + auth_3d_vec3 scale; + auth_3d_key visibility; + vec3 translation_value; + vec3 rotation_value; + vec3 scale_value; + bool visible; + mat4 mat_rot; + int64_t field_3B8; + int32_t field_3C0; + mat4 field_3C4; + vec3 field_404; + float_t frame; + bool has_rotation; + bool has_translation; + bool has_scale; + bool has_visibility; +}; + +static_assert(sizeof(auth_3d_object_model_transform) == 0x418, "\"auth_3d_object_model_transform\" struct should have a size of 0x418"); + +struct auth_3d_object_node { + prj::string name; + int32_t bone_id; + int32_t parent; + auth_3d_object_model_transform model_transform; + mat4* mat; + mat4 joint_orient; +}; + +static_assert(sizeof(auth_3d_object_node) == 0x488, "\"auth_3d_object_node\" struct should have a size of 0x488"); + +struct auth_3d_object_hrc { + prj::vector node; + prj::vector node_bone_mats; + mat4* bone_mats; + prj::string name; + prj::string uid_name; + object_info object_info; + bool reflect; + bool refract; + bool shadow; + prj::string parent_name; + prj::string parent_node; + prj::vector children_object; + prj::vector children_object_parent_node; + prj::vector children_object_hrc; + prj::vector children_object_hrc_parent_node; +}; + +static_assert(sizeof(auth_3d_object_hrc) == 0x120, "\"auth_3d_object_hrc\" struct should have a size of 0x120"); + +struct auth_3d_object_instance { + prj::string name; + prj::string uid_name; + object_info object_info; + bool shadow; + auth_3d_object_model_transform model_transform; + prj::vector object_bone_indices; + prj::vector mats; +}; + +static_assert(sizeof(auth_3d_object_instance) == 0x490, "\"auth_3d_object_instance\" struct should have a size of 0x490"); + +struct auth_3d_m_object_hrc { + prj::string name; + auth_3d_object_model_transform model_transform; + prj::vector node; + prj::vector instance; +}; + +static_assert(sizeof(auth_3d_m_object_hrc) == 0x468, "\"auth_3d_m_object_hrc\" struct should have a size of 0x468"); + +struct auth_3d_time_event { + float_t frame; + int32_t type; + size_t event_index; +}; + +static_assert(sizeof(auth_3d_time_event) == 0x10, "\"auth_3d_time_event\" struct should have a size of 0x10"); + +struct auth_3d_play_control { + float_t begin; + float_t size; + float_t fps; +}; + +static_assert(sizeof(auth_3d_play_control) == 0x0C, "\"auth_3d_play_control\" struct should have a size of 0x0C"); + +struct auth_3d_point { + prj::string name; + auth_3d_model_transform model_transform; +}; + +static_assert(sizeof(auth_3d_point) == 0x358, "\"auth_3d_point\" struct should have a size of 0x358"); + +struct auth_3d_camera_root_view_point { + auth_3d_model_transform model_transform; + auth_3d_key roll; + bool has_fov; + bool fov_is_horizontal; + auth_3d_key fov; + float_t aspect; + auth_3d_key focal_length; + float_t camera_aperture_w; + float_t camera_aperture_h; +}; + +static_assert(sizeof(auth_3d_camera_root_view_point) == 0x428, "\"auth_3d_camera_root_view_point\" struct should have a size of 0x428"); + +struct auth_3d_camera_root { + auth_3d_model_transform model_transform; + auth_3d_camera_root_view_point view_point; + auth_3d_model_transform interest; +}; + +static_assert(sizeof(auth_3d_camera_root) == 0xA98, "\"auth_3d_camera_root\" struct should have a size of 0xA98"); + +struct auth_3d_camera_auxiliary { + auth_3d_camera_auxiliary_flags flags; + auth_3d_key exposure; + auth_3d_key gamma; + auth_3d_key saturate; + auth_3d_key auto_exposure; + float_t exposure_value; + float_t gamma_value; + float_t saturate_value; + float_t auto_exposure_value; +}; + +static_assert(sizeof(auth_3d_camera_auxiliary) == 0x138, "\"auth_3d_camera_auxiliary\" struct should have a size of 0x138"); + +struct auth_3d_light { + auth_3d_light_flags flags; + auth_3d_light_flags flags_init; + light_id id; + prj::string name; + prj::string type; + auth_3d_model_transform position; + auth_3d_model_transform spot_direction; + auth_3d_rgba Ambient; + auth_3d_rgba Diffuse; + auth_3d_rgba Specular; + auth_3d_rgba Tone_Curve; + vec4 Ambient_init; + vec4 Diffuse_init; + vec4 Specular_init; + vec4 Tone_Curve_init; +}; + +static_assert(sizeof(auth_3d_light) == 0xC00, "\"auth_3d_light\" struct should have a size of 0xC00"); + +struct auth_3d_fog { + auth_3d_fog_flags flags; + auth_3d_fog_flags flags_init; + fog_id id; + prj::string name; + auth_3d_key density; + auth_3d_key start; + auth_3d_key end; + float_t density_value; + float_t start_value; + float_t end_value; + auth_3d_rgba color; + float_t density_init; + float_t start_init; + float_t end_init; + vec4 color_init; +}; + +static_assert(sizeof(auth_3d_fog) == 0x278, "\"auth_3d_fog\" struct should have a size of 0x278"); + +struct auth_3d_post_process { + auth_3d_post_process_flags flags; + auth_3d_post_process_flags flags_init; + auth_3d_key lens_flare; + auth_3d_key lens_shaft; + auth_3d_key lens_ghost; + auth_3d_rgba radius; + auth_3d_rgba intensity; + auth_3d_rgba scene_fade; + vec3 lens_init; + vec4 radius_init_value; + vec4 intensity_init_value; + vec4 scene_fade_value; + vec3 lens_value; +}; + +static_assert(sizeof(auth_3d_post_process) == 0x4E8, "\"auth_3d_post_process\" struct should have a size of 0x4E8"); + +struct auth_3d_dof { + bool has_dof; + auth_3d_model_transform model_transform; +}; + +static_assert(sizeof(auth_3d_dof) == 0x340, "\"auth_3d_dof\" struct should have a size of 0x340"); + +struct auth_3d_chara { + prj::string name; + auth_3d_model_transform model_transform; + int32_t index; +}; + +static_assert(sizeof(auth_3d_chara) == 0x360, "\"auth_3d_chara\" struct should have a size of 0x360"); + +struct auth_3d_motion { + prj::string name; +}; + +static_assert(sizeof(auth_3d_motion) == 0x20, "\"auth_3d_motion\" struct should have a size of 0x20"); + +struct auth_3d_auth_2d { + prj::string name; +}; + +static_assert(sizeof(auth_3d_auth_2d) == 0x20, "\"auth_3d_auth_2d\" struct should have a size of 0x20"); + +struct auth_3d { + int32_t uid; + int32_t id; + bool enable; + bool camera_root_update; + bool visible; + bool repeat; + bool field_C; + bool ended; + bool left_right_reverse; + bool once; + mat4 mat; + float_t alpha; + mdl::ObjFlags obj_flags; + bool field_58; + prj::map field_60; + prj::vector texture_pattern; + int32_t chara_id; + object_info object_info; + mat4* bone_mats; + bool shadow; + bool chara_item; + bool reflect; // X + chara_index src_chara; + chara_index dst_chara; + int32_t pos; + int64_t field_A8; + FrameRateControl* frame_rate; + float_t frame; + float_t req_frame; + float_t max_frame; + bool frame_changed; + float_t frame_offset; + float_t last_frame; + float_t fov_scale; + prj::vector* field_D8; + float_t blend; + int64_t field_E8; + int64_t field_F0; + bool paused; + prj::vector event; + prj::vector event_time; + auth_3d_time_event* event_time_next; + auth_3d_play_control play_control; + prj::vector point; + prj::vector curve; + prj::vector camera_root; + auth_3d_camera_auxiliary camera_auxiliary; + prj::vector light; + prj::vector fog; + auth_3d_post_process post_process; + auth_3d_dof dof; + prj::vector chara; + prj::vector motion; + prj::vector object; + prj::vector object_list; + prj::vector object_hrc; + prj::vector object_hrc_list; + prj::vector m_object_hrc; + prj::vector m_object_hrc_list; + prj::vector field_BE0; + prj::vector object_list_string; + prj::vector object_hrc_list_string; + prj::vector m_object_hrc_list_string; + prj::vector auth_2d; + int32_t state; + prj::vector field_C60; +}; + +static_assert(sizeof(auth_3d) == 0xC78, "\"auth_3d\" struct should have a size of 0xC78"); + +struct auth_3d_id { + int32_t id; + + inline auth_3d_id() { + id = -1; + } + + inline bool is_null() { + return id == -1; + } + + inline bool not_null() { + return id != -1; + } + + auth_3d_id(int32_t uid); + auth_3d_id(const char* name); + bool check_not_empty(); + bool check_loading(); + bool check_loaded(); + auth_3d* get_auth_3d(); + const mat4* get_auth_3d_object_mat(size_t index, bool hrc); + int32_t get_chara_id(); + bool get_enable(); + bool get_ended(); + float_t get_frame(); + float_t get_frame_offset(); + float_t get_last_frame(); + bool get_left_right_reverse(); + bool get_paused(); + float_t get_play_control_begin(); + float_t get_play_control_size(); + bool get_repeat(); + int32_t get_uid(); + void read_file(); + void set_alpha_obj_flags(float_t alpha, mdl::ObjFlags obj_flags); + void set_camera_root_update(bool value); + void set_chara_id(int32_t value); + void set_chara_item(bool value); + void set_enable(bool value); + void set_frame_rate(FrameRateControl* value); + void set_last_frame(float_t value); + void set_left_right_reverse(bool value); + void set_mat(const mat4& value); + void set_max_frame(float_t value); + void set_paused(bool value); + void set_pos(int32_t value); + void set_reflect(bool value); // X + void set_repeat(bool value); + void set_req_frame(float_t value); + void set_shadow(bool value); + void set_src_dst_chara(int32_t src_chara, int32_t dst_chara); + void set_visibility(bool value); + void unload(); +}; + +static_assert(sizeof(auth_3d_id) == 0x04, "\"auth_3d_id\" struct should have a size of 0x04"); + +inline bool operator >(const auth_3d_id& left, const auth_3d_id& right) { + return left.id > right.id; +} + +inline bool operator <(const auth_3d_id& left, const auth_3d_id& right) { + return left.id < right.id; +} + +inline bool operator >=(const auth_3d_id& left, const auth_3d_id& right) { + return left.id >= right.id; +} + +inline bool operator <=(const auth_3d_id& left, const auth_3d_id& right) { + return left.id <= right.id; +} + +inline bool operator ==(const auth_3d_id& left, const auth_3d_id& right) { + return left.id == right.id; +} + +inline bool operator !=(const auth_3d_id& left, const auth_3d_id& right) { + return left.id != right.id; +} + +extern int32_t(FASTCALL* auth_3d_data_get_uid_by_name)(const char* name); +extern bool (FASTCALL* auth_3d_data_check_category_loaded)(const char* category_name); +extern void (FASTCALL* auth_3d_data_load_category)(const char* category_name); +extern void (FASTCALL* auth_3d_data_unload_category)(const char* category_name); + +extern int32_t auth_3d_data_get_auth_3d_id(uint32_t uid, object_info obj_info, + int32_t* object_index, bool* hrc, int32_t instance); diff --git a/src/DivaGL/bone_database.cpp b/src/AFTModsShared/bone_database.cpp similarity index 100% rename from src/DivaGL/bone_database.cpp rename to src/AFTModsShared/bone_database.cpp diff --git a/src/DivaGL/bone_database.hpp b/src/AFTModsShared/bone_database.hpp similarity index 100% rename from src/DivaGL/bone_database.hpp rename to src/AFTModsShared/bone_database.hpp diff --git a/src/AFTModsShared/camera.cpp b/src/AFTModsShared/camera.cpp new file mode 100644 index 0000000..4a689f5 --- /dev/null +++ b/src/AFTModsShared/camera.cpp @@ -0,0 +1,18 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "camera.hpp" +#include "resolution_mode.hpp" + +camera_struct& camera_data = *(camera_struct*)0x0000000140FBC2C0; + +void camera_struct::get_view_point(vec3& value) { + value = view_point; +} + +void camera_struct::get_view_point(vec4& value) { + *(vec3*)&value = view_point; + value.w = 0.0f; +} diff --git a/src/AFTModsShared/camera.hpp b/src/AFTModsShared/camera.hpp new file mode 100644 index 0000000..594e806 --- /dev/null +++ b/src/AFTModsShared/camera.hpp @@ -0,0 +1,60 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/mat.hpp" +#include "../KKdLib/vec.hpp" + +struct camera_struct { + vec3 view_point; + vec3 interest; + float_t roll; + float_t fov; + float_t aet_fov; + int32_t field_24; + double_t aspect; + float_t min_distance; + float_t max_distance; + float_t proj_left_offset; + float_t proj_right_offset; + float_t proj_bottom_offset; + float_t proj_top_offset; + bool use_up; + char field_49; + char field_4A; + char field_4B; + vec3 up; + bool ignore_fov; + bool ignore_min_dist; + char field_5A; + char field_5B; + mat4 view; + mat4 inv_view; + mat4 projection; + mat4 view_projection; + mat4 view_projection_aet_2d; + mat4 view_projection_aet_3d; + float_t depth; + float_t aet_depth; + vec3 field_1E4; + vec3 field_1F0; + vec3 field_1FC; + vec3 field_208; + float_t distance; + vec3 rotation; + float_t fov_horizontal_rad; + char field_228; + bool fast_change; + bool fast_change_hist0; + bool fast_change_hist1; + int32_t field_22C; + + void get_view_point(vec3& value); + void get_view_point(vec4& value); +}; + +extern camera_struct& camera_data; diff --git a/src/DivaGL/canonical_properties.cpp b/src/AFTModsShared/canonical_properties.cpp similarity index 100% rename from src/DivaGL/canonical_properties.cpp rename to src/AFTModsShared/canonical_properties.cpp diff --git a/src/DivaGL/canonical_properties.hpp b/src/AFTModsShared/canonical_properties.hpp similarity index 96% rename from src/DivaGL/canonical_properties.hpp rename to src/AFTModsShared/canonical_properties.hpp index 3b9dd77..dfc2785 100644 --- a/src/DivaGL/canonical_properties.hpp +++ b/src/AFTModsShared/canonical_properties.hpp @@ -5,7 +5,7 @@ #pragma once -#include "types.hpp" +#include "../AFTModsShared/types.hpp" #include struct CanonicalProperties { diff --git a/src/DivaGL/color.cpp b/src/AFTModsShared/color.cpp similarity index 100% rename from src/DivaGL/color.cpp rename to src/AFTModsShared/color.cpp diff --git a/src/DivaGL/color.hpp b/src/AFTModsShared/color.hpp similarity index 100% rename from src/DivaGL/color.hpp rename to src/AFTModsShared/color.hpp diff --git a/src/DivaGL/dw.cpp b/src/AFTModsShared/dw.cpp similarity index 100% rename from src/DivaGL/dw.cpp rename to src/AFTModsShared/dw.cpp diff --git a/src/DivaGL/dw.hpp b/src/AFTModsShared/dw.hpp similarity index 100% rename from src/DivaGL/dw.hpp rename to src/AFTModsShared/dw.hpp diff --git a/src/DivaGL/file_handler.cpp b/src/AFTModsShared/file_handler.cpp similarity index 100% rename from src/DivaGL/file_handler.cpp rename to src/AFTModsShared/file_handler.cpp diff --git a/src/DivaGL/file_handler.hpp b/src/AFTModsShared/file_handler.hpp similarity index 100% rename from src/DivaGL/file_handler.hpp rename to src/AFTModsShared/file_handler.hpp diff --git a/src/DivaGL/frame_rate_control.cpp b/src/AFTModsShared/frame_rate_control.cpp similarity index 100% rename from src/DivaGL/frame_rate_control.cpp rename to src/AFTModsShared/frame_rate_control.cpp diff --git a/src/DivaGL/frame_rate_control.hpp b/src/AFTModsShared/frame_rate_control.hpp similarity index 100% rename from src/DivaGL/frame_rate_control.hpp rename to src/AFTModsShared/frame_rate_control.hpp diff --git a/src/DivaGL/item_table.hpp b/src/AFTModsShared/item_table.hpp similarity index 100% rename from src/DivaGL/item_table.hpp rename to src/AFTModsShared/item_table.hpp diff --git a/src/AFTModsShared/light_param/fog.cpp b/src/AFTModsShared/light_param/fog.cpp new file mode 100644 index 0000000..96a271b --- /dev/null +++ b/src/AFTModsShared/light_param/fog.cpp @@ -0,0 +1,60 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "fog.hpp" + +fog* fog_data = (fog*)0x00000001411974D0; + +fog_type fog::get_type() const { + return type; +} + +void fog::set_type(fog_type value) { + type = value; +} + +float_t fog::get_density() const { + return density; +} + +void fog::set_density(float_t value) { + density = value; +} + +float_t fog::get_start() const { + return start; +} + +void fog::set_start(float_t value) { + start = value; +} + +float_t fog::get_end() const { + return end; +} + +void fog::set_end(float_t value) { + end = value; +} + +int32_t fog::get_index() const { + return index; +} + +void fog::set_index(int32_t value) { + index = value; +} + +void fog::get_color(vec4& value) const { + value = color; +} + +void fog::set_color(const vec4& value) { + color = value; +} + +void fog::set_color(const vec4&& value) { + color = value; +} diff --git a/src/DivaGL/light_param/fog.hpp b/src/AFTModsShared/light_param/fog.hpp similarity index 97% rename from src/DivaGL/light_param/fog.hpp rename to src/AFTModsShared/light_param/fog.hpp index 182df93..f3bcb8b 100644 --- a/src/DivaGL/light_param/fog.hpp +++ b/src/AFTModsShared/light_param/fog.hpp @@ -43,7 +43,6 @@ struct fog { void get_color(vec4& value) const; void set_color(const vec4& value); void set_color(const vec4&& value); - void data_set(fog_id id); }; static_assert(sizeof(fog) == 0x24, "\"fog\" struct should have a size of 0x24"); diff --git a/src/AFTModsShared/light_param/light.cpp b/src/AFTModsShared/light_param/light.cpp new file mode 100644 index 0000000..d66d69a --- /dev/null +++ b/src/AFTModsShared/light_param/light.cpp @@ -0,0 +1,302 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "light.hpp" +#include "../../KKdLib/mat.hpp" +#include "../../AFTModsShared/uniform.hpp" + +light_set* light_set_data = (light_set*)0x00000001411A00A0; + +light_type light_data::get_type() const { + return type; +} + +void light_data::set_type(light_type value) { + type = value; + if (value < LIGHT_POINT) + position.w = 0.0f; + else + position.w = 1.0f; +} + +void light_data::get_ambient(vec4& value) const { + value = ambient; +} + +void light_data::set_ambient(const vec4& value) { + ambient = value; +} + +void light_data::set_ambient(const vec4&& value) { + ambient = value; +} + +void light_data::set_ambient(const vec4& value, bool set[4]) { + if (set[0]) + ambient.x = value.x; + if (set[1]) + ambient.y = value.y; + if (set[2]) + ambient.z = value.z; + if (set[3]) + ambient.w = value.w; +} + +void light_data::set_ambient(const vec4&& value, bool set[4]) { + if (set[0]) + ambient.x = value.x; + if (set[1]) + ambient.y = value.y; + if (set[2]) + ambient.z = value.z; + if (set[3]) + ambient.w = value.w; +} + +void light_data::get_diffuse(vec4& value) const { + value = diffuse; +} + +void light_data::set_diffuse(const vec4& value) { + diffuse = value; +} + +void light_data::set_diffuse(const vec4&& value) { + diffuse = value; +} + +void light_data::set_diffuse(const vec4& value, bool set[4]) { + if (set[0]) + diffuse.x = value.x; + if (set[1]) + diffuse.y = value.y; + if (set[2]) + diffuse.z = value.z; + if (set[3]) + diffuse.w = value.w; +} + +void light_data::set_diffuse(const vec4&& value, bool set[4]) { + if (set[0]) + diffuse.x = value.x; + if (set[1]) + diffuse.y = value.y; + if (set[2]) + diffuse.z = value.z; + if (set[3]) + diffuse.w = value.w; +} + +void light_data::get_specular(vec4& value) const { + value = specular; +} + +void light_data::set_specular(const vec4& value) { + specular = value; +} + +void light_data::set_specular(const vec4&& value) { + specular = value; +} + +void light_data::set_specular(const vec4& value, bool set[4]) { + if (set[0]) + specular.x = value.x; + if (set[1]) + specular.y = value.y; + if (set[2]) + specular.z = value.z; + if (set[3]) + specular.w = value.w; +} + +void light_data::set_specular(const vec4&& value, bool set[4]) { + if (set[0]) + specular.x = value.x; + if (set[1]) + specular.y = value.y; + if (set[2]) + specular.z = value.z; + if (set[3]) + specular.w = value.w; +} + +void light_data::get_position(vec3& value) const { + value = *(vec3*)&position; +} + +void light_data::set_position(const vec3& value) { + *(vec3*)&position = value; +} + +void light_data::set_position(const vec3&& value) { + *(vec3*)&position = value; +} + +void light_data::get_position(vec4& value) const { + value = position; +} + +void light_data::set_position(const vec4& value) { + position = value; +} + +void light_data::set_position(const vec4&& value) { + position = value; +} + +void light_data::get_spot_direction(vec3& value) const { + value = spot_direction; +} + +void light_data::set_spot_direction(const vec3& value) { + spot_direction = value; +} + +void light_data::set_spot_direction(const vec3&& value) { + spot_direction = value; +} + +float_t light_data::get_spot_exponent() const { + return spot_exponent; +} + +void light_data::set_spot_exponent(float_t value) { + spot_exponent = value; +} + +float_t light_data::get_spot_cutoff() const { + return spot_cutoff; +} + +void light_data::set_spot_cutoff(float_t value) { + spot_cutoff = value; +} + +float_t light_data::get_constant() const { + return attenuation.constant; +} + +void light_data::set_constant(float_t value) { + attenuation.constant = value; +} + +float_t light_data::get_linear() const { + return attenuation.linear; +} + +void light_data::set_linear(float_t value) { + attenuation.linear = value; +} + +float_t light_data::get_quadratic() const { + return attenuation.quadratic; +} + +void light_data::set_quadratic(float_t value) { + attenuation.quadratic = value; +} + +void light_data::get_attenuation(light_attenuation& value) const { + value = attenuation; +} + +void light_data::set_attenuation(const light_attenuation& value) { + attenuation = value; +} + +void light_data::set_attenuation(const light_attenuation&& value) { + attenuation = value; +} + +void light_data::get_ibl_color0(vec4& value) const { + value = ibl_color0; +} + +void light_data::set_ibl_color0(const vec4& value) { + ibl_color0 = value; +} + +void light_data::set_ibl_color0(const vec4&& value) { + ibl_color0 = value; +} + +void light_data::get_ibl_color1(vec4& value) const { + value = ibl_color1; +} + +void light_data::set_ibl_color1(const vec4& value) { + ibl_color1 = value; +} + +void light_data::set_ibl_color1(const vec4&& value) { + ibl_color1 = value; +} + +void light_data::get_ibl_direction(vec4& value) const { + value = ibl_direction; +} + +void light_data::set_ibl_direction(const vec4& value) { + ibl_direction = value; +} + +void light_data::set_ibl_direction(const vec4&& value) { + ibl_direction = value; +} + +void light_data::get_tone_curve(light_tone_curve& value) const { + value = tone_curve; +} + +void light_data::set_tone_curve(const light_tone_curve& value) { + tone_curve = value; +} + +void light_data::set_tone_curve(const light_tone_curve&& value) { + tone_curve = value; +} + +void light_data::get_clip_plane(light_clip_plane& value) const { + value = clip_plane; +} + +void light_data::set_clip_plane(const light_clip_plane& value) { + clip_plane = value; +} + +void light_data::set_clip_plane(const light_clip_plane&& value) { + clip_plane = value; +} + +void light_set::get_ambient_intensity(vec4& value) const { + value = ambient_intensity; +} + +void light_set::set_ambient_intensity(const vec4& value) { + ambient_intensity = value; +} + +void light_set::set_ambient_intensity(const vec4&& value) { + ambient_intensity = value; +} + +void light_set::get_irradiance(mat4& r, mat4& g, mat4& b) const { + r = irradiance_r; + g = irradiance_g; + b = irradiance_b; +} + +void light_set::set_irradiance(const mat4& r, const mat4& g, const mat4& b) { + irradiance_r = r; + irradiance_g = g; + irradiance_b = b; +} + +void light_set::set_irradiance(const mat4&& r, const mat4&& g, const mat4&& b) { + irradiance_r = r; + irradiance_g = g; + irradiance_b = b; +} diff --git a/src/DivaGL/light_param/light.hpp b/src/AFTModsShared/light_param/light.hpp similarity index 97% rename from src/DivaGL/light_param/light.hpp rename to src/AFTModsShared/light_param/light.hpp index 8a9f6db..a62659b 100644 --- a/src/DivaGL/light_param/light.hpp +++ b/src/AFTModsShared/light_param/light.hpp @@ -130,13 +130,12 @@ struct light_set { mat4 irradiance_g; mat4 irradiance_b; - void get_ambient_intensity(vec4& value); + void get_ambient_intensity(vec4& value) const; void set_ambient_intensity(const vec4& value); void set_ambient_intensity(const vec4&& value); - void get_irradiance(mat4& r, mat4& g, mat4& b); + void get_irradiance(mat4& r, mat4& g, mat4& b) const; void set_irradiance(const mat4& r, const mat4& g, const mat4& b); void set_irradiance(const mat4&& r, const mat4&& g, const mat4&& b); - void data_set(light_set_id id); }; static_assert(sizeof(light_set) == 0x5F0, "\"light_set\" struct should have a size of 0x5F0"); diff --git a/src/AFTModsShared/mdl/disp_manager.cpp b/src/AFTModsShared/mdl/disp_manager.cpp new file mode 100644 index 0000000..9383eee --- /dev/null +++ b/src/AFTModsShared/mdl/disp_manager.cpp @@ -0,0 +1,6 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "disp_manager.hpp" diff --git a/src/AFTModsShared/mdl/disp_manager.hpp b/src/AFTModsShared/mdl/disp_manager.hpp new file mode 100644 index 0000000..751808c --- /dev/null +++ b/src/AFTModsShared/mdl/disp_manager.hpp @@ -0,0 +1,95 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../../KKdLib/default.hpp" +#include "../../KKdLib/mat.hpp" +#include "../../KKdLib/vec.hpp" +#include "../object.hpp" +#include "../texture.hpp" + +namespace mdl { + enum ObjFlags : uint32_t { + OBJ_SHADOW = 0x00000001, + OBJ_2 = 0x00000002, + OBJ_4 = 0x00000004, + OBJ_8 = 0x00000008, + OBJ_10 = 0x00000010, + OBJ_20 = 0x00000020, + OBJ_40 = 0x00000040, + OBJ_SHADOW_OBJECT = 0x00000080, + OBJ_CHARA_REFLECT = 0x00000100, + OBJ_REFLECT = 0x00000200, + OBJ_REFRACT = 0x00000400, + OBJ_800 = 0x00000800, + OBJ_TRANSLUCENT_SORT_BY_RADIUS = 0x00001000, + OBJ_SSS = 0x00002000, + OBJ_4000 = 0x00004000, + OBJ_8000 = 0x00008000, + OBJ_ALPHA_ORDER_1 = 0x00010000, + OBJ_ALPHA_ORDER_2 = 0x00020000, + OBJ_ALPHA_ORDER_3 = 0x00040000, + OBJ_80000 = 0x00080000, + OBJ_100000 = 0x00100000, + OBJ_200000 = 0x00200000, + OBJ_400000 = 0x00400000, + OBJ_800000 = 0x00800000, + OBJ_USER = 0x01000000, + OBJ_2000000 = 0x02000000, + OBJ_4000000 = 0x04000000, + OBJ_8000000 = 0x08000000, + OBJ_10000000 = 0x10000000, + OBJ_20000000 = 0x20000000, + OBJ_40000000 = 0x40000000, + OBJ_NO_TRANSLUCENCY = 0x80000000, + }; +} + +struct texture_pattern_struct { + texture_id src; + texture_id dst; + + inline texture_pattern_struct() { + + } + + inline texture_pattern_struct(texture_id src, texture_id dst) : src(src), dst(dst) { + + } +}; + +static_assert(sizeof(texture_pattern_struct) == 0x08, "\"texture_pattern_struct\" struct should have a size of 0x08"); + +struct texture_transform_struct { + uint32_t id; + mat4 mat; + + inline texture_transform_struct() { + id = (uint32_t)-1; + mat = mat4_identity; + } + + inline texture_transform_struct(uint32_t id, const mat4& mat) : id(id), mat(mat) { + + } +}; + +static_assert(sizeof(texture_transform_struct) == 0x44, "\"texture_pattern_struct\" struct should have a size of 0x44"); + +struct texture_data_struct { + int32_t field_0; + vec3 texture_color_coefficients; + vec3 texture_color_offset; + vec3 texture_specular_coefficients; + vec3 texture_specular_offset; + + inline texture_data_struct() : field_0(), texture_color_coefficients(), + texture_color_offset(), texture_specular_coefficients(), texture_specular_offset() { + + } +}; + +static_assert(sizeof(texture_data_struct) == 0x34, "\"texture_pattern_struct\" struct should have a size of 0x34"); diff --git a/src/AFTModsShared/object.cpp b/src/AFTModsShared/object.cpp new file mode 100644 index 0000000..d404c95 --- /dev/null +++ b/src/AFTModsShared/object.cpp @@ -0,0 +1,141 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "object.hpp" +#include "../KKdLib/hash.hpp" +#include "../AFTModsShared/file_handler.hpp" +#include + +void (FASTCALL* objset_info_storage_unload_set)(int32_t set) + = (void (FASTCALL*)(int32_t set))0x00000001404599B0; +obj_mesh* (FASTCALL* objset_info_storage_get_obj_mesh_by_index)(uint32_t obj_info, int32_t mesh_index) + = (obj_mesh * (FASTCALL*)(uint32_t obj_info, int32_t mesh_index))0x0000000140459D40; +int32_t(FASTCALL* objset_info_storage_get_obj_mesh_index)(uint32_t obj_info, const char* mesh_name) + = (int32_t(FASTCALL*)(uint32_t obj_info, const char* mesh_name))0x0000000140459DE0; +const char* (FASTCALL* object_database_get_obj_name)(uint32_t obj_info) + = (const char* (FASTCALL*)(uint32_t obj_info))0x0000000140459F20; +uint32_t(FASTCALL* object_database_get_object_info)(const char* name) + = (uint32_t(FASTCALL*)(const char* name))0x0000000140459F80; +obj* (FASTCALL* objset_info_storage_get_obj)(uint32_t obj_info) + = (obj * (FASTCALL*)(uint32_t obj_info))0x000000014045A140; +obj_skin* (FASTCALL* objset_info_storage_get_obj_skin)(uint32_t obj_info) + = (obj_skin * (FASTCALL*)(uint32_t obj_info))0x000000014045A3E0; +int32_t(FASTCALL* objset_info_storage_get_set_obj_id)(int32_t set_index, int32_t obj_index) + = (int32_t(FASTCALL*)(int32_t set_index, int32_t obj_index))0x000000014045A750; +int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index) + = (int32_t(FASTCALL*)(int32_t set_index))0x000000014045AA10; +int32_t(FASTCALL* object_database_get_object_set_id)(const char* name) + = (int32_t(FASTCALL*)(const char* name))0x000000014045AA60; +const char* (FASTCALL* objset_info_storage_get_set_name)(int32_t set_id) + = (const char* (FASTCALL*)(int32_t set_id))0x000000014045AC80; +int32_t(FASTCALL* objset_info_storage_get_set_tex_num)(int32_t set) + = (int32_t(FASTCALL*)(int32_t set))0x000000014045ADE0; +texture** (FASTCALL* objset_info_storage_get_set_textures)(int32_t set) + = (texture * *(FASTCALL*)(int32_t set))0x000000014045AE20; +int32_t(FASTCALL* objset_info_storage_load_set)(int32_t set) + = (int32_t(FASTCALL*)(int32_t set))0x000000014045C6A0; +bool (FASTCALL* objset_info_storage_load_obj_set_check_not_read)(int32_t set) + = (bool(FASTCALL*)(int32_t set))0x000000014045DA60; + +obj_material_shader_lighting_type obj_material_shader_attrib::get_lighting_type() const { + if (!m.is_lgt_diffuse && !m.is_lgt_specular) + return OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT; + else if (!m.is_lgt_specular) + return OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT; + else + return OBJ_MATERIAL_SHADER_LIGHTING_PHONG; +} + +int32_t obj_texture_attrib::get_blend() const { + switch (m.blend) { + case 4: + return 2; + case 6: + return 1; + case 16: + return 3; + default: + return 0; + } +} + +void obj_mesh_vertex_buffer::cycle_index() { + if (++index >= count) + index = 0; +} + +AFTGLuint obj_mesh_vertex_buffer::get_buffer() { + if (index < count) + return buffers[index]; + return 0; +} + +inline int32_t obj_material_texture_type_get_texcoord_index( + obj_material_texture_type type, int32_t index) { + switch (type) { + case OBJ_MATERIAL_TEXTURE_COLOR: + if (index < 2) + return index; + case OBJ_MATERIAL_TEXTURE_NORMAL: + case OBJ_MATERIAL_TEXTURE_SPECULAR: + return 0; + case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY: + case OBJ_MATERIAL_TEXTURE_TRANSPARENCY: + return 1; + } + return -1; +} + +inline int32_t obj_material_texture_type_get_texture_index( + obj_material_texture_type type, int32_t base_index) { + switch (type) { + case OBJ_MATERIAL_TEXTURE_COLOR: + if (base_index < 2) + return base_index; + case OBJ_MATERIAL_TEXTURE_NORMAL: + return 2; + case OBJ_MATERIAL_TEXTURE_SPECULAR: + return 3; + case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY: + return 1; + case OBJ_MATERIAL_TEXTURE_TRANSPARENCY: + return 4; + case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE: // AFT + case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE: + return 5; + } + return -1; +} + +void obj_skin_set_matrix_buffer(obj_skin* s, const mat4* matrices, + const mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4& global_mat) { + if (!s->num_bone) + return; + + uint32_t* bone_id = s->bone_id_array; + mat4* bone_matrix = s->bone_matrix_array; + if (mat) + for (int32_t i = 0; i < s->num_bone; i++, bone_id++, bone_matrix++, matrix_buffer++) { + mat4 temp; + if (*bone_id & 0x8000) + mat4_mul(&ex_data_matrices[*bone_id & 0x7FFF], mat, &temp); + else + mat4_mul(&matrices[*bone_id], mat, &temp); + + mat4_mul(&global_mat, &temp, &temp); + mat4_mul(&temp, bone_matrix, matrix_buffer); + } + else + for (int32_t i = 0; i < s->num_bone; i++, bone_id++, bone_matrix++, matrix_buffer++) { + mat4 temp; + if (*bone_id & 0x8000) + temp = ex_data_matrices[*bone_id & 0x7FFF]; + else + temp = matrices[*bone_id]; + + mat4_mul(&global_mat, &temp, &temp); + mat4_mul(&temp, bone_matrix, matrix_buffer); + } +} diff --git a/src/AFTModsShared/object.hpp b/src/AFTModsShared/object.hpp new file mode 100644 index 0000000..ce9cf0d --- /dev/null +++ b/src/AFTModsShared/object.hpp @@ -0,0 +1,551 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/mat.hpp" +#include "../KKdLib/vec.hpp" +#include "texture.hpp" +#include "types.hpp" + +enum obj_index_format : uint32_t { + OBJ_INDEX_U8 = 0x00, + OBJ_INDEX_U16 = 0x01, + OBJ_INDEX_U32 = 0x02, +}; + +enum obj_material_aniso_direction : uint32_t { + OBJ_MATERIAL_ANISO_DIRECTION_NORMAL = 0, + OBJ_MATERIAL_ANISO_DIRECTION_U = 1, + OBJ_MATERIAL_ANISO_DIRECTION_V = 2, + OBJ_MATERIAL_ANISO_DIRECTION_RADIAL = 3, +}; + +enum obj_material_blend_factor : uint32_t { + OBJ_MATERIAL_BLEND_ZERO = 0, + OBJ_MATERIAL_BLEND_ONE = 1, + OBJ_MATERIAL_BLEND_SRC_COLOR = 2, + OBJ_MATERIAL_BLEND_INVERSE_SRC_COLOR = 3, + OBJ_MATERIAL_BLEND_SRC_ALPHA = 4, + OBJ_MATERIAL_BLEND_INVERSE_SRC_ALPHA = 5, + OBJ_MATERIAL_BLEND_DST_ALPHA = 6, + OBJ_MATERIAL_BLEND_INVERSE_DST_ALPHA = 7, + OBJ_MATERIAL_BLEND_DST_COLOR = 8, + OBJ_MATERIAL_BLEND_INVERSE_DST_COLOR = 9, + OBJ_MATERIAL_BLEND_ALPHA_SATURATE = 10, +}; + +enum obj_material_bump_map_type : uint32_t { + OBJ_MATERIAL_BUMP_MAP_NONE = 0, + OBJ_MATERIAL_BUMP_MAP_DOT = 1, + OBJ_MATERIAL_BUMP_MAP_ENV = 2, +}; + +enum obj_material_color_source_type : uint32_t { + OBJ_MATERIAL_COLOR_SOURCE_MATERIAL_COLOR = 0, + OBJ_MATERIAL_COLOR_SOURCE_VERTEX_COLOR = 1, + OBJ_MATERIAL_COLOR_SOURCE_VERTEX_MORPH = 2, +}; + +enum obj_material_shader_lighting_type : uint32_t { + OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT = 0x00, + OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT = 0x01, + OBJ_MATERIAL_SHADER_LIGHTING_PHONG = 0x02, +}; + +enum obj_material_specular_quality : uint32_t { + OBJ_MATERIAL_SPECULAR_QUALITY_LOW = 0, + OBJ_MATERIAL_SPECULAR_QUALITY_HIGH = 1, +}; + +enum obj_material_texture_type : uint32_t { + OBJ_MATERIAL_TEXTURE_NONE = 0x00, + OBJ_MATERIAL_TEXTURE_COLOR = 0x01, + OBJ_MATERIAL_TEXTURE_NORMAL = 0x02, + OBJ_MATERIAL_TEXTURE_SPECULAR = 0x03, + OBJ_MATERIAL_TEXTURE_HEIGHT = 0x04, + OBJ_MATERIAL_TEXTURE_REFLECTION = 0x05, + OBJ_MATERIAL_TEXTURE_TRANSLUCENCY = 0x06, + OBJ_MATERIAL_TEXTURE_TRANSPARENCY = 0x07, + OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE = 0x08, + OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE = 0x09, +}; + +enum obj_material_texture_coordinate_translation_type : uint32_t { + OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_NONE = 0x00, + OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_UV = 0x01, + OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_SPHERE = 0x02, + OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_CUBE = 0x03, +}; + +enum obj_material_vertex_translation_type : uint32_t { + OBJ_MATERIAL_VERTEX_TRANSLATION_DEFAULT = 0, + OBJ_MATERIAL_VERTEX_TRANSLATION_ENVELOPE = 1, + OBJ_MATERIAL_VERTEX_TRANSLATION_MORPHING = 2, +}; + +enum obj_primitive_type : uint32_t { + OBJ_PRIMITIVE_POINTS = 0x00, + OBJ_PRIMITIVE_LINES = 0x01, + OBJ_PRIMITIVE_LINE_STRIP = 0x02, + OBJ_PRIMITIVE_LINE_LOOP = 0x03, + OBJ_PRIMITIVE_TRIANGLES = 0x04, + OBJ_PRIMITIVE_TRIANGLE_STRIP = 0x05, + OBJ_PRIMITIVE_TRIANGLE_FAN = 0x06, + OBJ_PRIMITIVE_QUADS = 0x07, + OBJ_PRIMITIVE_QUAD_STRIP = 0x08, + OBJ_PRIMITIVE_POLYGON = 0x09, +}; + +enum obj_vertex_format : uint32_t { + OBJ_VERTEX_NONE = 0x0000, + OBJ_VERTEX_POSITION = 0x0001, + OBJ_VERTEX_NORMAL = 0x0002, + OBJ_VERTEX_TANGENT = 0x0004, + OBJ_VERTEX_BINORMAL = 0x0008, + OBJ_VERTEX_TEXCOORD0 = 0x0010, + OBJ_VERTEX_TEXCOORD1 = 0x0020, + OBJ_VERTEX_TEXCOORD2 = 0x0040, + OBJ_VERTEX_TEXCOORD3 = 0x0080, + OBJ_VERTEX_COLOR0 = 0x0100, + OBJ_VERTEX_COLOR1 = 0x0200, + OBJ_VERTEX_BONE_WEIGHT = 0x0400, + OBJ_VERTEX_BONE_INDEX = 0x0800, + OBJ_VERTEX_BONE_DATA = 0x0C00, + OBJ_VERTEX_UNKNOWN = 0x1000, +}; + +struct obj_axis_aligned_bounding_box { + vec3 center; + vec3 size; +}; + +struct obj_bounding_box { + vec3 center; + vec3 size; +}; + +struct obj_bounding_sphere { + vec3 center; + float_t radius; +}; + +struct obj_shader_compo_member { + uint32_t color : 1; + uint32_t color_a : 1; + uint32_t color_l1 : 1; + uint32_t color_l1_a : 1; + uint32_t color_l2 : 1; + uint32_t color_l2_a : 1; + uint32_t transparency : 1; + uint32_t specular : 1; + uint32_t normal_01 : 1; + uint32_t normal_02 : 1; + uint32_t envmap : 1; + uint32_t color_l3 : 1; + uint32_t color_l3_a : 1; + uint32_t translucency : 1; + uint32_t flag_14 : 1; + uint32_t override_ibl : 1; + uint32_t dummy : 16; +}; + +union obj_shader_compo { + obj_shader_compo_member m; + uint32_t w; +}; + +struct obj_material_shader_attrib_member { + obj_material_vertex_translation_type vtx_trans_type : 2; + obj_material_color_source_type col_src : 2; + uint32_t is_lgt_diffuse : 1; + uint32_t is_lgt_specular : 1; + uint32_t is_lgt_per_pixel : 1; + uint32_t is_lgt_double : 1; + obj_material_bump_map_type bump_map_type : 2; + uint32_t fresnel_type : 4; + uint32_t line_light : 4; + uint32_t recieve_shadow : 1; + uint32_t cast_shadow : 1; + obj_material_specular_quality specular_quality : 1; + obj_material_aniso_direction aniso_direction : 2; + uint32_t dummy : 9; +}; + +union obj_material_shader_attrib { + obj_material_shader_attrib_member m; + uint32_t w; + + obj_material_shader_lighting_type get_lighting_type() const; +}; + +struct obj_texture_attrib_member { + uint32_t repeat_u : 1; + uint32_t repeat_v : 1; + uint32_t mirror_u : 1; + uint32_t mirror_v : 1; + uint32_t ignore_alpha : 1; + uint32_t blend : 5; + uint32_t alpha_blend : 5; + uint32_t border : 1; + uint32_t clamp2edge : 1; + uint32_t filter : 3; + uint32_t mipmap : 2; + uint32_t mipmap_bias : 7; + uint32_t flag_29 : 1; + uint32_t anisotropic_filter : 2; +}; + +union obj_texture_attrib { + obj_texture_attrib_member m; + uint32_t w; + + int32_t get_blend() const; +}; + +struct obj_texture_shader_attrib_member { + obj_material_texture_type tex_type : 4; + int32_t uv_idx : 4; + obj_material_texture_coordinate_translation_type texcoord_trans : 3; + uint32_t dummy : 21; +}; + +union obj_texture_shader_attrib { + obj_texture_shader_attrib_member m; + uint32_t w; +}; + +struct obj_material_texture_data { + obj_texture_attrib attrib; + uint32_t tex_index; + obj_texture_shader_attrib shader_info; + char ex_shader[8]; + float_t weight; + mat4 tex_coord_mat; + uint32_t reserved[8]; +}; + +struct obj_material_attrib_member { + uint32_t alpha_texture : 1; + uint32_t alpha_material : 1; + uint32_t punch_through : 1; + uint32_t double_sided : 1; + uint32_t normal_dir_light : 1; + obj_material_blend_factor src_blend_factor : 4; + obj_material_blend_factor dst_blend_factor : 4; + uint32_t blend_operation : 3; + uint32_t zbias : 4; + uint32_t no_fog : 1; + uint32_t translucent_priority : 6; + uint32_t has_fog_height : 1; + uint32_t flag_28 : 1; + uint32_t fog_height : 1; + uint32_t flag_30 : 1; + uint32_t flag_31 : 1; +}; + +union obj_material_attrib { + obj_material_attrib_member m; + uint32_t w; +}; + +struct obj_material_color { + vec4 diffuse; + vec4 ambient; + vec4 specular; + vec4 emission; + float_t shininess; + float_t intensity; +}; + +struct obj_material { + obj_shader_compo shader_compo; + union { + char name[8]; + int32_t index; + } shader; + obj_material_shader_attrib shader_info; + obj_material_texture_data texdata[8]; + obj_material_attrib attrib; + obj_material_color color; + vec3 center; + float_t radius; + char name[64]; + float_t bump_depth; + uint32_t reserved[15]; +}; + +struct obj_material_data { + int32_t num_of_textures; + obj_material material; +}; + +struct obj_sub_mesh_attrib_member { + uint32_t recieve_shadow : 1; + uint32_t cast_shadow : 1; + uint32_t translucent : 1; + uint32_t cloth : 1; + uint32_t no_reflect : 1; // Own stuff + uint32_t reflect : 1; // Own stuff + uint32_t reflect_cam_back : 1; // Own stuff + uint32_t dummy : 25; // 28 +}; + +union obj_sub_mesh_attrib { + obj_sub_mesh_attrib_member m; + uint32_t w; +}; + +struct obj_sub_mesh { + uint32_t flags; + obj_bounding_sphere bounding_sphere; + uint32_t material_index; + uint8_t uv_index[8]; + int32_t num_bone_index; + uint16_t* bone_index_array; + uint32_t bones_per_vertex; + obj_primitive_type primitive_type; + obj_index_format index_format; + int32_t num_index; + void* index_array; + obj_sub_mesh_attrib attrib; + uint32_t reserved[4]; + obj_axis_aligned_bounding_box* axis_aligned_bounding_box; + uint16_t first_index; + uint16_t last_index; + uint32_t index_offset; +}; + +static_assert(sizeof(obj_sub_mesh) == 0x70, "\"obj_sub_mesh\" struct should have a size of 0x70"); + +struct obj_mesh_attrib_member { + uint32_t double_buffer : 1; + uint32_t billboard_y_axis : 1; + uint32_t translucent_sort_by_radius : 1; + uint32_t billboard : 1; + uint32_t no_reflect : 1; // Own stuff + uint32_t reflect : 1; // Own stuff + uint32_t reflect_cam_back : 1; // Own stuff + uint32_t disable_aabb_culling : 1; // Own stuff + uint32_t dummy : 22; // 28 + uint32_t compression : 2; // Own stuff +}; + +union obj_mesh_attrib { + obj_mesh_attrib_member m; + uint32_t w; +}; + +struct obj_mesh_vertex_array { + vec3* position; + vec3* normal; + vec4* tangent; + vec3* binormal; + vec2* texcoord0; + vec2* texcoord1; + vec2* texcoord2; + vec2* texcoord3; + vec4* color0; + vec4* color1; + vec4* bone_weight; + vec4* bone_index; + vec4* unknown; + void* field_68; + void* field_70; + void* field_78; + void* field_80; + void* field_88; + void* field_90; + void* field_98; +}; + +static_assert(sizeof(obj_mesh_vertex_array) == 0xA0, "\"obj_mesh_vertex_array\" struct should have a size of 0xA0"); + +struct obj_mesh { + uint32_t flags; + obj_bounding_sphere bounding_sphere; + int32_t num_submesh; + obj_sub_mesh* submesh_array; + obj_vertex_format vertex_format; + uint32_t size_vertex; + int32_t num_vertex; + union { + obj_mesh_vertex_array vertex_array; + void* vertex_array_ptr[20]; + }; + obj_mesh_attrib attrib; + uint32_t vertex_flags; + uint32_t reserved[6]; + char name[0x40]; +}; + +static_assert(sizeof(obj_mesh) == 0x130, "\"obj_mesh\" struct should have a size of 0x130"); + +struct obj { + uint32_t version; + uint32_t flags; + obj_bounding_sphere bounding_sphere; + int32_t num_mesh; + obj_mesh* mesh_array; + int32_t num_material; + obj_material_data* material_array; + uint32_t reserved[10]; +}; + +static_assert(sizeof(obj) == 0x60, "\"obj\" struct should have a size of 0x60"); + +struct obj_skin_ex_data { + int32_t num_osage_name; + int32_t num_osage_node; + const char** field_8; + struct obj_skin_osage_node* osage_node_array; + const char** osage_name_array; + struct obj_skin_block* block_array; + int32_t num_bone_name; + const char** bone_name_array; + struct obj_skin_osage_sibling_info* osage_sibling_infos; + uint32_t cloth_count; + uint32_t reserved[7]; +}; + +static_assert(sizeof(obj_skin_ex_data) == 0x60, "\"obj_skin_ex_data\" struct should have a size of 0x60"); + +struct obj_skin { + uint32_t* bone_id_array; + mat4* bone_matrix_array; + const char** bone_name_array; + obj_skin_ex_data* ex_data; + int32_t num_bone; + int32_t bone_parent_ids_offset; + int32_t field_28; + int32_t field_2C; + int32_t field_30; +}; + +static_assert(sizeof(obj_skin) == 0x38, "\"obj_skin\" struct should have a size of 0x38"); + +struct obj_set { + uint32_t version; + int32_t obj_num; + uint32_t last_obj_id; + obj** obj_data; + obj_skin** obj_skin_data; + const char** obj_name_data; + uint32_t* obj_id_data; + uint32_t* tex_id_data; + int32_t tex_num; + uint32_t reserved[2]; +}; + +static_assert(sizeof(obj_set) == 0x48, "\"obj_set\" struct should have a size of 0x48"); + +struct object_info { + uint16_t id; + uint16_t set_id; + + inline object_info() { + this->id = (uint16_t)-1; + this->set_id = (uint16_t)-1; + } + + inline object_info(uint16_t id, uint16_t set_id) { + this->id = id; + this->set_id = set_id; + } + + inline object_info(uint32_t data) { + this->id = (uint16_t)data; + this->set_id = (uint16_t)(data >> 16); + } + + inline bool is_null() const { + return id == (uint16_t)-1 && set_id == (uint16_t)-1; + } + + inline bool not_null() const { + return id != (uint16_t)-1 || set_id != (uint16_t)-1; + } + + inline operator uint32_t() { + return ((uint32_t)set_id << 16) | id; + } +}; + +static_assert(sizeof(object_info) == 0x04, "\"object_info\" struct should have a size of 0x04"); + +inline bool operator >(const object_info& left, const object_info& right) { + return *(uint32_t*)&left > *(uint32_t*)&right; +} + +inline bool operator <(const object_info& left, const object_info& right) { + return *(uint32_t*)&left < *(uint32_t*)&right; +} + +inline bool operator >=(const object_info& left, const object_info& right) { + return *(uint32_t*)&left >= *(uint32_t*)&right; +} + +inline bool operator <=(const object_info& left, const object_info& right) { + return *(uint32_t*)&left <= *(uint32_t*)&right; +} + +inline bool operator ==(const object_info& left, const object_info& right) { + return *(uint32_t*)&left == *(uint32_t*)&right; +} + +inline bool operator !=(const object_info& left, const object_info& right) { + return *(uint32_t*)&left != *(uint32_t*)&right; +} + +struct obj_mesh_index_buffer { + AFTGLuint buffer; + + inline obj_mesh_index_buffer() : buffer() { + + } +}; + +static_assert(sizeof(obj_mesh_index_buffer) == 0x04, "\"obj_mesh_index_buffer\" struct should have a size of 0x04"); + +struct obj_mesh_vertex_buffer { + int32_t count; + AFTGLuint buffers[3]; + int32_t index; + AFTGLenum target; + + inline obj_mesh_vertex_buffer() : count(), buffers(), index(), target(0x8892) { // GL_ARRAY_BUFFER + + } + + void cycle_index(); + AFTGLuint get_buffer(); +}; + +static_assert(sizeof(obj_mesh_vertex_buffer) == 0x18, "\"obj_mesh_vertex_buffer\" struct should have a size of 0x18"); + +extern void (FASTCALL* objset_info_storage_unload_set)(int32_t set); +extern obj_mesh* (FASTCALL* objset_info_storage_get_obj_mesh_by_index)(uint32_t obj_info, int32_t mesh_index); +extern int32_t(FASTCALL* objset_info_storage_get_obj_mesh_index)(uint32_t obj_info, const char* mesh_name); +extern const char* (FASTCALL* object_database_get_obj_name)(uint32_t obj_info); +extern uint32_t(FASTCALL* object_database_get_object_info)(const char* name); +extern obj* (FASTCALL* objset_info_storage_get_obj)(uint32_t obj_info); +extern obj_skin* (FASTCALL* objset_info_storage_get_obj_skin)(uint32_t obj_info); +extern int32_t(FASTCALL* objset_info_storage_get_set_obj_id)(int32_t set_index, int32_t obj_index); +extern int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index); +extern int32_t(FASTCALL* object_database_get_object_set_id)(const char* name); +extern const char* (FASTCALL* objset_info_storage_get_set_name)(int32_t set_id); +extern int32_t(FASTCALL* objset_info_storage_get_set_tex_num)(int32_t set); +extern texture** (FASTCALL* objset_info_storage_get_set_textures)(int32_t set); +extern int32_t(FASTCALL* objset_info_storage_load_set)(int32_t set); +extern bool (FASTCALL* objset_info_storage_load_obj_set_check_not_read)(int32_t set); + +extern int32_t obj_material_texture_type_get_texcoord_index( + obj_material_texture_type type, int32_t index); +extern int32_t obj_material_texture_type_get_texture_index( + obj_material_texture_type type, int32_t base_index); + +extern void obj_skin_set_matrix_buffer(obj_skin* s, const mat4* matrices, + const mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4& global_mat); diff --git a/src/DivaGL/print_work.cpp b/src/AFTModsShared/print_work.cpp similarity index 99% rename from src/DivaGL/print_work.cpp rename to src/AFTModsShared/print_work.cpp index fc281d1..d8f0ae1 100644 --- a/src/DivaGL/print_work.cpp +++ b/src/AFTModsShared/print_work.cpp @@ -4,7 +4,7 @@ */ #include "print_work.hpp" -#include "shader_ft.hpp" +#include "shader.hpp" static const font_character font_character_null = {}; @@ -182,7 +182,7 @@ void PrintWork::DrawTextMesh(app::text_flags flags, sprite_text_mesh& mesh) { args.SetVertexArray(mesh.vertices.data(), mesh.vertices.size()); if (flags & app::TEXT_FLAG_FONT) - args.shader = SHADER_FT_FONT; + args.shader = _FONT; args.id.index = mesh.sprite_id; spr::put_sprite(args); } diff --git a/src/DivaGL/print_work.hpp b/src/AFTModsShared/print_work.hpp similarity index 100% rename from src/DivaGL/print_work.hpp rename to src/AFTModsShared/print_work.hpp diff --git a/src/DivaGL/resolution_mode.cpp b/src/AFTModsShared/resolution_mode.cpp similarity index 100% rename from src/DivaGL/resolution_mode.cpp rename to src/AFTModsShared/resolution_mode.cpp diff --git a/src/DivaGL/resolution_mode.hpp b/src/AFTModsShared/resolution_mode.hpp similarity index 100% rename from src/DivaGL/resolution_mode.hpp rename to src/AFTModsShared/resolution_mode.hpp diff --git a/src/AFTModsShared/resource.h b/src/AFTModsShared/resource.h new file mode 100644 index 0000000..480b823 --- /dev/null +++ b/src/AFTModsShared/resource.h @@ -0,0 +1,8 @@ +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/AFTModsShared/rob/rob.cpp b/src/AFTModsShared/rob/rob.cpp new file mode 100644 index 0000000..bfd21a6 --- /dev/null +++ b/src/AFTModsShared/rob/rob.cpp @@ -0,0 +1,175 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "rob.hpp" +#include "../../KKdLib/str_utils.hpp" + +const mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index) + = (const mat4 * (FASTCALL*)(size_t rob_bone_data, size_t index))0x0000000140419520; +bool (FASTCALL* pv_osage_manager_array_get_disp)(int32_t* chara_id) + = (bool (FASTCALL*)(int32_t * chara_id))0x00000001404F9130; +const char* (FASTCALL* chara_index_get_auth_3d_name)(chara_index chara_index) + = (const char* (FASTCALL*)(chara_index chara_index))0x0000000140508100; +void(FASTCALL* sub_1405163C0)(rob_chara* rob_chr, int32_t index, mat4* mat) + = (void(FASTCALL*)(rob_chara* rob_chr, int32_t index, mat4 * mat))0x00000001405163C0; +float_t(FASTCALL* rob_chara_get_max_face_depth)(rob_chara* rob_chr) + = (float_t(FASTCALL*)(rob_chara* rob_chr))0x0000000140516510; +const mat4* (FASTCALL* rob_chara_get_bone_data_mat)(rob_chara* rob_chr, mot_bone_index index) + = (const mat4 * (FASTCALL*)(rob_chara* rob_chr, mot_bone_index index))0x0000000140516730; +const mat4* (FASTCALL* sub_140516740)(rob_chara* rob_chr) + = (const mat4 * (FASTCALL*)(rob_chara* rob_chr))0x0000000140516740; +bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr_smth, int32_t chara_id) + = (bool(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140531F50; +rob_chara* (FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id) + = (rob_chara * (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140532030; +size_t(FASTCALL* get_rob_chara_smth)() = (size_t(FASTCALL*)())0x00000001405320E0; +rob_chara_item_equip* (FASTCALL* rob_chara_array_get_item_equip)(size_t rob_chr_smth, int32_t chara_id) + = (rob_chara_item_equip * (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140532120; +size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id) + = (size_t(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405320F0; +bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id) + = (bool (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405327B0; + +rob_chara* rob_chara_array = (rob_chara*)0x00000001411B76A0; + +SkinParam::CollisionParam::CollisionParam() : type(), node_idx(), pos() { + radius = 0.2f; +} + +void RobOsage::SetAirRes(float_t air_res) { + skin_param_ptr->air_res = air_res; +} + +void RobOsage::SetColiR(float_t coli_r) { + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) + i->data_ptr->skp_osg_node.coli_r = coli_r; +} + +void RobOsage::SetForce(float_t force, float_t force_gain) { + skin_param_ptr->force = force; + skin_param_ptr->force_gain = force_gain; + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) { + i->data_ptr->force = force; + force = force * force_gain; + } +} + +void RobOsage::SetHinge(float_t hinge_y, float_t hinge_z) { + hinge_y = min_def(hinge_y, 179.0f); + hinge_z = min_def(hinge_z, 179.0f); + hinge_y = hinge_y * DEG_TO_RAD_FLOAT; + hinge_z = hinge_z * DEG_TO_RAD_FLOAT; + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) { + RobOsageNodeData* data = i->data_ptr; + data->skp_osg_node.hinge.ymin = -hinge_y; + data->skp_osg_node.hinge.ymax = hinge_y; + data->skp_osg_node.hinge.zmin = -hinge_z; + data->skp_osg_node.hinge.zmax = hinge_z; + } +} + +void RobOsage::SetInitRot(float_t init_rot_y, float_t init_rot_z) { + skin_param_ptr->init_rot.y = init_rot_y * DEG_TO_RAD_FLOAT; + skin_param_ptr->init_rot.z = init_rot_z * DEG_TO_RAD_FLOAT; +} + +void RobOsage::SetMotionResetData(uint32_t motion_id, float_t frame) { + osage_reset = true; + auto elem = motion_reset_data.find({ motion_id, (int32_t)prj::roundf(frame * 1000.0f) }); + if (elem != motion_reset_data.end() && elem->second.size() + 1 == nodes.size()) + reset_data_list = &elem->second; +} + +// 0x140480F40 +void RobOsage::SetNodesExternalForce(vec3* external_force, float_t strength) { + if (!external_force) { + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) + i->external_force = 0.0f; + return; + } + + vec3 v4 = *external_force; + size_t exf = osage_setting.exf; + size_t v8 = 0; + if (exf >= 4) { + float_t strength4 = strength * strength * strength * strength; + v8 = ((exf - 4) / 4 + 1) * 4; + for (size_t v10 = v8 / 4; v10; v10--) + v4 *= strength4; + } + + if (v8 < exf) + for (size_t v12 = exf - v8; v12; v12--) + v4 *= strength; + + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) { + i->external_force = v4; + v4 *= strength; + } +} + +// 0x140481540 +void RobOsage::SetNodesForce(float_t force) { + RobOsageNode* i_begin = nodes.data() + 1; + RobOsageNode* i_end = nodes.data() + nodes.size(); + for (RobOsageNode* i = i_begin; i != i_end; i++) + i->force = force; +} + +void RobOsage::SetRot(float_t rot_y, float_t rot_z) { + skin_param_ptr->rot.y = rot_y * DEG_TO_RAD_FLOAT; + skin_param_ptr->rot.z = rot_z * DEG_TO_RAD_FLOAT; +} + +int32_t rob_chara_item_equip_object::get_bone_index(const char* name) { + int32_t(FASTCALL * sub_1401F13B0)(int32_t a1, const char* a2) + = (int32_t(FASTCALL*)(int32_t a1, const char* a2))0x00000001401F13B0; + + int32_t bone_index = sub_1401F13B0(0, name); + if (bone_index == -1) + for (auto& i : ex_bones) + if (!str_utils_compare(name, i.first)) + return 0x8000 | i.second; + return bone_index; +} + +bone_node* rob_chara_item_equip_object::get_bone_node( + int32_t bone_index) { + if (!(bone_index & 0x8000)) + return &bone_nodes[bone_index & 0x7FFF]; + else if ((bone_index & 0x7FFF) < ex_data_bone_nodes.size()) + return &ex_data_bone_nodes[bone_index & 0x7FFF]; + return 0; +} + +bone_node* rob_chara_item_equip_object::get_bone_node(const char* name) { + return get_bone_node(get_bone_index(name)); +} + +void rob_chara_item_equip_object::skp_load(void* can_prop) { + void (FASTCALL * rob_chara_item_equip_object__skp_load)(rob_chara_item_equip_object * This, void* can_prop) + = (void (FASTCALL*)(rob_chara_item_equip_object * This, void* can_prop))0x00000001405F43E0; + rob_chara_item_equip_object__skp_load(this, can_prop); +} + +rob_chara_item_equip_object* rob_chara_item_equip::get_item_equip_object(item_id id) { + if (id >= ITEM_BODY && id <= ITEM_ITEM16) + return &item_equip_object[id]; + return 0; +} + +const mat4* rob_chara_get_adjust_data_mat(rob_chara* rob_chr) { + return &rob_chr->data.adjust_data.mat; +} diff --git a/src/AFTModsShared/rob/rob.hpp b/src/AFTModsShared/rob/rob.hpp new file mode 100644 index 0000000..33d99a8 --- /dev/null +++ b/src/AFTModsShared/rob/rob.hpp @@ -0,0 +1,1838 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../../KKdLib/default.hpp" +#include "../../KKdLib/mat.hpp" +#include "../../KKdLib/vec.hpp" +#include "../mdl/disp_manager.hpp" +#include "../item_table.hpp" +#include "../object.hpp" +#include "../shadow.hpp" + +enum chara_index { + CHARA_NONE = -1, + CHARA_MIKU = 0x00, + CHARA_RIN = 0x01, + CHARA_LEN = 0x02, + CHARA_LUKA = 0x03, + CHARA_NERU = 0x04, + CHARA_HAKU = 0x05, + CHARA_KAITO = 0x06, + CHARA_MEIKO = 0x07, + CHARA_SAKINE = 0x08, + CHARA_TETO = 0x09, + CHARA_MAX = 0x0A, +}; + +enum ex_expression_block_stack_type { + EX_EXPRESSION_BLOCK_STACK_NUMBER = 0x00, + EX_EXPRESSION_BLOCK_STACK_VARIABLE = 0x01, + EX_EXPRESSION_BLOCK_STACK_VARIABLE_RADIAN = 0x02, + EX_EXPRESSION_BLOCK_STACK_OP1 = 0x03, + EX_EXPRESSION_BLOCK_STACK_OP2 = 0x04, + EX_EXPRESSION_BLOCK_STACK_OP3 = 0x05, +}; + +enum eyes_base_adjust_type { + EYES_BASE_ADJUST_NONE = -1, + EYES_BASE_ADJUST_DIRECTION = 0x00, + EYES_BASE_ADJUST_CLEARANCE = 0x01, + EYES_BASE_ADJUST_OFF = 0x02, + EYES_BASE_ADJUST_MAX = 0x03, +}; + +enum mot_bone_index { + MOT_BONE_N_HARA_CP = 0x00, + MOT_BONE_KG_HARA_Y = 0x01, + MOT_BONE_KL_HARA_XZ = 0x02, + MOT_BONE_KL_HARA_ETC = 0x03, + MOT_BONE_N_HARA = 0x04, + MOT_BONE_CL_MUNE = 0x05, + MOT_BONE_J_MUNE_WJ = 0x06, + MOT_BONE_E_MUNE_CP = 0x07, + MOT_BONE_N_MUNE_B = 0x08, + MOT_BONE_KL_MUNE_B_WJ = 0x09, + MOT_BONE_KL_KUBI = 0x0A, + MOT_BONE_N_KAO = 0x0B, + MOT_BONE_CL_KAO = 0x0C, + MOT_BONE_J_KAO_WJ = 0x0D, + MOT_BONE_E_KAO_CP = 0x0E, + MOT_BONE_FACE_ROOT = 0x0F, + MOT_BONE_N_AGO = 0x10, + MOT_BONE_KL_AGO_WJ = 0x11, + MOT_BONE_N_TOOTH_UNDER = 0x12, + MOT_BONE_TL_TOOTH_UNDER_WJ = 0x13, + MOT_BONE_N_EYE_L = 0x14, + MOT_BONE_KL_EYE_L = 0x15, + MOT_BONE_N_EYE_L_WJ_EX = 0x16, + MOT_BONE_KL_HIGHLIGHT_L_WJ = 0x17, + MOT_BONE_N_EYE_R = 0x18, + MOT_BONE_KL_EYE_R = 0x19, + MOT_BONE_N_EYE_R_WJ_EX = 0x1A, + MOT_BONE_KL_HIGHLIGHT_R_WJ = 0x1B, + MOT_BONE_N_EYELID_L_A = 0x1C, + MOT_BONE_TL_EYELID_L_A_WJ = 0x1D, + MOT_BONE_N_EYELID_L_B = 0x1E, + MOT_BONE_TL_EYELID_L_B_WJ = 0x1F, + MOT_BONE_N_EYELID_R_A = 0x20, + MOT_BONE_TL_EYELID_R_A_WJ = 0x21, + MOT_BONE_N_EYELID_R_B = 0x22, + MOT_BONE_TL_EYELID_R_B_WJ = 0x23, + MOT_BONE_N_KUTI_D = 0x24, + MOT_BONE_TL_KUTI_D_WJ = 0x25, + MOT_BONE_N_KUTI_D_L = 0x26, + MOT_BONE_TL_KUTI_D_L_WJ = 0x27, + MOT_BONE_N_KUTI_D_R = 0x28, + MOT_BONE_TL_KUTI_D_R_WJ = 0x29, + MOT_BONE_N_KUTI_DS_L = 0x2A, + MOT_BONE_TL_KUTI_DS_L_WJ = 0x2B, + MOT_BONE_N_KUTI_DS_R = 0x2C, + MOT_BONE_TL_KUTI_DS_R_WJ = 0x2D, + MOT_BONE_N_KUTI_L = 0x2E, + MOT_BONE_TL_KUTI_L_WJ = 0x2F, + MOT_BONE_N_KUTI_M_L = 0x30, + MOT_BONE_TL_KUTI_M_L_WJ = 0x31, + MOT_BONE_N_KUTI_M_R = 0x32, + MOT_BONE_TL_KUTI_M_R_WJ = 0x33, + MOT_BONE_N_KUTI_R = 0x34, + MOT_BONE_TL_KUTI_R_WJ = 0x35, + MOT_BONE_N_KUTI_U = 0x36, + MOT_BONE_TL_KUTI_U_WJ = 0x37, + MOT_BONE_N_KUTI_U_L = 0x38, + MOT_BONE_TL_KUTI_U_L_WJ = 0x39, + MOT_BONE_N_KUTI_U_R = 0x3A, + MOT_BONE_TL_KUTI_U_R_WJ = 0x3B, + MOT_BONE_N_MABU_L_D_A = 0x3C, + MOT_BONE_TL_MABU_L_D_A_WJ = 0x3D, + MOT_BONE_N_MABU_L_D_B = 0x3E, + MOT_BONE_TL_MABU_L_D_B_WJ = 0x3F, + MOT_BONE_N_MABU_L_D_C = 0x40, + MOT_BONE_TL_MABU_L_D_C_WJ = 0x41, + MOT_BONE_N_MABU_L_U_A = 0x42, + MOT_BONE_TL_MABU_L_U_A_WJ = 0x43, + MOT_BONE_N_MABU_L_U_B = 0x44, + MOT_BONE_TL_MABU_L_U_B_WJ = 0x45, + MOT_BONE_N_EYELASHES_L = 0x46, + MOT_BONE_TL_EYELASHES_L_WJ = 0x47, + MOT_BONE_N_MABU_L_U_C = 0x48, + MOT_BONE_TL_MABU_L_U_C_WJ = 0x49, + MOT_BONE_N_MABU_R_D_A = 0x4A, + MOT_BONE_TL_MABU_R_D_A_WJ = 0x4B, + MOT_BONE_N_MABU_R_D_B = 0x4C, + MOT_BONE_TL_MABU_R_D_B_WJ = 0x4D, + MOT_BONE_N_MABU_R_D_C = 0x4E, + MOT_BONE_TL_MABU_R_D_C_WJ = 0x4F, + MOT_BONE_N_MABU_R_U_A = 0x50, + MOT_BONE_TL_MABU_R_U_A_WJ = 0x51, + MOT_BONE_N_MABU_R_U_B = 0x52, + MOT_BONE_TL_MABU_R_U_B_WJ = 0x53, + MOT_BONE_N_EYELASHES_R = 0x54, + MOT_BONE_TL_EYELASHES_R_WJ = 0x55, + MOT_BONE_N_MABU_R_U_C = 0x56, + MOT_BONE_TL_MABU_R_U_C_WJ = 0x57, + MOT_BONE_N_MAYU_L = 0x58, + MOT_BONE_TL_MAYU_L_WJ = 0x59, + MOT_BONE_N_MAYU_L_B = 0x5A, + MOT_BONE_TL_MAYU_L_B_WJ = 0x5B, + MOT_BONE_N_MAYU_L_C = 0x5C, + MOT_BONE_TL_MAYU_L_C_WJ = 0x5D, + MOT_BONE_N_MAYU_R = 0x5E, + MOT_BONE_TL_MAYU_R_WJ = 0x5F, + MOT_BONE_N_MAYU_R_B = 0x60, + MOT_BONE_TL_MAYU_R_B_WJ = 0x61, + MOT_BONE_N_MAYU_R_C = 0x62, + MOT_BONE_TL_MAYU_R_C_WJ = 0x63, + MOT_BONE_N_TOOTH_UPPER = 0x64, + MOT_BONE_TL_TOOTH_UPPER_WJ = 0x65, + MOT_BONE_N_KUBI_WJ_EX = 0x66, + MOT_BONE_N_WAKI_L = 0x67, + MOT_BONE_KL_WAKI_L_WJ = 0x68, + MOT_BONE_TL_UP_KATA_L = 0x69, + MOT_BONE_C_KATA_L = 0x6A, + MOT_BONE_J_KATA_L_WJ_CU = 0x6B, + MOT_BONE_J_UDE_L_WJ = 0x6C, + MOT_BONE_E_UDE_L_CP = 0x6D, + MOT_BONE_KL_TE_L_WJ = 0x6E, + MOT_BONE_N_HITO_L_EX = 0x6F, + MOT_BONE_NL_HITO_L_WJ = 0x70, + MOT_BONE_NL_HITO_B_L_WJ = 0x71, + MOT_BONE_NL_HITO_C_L_WJ = 0x72, + MOT_BONE_N_KO_L_EX = 0x73, + MOT_BONE_NL_KO_L_WJ = 0x74, + MOT_BONE_NL_KO_B_L_WJ = 0x75, + MOT_BONE_NL_KO_C_L_WJ = 0x76, + MOT_BONE_N_KUSU_L_EX = 0x77, + MOT_BONE_NL_KUSU_L_WJ = 0x78, + MOT_BONE_NL_KUSU_B_L_WJ = 0x79, + MOT_BONE_NL_KUSU_C_L_WJ = 0x7A, + MOT_BONE_N_NAKA_L_EX = 0x7B, + MOT_BONE_NL_NAKA_L_WJ = 0x7C, + MOT_BONE_NL_NAKA_B_L_WJ = 0x7D, + MOT_BONE_NL_NAKA_C_L_WJ = 0x7E, + MOT_BONE_N_OYA_L_EX = 0x7F, + MOT_BONE_NL_OYA_L_WJ = 0x80, + MOT_BONE_NL_OYA_B_L_WJ = 0x81, + MOT_BONE_NL_OYA_C_L_WJ = 0x82, + MOT_BONE_N_STE_L_WJ_EX = 0x83, + MOT_BONE_N_SUDE_L_WJ_EX = 0x84, + MOT_BONE_N_SUDE_B_L_WJ_EX = 0x85, + MOT_BONE_N_HIJI_L_WJ_EX = 0x86, + MOT_BONE_N_UP_KATA_L_EX = 0x87, + MOT_BONE_N_SKATA_L_WJ_CD_EX = 0x88, + MOT_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x89, + MOT_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x8A, + MOT_BONE_N_WAKI_R = 0x8B, + MOT_BONE_KL_WAKI_R_WJ = 0x8C, + MOT_BONE_TL_UP_KATA_R = 0x8D, + MOT_BONE_C_KATA_R = 0x8E, + MOT_BONE_J_KATA_R_WJ_CU = 0x8F, + MOT_BONE_J_UDE_R_WJ = 0x90, + MOT_BONE_E_UDE_R_CP = 0x91, + MOT_BONE_KL_TE_R_WJ = 0x92, + MOT_BONE_N_HITO_R_EX = 0x93, + MOT_BONE_NL_HITO_R_WJ = 0x94, + MOT_BONE_NL_HITO_B_R_WJ = 0x95, + MOT_BONE_NL_HITO_C_R_WJ = 0x96, + MOT_BONE_N_KO_R_EX = 0x97, + MOT_BONE_NL_KO_R_WJ = 0x98, + MOT_BONE_NL_KO_B_R_WJ = 0x99, + MOT_BONE_NL_KO_C_R_WJ = 0x9A, + MOT_BONE_N_KUSU_R_EX = 0x9B, + MOT_BONE_NL_KUSU_R_WJ = 0x9C, + MOT_BONE_NL_KUSU_B_R_WJ = 0x9D, + MOT_BONE_NL_KUSU_C_R_WJ = 0x9E, + MOT_BONE_N_NAKA_R_EX = 0x9F, + MOT_BONE_NL_NAKA_R_WJ = 0xA0, + MOT_BONE_NL_NAKA_B_R_WJ = 0xA1, + MOT_BONE_NL_NAKA_C_R_WJ = 0xA2, + MOT_BONE_N_OYA_R_EX = 0xA3, + MOT_BONE_NL_OYA_R_WJ = 0xA4, + MOT_BONE_NL_OYA_B_R_WJ = 0xA5, + MOT_BONE_NL_OYA_C_R_WJ = 0xA6, + MOT_BONE_N_STE_R_WJ_EX = 0xA7, + MOT_BONE_N_SUDE_R_WJ_EX = 0xA8, + MOT_BONE_N_SUDE_B_R_WJ_EX = 0xA9, + MOT_BONE_N_HIJI_R_WJ_EX = 0xAA, + MOT_BONE_N_UP_KATA_R_EX = 0xAB, + MOT_BONE_N_SKATA_R_WJ_CD_EX = 0xAC, + MOT_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xAD, + MOT_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xAE, + MOT_BONE_KL_KOSI_Y = 0xAF, + MOT_BONE_KL_KOSI_XZ = 0xB0, + MOT_BONE_KL_KOSI_ETC_WJ = 0xB1, + MOT_BONE_CL_MOMO_L = 0xB2, + MOT_BONE_J_MOMO_L_WJ = 0xB3, + MOT_BONE_J_SUNE_L_WJ = 0xB4, + MOT_BONE_E_SUNE_L_CP = 0xB5, + MOT_BONE_KL_ASI_L_WJ_CO = 0xB6, + MOT_BONE_KL_TOE_L_WJ = 0xB7, + MOT_BONE_N_HIZA_L_WJ_EX = 0xB8, + MOT_BONE_CL_MOMO_R = 0xB9, + MOT_BONE_J_MOMO_R_WJ = 0xBA, + MOT_BONE_J_SUNE_R_WJ = 0xBB, + MOT_BONE_E_SUNE_R_CP = 0xBC, + MOT_BONE_KL_ASI_R_WJ_CO = 0xBD, + MOT_BONE_KL_TOE_R_WJ = 0xBE, + MOT_BONE_N_HIZA_R_WJ_EX = 0xBF, + MOT_BONE_N_MOMO_A_L_WJ_CD_EX = 0xC0, + MOT_BONE_N_MOMO_B_L_WJ_EX = 0xC1, + MOT_BONE_N_MOMO_C_L_WJ_EX = 0xC2, + MOT_BONE_N_MOMO_A_R_WJ_CD_EX = 0xC3, + MOT_BONE_N_MOMO_B_R_WJ_EX = 0xC4, + MOT_BONE_N_MOMO_C_R_WJ_EX = 0xC5, + MOT_BONE_N_HARA_CD_EX = 0xC6, + MOT_BONE_N_HARA_B_WJ_EX = 0xC7, + MOT_BONE_N_HARA_C_WJ_EX = 0xC8, + MOT_BONE_MAX = 0xC9, +}; + +enum mothead_data_type { + MOTHEAD_DATA_TYPE_0 = 0x00, + MOTHEAD_DATA_TYPE_1 = 0x01, + MOTHEAD_DATA_TYPE_2 = 0x02, + MOTHEAD_DATA_TYPE_3 = 0x03, + MOTHEAD_DATA_TYPE_4 = 0x04, + MOTHEAD_DATA_TYPE_5 = 0x05, + MOTHEAD_DATA_TYPE_6 = 0x06, + MOTHEAD_DATA_TYPE_7 = 0x07, + MOTHEAD_DATA_TYPE_8 = 0x08, + MOTHEAD_DATA_TYPE_9 = 0x09, + MOTHEAD_DATA_TYPE_10 = 0x0A, + MOTHEAD_DATA_TYPE_11 = 0x0B, + MOTHEAD_DATA_TYPE_12 = 0x0C, + MOTHEAD_DATA_TYPE_13 = 0x0D, + MOTHEAD_DATA_TYPE_14 = 0x0E, + MOTHEAD_DATA_TYPE_15 = 0x0F, + MOTHEAD_DATA_TYPE_16 = 0x10, + MOTHEAD_DATA_TYPE_17 = 0x11, + MOTHEAD_DATA_TYPE_18 = 0x12, + MOTHEAD_DATA_TYPE_19 = 0x13, + MOTHEAD_DATA_TYPE_20 = 0x14, + MOTHEAD_DATA_TYPE_21 = 0x15, + MOTHEAD_DATA_TYPE_22 = 0x16, + MOTHEAD_DATA_TYPE_23 = 0x17, + MOTHEAD_DATA_TYPE_24 = 0x18, + MOTHEAD_DATA_TYPE_25 = 0x19, + MOTHEAD_DATA_TYPE_26 = 0x1A, + MOTHEAD_DATA_TYPE_27 = 0x1B, + MOTHEAD_DATA_TYPE_28 = 0x1C, + MOTHEAD_DATA_TYPE_29 = 0x1D, + MOTHEAD_DATA_TYPE_30 = 0x1E, + MOTHEAD_DATA_TYPE_31 = 0x1F, + MOTHEAD_DATA_TYPE_32 = 0x20, + MOTHEAD_DATA_TYPE_33 = 0x21, + MOTHEAD_DATA_TYPE_34 = 0x22, + MOTHEAD_DATA_TYPE_35 = 0x23, + MOTHEAD_DATA_TYPE_36 = 0x24, + MOTHEAD_DATA_TYPE_37 = 0x25, + MOTHEAD_DATA_TYPE_38 = 0x26, + MOTHEAD_DATA_TYPE_39 = 0x27, + MOTHEAD_DATA_TYPE_40 = 0x28, + MOTHEAD_DATA_TYPE_41 = 0x29, + MOTHEAD_DATA_TYPE_42 = 0x2A, + MOTHEAD_DATA_TYPE_43 = 0x2B, + MOTHEAD_DATA_TYPE_44 = 0x2C, + MOTHEAD_DATA_TYPE_45 = 0x2D, + MOTHEAD_DATA_TYPE_46 = 0x2E, + MOTHEAD_DATA_TYPE_47 = 0x2F, + MOTHEAD_DATA_TYPE_48 = 0x30, + MOTHEAD_DATA_TYPE_49 = 0x31, + MOTHEAD_DATA_SET_FACE_MOTION_ID = 0x32, + MOTHEAD_DATA_TYPE_51 = 0x33, + MOTHEAD_DATA_TYPE_52 = 0x34, + MOTHEAD_DATA_SET_FACE_MOTTBL_MOTION = 0x35, + MOTHEAD_DATA_SET_HAND_R_MOTTBL_MOTION = 0x36, + MOTHEAD_DATA_SET_HAND_L_MOTTBL_MOTION = 0x37, + MOTHEAD_DATA_SET_MOUTH_MOTTBL_MOTION = 0x38, + MOTHEAD_DATA_SET_EYES_MOTTBL_MOTION = 0x39, + MOTHEAD_DATA_SET_EYELID_MOTTBL_MOTION = 0x3A, + MOTHEAD_DATA_SET_ROB_CHARA_HEAD_OBJECT = 0x3B, + MOTHEAD_DATA_TYPE_60 = 0x3C, + MOTHEAD_DATA_SET_EYELID_MOTION_FROM_FACE = 0x3D, + MOTHEAD_DATA_ROB_PARTS_ADJUST = 0x3E, + MOTHEAD_DATA_TYPE_63 = 0x3F, + MOTHEAD_DATA_WIND_RESET = 0x40, + MOTHEAD_DATA_OSAGE_RESET = 0x41, + MOTHEAD_DATA_OSAGE_STEP = 0x42, + MOTHEAD_DATA_SLEEVE_ADJUST = 0x43, + MOTHEAD_DATA_TYPE_68 = 0x44, + MOTHEAD_DATA_TYPE_69 = 0x45, + MOTHEAD_DATA_TYPE_70 = 0x46, + MOTHEAD_DATA_OSAGE_MOVE_CANCEL = 0x47, + MOTHEAD_DATA_TYPE_72 = 0x48, + MOTHEAD_DATA_ROB_HAND_ADJUST = 0x49, + MOTHEAD_DATA_DISABLE_COLLISION = 0x4A, + MOTHEAD_DATA_ROB_ADJUST_GLOBAL = 0x4B, + MOTHEAD_DATA_ROB_ARM_ADJUST = 0x4C, + MOTHEAD_DATA_DISABLE_EYE_MOTION = 0x4D, + MOTHEAD_DATA_TYPE_78 = 0x4E, + MOTHEAD_DATA_ROB_CHARA_COLI_RING = 0x4F, + MOTHEAD_DATA_ADJUST_GET_GLOBAL_POSITION = 0x50, + MOTHEAD_DATA_MAX = 0x51, +}; + +enum MotionBlendType { + MOTION_BLEND_NONE = -1, + MOTION_BLEND = 0x00, + MOTION_BLEND_FREEZE = 0x01, + MOTION_BLEND_CROSS = 0x02, + MOTION_BLEND_COMBINE = 0x03, +}; + +enum motion_bone_index { + MOTION_BONE_NONE = -1, + MOTION_BONE_N_HARA_CP = 0x00, + MOTION_BONE_KG_HARA_Y = 0x01, + MOTION_BONE_KL_HARA_XZ = 0x02, + MOTION_BONE_KL_HARA_ETC = 0x03, + MOTION_BONE_N_HARA = 0x04, + MOTION_BONE_CL_MUNE = 0x05, + MOTION_BONE_N_MUNE_B = 0x06, + MOTION_BONE_KL_MUNE_B_WJ = 0x07, + MOTION_BONE_KL_KUBI = 0x08, + MOTION_BONE_N_KAO = 0x09, + MOTION_BONE_CL_KAO = 0x0A, + MOTION_BONE_FACE_ROOT = 0x0B, + MOTION_BONE_N_AGO = 0x0C, + MOTION_BONE_KL_AGO_WJ = 0x0D, + MOTION_BONE_N_TOOTH_UNDER = 0x0E, + MOTION_BONE_TL_TOOTH_UNDER_WJ = 0x0F, + MOTION_BONE_N_EYE_L = 0x10, + MOTION_BONE_KL_EYE_L = 0x11, + MOTION_BONE_N_EYE_L_WJ_EX = 0x12, + MOTION_BONE_KL_HIGHLIGHT_L_WJ = 0x13, + MOTION_BONE_N_EYE_R = 0x14, + MOTION_BONE_KL_EYE_R = 0x15, + MOTION_BONE_N_EYE_R_WJ_EX = 0x16, + MOTION_BONE_KL_HIGHLIGHT_R_WJ = 0x17, + MOTION_BONE_N_EYELID_L_A = 0x18, + MOTION_BONE_TL_EYELID_L_A_WJ = 0x19, + MOTION_BONE_N_EYELID_L_B = 0x1A, + MOTION_BONE_TL_EYELID_L_B_WJ = 0x1B, + MOTION_BONE_N_EYELID_R_A = 0x1C, + MOTION_BONE_TL_EYELID_R_A_WJ = 0x1D, + MOTION_BONE_N_EYELID_R_B = 0x1E, + MOTION_BONE_TL_EYELID_R_B_WJ = 0x1F, + MOTION_BONE_N_KUTI_D = 0x20, + MOTION_BONE_TL_KUTI_D_WJ = 0x21, + MOTION_BONE_N_KUTI_D_L = 0x22, + MOTION_BONE_TL_KUTI_D_L_WJ = 0x23, + MOTION_BONE_N_KUTI_D_R = 0x24, + MOTION_BONE_TL_KUTI_D_R_WJ = 0x25, + MOTION_BONE_N_KUTI_DS_L = 0x26, + MOTION_BONE_TL_KUTI_DS_L_WJ = 0x27, + MOTION_BONE_N_KUTI_DS_R = 0x28, + MOTION_BONE_TL_KUTI_DS_R_WJ = 0x29, + MOTION_BONE_N_KUTI_L = 0x2A, + MOTION_BONE_TL_KUTI_L_WJ = 0x2B, + MOTION_BONE_N_KUTI_M_L = 0x2C, + MOTION_BONE_TL_KUTI_M_L_WJ = 0x2D, + MOTION_BONE_N_KUTI_M_R = 0x2E, + MOTION_BONE_TL_KUTI_M_R_WJ = 0x2F, + MOTION_BONE_N_KUTI_R = 0x30, + MOTION_BONE_TL_KUTI_R_WJ = 0x31, + MOTION_BONE_N_KUTI_U = 0x32, + MOTION_BONE_TL_KUTI_U_WJ = 0x33, + MOTION_BONE_N_KUTI_U_L = 0x34, + MOTION_BONE_TL_KUTI_U_L_WJ = 0x35, + MOTION_BONE_N_KUTI_U_R = 0x36, + MOTION_BONE_TL_KUTI_U_R_WJ = 0x37, + MOTION_BONE_N_MABU_L_D_A = 0x38, + MOTION_BONE_TL_MABU_L_D_A_WJ = 0x39, + MOTION_BONE_N_MABU_L_D_B = 0x3A, + MOTION_BONE_TL_MABU_L_D_B_WJ = 0x3B, + MOTION_BONE_N_MABU_L_D_C = 0x3C, + MOTION_BONE_TL_MABU_L_D_C_WJ = 0x3D, + MOTION_BONE_N_MABU_L_U_A = 0x3E, + MOTION_BONE_TL_MABU_L_U_A_WJ = 0x3F, + MOTION_BONE_N_MABU_L_U_B = 0x40, + MOTION_BONE_TL_MABU_L_U_B_WJ = 0x41, + MOTION_BONE_N_EYELASHES_L = 0x42, + MOTION_BONE_TL_EYELASHES_L_WJ = 0x43, + MOTION_BONE_N_MABU_L_U_C = 0x44, + MOTION_BONE_TL_MABU_L_U_C_WJ = 0x45, + MOTION_BONE_N_MABU_R_D_A = 0x46, + MOTION_BONE_TL_MABU_R_D_A_WJ = 0x47, + MOTION_BONE_N_MABU_R_D_B = 0x48, + MOTION_BONE_TL_MABU_R_D_B_WJ = 0x49, + MOTION_BONE_N_MABU_R_D_C = 0x4A, + MOTION_BONE_TL_MABU_R_D_C_WJ = 0x4B, + MOTION_BONE_N_MABU_R_U_A = 0x4C, + MOTION_BONE_TL_MABU_R_U_A_WJ = 0x4D, + MOTION_BONE_N_MABU_R_U_B = 0x4E, + MOTION_BONE_TL_MABU_R_U_B_WJ = 0x4F, + MOTION_BONE_N_EYELASHES_R = 0x50, + MOTION_BONE_TL_EYELASHES_R_WJ = 0x51, + MOTION_BONE_N_MABU_R_U_C = 0x52, + MOTION_BONE_TL_MABU_R_U_C_WJ = 0x53, + MOTION_BONE_N_MAYU_L = 0x54, + MOTION_BONE_TL_MAYU_L_WJ = 0x55, + MOTION_BONE_N_MAYU_L_B = 0x56, + MOTION_BONE_TL_MAYU_L_B_WJ = 0x57, + MOTION_BONE_N_MAYU_L_C = 0x58, + MOTION_BONE_TL_MAYU_L_C_WJ = 0x59, + MOTION_BONE_N_MAYU_R = 0x5A, + MOTION_BONE_TL_MAYU_R_WJ = 0x5B, + MOTION_BONE_N_MAYU_R_B = 0x5C, + MOTION_BONE_TL_MAYU_R_B_WJ = 0x5D, + MOTION_BONE_N_MAYU_R_C = 0x5E, + MOTION_BONE_TL_MAYU_R_C_WJ = 0x5F, + MOTION_BONE_N_TOOTH_UPPER = 0x60, + MOTION_BONE_TL_TOOTH_UPPER_WJ = 0x61, + MOTION_BONE_N_KUBI_WJ_EX = 0x62, + MOTION_BONE_N_WAKI_L = 0x63, + MOTION_BONE_KL_WAKI_L_WJ = 0x64, + MOTION_BONE_TL_UP_KATA_L = 0x65, + MOTION_BONE_C_KATA_L = 0x66, + MOTION_BONE_KL_TE_L_WJ = 0x67, + MOTION_BONE_N_HITO_L_EX = 0x68, + MOTION_BONE_NL_HITO_L_WJ = 0x69, + MOTION_BONE_NL_HITO_B_L_WJ = 0x6A, + MOTION_BONE_NL_HITO_C_L_WJ = 0x6B, + MOTION_BONE_N_KO_L_EX = 0x6C, + MOTION_BONE_NL_KO_L_WJ = 0x6D, + MOTION_BONE_NL_KO_B_L_WJ = 0x6E, + MOTION_BONE_NL_KO_C_L_WJ = 0x6F, + MOTION_BONE_N_KUSU_L_EX = 0x70, + MOTION_BONE_NL_KUSU_L_WJ = 0x71, + MOTION_BONE_NL_KUSU_B_L_WJ = 0x72, + MOTION_BONE_NL_KUSU_C_L_WJ = 0x73, + MOTION_BONE_N_NAKA_L_EX = 0x74, + MOTION_BONE_NL_NAKA_L_WJ = 0x75, + MOTION_BONE_NL_NAKA_B_L_WJ = 0x76, + MOTION_BONE_NL_NAKA_C_L_WJ = 0x77, + MOTION_BONE_N_OYA_L_EX = 0x78, + MOTION_BONE_NL_OYA_L_WJ = 0x79, + MOTION_BONE_NL_OYA_B_L_WJ = 0x7A, + MOTION_BONE_NL_OYA_C_L_WJ = 0x7B, + MOTION_BONE_N_STE_L_WJ_EX = 0x7C, + MOTION_BONE_N_SUDE_L_WJ_EX = 0x7D, + MOTION_BONE_N_SUDE_B_L_WJ_EX = 0x7E, + MOTION_BONE_N_HIJI_L_WJ_EX = 0x7F, + MOTION_BONE_N_UP_KATA_L_EX = 0x80, + MOTION_BONE_N_SKATA_L_WJ_CD_EX = 0x81, + MOTION_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x82, + MOTION_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x83, + MOTION_BONE_N_WAKI_R = 0x84, + MOTION_BONE_KL_WAKI_R_WJ = 0x85, + MOTION_BONE_TL_UP_KATA_R = 0x86, + MOTION_BONE_C_KATA_R = 0x87, + MOTION_BONE_KL_TE_R_WJ = 0x88, + MOTION_BONE_N_HITO_R_EX = 0x89, + MOTION_BONE_NL_HITO_R_WJ = 0x8A, + MOTION_BONE_NL_HITO_B_R_WJ = 0x8B, + MOTION_BONE_NL_HITO_C_R_WJ = 0x8C, + MOTION_BONE_N_KO_R_EX = 0x8D, + MOTION_BONE_NL_KO_R_WJ = 0x8E, + MOTION_BONE_NL_KO_B_R_WJ = 0x8F, + MOTION_BONE_NL_KO_C_R_WJ = 0x90, + MOTION_BONE_N_KUSU_R_EX = 0x91, + MOTION_BONE_NL_KUSU_R_WJ = 0x92, + MOTION_BONE_NL_KUSU_B_R_WJ = 0x93, + MOTION_BONE_NL_KUSU_C_R_WJ = 0x94, + MOTION_BONE_N_NAKA_R_EX = 0x95, + MOTION_BONE_NL_NAKA_R_WJ = 0x96, + MOTION_BONE_NL_NAKA_B_R_WJ = 0x97, + MOTION_BONE_NL_NAKA_C_R_WJ = 0x98, + MOTION_BONE_N_OYA_R_EX = 0x99, + MOTION_BONE_NL_OYA_R_WJ = 0x9A, + MOTION_BONE_NL_OYA_B_R_WJ = 0x9B, + MOTION_BONE_NL_OYA_C_R_WJ = 0x9C, + MOTION_BONE_N_STE_R_WJ_EX = 0x9D, + MOTION_BONE_N_SUDE_R_WJ_EX = 0x9E, + MOTION_BONE_N_SUDE_B_R_WJ_EX = 0x9F, + MOTION_BONE_N_HIJI_R_WJ_EX = 0xA0, + MOTION_BONE_N_UP_KATA_R_EX = 0xA1, + MOTION_BONE_N_SKATA_R_WJ_CD_EX = 0xA2, + MOTION_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xA3, + MOTION_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xA4, + MOTION_BONE_KL_KOSI_Y = 0xA5, + MOTION_BONE_KL_KOSI_XZ = 0xA6, + MOTION_BONE_KL_KOSI_ETC_WJ = 0xA7, + MOTION_BONE_CL_MOMO_L = 0xA8, + MOTION_BONE_KL_ASI_L_WJ_CO = 0xA9, + MOTION_BONE_KL_TOE_L_WJ = 0xAA, + MOTION_BONE_N_HIZA_L_WJ_EX = 0xAB, + MOTION_BONE_CL_MOMO_R = 0xAC, + MOTION_BONE_KL_ASI_R_WJ_CO = 0xAD, + MOTION_BONE_KL_TOE_R_WJ = 0xAE, + MOTION_BONE_N_HIZA_R_WJ_EX = 0xAF, + MOTION_BONE_N_MOMO_A_L_WJ_CD_EX = 0xB0, + MOTION_BONE_N_MOMO_B_L_WJ_EX = 0xB1, + MOTION_BONE_N_MOMO_C_L_WJ_EX = 0xB2, + MOTION_BONE_N_MOMO_A_R_WJ_CD_EX = 0xB3, + MOTION_BONE_N_MOMO_B_R_WJ_EX = 0xB4, + MOTION_BONE_N_MOMO_C_R_WJ_EX = 0xB5, + MOTION_BONE_N_HARA_CD_EX = 0xB6, + MOTION_BONE_N_HARA_B_WJ_EX = 0xB7, + MOTION_BONE_N_HARA_C_WJ_EX = 0xB8, + MOTION_BONE_MAX = 0xB9, +}; + +enum rob_bone_index { + ROB_BONE_NONE = -1, + ROB_BONE_N_HARA_CP = 0x00, + ROB_BONE_KG_HARA_Y = 0x01, + ROB_BONE_KL_HARA_XZ = 0x02, + ROB_BONE_KL_HARA_ETC = 0x03, + ROB_BONE_N_HARA = 0x04, + ROB_BONE_CL_MUNE = 0x05, + ROB_BONE_N_MUNE_B = 0x06, + ROB_BONE_KL_MUNE_B_WJ = 0x07, + ROB_BONE_KL_KUBI = 0x08, + ROB_BONE_N_KAO = 0x09, + ROB_BONE_CL_KAO = 0x0A, + ROB_BONE_FACE_ROOT = 0x0B, + ROB_BONE_N_AGO = 0x0C, + ROB_BONE_KL_AGO_WJ = 0x0D, + ROB_BONE_N_TOOTH_UNDER = 0x0E, + ROB_BONE_TL_TOOTH_UNDER_WJ = 0x0F, + ROB_BONE_N_EYE_L = 0x10, + ROB_BONE_KL_EYE_L = 0x11, + ROB_BONE_N_EYE_L_WJ_EX = 0x12, + ROB_BONE_KL_HIGHLIGHT_L_WJ = 0x13, + ROB_BONE_N_EYE_R = 0x14, + ROB_BONE_KL_EYE_R = 0x15, + ROB_BONE_N_EYE_R_WJ_EX = 0x16, + ROB_BONE_KL_HIGHLIGHT_R_WJ = 0x17, + ROB_BONE_N_EYELID_L_A = 0x18, + ROB_BONE_TL_EYELID_L_A_WJ = 0x19, + ROB_BONE_N_EYELID_L_B = 0x1A, + ROB_BONE_TL_EYELID_L_B_WJ = 0x1B, + ROB_BONE_N_EYELID_R_A = 0x1C, + ROB_BONE_TL_EYELID_R_A_WJ = 0x1D, + ROB_BONE_N_EYELID_R_B = 0x1E, + ROB_BONE_TL_EYELID_R_B_WJ = 0x1F, + ROB_BONE_N_KUTI_D = 0x20, + ROB_BONE_TL_KUTI_D_WJ = 0x21, + ROB_BONE_N_KUTI_D_L = 0x22, + ROB_BONE_TL_KUTI_D_L_WJ = 0x23, + ROB_BONE_N_KUTI_D_R = 0x24, + ROB_BONE_TL_KUTI_D_R_WJ = 0x25, + ROB_BONE_N_KUTI_DS_L = 0x26, + ROB_BONE_TL_KUTI_DS_L_WJ = 0x27, + ROB_BONE_N_KUTI_DS_R = 0x28, + ROB_BONE_TL_KUTI_DS_R_WJ = 0x29, + ROB_BONE_N_KUTI_L = 0x2A, + ROB_BONE_TL_KUTI_L_WJ = 0x2B, + ROB_BONE_N_KUTI_M_L = 0x2C, + ROB_BONE_TL_KUTI_M_L_WJ = 0x2D, + ROB_BONE_N_KUTI_M_R = 0x2E, + ROB_BONE_TL_KUTI_M_R_WJ = 0x2F, + ROB_BONE_N_KUTI_R = 0x30, + ROB_BONE_TL_KUTI_R_WJ = 0x31, + ROB_BONE_N_KUTI_U = 0x32, + ROB_BONE_TL_KUTI_U_WJ = 0x33, + ROB_BONE_N_KUTI_U_L = 0x34, + ROB_BONE_TL_KUTI_U_L_WJ = 0x35, + ROB_BONE_N_KUTI_U_R = 0x36, + ROB_BONE_TL_KUTI_U_R_WJ = 0x37, + ROB_BONE_N_MABU_L_D_A = 0x38, + ROB_BONE_TL_MABU_L_D_A_WJ = 0x39, + ROB_BONE_N_MABU_L_D_B = 0x3A, + ROB_BONE_TL_MABU_L_D_B_WJ = 0x3B, + ROB_BONE_N_MABU_L_D_C = 0x3C, + ROB_BONE_TL_MABU_L_D_C_WJ = 0x3D, + ROB_BONE_N_MABU_L_U_A = 0x3E, + ROB_BONE_TL_MABU_L_U_A_WJ = 0x3F, + ROB_BONE_N_MABU_L_U_B = 0x40, + ROB_BONE_TL_MABU_L_U_B_WJ = 0x41, + ROB_BONE_N_EYELASHES_L = 0x42, + ROB_BONE_TL_EYELASHES_L_WJ = 0x43, + ROB_BONE_N_MABU_L_U_C = 0x44, + ROB_BONE_TL_MABU_L_U_C_WJ = 0x45, + ROB_BONE_N_MABU_R_D_A = 0x46, + ROB_BONE_TL_MABU_R_D_A_WJ = 0x47, + ROB_BONE_N_MABU_R_D_B = 0x48, + ROB_BONE_TL_MABU_R_D_B_WJ = 0x49, + ROB_BONE_N_MABU_R_D_C = 0x4A, + ROB_BONE_TL_MABU_R_D_C_WJ = 0x4B, + ROB_BONE_N_MABU_R_U_A = 0x4C, + ROB_BONE_TL_MABU_R_U_A_WJ = 0x4D, + ROB_BONE_N_MABU_R_U_B = 0x4E, + ROB_BONE_TL_MABU_R_U_B_WJ = 0x4F, + ROB_BONE_N_EYELASHES_R = 0x50, + ROB_BONE_TL_EYELASHES_R_WJ = 0x51, + ROB_BONE_N_MABU_R_U_C = 0x52, + ROB_BONE_TL_MABU_R_U_C_WJ = 0x53, + ROB_BONE_N_MAYU_L = 0x54, + ROB_BONE_TL_MAYU_L_WJ = 0x55, + ROB_BONE_N_MAYU_L_B = 0x56, + ROB_BONE_TL_MAYU_L_B_WJ = 0x57, + ROB_BONE_N_MAYU_L_C = 0x58, + ROB_BONE_TL_MAYU_L_C_WJ = 0x59, + ROB_BONE_N_MAYU_R = 0x5A, + ROB_BONE_TL_MAYU_R_WJ = 0x5B, + ROB_BONE_N_MAYU_R_B = 0x5C, + ROB_BONE_TL_MAYU_R_B_WJ = 0x5D, + ROB_BONE_N_MAYU_R_C = 0x5E, + ROB_BONE_TL_MAYU_R_C_WJ = 0x5F, + ROB_BONE_N_TOOTH_UPPER = 0x60, + ROB_BONE_TL_TOOTH_UPPER_WJ = 0x61, + ROB_BONE_N_KUBI_WJ_EX = 0x62, + ROB_BONE_N_WAKI_L = 0x63, + ROB_BONE_KL_WAKI_L_WJ = 0x64, + ROB_BONE_TL_UP_KATA_L = 0x65, + ROB_BONE_C_KATA_L = 0x66, + ROB_BONE_KATA_L_WJ_CU = 0x67, + ROB_BONE_UDE_L_WJ = 0x68, + ROB_BONE_KL_TE_L_WJ = 0x69, + ROB_BONE_N_HITO_L_EX = 0x6A, + ROB_BONE_NL_HITO_L_WJ = 0x6B, + ROB_BONE_NL_HITO_B_L_WJ = 0x6C, + ROB_BONE_NL_HITO_C_L_WJ = 0x6D, + ROB_BONE_N_KO_L_EX = 0x6E, + ROB_BONE_NL_KO_L_WJ = 0x6F, + ROB_BONE_NL_KO_B_L_WJ = 0x70, + ROB_BONE_NL_KO_C_L_WJ = 0x71, + ROB_BONE_N_KUSU_L_EX = 0x72, + ROB_BONE_NL_KUSU_L_WJ = 0x73, + ROB_BONE_NL_KUSU_B_L_WJ = 0x74, + ROB_BONE_NL_KUSU_C_L_WJ = 0x75, + ROB_BONE_N_NAKA_L_EX = 0x76, + ROB_BONE_NL_NAKA_L_WJ = 0x77, + ROB_BONE_NL_NAKA_B_L_WJ = 0x78, + ROB_BONE_NL_NAKA_C_L_WJ = 0x79, + ROB_BONE_N_OYA_L_EX = 0x7A, + ROB_BONE_NL_OYA_L_WJ = 0x7B, + ROB_BONE_NL_OYA_B_L_WJ = 0x7C, + ROB_BONE_NL_OYA_C_L_WJ = 0x7D, + ROB_BONE_N_STE_L_WJ_EX = 0x7E, + ROB_BONE_N_SUDE_L_WJ_EX = 0x7F, + ROB_BONE_N_SUDE_B_L_WJ_EX = 0x80, + ROB_BONE_N_HIJI_L_WJ_EX = 0x81, + ROB_BONE_N_UP_KATA_L_EX = 0x82, + ROB_BONE_N_SKATA_L_WJ_CD_EX = 0x83, + ROB_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x84, + ROB_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x85, + ROB_BONE_N_WAKI_R = 0x86, + ROB_BONE_KL_WAKI_R_WJ = 0x87, + ROB_BONE_TL_UP_KATA_R = 0x88, + ROB_BONE_C_KATA_R = 0x89, + ROB_BONE_KATA_R_WJ_CU = 0x8A, + ROB_BONE_UDE_R_WJ = 0x8B, + ROB_BONE_KL_TE_R_WJ = 0x8C, + ROB_BONE_N_HITO_R_EX = 0x8D, + ROB_BONE_NL_HITO_R_WJ = 0x8E, + ROB_BONE_NL_HITO_B_R_WJ = 0x8F, + ROB_BONE_NL_HITO_C_R_WJ = 0x90, + ROB_BONE_N_KO_R_EX = 0x91, + ROB_BONE_NL_KO_R_WJ = 0x92, + ROB_BONE_NL_KO_B_R_WJ = 0x93, + ROB_BONE_NL_KO_C_R_WJ = 0x94, + ROB_BONE_N_KUSU_R_EX = 0x95, + ROB_BONE_NL_KUSU_R_WJ = 0x96, + ROB_BONE_NL_KUSU_B_R_WJ = 0x97, + ROB_BONE_NL_KUSU_C_R_WJ = 0x98, + ROB_BONE_N_NAKA_R_EX = 0x99, + ROB_BONE_NL_NAKA_R_WJ = 0x9A, + ROB_BONE_NL_NAKA_B_R_WJ = 0x9B, + ROB_BONE_NL_NAKA_C_R_WJ = 0x9C, + ROB_BONE_N_OYA_R_EX = 0x9D, + ROB_BONE_NL_OYA_R_WJ = 0x9E, + ROB_BONE_NL_OYA_B_R_WJ = 0x9F, + ROB_BONE_NL_OYA_C_R_WJ = 0xA0, + ROB_BONE_N_STE_R_WJ_EX = 0xA1, + ROB_BONE_N_SUDE_R_WJ_EX = 0xA2, + ROB_BONE_N_SUDE_B_R_WJ_EX = 0xA3, + ROB_BONE_N_HIJI_R_WJ_EX = 0xA4, + ROB_BONE_N_UP_KATA_R_EX = 0xA5, + ROB_BONE_N_SKATA_R_WJ_CD_EX = 0xA6, + ROB_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xA7, + ROB_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xA8, + ROB_BONE_KL_KOSI_Y = 0xA9, + ROB_BONE_KL_KOSI_XZ = 0xAA, + ROB_BONE_KL_KOSI_ETC_WJ = 0xAB, + ROB_BONE_CL_MOMO_L = 0xAC, + ROB_BONE_J_MOMO_L_WJ = 0xAD, + ROB_BONE_J_SUNE_L_WJ = 0xAE, + ROB_BONE_KL_ASI_L_WJ_CO = 0xAF, + ROB_BONE_KL_TOE_L_WJ = 0xB0, + ROB_BONE_N_HIZA_L_WJ_EX = 0xB1, + ROB_BONE_CL_MOMO_R = 0xB2, + ROB_BONE_J_MOMO_R_WJ = 0xB3, + ROB_BONE_J_SUNE_R_WJ = 0xB4, + ROB_BONE_KL_ASI_R_WJ_CO = 0xB5, + ROB_BONE_KL_TOE_R_WJ = 0xB6, + ROB_BONE_N_HIZA_R_WJ_EX = 0xB7, + ROB_BONE_N_MOMO_A_L_WJ_CD_EX = 0xB8, + ROB_BONE_N_MOMO_B_L_WJ_EX = 0xB9, + ROB_BONE_N_MOMO_C_L_WJ_EX = 0xBA, + ROB_BONE_N_MOMO_A_R_WJ_CD_EX = 0xBB, + ROB_BONE_N_MOMO_B_R_WJ_EX = 0xBC, + ROB_BONE_N_MOMO_C_R_WJ_EX = 0xBD, + ROB_BONE_N_HARA_CD_EX = 0xBE, + ROB_BONE_N_HARA_B_WJ_EX = 0xBF, + ROB_BONE_N_HARA_C_WJ_EX = 0xC0, + ROB_BONE_MAX = 0xC1, +}; + +enum rob_chara_type { + ROB_CHARA_TYPE_NONE = -1, + ROB_CHARA_TYPE_0 = 0x00, + ROB_CHARA_TYPE_1 = 0x01, + ROB_CHARA_TYPE_2 = 0x02, + ROB_CHARA_TYPE_3 = 0x03, +}; + +enum rob_chara_data_hand_adjust_type : uint16_t { + ROB_CHARA_DATA_HAND_ADJUST_NONE = (uint16_t)-1, + ROB_CHARA_DATA_HAND_ADJUST_NORMAL = 0x00, + ROB_CHARA_DATA_HAND_ADJUST_SHORT = 0x01, + ROB_CHARA_DATA_HAND_ADJUST_TALL = 0x02, + ROB_CHARA_DATA_HAND_ADJUST_MIN = 0x03, + ROB_CHARA_DATA_HAND_ADJUST_MAX = 0x04, + ROB_CHARA_DATA_HAND_ADJUST_OPPOSITE_CHARA = 0x05, + ROB_CHARA_DATA_HAND_ADJUST_CUSTOM = 0x06, + ROB_CHARA_DATA_HAND_ADJUST_1P = 0x07, + ROB_CHARA_DATA_HAND_ADJUST_2P = 0x08, + ROB_CHARA_DATA_HAND_ADJUST_3P = 0x09, + ROB_CHARA_DATA_HAND_ADJUST_4P = 0x0A, + ROB_CHARA_DATA_HAND_ADJUST_ITEM = 0x0F, // X +}; + +enum rob_osage_parts { + ROB_OSAGE_PARTS_NONE = -1, + ROB_OSAGE_PARTS_LEFT = 0x00, + ROB_OSAGE_PARTS_RIGHT = 0x01, + ROB_OSAGE_PARTS_CENTER = 0x02, + ROB_OSAGE_PARTS_LONG_C = 0x03, + ROB_OSAGE_PARTS_SHORT_L = 0x04, + ROB_OSAGE_PARTS_SHORT_R = 0x05, + ROB_OSAGE_PARTS_APPEND_L = 0x06, + ROB_OSAGE_PARTS_APPEND_R = 0x07, + ROB_OSAGE_PARTS_MUFFLER = 0x08, + ROB_OSAGE_PARTS_WHITE_ONE_L = 0x09, + ROB_OSAGE_PARTS_PONY = 0x0A, + ROB_OSAGE_PARTS_ANGEL_L = 0x0B, + ROB_OSAGE_PARTS_ANGEL_R = 0x0C, + ROB_OSAGE_PARTS_MAX = 0x0D, +}; + +enum ExNodeType { + EX_NONE = 0x00, + EX_OSAGE = 0x01, + EX_EXPRESSION = 0x02, + EX_CONSTRAINT = 0x03, + EX_CLOTH = 0x04, +}; + +namespace SkinParam { + enum CollisionType { + CollisionTypeEnd = 0x0, + CollisionTypeBall = 0x1, + CollisionTypeCapsule = 0x2, + CollisionTypePlane = 0x3, + CollisionTypeEllipse = 0x4, + CollisionTypeAABB = 0x5, + CollisionTypeMax = 0x6, + }; + + enum RootCollisionType { + RootCollisionTypeEnd = 0x00, + RootCollisionTypeCapsule = 0x01, + RootCollisionTypeCapsuleWithRoot = 0x02, + RootCollisionTypeMax = 0x03, + }; +} + +struct rob_chara; +struct rob_chara_bone_data; + +struct bone_node_expression_data { + vec3 position; + vec3 rotation; + vec3 scale; + vec3 parent_scale; +}; + +static_assert(sizeof(bone_node_expression_data) == 0x30, "\"bone_node_expression_data\" struct should have a size of 0x30"); + +struct bone_node { + const char* name; + mat4* mat; + bone_node* parent; + bone_node_expression_data exp_data; + mat4* ex_data_mat; +}; + +static_assert(sizeof(bone_node) == 0x50, "\"bone_node\" struct should have a size of 0x50"); + +struct rob_sleeve_data { + float_t radius; + float_t cyofs; + float_t czofs; + float_t ymin; + float_t ymax; + float_t zmin; + float_t zmax; + float_t mune_xofs; + float_t mune_yofs; + float_t mune_zofs; + float_t mune_rad; +}; + +static_assert(sizeof(rob_sleeve_data) == 0x2C, "\"rob_sleeve_data\" struct should have a size of 0x2C"); + +struct eyes_adjust { + bool xrot_adjust; + eyes_base_adjust_type base_adjust; + float_t neg; + float_t pos; +}; + +static_assert(sizeof(eyes_adjust) == 0x10, "\"eyes_adjust\" struct should have a size of 0x10"); + +union rob_chara_pv_data_item { + struct { + int32_t head; + int32_t face; + int32_t chest; + int32_t back; + }; + int32_t arr[4]; +}; + +static_assert(sizeof(rob_chara_pv_data_item) == 0x10, "\"rob_chara_pv_data_item\" struct should have a size of 0x10"); + +struct rob_chara_pv_data { + rob_chara_type type; + bool field_4; + bool field_5; + bool field_6; + vec3 field_8; + int16_t rot_y_int16; + int16_t field_16; + rob_sleeve_data sleeve_l; + rob_sleeve_data sleeve_r; + int32_t field_70; + uint32_t motion_face_ids[10]; + int32_t chara_size_index; + bool height_adjust; + rob_chara_pv_data_item item; + eyes_adjust eyes_adjust; +}; + +static_assert(sizeof(rob_chara_pv_data) == 0xC4, "\"rob_chara_pv_data\" struct should have a size of 0xC4"); + +struct rob_chara_item_equip_object; + +class ExNodeBlock; + +struct ExNodeBlock_vtbl { + ExNodeBlock* (FASTCALL* Dispose)(ExNodeBlock* This, uint8_t); + void(FASTCALL* Field_8)(ExNodeBlock* This); + void(FASTCALL* Field_10)(ExNodeBlock* This); + void(FASTCALL* Field_18)(ExNodeBlock* This, int32_t stage, bool disable_external_force); + void(FASTCALL* Field_20)(ExNodeBlock* This); + void(FASTCALL* SetOsagePlayData)(ExNodeBlock* This); + void(FASTCALL* Disp)(ExNodeBlock* This); + void(FASTCALL* Reset)(ExNodeBlock* This); + void(FASTCALL* Field_40)(ExNodeBlock* This); + void(FASTCALL* Field_48)(ExNodeBlock* This); + void(FASTCALL* Field_50)(ExNodeBlock* This); + void(FASTCALL* Field_58)(ExNodeBlock* This); +}; + +static_assert(sizeof(ExNodeBlock_vtbl) == 0x60, "\"ExNodeBlock_vtbl\" struct should have a size of 0x60"); + +class ExNodeBlock { +public: + ExNodeBlock_vtbl* __vftable; + bone_node* bone_node_ptr; + ExNodeType type; + const char* name; + bone_node* parent_bone_node; + prj::string parent_name; + ExNodeBlock* parent_node; + rob_chara_item_equip_object* item_equip_object; + bool field_58; + bool field_59; + bool has_children_node; +}; + +static_assert(sizeof(ExNodeBlock) == 0x60, "\"ExNodeBlock\" struct should have a size of 0x60"); + +struct RobOsageNode; + +struct RobOsageNodeDataNormalRef { + bool set; + RobOsageNode* n; + RobOsageNode* u; + RobOsageNode* d; + RobOsageNode* l; + RobOsageNode* r; + mat4 mat; +}; + +static_assert(sizeof(RobOsageNodeDataNormalRef) == 0x70, "\"RobOsageNodeDataNormalRef\" struct should have a size of 0x70"); + +struct skin_param_hinge { + float_t ymin; + float_t ymax; + float_t zmin; + float_t zmax; +}; + +static_assert(sizeof(skin_param_hinge) == 0x10, "\"skin_param_hinge\" struct should have a size of 0x10"); + +struct skin_param_osage_node { + float_t coli_r; + float_t weight; + float_t inertial_cancel; + skin_param_hinge hinge; +}; + +static_assert(sizeof(skin_param_osage_node) == 0x1C, "\"skin_param_osage_node\" struct should have a size of 0x1C"); + +struct RobOsageNodeResetData { + vec3 pos; + vec3 delta_pos; + vec3 rotation; + float_t length; +}; + +static_assert(sizeof(RobOsageNodeResetData) == 0x28, "\"RobOsageNodeResetData\" struct should have a size of 0x28"); + +struct skin_param_osage_root; + +struct RobOsageNodeData { + float_t force; + prj::vector boc; + RobOsageNodeDataNormalRef normal_ref; + skin_param_osage_node skp_osg_node; +}; + +static_assert(sizeof(RobOsageNodeData) == 0xB0, "\"RobOsageNodeData\" struct should have a size of 0xB0"); + +struct opd_blend_data { + int32_t motion_id; + float_t frame; + float_t frame_count; + bool use_blend; + MotionBlendType type; + float_t blend; +}; + +static_assert(sizeof(opd_blend_data) == 0x18, "\"opd_blend_data\" struct should have a size of 0x18"); + +struct opd_vec3_data { + const float_t* x; + const float_t* y; + const float_t* z; +}; + +static_assert(sizeof(opd_vec3_data) == 0x18, "\"opd_vec3_data\" struct should have a size of 0x18"); + +struct opd_node_data { + float_t length; + vec3 rotation; +}; + +static_assert(sizeof(opd_node_data) == 0x10, "\"opd_node_data\" struct should have a size of 0x10"); + +struct opd_node_data_pair { + opd_node_data curr; + opd_node_data prev; +}; + +static_assert(sizeof(opd_node_data_pair) == 0x20, "\"opd_node_data_pair\" struct should have a size of 0x20"); + +struct RobOsageNode { + float_t length; + vec3 pos; + vec3 fixed_pos; + vec3 delta_pos; + vec3 vel; + float_t child_length; + bone_node* bone_node_ptr; + mat4* bone_node_mat; + mat4 mat; + RobOsageNode* sibling_node; + float_t max_distance; + vec3 rel_pos; + RobOsageNodeResetData reset_data; + float_t hit; + float_t friction; + vec3 external_force; + float_t force; + RobOsageNodeData* data_ptr; + RobOsageNodeData data; + prj::vector opd_data; + opd_node_data_pair opd_node_data; +}; + +static_assert(sizeof(RobOsageNode) == 0x1D0, "\"RobOsageNode\" struct should have a size of 0x1D0"); + +namespace SkinParam { + struct CollisionParam { + CollisionType type; + int32_t node_idx[2]; + float_t radius; + vec3 pos[2]; + + CollisionParam(); + }; + + static_assert(sizeof(SkinParam::CollisionParam) == 0x28, "\"SkinParam::CollisionParam\" struct should have a size of 0x28"); +}; + +struct skin_param_osage_root_normal_ref { + prj::string n; + prj::string u; + prj::string d; + prj::string l; + prj::string r; +}; + +static_assert(sizeof(skin_param_osage_root_normal_ref) == 0xA0, "\"skin_param_osage_root_normal_ref\" struct should have a size of 0xA0"); + +struct skin_param_osage_root_boc { + int32_t ed_node; + prj::string ed_root; + int32_t st_node; +}; + +static_assert(sizeof(skin_param_osage_root_boc) == 0x30, "\"skin_param_osage_root_boc\" struct should have a size of 0x30"); + +struct skin_param_osage_root { + int32_t field_0; + float_t force; + float_t force_gain; + float_t air_res; + float_t rot_y; + float_t rot_z; + float_t init_rot_y; + float_t init_rot_z; + float_t hinge_y; + float_t hinge_z; + const char* name; + prj::vector coli; + float_t coli_r; + float_t friction; + float_t wind_afc; + int32_t yz_order; + prj::vector boc; + SkinParam::RootCollisionType coli_type; + float_t stiffness; + float_t move_cancel; + prj::string colli_tgt_osg; + prj::vector normal_ref; +}; + +static_assert(sizeof(skin_param_osage_root) == 0xB8, "\"skin_param_osage_root\" struct should have a size of 0xB8"); + +struct skin_param { + prj::vector coli; + float_t friction; + float_t wind_afc; + float_t air_res; + vec3 rot; + vec3 init_rot; + SkinParam::RootCollisionType coli_type; + float_t stiffness; + float_t move_cancel; + float_t coli_r; + skin_param_hinge hinge; + float_t force; + float_t force_gain; + prj::vector* colli_tgt_osg; +}; + +static_assert(sizeof(skin_param) == 0x70, "\"skin_param\" struct should have a size of 0x70"); + +struct OsageCollision { + struct Work { + SkinParam::CollisionType type; + float_t radius; + vec3 pos[2]; + vec3 vec_center; + float_t vec_center_length; + float_t vec_center_length_squared; + float_t friction; + }; + + static_assert(sizeof(OsageCollision::Work) == 0x38, "\"OsageCollision::Work\" struct should have a size of 0x38"); + + prj::vector work_list; +}; + +static_assert(sizeof(OsageCollision) == 0x18, "\"OsageCollision\" struct should have a size of 0x18"); + +struct osage_ring_data { + float_t ring_rectangle_x; + float_t ring_rectangle_y; + float_t ring_rectangle_width; + float_t ring_rectangle_height; + float_t ring_height; + float_t ring_out_height; + bool init; + OsageCollision coli; + prj::vector skp_root_coli; +}; + +static_assert(sizeof(osage_ring_data) == 0x50, "\"OsageCollision\" struct should have a size of 0x50"); + +struct skin_param_file_data; + +struct CLOTHNode { + uint32_t flags; + vec3 pos; + vec3 fixed_pos; + vec3 prev_pos; + vec3 delta_pos; + vec3 normal; + vec3 tangent; + vec3 binormal; + float_t tangent_sign; + vec2 texcoord; + vec3 direction; + float_t dist_up; + float_t dist_down; + float_t dist_right; + float_t dist_left; + vec3 field_80; + RobOsageNodeResetData reset_data; + prj::vector opd_data; + opd_node_data_pair opd_node_data; +}; + +static_assert(sizeof(CLOTHNode) == 0xF0, "\"CLOTHNode\" struct should have a size of 0xF0"); + +struct CLOTHLine { + size_t idx[2]; + float_t length; +}; + +static_assert(sizeof(CLOTHLine) == 0x18, "\"CLOTHLine\" struct should have a size of 0x18"); + +class CLOTH; + +struct CLOTH_vtbl { + CLOTH* (FASTCALL* Dispose)(CLOTH* This, uint8_t); + void(FASTCALL* Field_8)(CLOTH* This); + void(FASTCALL* Field_10)(CLOTH* This); + void(FASTCALL* Field_18)(CLOTH* This, int32_t stage, bool disable_external_force); + void(FASTCALL* Field_20)(CLOTH* This); + void(FASTCALL* SetOsagePlayData)(CLOTH* This); + void(FASTCALL* Disp)(CLOTH* This); + void(FASTCALL* Reset)(CLOTH* This); + void(FASTCALL* Field_40)(CLOTH* This); + void(FASTCALL* Field_48)(CLOTH* This); + void(FASTCALL* Field_50)(CLOTH* This); + void(FASTCALL* Field_58)(CLOTH* This); +}; + +static_assert(sizeof(CLOTH_vtbl) == 0x60, "\"CLOTH_vtbl\" struct should have a size of 0x60"); + +class CLOTH { +public: + CLOTH_vtbl* __vftable; + int32_t field_8; + size_t root_count; + size_t nodes_count; + prj::vector nodes; + vec3 wind_direction; + float_t field_44; + bool set_external_force; + vec3 external_force; + prj::vector lines; + skin_param* skin_param_ptr; + skin_param skin_param; + OsageCollision::Work coli[64]; + OsageCollision::Work coli_ring[64]; + osage_ring_data ring; + mat4* mats; +}; + +static_assert(sizeof(CLOTH) == 0x1D40, "\"CLOTH\" struct should have a size of 0x1D40"); + +struct RobClothRoot { + vec3 pos; + vec3 normal; + vec4 tangent; + bone_node* node[4]; + mat4* node_mat[4]; + mat4* mat[4]; + float_t weight[4]; + mat4 field_98; + mat4 field_D8; + mat4 field_118; +}; + +static_assert(sizeof(RobClothRoot) == 0x158, "\"RobClothRoot\" struct should have a size of 0x158"); + +struct RobClothSubMeshArray { + obj_sub_mesh arr[4]; +}; + +static_assert(sizeof(RobClothSubMeshArray) == 0x1C0, "\"RobClothSubMeshArray\" struct should have a size of 0x1C0"); + +class RobCloth : public CLOTH { +public: + prj::vector root; + rob_chara_item_equip_object* itm_eq_obj; + struct obj_skin_block_cloth_root* cls_root; + struct obj_skin_block_cloth* cls_data; + float_t move_cancel; + bool osage_reset; + obj_mesh mesh[2]; + RobClothSubMeshArray submesh[2]; + obj_axis_aligned_bounding_box axis_aligned_bounding_box; + obj_mesh_vertex_buffer vertex_buffer[2]; + obj_mesh_index_buffer index_buffer[2]; + prj::map, prj::list> motion_reset_data; + prj::list* reset_data_list; +}; + +static_assert(sizeof(RobCloth) == 0x23C0, "\"RobCloth\" struct should have a size of 0x23C0"); + +class ExClothBlock : public ExNodeBlock { +public: + RobCloth rob; + struct obj_skin_block_cloth* cls_data; + mat4* mats; + size_t index; +}; + +static_assert(sizeof(ExClothBlock) == 0x2438, "\"ExClothBlock\" struct should have a size of 0x2438"); + +struct skin_param_file_data { + skin_param skin_param; + prj::vector nodes_data; + bool field_88; +}; + +static_assert(sizeof(skin_param_file_data) == 0x90, "\"skin_param_file_data\" struct should have a size of 0x90"); + +struct osage_setting_osg_cat { + rob_osage_parts parts; + size_t exf; +}; + +static_assert(sizeof(osage_setting_osg_cat) == 0x10, "\"osage_setting_osg_cat\" struct should have a size of 0x10"); + +struct RobOsage { + skin_param* skin_param_ptr; + bone_node_expression_data exp_data; + prj::vector nodes; + RobOsageNode end_node; + skin_param skin_param; + osage_setting_osg_cat osage_setting; + bool field_2A0; + bool field_2A1; + float_t field_2A4; + OsageCollision::Work coli[64]; + OsageCollision::Work coli_ring[64]; + vec3 wind_direction; + float_t field_1EB4; + int32_t yz_order; + int32_t field_1EBC; + mat4* root_matrix_ptr; + mat4 root_matrix; + float_t move_cancel; + bool field_1F0C; + bool osage_reset; + bool prev_osage_reset; + bool disable_collision; + osage_ring_data ring; + prj::map, prj::list> motion_reset_data; + prj::list* reset_data_list; + bool set_external_force; + vec3 external_force; + + void SetAirRes(float_t air_res); + void SetColiR(float_t coli_r); + void SetForce(float_t force, float_t force_gain); + void SetHinge(float_t hinge_y, float_t hinge_z); + void SetInitRot(float_t init_rot_y, float_t init_rot_z); + void SetMotionResetData(uint32_t motion_id, float_t frame); + void SetNodesExternalForce(vec3* external_force, float_t strength); + void SetNodesForce(float_t force); + void SetRot(float_t rot_y, float_t rot_z); +}; + +static_assert(sizeof(RobOsage) == 0x1F88, "\"RobOsage\" struct should have a size of 0x1F88"); + +class ExOsageBlock : public ExNodeBlock { +public: + size_t index; + RobOsage rob; + mat4* mats; + int32_t field_1FF8; + float_t step; +}; + +static_assert(sizeof(ExOsageBlock) == 0x2000, "\"ExOsageBlock\" struct should have a size of 0x2000"); + +struct rob_chara_item_equip; + +struct rob_chara_item_equip_object { + size_t index; + mat4* mats; + object_info obj_info; + int32_t field_14; + prj::vector texture_pattern; + texture_data_struct texture_data; + bool null_blocks_data_set; + bone_node_expression_data exp_data; + float_t alpha; + mdl::ObjFlags obj_flags; + bool can_disp; + int32_t field_A4; + mat4* mat; + int32_t init_iterations; + bone_node* bone_nodes; + prj::vector node_blocks; + prj::vector ex_data_bone_nodes; + prj::vector ex_data_bone_mats; + prj::vector ex_data_mats; + prj::vector_pair ex_bones; + int64_t field_138; + prj::vector null_blocks; + prj::vector osage_blocks; + prj::vector constraint_blocks; + prj::vector expression_blocks; + prj::vector cloth_blocks; + bool osage_depends_on_others; + int32_t auth_obj_index; // RobTexAnim + size_t osage_nodes_count; + bool use_opd; + int32_t auth_3d_id; // RobTexAnim + obj_skin_ex_data* skin_ex_data; + obj_skin* skin; + rob_chara_item_equip* item_equip; + + int32_t get_bone_index(const char* name); + bone_node* get_bone_node(int32_t bone_index); + bone_node* get_bone_node(const char* name); + void skp_load(void* can_prop); // CanonicalProperties +}; + +static_assert(sizeof(rob_chara_item_equip_object) == 0x1E8, "\"rob_chara_item_equip_object\" struct should have a size of 0x1E8"); + +struct rob_chara_item_equip { + bone_node* bone_nodes; + mat4* matrices; + rob_chara_item_equip_object* item_equip_object; + int32_t field_18[31]; + bool item_equip_range; + item_id first_item_equip_object; + item_id max_item_equip_object; + int32_t field_A0; + shadow_type_enum shadow_type; + vec3 position; + prj::vector texture_pattern; + object_info field_D0; + item_id field_D4; + bool disable_update; + int32_t field_DC; + vec4 texture_color_coefficients; + float_t wet; + float_t wind_strength; + bool chara_color; + bool npr_flag; + mat4 mat; + mat4 field_13C[30]; + int32_t field_8BC; + int32_t field_8C0; + int32_t field_8C4; + int32_t field_8C8; + int32_t field_8CC; + int32_t field_8D0; + int32_t field_8D4; + int32_t field_8D8; + int32_t field_8DC; + int32_t field_8E0; + int32_t field_8E4; + int32_t field_8E8; + int32_t field_8EC; + int32_t field_8F0; + int32_t field_8F4; + int32_t field_8F8; + int32_t field_8FC; + int64_t field_900; + int64_t field_908; + int64_t field_910; + int64_t field_918; + int64_t field_920; + int64_t field_928; + int64_t field_930; + float_t osage_step; + bool use_opd; + prj::vector opd_blend_data; + bool parts_short; + bool parts_append; + bool parts_white_one_l; + + rob_chara_item_equip_object* get_item_equip_object(item_id id); +}; + +static_assert(sizeof(rob_chara_item_equip) == 0x960, "\"rob_chara_item_equip\" struct should have a size of 0x960"); + +struct item_cos_texture_change_tex { + texture* org; + texture* chg; + bool changed; +}; + +static_assert(sizeof(item_cos_texture_change_tex) == 0x18, "\"rob_chara_item_cos_data\" struct should have a size of 0x18"); + +struct rob_chara_item_cos_data { + ::chara_index chara_index; + ::chara_index chara_index_2nd; + item_cos_data cos; + item_cos_data cos_2nd; + prj::map> texture_change; + prj::map> item_change; + prj::map field_F0; + prj::map field_100; + std::vector texture_pattern[31]; + std::map head_replace; +}; + +static_assert(sizeof(rob_chara_item_cos_data) == 0x408, "\"rob_chara_item_cos_data\" struct should have a size of 0x408"); + +struct struc_264 { + uint8_t data[0x1D8]; +}; + +static_assert(sizeof(struc_264) == 0x1D8, "\"struc_264\" struct should have a size of 0x1D8"); + +struct RobSubAction { + uint8_t data[0xB0]; +}; + +static_assert(sizeof(RobSubAction) == 0xB0, "\"RobSubAction\" struct should have a size of 0xB0"); + +struct struc_389 { + float_t frame; + float_t prev_frame; + float_t last_set_frame; +}; + +static_assert(sizeof(struc_389) == 0x0C, "\"struc_389\" struct should have a size of 0x0C"); + +struct struc_406 { + float_t frame; + float_t field_4; + float_t step; +}; + +static_assert(sizeof(struc_406) == 0x0C, "\"struc_406\" struct should have a size of 0x0C"); + +struct rob_chara_data_hand_adjust { + bool enable; + int16_t scale_select; + rob_chara_data_hand_adjust_type type; + float_t current_scale; + float_t scale; + float_t duration; + float_t current_time; + float_t rotation_blend; + float_t scale_blend; + bool enable_scale; + bool disable_x; + bool disable_y; + bool disable_z; + vec3 offset; + vec3 field_30; + float_t arm_length; + int32_t field_40; +}; + +static_assert(sizeof(rob_chara_data_hand_adjust) == 0x44, "\"rob_chara_data_hand_adjust\" struct should have a size of 0x44"); + +struct rob_chara_motion { + uint32_t motion_id; + uint32_t prev_motion_id; + struc_389 frame_data; + struc_406 step_data; + uint8_t data[0x1198]; + rob_chara_data_hand_adjust hand_adjust[2]; + rob_chara_data_hand_adjust hand_adjust_prev[2]; + uint8_t data1[0x30]; +}; + +static_assert(sizeof(rob_chara_motion) == 0x12F8, "\"rob_chara_motion\" struct should have a size of 0x12F8"); + +struct struc_526 { + int32_t field_0; + int32_t field_4; +}; + +struct struc_228 { + int32_t field_0; + int32_t field_4; + uint32_t field_8; + int32_t field_C; +}; + +struct struc_227 { + int32_t field_0; + float_t field_4; + float_t field_8; +}; + +struct struc_652 { + int32_t motion_id; + float_t frame_count; + float_t frame; + int16_t field_C; + struc_228 field_10; + struc_228 field_20; + struc_228 field_30; + struc_228 field_40; + int16_t field_50; + int16_t field_52; + int16_t field_54; + int32_t field_58; + int32_t field_5C; + int32_t field_60; + int32_t field_64; + int32_t field_68; + int32_t loop_count; + float_t loop_begin; + float_t loop_end; + float_t field_78; + float_t field_7C; + float_t field_80; + int8_t field_84; + int32_t field_88; + int32_t field_8C; + int32_t field_90; + int16_t field_94; + int16_t field_96; + int16_t field_98; + int32_t field_9C; + int16_t field_A0; + int32_t field_A4; + int64_t field_A8; + struc_227 field_B0[26]; + int32_t field_1E8; + float_t field_1EC; + float_t field_1F0; + float_t field_1F4; + float_t field_1F8; + float_t field_1FC; + float_t field_200; + int32_t field_204; + int32_t field_208; + int32_t field_20C; + int64_t field_210; + float_t field_218; + float_t field_21C; + int16_t field_220; + prj::list field_228; + int16_t field_238; + float_t field_23C; + int32_t field_240; + int16_t field_244; + const void* field_248; + int64_t field_250; + float_t field_258; + int32_t field_25C; + struc_526 field_260; + struc_526 field_268; + int32_t field_270; + int16_t field_274; + int16_t field_276; + int32_t field_278; + int32_t field_27C; + int32_t field_280; + int16_t field_284; + int64_t field_288; + int32_t field_290; + int32_t field_294; + int32_t field_298; + float_t field_29C; + int8_t field_2A0; + float_t field_2A4; + float_t field_2A8; + float_t field_2AC; + int64_t field_2B0; + int16_t field_2B8; + int32_t field_2BC; + float_t field_2C0; + float_t field_2C4; + int32_t field_2C8; + int32_t field_2CC; + int64_t field_2D0; + int64_t field_2D8; + int64_t field_2E0; + int16_t field_2E8; + int32_t field_2EC; + int32_t field_2F0; + struc_526 field_2F4; + int32_t field_2FC; + int8_t field_300; + int32_t field_304; + int32_t field_308; + float_t field_30C; + int32_t field_310; + int16_t field_314; + vec3 field_318; + float_t field_324; + float_t field_328; + int32_t iterations; +}; + +struct struc_377 { + struct mothead_data* current; + struct mothead_data* data; +}; + +struct struc_226 { + int8_t field_0[27]; +}; + +struct struc_225 { + float_t field_0[27]; +}; + +struct struc_224 { + int32_t field_0[27]; +}; + +struct struc_306 { + int16_t field_0; + float_t frame; + float_t field_8; + int16_t field_C; + int16_t field_E; + vec3 field_10; + vec3 field_1C; + vec3 field_28; + int32_t field_34; + int32_t field_38; + int32_t field_3C; + int32_t field_40; + int32_t field_44; + int32_t field_48; +}; + +struct struc_651 { + struc_377 field_0; + int32_t field_10; + int32_t field_14; + int32_t field_18; + float_t field_1C; + vec3 field_20; + struc_226 field_2C[3]; + struc_225 field_80[3]; + struc_224 field_1C4[3]; + int64_t field_308; + float_t field_310; + float_t field_314; + int8_t field_318; + int32_t field_31C; + float_t field_320; + float_t field_324; + float_t field_328; + float_t field_32C; + float_t field_330; + float_t field_334; + int8_t field_338; + struc_306 field_33C[4]; +}; + +struct struc_223 { + struc_652 field_0; + struc_651 field_330; + int64_t* field_7A0; + int32_t motion_set_id; +}; + +static_assert(sizeof(struc_223) == 0x7B0, "\"struc_223\" struct should have a size of 0x7B0"); + +struct rob_chara_data_miku_rot { + uint8_t data[0xAC]; +}; + +static_assert(sizeof(rob_chara_data_miku_rot) == 0xAC, "\"rob_chara_data_miku_rot\" struct should have a size of 0xAC"); + +struct rob_chara_adjust_data { + float_t scale; + bool height_adjust; + float_t pos_adjust_y; + vec3 pos_adjust; + vec3 offset; + bool offset_x; + bool offset_y; + bool offset_z; + bool get_global_position; + vec3 pos; + mat4 mat; + float_t left_hand_scale; + float_t right_hand_scale; + float_t left_hand_scale_default; + float_t right_hand_scale_default; +}; + +static_assert(sizeof(rob_chara_adjust_data) == 0x84, "\"rob_chara_adjust_data\" struct should have a size of 0x84"); + +struct struc_209 { + uint8_t data[0x1F28]; +}; + +static_assert(sizeof(struc_209) == 0x1F28, "\"struc_209\" struct should have a size of 0x1F28"); + +struct rob_chara_data { + uint8_t field_0; + uint8_t field_1; + uint8_t field_2; + uint8_t field_3; + int32_t field_4; + struc_264 field_8; + RobSubAction rob_sub_action; + rob_chara_motion motion; + struc_223 field_1588; + rob_chara_data_miku_rot miku_rot; + rob_chara_adjust_data adjust_data; + struc_209 field_1E68; + float_t field_3D90; + int32_t field_3D94; + int16_t field_3D98; + int16_t field_3D9A; + int32_t field_3D9C; + int32_t field_3DA0; + int8_t field_3DA4; + int64_t field_3DA8; + int64_t field_3DB0; + int32_t field_3DB8; + int32_t field_3DBC; + int32_t field_3DC0; + int32_t field_3DC4; + int32_t field_3DC8; + int32_t field_3DCC; + int32_t field_3DD0; + float_t field_3DD4; + int32_t field_3DD8; + float_t field_3DDC; + int8_t field_3DE0; +}; + +static_assert(sizeof(rob_chara_data) == 0x3DE8, "\"rob_chara_data\" struct should have a size of 0x3DE8"); + +struct rob_touch { + uint8_t data[0x28]; +}; + +static_assert(sizeof(rob_touch) == 0x28, "\"rob_touch\" struct should have a size of 0x28"); + +struct rob_chara { + int8_t chara_id; + int8_t field_1; + int8_t field_2; + int8_t field_3; + int32_t type; + int16_t field_8; + int16_t field_A; + bool field_C; + bool field_D; + chara_index chara_index; + int32_t cos_id; + int32_t field_18; + float_t frame_speed; + void* field_20; + struct rob_chara_bone_data* bone_data; + rob_chara_item_equip* item_equip; + rob_chara_item_cos_data item_cos_data; + rob_chara_data data; + rob_chara_data data_prev; + struct chara_init_data* chara_init_data; + struct rob_detail* rob_detail; + rob_chara_pv_data pv_data; + int32_t field_80E4; + rob_touch rob_touch; + + inline bool is_visible() { + return !!(data.field_0 & 0x01); + } +}; + +static_assert(sizeof(rob_chara) == 0x8110, "\"rob_chara\" struct should have a size of 0x8110"); + +#define ROB_CHARA_COUNT 6 + +extern rob_chara* rob_chara_array; + +extern const mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index); +extern bool (FASTCALL* pv_osage_manager_array_get_disp)(int32_t* chara_id); +extern const char* (FASTCALL* chara_index_get_auth_3d_name)(chara_index chara_index); +extern void(FASTCALL* sub_1405163C0)(rob_chara* rob_chr, int32_t index, mat4* mat); +extern float_t(FASTCALL* rob_chara_get_max_face_depth)(rob_chara* rob_chr); +extern const mat4* (FASTCALL* rob_chara_get_bone_data_mat)(rob_chara* rob_chr, mot_bone_index index); +extern const mat4* (FASTCALL* sub_140516740)(rob_chara* rob_chr); +extern bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr_smth, int32_t chara_id); +extern rob_chara* (FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id); +extern size_t(FASTCALL* get_rob_chara_smth)(); +extern rob_chara_item_equip* (FASTCALL* rob_chara_array_get_item_equip)(size_t rob_chr_smth, int32_t chara_id); +extern size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id); +extern bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id); + +extern const mat4* rob_chara_get_adjust_data_mat(rob_chara* rob_chr); diff --git a/src/AFTModsShared/shader.hpp b/src/AFTModsShared/shader.hpp new file mode 100644 index 0000000..eb620e2 --- /dev/null +++ b/src/AFTModsShared/shader.hpp @@ -0,0 +1,75 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +enum ShaderName { + SHADER_FFP = 0, + _BLINN, + _ITEM, + _STAGE, + _SKIN, + _SSS_SKIN, + _SSS_FILT, + _HAIR, + _CLOTH, + _TIGHTS, + _SKY, + _EYEBALL, + _EYELENSE, + _GLASEYE, + _MEMBRAN, + _SHDMAP, + _ESM, + _ESMGAUSS, + _ESMFILT, + _LITPROJ, + _SIMPLE, + _SIL, + _LAMBERT, + _CONSTANT, + _PEEL, + _TONEMAP, + _REDUCE, + _MAGNIFY, + _MLAA, + _CONTOUR, + _EXPOSURE, + _GAUSS, + _SUN, + _FADE, + _WATER01, + _WATER02, + _WATRING, + _W_PTCL, + _SNOW_PT, + _LEAF_PT, + _STAR, + _SNORING, + _SN_FOOT, + _SN_TSL, + _SN_NRM, + _FLOOR, + _PUDDLE, + _S_REFL, + _S_REFR, + _RIPEMIT, + _RAIN, + _VOLLIT, + _FENCE, + _RIPPLE, + _FOGPTCL, + _PARTICL, + _GLITTER_PT, + _SHOW_VEC, + _FONT, + _MOVIE, + _IMGFILT, + _SPRITE, + SHADER_END, + SHADER_MAX, +}; + +static_assert(SHADER_MAX == 0x3F, "\"SHADER_MAX\" enum should have a value of 0x3F"); diff --git a/src/AFTModsShared/shadow.hpp b/src/AFTModsShared/shadow.hpp new file mode 100644 index 0000000..8e69d0f --- /dev/null +++ b/src/AFTModsShared/shadow.hpp @@ -0,0 +1,15 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "types.hpp" + +enum shadow_type_enum { + SHADOW_CHARA = 0, + SHADOW_STAGE, + SHADOW_MAX, +}; diff --git a/src/AFTModsShared/sprite.cpp b/src/AFTModsShared/sprite.cpp new file mode 100644 index 0000000..ffeb48c --- /dev/null +++ b/src/AFTModsShared/sprite.cpp @@ -0,0 +1,266 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "sprite.hpp" +#include "camera.hpp" +#include "shader.hpp" +#include + +namespace spr { + struct SpriteVertexData { + size_t max_count; + spr::SpriteVertex* array; + }; +} + +vec4& spr_color = *(vec4*)0x00000001411ACC30; + +void (FASTCALL* sprite_manager_unload_set)(int32_t set_id) + = (void (FASTCALL*)(int32_t set_id))0x000000014063F8D0; +size_t(FASTCALL* sprite_manager_get_reqlist_count)(int32_t index) + = (size_t(FASTCALL*)(int32_t index))0x000000014063FA90; +void (FASTCALL* sprite_manager_read_file)(int32_t set_id, const prj::string mdata_dir) + = (void (FASTCALL*)(int32_t set_id, const prj::string mdata_dir))0x0000000140640E10; +bool (FASTCALL* sprite_manager_load_file)(int32_t set_id) + = (bool (FASTCALL*)(int32_t set_id))0x0000000140640FB0; + +spr::SpriteVertexData& sprite_vertex_data = *(spr::SpriteVertexData*)0x000000014CC62480; + +const size_t sprite_vertex_array_max_count = 0x2000; +spr::SpriteVertex* sprite_vertex_array = (spr::SpriteVertex*)0x000000014CC62480; + +size_t& sprite_vertex_array_count = *(size_t*)0x000000014CC611B0; + +bool sprite_break_sprite_vertex_limit = false; + +namespace spr { + void(FASTCALL* put_cross)(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z) + = (void(FASTCALL*)(const mat4 & mat, color4u8 color_x, color4u8 color_y, color4u8 color_z))0x00000001404BC920; + void(FASTCALL* put_rgb_cross)(const mat4& mat) = (void(FASTCALL*)(const mat4 & mat))0x00000001404BC8F0; + spr::SprArgs* (FASTCALL* put_sprite)(const spr::SprArgs& args) + = (spr::SprArgs * (FASTCALL*)(const spr::SprArgs & args))0x0000000140640740; + + SprArgs::SprArgs() : kind(), attr(), blend(), index(), layer(), + prio(), resolution_mode_screen(), resolution_mode_sprite(), texture(), + shader(), vertex_array(), num_vertex(), flags(), field_CC(), next() { + Reset(); + } + + SpriteVertex* SprArgs::GetVertexArray() { + if (sprite_break_sprite_vertex_limit) + return sprite_vertex_data.array + vertex_array; + else + return vertex_array_ptr; + } + + void SprArgs::Reset() { + kind = SPR_KIND_NORMAL; + id = {}; + color = 0xFFFFFFFF; + attr = (SprAttr)0; + blend = 0; + index = -1; + layer = 0; + prio = SPR_PRIO_DEFAULT; + resolution_mode_screen = RESOLUTION_MODE_HD; + resolution_mode_sprite = RESOLUTION_MODE_HD; + center = 0.0f; + trans = 0.0f; + scale = 1.0f; + rot = 0.0f; + skew_angle = 0.0f; + mat = mat4_identity; + texture = 0; + shader = SHADER_FFP; + if (sprite_break_sprite_vertex_limit) + vertex_array = -1; + else + vertex_array = 0; + num_vertex = 0; + flags = (SprArgs::Flags)0; + sprite_size = 0.0f; + field_CC = 0; + texture_pos = 0.0f; + texture_size = 1.0f; + next = 0; + } + + void SprArgs::SetSpriteSize(vec2 size) { + if (flags & SPRITE_SIZE) + return; + + enum_or(flags, SPRITE_SIZE); + sprite_size = size; + field_CC = 0; + } + + void SprArgs::SetTexturePosSize(float_t x, float_t y, float_t width, float_t height) { + if (flags & TEXTURE_POS_SIZE) + return; + + enum_or(flags, TEXTURE_POS_SIZE); + texture_pos.x = x; + texture_pos.y = y; + texture_size.x = width; + texture_size.y = height; + } + + void SprArgs::SetVertexArray(SpriteVertex* vertex_array, size_t num_vertex) { + void (FASTCALL * spr__SprArgs__SetVertexArray)(spr::SprArgs * This, + spr::SpriteVertex * vertex_array, size_t num_vertex) + = (void (FASTCALL*)(spr::SprArgs * This, + spr::SpriteVertex * vertex_array, size_t num_vertex))0x000000014063F040; + spr__SprArgs__SetVertexArray(this, vertex_array, num_vertex); + } + + void SprArgs::SetNext(SprArgs* args, SprArgs* next) { + while (args->next) + args = args->next; + args->next = next; + next->kind = SPR_KIND_LINE; + } + + vec2 proj_sprite_3d_line(vec3 vec, bool offset) { + mat4 view; + mat4_transpose(&camera_data.view, &view); + + mat4_transform_point(&view, &vec, &vec); + if (fabsf(vec.z) < 1.0e-10f) + return 0.0f; + + vec2 sc_vec = camera_data.depth * *(vec2*)&vec.x * (1.0f / vec.z); + + resolution_struct* res_wind_int = res_window_internal_get(); + sc_vec.x = (float_t)res_wind_int->width * 0.5f - sc_vec.x; + sc_vec.y = (float_t)res_wind_int->height * 0.5f + sc_vec.y; + if (offset) { + resolution_struct* res_wind = res_window_get(); + sc_vec.x = (float_t)res_wind_int->x_offset + sc_vec.x; + sc_vec.y = (float_t)(res_wind->height + - res_wind_int->y_offset - res_wind_int->height) + sc_vec.y; + } + return sc_vec; + } + + void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color) { + vec2 sc_p1 = proj_sprite_3d_line(p1, true); + vec2 sc_p2 = proj_sprite_3d_line(p2, true); + spr::put_sprite_line(sc_p1, sc_p2, RESOLUTION_MODE_MAX, SPR_PRIO_DEBUG, color, 0); + } + + void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { + spr::SprArgs args; + args.trans.x = p1.x; + args.trans.y = p1.y; + args.trans.z = 0.0f; + args.layer = layer; + args.kind = SPR_KIND_LINES; + args.resolution_mode_screen = mode; + args.resolution_mode_sprite = mode; + args.prio = prio; + args.color = color; + args.SetSpriteSize({ p2.x - p1.x, p2.y - p1.y }); + enum_or(args.attr, SPR_ATTR_MATRIX); + spr::put_sprite(args); + } + + void put_sprite_line_list(vec2* points, size_t count, resolution_mode mode, + spr::SprPrio prio, color4u8 color, int32_t layer) { + spr::SprArgs args; + args.kind = SPR_KIND_ARROW_AB; + args.layer = layer; + args.resolution_mode_screen = mode; + args.resolution_mode_sprite = mode; + args.prio = prio; + args.color = color; + + std::vector vertex_array; + vertex_array.reserve(count); + + for (size_t i = 0; i < count; i++, points++) { + spr::SpriteVertex vert = {}; + *(vec2*)&vert.pos = *points; + vertex_array.push_back(vert); + } + + args.SetVertexArray(vertex_array.data(), vertex_array.size()); + spr::put_sprite(args); + } + + void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { + spr::SprArgs args; + args.trans.x = rect.pos.x; + args.trans.y = rect.pos.y; + args.trans.z = 0.0f; + args.layer = layer; + args.kind = SPR_KIND_MULTI; + args.resolution_mode_screen = mode; + args.resolution_mode_sprite = mode; + args.prio = prio; + args.color = color; + args.SetSpriteSize(rect.size); + enum_or(args.attr, SPR_ATTR_MATRIX); + spr::put_sprite(args); + } + + void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { + spr::SprArgs args; + args.trans.x = rect.pos.x; + args.trans.y = rect.pos.y; + args.trans.z = 0.0f; + args.layer = layer; + args.kind = SPR_KIND_RECT; + args.resolution_mode_screen = mode; + args.resolution_mode_sprite = mode; + args.prio = prio; + args.color = color; + args.SetSpriteSize(rect.size); + enum_or(args.attr, SPR_ATTR_MATRIX); + spr::put_sprite(args); + } + + void put_sprite_triangles(SpriteVertex* vert, size_t num, resolution_mode mode, + SprPrio prio, int32_t spr_id, int32_t layer) { + spr::SprArgs args; + args.layer = layer; + args.kind = SPR_KIND_TRIANGLE; + args.resolution_mode_screen = mode; + args.resolution_mode_sprite = mode; + args.prio = prio; + args.color = vert[0].color; + if (spr_id != -1) + args.id.info = sprite_database_get_spr_by_id(spr_id)->info; + enum_or(args.attr, SPR_ATTR_MATRIX); + args.SetVertexArray(vert, num); + spr::put_sprite(args); + } +} + +const spr_db_spr* sprite_database_get_spr_by_id(int32_t id) { + const spr_db_spr* (FASTCALL* sprite_database_struct__get_spr_by_id) + (size_t _this, int32_t id) + = (const spr_db_spr * (FASTCALL*)(size_t _this, int32_t id))0x000000014063C800; + return sprite_database_struct__get_spr_by_id(0x000000014CC62290, id); +} + +int32_t sprite_database_get_spr_set_id_by_name(const prj::string& name) { + int32_t(FASTCALL * sprite_database_struct__get_spr_set_id_by_name) + (size_t _this, const prj::string & name) + = (int32_t(FASTCALL*)(size_t _this, const prj::string & name))0x00000001401121A0; + return sprite_database_struct__get_spr_set_id_by_name(0x000000014CC62290, name); +} + +void sprite_shared_init() { + const uint8_t orig_spr__SprArgs__SetVertexArray[] = { + 0x40, 0x53, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x8B, + 0x05, 0x63, 0x21, 0x62, 0x0C, 0x4C, 0x8B, 0xC9, + }; + + if (memcmp((void*)0x000000014063F040, (void*)orig_spr__SprArgs__SetVertexArray, + sizeof(orig_spr__SprArgs__SetVertexArray))) + sprite_break_sprite_vertex_limit = true; + else + sprite_break_sprite_vertex_limit = false; +} diff --git a/src/AFTModsShared/sprite.hpp b/src/AFTModsShared/sprite.hpp new file mode 100644 index 0000000..28a3e03 --- /dev/null +++ b/src/AFTModsShared/sprite.hpp @@ -0,0 +1,292 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/mat.hpp" +#include "../KKdLib/rectangle.hpp" +#include "../KKdLib/vec.hpp" +#include "color.hpp" +#include "resolution_mode.hpp" +#include "texture.hpp" +#include "types.hpp" + +struct spr_info { + uint16_t index; + uint16_t set_index; + + inline spr_info() { + this->index = (uint16_t)-1; + this->set_index = (uint16_t)-1; + } + + inline spr_info(uint16_t index, uint16_t set_index) { + this->index = index; + this->set_index = set_index; + } + + inline bool is_null() const { + return index == (uint16_t)-1 && set_index == (uint16_t)-1; + } + + inline bool not_null() const { + return index != (uint16_t)-1 || set_index != (uint16_t)-1; + } +}; + +constexpr bool operator==(const spr_info& left, const spr_info& right) { + return *(uint32_t*)&left == *(uint32_t*)&right; +} + +constexpr bool operator!=(const spr_info& left, const spr_info& right) { + return !(left == right); +} + +constexpr bool operator<(const spr_info& left, const spr_info& right) { + return *(uint32_t*)&left < *(uint32_t*)&right; +} + +constexpr bool operator>(const spr_info& left, const spr_info& right) { + return right < left; +} + +constexpr bool operator<=(const spr_info& left, const spr_info& right) { + return !(right < left); +} + +constexpr bool operator>=(const spr_info& left, const spr_info& right) { + return !(left < right); +} + +struct spr_db_spr { + uint32_t id; + prj::string name; + spr_info info; +}; + +struct SpriteHeaderFile { + uint32_t flag; + uint32_t texofs; + int32_t num_of_texture; + int32_t num_of_sprite; + uint32_t sprinfo_offset; + uint32_t texname_offset; + uint32_t sprname_offset; + uint32_t sprdata_offset; +}; + +namespace spr { + struct SprInfo { + uint32_t texid; + int32_t rotate; + float_t su; + float_t sv; + float_t eu; + float_t ev; + float_t px; + float_t py; + float_t width; + float_t height; + }; +}; + +struct SpriteData { + uint32_t attr; + resolution_mode resolution_mode; +}; + +struct SpriteHeader { + uint32_t flag; + uint32_t texofs; + int32_t num_of_texture; + int32_t num_of_sprite; + spr::SprInfo* sprinfo; + const char** texname; + const char** sprname; + SpriteData* sprdata; +}; + +struct SprSet { + void* vftable; + int32_t flag; + int32_t index; + SpriteHeaderFile* header_file; + SpriteHeader* header; + texture** textures; + int32_t load_count; + void* file_handler; + bool ready; + prj::shared_ptr alloc_handler; // prj::stack_allocator + prj::string file; +}; + +namespace spr { + enum SprAttr : uint32_t { + SPR_ATTR_FLIP_H = 0x00010000, + SPR_ATTR_FLIP_V = 0x00020000, + SPR_ATTR_CTR_LT = 0x00040000, + SPR_ATTR_CTR_CT = 0x00080000, + SPR_ATTR_CTR_RT = 0x00100000, + SPR_ATTR_CTR_LC = 0x00200000, + SPR_ATTR_CTR_CC = 0x00400000, + SPR_ATTR_CTR_RC = 0x00800000, + SPR_ATTR_CTR_LB = 0x01000000, + SPR_ATTR_CTR_CB = 0x02000000, + SPR_ATTR_CTR_RB = 0x04000000, + SPR_ATTR_MATRIX = 0x08000000, + SPR_ATTR_10000000 = 0x10000000, + SPR_ATTR_NOBLEND = 0x20000000, + + SPR_ATTR_CTR = 0x07FC0000, + }; + + enum SprKind { + SPR_KIND_NORMAL = 0, + SPR_KIND_LINE, + SPR_KIND_LINES, + SPR_KIND_RECT, + SPR_KIND_MULTI, + SPR_KIND_ARROW_A, + SPR_KIND_ARROW_B, + SPR_KIND_ARROW_AB, + SPR_KIND_TRIANGLE, + SPR_KIND_CIRCLE, + }; + + enum SprPrio { + SPR_PRIO_00 = 0, + SPR_PRIO_01, + SPR_PRIO_02, + SPR_PRIO_03, + SPR_PRIO_04, + SPR_PRIO_05, + SPR_PRIO_06, + SPR_PRIO_07, + SPR_PRIO_08, + SPR_PRIO_09, + SPR_PRIO_10, + SPR_PRIO_11, + SPR_PRIO_12, + SPR_PRIO_13, + SPR_PRIO_14, + SPR_PRIO_15, + SPR_PRIO_16, + SPR_PRIO_17, + SPR_PRIO_18, + SPR_PRIO_19, + SPR_PRIO_20, + SPR_PRIO_21, + SPR_PRIO_22, + SPR_PRIO_23, + SPR_PRIO_24, + SPR_PRIO_25, + SPR_PRIO_26, + SPR_PRIO_27, + SPR_PRIO_28, + SPR_PRIO_29, + SPR_PRIO_30, + SPR_PRIO_31, + SPR_PRIO_MAX, + + SPR_PRIO_BACKGROUND = SPR_PRIO_03, + SPR_PRIO_DEFAULT = SPR_PRIO_07, + SPR_PRIO_DEBUG = SPR_PRIO_29, + }; + + struct SpriteVertex { + vec3 pos; + vec2 uv; + color4u8 color; + }; + + struct SprArgs { + enum Flags : uint32_t { + SPRITE_SIZE = 0x01, + TEXTURE_POS_SIZE = 0x02, + }; + + union IDUnion { + int32_t index; + uint32_t id; + spr_info info; + + IDUnion() { + index = -1; + id = -1; + info = {}; + } + }; + + SprKind kind; + IDUnion id; + color4u8_bgra color; + SprAttr attr; + int32_t blend; + int32_t index; + int32_t layer; + SprPrio prio; + resolution_mode resolution_mode_screen; + resolution_mode resolution_mode_sprite; + vec3 center; + vec3 trans; + vec3 scale; + vec3 rot; + vec2 skew_angle; + mat4 mat; + texture* texture; + int32_t shader; + union { + size_t vertex_array; + SpriteVertex* vertex_array_ptr; + }; + size_t num_vertex; + Flags flags; + vec2 sprite_size; + int32_t field_CC; + vec2 texture_pos; + vec2 texture_size; + spr::SprArgs* next; + + SprArgs(); + + SpriteVertex* GetVertexArray(); + void Reset(); + void SetSpriteSize(vec2 size); + void SetTexturePosSize(float_t x, float_t y, float_t width, float_t height); + void SetVertexArray(SpriteVertex* vertex_array, size_t num_vertex); + + static void SetNext(SprArgs* args, SprArgs* next); + }; + + static_assert(sizeof(spr::SprArgs) == 0xE8, "\"spr::SprArgs\" struct should have a size of 0xE8"); + + extern void(FASTCALL* put_cross)(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z); + extern void(FASTCALL* put_rgb_cross)(const mat4& mat); + extern spr::SprArgs* (FASTCALL* put_sprite)(const spr::SprArgs& args); + + vec2 proj_sprite_3d_line(vec3 vec, bool offset); + + void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color); + void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_line_list(vec2* points, size_t count, resolution_mode mode, + spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); + void put_sprite_triangles(SpriteVertex* vert, size_t num, resolution_mode mode, + SprPrio prio, int32_t spr_id, int32_t layer); +} + +extern vec4& spr_color; + +extern void (FASTCALL* sprite_manager_unload_set)(int32_t set_id); +extern size_t(FASTCALL* sprite_manager_get_reqlist_count)(int32_t index); +extern void (FASTCALL* sprite_manager_read_file)(int32_t set_id, const prj::string mdata_dir); +extern bool (FASTCALL* sprite_manager_load_file)(int32_t set_id); + +extern const spr_db_spr* sprite_database_get_spr_by_id(int32_t id); +extern int32_t sprite_database_get_spr_set_id_by_name(const prj::string& name); + +extern void sprite_shared_init(); diff --git a/src/DivaGL/task.cpp b/src/AFTModsShared/task.cpp similarity index 100% rename from src/DivaGL/task.cpp rename to src/AFTModsShared/task.cpp diff --git a/src/DivaGL/task.hpp b/src/AFTModsShared/task.hpp similarity index 100% rename from src/DivaGL/task.hpp rename to src/AFTModsShared/task.hpp diff --git a/src/AFTModsShared/texture.cpp b/src/AFTModsShared/texture.cpp new file mode 100644 index 0000000..300d0c5 --- /dev/null +++ b/src/AFTModsShared/texture.cpp @@ -0,0 +1,62 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#include "texture.hpp" + +void(FASTCALL* texture_apply_color_tone)(texture* chg_tex, texture* org_tex, color_tone* col_tone) + = (void(FASTCALL*)(texture * chg_tex, texture * org_tex, color_tone * col_tone))0x00000001403B5DF0; +texture* (FASTCALL* texture_alloc)(texture_id id) = (texture * (FASTCALL*)(texture_id id))0x000000014069A390; +int32_t(FASTCALL* texture_get_size)(AFTGLenum internal_format, int32_t width, int32_t height) + = (int32_t(FASTCALL *)(AFTGLenum internal_format, int32_t width, int32_t height))0x000000014069A6D0; +texture* (FASTCALL* texture_create_copy_texture)(texture_id id, texture* org_tex) += (texture * (FASTCALL*)(texture_id id, texture * org_tex))0x000000014069B550; +texture* (FASTCALL* texture_load_tex_cube_map)(texture_id id, uint32_t internal_format, + int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr) + = (texture * (FASTCALL*)(texture_id id, uint32_t internal_format, + int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr))0x000000014069B860; +texture* (FASTCALL* texture_load_tex_2d)(texture_id id, uint32_t internal_format, int32_t width, int32_t height, + int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy) + = (texture * (FASTCALL*)(texture_id id, uint32_t internal_format, int32_t width, int32_t height, + int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy))0x000000014069B8E0; +int32_t(FASTCALL* texture_info_get_id)(const char* name) + = (int32_t(FASTCALL*)(const char* name))0x000000014069CBD0; +texture* (FASTCALL* texture_manager_get_texture)(uint32_t id) + = (texture * (FASTCALL*)(uint32_t id))0x000000014069CD70; +void (FASTCALL* txp_set_load)(const void* data, texture*** textures, uint32_t* texture_ids) + = (void (FASTCALL*)(const void* data, texture * **textures, uint32_t * texture_ids))0x000000014069D4B0; +void(FASTCALL* texture_release)(texture* tex) = (void(FASTCALL*)(texture * tex))0x000000014069DA70; + +texture::texture() : ref_count(), flags(), width(), height(), +glid(), target(), internal_format(), max_mipmap_level(), size_texmem() { + +} + +int32_t texture::get_height_align_mip_level(uint8_t mip_level) const { + if (flags & TEXTURE_BLOCK_COMPRESSION) + return max_def((uint32_t)height >> mip_level, 4u); + else + return max_def((uint32_t)height >> mip_level, 1u); +} + +int32_t texture::get_size_mip_level(uint8_t mip_level) const { + return texture_get_size(internal_format, + get_width_mip_level(mip_level), get_height_mip_level(mip_level)); +} + +int32_t texture::get_width_align_mip_level(uint8_t mip_level) const { + if (flags & TEXTURE_BLOCK_COMPRESSION) + return max_def((uint32_t)width >> mip_level, 4u); + else + return max_def((uint32_t)width >> mip_level, 1u); +} + +void texture_array_free(texture** arr) { + if (!arr) + return; + + for (texture** i = arr; *i; i++) + texture_release(*i); + free_def(arr); +} diff --git a/src/AFTModsShared/texture.hpp b/src/AFTModsShared/texture.hpp new file mode 100644 index 0000000..8394cea --- /dev/null +++ b/src/AFTModsShared/texture.hpp @@ -0,0 +1,108 @@ +/* + by korenkonder + GitHub/GitLab: korenkonder +*/ + +#pragma once + +#include "../KKdLib/default.hpp" +#include "../KKdLib/image.hpp" +#include "types.hpp" + +enum texture_flags { + TEXTURE_BLOCK_COMPRESSION = 0x01, +}; + +static_assert(sizeof(texture_flags) == 0x04, "\"texture_flags\" struct should have a size of 0x04"); + +struct texture_id { + uint32_t index : 24; + uint32_t id : 8; + + inline texture_id() { + id = 0; + index = 0; + } + + inline texture_id(uint8_t id, uint32_t index) { + this->id = id; + this->index = index; + } + + inline operator uint32_t() const { + return *(uint32_t*)this; + } +}; + +static_assert(sizeof(texture_id) == 0x04, "\"texture_id\" struct should have a size of 0x04"); + +constexpr bool operator==(const texture_id& left, const texture_id& right) { + return (((uint64_t)left.id << 32) | left.index) == (((uint64_t)right.id << 32) | right.index); +} + +constexpr bool operator!=(const texture_id& left, const texture_id& right) { + return !(left == right); +} + +constexpr bool operator<(const texture_id& left, const texture_id& right) { + return (((uint64_t)left.id << 32) | left.index) < (((uint64_t)right.id << 32) | right.index); +} + +constexpr bool operator>(const texture_id& left, const texture_id& right) { + return right < left; +} + +constexpr bool operator<=(const texture_id& left, const texture_id& right) { + return !(right < left); +} + +constexpr bool operator>=(const texture_id& left, const texture_id& right) { + return !(left < right); +} + +struct texture { + int32_t ref_count; + texture_id id; + texture_flags flags; + int16_t width; + int16_t height; + AFTGLuint glid; + AFTGLenum target; + AFTGLenum internal_format; + int32_t max_mipmap_level; + int32_t size_texmem; + + texture(); + + int32_t get_height_align_mip_level(uint8_t mip_level = 0) const; + int32_t get_size_mip_level(uint8_t mip_level = 0) const; + int32_t get_width_align_mip_level(uint8_t mip_level = 0) const; + + inline int32_t get_height_mip_level(uint8_t mip_level) const { + return max_def(height >> mip_level, 1); + } + inline int32_t get_width_mip_level(uint8_t mip_level) const { + return max_def(width >> mip_level, 1); + } +}; + +static_assert(sizeof(texture) == 0x24, "\"texture\" struct should have a size of 0x24"); + +extern void(FASTCALL* texture_apply_color_tone)(texture* chg_tex, texture* org_tex, color_tone* col_tone); +extern texture* (FASTCALL* texture_alloc)(texture_id id); +extern int32_t(FASTCALL* texture_get_size)(AFTGLenum internal_format, int32_t width, int32_t height); +extern texture* (FASTCALL* texture_create_copy_texture)(texture_id id, texture* org_tex); +extern texture* (FASTCALL* texture_load_tex_cube_map)(texture_id id, uint32_t internal_format, + int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr); +extern texture* (FASTCALL* texture_load_tex_2d)(texture_id id, uint32_t internal_format, + int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy); +extern int32_t(FASTCALL* texture_info_get_id)(const char* name); +extern texture* (FASTCALL* texture_manager_get_texture)(uint32_t id); +extern void (FASTCALL* txp_set_load)(const void* data, texture*** textures, uint32_t* texture_ids); +extern void(FASTCALL* texture_release)(texture* tex); + +extern void texture_array_free(texture** arr); + +extern texture_id texture_manager_get_copy_id(uint32_t id); + +extern void texture_patch(); diff --git a/src/DivaGL/types.hpp b/src/AFTModsShared/types.hpp similarity index 99% rename from src/DivaGL/types.hpp rename to src/AFTModsShared/types.hpp index f9a704c..e273ea1 100644 --- a/src/DivaGL/types.hpp +++ b/src/AFTModsShared/types.hpp @@ -17,6 +17,10 @@ #include #include +typedef uint32_t AFTGLuint; +typedef uint32_t AFTGLenum; +typedef ssize_t AFTGLsizeiptr; + namespace prj { typedef enum HeapCMallocType { HeapCMallocSystem = 0x00, diff --git a/src/DivaGL/uniform.cpp b/src/AFTModsShared/uniform.cpp similarity index 100% rename from src/DivaGL/uniform.cpp rename to src/AFTModsShared/uniform.cpp diff --git a/src/DivaGL/uniform.hpp b/src/AFTModsShared/uniform.hpp similarity index 100% rename from src/DivaGL/uniform.hpp rename to src/AFTModsShared/uniform.hpp diff --git a/src/DivaGL/DivaGL.vcxproj b/src/DivaGL/DivaGL.vcxproj index 2151428..607559f 100644 --- a/src/DivaGL/DivaGL.vcxproj +++ b/src/DivaGL/DivaGL.vcxproj @@ -79,16 +79,10 @@ DebugFull Windows $(SolutionDir)extern\lib;$(SolutionDir)lib\debugopt\ - opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies) + opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;AFTModsShared.lib;KKdLib.lib;%(AdditionalDependencies) /ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions) false - - copy /Y "$(SolutionDir)bin\$(TargetName).dva" "N:\DUMP\plugins\$(TargetName).dva" -copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\plugins\$(TargetName).pdb" -del "$(SolutionDir)bin\$(TargetName).exp" -del "$(SolutionDir)bin\$(TargetName).lib" - @@ -120,18 +114,12 @@ del "$(SolutionDir)bin\$(TargetName).lib" true Windows $(SolutionDir)extern\lib;$(SolutionDir)lib\release\ - opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;KKdLib.lib;%(AdditionalDependencies) + opengl32.lib;detours.lib;syelog.lib;libdeflatestatic.lib;AFTModsShared.lib;KKdLib.lib;%(AdditionalDependencies) true /ignore:4098 /ignore:4099 /ignore:4286 %(AdditionalOptions) true false - - copy /Y "$(SolutionDir)bin\$(TargetName).dva" "N:\DUMP\plugins\$(TargetName).dva" -copy /Y "$(SolutionDir)bin\$(TargetName).pdb" "N:\DUMP\plugins\$(TargetName).pdb" -del "$(SolutionDir)bin\$(TargetName).exp" -del "$(SolutionDir)bin\$(TargetName).lib" - @@ -161,8 +149,6 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - @@ -174,29 +160,20 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - - - - - - - - @@ -205,9 +182,7 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - @@ -221,8 +196,6 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - @@ -234,30 +207,20 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - - - - - - - - - @@ -267,10 +230,7 @@ del "$(SolutionDir)bin\$(TargetName).lib" - - - diff --git a/src/DivaGL/Glitter/glitter.hpp b/src/DivaGL/Glitter/glitter.hpp index 695ea95..2e4cfc1 100644 --- a/src/DivaGL/Glitter/glitter.hpp +++ b/src/DivaGL/Glitter/glitter.hpp @@ -9,15 +9,15 @@ #include "../../KKdLib/hash.hpp" #include "../../KKdLib/mat.hpp" #include "../../KKdLib/vec.hpp" +#include "../../AFTModsShared/color.hpp" +#include "../../AFTModsShared/file_handler.hpp" +#include "../../AFTModsShared/frame_rate_control.hpp" +#include "../../AFTModsShared/task.hpp" +#include "../../AFTModsShared/types.hpp" #include "../GL/array_buffer.hpp" #include "../GL/element_array_buffer.hpp" -#include "../color.hpp" -#include "../file_handler.hpp" -#include "../frame_rate_control.hpp" #include "../gl.hpp" #include "../object.hpp" -#include "../task.hpp" -#include "../types.hpp" #include "../texture.hpp" #define SHARED_GLITTER_BUFFER (1) diff --git a/src/DivaGL/auth_3d.cpp b/src/DivaGL/auth_3d.cpp index 21fc456..16e8b87 100644 --- a/src/DivaGL/auth_3d.cpp +++ b/src/DivaGL/auth_3d.cpp @@ -5,503 +5,20 @@ #include "auth_3d.hpp" #include "../KKdLib/hash.hpp" -#include "light_param/fog.hpp" -#include "light_param/light.hpp" +#include "../AFTModsShared/light_param/fog.hpp" +#include "../AFTModsShared/light_param/light.hpp" +#include "../AFTModsShared/canonical_properties.hpp" +#include "../AFTModsShared/file_handler.hpp" +#include "../AFTModsShared/frame_rate_control.hpp" +#include "../AFTModsShared/types.hpp" #include "mdl/disp_manager.hpp" #include "pv_game/firstread.hpp" #include "rob/rob.hpp" -#include "canonical_properties.hpp" -#include "file_handler.hpp" -#include "frame_rate_control.hpp" #include "render_context.hpp" #include "sprite.hpp" #include "texture.hpp" -#include "types.hpp" #include -enum auth_3d_camera_auxiliary_flags { - AUTH_3D_CAMERA_AUXILIARY_EXPOSURE = 0x01, - AUTH_3D_CAMERA_AUXILIARY_GAMMA = 0x02, - AUTH_3D_CAMERA_AUXILIARY_SATURATE = 0x04, - AUTH_3D_CAMERA_AUXILIARY_AUTO_EXPOSURE = 0x08, -}; - -enum auth_3d_ep_type { - AUTH_3D_EP_NONE = 0x00, - AUTH_3D_EP_LINEAR = 0x01, - AUTH_3D_EP_CYCLE = 0x02, - AUTH_3D_EP_CYCLE_OFFSET = 0x03, -}; - -enum auth_3d_fog_flags { - AUTH_3D_FOG_DENSITY = 0x01, - AUTH_3D_FOG_START = 0x02, - AUTH_3D_FOG_END = 0x04, - AUTH_3D_FOG_COLOR = 0x08, -}; - -enum auth_3d_key_type { - AUTH_3D_KEY_NONE = 0x00, - AUTH_3D_KEY_STATIC = 0x01, - AUTH_3D_KEY_LINEAR = 0x02, - AUTH_3D_KEY_HERMITE = 0x03, - AUTH_3D_KEY_HOLD = 0x04, -}; - -enum auth_3d_light_flags { - AUTH_3D_LIGHT_AMBIENT = 0x01, - AUTH_3D_LIGHT_DIFFUSE = 0x02, - AUTH_3D_LIGHT_SPECULAR = 0x04, - AUTH_3D_LIGHT_TONE_CURVE = 0x08, -}; - -enum auth_3d_object_texture_transform_flags { - AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_U = 0x001, - AUTH_3D_OBJECT_TEX_TRANSFORM_COVERAGE_V = 0x002, - AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_U = 0x004, - AUTH_3D_OBJECT_TEX_TRANSFORM_REPEAT_V = 0x008, - AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_U = 0x010, - AUTH_3D_OBJECT_TEX_TRANSFORM_TRANSLATE_FRAME_V = 0x020, - AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_U = 0x040, - AUTH_3D_OBJECT_TEX_TRANSFORM_OFFSET_V = 0x080, - AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE_FRAME = 0x100, - AUTH_3D_OBJECT_TEX_TRANSFORM_ROTATE = 0x200, -}; - -enum auth_3d_post_process_flags { - AUTH_3D_POST_PROCESS_LENS_FLARE = 0x01, - AUTH_3D_POST_PROCESS_LENS_SHAFT = 0x02, - AUTH_3D_POST_PROCESS_LENS_GHOST = 0x04, - AUTH_3D_POST_PROCESS_RADIUS = 0x08, - AUTH_3D_POST_PROCESS_INTENSITY = 0x10, - AUTH_3D_POST_PROCESS_SCENE_FADE = 0x20, -}; - -struct kft3 { - float_t frame; - float_t value; - float_t tangent1; - float_t tangent2; -}; - -static_assert(sizeof(kft3) == 0x10, "\"kft3\" struct should have a size of 0x10"); - -struct auth_3d_key { - auth_3d_key_type type; - float_t value; - float_t max_frame; - auth_3d_ep_type ep_type_pre; - auth_3d_ep_type ep_type_post; - float_t frame_delta; - float_t value_delta; - prj::vector keys_vec; - size_t length; - kft3* keys; -}; - -static_assert(sizeof(auth_3d_key) == 0x48, "\"auth_3d_key\" struct should have a size of 0x48"); - -struct auth_3d_vec3 { - auth_3d_key x; - auth_3d_key y; - auth_3d_key z; -}; - -static_assert(sizeof(auth_3d_vec3) == 0xD8, "\"auth_3d_vec3\" struct should have a size of 0xD8"); - -struct auth_3d_rgba { - auth_3d_key r; - auth_3d_key g; - auth_3d_key b; - auth_3d_key a; - bool has_r; - bool has_g; - bool has_b; - bool has_a; - int32_t field_124; - vec4 value; - bool has_got[4]; -}; - -static_assert(sizeof(auth_3d_rgba) == 0x140, "\"auth_3d_rgba\" struct should have a size of 0x140"); - -struct auth_3d_model_transform { - mat4 mat; - auth_3d_vec3 scale; - auth_3d_vec3 rotation; - auth_3d_vec3 translation; - auth_3d_key visibility; - vec3 scale_value; - vec3 rotation_value; - vec3 translation_value; - bool visible; -}; - -static_assert(sizeof(auth_3d_model_transform) == 0x338, "\"auth_3d_model_transform\" struct should have a size of 0x338"); - -struct auth_3d_curve { - auth_3d_key curve; - prj::string name; - float_t value; - uint32_t type; -}; - -static_assert(sizeof(auth_3d_curve) == 0x70, "\"auth_3d_curve\" struct should have a size of 0x70"); - -struct auth_3d_object_curve { - auth_3d_curve* curve; - prj::string name; - float_t frame_offset; - float_t value; -}; - -static_assert(sizeof(auth_3d_object_curve) == 0x30, "\"auth_3d_object_curve\" struct should have a size of 0x30"); - -struct auth_3d_object_texture_pattern { - prj::string name; - int32_t texture_id; - auth_3d_object_curve pattern; -}; - -static_assert(sizeof(auth_3d_object_texture_pattern) == 0x58, "\"auth_3d_object_texture_pattern\" struct should have a size of 0x58"); - -struct auth_3d_object_texture_transform { - auth_3d_object_texture_transform_flags flags; - prj::string name; - int32_t texture_id; - auth_3d_key coverageU; - auth_3d_key coverageV; - auth_3d_key repeatU; - auth_3d_key repeatV; - auth_3d_key translateFrameU; - auth_3d_key translateFrameV; - auth_3d_key offsetU; - auth_3d_key offsetV; - auth_3d_key rotateFrame; - auth_3d_key rotate; - mat4 mat; - vec3 scale_value; - vec3 repeat_value; - vec3 rotate_value; - vec3 translateFrame_value; -}; - -static_assert(sizeof(auth_3d_object_texture_transform) == 0x370, "\"auth_3d_object_texture_transform\" struct should have a size of 0x370"); - -struct auth_3d_object_hrc; - -struct auth_3d_object { - auth_3d_model_transform model_transform; - int64_t field_338; - prj::string name; - prj::string uid_name; - prj::string parent_name; - prj::string parent_node; - auth_3d_object_curve pattern; - auth_3d_object_curve morph; - prj::vector texture_pattern; - prj::vectortexture_transform; - prj::vector children_object; - prj::vector children_object_hrc; - object_info object_info; - bool reflect; - bool refract; -}; - -static_assert(sizeof(auth_3d_object) == 0x488, "\"auth_3d_object\" struct should have a size of 0x488"); - -struct auth_3d_object_model_transform { - mat4 mat; - mat4 mat_inner; - auth_3d_vec3 translation; - auth_3d_vec3 rotation; - auth_3d_vec3 scale; - auth_3d_key visibility; - vec3 translation_value; - vec3 rotation_value; - vec3 scale_value; - bool visible; - mat4 mat_rot; - int64_t field_3B8; - int32_t field_3C0; - mat4 field_3C4; - vec3 field_404; - float_t frame; - bool has_rotation; - bool has_translation; - bool has_scale; - bool has_visibility; -}; - -static_assert(sizeof(auth_3d_object_model_transform) == 0x418, "\"auth_3d_object_model_transform\" struct should have a size of 0x418"); - -struct auth_3d_object_node { - prj::string name; - int32_t bone_id; - int32_t parent; - auth_3d_object_model_transform model_transform; - mat4* mat; - mat4 joint_orient; -}; - -static_assert(sizeof(auth_3d_object_node) == 0x488, "\"auth_3d_object_node\" struct should have a size of 0x488"); - -struct auth_3d_object_hrc { - prj::vector node; - prj::vector node_bone_mats; - mat4* bone_mats; - prj::string name; - prj::string uid_name; - object_info object_info; - bool reflect; - bool refract; - bool shadow; - prj::string parent_name; - prj::string parent_node; - prj::vector children_object; - prj::vector children_object_parent_node; - prj::vector children_object_hrc; - prj::vector children_object_hrc_parent_node; -}; - -static_assert(sizeof(auth_3d_object_hrc) == 0x120, "\"auth_3d_object_hrc\" struct should have a size of 0x120"); - -struct auth_3d_object_instance { - prj::string name; - prj::string uid_name; - object_info object_info; - bool shadow; - auth_3d_object_model_transform model_transform; - prj::vector object_bone_indices; - prj::vector mats; -}; - -static_assert(sizeof(auth_3d_object_instance) == 0x490, "\"auth_3d_object_instance\" struct should have a size of 0x490"); - -struct auth_3d_m_object_hrc { - prj::string name; - auth_3d_object_model_transform model_transform; - prj::vector node; - prj::vector instance; -}; - -static_assert(sizeof(auth_3d_m_object_hrc) == 0x468, "\"auth_3d_m_object_hrc\" struct should have a size of 0x468"); - -struct auth_3d_time_event { - float_t frame; - int32_t type; - size_t event_index; -}; - -static_assert(sizeof(auth_3d_time_event) == 0x10, "\"auth_3d_time_event\" struct should have a size of 0x10"); - -struct auth_3d_play_control { - float_t begin; - float_t size; - float_t fps; -}; - -static_assert(sizeof(auth_3d_play_control) == 0x0C, "\"auth_3d_play_control\" struct should have a size of 0x0C"); - -struct auth_3d_point { - prj::string name; - auth_3d_model_transform model_transform; -}; - -static_assert(sizeof(auth_3d_point) == 0x358, "\"auth_3d_point\" struct should have a size of 0x358"); - -struct auth_3d_camera_root_view_point { - auth_3d_model_transform model_transform; - auth_3d_key roll; - bool has_fov; - bool fov_is_horizontal; - auth_3d_key fov; - float_t aspect; - auth_3d_key focal_length; - float_t camera_aperture_w; - float_t camera_aperture_h; -}; - -static_assert(sizeof(auth_3d_camera_root_view_point) == 0x428, "\"auth_3d_camera_root_view_point\" struct should have a size of 0x428"); - -struct auth_3d_camera_root { - auth_3d_model_transform model_transform; - auth_3d_camera_root_view_point view_point; - auth_3d_model_transform interest; -}; - -static_assert(sizeof(auth_3d_camera_root) == 0xA98, "\"auth_3d_camera_root\" struct should have a size of 0xA98"); - -struct auth_3d_camera_auxiliary { - auth_3d_camera_auxiliary_flags flags; - auth_3d_key exposure; - auth_3d_key gamma; - auth_3d_key saturate; - auth_3d_key auto_exposure; - float_t exposure_value; - float_t gamma_value; - float_t saturate_value; - float_t auto_exposure_value; -}; - -static_assert(sizeof(auth_3d_camera_auxiliary) == 0x138, "\"auth_3d_camera_auxiliary\" struct should have a size of 0x138"); - -struct auth_3d_light { - auth_3d_light_flags flags; - auth_3d_light_flags flags_init; - light_id id; - prj::string name; - prj::string type; - auth_3d_model_transform position; - auth_3d_model_transform spot_direction; - auth_3d_rgba Ambient; - auth_3d_rgba Diffuse; - auth_3d_rgba Specular; - auth_3d_rgba Tone_Curve; - vec4 Ambient_init; - vec4 Diffuse_init; - vec4 Specular_init; - vec4 Tone_Curve_init; -}; - -static_assert(sizeof(auth_3d_light) == 0xC00, "\"auth_3d_light\" struct should have a size of 0xC00"); - -struct auth_3d_fog { - auth_3d_fog_flags flags; - auth_3d_fog_flags flags_init; - fog_id id; - prj::string name; - auth_3d_key density; - auth_3d_key start; - auth_3d_key end; - float_t density_value; - float_t start_value; - float_t end_value; - auth_3d_rgba color; - float_t density_init; - float_t start_init; - float_t end_init; - vec4 color_init; -}; - -static_assert(sizeof(auth_3d_fog) == 0x278, "\"auth_3d_fog\" struct should have a size of 0x278"); - -struct auth_3d_post_process { - auth_3d_post_process_flags flags; - auth_3d_post_process_flags flags_init; - auth_3d_key lens_flare; - auth_3d_key lens_shaft; - auth_3d_key lens_ghost; - auth_3d_rgba radius; - auth_3d_rgba intensity; - auth_3d_rgba scene_fade; - vec3 lens_init; - vec4 radius_init_value; - vec4 intensity_init_value; - vec4 scene_fade_value; - vec3 lens_value; -}; - -static_assert(sizeof(auth_3d_post_process) == 0x4E8, "\"auth_3d_post_process\" struct should have a size of 0x4E8"); - -struct auth_3d_dof { - bool has_dof; - auth_3d_model_transform model_transform; -}; - -static_assert(sizeof(auth_3d_dof) == 0x340, "\"auth_3d_dof\" struct should have a size of 0x340"); - -struct auth_3d_chara { - prj::string name; - auth_3d_model_transform model_transform; - int32_t index; -}; - -static_assert(sizeof(auth_3d_chara) == 0x360, "\"auth_3d_chara\" struct should have a size of 0x360"); - -struct auth_3d_motion { - prj::string name; -}; - -static_assert(sizeof(auth_3d_motion) == 0x20, "\"auth_3d_motion\" struct should have a size of 0x20"); - -struct auth_3d_auth_2d { - prj::string name; -}; - -static_assert(sizeof(auth_3d_auth_2d) == 0x20, "\"auth_3d_auth_2d\" struct should have a size of 0x20"); - -struct auth_3d { - int32_t uid; - int32_t id; - bool enable; - bool camera_root_update; - bool visible; - bool repeat; - bool field_C; - bool ended; - bool left_right_reverse; - bool once; - mat4 mat; - float_t alpha; - mdl::ObjFlags obj_flags; - bool field_58; - prj::map field_60; - prj::vector texture_pattern; - int32_t chara_id; - object_info object_info; - mat4* bone_mats; - bool shadow; - bool chara_item; - bool reflect; - chara_index src_chara; - chara_index dst_chara; - int32_t pos; - int64_t field_A8; - FrameRateControl* frame_rate; - float_t frame; - float_t req_frame; - float_t max_frame; - bool frame_changed; - float_t frame_offset; - float_t last_frame; - float_t fov_scale; - prj::vector* field_D8; - float_t blend; - int64_t field_E8; - int64_t field_F0; - bool paused; - prj::vector event; - prj::vector event_time; - auth_3d_time_event* event_time_next; - auth_3d_play_control play_control; - prj::vector point; - prj::vector curve; - prj::vector camera_root; - auth_3d_camera_auxiliary camera_auxiliary; - prj::vector light; - prj::vector fog; - auth_3d_post_process post_process; - auth_3d_dof dof; - prj::vector chara; - prj::vector motion; - prj::vector object; - prj::vector object_list; - prj::vector object_hrc; - prj::vector object_hrc_list; - prj::vector m_object_hrc; - prj::vector m_object_hrc_list; - prj::vector field_BE0; - prj::vector object_list_string; - prj::vector object_hrc_list_string; - prj::vector m_object_hrc_list_string; - prj::vector auth_2d; - int32_t state; - prj::vector field_C60; -}; - -static_assert(sizeof(auth_3d) == 0xC78, "\"auth_3d\" struct should have a size of 0xC78"); - enum auth_3d_material_list_flags { AUTH_3D_MATERIAL_LIST_BLEND_COLOR = 0x01, AUTH_3D_MATERIAL_LIST_EMISSION = 0x02, @@ -531,67 +48,6 @@ struct struc_8 { static_assert(sizeof(struc_8) == 0x90, "\"struc_8\" struct should have a size of 0x90"); -struct auth_3d_db_uid { - int32_t org_uid; - int32_t enabled; - const char* name; - prj::string category; - float_t size; -}; - -static_assert(sizeof(auth_3d_db_uid) == 0x38, "\"auth_3d_db_uid\" struct should have a size of 0x38"); - -struct auth_3d_db_category { - prj::string name; - prj::vector uids; -}; - -static_assert(sizeof(auth_3d_db_category) == 0x38, "\"auth_3d_db_category\" struct should have a size of 0x38"); - -struct auth_3d_uid_file { - int32_t load_count; - int32_t uid; - prj::string file_name; - int32_t state; - struc_8 field_30; - const char* name; - void* farc; // auth_3d_farc -}; - -static_assert(sizeof(auth_3d_uid_file) == 0xD0, "\"auth_3d_uid_file\" struct should have a size of 0xD0"); - -#define AUTH_3D_DATA_COUNT 0x100 - -struct auth_3d_data_struct { - prj::map field_0; // struc_87 - prj::sorted_vector field_10; - prj::vector category; - prj::vector uid; - p_file_handler auth_3d_db_file_handler; - prj::vector db_file_handlers; - prj::sorted_vector field_A0; - int64_t field_E0; - p_file_handler auth_3d_setting_file_handler; - prj::vector farcs; // auth_3d_farc - prj::vector uid_files; - prj::vector loaded_ids; - auth_3d data[AUTH_3D_DATA_COUNT]; - int64_t field_C7938; -}; - -static_assert(sizeof(auth_3d_data_struct) == 0xC7940, "\"auth_3d_data_struct\" struct should have a size of 0xC7940"); - -int32_t(FASTCALL* auth_3d_data_get_uid_by_name)(const char* name) - = (int32_t(FASTCALL*)(const char* name)) 0x00000001401E7EA0; -bool (FASTCALL* auth_3d_data_check_category_loaded)(const char* category_name) - = (bool (FASTCALL*)(const char* category_name))0x00000001401CBE20; -void (FASTCALL* auth_3d_data_load_category)(const char* category_name) - = (void (FASTCALL*)(const char* category_name))0x00000001401CBE80; -void (FASTCALL* auth_3d_data_unload_category)(const char* category_name) - = (void (FASTCALL*)(const char* category_name))0x00000001401CBAB0; - -static auth_3d_data_struct* auth_3d_data = (auth_3d_data_struct*)0x0000000140EDA950; - static void(FASTCALL* auth_3d_rgba__free)(auth_3d_rgba* rgba) = (void(FASTCALL*)(auth_3d_rgba * rgba))0x00000001401B8900; static void (FASTCALL* auth_3d_rgba__ctrl)(auth_3d_rgba* rgba, float_t frame) @@ -601,382 +57,10 @@ static bool (FASTCALL* auth_3d_key__parse)(auth_3d_key* k, struc_8* a2, prj::str static bool (FASTCALL* auth_3d_rgba__parse)(auth_3d_rgba* rgba, struc_8* a2, prj::string_range_capacity str_rng_cap) = (bool (FASTCALL*)(auth_3d_rgba * rgba, struc_8 * a2, prj::string_range_capacity str_rng_cap))0x00000001401DB520; -static int32_t auth_3d_get_auth_3d_object_index(auth_3d* auth, object_info object_info, int32_t instance); -static const mat4* auth_3d_get_auth_3d_object_mat(auth_3d* auth, size_t index); -static const mat4* auth_3d_get_auth_3d_object_hrc_bone_mats(auth_3d* auth, size_t index); -static int32_t auth_3d_get_auth_3d_object_hrc_index(auth_3d* auth, object_info obj_info, int32_t instance); static void auth_3d_material_list_ctrl(auth_3d_material_list* ml, float_t frame); static bool auth_3d_material_list_parse(auth_3d_material_list* ml, struc_8* a2, prj::string_range_capacity str_rng_cap); static void auth_3d_set_material_list(auth_3d* auth); -auth_3d_id::auth_3d_id(int32_t uid) : id() { - ((auth_3d_id * (FASTCALL*)(auth_3d_id * This, int32_t uid))0x00000001401CDC80)(this, uid); -} - -auth_3d_id::auth_3d_id(const char* name) : id() { - ((auth_3d_id * (FASTCALL*)(auth_3d_id * This, int32_t uid))0x00000001401CDC80)( - this, auth_3d_data_get_uid_by_name(name)); -} - -bool auth_3d_id::check_not_empty() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->id != -1; - } - return false; -} - -bool auth_3d_id::check_loading() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->state == 1; - } - return false; -} - -bool auth_3d_id::check_loaded() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->state == 2; - } - return true; -} - -void* auth_3d_id::get_auth_3d() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth; - } - return 0; -} - -int32_t auth_3d_id::get_chara_id() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->chara_id; - } - return -1; -} - -const mat4* auth_3d_id::get_auth_3d_object_mat(size_t index, bool hrc) { - if (id < 0 || (id & 0x7FFF) >= AUTH_3D_DATA_COUNT) - return 0; - - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id != id || !auth->enable) - return 0; - - if (hrc) - return auth_3d_get_auth_3d_object_hrc_bone_mats(auth, index); - return auth_3d_get_auth_3d_object_mat(auth, index); -} - -bool auth_3d_id::get_enable() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->enable; - } - return false; -} - -bool auth_3d_id::get_ended() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->ended; - } - return true; -} - -float_t auth_3d_id::get_frame() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->frame; - } - return 0.0f; -} - -float_t auth_3d_id::get_frame_offset() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->frame_offset; - } - return 0.0f; -} - -float_t auth_3d_id::get_last_frame() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->last_frame; - } - return 0.0f; -} - -bool auth_3d_id::get_left_right_reverse() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->left_right_reverse; - } - return false; -} - -float_t auth_3d_id::get_play_control_begin() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->play_control.begin; - } - return 0.0f; -} - -float_t auth_3d_id::get_play_control_size() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->play_control.size; - } - return 0.0f; -} - -bool auth_3d_id::get_paused() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->paused; - } - return false; -} - -bool auth_3d_id::get_repeat() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->repeat; - } - return false; -} - -int32_t auth_3d_id::get_uid() { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - return auth->uid; - } - return -1; -} - -void auth_3d_id::read_file() { - ((void (FASTCALL*)(auth_3d_id * This))0x00000001401E0F80)(this); -} - -void auth_3d_id::set_alpha_obj_flags(float_t alpha, mdl::ObjFlags obj_flags) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) { - auth->alpha = alpha; - auth->obj_flags = obj_flags; - } - } -} - -void auth_3d_id::set_camera_root_update(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->camera_root_update = value; - } -} - -void auth_3d_id::set_chara_id(int32_t value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->chara_id = value; - } -} - -void auth_3d_id::set_chara_item(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->chara_item = value; - } -} - -void auth_3d_id::set_enable(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->enable = value; - } -} - -void auth_3d_id::set_frame_rate(FrameRateControl* value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - if (value) - auth->frame_rate = value; - else - auth->frame_rate = get_sys_frame_rate(); - } -} - -void auth_3d_id::set_last_frame(float_t value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->last_frame = value; - } -} - -void auth_3d_id::set_left_right_reverse(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->left_right_reverse = value; - } -} - -void auth_3d_id::set_mat(const mat4& value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->mat = value; - } -} - -void auth_3d_id::set_max_frame(float_t value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->max_frame = value; - } -} - -void auth_3d_id::set_paused(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->paused = value; - } -} - -void auth_3d_id::set_pos(int32_t value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->pos = value; - } -} - -void auth_3d_id::set_reflect(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->reflect = value; - } -} - -void auth_3d_id::set_repeat(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->repeat = value; - } -} - -void auth_3d_id::set_req_frame(float_t value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) { - auth->req_frame = value; - auth->frame_changed = true; - } - } -} - -void auth_3d_id::set_shadow(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->shadow = value; - } -} - -void auth_3d_id::set_src_dst_chara(int32_t src_chara, int32_t dst_chara) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) { - auth->src_chara = (chara_index)src_chara; - auth->dst_chara = (chara_index)dst_chara; - } - } -} - -void auth_3d_id::set_visibility(bool value) { - if (id >= 0 && ((id & 0x7FFF) < AUTH_3D_DATA_COUNT)) { - auth_3d* auth = &auth_3d_data->data[id & 0x7FFF]; - if (auth->id == id) - auth->visible = value; - } -} - -void auth_3d_id::unload() { - ((void (FASTCALL*)(auth_3d_id * This))0x00000001401D0190)(this); -} - -int32_t auth_3d_data_get_auth_3d_id(uint32_t uid, object_info obj_info, - int32_t* object_index, bool* hrc, int32_t instance) { - for (int32_t& i : auth_3d_data->loaded_ids) { - if (i < 0 || (i & 0x7FFF) >= AUTH_3D_DATA_COUNT) - continue; - - auth_3d* auth = &auth_3d_data->data[i & 0x7FFF]; - if (auth->id != i || !auth->enable) - continue; - - bool ret = false; - if (uid != -1) { - if (auth->uid != uid) - continue; - ret = true; - } - - int32_t obj_index = auth_3d_get_auth_3d_object_index(auth, obj_info, instance); - if (obj_index >= 0) { - if (object_index) - *object_index = obj_index; - if (hrc) - *hrc = false; - return i; - } - - int32_t obj_hrc_index = auth_3d_get_auth_3d_object_hrc_index(auth, obj_info, instance); - if (obj_hrc_index >= 0) { - if (object_index) - *object_index = obj_hrc_index; - if (hrc) - *hrc = true; - return i; - } - - if (ret) - return -1; - } - return -1; -} - HOOK(void, FASTCALL, auth_3d_parse, 0x00000001401C15B0, auth_3d* auth) { const int32_t state_before = auth->state; originalauth_3d_parse(auth); @@ -1369,6 +453,7 @@ void auth_3d_patch() { // Move both auth_3d_curve's value and type WRITE_MEMORY_STRING(0x00000001401B316A, "\x48\x8B\x43\x68\x48\x89" "\x47\x68\x48\x8B\xC7\x48\x8B\x5C\x24\x48\x48\x83\xC4\x30\x5F\xC3", 0x16); + // Null auth_3d's shadow, chara_item and reflect WRITE_MEMORY_STRING(0x00000001401D7A78, "\x44\x89\xBF\x98\x00\x00\x00", 0x07); @@ -1382,47 +467,6 @@ void auth_3d_patch() { INSTALL_HOOK(auth_3d_curve_parse); } -static int32_t auth_3d_get_auth_3d_object_index(auth_3d* auth, object_info object_info, int32_t instance) { - int32_t obj_instance = 0; - for (auth_3d_object& i : auth->object) - if (object_info == i.object_info) { - if (obj_instance == instance) - return (int32_t)(&i - auth->object.data()); - obj_instance++; - } - return -1; -} - -static const mat4* auth_3d_get_auth_3d_object_mat(auth_3d* auth, size_t index) { - if (index >= auth->object.size()) - return 0; - return &auth->object[index].model_transform.mat; -} - -static const mat4* auth_3d_get_auth_3d_object_hrc_bone_mats(auth_3d* auth, size_t index) { - if (index >= auth->object_hrc.size() || auth->object_hrc[index].node_bone_mats.size() < 1) - return 0; - return auth->object_hrc[index].node_bone_mats.data(); -} - -static int32_t auth_3d_get_auth_3d_object_hrc_index(auth_3d* auth, object_info obj_info, int32_t instance) { - if (instance < 0) { - for (auth_3d_object_hrc& i : auth->object_hrc) - if (obj_info == i.object_info) - return (int32_t)(&i - auth->object_hrc.data()); - } - else { - int32_t obj_instance = 0; - for (auth_3d_object_hrc& i : auth->object_hrc) - if (obj_info == i.object_info) { - if (obj_instance == instance) - return (int32_t)(&i - auth->object_hrc.data()); - obj_instance++; - } - } - return -1; -} - static void auth_3d_material_list_ctrl(auth_3d_material_list* ml, float_t frame) { auth_3d_rgba__ctrl(&ml->blend_color, frame); auth_3d_rgba__ctrl(&ml->emission, frame); diff --git a/src/DivaGL/auth_3d.hpp b/src/DivaGL/auth_3d.hpp index 481f47a..2eea4e6 100644 --- a/src/DivaGL/auth_3d.hpp +++ b/src/DivaGL/auth_3d.hpp @@ -5,101 +5,6 @@ #pragma once -#include "../KKdLib/default.hpp" -#include "../KKdLib/mat.hpp" -#include "../KKdLib/vec.hpp" -#include "mdl/draw_object.hpp" -#include "frame_rate_control.hpp" -#include "object.hpp" - -struct auth_3d_id { - int32_t id; - - inline auth_3d_id() { - id = -1; - } - - inline bool is_null() { - return id == -1; - } - - inline bool not_null() { - return id != -1; - } - - auth_3d_id(int32_t uid); - auth_3d_id(const char* name); - bool check_not_empty(); - bool check_loading(); - bool check_loaded(); - void* get_auth_3d(); - const mat4* get_auth_3d_object_mat(size_t index, bool hrc); - int32_t get_chara_id(); - bool get_enable(); - bool get_ended(); - float_t get_frame(); - float_t get_frame_offset(); - float_t get_last_frame(); - bool get_left_right_reverse(); - bool get_paused(); - float_t get_play_control_begin(); - float_t get_play_control_size(); - bool get_repeat(); - int32_t get_uid(); - void read_file(); - void set_alpha_obj_flags(float_t alpha, mdl::ObjFlags obj_flags); - void set_camera_root_update(bool value); - void set_chara_id(int32_t value); - void set_chara_item(bool value); - void set_enable(bool value); - void set_frame_rate(FrameRateControl* value); - void set_last_frame(float_t value); - void set_left_right_reverse(bool value); - void set_mat(const mat4& value); - void set_max_frame(float_t value); - void set_paused(bool value); - void set_pos(int32_t value); - void set_reflect(bool value); - void set_repeat(bool value); - void set_req_frame(float_t value); - void set_shadow(bool value); - void set_src_dst_chara(int32_t src_chara, int32_t dst_chara); - void set_visibility(bool value); - void unload(); -}; - -static_assert(sizeof(auth_3d_id) == 0x04, "\"auth_3d_id\" struct should have a size of 0x04"); - -inline bool operator >(const auth_3d_id& left, const auth_3d_id& right) { - return left.id > right.id; -} - -inline bool operator <(const auth_3d_id& left, const auth_3d_id& right) { - return left.id < right.id; -} - -inline bool operator >=(const auth_3d_id& left, const auth_3d_id& right) { - return left.id >= right.id; -} - -inline bool operator <=(const auth_3d_id& left, const auth_3d_id& right) { - return left.id <= right.id; -} - -inline bool operator ==(const auth_3d_id& left, const auth_3d_id& right) { - return left.id == right.id; -} - -inline bool operator !=(const auth_3d_id& left, const auth_3d_id& right) { - return left.id != right.id; -} - -extern int32_t(FASTCALL* auth_3d_data_get_uid_by_name)(const char* name); -extern bool (FASTCALL* auth_3d_data_check_category_loaded)(const char* category_name); -extern void (FASTCALL* auth_3d_data_load_category)(const char* category_name); -extern void (FASTCALL* auth_3d_data_unload_category)(const char* category_name); - -extern int32_t auth_3d_data_get_auth_3d_id(uint32_t uid, object_info obj_info, - int32_t* object_index, bool* hrc, int32_t instance); +#include "../AFTModsShared/auth_3d.hpp" extern void auth_3d_patch(); diff --git a/src/DivaGL/camera.cpp b/src/DivaGL/camera.cpp index 356245e..a91a67e 100644 --- a/src/DivaGL/camera.cpp +++ b/src/DivaGL/camera.cpp @@ -5,11 +5,9 @@ #include "camera.hpp" #include "render.hpp" -#include "resolution_mode.hpp" +#include "../AFTModsShared/resolution_mode.hpp" #include -camera_struct& camera_data = *(camera_struct*)0x0000000140FBC2C0; - static void (FASTCALL* camera_struct__update_view)(camera_struct& cam) = (void (FASTCALL*)(camera_struct & cam))0x00000001401F7690; @@ -75,15 +73,6 @@ HOOK(void, FASTCALL, camera_update, 0x00000001401F8970) { camera_data.fast_change = false; } -void camera_struct::get_view_point(vec3& value) { - value = view_point; -} - -void camera_struct::get_view_point(vec4& value) { - *(vec3*)&value = view_point; - value.w = 0.0f; -} - void camera_patch() { INSTALL_HOOK(camera_data_update_projection); INSTALL_HOOK(camera_update); diff --git a/src/DivaGL/camera.hpp b/src/DivaGL/camera.hpp index 18ff4cc..e4f0dbc 100644 --- a/src/DivaGL/camera.hpp +++ b/src/DivaGL/camera.hpp @@ -6,57 +6,6 @@ #pragma once #include "../KKdLib/default.hpp" -#include "../KKdLib/mat.hpp" -#include "../KKdLib/vec.hpp" - -struct camera_struct { - vec3 view_point; - vec3 interest; - float_t roll; - float_t fov; - float_t aet_fov; - int32_t field_24; - double_t aspect; - float_t min_distance; - float_t max_distance; - float_t proj_left_offset; - float_t proj_right_offset; - float_t proj_bottom_offset; - float_t proj_top_offset; - bool use_up; - char field_49; - char field_4A; - char field_4B; - vec3 up; - bool ignore_fov; - bool ignore_min_dist; - char field_5A; - char field_5B; - mat4 view; - mat4 inv_view; - mat4 projection; - mat4 view_projection; - mat4 view_projection_aet_2d; - mat4 view_projection_aet_3d; - float_t depth; - float_t aet_depth; - vec3 field_1E4; - vec3 field_1F0; - vec3 field_1FC; - vec3 field_208; - float_t distance; - vec3 rotation; - float_t fov_horizontal_rad; - char field_228; - bool fast_change; - bool fast_change_hist0; - bool fast_change_hist1; - int32_t field_22C; - - void get_view_point(vec3& value); - void get_view_point(vec4& value); -}; - -extern camera_struct& camera_data; +#include "../AFTModsShared/camera.hpp" extern void camera_patch(); diff --git a/src/DivaGL/clear_color.hpp b/src/DivaGL/clear_color.hpp index 8fc4059..b79cb71 100644 --- a/src/DivaGL/clear_color.hpp +++ b/src/DivaGL/clear_color.hpp @@ -6,7 +6,7 @@ #pragma once #include "../KKdLib/default.hpp" -#include "color.hpp" +#include "../AFTModsShared/color.hpp" extern color4u8& clear_color; diff --git a/src/DivaGL/data_test/rob_osage_test.cpp b/src/DivaGL/data_test/rob_osage_test.cpp index ac28ae1..1bc81c7 100644 --- a/src/DivaGL/data_test/rob_osage_test.cpp +++ b/src/DivaGL/data_test/rob_osage_test.cpp @@ -8,13 +8,13 @@ #include "../../KKdLib/io/path.hpp" #include "../../KKdLib/prj/algorithm.hpp" #include "../../KKdLib/key_val.hpp" +#include "../../AFTModsShared/bone_database.hpp" +#include "../../AFTModsShared/canonical_properties.hpp" +#include "../../AFTModsShared/dw.hpp" +#include "../../AFTModsShared/resolution_mode.hpp" #include "../Glitter/glitter.hpp" #include "../rob/rob.hpp" -#include "../bone_database.hpp" -#include "../canonical_properties.hpp" -#include "../dw.hpp" #include "../render_context.hpp" -#include "../resolution_mode.hpp" #include class RobOsageTestDw : public dw::Shell { diff --git a/src/DivaGL/data_test/rob_osage_test.hpp b/src/DivaGL/data_test/rob_osage_test.hpp index 9117ce9..c41a253 100644 --- a/src/DivaGL/data_test/rob_osage_test.hpp +++ b/src/DivaGL/data_test/rob_osage_test.hpp @@ -7,9 +7,9 @@ #include "../../KKdLib/default.hpp" #include "../../KKdLib/prj/vector_pair.hpp" +#include "../../AFTModsShared/task.hpp" +#include "../../AFTModsShared/types.hpp" #include "../rob/rob.hpp" -#include "../task.hpp" -#include "../types.hpp" class RobOsageTest : public app::Task { public: diff --git a/src/DivaGL/dllmain.cpp b/src/DivaGL/dllmain.cpp index 72d0aaa..afa37d7 100644 --- a/src/DivaGL/dllmain.cpp +++ b/src/DivaGL/dllmain.cpp @@ -27,7 +27,6 @@ static std::wstring GetDirPath(); std::wstring CONFIG_FILE_STRING = GetDirPath() + L"\\plugins\\DivaGL.ini"; LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str(); - void FASTCALL divagl_main() { int32_t cpuid_data[4] = {}; __cpuid(cpuid_data, 1); diff --git a/src/DivaGL/effect.cpp b/src/DivaGL/effect.cpp index 33f08cc..3b39af7 100644 --- a/src/DivaGL/effect.cpp +++ b/src/DivaGL/effect.cpp @@ -7,13 +7,13 @@ #include "../KKdLib/prj/algorithm.hpp" #include "../KKdLib/prj/vector_pair.hpp" #include "../KKdLib/hash.hpp" +#include "../AFTModsShared/file_handler.hpp" +#include "../AFTModsShared/frame_rate_control.hpp" #include "GL/element_array_buffer.hpp" #include "GL/shader_storage_buffer.hpp" #include "GL/uniform_buffer.hpp" #include "rob/rob.hpp" #include "auth_3d.hpp" -#include "file_handler.hpp" -#include "frame_rate_control.hpp" #include "gl_state.hpp" #include "render_context.hpp" #include "render_manager.hpp" diff --git a/src/DivaGL/graphics/color_change_dw.cpp b/src/DivaGL/graphics/color_change_dw.cpp index e6651e5..864f534 100644 --- a/src/DivaGL/graphics/color_change_dw.cpp +++ b/src/DivaGL/graphics/color_change_dw.cpp @@ -4,7 +4,9 @@ */ #include "color_change_dw.hpp" +#include "../../AFTModsShared/dw.hpp" #include "../rob/rob.hpp" +#include "../gl_state.hpp" #include "../texture.hpp" #include diff --git a/src/DivaGL/graphics/color_change_dw.hpp b/src/DivaGL/graphics/color_change_dw.hpp index 36f7f6d..7892a97 100644 --- a/src/DivaGL/graphics/color_change_dw.hpp +++ b/src/DivaGL/graphics/color_change_dw.hpp @@ -6,7 +6,6 @@ #pragma once #include "../../KKdLib/default.hpp" -#include "../dw.hpp" extern void color_change_dw_init(); extern void color_change_dw_free(); diff --git a/src/DivaGL/hook.cpp b/src/DivaGL/hook.cpp index 40f5d35..bd54d16 100644 --- a/src/DivaGL/hook.cpp +++ b/src/DivaGL/hook.cpp @@ -57,6 +57,8 @@ HOOK(int32_t, FASTCALL, data_init, 0x0000000140192FF0) { wrap_addresses(); #endif + sprite_shared_init(); + auth_3d_patch(); camera_patch(); color_change_dw_patch(); @@ -314,9 +316,6 @@ void hook_funcs() { extern size_t glut_handle; *(uint64_t*)&buf[0x02] = (uint64_t)&glut_create_context; WRITE_MEMORY_STRING(glut_handle + 0x0000A970, buf, 0x0C); - - // Patch font shader index - WRITE_MEMORY(0x00000001401982D8, uint32_t, SHADER_FT_FONT); } static HGLRC FASTCALL glut_create_context(int64_t a1, int64_t a2, int64_t a3, int64_t a4, int32_t a5) { diff --git a/src/DivaGL/light_param.cpp b/src/DivaGL/light_param.cpp index fbfbaab..c4bed4e 100644 --- a/src/DivaGL/light_param.cpp +++ b/src/DivaGL/light_param.cpp @@ -6,8 +6,7 @@ #include "light_param.hpp" #include "../KKdLib/hash.hpp" #include "../KKdLib/str_utils.hpp" -#include "light_param/light.hpp" -#include "file_handler.hpp" +#include "../AFTModsShared/file_handler.hpp" #include "render_context.hpp" #include diff --git a/src/DivaGL/light_param.hpp b/src/DivaGL/light_param.hpp index e32bf67..6efe40c 100644 --- a/src/DivaGL/light_param.hpp +++ b/src/DivaGL/light_param.hpp @@ -5,7 +5,7 @@ #pragma once -#include "types.hpp" +#include "../AFTModsShared/types.hpp" extern void light_param_patch(); extern void light_param_data_storage_data_set_ibl(); diff --git a/src/DivaGL/light_param/fog.cpp b/src/DivaGL/light_param/fog.cpp deleted file mode 100644 index b509edd..0000000 --- a/src/DivaGL/light_param/fog.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - by korenkonder - GitHub/GitLab: korenkonder -*/ - -#include "fog.hpp" -#include "../render_context.hpp" - -fog* fog_data = (fog*)0x00000001411974D0; - -fog_type fog::get_type() const { - return type; -} - -void fog::set_type(fog_type value) { - type = value; -} - -float_t fog::get_density() const { - return density; -} - -void fog::set_density(float_t value) { - density = value; -} - -float_t fog::get_start() const { - return start; -} - -void fog::set_start(float_t value) { - start = value; -} - -float_t fog::get_end() const { - return end; -} - -void fog::set_end(float_t value) { - end = value; -} - -int32_t fog::get_index() const { - return index; -} - -void fog::set_index(int32_t value) { - index = value; -} - -void fog::get_color(vec4& value) const { - value = color; -} - -void fog::set_color(const vec4& value) { - color = value; -} - -void fog::set_color(const vec4&& value) { - color = value; -} - -void fog::data_set(fog_id id) { - fog_type type = get_type(); - if (type == FOG_NONE) - return; - - float_t density = get_density(); - float_t start = get_start(); - float_t end = get_end(); - if (start >= end) - start = end - 0.01f; - - vec4 params; - params.x = density; - params.y = start; - params.z = end; - params.w = 1.0f / (end - start); - - extern render_context* rctx; - - switch (id) { - case FOG_DEPTH: { - float_t density = get_density(); - float_t start = get_start(); - float_t end = get_end(); - if (start >= end) - start = end - 0.01f; - vec4 color; - get_color(color); - - render_context::fog_params params = {}; - rctx->get_scene_fog_params(params); - params.density = density; - params.start = start; - params.end = end; - params.depth_color = color; - rctx->set_scene_fog_params(params); - } break; - case FOG_HEIGHT: { - float_t density = get_density(); - float_t start = get_start(); - float_t end = get_end(); - if (start >= end) - start = end - 0.01f; - vec4 color; - get_color(color); - - render_context::fog_params params = {}; - rctx->get_scene_fog_params(params); - params.height_params.x = density; - params.height_params.y = start; - params.height_params.z = end; - params.height_params.w = 1.0f / (end - start); - params.height_color = color; - rctx->set_scene_fog_params(params); - } break; - case FOG_BUMP: { - float_t density = get_density(); - float_t start = get_start(); - float_t end = get_end(); - if (start >= end) - start = end - 0.01f; - - render_context::fog_params params = {}; - rctx->get_scene_fog_params(params); - params.bump_params.x = density; - params.bump_params.y = start; - params.bump_params.z = end; - params.bump_params.w = 1.0f / (end - start); - rctx->set_scene_fog_params(params); - } break; - } -} diff --git a/src/DivaGL/light_param/light.cpp b/src/DivaGL/light_param/light.cpp deleted file mode 100644 index 3b0aa6e..0000000 --- a/src/DivaGL/light_param/light.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* - by korenkonder - GitHub/GitLab: korenkonder -*/ - -#include "light.hpp" -#include "../../KKdLib/mat.hpp" -#include "../render_context.hpp" -#include "../uniform.hpp" - -struct light_data_color { - vec4 ambient; - vec4 diffuse; - vec4 specular; -}; - -light_set* light_set_data = (light_set*)0x00000001411A00A0; - -static vec4& npr_cloth_spec_color = *(vec4*)0x0000000140C9B2A0; -static bool& light_chara_ambient = *(bool*)0x00000001411A0080; - -static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force = false); -static void light_get_light_color(light_data* light, light_data_color& value, light_id id); - -light_type light_data::get_type() const { - return type; -} - -void light_data::set_type(light_type value) { - type = value; - if (value < LIGHT_POINT) - position.w = 0.0f; - else - position.w = 1.0f; -} - -void light_data::get_ambient(vec4& value) const { - value = ambient; -} - -void light_data::set_ambient(const vec4& value) { - ambient = value; -} - -void light_data::set_ambient(const vec4&& value) { - ambient = value; -} - -void light_data::set_ambient(const vec4& value, bool set[4]) { - if (set[0]) - ambient.x = value.x; - if (set[1]) - ambient.y = value.y; - if (set[2]) - ambient.z = value.z; - if (set[3]) - ambient.w = value.w; -} - -void light_data::set_ambient(const vec4&& value, bool set[4]) { - if (set[0]) - ambient.x = value.x; - if (set[1]) - ambient.y = value.y; - if (set[2]) - ambient.z = value.z; - if (set[3]) - ambient.w = value.w; -} - -void light_data::get_diffuse(vec4& value) const { - value = diffuse; -} - -void light_data::set_diffuse(const vec4& value) { - diffuse = value; -} - -void light_data::set_diffuse(const vec4&& value) { - diffuse = value; -} - -void light_data::set_diffuse(const vec4& value, bool set[4]) { - if (set[0]) - diffuse.x = value.x; - if (set[1]) - diffuse.y = value.y; - if (set[2]) - diffuse.z = value.z; - if (set[3]) - diffuse.w = value.w; -} - -void light_data::set_diffuse(const vec4&& value, bool set[4]) { - if (set[0]) - diffuse.x = value.x; - if (set[1]) - diffuse.y = value.y; - if (set[2]) - diffuse.z = value.z; - if (set[3]) - diffuse.w = value.w; -} - -void light_data::get_specular(vec4& value) const { - value = specular; -} - -void light_data::set_specular(const vec4& value) { - specular = value; -} - -void light_data::set_specular(const vec4&& value) { - specular = value; -} - -void light_data::set_specular(const vec4& value, bool set[4]) { - if (set[0]) - specular.x = value.x; - if (set[1]) - specular.y = value.y; - if (set[2]) - specular.z = value.z; - if (set[3]) - specular.w = value.w; -} - -void light_data::set_specular(const vec4&& value, bool set[4]) { - if (set[0]) - specular.x = value.x; - if (set[1]) - specular.y = value.y; - if (set[2]) - specular.z = value.z; - if (set[3]) - specular.w = value.w; -} - -void light_data::get_position(vec3& value) const { - value = *(vec3*)&position; -} - -void light_data::set_position(const vec3& value) { - *(vec3*)&position = value; -} - -void light_data::set_position(const vec3&& value) { - *(vec3*)&position = value; -} - -void light_data::get_position(vec4& value) const { - value = position; -} - -void light_data::set_position(const vec4& value) { - position = value; -} - -void light_data::set_position(const vec4&& value) { - position = value; -} - -void light_data::get_spot_direction(vec3& value) const { - value = spot_direction; -} - -void light_data::set_spot_direction(const vec3& value) { - spot_direction = value; -} - -void light_data::set_spot_direction(const vec3&& value) { - spot_direction = value; -} - -float_t light_data::get_spot_exponent() const { - return spot_exponent; -} - -void light_data::set_spot_exponent(float_t value) { - spot_exponent = value; -} - -float_t light_data::get_spot_cutoff() const { - return spot_cutoff; -} - -void light_data::set_spot_cutoff(float_t value) { - spot_cutoff = value; -} - -float_t light_data::get_constant() const { - return attenuation.constant; -} - -void light_data::set_constant(float_t value) { - attenuation.constant = value; -} - -float_t light_data::get_linear() const { - return attenuation.linear; -} - -void light_data::set_linear(float_t value) { - attenuation.linear = value; -} - -float_t light_data::get_quadratic() const { - return attenuation.quadratic; -} - -void light_data::set_quadratic(float_t value) { - attenuation.quadratic = value; -} - -void light_data::get_attenuation(light_attenuation& value) const { - value = attenuation; -} - -void light_data::set_attenuation(const light_attenuation& value) { - attenuation = value; -} - -void light_data::set_attenuation(const light_attenuation&& value) { - attenuation = value; -} - -void light_data::get_ibl_color0(vec4& value) const { - value = ibl_color0; -} - -void light_data::set_ibl_color0(const vec4& value) { - ibl_color0 = value; -} - -void light_data::set_ibl_color0(const vec4&& value) { - ibl_color0 = value; -} - -void light_data::get_ibl_color1(vec4& value) const { - value = ibl_color1; -} - -void light_data::set_ibl_color1(const vec4& value) { - ibl_color1 = value; -} - -void light_data::set_ibl_color1(const vec4&& value) { - ibl_color1 = value; -} - -void light_data::get_ibl_direction(vec4& value) const { - value = ibl_direction; -} - -void light_data::set_ibl_direction(const vec4& value) { - ibl_direction = value; -} - -void light_data::set_ibl_direction(const vec4&& value) { - ibl_direction = value; -} - -void light_data::get_tone_curve(light_tone_curve& value) const { - value = tone_curve; -} - -void light_data::set_tone_curve(const light_tone_curve& value) { - tone_curve = value; -} - -void light_data::set_tone_curve(const light_tone_curve&& value) { - tone_curve = value; -} - -void light_data::get_clip_plane(light_clip_plane& value) const { - value = clip_plane; -} - -void light_data::set_clip_plane(const light_clip_plane& value) { - clip_plane = value; -} - -void light_data::set_clip_plane(const light_clip_plane&& value) { - clip_plane = value; -} - -void light_set::get_ambient_intensity(vec4& value) { - value = ambient_intensity; -} - -void light_set::set_ambient_intensity(const vec4& value) { - ambient_intensity = value; -} - -void light_set::set_ambient_intensity(const vec4&& value) { - ambient_intensity = value; -} - -void light_set::get_irradiance(mat4& r, mat4& g, mat4& b) { - r = irradiance_r; - g = irradiance_g; - b = irradiance_b; -} - -void light_set::set_irradiance(const mat4& r, const mat4& g, const mat4& b) { - irradiance_r = r; - irradiance_g = g; - irradiance_b = b; -} - -void light_set::set_irradiance(const mat4&& r, const mat4&& g, const mat4&& b) { - irradiance_r = r; - irradiance_g = g; - irradiance_b = b; -} - -void light_set::data_set(light_set_id id) { - static const float_t spec_coef = (float_t)(1.0 / (1.0 - cos(18.0 * DEG_TO_RAD))); - static const float_t luce_coef = (float_t)(1.0 / (1.0 - cos(45.0 * DEG_TO_RAD))); - - light_data_color light_color[LIGHT_MAX]; - for (int32_t i = 0; i < LIGHT_MAX; i++) - light_get_light_color(&lights[i], light_color[i], (light_id)i); - - vec4 light_env_stage_diffuse = light_color[LIGHT_STAGE].diffuse; - vec4 light_env_stage_specular = light_color[LIGHT_STAGE].specular; - - vec4 light_env_chara_diffuse = light_color[LIGHT_CHARA].diffuse; - vec4 light_env_chara_ambient = light_color[LIGHT_CHARA].ambient; - vec4 light_env_chara_specular = light_color[LIGHT_CHARA].specular; - - vec4 light_env_reflect_diffuse; - vec4 light_env_reflect_ambient; - lights[LIGHT_REFLECT].get_diffuse(light_env_reflect_diffuse); - lights[LIGHT_REFLECT].get_ambient(light_env_reflect_ambient); - - vec4 light_env_proj_diffuse; - vec4 light_env_proj_specular; - vec4 light_env_proj_position; - lights[LIGHT_PROJECTION].get_diffuse(light_env_proj_diffuse); - lights[LIGHT_PROJECTION].get_specular(light_env_proj_specular); - lights[LIGHT_PROJECTION].get_position(light_env_proj_position); - if (lights[LIGHT_PROJECTION].get_type() == LIGHT_PARALLEL) - light_get_direction_from_position(&light_env_proj_position, 0, true); - - vec4 light_chara_dir; - vec4 light_chara_ibl_color0; - vec4 light_chara_ibl_color1; - vec4 light_chara_specular; - lights[LIGHT_CHARA].get_position(light_chara_dir); - light_get_direction_from_position(&light_chara_dir, &lights[LIGHT_CHARA]); - lights[LIGHT_CHARA].get_ibl_color0(light_chara_ibl_color0); - lights[LIGHT_CHARA].get_ibl_color1(light_chara_ibl_color1); - lights[LIGHT_CHARA].get_specular(light_chara_specular); - - vec4 light_chara_spec = light_chara_specular * light_chara_ibl_color0 * spec_coef; - vec4 light_chara_luce = light_chara_ibl_color0 * luce_coef; - vec4 light_chara_back = light_chara_specular * light_chara_ibl_color1 * spec_coef; - - vec4 light_stage_dir; - vec4 light_stage_ibl_color; - vec4 light_stage_diffuse; - vec4 light_stage_specular; - lights[LIGHT_STAGE].get_position(light_stage_dir); - light_get_direction_from_position(&light_stage_dir, &lights[LIGHT_STAGE]); - lights[LIGHT_STAGE].get_ibl_color0(light_stage_ibl_color); - lights[LIGHT_STAGE].get_diffuse(light_stage_diffuse); - lights[LIGHT_STAGE].get_specular(light_stage_specular); - - vec4 light_stage_diff = light_stage_diffuse * light_stage_ibl_color; - vec4 light_stage_spec = light_stage_specular * light_stage_ibl_color * spec_coef; - - mat4 irradiance_r_transforms; - mat4 irradiance_g_transforms; - mat4 irradiance_b_transforms; - get_irradiance(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms); - - float_t* (FASTCALL * face_data_get)() = (float_t * (FASTCALL*)())0x00000001403D8310; - float_t v27 = face_data_get()[0]; - float_t v28 = (float_t)(1.0 - exp(v27 * -0.44999999)) * 2.0f; - v27 = max_def(v27, 0.0f); - vec4 light_face_diff = { v28 * 0.1f, v27 * 0.06f, 1.0f, 1.0f }; - - vec4 chara_color_rim; - vec4 chara_color0; - vec4 chara_color1; - if (lights[LIGHT_CHARA_COLOR].get_type() == LIGHT_PARALLEL) { - lights[LIGHT_CHARA_COLOR].get_ambient(chara_color_rim); - lights[LIGHT_CHARA_COLOR].get_diffuse(chara_color0); - lights[LIGHT_CHARA_COLOR].get_specular(chara_color1); - if (chara_color1.w > 1.0f) - chara_color1.w = 1.0f; - } - else { - chara_color_rim = 0.0f; - chara_color0 = 0.0f; - chara_color1 = 0.0f; - } - - vec4 chara_f_dir; - vec4 chara_f_ambient; - vec4 chara_f_diffuse; - vec4 chara_tc_param; - if (lights[LIGHT_TONE_CURVE].get_type() == LIGHT_PARALLEL) { - uniform->arr[U_TONE_CURVE] = 1; - lights[LIGHT_TONE_CURVE].get_position(chara_f_dir); - light_get_direction_from_position(&chara_f_dir, &lights[LIGHT_TONE_CURVE]); - lights[LIGHT_TONE_CURVE].get_ambient(chara_f_ambient); - lights[LIGHT_TONE_CURVE].get_diffuse(chara_f_diffuse); - - light_tone_curve tone_curve; - lights[LIGHT_TONE_CURVE].get_tone_curve(tone_curve); - chara_tc_param.x = tone_curve.start_point; - float_t end_point = min_def(tone_curve.end_point, 1.0f) - tone_curve.start_point; - if (end_point > 0.0f) - chara_tc_param.y = 1.0f / end_point; - else - chara_tc_param.y = 0.0f; - chara_tc_param.z = tone_curve.coefficient; - chara_tc_param.w = 0.0f; - } - else { - uniform->arr[U_TONE_CURVE] = 0; - chara_f_dir = { 0.0f, 1.0f, 0.0f, 0.0f }; - chara_f_ambient = 0.0f; - chara_f_diffuse = 0.0f; - chara_tc_param = 0.0f; - } - - vec4 light_reflect_dir; - lights[LIGHT_CHARA].get_position(light_reflect_dir); - if (fabsf(light_reflect_dir.x) <= 0.000001f && fabsf(light_reflect_dir.y) <= 0.000001f - && fabsf(light_reflect_dir.z) <= 0.000001f) - *(vec3*)&light_reflect_dir = vec3(0.0f, 1.0f, 0.0f); - else { - float_t length = vec3::length(*(vec3*)&light_reflect_dir); - if (length != 0.0f) - *(vec3*)&light_reflect_dir *= 1.0f / length; - } - light_reflect_dir.w = 1.0f; - - vec4 clip_plane; - if (lights[LIGHT_REFLECT].get_type() == LIGHT_SPOT) { - vec3 spot_direction; - vec4 position; - lights[LIGHT_REFLECT].get_spot_direction(spot_direction); - lights[LIGHT_REFLECT].get_position(position); - *(vec3*)&clip_plane = -spot_direction; - light_get_direction_from_position(&clip_plane, &lights[LIGHT_REFLECT], true); - clip_plane.w = -vec3::dot(*(vec3*)&position, *(vec3*)&clip_plane); - } - else if (lights[LIGHT_REFLECT].get_type() == LIGHT_POINT) - clip_plane = { 0.0f, -1.0f, 0.0f, 9999.0f }; - else - clip_plane = { 0.0f, -1.0f, 0.0f, 0.0f }; - - vec4 light_chara_ibl_direction; - vec4 light_chara_position; - lights[LIGHT_CHARA].get_ibl_direction(light_chara_ibl_direction); - lights[LIGHT_CHARA].get_position(light_chara_position); - - mat4 normal_tangent_transforms = mat4_identity; - - float_t length = vec3::length(*(vec3*)&light_chara_ibl_direction); - if (length >= 0.000001f) { - vec3 ibl_direction = *(vec3*)&light_chara_ibl_direction * (1.0f / length); - - length = vec3::length(*(vec3*)&light_chara_position); - if (length >= 0.000001f) { - vec3 position = *(vec3*)&light_chara_position * (1.0f / length); - - vec3 axis = vec3::cross(ibl_direction, position); - length = vec3::length(axis); - - float_t v52 = vec3::dot(ibl_direction, position); - float_t angle = fabsf(atan2f(length, v52)); - if (angle >= 0.01f && angle <= 3.131592653589793f) { - if (length != 0.0f) - axis *= 1.0f / length; - - mat4_set(&axis, -angle, &normal_tangent_transforms); - } - } - } - - extern render_context* rctx; - rctx->set_scene_light(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms, - light_env_stage_diffuse, light_env_stage_specular, light_env_chara_diffuse, - light_env_chara_ambient, light_env_chara_specular, - light_env_reflect_diffuse, light_env_reflect_ambient, - light_env_proj_diffuse, light_env_proj_specular, - light_env_proj_position, light_stage_dir, light_stage_diff, - light_stage_spec, light_chara_dir, light_chara_spec, - light_chara_luce, light_chara_back, light_face_diff, - chara_color0, chara_color1, chara_f_dir, chara_f_ambient, - chara_f_diffuse, chara_tc_param, normal_tangent_transforms, - light_reflect_dir, clip_plane, npr_cloth_spec_color); -} - -static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force) { - if (force || light->get_type() == LIGHT_PARALLEL) { - float_t length = vec3::length(*(vec3*)pos_dir); - if (length <= 0.000001) - *(vec3*)pos_dir = vec3(0.0f, 1.0f, 0.0f); - else - *(vec3*)pos_dir *= 1.0f / length; - pos_dir->w = 0.0f; - } -} - -static void light_get_light_color(light_data* light, light_data_color& value, light_id id) { - if (id || light_chara_ambient) - value.ambient = light->ambient; - else - value.ambient = { 0.0f, 0.0f, 0.0f, 1.0f }; - - if (!id && false) - value.diffuse = light->diffuse * 4.0f; - else - value.diffuse = light->diffuse; - - value.specular = light->specular; -} diff --git a/src/DivaGL/mdl/disp_manager.cpp b/src/DivaGL/mdl/disp_manager.cpp index 7b5b53f..b409cd4 100644 --- a/src/DivaGL/mdl/disp_manager.cpp +++ b/src/DivaGL/mdl/disp_manager.cpp @@ -5,6 +5,7 @@ #include "disp_manager.hpp" #include "../../KKdLib/hash.hpp" +#include "../../AFTModsShared/uniform.hpp" #include "../Glitter/glitter.hpp" #include "../rob/rob.hpp" #include "../gl_state.hpp" @@ -13,7 +14,6 @@ #include "../shader_ft.hpp" #include "../sprite.hpp" #include "../stage.hpp" -#include "../uniform.hpp" #include "../wrap.hpp" #include "draw_object.hpp" #include @@ -58,23 +58,6 @@ material_list_struct::material_list_struct(uint64_t hash, vec4& blend_color, } -texture_pattern_struct::texture_pattern_struct() { - -} - -texture_pattern_struct::texture_pattern_struct(texture_id src, texture_id dst) : src(src), dst(dst) { - -} - -texture_transform_struct::texture_transform_struct() { - id = (uint32_t)-1; - mat = mat4_identity; -} - -texture_transform_struct::texture_transform_struct(uint32_t id, const mat4& mat) : id(id), mat(mat) { - -} - namespace mdl { prj::vector vertex_array_cache; prj::vector etc_vertex_array_cache; @@ -82,7 +65,6 @@ namespace mdl { int32_t material_list_count; material_list_struct material_list_array[MATERIAL_LIST_COUNT]; - bool obj_reflect_enable; ObjSubMeshArgs::ObjSubMeshArgs() : sub_mesh(), mesh(), material(), textures(), mat_count(), mats(), @@ -2375,9 +2357,9 @@ namespace mdl { return obj_axis_aligned_bounding_box_check_visibility_default(aabb, mat); } - bool DispManager::entry_obj(const ::obj* obj, const mat4& mat, obj_mesh_vertex_buffer* obj_vert_buf, + bool DispManager::entry_obj(const ::obj* obj, const mat4& mat, obj_mesh_vertex_buffer_divagl* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, const prj::vector* textures, const vec4* blend_color, - const mat4* bone_mat, const ::obj* obj_morph, obj_mesh_vertex_buffer* obj_morph_vert_buf, + const mat4* bone_mat, const ::obj* obj_morph, obj_mesh_vertex_buffer_divagl* obj_morph_vert_buf, int32_t instances_count, const mat4* instances_mat, draw_func func, const ObjSubMeshArgs* func_data, bool enable_bone_mat, bool local) { if (!obj_vert_buf || !obj_index_buf) @@ -2986,40 +2968,38 @@ namespace mdl { return true; } - void DispManager::entry_obj_by_obj(const mat4& mat, - const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer* obj_vert_buf, - obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) { - if (!obj) - return; - - const vec4 blend_color(1.0f, 1.0f, 1.0f, alpha); - - entry_obj(obj, mat, obj_vert_buf, obj_index_buf, textures, - alpha < 1.0f ? &blend_color : 0, bone_mat, 0, 0, 0, 0, 0, 0, !!bone_mat); - } - #if SHARED_OBJECT_BUFFER #pragma warning(push) +#pragma warning(disable: 6385) #pragma warning(disable: 6386) void DispManager::entry_obj_by_obj(const mat4& mat, - const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer_aft* obj_vert_buf, - obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) { + const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer* obj_vert_buf, + obj_mesh_index_buffer* obj_index_buf, const mat4* bone_mat, float_t alpha) { if (!obj) return; - obj_mesh_vertex_buffer* _obj_vert_buf = new (_operator_new( - sizeof(obj_mesh_vertex_buffer) * obj->num_mesh)) obj_mesh_vertex_buffer[obj->num_mesh]; + const int32_t num_mesh = obj->num_mesh; + obj_mesh_vertex_buffer_divagl* _obj_vert_buf = new (_operator_new( + sizeof(obj_mesh_vertex_buffer_divagl) * num_mesh)) obj_mesh_vertex_buffer_divagl[num_mesh]; if (!_obj_vert_buf) return; - for (int32_t i = 0; i < obj->num_mesh; i++) { - _obj_vert_buf[i].count = obj_vert_buf[i].count; - _obj_vert_buf[i].buffers[0] = obj_vert_buf[i].buffers[0]; - _obj_vert_buf[i].buffers[1] = obj_vert_buf[i].buffers[1]; - _obj_vert_buf[i].buffers[2] = obj_vert_buf[i].buffers[2]; - _obj_vert_buf[i].index = obj_vert_buf[i].index; - _obj_vert_buf[i].size = obj_vert_buf[i].get_size(); - _obj_vert_buf[i].offset = 0; + for (int32_t i = 0; i < num_mesh; i++) { + obj_mesh_vertex_buffer& src_buf = obj_vert_buf[i]; + obj_mesh_vertex_buffer_divagl& dst_buf = _obj_vert_buf[i]; + dst_buf = src_buf; + if (src_buf.buffers[0]) { + GLint buffer; + GLint size; + glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, &buffer); + glBindBuffer(src_buf.target, src_buf.buffers[0]); + glGetBufferParameteriv(src_buf.target, GL_BUFFER_SIZE, &size); + glBindBuffer(src_buf.target, buffer); + dst_buf.size = size; + } + else + dst_buf.size = 0; + dst_buf.offset = 0; } vec4 blend_color = 1.0f; @@ -3033,17 +3013,29 @@ namespace mdl { #pragma warning(pop) #endif + void DispManager::entry_obj_by_obj(const mat4& mat, + const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer_divagl* obj_vert_buf, + obj_mesh_index_buffer* obj_index_buf, const mat4* bone_mat, float_t alpha) { + if (!obj) + return; + + const vec4 blend_color(1.0f, 1.0f, 1.0f, alpha); + + entry_obj(obj, mat, obj_vert_buf, obj_index_buf, textures, + alpha < 1.0f ? &blend_color : 0, bone_mat, 0, 0, 0, 0, 0, 0, !!bone_mat); + } + bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info) { return entry_obj_by_object_info(mat, obj_info, 0, 0, 0, 0, 0, 0, false); } - bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info, mat4* bone_mat) { + bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info, const mat4* bone_mat) { vec4 blend_color = 1.0f; return entry_obj_by_object_info(mat, obj_info, &blend_color, bone_mat, 0, 0, 0, 0, true); } bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info, - vec4* blend_color, mat4* bone_mat, int32_t instances_count, mat4* instances_mat, + const vec4* blend_color, const mat4* bone_mat, int32_t instances_count, const mat4* instances_mat, void(*func)(const ObjSubMeshArgs*), const ObjSubMeshArgs* func_data, bool enable_bone_mat, bool local) { if (obj_info.id == (uint16_t)-1 && obj_info.set_id == (uint16_t)-1) @@ -3054,14 +3046,16 @@ namespace mdl { return false; prj::vector* textures = objset_info_storage_get_set_gentex(obj_info.set_id); - obj_mesh_vertex_buffer* obj_vert_buffer = objset_info_storage_get_obj_mesh_vertex_buffer(obj_info, 0); + obj_mesh_vertex_buffer_divagl* obj_vert_buffer = (obj_mesh_vertex_buffer_divagl*) + objset_info_storage_get_obj_mesh_vertex_buffer(obj_info, 0); obj_mesh_index_buffer* obj_index_buffer = objset_info_storage_get_obj_mesh_index_buffer(obj_info, 0); ::obj* obj_morph = 0; - obj_mesh_vertex_buffer* obj_morph_vert_buffer = 0; + obj_mesh_vertex_buffer_divagl* obj_morph_vert_buffer = 0; if (morph.object.set_id != (uint16_t)-1) { obj_morph = objset_info_storage_get_obj(morph.object); - obj_morph_vert_buffer = objset_info_storage_get_obj_mesh_vertex_buffer(morph.object, 0); + obj_morph_vert_buffer = (obj_mesh_vertex_buffer_divagl*) + objset_info_storage_get_obj_mesh_vertex_buffer(morph.object, 0); } return entry_obj(obj, mat, obj_vert_buffer, obj_index_buffer, @@ -3070,26 +3064,26 @@ namespace mdl { } bool DispManager::entry_obj_by_object_info(const mat4& mat, - object_info obj_info, float_t alpha, mat4* bone_mat) { + object_info obj_info, float_t alpha, const mat4* bone_mat) { vec4 blend_color = 1.0f; blend_color.w = alpha; return entry_obj_by_object_info(mat, obj_info, &blend_color, bone_mat, 0, 0, 0, 0, true); } bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info, - float_t r, float_t g, float_t b, float_t a, mat4* bone_mat, bool local) { + float_t r, float_t g, float_t b, float_t a, const mat4* bone_mat, bool local) { vec4 blend_color = { r, g, b, a }; return entry_obj_by_object_info(mat, obj_info, &blend_color, bone_mat, 0, 0, 0, 0, true, local); } bool DispManager::entry_obj_by_object_info(const mat4& mat, object_info obj_info, - vec4* blend_color, mat4* bone_mat, bool local) { + const vec4* blend_color, const mat4* bone_mat, bool local) { return entry_obj_by_object_info(mat, obj_info, blend_color, 0, 0, 0, 0, 0, false, local); } void DispManager::entry_obj_by_object_info_object_skin(object_info obj_info, prj::vector* texture_pattern, texture_data_struct* texture_data, float_t alpha, - mat4* matrices, mat4* ex_data_matrices, const mat4* mat, const mat4& global_mat) { + const mat4* matrices, const mat4* ex_data_matrices, const mat4* mat, const mat4& global_mat) { obj_skin* skin = objset_info_storage_get_obj_skin(obj_info); if (!skin) return; @@ -3593,17 +3587,10 @@ namespace mdl { } -#if SHARED_OBJECT_BUFFER - HOOK(void, FASTCALL, DispManager__entry_obj_by_obj, 0x0000000140439A20, obj* obj_data, prj::vector* textures, - obj_mesh_vertex_buffer_aft* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) { - disp_manager->entry_obj_by_obj(*rob_chara_item_equip_mat, obj_data, textures, obj_vert_buf, obj_index_buf, bone_mat, alpha); - } -#else HOOK(void, FASTCALL, DispManager__entry_obj_by_obj, 0x0000000140439A20, obj* obj_data, prj::vector* textures, obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) { disp_manager->entry_obj_by_obj(*rob_chara_item_equip_mat, obj_data, textures, obj_vert_buf, obj_index_buf, bone_mat, alpha); } -#endif HOOK(void, FASTCALL, disp_manager_refresh, 0x0000000140439D20) { disp_manager->refresh(); @@ -3621,6 +3608,13 @@ namespace mdl { disp_manager->entry_obj_etc(mat, etc); } + HOOK(void, FASTCALL, DispManager__entry_obj_by_object_info_object_skin, 0x00000001405E8E20, uint32_t obj_info, + prj::vector* texture_pattern, texture_data_struct* texture_data, float_t alpha, + const mat4* matrices, const mat4* ex_data_matrices, const mat4* mat) { + disp_manager->entry_obj_by_object_info_object_skin(obj_info, texture_pattern, + texture_data, alpha, matrices, ex_data_matrices, mat, *rob_chara_item_equip_mat); + } + void disp_manager_patch() { INSTALL_HOOK(DataTestObjectManager__Disp); INSTALL_HOOK(MeshDw__DrawObjAxisAlignedBoundingBox); @@ -3630,6 +3624,7 @@ namespace mdl { INSTALL_HOOK(DispManager__entry_obj_by_obj); INSTALL_HOOK(disp_manager_refresh); INSTALL_HOOK(sub_1404BCC60); + INSTALL_HOOK(DispManager__entry_obj_by_object_info_object_skin); } } diff --git a/src/DivaGL/mdl/disp_manager.hpp b/src/DivaGL/mdl/disp_manager.hpp index 9f7acfb..747a893 100644 --- a/src/DivaGL/mdl/disp_manager.hpp +++ b/src/DivaGL/mdl/disp_manager.hpp @@ -8,9 +8,10 @@ #include "../../KKdLib/default.hpp" #include "../../KKdLib/mat.hpp" #include "../../KKdLib/vec.hpp" +#include "../../AFTModsShared/mdl/disp_manager.hpp" +#include "../../AFTModsShared/color.hpp" #include "../GL/array_buffer.hpp" #include "../GL/element_array_buffer.hpp" -#include "../color.hpp" #include "../object.hpp" #include "../shadow.hpp" @@ -41,41 +42,6 @@ namespace mdl { OBJ_KIND_MAX, }; - enum ObjFlags : uint32_t { - OBJ_SHADOW = 0x00000001, - OBJ_2 = 0x00000002, - OBJ_4 = 0x00000004, - OBJ_8 = 0x00000008, - OBJ_10 = 0x00000010, - OBJ_20 = 0x00000020, - OBJ_40 = 0x00000040, - OBJ_SHADOW_OBJECT = 0x00000080, - OBJ_CHARA_REFLECT = 0x00000100, - OBJ_REFLECT = 0x00000200, - OBJ_REFRACT = 0x00000400, - OBJ_800 = 0x00000800, - OBJ_TRANSLUCENT_SORT_BY_RADIUS = 0x00001000, - OBJ_SSS = 0x00002000, - OBJ_4000 = 0x00004000, - OBJ_8000 = 0x00008000, - OBJ_ALPHA_ORDER_1 = 0x00010000, - OBJ_ALPHA_ORDER_2 = 0x00020000, - OBJ_ALPHA_ORDER_3 = 0x00040000, - OBJ_80000 = 0x00080000, - OBJ_100000 = 0x00100000, - OBJ_200000 = 0x00200000, - OBJ_400000 = 0x00400000, - OBJ_800000 = 0x00800000, - OBJ_USER = 0x01000000, - OBJ_2000000 = 0x02000000, - OBJ_4000000 = 0x04000000, - OBJ_8000000 = 0x08000000, - OBJ_10000000 = 0x10000000, - OBJ_20000000 = 0x20000000, - OBJ_40000000 = 0x40000000, - OBJ_NO_TRANSLUCENCY = 0x80000000, - }; - enum ObjType { OBJ_TYPE_OPAQUE = 0, OBJ_TYPE_TRANSLUCENT, @@ -139,36 +105,6 @@ struct morph_struct { static_assert(sizeof(morph_struct) == 0x08, "\"morph_struct\" struct should have a size of 0x08"); -struct texture_pattern_struct { - texture_id src; - texture_id dst; - - texture_pattern_struct(); - texture_pattern_struct(texture_id src, texture_id dst); -}; - -static_assert(sizeof(texture_pattern_struct) == 0x08, "\"texture_pattern_struct\" struct should have a size of 0x08"); - -struct texture_transform_struct { - uint32_t id; - mat4 mat; - - texture_transform_struct(); - texture_transform_struct(uint32_t id, const mat4& mat); -}; - -static_assert(sizeof(texture_transform_struct) == 0x44, "\"texture_pattern_struct\" struct should have a size of 0x44"); - -struct texture_data_struct { - int32_t field_0; - vec3 texture_color_coefficients; - vec3 texture_color_offset; - vec3 texture_specular_coefficients; - vec3 texture_specular_offset; -}; - -static_assert(sizeof(texture_data_struct) == 0x34, "\"texture_pattern_struct\" struct should have a size of 0x34"); - namespace mdl { struct ObjSubMeshArgs; @@ -459,32 +395,33 @@ namespace mdl { void draw(mdl::ObjType type, int32_t depth_mask = 0, bool reflect_texture_mask = true, int32_t alpha = -1); /*void draw_show_vector(mdl::ObjType type, int32_t show_vector);*/ void entry_list(ObjType type, ObjData* data); - bool entry_obj(const ::obj* obj, const mat4& mat, obj_mesh_vertex_buffer* obj_vert_buf, + bool entry_obj(const ::obj* obj, const mat4& mat, obj_mesh_vertex_buffer_divagl* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, const prj::vector* textures, const vec4* blend_color, - const mat4* bone_mat, const ::obj* obj_morph, obj_mesh_vertex_buffer* obj_morph_vert_buf, + const mat4* bone_mat, const ::obj* obj_morph, obj_mesh_vertex_buffer_divagl* obj_morph_vert_buf, int32_t instances_count, const mat4* instances_mat, draw_func func, const ObjSubMeshArgs* func_data, bool enable_bone_mat, bool local = false); - void entry_obj_by_obj(const mat4& mat, - const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer* obj_vert_buf, - obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha); #if SHARED_OBJECT_BUFFER void entry_obj_by_obj(const mat4& mat, - const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer_aft* obj_vert_buf, - obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha); + const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer* obj_vert_buf, + obj_mesh_index_buffer* obj_index_buf, const mat4* bone_mat, float_t alpha); #endif + void entry_obj_by_obj(const mat4& mat, + const ::obj* obj, prj::vector* textures, obj_mesh_vertex_buffer_divagl* obj_vert_buf, + obj_mesh_index_buffer* obj_index_buf, const mat4* bone_mat, float_t alpha); + bool entry_obj_by_object_info(const mat4& mat, object_info obj_info); - bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, mat4* bone_mat); + bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, const mat4* bone_mat); bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, - vec4* blend_color, mat4* bone_mat, int32_t instances_count, mat4* instances_mat, + const vec4* blend_color, const mat4* bone_mat, int32_t instances_count, const mat4* instances_mat, void(*func)(const ObjSubMeshArgs*), const ObjSubMeshArgs* func_data, bool enable_bone_mat, bool local = false); - bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, float_t alpha, mat4* bone_mat = 0); + bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, float_t alpha, const mat4* bone_mat = 0); bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, - float_t r, float_t g, float_t b, float_t a, mat4* bone_mat = 0, bool local = false); + float_t r, float_t g, float_t b, float_t a, const mat4* bone_mat = 0, bool local = false); bool entry_obj_by_object_info(const mat4& mat, object_info obj_info, - vec4* blend_color, mat4* bone_mat = 0, bool local = false); + const vec4* blend_color, const mat4* bone_mat = 0, bool local = false); void entry_obj_by_object_info_object_skin(object_info obj_info, prj::vector* texture_pattern, texture_data_struct* texture_data, float_t alpha, - mat4* matrices, mat4* ex_data_matrices, const mat4* mat, const mat4& global_mat); + const mat4* matrices, const mat4* ex_data_matrices, const mat4* mat, const mat4& global_mat); void entry_obj_etc(const mat4& mat, const EtcObj& etc, bool local = false); void entry_obj_user(const mat4& mat, UserArgsFunc func, void* data, ObjType type); GLuint get_vertex_array(const ObjSubMeshArgs* args); diff --git a/src/DivaGL/mdl/draw_object.cpp b/src/DivaGL/mdl/draw_object.cpp index 03c8656..e846f6d 100644 --- a/src/DivaGL/mdl/draw_object.cpp +++ b/src/DivaGL/mdl/draw_object.cpp @@ -5,7 +5,7 @@ #include "draw_object.hpp" #include "../../KKdLib/hash.hpp" -#include "../light_param/light.hpp" +#include "../../AFTModsShared/light_param/light.hpp" #include "../shader_ft.hpp" #include "../texture.hpp" diff --git a/src/DivaGL/object.cpp b/src/DivaGL/object.cpp index 87f68bf..728f260 100644 --- a/src/DivaGL/object.cpp +++ b/src/DivaGL/object.cpp @@ -5,9 +5,9 @@ #include "object.hpp" #include "../KKdLib/hash.hpp" +#include "../AFTModsShared/file_handler.hpp" #include "mdl/disp_manager.hpp" #include "pv_game/firstread.hpp" -#include "file_handler.hpp" #include "gl_state.hpp" #include "wrap.hpp" #include @@ -51,42 +51,14 @@ struct ObjsetInfo { static_assert(sizeof(ObjsetInfo) == 0xD8, "\"ObjsetInfo\" struct should have a size of 0xD8"); -void (FASTCALL* objset_info_storage_unload_set)(int32_t set) - = (void (FASTCALL*)(int32_t set))0x00000001404599B0; -obj_mesh* (FASTCALL* objset_info_storage_get_obj_mesh_by_index)(uint32_t obj_info, int32_t mesh_index) - = (obj_mesh * (FASTCALL*)(uint32_t obj_info, int32_t mesh_index))0x0000000140459D40; -int32_t(FASTCALL* objset_info_storage_get_obj_mesh_index)(uint32_t obj_info, const char* mesh_name) - = (int32_t(FASTCALL*)(uint32_t obj_info, const char* mesh_name))0x0000000140459DE0; -const char* (FASTCALL* object_database_get_obj_name)(uint32_t obj_info) - = (const char* (FASTCALL*)(uint32_t obj_info))0x0000000140459F20; -uint32_t(FASTCALL* object_database_get_object_info)(const char* name) - = (uint32_t(FASTCALL*)(const char* name))0x0000000140459F80; -obj* (FASTCALL* objset_info_storage_get_obj)(uint32_t obj_info) - = (obj * (FASTCALL*)(uint32_t obj_info))0x000000014045A140; obj_mesh_index_buffer* (FASTCALL* objset_info_storage_get_obj_mesh_index_buffer)(uint32_t obj_info, int32_t a2) = (obj_mesh_index_buffer * (FASTCALL*)(uint32_t obj_info, int32_t a2))0x000000014045A250; -obj_skin* (FASTCALL* objset_info_storage_get_obj_skin)(uint32_t obj_info) - = (obj_skin * (FASTCALL*)(uint32_t obj_info))0x000000014045A3E0; obj_mesh_vertex_buffer* (FASTCALL* objset_info_storage_get_obj_mesh_vertex_buffer)(uint32_t obj_info, int32_t a2) = (obj_mesh_vertex_buffer * (FASTCALL*)(uint32_t obj_info, int32_t a2))0x000000014045A480; -int32_t(FASTCALL* objset_info_storage_get_set_obj_id)(int32_t set_index, int32_t obj_index) - = (int32_t(FASTCALL*)(int32_t set_index, int32_t obj_index))0x000000014045A750; GLuint(FASTCALL* objset_info_storage_get_set_texture)(int32_t set, int32_t tex_id) = (GLuint(FASTCALL*)(int32_t set, int32_t tex_id))0x000000014045A8F0; prj::vector* (FASTCALL* objset_info_storage_get_set_gentex)(int32_t set) = (prj::vector * (FASTCALL*)(int32_t set))0x000000014045A9E0; -int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index) - = (int32_t(FASTCALL*)(int32_t set_index))0x000000014045AA10; -int32_t(FASTCALL* object_database_get_object_set_id)(const char* name) - = (int32_t(FASTCALL*)(const char* name))0x000000014045AA60; -int32_t(FASTCALL* objset_info_storage_get_set_tex_num)(int32_t set) - = (int32_t(FASTCALL*)(int32_t set))0x000000014045ADE0; -texture** (FASTCALL* objset_info_storage_get_set_textures)(int32_t set) - = (texture * *(FASTCALL*)(int32_t set))0x000000014045AE20; -int32_t(FASTCALL* objset_info_storage_load_set)(int32_t set) - = (int32_t(FASTCALL*)(int32_t set))0x000000014045C6A0; -bool (FASTCALL* objset_info_storage_load_obj_set_check_not_read)(int32_t set) - = (bool(FASTCALL*)(int32_t set))0x000000014045DA60; static BufObjMgr& bufobj_mgr = *(BufObjMgr*)0x00000001411A34D0; @@ -106,33 +78,16 @@ static uint32_t obj_vertex_format_get_vertex_size(obj_vertex_format format); static uint32_t obj_vertex_format_get_vertex_size_comp1(obj_vertex_format format); static uint32_t obj_vertex_format_get_vertex_size_comp2(obj_vertex_format format); -obj_material_shader_lighting_type obj_material_shader_attrib::get_lighting_type() const { - if (!m.is_lgt_diffuse && !m.is_lgt_specular) - return OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT; - else if (!m.is_lgt_specular) - return OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT; - else - return OBJ_MATERIAL_SHADER_LIGHTING_PHONG; -} - -int32_t obj_texture_attrib::get_blend() const { - switch (m.blend) { - case 4: - return 2; - case 6: - return 1; - case 16: - return 3; - default: - return 0; - } -} - -obj_mesh_index_buffer::obj_mesh_index_buffer() : buffer() { +obj_mesh_index_buffer_divagl::obj_mesh_index_buffer_divagl() { } -bool obj_mesh_index_buffer::load(obj_mesh* mesh) { +obj_mesh_index_buffer_divagl::obj_mesh_index_buffer_divagl( + const obj_mesh_index_buffer& other) : obj_mesh_index_buffer(other) { + +} + +bool obj_mesh_index_buffer_divagl::load(obj_mesh* mesh) { size_t num_index = 0; for (int32_t i = 0; i < mesh->num_submesh; i++) if (mesh->submesh_array[i].index_format == OBJ_INDEX_U16) @@ -144,14 +99,14 @@ bool obj_mesh_index_buffer::load(obj_mesh* mesh) { } uint16_t* indices = force_malloc(num_index); - obj_mesh_index_buffer::fill_data(indices, mesh); + obj_mesh_index_buffer_divagl::fill_data(indices, mesh); bool ret = load_data(num_index * sizeof(uint16_t), indices); free_def(indices); return ret; } -bool obj_mesh_index_buffer::load_data(size_t size, const void* data) { +bool obj_mesh_index_buffer_divagl::load_data(size_t size, const void* data) { if (!size) return false; @@ -159,12 +114,12 @@ bool obj_mesh_index_buffer::load_data(size_t size, const void* data) { return true; } -void obj_mesh_index_buffer::unload() { +void obj_mesh_index_buffer_divagl::unload() { free_index_buffer(buffer); buffer = 0; } -void* obj_mesh_index_buffer::fill_data(void* data, obj_mesh* mesh) { +void* obj_mesh_index_buffer_divagl::fill_data(void* data, obj_mesh* mesh) { uint16_t* indices = (uint16_t*)data; for (int32_t i = 0; i < mesh->num_submesh; i++) { obj_sub_mesh& sub_mesh = mesh->submesh_array[i]; @@ -206,25 +161,35 @@ void* obj_mesh_index_buffer::fill_data(void* data, obj_mesh* mesh) { } #if SHARED_OBJECT_BUFFER -obj_mesh_vertex_buffer::obj_mesh_vertex_buffer() : count(), buffers(), size(), offset(), index() { +obj_mesh_vertex_buffer_divagl::obj_mesh_vertex_buffer_divagl() : size(), offset() { #else -obj_mesh_vertex_buffer::obj_mesh_vertex_buffer() : count(), buffers(), index(), target() { +obj_mesh_vertex_buffer_divagl::obj_mesh_vertex_buffer_divagl() { #endif } -void obj_mesh_vertex_buffer::cycle_index() { +#if SHARED_OBJECT_BUFFER +obj_mesh_vertex_buffer_divagl::obj_mesh_vertex_buffer_divagl( + const obj_mesh_vertex_buffer& other) : obj_mesh_vertex_buffer(other), size(), offset() { +#else +obj_mesh_vertex_buffer_divagl::obj_mesh_vertex_buffer_divagl( + const obj_mesh_vertex_buffer& other) : obj_mesh_vertex_buffer(other) { +#endif + +} + +void obj_mesh_vertex_buffer_divagl::cycle_index() { if (++index >= count) index = 0; } -GLuint obj_mesh_vertex_buffer::get_buffer() { +GLuint obj_mesh_vertex_buffer_divagl::get_buffer() { if (index < count) return buffers[index]; return 0; } -size_t obj_mesh_vertex_buffer::get_offset() { +size_t obj_mesh_vertex_buffer_divagl::get_offset() { #if SHARED_OBJECT_BUFFER if (buffers[0]) return offset; @@ -232,7 +197,7 @@ size_t obj_mesh_vertex_buffer::get_offset() { #endif } -GLsizeiptr obj_mesh_vertex_buffer::get_size() { +GLsizeiptr obj_mesh_vertex_buffer_divagl::get_size() { #if SHARED_OBJECT_BUFFER if (buffers[0]) return size; @@ -250,7 +215,7 @@ GLsizeiptr obj_mesh_vertex_buffer::get_size() { return 0; } -bool obj_mesh_vertex_buffer::load(obj_mesh* mesh, bool dynamic) { +bool obj_mesh_vertex_buffer_divagl::load(obj_mesh* mesh, bool dynamic) { if (!mesh->num_vertex) return false; @@ -271,7 +236,7 @@ bool obj_mesh_vertex_buffer::load(obj_mesh* mesh, bool dynamic) { mesh->size_vertex = size_vertex; void* vertex = force_malloc((size_t)size_vertex * mesh->num_vertex); - obj_mesh_vertex_buffer::fill_data(vertex, mesh); + obj_mesh_vertex_buffer_divagl::fill_data(vertex, mesh); bool ret = load_data((size_t)size_vertex * mesh->num_vertex, vertex, mesh->attrib.m.double_buffer ? 2 : 1, dynamic); @@ -279,7 +244,7 @@ bool obj_mesh_vertex_buffer::load(obj_mesh* mesh, bool dynamic) { return ret; } -bool obj_mesh_vertex_buffer::load_data(size_t size, const void* data, int32_t count, bool dynamic) { +bool obj_mesh_vertex_buffer_divagl::load_data(size_t size, const void* data, int32_t count, bool dynamic) { if (!size || count > 3) return false; @@ -295,7 +260,7 @@ bool obj_mesh_vertex_buffer::load_data(size_t size, const void* data, int32_t co return true; } -void obj_mesh_vertex_buffer::unload() { +void obj_mesh_vertex_buffer_divagl::unload() { for (int32_t i = 0; i < count; i++) { free_vertex_buffer(buffers[i]); buffers[i] = 0; @@ -306,7 +271,7 @@ void obj_mesh_vertex_buffer::unload() { index = 0; } -void* obj_mesh_vertex_buffer::fill_data(void* data, obj_mesh* mesh) { +void* obj_mesh_vertex_buffer_divagl::fill_data(void* data, obj_mesh* mesh) { obj_vertex_format vertex_format = mesh->vertex_format; obj_mesh_vertex_array vtx = mesh->vertex_array; uint32_t size_vertex = mesh->size_vertex; @@ -693,7 +658,7 @@ void* obj_mesh_vertex_buffer::fill_data(void* data, obj_mesh* mesh) { return (void*)((size_t)data + (size_t)size_vertex * num_vertex); } -#if SHARED_OBJECT_BUFFER +/*#if SHARED_OBJECT_BUFFER void obj_mesh_vertex_buffer_aft::cycle_index() { if (++index >= count) index = 0; @@ -705,19 +670,7 @@ GLuint obj_mesh_vertex_buffer_aft::get_buffer() { return 0; } -GLsizeiptr obj_mesh_vertex_buffer_aft::get_size() { - if (buffers[0]) { - GLint buffer; - GLint size; - glGetIntegervDLL(GL_ARRAY_BUFFER_BINDING, &buffer); - gl_state_bind_array_buffer(buffers[0]); - glGetBufferParameteriv(target, GL_BUFFER_SIZE, &size); - gl_state_bind_array_buffer(buffer); - return size; - } - return 0; -} -#endif +#endif*/ #if SHARED_OBJECT_BUFFER obj_index_buffer::obj_index_buffer() : mesh_num(), mesh_data(), buffer() { @@ -732,7 +685,7 @@ bool obj_index_buffer::load(obj* obj) { return false; mesh_num = obj->num_mesh; - mesh_data = new obj_mesh_index_buffer[obj->num_mesh]; + mesh_data = new obj_mesh_index_buffer_divagl[obj->num_mesh]; if (!mesh_data) return false; @@ -756,7 +709,7 @@ bool obj_index_buffer::load(obj* obj) { void* data = index; for (int32_t i = 0; i < mesh_num; i++) { uint32_t offset = (uint32_t)((size_t)data - (size_t)index); - data = obj_mesh_index_buffer::fill_data(data, &obj->mesh_array[i]); + data = obj_mesh_index_buffer_divagl::fill_data(data, &obj->mesh_array[i]); obj_mesh& mesh = obj->mesh_array[i]; for (int32_t j = 0; j < mesh.num_submesh; j++) @@ -813,7 +766,7 @@ bool obj_vertex_buffer::load(obj* obj) { return false; mesh_num = obj->num_mesh; - mesh_data = new obj_mesh_vertex_buffer[obj->num_mesh]; + mesh_data = new obj_mesh_vertex_buffer_divagl[obj->num_mesh]; if (!mesh_data) return false; @@ -858,12 +811,12 @@ bool obj_vertex_buffer::load(obj* obj) { void* data = vertex; for (int32_t i = 0; i < mesh_num; i++) { - obj_mesh_vertex_buffer& mesh_buffer = mesh_data[i]; + obj_mesh_vertex_buffer_divagl& mesh_buffer = mesh_data[i]; mesh_buffer.offset = (size_t)data - (size_t)vertex; mesh_buffer.count = count; mesh_buffer.size = (GLsizeiptr)buffer_size; - data = obj_mesh_vertex_buffer::fill_data(data, &obj->mesh_array[i]); + data = obj_mesh_vertex_buffer_divagl::fill_data(data, &obj->mesh_array[i]); } for (int32_t i = 0; i < count; i++) { @@ -905,75 +858,7 @@ void obj_vertex_buffer::unload() { #endif } -inline int32_t obj_material_texture_type_get_texcoord_index( - obj_material_texture_type type, int32_t index) { - switch (type) { - case OBJ_MATERIAL_TEXTURE_COLOR: - if (index < 2) - return index; - case OBJ_MATERIAL_TEXTURE_NORMAL: - case OBJ_MATERIAL_TEXTURE_SPECULAR: - return 0; - case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY: - case OBJ_MATERIAL_TEXTURE_TRANSPARENCY: - return 1; - } - return -1; -} - -inline int32_t obj_material_texture_type_get_texture_index( - obj_material_texture_type type, int32_t base_index) { - switch (type) { - case OBJ_MATERIAL_TEXTURE_COLOR: - if (base_index < 2) - return base_index; - case OBJ_MATERIAL_TEXTURE_NORMAL: - return 2; - case OBJ_MATERIAL_TEXTURE_SPECULAR: - return 3; - case OBJ_MATERIAL_TEXTURE_TRANSLUCENCY: - return 1; - case OBJ_MATERIAL_TEXTURE_TRANSPARENCY: - return 4; - case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE: // AFT - case OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE: - return 5; - } - return -1; -} - -void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices, - mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4& global_mat) { - if (!s->num_bone) - return; - - uint32_t* bone_id = s->bone_id_array; - mat4* bone_matrix = s->bone_matrix_array; - if (mat) - for (int32_t i = 0; i < s->num_bone; i++, bone_id++, bone_matrix++, matrix_buffer++) { - mat4 temp; - if (*bone_id & 0x8000) - mat4_mul(&ex_data_matrices[*bone_id & 0x7FFF], mat, &temp); - else - mat4_mul(&matrices[*bone_id], mat, &temp); - - mat4_mul(&global_mat, &temp, &temp); - mat4_mul(&temp, bone_matrix, matrix_buffer); - } - else - for (int32_t i = 0; i < s->num_bone; i++, bone_id++, bone_matrix++, matrix_buffer++) { - mat4 temp; - if (*bone_id & 0x8000) - temp = ex_data_matrices[*bone_id & 0x7FFF]; - else - temp = matrices[*bone_id]; - - mat4_mul(&global_mat, &temp, &temp); - mat4_mul(&temp, bone_matrix, matrix_buffer); - } -} - -HOOK(bool, FASTCALL, obj_mesh_vertex_buffer__load, 0x0000000140458280, obj_mesh_vertex_buffer* objvb, obj_mesh* mesh) { +HOOK(bool, FASTCALL, obj_mesh_vertex_buffer__load, 0x0000000140458280, obj_mesh_vertex_buffer_divagl* objvb, obj_mesh* mesh) { return objvb->load(mesh, true); } @@ -1211,7 +1096,7 @@ HOOK(bool, FASTCALL, _objset_info_storage_load_obj_set_check_not_read, 0x0000000 return ret; } -HOOK(void, FASTCALL, obj_mesh_vertex_buffer__unload, 0x0000000140461870, obj_mesh_vertex_buffer* objvb) { +HOOK(void, FASTCALL, obj_mesh_vertex_buffer__unload, 0x0000000140461870, obj_mesh_vertex_buffer_divagl* objvb) { objvb->unload(); } diff --git a/src/DivaGL/object.hpp b/src/DivaGL/object.hpp index c987651..f396bcc 100644 --- a/src/DivaGL/object.hpp +++ b/src/DivaGL/object.hpp @@ -8,502 +8,15 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/object.hpp" +#include "../AFTModsShared/types.hpp" #include "texture.hpp" -#include "types.hpp" #define SHARED_OBJECT_BUFFER (1) -enum obj_index_format : uint32_t { - OBJ_INDEX_U8 = 0x00, - OBJ_INDEX_U16 = 0x01, - OBJ_INDEX_U32 = 0x02, -}; - -enum obj_material_aniso_direction : uint32_t { - OBJ_MATERIAL_ANISO_DIRECTION_NORMAL = 0, - OBJ_MATERIAL_ANISO_DIRECTION_U = 1, - OBJ_MATERIAL_ANISO_DIRECTION_V = 2, - OBJ_MATERIAL_ANISO_DIRECTION_RADIAL = 3, -}; - -enum obj_material_blend_factor : uint32_t { - OBJ_MATERIAL_BLEND_ZERO = 0, - OBJ_MATERIAL_BLEND_ONE = 1, - OBJ_MATERIAL_BLEND_SRC_COLOR = 2, - OBJ_MATERIAL_BLEND_INVERSE_SRC_COLOR = 3, - OBJ_MATERIAL_BLEND_SRC_ALPHA = 4, - OBJ_MATERIAL_BLEND_INVERSE_SRC_ALPHA = 5, - OBJ_MATERIAL_BLEND_DST_ALPHA = 6, - OBJ_MATERIAL_BLEND_INVERSE_DST_ALPHA = 7, - OBJ_MATERIAL_BLEND_DST_COLOR = 8, - OBJ_MATERIAL_BLEND_INVERSE_DST_COLOR = 9, - OBJ_MATERIAL_BLEND_ALPHA_SATURATE = 10, -}; - -enum obj_material_bump_map_type : uint32_t { - OBJ_MATERIAL_BUMP_MAP_NONE = 0, - OBJ_MATERIAL_BUMP_MAP_DOT = 1, - OBJ_MATERIAL_BUMP_MAP_ENV = 2, -}; - -enum obj_material_color_source_type : uint32_t { - OBJ_MATERIAL_COLOR_SOURCE_MATERIAL_COLOR = 0, - OBJ_MATERIAL_COLOR_SOURCE_VERTEX_COLOR = 1, - OBJ_MATERIAL_COLOR_SOURCE_VERTEX_MORPH = 2, -}; - -enum obj_material_shader_lighting_type : uint32_t { - OBJ_MATERIAL_SHADER_LIGHTING_LAMBERT = 0x00, - OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT = 0x01, - OBJ_MATERIAL_SHADER_LIGHTING_PHONG = 0x02, -}; - -enum obj_material_specular_quality : uint32_t { - OBJ_MATERIAL_SPECULAR_QUALITY_LOW = 0, - OBJ_MATERIAL_SPECULAR_QUALITY_HIGH = 1, -}; - -enum obj_material_texture_type : uint32_t { - OBJ_MATERIAL_TEXTURE_NONE = 0x00, - OBJ_MATERIAL_TEXTURE_COLOR = 0x01, - OBJ_MATERIAL_TEXTURE_NORMAL = 0x02, - OBJ_MATERIAL_TEXTURE_SPECULAR = 0x03, - OBJ_MATERIAL_TEXTURE_HEIGHT = 0x04, - OBJ_MATERIAL_TEXTURE_REFLECTION = 0x05, - OBJ_MATERIAL_TEXTURE_TRANSLUCENCY = 0x06, - OBJ_MATERIAL_TEXTURE_TRANSPARENCY = 0x07, - OBJ_MATERIAL_TEXTURE_ENVIRONMENT_SPHERE = 0x08, - OBJ_MATERIAL_TEXTURE_ENVIRONMENT_CUBE = 0x09, -}; - -enum obj_material_texture_coordinate_translation_type : uint32_t { - OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_NONE = 0x00, - OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_UV = 0x01, - OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_SPHERE = 0x02, - OBJ_MATERIAL_TEXTURE_COORDINATE_TRANSLATION_CUBE = 0x03, -}; - -enum obj_material_vertex_translation_type : uint32_t { - OBJ_MATERIAL_VERTEX_TRANSLATION_DEFAULT = 0, - OBJ_MATERIAL_VERTEX_TRANSLATION_ENVELOPE = 1, - OBJ_MATERIAL_VERTEX_TRANSLATION_MORPHING = 2, -}; - -enum obj_primitive_type : uint32_t { - OBJ_PRIMITIVE_POINTS = 0x00, - OBJ_PRIMITIVE_LINES = 0x01, - OBJ_PRIMITIVE_LINE_STRIP = 0x02, - OBJ_PRIMITIVE_LINE_LOOP = 0x03, - OBJ_PRIMITIVE_TRIANGLES = 0x04, - OBJ_PRIMITIVE_TRIANGLE_STRIP = 0x05, - OBJ_PRIMITIVE_TRIANGLE_FAN = 0x06, - OBJ_PRIMITIVE_QUADS = 0x07, - OBJ_PRIMITIVE_QUAD_STRIP = 0x08, - OBJ_PRIMITIVE_POLYGON = 0x09, -}; - -enum obj_vertex_format : uint32_t { - OBJ_VERTEX_NONE = 0x0000, - OBJ_VERTEX_POSITION = 0x0001, - OBJ_VERTEX_NORMAL = 0x0002, - OBJ_VERTEX_TANGENT = 0x0004, - OBJ_VERTEX_BINORMAL = 0x0008, - OBJ_VERTEX_TEXCOORD0 = 0x0010, - OBJ_VERTEX_TEXCOORD1 = 0x0020, - OBJ_VERTEX_TEXCOORD2 = 0x0040, - OBJ_VERTEX_TEXCOORD3 = 0x0080, - OBJ_VERTEX_COLOR0 = 0x0100, - OBJ_VERTEX_COLOR1 = 0x0200, - OBJ_VERTEX_BONE_WEIGHT = 0x0400, - OBJ_VERTEX_BONE_INDEX = 0x0800, - OBJ_VERTEX_BONE_DATA = 0x0C00, - OBJ_VERTEX_UNKNOWN = 0x1000, -}; - -struct obj_axis_aligned_bounding_box { - vec3 center; - vec3 size; -}; - -struct obj_bounding_box { - vec3 center; - vec3 size; -}; - -struct obj_bounding_sphere { - vec3 center; - float_t radius; -}; - -struct obj_shader_compo_member { - uint32_t color : 1; - uint32_t color_a : 1; - uint32_t color_l1 : 1; - uint32_t color_l1_a : 1; - uint32_t color_l2 : 1; - uint32_t color_l2_a : 1; - uint32_t transparency : 1; - uint32_t specular : 1; - uint32_t normal_01 : 1; - uint32_t normal_02 : 1; - uint32_t envmap : 1; - uint32_t color_l3 : 1; - uint32_t color_l3_a : 1; - uint32_t translucency : 1; - uint32_t flag_14 : 1; - uint32_t override_ibl : 1; - uint32_t dummy : 16; -}; - -union obj_shader_compo { - obj_shader_compo_member m; - uint32_t w; -}; - -struct obj_material_shader_attrib_member { - obj_material_vertex_translation_type vtx_trans_type : 2; - obj_material_color_source_type col_src : 2; - uint32_t is_lgt_diffuse : 1; - uint32_t is_lgt_specular : 1; - uint32_t is_lgt_per_pixel : 1; - uint32_t is_lgt_double : 1; - obj_material_bump_map_type bump_map_type : 2; - uint32_t fresnel_type : 4; - uint32_t line_light : 4; - uint32_t recieve_shadow : 1; - uint32_t cast_shadow : 1; - obj_material_specular_quality specular_quality : 1; - obj_material_aniso_direction aniso_direction : 2; - uint32_t dummy : 9; -}; - -union obj_material_shader_attrib { - obj_material_shader_attrib_member m; - uint32_t w; - - obj_material_shader_lighting_type get_lighting_type() const; -}; - -struct obj_texture_attrib_member { - uint32_t repeat_u : 1; - uint32_t repeat_v : 1; - uint32_t mirror_u : 1; - uint32_t mirror_v : 1; - uint32_t ignore_alpha : 1; - uint32_t blend : 5; - uint32_t alpha_blend : 5; - uint32_t border : 1; - uint32_t clamp2edge : 1; - uint32_t filter : 3; - uint32_t mipmap : 2; - uint32_t mipmap_bias : 7; - uint32_t flag_29 : 1; - uint32_t anisotropic_filter : 2; -}; - -union obj_texture_attrib { - obj_texture_attrib_member m; - uint32_t w; - - int32_t get_blend() const; -}; - -struct obj_texture_shader_attrib_member { - obj_material_texture_type tex_type : 4; - int32_t uv_idx : 4; - obj_material_texture_coordinate_translation_type texcoord_trans : 3; - uint32_t dummy : 21; -}; - -union obj_texture_shader_attrib { - obj_texture_shader_attrib_member m; - uint32_t w; -}; - -struct obj_material_texture_data { - obj_texture_attrib attrib; - uint32_t tex_index; - obj_texture_shader_attrib shader_info; - char ex_shader[8]; - float_t weight; - mat4 tex_coord_mat; - uint32_t reserved[8]; -}; - -struct obj_material_attrib_member { - uint32_t alpha_texture : 1; - uint32_t alpha_material : 1; - uint32_t punch_through : 1; - uint32_t double_sided : 1; - uint32_t normal_dir_light : 1; - obj_material_blend_factor src_blend_factor : 4; - obj_material_blend_factor dst_blend_factor : 4; - uint32_t blend_operation : 3; - uint32_t zbias : 4; - uint32_t no_fog : 1; - uint32_t translucent_priority : 6; - uint32_t has_fog_height : 1; - uint32_t flag_28 : 1; - uint32_t fog_height : 1; - uint32_t flag_30 : 1; - uint32_t flag_31 : 1; -}; - -union obj_material_attrib { - obj_material_attrib_member m; - uint32_t w; -}; - -struct obj_material_color { - vec4 diffuse; - vec4 ambient; - vec4 specular; - vec4 emission; - float_t shininess; - float_t intensity; -}; - -struct obj_material { - obj_shader_compo shader_compo; - union { - char name[8]; - int32_t index; - } shader; - obj_material_shader_attrib shader_info; - obj_material_texture_data texdata[8]; - obj_material_attrib attrib; - obj_material_color color; - vec3 center; - float_t radius; - char name[64]; - float_t bump_depth; - uint32_t reserved[15]; -}; - -struct obj_material_data { - int32_t num_of_textures; - obj_material material; -}; - -struct obj_sub_mesh_attrib_member { - uint32_t recieve_shadow : 1; - uint32_t cast_shadow : 1; - uint32_t translucent : 1; - uint32_t cloth : 1; - uint32_t no_reflect : 1; // Own stuff - uint32_t reflect : 1; // Own stuff - uint32_t reflect_cam_back : 1; // Own stuff - uint32_t dummy : 25; // 28 -}; - -union obj_sub_mesh_attrib { - obj_sub_mesh_attrib_member m; - uint32_t w; -}; - -struct obj_sub_mesh { - uint32_t flags; - obj_bounding_sphere bounding_sphere; - uint32_t material_index; - uint8_t uv_index[8]; - int32_t num_bone_index; - uint16_t* bone_index_array; - uint32_t bones_per_vertex; - obj_primitive_type primitive_type; - obj_index_format index_format; - int32_t num_index; - void* index_array; - obj_sub_mesh_attrib attrib; - uint32_t reserved[4]; - obj_axis_aligned_bounding_box* axis_aligned_bounding_box; - uint16_t first_index; - uint16_t last_index; - uint32_t index_offset; -}; - -static_assert(sizeof(obj_sub_mesh) == 0x70, "\"obj_sub_mesh\" struct should have a size of 0x70"); - -struct obj_mesh_attrib_member { - uint32_t double_buffer : 1; - uint32_t billboard_y_axis : 1; - uint32_t translucent_sort_by_radius : 1; - uint32_t billboard : 1; - uint32_t no_reflect : 1; // Own stuff - uint32_t reflect : 1; // Own stuff - uint32_t reflect_cam_back : 1; // Own stuff - uint32_t disable_aabb_culling : 1; // Own stuff - uint32_t dummy : 22; // 28 - uint32_t compression : 2; // Own stuff -}; - -union obj_mesh_attrib { - obj_mesh_attrib_member m; - uint32_t w; -}; - -struct obj_mesh_vertex_array { - vec3* position; - vec3* normal; - vec4* tangent; - vec3* binormal; - vec2* texcoord0; - vec2* texcoord1; - vec2* texcoord2; - vec2* texcoord3; - vec4* color0; - vec4* color1; - vec4* bone_weight; - vec4* bone_index; - vec4* unknown; - void* field_68; - void* field_70; - void* field_78; - void* field_80; - void* field_88; - void* field_90; - void* field_98; -}; - -static_assert(sizeof(obj_mesh_vertex_array) == 0xA0, "\"obj_mesh_vertex_array\" struct should have a size of 0xA0"); - -struct obj_mesh { - uint32_t flags; - obj_bounding_sphere bounding_sphere; - int32_t num_submesh; - obj_sub_mesh* submesh_array; - obj_vertex_format vertex_format; - uint32_t size_vertex; - int32_t num_vertex; - union { - obj_mesh_vertex_array vertex_array; - void* vertex_array_ptr[20]; - }; - obj_mesh_attrib attrib; - uint32_t vertex_flags; - uint32_t reserved[6]; - char name[0x40]; -}; - -static_assert(sizeof(obj_mesh) == 0x130, "\"obj_mesh\" struct should have a size of 0x130"); - -struct obj { - uint32_t version; - uint32_t flags; - obj_bounding_sphere bounding_sphere; - int32_t num_mesh; - obj_mesh* mesh_array; - int32_t num_material; - obj_material_data* material_array; - uint32_t reserved[10]; -}; - -static_assert(sizeof(obj) == 0x60, "\"obj\" struct should have a size of 0x60"); - -struct obj_skin_ex_data { - int32_t num_osage_name; - int32_t num_osage_node; - const char** field_8; - struct obj_skin_osage_node* osage_node_array; - const char** osage_name_array; - struct obj_skin_block* block_array; - int32_t num_bone_name; - const char** bone_name_array; - struct obj_skin_osage_sibling_info* osage_sibling_infos; - uint32_t cloth_count; - uint32_t reserved[7]; -}; - -static_assert(sizeof(obj_skin_ex_data) == 0x60, "\"obj_skin_ex_data\" struct should have a size of 0x60"); - -struct obj_skin { - uint32_t* bone_id_array; - mat4* bone_matrix_array; - const char** bone_name_array; - obj_skin_ex_data* ex_data; - int32_t num_bone; - int32_t bone_parent_ids_offset; - int32_t field_28; - int32_t field_2C; - int32_t field_30; -}; - -static_assert(sizeof(obj_skin) == 0x38, "\"obj_skin\" struct should have a size of 0x38"); - -struct obj_set { - uint32_t version; - int32_t obj_num; - uint32_t last_obj_id; - obj** obj_data; - obj_skin** obj_skin_data; - const char** obj_name_data; - uint32_t* obj_id_data; - uint32_t* tex_id_data; - int32_t tex_num; - uint32_t reserved[2]; -}; - -static_assert(sizeof(obj_set) == 0x48, "\"obj_set\" struct should have a size of 0x48"); - -struct object_info { - uint16_t id; - uint16_t set_id; - - inline object_info() { - this->id = (uint16_t)-1; - this->set_id = (uint16_t)-1; - } - - inline object_info(uint16_t id, uint16_t set_id) { - this->id = id; - this->set_id = set_id; - } - - inline object_info(uint32_t data) { - this->id = (uint16_t)data; - this->set_id = (uint16_t)(data >> 16); - } - - inline bool is_null() const { - return id == (uint16_t)-1 && set_id == (uint16_t)-1; - } - - inline bool not_null() const { - return id != (uint16_t)-1 || set_id != (uint16_t)-1; - } - - inline operator uint32_t() { - return ((uint32_t)set_id << 16) | id; - } -}; - -inline bool operator >(const object_info& left, const object_info& right) { - return *(uint32_t*)&left > *(uint32_t*)&right; -} - -inline bool operator <(const object_info& left, const object_info& right) { - return *(uint32_t*)&left < *(uint32_t*)&right; -} - -inline bool operator >=(const object_info& left, const object_info& right) { - return *(uint32_t*)&left >= *(uint32_t*)&right; -} - -inline bool operator <=(const object_info& left, const object_info& right) { - return *(uint32_t*)&left <= *(uint32_t*)&right; -} - -inline bool operator ==(const object_info& left, const object_info& right) { - return *(uint32_t*)&left == *(uint32_t*)&right; -} - -inline bool operator !=(const object_info& left, const object_info& right) { - return *(uint32_t*)&left != *(uint32_t*)&right; -} - -struct obj_mesh_index_buffer { - GLuint buffer; - - obj_mesh_index_buffer(); +struct obj_mesh_index_buffer_divagl : obj_mesh_index_buffer { + obj_mesh_index_buffer_divagl(); + obj_mesh_index_buffer_divagl(const obj_mesh_index_buffer& other); bool load(obj_mesh* mesh); bool load_data(size_t size, const void* data); @@ -512,22 +25,14 @@ struct obj_mesh_index_buffer { static void* fill_data(void* data, obj_mesh* mesh); }; -#if !SHARED_OBJECT_BUFFER -static_assert(sizeof(obj_mesh_index_buffer) == 0x04, "\"obj_mesh_index_buffer\" struct should have a size of 0x04"); -#endif - -struct obj_mesh_vertex_buffer { - int32_t count; - GLuint buffers[3]; - int32_t index; +struct obj_mesh_vertex_buffer_divagl : obj_mesh_vertex_buffer { #if SHARED_OBJECT_BUFFER GLsizeiptr size; size_t offset; -#else - GLenum target; #endif - obj_mesh_vertex_buffer(); + obj_mesh_vertex_buffer_divagl(); + obj_mesh_vertex_buffer_divagl(const obj_mesh_vertex_buffer& other); void cycle_index(); GLuint get_buffer(); @@ -540,28 +45,9 @@ struct obj_mesh_vertex_buffer { static void* fill_data(void* data, obj_mesh* mesh); }; -#if SHARED_OBJECT_BUFFER -struct obj_mesh_vertex_buffer_aft { - int32_t count; - GLuint buffers[3]; - int32_t index; - GLenum target; - - void cycle_index(); - GLuint get_buffer(); - GLsizeiptr get_size(); -}; -#endif - -#if SHARED_OBJECT_BUFFER -static_assert(sizeof(obj_mesh_vertex_buffer_aft) == 0x18, "\"obj_mesh_vertex_buffer_aft\" struct should have a size of 0x18"); -#else -static_assert(sizeof(obj_mesh_vertex_buffer) == 0x18, "\"obj_mesh_vertex_buffer\" struct should have a size of 0x18"); -#endif - struct obj_index_buffer { int32_t mesh_num; - obj_mesh_index_buffer* mesh_data; + obj_mesh_index_buffer_divagl* mesh_data; #if SHARED_OBJECT_BUFFER GLuint buffer; #endif @@ -578,7 +64,7 @@ static_assert(sizeof(obj_index_buffer) == 0x10, "\"obj_index_buffer\" struct sho struct obj_vertex_buffer { int32_t mesh_num; - obj_mesh_vertex_buffer* mesh_data; + obj_mesh_vertex_buffer_divagl* mesh_data; #if SHARED_OBJECT_BUFFER GLuint buffers[3]; #endif @@ -593,31 +79,9 @@ struct obj_vertex_buffer { static_assert(sizeof(obj_vertex_buffer) == 0x10, "\"obj_vertex_buffer\" struct should have a size of 0x10"); #endif -extern void (FASTCALL* objset_info_storage_unload_set)(int32_t set); -extern obj_mesh* (FASTCALL* objset_info_storage_get_obj_mesh_by_index)(uint32_t obj_info, int32_t mesh_index); -extern int32_t(FASTCALL* objset_info_storage_get_obj_mesh_index)(uint32_t obj_info, const char* mesh_name); -extern const char* (FASTCALL* object_database_get_obj_name)(uint32_t obj_info); -extern uint32_t(FASTCALL* object_database_get_object_info)(const char* name); -extern obj* (FASTCALL* objset_info_storage_get_obj)(uint32_t obj_info); extern obj_mesh_index_buffer* (FASTCALL* objset_info_storage_get_obj_mesh_index_buffer)(uint32_t obj_info, int32_t a2); -extern obj_skin* (FASTCALL* objset_info_storage_get_obj_skin)(uint32_t obj_info); extern obj_mesh_vertex_buffer* (FASTCALL* objset_info_storage_get_obj_mesh_vertex_buffer)(uint32_t obj_info, int32_t a2); -extern int32_t(FASTCALL* objset_info_storage_get_set_obj_id)(int32_t set_index, int32_t obj_index); extern GLuint(FASTCALL* objset_info_storage_get_set_texture)(int32_t set, int32_t tex_id); extern prj::vector* (FASTCALL* objset_info_storage_get_set_gentex)(int32_t set); -extern int32_t(FASTCALL* object_database_get_set_id)(int32_t set_index); -extern int32_t(FASTCALL* object_database_get_object_set_id)(const char* name); -extern int32_t(FASTCALL* objset_info_storage_get_set_tex_num)(int32_t set); -extern texture** (FASTCALL* objset_info_storage_get_set_textures)(int32_t set); -extern int32_t(FASTCALL* objset_info_storage_load_set)(int32_t set); -extern bool (FASTCALL* objset_info_storage_load_obj_set_check_not_read)(int32_t set); - -extern int32_t obj_material_texture_type_get_texcoord_index( - obj_material_texture_type type, int32_t index); -extern int32_t obj_material_texture_type_get_texture_index( - obj_material_texture_type type, int32_t base_index); - -extern void obj_skin_set_matrix_buffer(obj_skin* s, mat4* matrices, - mat4* ex_data_matrices, mat4* matrix_buffer, const mat4* mat, const mat4& global_mat); extern void object_patch(); diff --git a/src/DivaGL/pv_game/dsc.hpp b/src/DivaGL/pv_game/dsc.hpp index 0ca2d3d..ccdd068 100644 --- a/src/DivaGL/pv_game/dsc.hpp +++ b/src/DivaGL/pv_game/dsc.hpp @@ -5,7 +5,7 @@ #pragma once -#include "../types.hpp" +#include "../../AFTModsShared/types.hpp" struct dsc_data { int32_t func; diff --git a/src/DivaGL/pv_game/firstread.hpp b/src/DivaGL/pv_game/firstread.hpp index da5f4a1..27240fc 100644 --- a/src/DivaGL/pv_game/firstread.hpp +++ b/src/DivaGL/pv_game/firstread.hpp @@ -6,9 +6,9 @@ #pragma once #include "../../KKdLib/vec.hpp" +#include "../../AFTModsShared/types.hpp" #include "../object.hpp" #include "../stage.hpp" -#include "../types.hpp" struct firstread_str_array_string { int32_t id; diff --git a/src/DivaGL/pv_game/pv_game.cpp b/src/DivaGL/pv_game/pv_game.cpp index 04fff6c..116ec24 100644 --- a/src/DivaGL/pv_game/pv_game.cpp +++ b/src/DivaGL/pv_game/pv_game.cpp @@ -5,11 +5,12 @@ #include "pv_game.hpp" #include "../../KKdLib/io/memory_stream.hpp" +#include "../../AFTModsShared/auth_2d.hpp" +#include "../../AFTModsShared/print_work.hpp" #include "../Glitter/glitter.hpp" #include "../rob/rob.hpp" -#include "../auth_2d.hpp" #include "../auth_3d.hpp" -#include "../print_work.hpp" +#include "../render_texture.hpp" #include "dsc.hpp" #include "firstread.hpp" #include "pvpp.hpp" diff --git a/src/DivaGL/pv_game/pvpp.hpp b/src/DivaGL/pv_game/pvpp.hpp index c0e5da2..a9e1927 100644 --- a/src/DivaGL/pv_game/pvpp.hpp +++ b/src/DivaGL/pv_game/pvpp.hpp @@ -6,7 +6,7 @@ #pragma once #include "../../KKdLib/vec.hpp" -#include "../types.hpp" +#include "../../AFTModsShared/types.hpp" enum pvpp_chara_id : int8_t { PVPP_CHARA_PNONE = -1, diff --git a/src/DivaGL/pv_game/pvsr.hpp b/src/DivaGL/pv_game/pvsr.hpp index a8208cb..59deb44 100644 --- a/src/DivaGL/pv_game/pvsr.hpp +++ b/src/DivaGL/pv_game/pvsr.hpp @@ -5,7 +5,7 @@ #pragma once -#include "../types.hpp" +#include "../../AFTModsShared/types.hpp" enum pvsr_auth_3d_flags : uint8_t { PVSR_AUTH_3D_REPEAT = 0x01, diff --git a/src/DivaGL/render_context.cpp b/src/DivaGL/render_context.cpp index 7d1c95f..d3193a1 100644 --- a/src/DivaGL/render_context.cpp +++ b/src/DivaGL/render_context.cpp @@ -6,7 +6,7 @@ #include "render_context.hpp" #include "render_manager.hpp" #include "shader_ft.hpp" -#include "uniform.hpp" +#include "../AFTModsShared/uniform.hpp" draw_state_struct& draw_state = *(draw_state_struct*)0x00000001411A32B0; diff --git a/src/DivaGL/render_context.hpp b/src/DivaGL/render_context.hpp index c4237f8..d0476ee 100644 --- a/src/DivaGL/render_context.hpp +++ b/src/DivaGL/render_context.hpp @@ -8,11 +8,11 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/light_param/fog.hpp" +#include "../AFTModsShared/light_param/light.hpp" #include "GL/array_buffer.hpp" #include "GL/shader_storage_buffer.hpp" #include "GL/uniform_buffer.hpp" -#include "light_param/fog.hpp" -#include "light_param/light.hpp" #include "mdl/disp_manager.hpp" #include "camera.hpp" #include "render.hpp" diff --git a/src/DivaGL/render_manager.cpp b/src/DivaGL/render_manager.cpp index 9152e46..138aba0 100644 --- a/src/DivaGL/render_manager.cpp +++ b/src/DivaGL/render_manager.cpp @@ -5,9 +5,9 @@ #include "render_manager.hpp" #include "../KKdLib/mat.hpp" +#include "../AFTModsShared/light_param/fog.hpp" +#include "../AFTModsShared/light_param/light.hpp" #include "Glitter/glitter.hpp" -#include "light_param/fog.hpp" -#include "light_param/light.hpp" #include "mdl/disp_manager.hpp" #include "mdl/draw_object.hpp" #include "rob/rob.hpp" @@ -24,6 +24,12 @@ #include "texture.hpp" #include +struct light_data_color { + vec4 ambient; + vec4 diffuse; + vec4 specular; +}; + struct reflect_full_struct { RenderTexture reflect_texture; RenderTexture reflect_buffer_texture; @@ -75,6 +81,13 @@ static bool draw_pass_reflect_get_obj_reflect_surface(mdl::ObjType type); static void blur_filter_apply(RenderTexture* dst, RenderTexture* src, blur_filter_mode filter, const vec2 res_scale, const vec4 scale, const vec4 offset); +static void fog_set(fog_id id); + +static void light_get_direction_from_position(vec4* pos_dir, const light_data* light, bool force = false); +static void light_get_light_color(const light_data* light, light_data_color& value, light_id id); + +static void lighting_set(light_set_id set_id); + static void render_manager_free_render_textures(); static void render_manager_init_render_textures(int32_t multisample); @@ -376,7 +389,7 @@ namespace rndr { draw_pass_set_camera(); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); disp_manager->draw(mdl::OBJ_TYPE_OPAQUE); disp_manager->draw(mdl::OBJ_TYPE_TRANSPARENT); @@ -472,7 +485,7 @@ namespace rndr { draw_pass_set_camera(); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); if (shadow) draw_pass_3d_shadow_set(shadow_ptr); @@ -559,7 +572,7 @@ namespace rndr { draw_pass_set_camera(); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); if (shadow) draw_pass_3d_shadow_set(shadow_ptr); @@ -653,9 +666,9 @@ namespace rndr { draw_pass_set_camera(); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); for (int32_t i = FOG_DEPTH; i < FOG_BUMP; i++) - fog_data[i].data_set((fog_id)i); + fog_set((fog_id)i); glClearColorDLL(0.0f, 0.0f, 0.0f, 0.0f); glClearDLL(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -720,9 +733,9 @@ namespace rndr { draw_pass_set_camera(); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); for (int32_t i = FOG_DEPTH; i < FOG_BUMP; i++) - fog_data[i].data_set((fog_id)i); + fog_set((fog_id)i); vec4 clear_color; glGetFloatvDLL(GL_COLOR_CLEAR_VALUE, (GLfloat*)&clear_color); @@ -848,9 +861,9 @@ namespace rndr { gl_state_set_depth_func(GL_LEQUAL); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); for (int32_t i = FOG_DEPTH; i < FOG_MAX; i++) - fog_data[i].data_set((fog_id)i); + fog_set((fog_id)i); if (shadow) draw_pass_3d_shadow_set(shadow_ptr); @@ -2061,9 +2074,9 @@ static void draw_pass_reflect_full(rndr::RenderManager& render_manager) { gl_state_set_depth_func(GL_LEQUAL); for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++) - light_set_data[i].data_set((light_set_id)i); + lighting_set((light_set_id)i); for (int32_t i = FOG_DEPTH; i < FOG_MAX; i++) - fog_data[i].data_set((fog_id)i); + fog_set((fog_id)i); glClearColorDLL(0.0f, 0.0f, 0.0f, 0.0f); if (disp_manager->get_obj_count(mdl::OBJ_TYPE_SSS)) @@ -2272,6 +2285,290 @@ static void blur_filter_apply(RenderTexture* dst, RenderTexture* src, gl_state_end_event(); } +static void fog_set(fog_id id) { + fog* f = &fog_data[id]; + fog_type type = f->get_type(); + if (type == FOG_NONE) + return; + + float_t density = f->get_density(); + float_t start = f->get_start(); + float_t end = f->get_end(); + if (start >= end) + start = end - 0.01f; + + vec4 params; + params.x = density; + params.y = start; + params.z = end; + params.w = 1.0f / (end - start); + + switch (id) { + case FOG_DEPTH: { + float_t density = f->get_density(); + float_t start = f->get_start(); + float_t end = f->get_end(); + if (start >= end) + start = end - 0.01f; + vec4 color; + f->get_color(color); + + render_context::fog_params params = {}; + rctx->get_scene_fog_params(params); + params.density = density; + params.start = start; + params.end = end; + params.depth_color = color; + rctx->set_scene_fog_params(params); + } break; + case FOG_HEIGHT: { + float_t density = f->get_density(); + float_t start = f->get_start(); + float_t end = f->get_end(); + if (start >= end) + start = end - 0.01f; + vec4 color; + f->get_color(color); + + render_context::fog_params params = {}; + rctx->get_scene_fog_params(params); + params.height_params.x = density; + params.height_params.y = start; + params.height_params.z = end; + params.height_params.w = 1.0f / (end - start); + params.height_color = color; + rctx->set_scene_fog_params(params); + } break; + case FOG_BUMP: { + float_t density = f->get_density(); + float_t start = f->get_start(); + float_t end = f->get_end(); + if (start >= end) + start = end - 0.01f; + + render_context::fog_params params = {}; + rctx->get_scene_fog_params(params); + params.bump_params.x = density; + params.bump_params.y = start; + params.bump_params.z = end; + params.bump_params.w = 1.0f / (end - start); + rctx->set_scene_fog_params(params); + } break; + } +} + +static void light_get_direction_from_position(vec4* pos_dir, const light_data* light, bool force) { + if (force || light->get_type() == LIGHT_PARALLEL) { + float_t length = vec3::length(*(vec3*)pos_dir); + if (length <= 0.000001) + *(vec3*)pos_dir = vec3(0.0f, 1.0f, 0.0f); + else + *(vec3*)pos_dir *= 1.0f / length; + pos_dir->w = 0.0f; + } +} + +static void light_get_light_color(const light_data* light, light_data_color& value, light_id id) { + static bool& light_chara_ambient = *(bool*)0x00000001411A0080; + if (id || light_chara_ambient) + value.ambient = light->ambient; + else + value.ambient = { 0.0f, 0.0f, 0.0f, 1.0f }; + + if (!id && false) + value.diffuse = light->diffuse * 4.0f; + else + value.diffuse = light->diffuse; + + value.specular = light->specular; +} + +static void lighting_set(light_set_id set_id) { + static const float_t spec_coef = (float_t)(1.0 / (1.0 - cos(18.0 * DEG_TO_RAD))); + static const float_t luce_coef = (float_t)(1.0 / (1.0 - cos(45.0 * DEG_TO_RAD))); + + const light_set* set = &light_set_data[set_id]; + + light_data_color light_color[LIGHT_MAX]; + for (int32_t i = 0; i < LIGHT_MAX; i++) + light_get_light_color(&set->lights[i], light_color[i], (light_id)i); + + vec4 light_env_stage_diffuse = light_color[LIGHT_STAGE].diffuse; + vec4 light_env_stage_specular = light_color[LIGHT_STAGE].specular; + + vec4 light_env_chara_diffuse = light_color[LIGHT_CHARA].diffuse; + vec4 light_env_chara_ambient = light_color[LIGHT_CHARA].ambient; + vec4 light_env_chara_specular = light_color[LIGHT_CHARA].specular; + + vec4 light_env_reflect_diffuse; + vec4 light_env_reflect_ambient; + set->lights[LIGHT_REFLECT].get_diffuse(light_env_reflect_diffuse); + set->lights[LIGHT_REFLECT].get_ambient(light_env_reflect_ambient); + + vec4 light_env_proj_diffuse; + vec4 light_env_proj_specular; + vec4 light_env_proj_position; + set->lights[LIGHT_PROJECTION].get_diffuse(light_env_proj_diffuse); + set->lights[LIGHT_PROJECTION].get_specular(light_env_proj_specular); + set->lights[LIGHT_PROJECTION].get_position(light_env_proj_position); + if (set->lights[LIGHT_PROJECTION].get_type() == LIGHT_PARALLEL) + light_get_direction_from_position(&light_env_proj_position, 0, true); + + vec4 light_chara_dir; + vec4 light_chara_ibl_color0; + vec4 light_chara_ibl_color1; + vec4 light_chara_specular; + set->lights[LIGHT_CHARA].get_position(light_chara_dir); + light_get_direction_from_position(&light_chara_dir, &set->lights[LIGHT_CHARA]); + set->lights[LIGHT_CHARA].get_ibl_color0(light_chara_ibl_color0); + set->lights[LIGHT_CHARA].get_ibl_color1(light_chara_ibl_color1); + set->lights[LIGHT_CHARA].get_specular(light_chara_specular); + + vec4 light_chara_spec = light_chara_specular * light_chara_ibl_color0 * spec_coef; + vec4 light_chara_luce = light_chara_ibl_color0 * luce_coef; + vec4 light_chara_back = light_chara_specular * light_chara_ibl_color1 * spec_coef; + + vec4 light_stage_dir; + vec4 light_stage_ibl_color; + vec4 light_stage_diffuse; + vec4 light_stage_specular; + set->lights[LIGHT_STAGE].get_position(light_stage_dir); + light_get_direction_from_position(&light_stage_dir, &set->lights[LIGHT_STAGE]); + set->lights[LIGHT_STAGE].get_ibl_color0(light_stage_ibl_color); + set->lights[LIGHT_STAGE].get_diffuse(light_stage_diffuse); + set->lights[LIGHT_STAGE].get_specular(light_stage_specular); + + vec4 light_stage_diff = light_stage_diffuse * light_stage_ibl_color; + vec4 light_stage_spec = light_stage_specular * light_stage_ibl_color * spec_coef; + + mat4 irradiance_r_transforms; + mat4 irradiance_g_transforms; + mat4 irradiance_b_transforms; + set->get_irradiance(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms); + + float_t* (FASTCALL * face_data_get)() = (float_t * (FASTCALL*)())0x00000001403D8310; + float_t v27 = face_data_get()[0]; + float_t v28 = (float_t)(1.0 - exp(v27 * -0.44999999)) * 2.0f; + v27 = max_def(v27, 0.0f); + vec4 light_face_diff = { v28 * 0.1f, v27 * 0.06f, 1.0f, 1.0f }; + + vec4 chara_color_rim; + vec4 chara_color0; + vec4 chara_color1; + if (set->lights[LIGHT_CHARA_COLOR].get_type() == LIGHT_PARALLEL) { + set->lights[LIGHT_CHARA_COLOR].get_ambient(chara_color_rim); + set->lights[LIGHT_CHARA_COLOR].get_diffuse(chara_color0); + set->lights[LIGHT_CHARA_COLOR].get_specular(chara_color1); + if (chara_color1.w > 1.0f) + chara_color1.w = 1.0f; + } + else { + chara_color_rim = 0.0f; + chara_color0 = 0.0f; + chara_color1 = 0.0f; + } + + vec4 chara_f_dir; + vec4 chara_f_ambient; + vec4 chara_f_diffuse; + vec4 chara_tc_param; + if (set->lights[LIGHT_TONE_CURVE].get_type() == LIGHT_PARALLEL) { + uniform->arr[U_TONE_CURVE] = 1; + set->lights[LIGHT_TONE_CURVE].get_position(chara_f_dir); + light_get_direction_from_position(&chara_f_dir, &set->lights[LIGHT_TONE_CURVE]); + set->lights[LIGHT_TONE_CURVE].get_ambient(chara_f_ambient); + set->lights[LIGHT_TONE_CURVE].get_diffuse(chara_f_diffuse); + + light_tone_curve tone_curve; + set->lights[LIGHT_TONE_CURVE].get_tone_curve(tone_curve); + chara_tc_param.x = tone_curve.start_point; + float_t end_point = min_def(tone_curve.end_point, 1.0f) - tone_curve.start_point; + if (end_point > 0.0f) + chara_tc_param.y = 1.0f / end_point; + else + chara_tc_param.y = 0.0f; + chara_tc_param.z = tone_curve.coefficient; + chara_tc_param.w = 0.0f; + } + else { + uniform->arr[U_TONE_CURVE] = 0; + chara_f_dir = { 0.0f, 1.0f, 0.0f, 0.0f }; + chara_f_ambient = 0.0f; + chara_f_diffuse = 0.0f; + chara_tc_param = 0.0f; + } + + vec4 light_reflect_dir; + set->lights[LIGHT_CHARA].get_position(light_reflect_dir); + if (fabsf(light_reflect_dir.x) <= 0.000001f && fabsf(light_reflect_dir.y) <= 0.000001f + && fabsf(light_reflect_dir.z) <= 0.000001f) + *(vec3*)&light_reflect_dir = vec3(0.0f, 1.0f, 0.0f); + else { + float_t length = vec3::length(*(vec3*)&light_reflect_dir); + if (length != 0.0f) + *(vec3*)&light_reflect_dir *= 1.0f / length; + } + light_reflect_dir.w = 1.0f; + + vec4 clip_plane; + if (set->lights[LIGHT_REFLECT].get_type() == LIGHT_SPOT) { + vec3 spot_direction; + vec4 position; + set->lights[LIGHT_REFLECT].get_spot_direction(spot_direction); + set->lights[LIGHT_REFLECT].get_position(position); + *(vec3*)&clip_plane = -spot_direction; + light_get_direction_from_position(&clip_plane, &set->lights[LIGHT_REFLECT], true); + clip_plane.w = -vec3::dot(*(vec3*)&position, *(vec3*)&clip_plane); + } + else if (set->lights[LIGHT_REFLECT].get_type() == LIGHT_POINT) + clip_plane = { 0.0f, -1.0f, 0.0f, 9999.0f }; + else + clip_plane = { 0.0f, -1.0f, 0.0f, 0.0f }; + + vec4 light_chara_ibl_direction; + vec4 light_chara_position; + set->lights[LIGHT_CHARA].get_ibl_direction(light_chara_ibl_direction); + set->lights[LIGHT_CHARA].get_position(light_chara_position); + + mat4 normal_tangent_transforms = mat4_identity; + + float_t length = vec3::length(*(vec3*)&light_chara_ibl_direction); + if (length >= 0.000001f) { + vec3 ibl_direction = *(vec3*)&light_chara_ibl_direction * (1.0f / length); + + length = vec3::length(*(vec3*)&light_chara_position); + if (length >= 0.000001f) { + vec3 position = *(vec3*)&light_chara_position * (1.0f / length); + + vec3 axis = vec3::cross(ibl_direction, position); + length = vec3::length(axis); + + float_t v52 = vec3::dot(ibl_direction, position); + float_t angle = fabsf(atan2f(length, v52)); + if (angle >= 0.01f && angle <= 3.131592653589793f) { + if (length != 0.0f) + axis *= 1.0f / length; + + mat4_set(&axis, -angle, &normal_tangent_transforms); + } + } + } + + static vec4& npr_cloth_spec_color = *(vec4*)0x0000000140C9B2A0; + + rctx->set_scene_light(irradiance_r_transforms, irradiance_g_transforms, irradiance_b_transforms, + light_env_stage_diffuse, light_env_stage_specular, light_env_chara_diffuse, + light_env_chara_ambient, light_env_chara_specular, + light_env_reflect_diffuse, light_env_reflect_ambient, + light_env_proj_diffuse, light_env_proj_specular, + light_env_proj_position, light_stage_dir, light_stage_diff, + light_stage_spec, light_chara_dir, light_chara_spec, + light_chara_luce, light_chara_back, light_face_diff, + chara_color0, chara_color1, chara_f_dir, chara_f_ambient, + chara_f_diffuse, chara_tc_param, normal_tangent_transforms, + light_reflect_dir, clip_plane, npr_cloth_spec_color); +} + static void render_manager_free_render_textures() { if (render_manager.multisample_renderbuffer) { glDeleteRenderbuffers(1, &render_manager.multisample_renderbuffer); diff --git a/src/DivaGL/render_manager.hpp b/src/DivaGL/render_manager.hpp index 6097c18..57cc21b 100644 --- a/src/DivaGL/render_manager.hpp +++ b/src/DivaGL/render_manager.hpp @@ -7,10 +7,10 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/types.hpp" #include "render.hpp" #include "shadow.hpp" #include "stage.hpp" -#include "types.hpp" #include "wrap.hpp" enum draw_pass_3d_type { diff --git a/src/DivaGL/renderer/fbo.cpp b/src/DivaGL/renderer/fbo.cpp index 833e17f..6ed9fb9 100644 --- a/src/DivaGL/renderer/fbo.cpp +++ b/src/DivaGL/renderer/fbo.cpp @@ -4,7 +4,7 @@ */ #include "fbo.hpp" -#include "../types.hpp" +#include "../../AFTModsShared/types.hpp" namespace renderer { FBO::FBO() : flags(), width(), height(), buffer(), count(), textures() { diff --git a/src/DivaGL/rob/rob.cpp b/src/DivaGL/rob/rob.cpp index 248d216..65cf87f 100644 --- a/src/DivaGL/rob/rob.cpp +++ b/src/DivaGL/rob/rob.cpp @@ -5,7 +5,9 @@ #include "rob.hpp" #include "../../KKdLib/str_utils.hpp" +#include "../mdl/disp_manager.hpp" #include "../gl_state.hpp" +#include "../object.hpp" #include "../render_manager.hpp" #include #include @@ -33,11 +35,7 @@ struct rob_chara_age_age_object { rob_chara_age_age_object_vertex* vertex_data; int32_t vertex_data_size; int32_t vertex_array_size; -#if SHARED_OBJECT_BUFFER - obj_mesh_vertex_buffer_aft obj_vert_buf; -#else obj_mesh_vertex_buffer obj_vert_buf; -#endif obj_mesh_index_buffer obj_index_buf; vec3 pos[10]; int32_t disp_count; @@ -124,33 +122,6 @@ struct rob_chara_arm_adjust_x { void reset(); }; -const mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index) - = (const mat4 * (FASTCALL*)(size_t rob_bone_data, size_t index))0x0000000140419520; -bool (FASTCALL* pv_osage_manager_array_get_disp)(int32_t* chara_id) - = (bool (FASTCALL*)(int32_t * chara_id))0x00000001404F9130; -const char* (FASTCALL* chara_index_get_auth_3d_name)(chara_index chara_index) - = (const char* (FASTCALL*)(chara_index chara_index))0x0000000140508100; -void(FASTCALL* sub_1405163C0)(rob_chara* rob_chr, int32_t index, mat4* mat) - = (void(FASTCALL*)(rob_chara* rob_chr, int32_t index, mat4 * mat))0x00000001405163C0; -float_t(FASTCALL* rob_chara_get_max_face_depth)(rob_chara* rob_chr) - = (float_t(FASTCALL*)(rob_chara* rob_chr))0x0000000140516510; -const mat4* (FASTCALL* rob_chara_get_bone_data_mat)(rob_chara* rob_chr, mot_bone_index index) - = (const mat4 * (FASTCALL*)(rob_chara* rob_chr, mot_bone_index index))0x0000000140516730; -const mat4* (FASTCALL* sub_140516740)(rob_chara* rob_chr) - = (const mat4 * (FASTCALL*)(rob_chara* rob_chr))0x0000000140516740; -bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr_smth, int32_t chara_id) - = (bool(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140531F50; -rob_chara* (FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id) - = (rob_chara * (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140532030; -size_t(FASTCALL* get_rob_chara_smth)() = (size_t(FASTCALL*)())0x00000001405320E0; -rob_chara_item_equip* (FASTCALL* rob_chara_array_get_item_equip)(size_t rob_chr_smth, int32_t chara_id) - = (rob_chara_item_equip * (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x0000000140532120; -size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id) - = (size_t(FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405320F0; -bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id) - = (bool (FASTCALL*)(size_t rob_chr_smth, int32_t chara_id))0x00000001405327B0; - -static rob_chara* rob_chara_array = (rob_chara*)0x00000001411B76A0; static rob_chara_age_age* rob_chara_age_age_array = (rob_chara_age_age*)0x00000001411E83C0; static bool& chara_reflect = *(bool*)0x00000001411ADAFC; @@ -163,169 +134,6 @@ rob_chara_arm_adjust_x rob_chara_arm_adjust_x_array[ROB_CHARA_COUNT]; static void rob_chara_age_age_array_disp(int32_t chara_id, bool reflect, bool chara_color); -SkinParam::CollisionParam::CollisionParam() : type(), node_idx(), pos() { - radius = 0.2f; -} - -void RobOsage::SetAirRes(float_t air_res) { - skin_param_ptr->air_res = air_res; -} - -void RobOsage::SetColiR(float_t coli_r) { - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) - i->data_ptr->skp_osg_node.coli_r = coli_r; -} - -void RobOsage::SetForce(float_t force, float_t force_gain) { - skin_param_ptr->force = force; - skin_param_ptr->force_gain = force_gain; - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) { - i->data_ptr->force = force; - force = force * force_gain; - } -} - -void RobOsage::SetHinge(float_t hinge_y, float_t hinge_z) { - hinge_y = min_def(hinge_y, 179.0f); - hinge_z = min_def(hinge_z, 179.0f); - hinge_y = hinge_y * DEG_TO_RAD_FLOAT; - hinge_z = hinge_z * DEG_TO_RAD_FLOAT; - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) { - RobOsageNodeData* data = i->data_ptr; - data->skp_osg_node.hinge.ymin = -hinge_y; - data->skp_osg_node.hinge.ymax = hinge_y; - data->skp_osg_node.hinge.zmin = -hinge_z; - data->skp_osg_node.hinge.zmax = hinge_z; - } -} - -void RobOsage::SetInitRot(float_t init_rot_y, float_t init_rot_z) { - skin_param_ptr->init_rot.y = init_rot_y * DEG_TO_RAD_FLOAT; - skin_param_ptr->init_rot.z = init_rot_z * DEG_TO_RAD_FLOAT; -} - -void RobOsage::SetMotionResetData(uint32_t motion_id, float_t frame) { - osage_reset = true; - auto elem = motion_reset_data.find({ motion_id, (int32_t)prj::roundf(frame * 1000.0f) }); - if (elem != motion_reset_data.end() && elem->second.size() + 1 == nodes.size()) - reset_data_list = &elem->second; -} - -// 0x140480F40 -void RobOsage::SetNodesExternalForce(vec3* external_force, float_t strength) { - if (!external_force) { - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) - i->external_force = 0.0f; - return; - } - - vec3 v4 = *external_force; - size_t exf = osage_setting.exf; - size_t v8 = 0; - if (exf >= 4) { - float_t strength4 = strength * strength * strength * strength; - v8 = ((exf - 4) / 4 + 1) * 4; - for (size_t v10 = v8 / 4; v10; v10--) - v4 *= strength4; - } - - if (v8 < exf) - for (size_t v12 = exf - v8; v12; v12--) - v4 *= strength; - - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) { - i->external_force = v4; - v4 *= strength; - } -} - -// 0x140481540 -void RobOsage::SetNodesForce(float_t force) { - RobOsageNode* i_begin = nodes.data() + 1; - RobOsageNode* i_end = nodes.data() + nodes.size(); - for (RobOsageNode* i = i_begin; i != i_end; i++) - i->force = force; -} - -void RobOsage::SetRot(float_t rot_y, float_t rot_z) { - skin_param_ptr->rot.y = rot_y * DEG_TO_RAD_FLOAT; - skin_param_ptr->rot.z = rot_z * DEG_TO_RAD_FLOAT; -} - -void rob_chara_item_equip_object::disp(const mat4& mat) { - if (obj_info.is_null()) - return; - - mdl::ObjFlags flags = disp_manager->get_obj_flags(); - mdl::ObjFlags chara_flags = flags; - if (fabsf(alpha - 1.0f) > 0.000001f) - enum_or(chara_flags, obj_flags); - else - enum_and(chara_flags, ~(mdl::OBJ_ALPHA_ORDER_3 | mdl::OBJ_ALPHA_ORDER_2 | mdl::OBJ_ALPHA_ORDER_1)); - disp_manager->set_obj_flags(chara_flags); - if (can_disp) { - disp_manager->entry_obj_by_object_info_object_skin(obj_info, - &texture_pattern, &texture_data, alpha, mats, ex_data_bone_mats.data(), 0, mat); - - rob_chara_item_equip_mat = &mat; - - for (ExNodeBlock*& i : node_blocks) - i->__vftable->Disp(i); - } - disp_manager->set_obj_flags(flags); -} - -int32_t rob_chara_item_equip_object::get_bone_index(const char* name) { - int32_t(FASTCALL * sub_1401F13B0)(int32_t a1, const char* a2) - = (int32_t(FASTCALL*)(int32_t a1, const char* a2))0x00000001401F13B0; - - int32_t bone_index = sub_1401F13B0(0, name); - if (bone_index == -1) - for (auto& i : ex_bones) - if (!str_utils_compare(name, i.first)) - return 0x8000 | i.second; - return bone_index; -} - -bone_node* rob_chara_item_equip_object::get_bone_node( - int32_t bone_index) { - if (!(bone_index & 0x8000)) - return &bone_nodes[bone_index & 0x7FFF]; - else if ((bone_index & 0x7FFF) < ex_data_bone_nodes.size()) - return &ex_data_bone_nodes[bone_index & 0x7FFF]; - return 0; -} - -bone_node* rob_chara_item_equip_object::get_bone_node(const char* name) { - return get_bone_node(get_bone_index(name)); -} - -void rob_chara_item_equip_object::skp_load(void* can_prop) { - void (FASTCALL * rob_chara_item_equip_object__skp_load)(rob_chara_item_equip_object * This, void* can_prop) - = (void (FASTCALL*)(rob_chara_item_equip_object * This, void* can_prop))0x00000001405F43E0; - rob_chara_item_equip_object__skp_load(this, can_prop); -} - -rob_chara_item_equip_object* rob_chara_item_equip::get_item_equip_object(item_id id) { - if (id >= ITEM_BODY && id <= ITEM_ITEM16) - return &item_equip_object[id]; - return 0; -} - -const mat4* rob_chara_get_adjust_data_mat(rob_chara* rob_chr) { - return &rob_chr->data.adjust_data.mat; -} - const mat4* rob_chara_get_item_adjust_data_mat(rob_chara* rob_chr) { return &rob_chara_item_adjust_x_array[rob_chr - rob_chara_array].mat; } @@ -674,9 +482,12 @@ HOOK(void, FASTCALL, rob_chara_item_equip_disp, 0x0000000140512950, sub_140512C20(rob_item_equip); rob_chara_age_age_array_disp(chara_id, chara_reflect, rob_item_equip->chara_color); + static void (FASTCALL * rob_chara_item_equip_object_disp)(rob_chara_item_equip_object* rob_bone_data) + = (void (FASTCALL*)(rob_chara_item_equip_object* rob_bone_data))0x00000001405F2700; + if (rob_item_equip->item_equip_range) for (int32_t i = rob_item_equip->first_item_equip_object; i < rob_item_equip->max_item_equip_object; i++) - rob_item_equip->item_equip_object[i].disp(rob_item_equip->mat); + rob_chara_item_equip_object_disp(&rob_item_equip->item_equip_object[i]); else { for (int32_t i = ITEM_ATAMA; i < ITEM_MAX; i++) { mdl::ObjFlags chara_flags = (mdl::ObjFlags)0; @@ -695,7 +506,7 @@ HOOK(void, FASTCALL, rob_chara_item_equip_disp, 0x0000000140512950, enum_and(flags, ~mdl::OBJ_SHADOW); disp_manager.set_obj_flags((mdl::ObjFlags)(chara_flags | flags | mdl::OBJ_SSS)); - rob_item_equip->item_equip_object[i].disp(rob_item_equip->mat); + rob_chara_item_equip_object_disp(&rob_item_equip->item_equip_object[i]); } } disp_manager.set_texture_color_coefficients(temp_texture_color_coeff); @@ -767,6 +578,12 @@ HOOK(void, FASTCALL, sub_140526FD0, 0x0000000140526FD0, item_cos_data->texture_change.insert({ item_no, tex_chg_vec }); } +HOOK(void, FASTCALL, rob_chara_item_equip_object_disp, 0x00000001405F2700, rob_chara_item_equip_object* itm_eq_obj) { + rob_chara_item_equip_mat = &itm_eq_obj->item_equip->mat; + originalrob_chara_item_equip_object_disp(itm_eq_obj); + rob_chara_item_equip_mat = 0; +} + HOOK(void, FASTCALL, sub_1405335C0, 0x0000001405335C0, struc_223* a1) { originalsub_1405335C0(a1); rob_chara* rob_chr = (rob_chara*)((size_t)a1 - 0x19C8); @@ -907,6 +724,7 @@ void rob_patch() { INSTALL_HOOK(rob_chara_item_equip_disp); INSTALL_HOOK(rob_chara_set_chara_size); INSTALL_HOOK(sub_140526FD0); + INSTALL_HOOK(rob_chara_item_equip_object_disp); INSTALL_HOOK(sub_1405335C0); INSTALL_HOOK(mothead_func_32); INSTALL_HOOK(sub_14053ACA0); diff --git a/src/DivaGL/rob/rob.hpp b/src/DivaGL/rob/rob.hpp index eff2c1d..f510a43 100644 --- a/src/DivaGL/rob/rob.hpp +++ b/src/DivaGL/rob/rob.hpp @@ -8,1836 +8,10 @@ #include "../../KKdLib/default.hpp" #include "../../KKdLib/mat.hpp" #include "../../KKdLib/vec.hpp" -#include "../mdl/disp_manager.hpp" -#include "../item_table.hpp" -#include "../object.hpp" - -enum chara_index { - CHARA_NONE = -1, - CHARA_MIKU = 0x00, - CHARA_RIN = 0x01, - CHARA_LEN = 0x02, - CHARA_LUKA = 0x03, - CHARA_NERU = 0x04, - CHARA_HAKU = 0x05, - CHARA_KAITO = 0x06, - CHARA_MEIKO = 0x07, - CHARA_SAKINE = 0x08, - CHARA_TETO = 0x09, - CHARA_MAX = 0x0A, -}; - -enum ex_expression_block_stack_type { - EX_EXPRESSION_BLOCK_STACK_NUMBER = 0x00, - EX_EXPRESSION_BLOCK_STACK_VARIABLE = 0x01, - EX_EXPRESSION_BLOCK_STACK_VARIABLE_RADIAN = 0x02, - EX_EXPRESSION_BLOCK_STACK_OP1 = 0x03, - EX_EXPRESSION_BLOCK_STACK_OP2 = 0x04, - EX_EXPRESSION_BLOCK_STACK_OP3 = 0x05, -}; - -enum eyes_base_adjust_type { - EYES_BASE_ADJUST_NONE = -1, - EYES_BASE_ADJUST_DIRECTION = 0x00, - EYES_BASE_ADJUST_CLEARANCE = 0x01, - EYES_BASE_ADJUST_OFF = 0x02, - EYES_BASE_ADJUST_MAX = 0x03, -}; - -enum mot_bone_index { - MOT_BONE_N_HARA_CP = 0x00, - MOT_BONE_KG_HARA_Y = 0x01, - MOT_BONE_KL_HARA_XZ = 0x02, - MOT_BONE_KL_HARA_ETC = 0x03, - MOT_BONE_N_HARA = 0x04, - MOT_BONE_CL_MUNE = 0x05, - MOT_BONE_J_MUNE_WJ = 0x06, - MOT_BONE_E_MUNE_CP = 0x07, - MOT_BONE_N_MUNE_B = 0x08, - MOT_BONE_KL_MUNE_B_WJ = 0x09, - MOT_BONE_KL_KUBI = 0x0A, - MOT_BONE_N_KAO = 0x0B, - MOT_BONE_CL_KAO = 0x0C, - MOT_BONE_J_KAO_WJ = 0x0D, - MOT_BONE_E_KAO_CP = 0x0E, - MOT_BONE_FACE_ROOT = 0x0F, - MOT_BONE_N_AGO = 0x10, - MOT_BONE_KL_AGO_WJ = 0x11, - MOT_BONE_N_TOOTH_UNDER = 0x12, - MOT_BONE_TL_TOOTH_UNDER_WJ = 0x13, - MOT_BONE_N_EYE_L = 0x14, - MOT_BONE_KL_EYE_L = 0x15, - MOT_BONE_N_EYE_L_WJ_EX = 0x16, - MOT_BONE_KL_HIGHLIGHT_L_WJ = 0x17, - MOT_BONE_N_EYE_R = 0x18, - MOT_BONE_KL_EYE_R = 0x19, - MOT_BONE_N_EYE_R_WJ_EX = 0x1A, - MOT_BONE_KL_HIGHLIGHT_R_WJ = 0x1B, - MOT_BONE_N_EYELID_L_A = 0x1C, - MOT_BONE_TL_EYELID_L_A_WJ = 0x1D, - MOT_BONE_N_EYELID_L_B = 0x1E, - MOT_BONE_TL_EYELID_L_B_WJ = 0x1F, - MOT_BONE_N_EYELID_R_A = 0x20, - MOT_BONE_TL_EYELID_R_A_WJ = 0x21, - MOT_BONE_N_EYELID_R_B = 0x22, - MOT_BONE_TL_EYELID_R_B_WJ = 0x23, - MOT_BONE_N_KUTI_D = 0x24, - MOT_BONE_TL_KUTI_D_WJ = 0x25, - MOT_BONE_N_KUTI_D_L = 0x26, - MOT_BONE_TL_KUTI_D_L_WJ = 0x27, - MOT_BONE_N_KUTI_D_R = 0x28, - MOT_BONE_TL_KUTI_D_R_WJ = 0x29, - MOT_BONE_N_KUTI_DS_L = 0x2A, - MOT_BONE_TL_KUTI_DS_L_WJ = 0x2B, - MOT_BONE_N_KUTI_DS_R = 0x2C, - MOT_BONE_TL_KUTI_DS_R_WJ = 0x2D, - MOT_BONE_N_KUTI_L = 0x2E, - MOT_BONE_TL_KUTI_L_WJ = 0x2F, - MOT_BONE_N_KUTI_M_L = 0x30, - MOT_BONE_TL_KUTI_M_L_WJ = 0x31, - MOT_BONE_N_KUTI_M_R = 0x32, - MOT_BONE_TL_KUTI_M_R_WJ = 0x33, - MOT_BONE_N_KUTI_R = 0x34, - MOT_BONE_TL_KUTI_R_WJ = 0x35, - MOT_BONE_N_KUTI_U = 0x36, - MOT_BONE_TL_KUTI_U_WJ = 0x37, - MOT_BONE_N_KUTI_U_L = 0x38, - MOT_BONE_TL_KUTI_U_L_WJ = 0x39, - MOT_BONE_N_KUTI_U_R = 0x3A, - MOT_BONE_TL_KUTI_U_R_WJ = 0x3B, - MOT_BONE_N_MABU_L_D_A = 0x3C, - MOT_BONE_TL_MABU_L_D_A_WJ = 0x3D, - MOT_BONE_N_MABU_L_D_B = 0x3E, - MOT_BONE_TL_MABU_L_D_B_WJ = 0x3F, - MOT_BONE_N_MABU_L_D_C = 0x40, - MOT_BONE_TL_MABU_L_D_C_WJ = 0x41, - MOT_BONE_N_MABU_L_U_A = 0x42, - MOT_BONE_TL_MABU_L_U_A_WJ = 0x43, - MOT_BONE_N_MABU_L_U_B = 0x44, - MOT_BONE_TL_MABU_L_U_B_WJ = 0x45, - MOT_BONE_N_EYELASHES_L = 0x46, - MOT_BONE_TL_EYELASHES_L_WJ = 0x47, - MOT_BONE_N_MABU_L_U_C = 0x48, - MOT_BONE_TL_MABU_L_U_C_WJ = 0x49, - MOT_BONE_N_MABU_R_D_A = 0x4A, - MOT_BONE_TL_MABU_R_D_A_WJ = 0x4B, - MOT_BONE_N_MABU_R_D_B = 0x4C, - MOT_BONE_TL_MABU_R_D_B_WJ = 0x4D, - MOT_BONE_N_MABU_R_D_C = 0x4E, - MOT_BONE_TL_MABU_R_D_C_WJ = 0x4F, - MOT_BONE_N_MABU_R_U_A = 0x50, - MOT_BONE_TL_MABU_R_U_A_WJ = 0x51, - MOT_BONE_N_MABU_R_U_B = 0x52, - MOT_BONE_TL_MABU_R_U_B_WJ = 0x53, - MOT_BONE_N_EYELASHES_R = 0x54, - MOT_BONE_TL_EYELASHES_R_WJ = 0x55, - MOT_BONE_N_MABU_R_U_C = 0x56, - MOT_BONE_TL_MABU_R_U_C_WJ = 0x57, - MOT_BONE_N_MAYU_L = 0x58, - MOT_BONE_TL_MAYU_L_WJ = 0x59, - MOT_BONE_N_MAYU_L_B = 0x5A, - MOT_BONE_TL_MAYU_L_B_WJ = 0x5B, - MOT_BONE_N_MAYU_L_C = 0x5C, - MOT_BONE_TL_MAYU_L_C_WJ = 0x5D, - MOT_BONE_N_MAYU_R = 0x5E, - MOT_BONE_TL_MAYU_R_WJ = 0x5F, - MOT_BONE_N_MAYU_R_B = 0x60, - MOT_BONE_TL_MAYU_R_B_WJ = 0x61, - MOT_BONE_N_MAYU_R_C = 0x62, - MOT_BONE_TL_MAYU_R_C_WJ = 0x63, - MOT_BONE_N_TOOTH_UPPER = 0x64, - MOT_BONE_TL_TOOTH_UPPER_WJ = 0x65, - MOT_BONE_N_KUBI_WJ_EX = 0x66, - MOT_BONE_N_WAKI_L = 0x67, - MOT_BONE_KL_WAKI_L_WJ = 0x68, - MOT_BONE_TL_UP_KATA_L = 0x69, - MOT_BONE_C_KATA_L = 0x6A, - MOT_BONE_J_KATA_L_WJ_CU = 0x6B, - MOT_BONE_J_UDE_L_WJ = 0x6C, - MOT_BONE_E_UDE_L_CP = 0x6D, - MOT_BONE_KL_TE_L_WJ = 0x6E, - MOT_BONE_N_HITO_L_EX = 0x6F, - MOT_BONE_NL_HITO_L_WJ = 0x70, - MOT_BONE_NL_HITO_B_L_WJ = 0x71, - MOT_BONE_NL_HITO_C_L_WJ = 0x72, - MOT_BONE_N_KO_L_EX = 0x73, - MOT_BONE_NL_KO_L_WJ = 0x74, - MOT_BONE_NL_KO_B_L_WJ = 0x75, - MOT_BONE_NL_KO_C_L_WJ = 0x76, - MOT_BONE_N_KUSU_L_EX = 0x77, - MOT_BONE_NL_KUSU_L_WJ = 0x78, - MOT_BONE_NL_KUSU_B_L_WJ = 0x79, - MOT_BONE_NL_KUSU_C_L_WJ = 0x7A, - MOT_BONE_N_NAKA_L_EX = 0x7B, - MOT_BONE_NL_NAKA_L_WJ = 0x7C, - MOT_BONE_NL_NAKA_B_L_WJ = 0x7D, - MOT_BONE_NL_NAKA_C_L_WJ = 0x7E, - MOT_BONE_N_OYA_L_EX = 0x7F, - MOT_BONE_NL_OYA_L_WJ = 0x80, - MOT_BONE_NL_OYA_B_L_WJ = 0x81, - MOT_BONE_NL_OYA_C_L_WJ = 0x82, - MOT_BONE_N_STE_L_WJ_EX = 0x83, - MOT_BONE_N_SUDE_L_WJ_EX = 0x84, - MOT_BONE_N_SUDE_B_L_WJ_EX = 0x85, - MOT_BONE_N_HIJI_L_WJ_EX = 0x86, - MOT_BONE_N_UP_KATA_L_EX = 0x87, - MOT_BONE_N_SKATA_L_WJ_CD_EX = 0x88, - MOT_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x89, - MOT_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x8A, - MOT_BONE_N_WAKI_R = 0x8B, - MOT_BONE_KL_WAKI_R_WJ = 0x8C, - MOT_BONE_TL_UP_KATA_R = 0x8D, - MOT_BONE_C_KATA_R = 0x8E, - MOT_BONE_J_KATA_R_WJ_CU = 0x8F, - MOT_BONE_J_UDE_R_WJ = 0x90, - MOT_BONE_E_UDE_R_CP = 0x91, - MOT_BONE_KL_TE_R_WJ = 0x92, - MOT_BONE_N_HITO_R_EX = 0x93, - MOT_BONE_NL_HITO_R_WJ = 0x94, - MOT_BONE_NL_HITO_B_R_WJ = 0x95, - MOT_BONE_NL_HITO_C_R_WJ = 0x96, - MOT_BONE_N_KO_R_EX = 0x97, - MOT_BONE_NL_KO_R_WJ = 0x98, - MOT_BONE_NL_KO_B_R_WJ = 0x99, - MOT_BONE_NL_KO_C_R_WJ = 0x9A, - MOT_BONE_N_KUSU_R_EX = 0x9B, - MOT_BONE_NL_KUSU_R_WJ = 0x9C, - MOT_BONE_NL_KUSU_B_R_WJ = 0x9D, - MOT_BONE_NL_KUSU_C_R_WJ = 0x9E, - MOT_BONE_N_NAKA_R_EX = 0x9F, - MOT_BONE_NL_NAKA_R_WJ = 0xA0, - MOT_BONE_NL_NAKA_B_R_WJ = 0xA1, - MOT_BONE_NL_NAKA_C_R_WJ = 0xA2, - MOT_BONE_N_OYA_R_EX = 0xA3, - MOT_BONE_NL_OYA_R_WJ = 0xA4, - MOT_BONE_NL_OYA_B_R_WJ = 0xA5, - MOT_BONE_NL_OYA_C_R_WJ = 0xA6, - MOT_BONE_N_STE_R_WJ_EX = 0xA7, - MOT_BONE_N_SUDE_R_WJ_EX = 0xA8, - MOT_BONE_N_SUDE_B_R_WJ_EX = 0xA9, - MOT_BONE_N_HIJI_R_WJ_EX = 0xAA, - MOT_BONE_N_UP_KATA_R_EX = 0xAB, - MOT_BONE_N_SKATA_R_WJ_CD_EX = 0xAC, - MOT_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xAD, - MOT_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xAE, - MOT_BONE_KL_KOSI_Y = 0xAF, - MOT_BONE_KL_KOSI_XZ = 0xB0, - MOT_BONE_KL_KOSI_ETC_WJ = 0xB1, - MOT_BONE_CL_MOMO_L = 0xB2, - MOT_BONE_J_MOMO_L_WJ = 0xB3, - MOT_BONE_J_SUNE_L_WJ = 0xB4, - MOT_BONE_E_SUNE_L_CP = 0xB5, - MOT_BONE_KL_ASI_L_WJ_CO = 0xB6, - MOT_BONE_KL_TOE_L_WJ = 0xB7, - MOT_BONE_N_HIZA_L_WJ_EX = 0xB8, - MOT_BONE_CL_MOMO_R = 0xB9, - MOT_BONE_J_MOMO_R_WJ = 0xBA, - MOT_BONE_J_SUNE_R_WJ = 0xBB, - MOT_BONE_E_SUNE_R_CP = 0xBC, - MOT_BONE_KL_ASI_R_WJ_CO = 0xBD, - MOT_BONE_KL_TOE_R_WJ = 0xBE, - MOT_BONE_N_HIZA_R_WJ_EX = 0xBF, - MOT_BONE_N_MOMO_A_L_WJ_CD_EX = 0xC0, - MOT_BONE_N_MOMO_B_L_WJ_EX = 0xC1, - MOT_BONE_N_MOMO_C_L_WJ_EX = 0xC2, - MOT_BONE_N_MOMO_A_R_WJ_CD_EX = 0xC3, - MOT_BONE_N_MOMO_B_R_WJ_EX = 0xC4, - MOT_BONE_N_MOMO_C_R_WJ_EX = 0xC5, - MOT_BONE_N_HARA_CD_EX = 0xC6, - MOT_BONE_N_HARA_B_WJ_EX = 0xC7, - MOT_BONE_N_HARA_C_WJ_EX = 0xC8, - MOT_BONE_MAX = 0xC9, -}; - -enum mothead_data_type { - MOTHEAD_DATA_TYPE_0 = 0x00, - MOTHEAD_DATA_TYPE_1 = 0x01, - MOTHEAD_DATA_TYPE_2 = 0x02, - MOTHEAD_DATA_TYPE_3 = 0x03, - MOTHEAD_DATA_TYPE_4 = 0x04, - MOTHEAD_DATA_TYPE_5 = 0x05, - MOTHEAD_DATA_TYPE_6 = 0x06, - MOTHEAD_DATA_TYPE_7 = 0x07, - MOTHEAD_DATA_TYPE_8 = 0x08, - MOTHEAD_DATA_TYPE_9 = 0x09, - MOTHEAD_DATA_TYPE_10 = 0x0A, - MOTHEAD_DATA_TYPE_11 = 0x0B, - MOTHEAD_DATA_TYPE_12 = 0x0C, - MOTHEAD_DATA_TYPE_13 = 0x0D, - MOTHEAD_DATA_TYPE_14 = 0x0E, - MOTHEAD_DATA_TYPE_15 = 0x0F, - MOTHEAD_DATA_TYPE_16 = 0x10, - MOTHEAD_DATA_TYPE_17 = 0x11, - MOTHEAD_DATA_TYPE_18 = 0x12, - MOTHEAD_DATA_TYPE_19 = 0x13, - MOTHEAD_DATA_TYPE_20 = 0x14, - MOTHEAD_DATA_TYPE_21 = 0x15, - MOTHEAD_DATA_TYPE_22 = 0x16, - MOTHEAD_DATA_TYPE_23 = 0x17, - MOTHEAD_DATA_TYPE_24 = 0x18, - MOTHEAD_DATA_TYPE_25 = 0x19, - MOTHEAD_DATA_TYPE_26 = 0x1A, - MOTHEAD_DATA_TYPE_27 = 0x1B, - MOTHEAD_DATA_TYPE_28 = 0x1C, - MOTHEAD_DATA_TYPE_29 = 0x1D, - MOTHEAD_DATA_TYPE_30 = 0x1E, - MOTHEAD_DATA_TYPE_31 = 0x1F, - MOTHEAD_DATA_TYPE_32 = 0x20, - MOTHEAD_DATA_TYPE_33 = 0x21, - MOTHEAD_DATA_TYPE_34 = 0x22, - MOTHEAD_DATA_TYPE_35 = 0x23, - MOTHEAD_DATA_TYPE_36 = 0x24, - MOTHEAD_DATA_TYPE_37 = 0x25, - MOTHEAD_DATA_TYPE_38 = 0x26, - MOTHEAD_DATA_TYPE_39 = 0x27, - MOTHEAD_DATA_TYPE_40 = 0x28, - MOTHEAD_DATA_TYPE_41 = 0x29, - MOTHEAD_DATA_TYPE_42 = 0x2A, - MOTHEAD_DATA_TYPE_43 = 0x2B, - MOTHEAD_DATA_TYPE_44 = 0x2C, - MOTHEAD_DATA_TYPE_45 = 0x2D, - MOTHEAD_DATA_TYPE_46 = 0x2E, - MOTHEAD_DATA_TYPE_47 = 0x2F, - MOTHEAD_DATA_TYPE_48 = 0x30, - MOTHEAD_DATA_TYPE_49 = 0x31, - MOTHEAD_DATA_SET_FACE_MOTION_ID = 0x32, - MOTHEAD_DATA_TYPE_51 = 0x33, - MOTHEAD_DATA_TYPE_52 = 0x34, - MOTHEAD_DATA_SET_FACE_MOTTBL_MOTION = 0x35, - MOTHEAD_DATA_SET_HAND_R_MOTTBL_MOTION = 0x36, - MOTHEAD_DATA_SET_HAND_L_MOTTBL_MOTION = 0x37, - MOTHEAD_DATA_SET_MOUTH_MOTTBL_MOTION = 0x38, - MOTHEAD_DATA_SET_EYES_MOTTBL_MOTION = 0x39, - MOTHEAD_DATA_SET_EYELID_MOTTBL_MOTION = 0x3A, - MOTHEAD_DATA_SET_ROB_CHARA_HEAD_OBJECT = 0x3B, - MOTHEAD_DATA_TYPE_60 = 0x3C, - MOTHEAD_DATA_SET_EYELID_MOTION_FROM_FACE = 0x3D, - MOTHEAD_DATA_ROB_PARTS_ADJUST = 0x3E, - MOTHEAD_DATA_TYPE_63 = 0x3F, - MOTHEAD_DATA_WIND_RESET = 0x40, - MOTHEAD_DATA_OSAGE_RESET = 0x41, - MOTHEAD_DATA_OSAGE_STEP = 0x42, - MOTHEAD_DATA_SLEEVE_ADJUST = 0x43, - MOTHEAD_DATA_TYPE_68 = 0x44, - MOTHEAD_DATA_TYPE_69 = 0x45, - MOTHEAD_DATA_TYPE_70 = 0x46, - MOTHEAD_DATA_OSAGE_MOVE_CANCEL = 0x47, - MOTHEAD_DATA_TYPE_72 = 0x48, - MOTHEAD_DATA_ROB_HAND_ADJUST = 0x49, - MOTHEAD_DATA_DISABLE_COLLISION = 0x4A, - MOTHEAD_DATA_ROB_ADJUST_GLOBAL = 0x4B, - MOTHEAD_DATA_ROB_ARM_ADJUST = 0x4C, - MOTHEAD_DATA_DISABLE_EYE_MOTION = 0x4D, - MOTHEAD_DATA_TYPE_78 = 0x4E, - MOTHEAD_DATA_ROB_CHARA_COLI_RING = 0x4F, - MOTHEAD_DATA_ADJUST_GET_GLOBAL_POSITION = 0x50, - MOTHEAD_DATA_MAX = 0x51, -}; - -enum MotionBlendType { - MOTION_BLEND_NONE = -1, - MOTION_BLEND = 0x00, - MOTION_BLEND_FREEZE = 0x01, - MOTION_BLEND_CROSS = 0x02, - MOTION_BLEND_COMBINE = 0x03, -}; - -enum motion_bone_index { - MOTION_BONE_NONE = -1, - MOTION_BONE_N_HARA_CP = 0x00, - MOTION_BONE_KG_HARA_Y = 0x01, - MOTION_BONE_KL_HARA_XZ = 0x02, - MOTION_BONE_KL_HARA_ETC = 0x03, - MOTION_BONE_N_HARA = 0x04, - MOTION_BONE_CL_MUNE = 0x05, - MOTION_BONE_N_MUNE_B = 0x06, - MOTION_BONE_KL_MUNE_B_WJ = 0x07, - MOTION_BONE_KL_KUBI = 0x08, - MOTION_BONE_N_KAO = 0x09, - MOTION_BONE_CL_KAO = 0x0A, - MOTION_BONE_FACE_ROOT = 0x0B, - MOTION_BONE_N_AGO = 0x0C, - MOTION_BONE_KL_AGO_WJ = 0x0D, - MOTION_BONE_N_TOOTH_UNDER = 0x0E, - MOTION_BONE_TL_TOOTH_UNDER_WJ = 0x0F, - MOTION_BONE_N_EYE_L = 0x10, - MOTION_BONE_KL_EYE_L = 0x11, - MOTION_BONE_N_EYE_L_WJ_EX = 0x12, - MOTION_BONE_KL_HIGHLIGHT_L_WJ = 0x13, - MOTION_BONE_N_EYE_R = 0x14, - MOTION_BONE_KL_EYE_R = 0x15, - MOTION_BONE_N_EYE_R_WJ_EX = 0x16, - MOTION_BONE_KL_HIGHLIGHT_R_WJ = 0x17, - MOTION_BONE_N_EYELID_L_A = 0x18, - MOTION_BONE_TL_EYELID_L_A_WJ = 0x19, - MOTION_BONE_N_EYELID_L_B = 0x1A, - MOTION_BONE_TL_EYELID_L_B_WJ = 0x1B, - MOTION_BONE_N_EYELID_R_A = 0x1C, - MOTION_BONE_TL_EYELID_R_A_WJ = 0x1D, - MOTION_BONE_N_EYELID_R_B = 0x1E, - MOTION_BONE_TL_EYELID_R_B_WJ = 0x1F, - MOTION_BONE_N_KUTI_D = 0x20, - MOTION_BONE_TL_KUTI_D_WJ = 0x21, - MOTION_BONE_N_KUTI_D_L = 0x22, - MOTION_BONE_TL_KUTI_D_L_WJ = 0x23, - MOTION_BONE_N_KUTI_D_R = 0x24, - MOTION_BONE_TL_KUTI_D_R_WJ = 0x25, - MOTION_BONE_N_KUTI_DS_L = 0x26, - MOTION_BONE_TL_KUTI_DS_L_WJ = 0x27, - MOTION_BONE_N_KUTI_DS_R = 0x28, - MOTION_BONE_TL_KUTI_DS_R_WJ = 0x29, - MOTION_BONE_N_KUTI_L = 0x2A, - MOTION_BONE_TL_KUTI_L_WJ = 0x2B, - MOTION_BONE_N_KUTI_M_L = 0x2C, - MOTION_BONE_TL_KUTI_M_L_WJ = 0x2D, - MOTION_BONE_N_KUTI_M_R = 0x2E, - MOTION_BONE_TL_KUTI_M_R_WJ = 0x2F, - MOTION_BONE_N_KUTI_R = 0x30, - MOTION_BONE_TL_KUTI_R_WJ = 0x31, - MOTION_BONE_N_KUTI_U = 0x32, - MOTION_BONE_TL_KUTI_U_WJ = 0x33, - MOTION_BONE_N_KUTI_U_L = 0x34, - MOTION_BONE_TL_KUTI_U_L_WJ = 0x35, - MOTION_BONE_N_KUTI_U_R = 0x36, - MOTION_BONE_TL_KUTI_U_R_WJ = 0x37, - MOTION_BONE_N_MABU_L_D_A = 0x38, - MOTION_BONE_TL_MABU_L_D_A_WJ = 0x39, - MOTION_BONE_N_MABU_L_D_B = 0x3A, - MOTION_BONE_TL_MABU_L_D_B_WJ = 0x3B, - MOTION_BONE_N_MABU_L_D_C = 0x3C, - MOTION_BONE_TL_MABU_L_D_C_WJ = 0x3D, - MOTION_BONE_N_MABU_L_U_A = 0x3E, - MOTION_BONE_TL_MABU_L_U_A_WJ = 0x3F, - MOTION_BONE_N_MABU_L_U_B = 0x40, - MOTION_BONE_TL_MABU_L_U_B_WJ = 0x41, - MOTION_BONE_N_EYELASHES_L = 0x42, - MOTION_BONE_TL_EYELASHES_L_WJ = 0x43, - MOTION_BONE_N_MABU_L_U_C = 0x44, - MOTION_BONE_TL_MABU_L_U_C_WJ = 0x45, - MOTION_BONE_N_MABU_R_D_A = 0x46, - MOTION_BONE_TL_MABU_R_D_A_WJ = 0x47, - MOTION_BONE_N_MABU_R_D_B = 0x48, - MOTION_BONE_TL_MABU_R_D_B_WJ = 0x49, - MOTION_BONE_N_MABU_R_D_C = 0x4A, - MOTION_BONE_TL_MABU_R_D_C_WJ = 0x4B, - MOTION_BONE_N_MABU_R_U_A = 0x4C, - MOTION_BONE_TL_MABU_R_U_A_WJ = 0x4D, - MOTION_BONE_N_MABU_R_U_B = 0x4E, - MOTION_BONE_TL_MABU_R_U_B_WJ = 0x4F, - MOTION_BONE_N_EYELASHES_R = 0x50, - MOTION_BONE_TL_EYELASHES_R_WJ = 0x51, - MOTION_BONE_N_MABU_R_U_C = 0x52, - MOTION_BONE_TL_MABU_R_U_C_WJ = 0x53, - MOTION_BONE_N_MAYU_L = 0x54, - MOTION_BONE_TL_MAYU_L_WJ = 0x55, - MOTION_BONE_N_MAYU_L_B = 0x56, - MOTION_BONE_TL_MAYU_L_B_WJ = 0x57, - MOTION_BONE_N_MAYU_L_C = 0x58, - MOTION_BONE_TL_MAYU_L_C_WJ = 0x59, - MOTION_BONE_N_MAYU_R = 0x5A, - MOTION_BONE_TL_MAYU_R_WJ = 0x5B, - MOTION_BONE_N_MAYU_R_B = 0x5C, - MOTION_BONE_TL_MAYU_R_B_WJ = 0x5D, - MOTION_BONE_N_MAYU_R_C = 0x5E, - MOTION_BONE_TL_MAYU_R_C_WJ = 0x5F, - MOTION_BONE_N_TOOTH_UPPER = 0x60, - MOTION_BONE_TL_TOOTH_UPPER_WJ = 0x61, - MOTION_BONE_N_KUBI_WJ_EX = 0x62, - MOTION_BONE_N_WAKI_L = 0x63, - MOTION_BONE_KL_WAKI_L_WJ = 0x64, - MOTION_BONE_TL_UP_KATA_L = 0x65, - MOTION_BONE_C_KATA_L = 0x66, - MOTION_BONE_KL_TE_L_WJ = 0x67, - MOTION_BONE_N_HITO_L_EX = 0x68, - MOTION_BONE_NL_HITO_L_WJ = 0x69, - MOTION_BONE_NL_HITO_B_L_WJ = 0x6A, - MOTION_BONE_NL_HITO_C_L_WJ = 0x6B, - MOTION_BONE_N_KO_L_EX = 0x6C, - MOTION_BONE_NL_KO_L_WJ = 0x6D, - MOTION_BONE_NL_KO_B_L_WJ = 0x6E, - MOTION_BONE_NL_KO_C_L_WJ = 0x6F, - MOTION_BONE_N_KUSU_L_EX = 0x70, - MOTION_BONE_NL_KUSU_L_WJ = 0x71, - MOTION_BONE_NL_KUSU_B_L_WJ = 0x72, - MOTION_BONE_NL_KUSU_C_L_WJ = 0x73, - MOTION_BONE_N_NAKA_L_EX = 0x74, - MOTION_BONE_NL_NAKA_L_WJ = 0x75, - MOTION_BONE_NL_NAKA_B_L_WJ = 0x76, - MOTION_BONE_NL_NAKA_C_L_WJ = 0x77, - MOTION_BONE_N_OYA_L_EX = 0x78, - MOTION_BONE_NL_OYA_L_WJ = 0x79, - MOTION_BONE_NL_OYA_B_L_WJ = 0x7A, - MOTION_BONE_NL_OYA_C_L_WJ = 0x7B, - MOTION_BONE_N_STE_L_WJ_EX = 0x7C, - MOTION_BONE_N_SUDE_L_WJ_EX = 0x7D, - MOTION_BONE_N_SUDE_B_L_WJ_EX = 0x7E, - MOTION_BONE_N_HIJI_L_WJ_EX = 0x7F, - MOTION_BONE_N_UP_KATA_L_EX = 0x80, - MOTION_BONE_N_SKATA_L_WJ_CD_EX = 0x81, - MOTION_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x82, - MOTION_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x83, - MOTION_BONE_N_WAKI_R = 0x84, - MOTION_BONE_KL_WAKI_R_WJ = 0x85, - MOTION_BONE_TL_UP_KATA_R = 0x86, - MOTION_BONE_C_KATA_R = 0x87, - MOTION_BONE_KL_TE_R_WJ = 0x88, - MOTION_BONE_N_HITO_R_EX = 0x89, - MOTION_BONE_NL_HITO_R_WJ = 0x8A, - MOTION_BONE_NL_HITO_B_R_WJ = 0x8B, - MOTION_BONE_NL_HITO_C_R_WJ = 0x8C, - MOTION_BONE_N_KO_R_EX = 0x8D, - MOTION_BONE_NL_KO_R_WJ = 0x8E, - MOTION_BONE_NL_KO_B_R_WJ = 0x8F, - MOTION_BONE_NL_KO_C_R_WJ = 0x90, - MOTION_BONE_N_KUSU_R_EX = 0x91, - MOTION_BONE_NL_KUSU_R_WJ = 0x92, - MOTION_BONE_NL_KUSU_B_R_WJ = 0x93, - MOTION_BONE_NL_KUSU_C_R_WJ = 0x94, - MOTION_BONE_N_NAKA_R_EX = 0x95, - MOTION_BONE_NL_NAKA_R_WJ = 0x96, - MOTION_BONE_NL_NAKA_B_R_WJ = 0x97, - MOTION_BONE_NL_NAKA_C_R_WJ = 0x98, - MOTION_BONE_N_OYA_R_EX = 0x99, - MOTION_BONE_NL_OYA_R_WJ = 0x9A, - MOTION_BONE_NL_OYA_B_R_WJ = 0x9B, - MOTION_BONE_NL_OYA_C_R_WJ = 0x9C, - MOTION_BONE_N_STE_R_WJ_EX = 0x9D, - MOTION_BONE_N_SUDE_R_WJ_EX = 0x9E, - MOTION_BONE_N_SUDE_B_R_WJ_EX = 0x9F, - MOTION_BONE_N_HIJI_R_WJ_EX = 0xA0, - MOTION_BONE_N_UP_KATA_R_EX = 0xA1, - MOTION_BONE_N_SKATA_R_WJ_CD_EX = 0xA2, - MOTION_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xA3, - MOTION_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xA4, - MOTION_BONE_KL_KOSI_Y = 0xA5, - MOTION_BONE_KL_KOSI_XZ = 0xA6, - MOTION_BONE_KL_KOSI_ETC_WJ = 0xA7, - MOTION_BONE_CL_MOMO_L = 0xA8, - MOTION_BONE_KL_ASI_L_WJ_CO = 0xA9, - MOTION_BONE_KL_TOE_L_WJ = 0xAA, - MOTION_BONE_N_HIZA_L_WJ_EX = 0xAB, - MOTION_BONE_CL_MOMO_R = 0xAC, - MOTION_BONE_KL_ASI_R_WJ_CO = 0xAD, - MOTION_BONE_KL_TOE_R_WJ = 0xAE, - MOTION_BONE_N_HIZA_R_WJ_EX = 0xAF, - MOTION_BONE_N_MOMO_A_L_WJ_CD_EX = 0xB0, - MOTION_BONE_N_MOMO_B_L_WJ_EX = 0xB1, - MOTION_BONE_N_MOMO_C_L_WJ_EX = 0xB2, - MOTION_BONE_N_MOMO_A_R_WJ_CD_EX = 0xB3, - MOTION_BONE_N_MOMO_B_R_WJ_EX = 0xB4, - MOTION_BONE_N_MOMO_C_R_WJ_EX = 0xB5, - MOTION_BONE_N_HARA_CD_EX = 0xB6, - MOTION_BONE_N_HARA_B_WJ_EX = 0xB7, - MOTION_BONE_N_HARA_C_WJ_EX = 0xB8, - MOTION_BONE_MAX = 0xB9, -}; - -enum rob_bone_index { - ROB_BONE_NONE = -1, - ROB_BONE_N_HARA_CP = 0x00, - ROB_BONE_KG_HARA_Y = 0x01, - ROB_BONE_KL_HARA_XZ = 0x02, - ROB_BONE_KL_HARA_ETC = 0x03, - ROB_BONE_N_HARA = 0x04, - ROB_BONE_CL_MUNE = 0x05, - ROB_BONE_N_MUNE_B = 0x06, - ROB_BONE_KL_MUNE_B_WJ = 0x07, - ROB_BONE_KL_KUBI = 0x08, - ROB_BONE_N_KAO = 0x09, - ROB_BONE_CL_KAO = 0x0A, - ROB_BONE_FACE_ROOT = 0x0B, - ROB_BONE_N_AGO = 0x0C, - ROB_BONE_KL_AGO_WJ = 0x0D, - ROB_BONE_N_TOOTH_UNDER = 0x0E, - ROB_BONE_TL_TOOTH_UNDER_WJ = 0x0F, - ROB_BONE_N_EYE_L = 0x10, - ROB_BONE_KL_EYE_L = 0x11, - ROB_BONE_N_EYE_L_WJ_EX = 0x12, - ROB_BONE_KL_HIGHLIGHT_L_WJ = 0x13, - ROB_BONE_N_EYE_R = 0x14, - ROB_BONE_KL_EYE_R = 0x15, - ROB_BONE_N_EYE_R_WJ_EX = 0x16, - ROB_BONE_KL_HIGHLIGHT_R_WJ = 0x17, - ROB_BONE_N_EYELID_L_A = 0x18, - ROB_BONE_TL_EYELID_L_A_WJ = 0x19, - ROB_BONE_N_EYELID_L_B = 0x1A, - ROB_BONE_TL_EYELID_L_B_WJ = 0x1B, - ROB_BONE_N_EYELID_R_A = 0x1C, - ROB_BONE_TL_EYELID_R_A_WJ = 0x1D, - ROB_BONE_N_EYELID_R_B = 0x1E, - ROB_BONE_TL_EYELID_R_B_WJ = 0x1F, - ROB_BONE_N_KUTI_D = 0x20, - ROB_BONE_TL_KUTI_D_WJ = 0x21, - ROB_BONE_N_KUTI_D_L = 0x22, - ROB_BONE_TL_KUTI_D_L_WJ = 0x23, - ROB_BONE_N_KUTI_D_R = 0x24, - ROB_BONE_TL_KUTI_D_R_WJ = 0x25, - ROB_BONE_N_KUTI_DS_L = 0x26, - ROB_BONE_TL_KUTI_DS_L_WJ = 0x27, - ROB_BONE_N_KUTI_DS_R = 0x28, - ROB_BONE_TL_KUTI_DS_R_WJ = 0x29, - ROB_BONE_N_KUTI_L = 0x2A, - ROB_BONE_TL_KUTI_L_WJ = 0x2B, - ROB_BONE_N_KUTI_M_L = 0x2C, - ROB_BONE_TL_KUTI_M_L_WJ = 0x2D, - ROB_BONE_N_KUTI_M_R = 0x2E, - ROB_BONE_TL_KUTI_M_R_WJ = 0x2F, - ROB_BONE_N_KUTI_R = 0x30, - ROB_BONE_TL_KUTI_R_WJ = 0x31, - ROB_BONE_N_KUTI_U = 0x32, - ROB_BONE_TL_KUTI_U_WJ = 0x33, - ROB_BONE_N_KUTI_U_L = 0x34, - ROB_BONE_TL_KUTI_U_L_WJ = 0x35, - ROB_BONE_N_KUTI_U_R = 0x36, - ROB_BONE_TL_KUTI_U_R_WJ = 0x37, - ROB_BONE_N_MABU_L_D_A = 0x38, - ROB_BONE_TL_MABU_L_D_A_WJ = 0x39, - ROB_BONE_N_MABU_L_D_B = 0x3A, - ROB_BONE_TL_MABU_L_D_B_WJ = 0x3B, - ROB_BONE_N_MABU_L_D_C = 0x3C, - ROB_BONE_TL_MABU_L_D_C_WJ = 0x3D, - ROB_BONE_N_MABU_L_U_A = 0x3E, - ROB_BONE_TL_MABU_L_U_A_WJ = 0x3F, - ROB_BONE_N_MABU_L_U_B = 0x40, - ROB_BONE_TL_MABU_L_U_B_WJ = 0x41, - ROB_BONE_N_EYELASHES_L = 0x42, - ROB_BONE_TL_EYELASHES_L_WJ = 0x43, - ROB_BONE_N_MABU_L_U_C = 0x44, - ROB_BONE_TL_MABU_L_U_C_WJ = 0x45, - ROB_BONE_N_MABU_R_D_A = 0x46, - ROB_BONE_TL_MABU_R_D_A_WJ = 0x47, - ROB_BONE_N_MABU_R_D_B = 0x48, - ROB_BONE_TL_MABU_R_D_B_WJ = 0x49, - ROB_BONE_N_MABU_R_D_C = 0x4A, - ROB_BONE_TL_MABU_R_D_C_WJ = 0x4B, - ROB_BONE_N_MABU_R_U_A = 0x4C, - ROB_BONE_TL_MABU_R_U_A_WJ = 0x4D, - ROB_BONE_N_MABU_R_U_B = 0x4E, - ROB_BONE_TL_MABU_R_U_B_WJ = 0x4F, - ROB_BONE_N_EYELASHES_R = 0x50, - ROB_BONE_TL_EYELASHES_R_WJ = 0x51, - ROB_BONE_N_MABU_R_U_C = 0x52, - ROB_BONE_TL_MABU_R_U_C_WJ = 0x53, - ROB_BONE_N_MAYU_L = 0x54, - ROB_BONE_TL_MAYU_L_WJ = 0x55, - ROB_BONE_N_MAYU_L_B = 0x56, - ROB_BONE_TL_MAYU_L_B_WJ = 0x57, - ROB_BONE_N_MAYU_L_C = 0x58, - ROB_BONE_TL_MAYU_L_C_WJ = 0x59, - ROB_BONE_N_MAYU_R = 0x5A, - ROB_BONE_TL_MAYU_R_WJ = 0x5B, - ROB_BONE_N_MAYU_R_B = 0x5C, - ROB_BONE_TL_MAYU_R_B_WJ = 0x5D, - ROB_BONE_N_MAYU_R_C = 0x5E, - ROB_BONE_TL_MAYU_R_C_WJ = 0x5F, - ROB_BONE_N_TOOTH_UPPER = 0x60, - ROB_BONE_TL_TOOTH_UPPER_WJ = 0x61, - ROB_BONE_N_KUBI_WJ_EX = 0x62, - ROB_BONE_N_WAKI_L = 0x63, - ROB_BONE_KL_WAKI_L_WJ = 0x64, - ROB_BONE_TL_UP_KATA_L = 0x65, - ROB_BONE_C_KATA_L = 0x66, - ROB_BONE_KATA_L_WJ_CU = 0x67, - ROB_BONE_UDE_L_WJ = 0x68, - ROB_BONE_KL_TE_L_WJ = 0x69, - ROB_BONE_N_HITO_L_EX = 0x6A, - ROB_BONE_NL_HITO_L_WJ = 0x6B, - ROB_BONE_NL_HITO_B_L_WJ = 0x6C, - ROB_BONE_NL_HITO_C_L_WJ = 0x6D, - ROB_BONE_N_KO_L_EX = 0x6E, - ROB_BONE_NL_KO_L_WJ = 0x6F, - ROB_BONE_NL_KO_B_L_WJ = 0x70, - ROB_BONE_NL_KO_C_L_WJ = 0x71, - ROB_BONE_N_KUSU_L_EX = 0x72, - ROB_BONE_NL_KUSU_L_WJ = 0x73, - ROB_BONE_NL_KUSU_B_L_WJ = 0x74, - ROB_BONE_NL_KUSU_C_L_WJ = 0x75, - ROB_BONE_N_NAKA_L_EX = 0x76, - ROB_BONE_NL_NAKA_L_WJ = 0x77, - ROB_BONE_NL_NAKA_B_L_WJ = 0x78, - ROB_BONE_NL_NAKA_C_L_WJ = 0x79, - ROB_BONE_N_OYA_L_EX = 0x7A, - ROB_BONE_NL_OYA_L_WJ = 0x7B, - ROB_BONE_NL_OYA_B_L_WJ = 0x7C, - ROB_BONE_NL_OYA_C_L_WJ = 0x7D, - ROB_BONE_N_STE_L_WJ_EX = 0x7E, - ROB_BONE_N_SUDE_L_WJ_EX = 0x7F, - ROB_BONE_N_SUDE_B_L_WJ_EX = 0x80, - ROB_BONE_N_HIJI_L_WJ_EX = 0x81, - ROB_BONE_N_UP_KATA_L_EX = 0x82, - ROB_BONE_N_SKATA_L_WJ_CD_EX = 0x83, - ROB_BONE_N_SKATA_B_L_WJ_CD_CU_EX = 0x84, - ROB_BONE_N_SKATA_C_L_WJ_CD_CU_EX = 0x85, - ROB_BONE_N_WAKI_R = 0x86, - ROB_BONE_KL_WAKI_R_WJ = 0x87, - ROB_BONE_TL_UP_KATA_R = 0x88, - ROB_BONE_C_KATA_R = 0x89, - ROB_BONE_KATA_R_WJ_CU = 0x8A, - ROB_BONE_UDE_R_WJ = 0x8B, - ROB_BONE_KL_TE_R_WJ = 0x8C, - ROB_BONE_N_HITO_R_EX = 0x8D, - ROB_BONE_NL_HITO_R_WJ = 0x8E, - ROB_BONE_NL_HITO_B_R_WJ = 0x8F, - ROB_BONE_NL_HITO_C_R_WJ = 0x90, - ROB_BONE_N_KO_R_EX = 0x91, - ROB_BONE_NL_KO_R_WJ = 0x92, - ROB_BONE_NL_KO_B_R_WJ = 0x93, - ROB_BONE_NL_KO_C_R_WJ = 0x94, - ROB_BONE_N_KUSU_R_EX = 0x95, - ROB_BONE_NL_KUSU_R_WJ = 0x96, - ROB_BONE_NL_KUSU_B_R_WJ = 0x97, - ROB_BONE_NL_KUSU_C_R_WJ = 0x98, - ROB_BONE_N_NAKA_R_EX = 0x99, - ROB_BONE_NL_NAKA_R_WJ = 0x9A, - ROB_BONE_NL_NAKA_B_R_WJ = 0x9B, - ROB_BONE_NL_NAKA_C_R_WJ = 0x9C, - ROB_BONE_N_OYA_R_EX = 0x9D, - ROB_BONE_NL_OYA_R_WJ = 0x9E, - ROB_BONE_NL_OYA_B_R_WJ = 0x9F, - ROB_BONE_NL_OYA_C_R_WJ = 0xA0, - ROB_BONE_N_STE_R_WJ_EX = 0xA1, - ROB_BONE_N_SUDE_R_WJ_EX = 0xA2, - ROB_BONE_N_SUDE_B_R_WJ_EX = 0xA3, - ROB_BONE_N_HIJI_R_WJ_EX = 0xA4, - ROB_BONE_N_UP_KATA_R_EX = 0xA5, - ROB_BONE_N_SKATA_R_WJ_CD_EX = 0xA6, - ROB_BONE_N_SKATA_B_R_WJ_CD_CU_EX = 0xA7, - ROB_BONE_N_SKATA_C_R_WJ_CD_CU_EX = 0xA8, - ROB_BONE_KL_KOSI_Y = 0xA9, - ROB_BONE_KL_KOSI_XZ = 0xAA, - ROB_BONE_KL_KOSI_ETC_WJ = 0xAB, - ROB_BONE_CL_MOMO_L = 0xAC, - ROB_BONE_J_MOMO_L_WJ = 0xAD, - ROB_BONE_J_SUNE_L_WJ = 0xAE, - ROB_BONE_KL_ASI_L_WJ_CO = 0xAF, - ROB_BONE_KL_TOE_L_WJ = 0xB0, - ROB_BONE_N_HIZA_L_WJ_EX = 0xB1, - ROB_BONE_CL_MOMO_R = 0xB2, - ROB_BONE_J_MOMO_R_WJ = 0xB3, - ROB_BONE_J_SUNE_R_WJ = 0xB4, - ROB_BONE_KL_ASI_R_WJ_CO = 0xB5, - ROB_BONE_KL_TOE_R_WJ = 0xB6, - ROB_BONE_N_HIZA_R_WJ_EX = 0xB7, - ROB_BONE_N_MOMO_A_L_WJ_CD_EX = 0xB8, - ROB_BONE_N_MOMO_B_L_WJ_EX = 0xB9, - ROB_BONE_N_MOMO_C_L_WJ_EX = 0xBA, - ROB_BONE_N_MOMO_A_R_WJ_CD_EX = 0xBB, - ROB_BONE_N_MOMO_B_R_WJ_EX = 0xBC, - ROB_BONE_N_MOMO_C_R_WJ_EX = 0xBD, - ROB_BONE_N_HARA_CD_EX = 0xBE, - ROB_BONE_N_HARA_B_WJ_EX = 0xBF, - ROB_BONE_N_HARA_C_WJ_EX = 0xC0, - ROB_BONE_MAX = 0xC1, -}; - -enum rob_chara_type { - ROB_CHARA_TYPE_NONE = -1, - ROB_CHARA_TYPE_0 = 0x00, - ROB_CHARA_TYPE_1 = 0x01, - ROB_CHARA_TYPE_2 = 0x02, - ROB_CHARA_TYPE_3 = 0x03, -}; - -enum rob_chara_data_hand_adjust_type : uint16_t { - ROB_CHARA_DATA_HAND_ADJUST_NONE = (uint16_t)-1, - ROB_CHARA_DATA_HAND_ADJUST_NORMAL = 0x00, - ROB_CHARA_DATA_HAND_ADJUST_SHORT = 0x01, - ROB_CHARA_DATA_HAND_ADJUST_TALL = 0x02, - ROB_CHARA_DATA_HAND_ADJUST_MIN = 0x03, - ROB_CHARA_DATA_HAND_ADJUST_MAX = 0x04, - ROB_CHARA_DATA_HAND_ADJUST_OPPOSITE_CHARA = 0x05, - ROB_CHARA_DATA_HAND_ADJUST_CUSTOM = 0x06, - ROB_CHARA_DATA_HAND_ADJUST_1P = 0x07, - ROB_CHARA_DATA_HAND_ADJUST_2P = 0x08, - ROB_CHARA_DATA_HAND_ADJUST_3P = 0x09, - ROB_CHARA_DATA_HAND_ADJUST_4P = 0x0A, - ROB_CHARA_DATA_HAND_ADJUST_ITEM = 0x0F, // X -}; - -enum rob_osage_parts { - ROB_OSAGE_PARTS_NONE = -1, - ROB_OSAGE_PARTS_LEFT = 0x00, - ROB_OSAGE_PARTS_RIGHT = 0x01, - ROB_OSAGE_PARTS_CENTER = 0x02, - ROB_OSAGE_PARTS_LONG_C = 0x03, - ROB_OSAGE_PARTS_SHORT_L = 0x04, - ROB_OSAGE_PARTS_SHORT_R = 0x05, - ROB_OSAGE_PARTS_APPEND_L = 0x06, - ROB_OSAGE_PARTS_APPEND_R = 0x07, - ROB_OSAGE_PARTS_MUFFLER = 0x08, - ROB_OSAGE_PARTS_WHITE_ONE_L = 0x09, - ROB_OSAGE_PARTS_PONY = 0x0A, - ROB_OSAGE_PARTS_ANGEL_L = 0x0B, - ROB_OSAGE_PARTS_ANGEL_R = 0x0C, - ROB_OSAGE_PARTS_MAX = 0x0D, -}; - -enum ExNodeType { - EX_NONE = 0x00, - EX_OSAGE = 0x01, - EX_EXPRESSION = 0x02, - EX_CONSTRAINT = 0x03, - EX_CLOTH = 0x04, -}; - -namespace SkinParam { - enum CollisionType { - CollisionTypeEnd = 0x0, - CollisionTypeBall = 0x1, - CollisionTypeCapsule = 0x2, - CollisionTypePlane = 0x3, - CollisionTypeEllipse = 0x4, - CollisionTypeAABB = 0x5, - CollisionTypeMax = 0x6, - }; - - enum RootCollisionType { - RootCollisionTypeEnd = 0x00, - RootCollisionTypeCapsule = 0x01, - RootCollisionTypeCapsuleWithRoot = 0x02, - RootCollisionTypeMax = 0x03, - }; -} - -struct rob_chara; -struct rob_chara_bone_data; - -struct bone_node_expression_data { - vec3 position; - vec3 rotation; - vec3 scale; - vec3 parent_scale; -}; - -static_assert(sizeof(bone_node_expression_data) == 0x30, "\"bone_node_expression_data\" struct should have a size of 0x30"); - -struct bone_node { - const char* name; - mat4* mat; - bone_node* parent; - bone_node_expression_data exp_data; - mat4* ex_data_mat; -}; - -static_assert(sizeof(bone_node) == 0x50, "\"bone_node\" struct should have a size of 0x50"); - -struct rob_sleeve_data { - float_t radius; - float_t cyofs; - float_t czofs; - float_t ymin; - float_t ymax; - float_t zmin; - float_t zmax; - float_t mune_xofs; - float_t mune_yofs; - float_t mune_zofs; - float_t mune_rad; -}; - -static_assert(sizeof(rob_sleeve_data) == 0x2C, "\"rob_sleeve_data\" struct should have a size of 0x2C"); - -struct eyes_adjust { - bool xrot_adjust; - eyes_base_adjust_type base_adjust; - float_t neg; - float_t pos; -}; - -static_assert(sizeof(eyes_adjust) == 0x10, "\"eyes_adjust\" struct should have a size of 0x10"); - -union rob_chara_pv_data_item { - struct { - int32_t head; - int32_t face; - int32_t chest; - int32_t back; - }; - int32_t arr[4]; -}; - -static_assert(sizeof(rob_chara_pv_data_item) == 0x10, "\"rob_chara_pv_data_item\" struct should have a size of 0x10"); - -struct rob_chara_pv_data { - rob_chara_type type; - bool field_4; - bool field_5; - bool field_6; - vec3 field_8; - int16_t rot_y_int16; - int16_t field_16; - rob_sleeve_data sleeve_l; - rob_sleeve_data sleeve_r; - int32_t field_70; - uint32_t motion_face_ids[10]; - int32_t chara_size_index; - bool height_adjust; - rob_chara_pv_data_item item; - eyes_adjust eyes_adjust; -}; - -static_assert(sizeof(rob_chara_pv_data) == 0xC4, "\"rob_chara_pv_data\" struct should have a size of 0xC4"); - -struct rob_chara_item_equip_object; - -class ExNodeBlock; - -struct ExNodeBlock_vtbl { - ExNodeBlock* (FASTCALL* Dispose)(ExNodeBlock* This, uint8_t); - void(FASTCALL* Field_8)(ExNodeBlock* This); - void(FASTCALL* Field_10)(ExNodeBlock* This); - void(FASTCALL* Field_18)(ExNodeBlock* This, int32_t stage, bool disable_external_force); - void(FASTCALL* Field_20)(ExNodeBlock* This); - void(FASTCALL* SetOsagePlayData)(ExNodeBlock* This); - void(FASTCALL* Disp)(ExNodeBlock* This); - void(FASTCALL* Reset)(ExNodeBlock* This); - void(FASTCALL* Field_40)(ExNodeBlock* This); - void(FASTCALL* Field_48)(ExNodeBlock* This); - void(FASTCALL* Field_50)(ExNodeBlock* This); - void(FASTCALL* Field_58)(ExNodeBlock* This); -}; - -static_assert(sizeof(ExNodeBlock_vtbl) == 0x60, "\"ExNodeBlock_vtbl\" struct should have a size of 0x60"); - -class ExNodeBlock { -public: - ExNodeBlock_vtbl* __vftable; - bone_node* bone_node_ptr; - ExNodeType type; - const char* name; - bone_node* parent_bone_node; - prj::string parent_name; - ExNodeBlock* parent_node; - rob_chara_item_equip_object* item_equip_object; - bool field_58; - bool field_59; - bool has_children_node; -}; - -static_assert(sizeof(ExNodeBlock) == 0x60, "\"ExNodeBlock\" struct should have a size of 0x60"); - -struct RobOsageNode; - -struct RobOsageNodeDataNormalRef { - bool set; - RobOsageNode* n; - RobOsageNode* u; - RobOsageNode* d; - RobOsageNode* l; - RobOsageNode* r; - mat4 mat; -}; - -static_assert(sizeof(RobOsageNodeDataNormalRef) == 0x70, "\"RobOsageNodeDataNormalRef\" struct should have a size of 0x70"); - -struct skin_param_hinge { - float_t ymin; - float_t ymax; - float_t zmin; - float_t zmax; -}; - -static_assert(sizeof(skin_param_hinge) == 0x10, "\"skin_param_hinge\" struct should have a size of 0x10"); - -struct skin_param_osage_node { - float_t coli_r; - float_t weight; - float_t inertial_cancel; - skin_param_hinge hinge; -}; - -static_assert(sizeof(skin_param_osage_node) == 0x1C, "\"skin_param_osage_node\" struct should have a size of 0x1C"); - -struct RobOsageNodeResetData { - vec3 pos; - vec3 delta_pos; - vec3 rotation; - float_t length; -}; - -static_assert(sizeof(RobOsageNodeResetData) == 0x28, "\"RobOsageNodeResetData\" struct should have a size of 0x28"); - -struct skin_param_osage_root; - -struct RobOsageNodeData { - float_t force; - prj::vector boc; - RobOsageNodeDataNormalRef normal_ref; - skin_param_osage_node skp_osg_node; -}; - -static_assert(sizeof(RobOsageNodeData) == 0xB0, "\"RobOsageNodeData\" struct should have a size of 0xB0"); - -struct opd_blend_data { - int32_t motion_id; - float_t frame; - float_t frame_count; - bool use_blend; - MotionBlendType type; - float_t blend; -}; - -static_assert(sizeof(opd_blend_data) == 0x18, "\"opd_blend_data\" struct should have a size of 0x18"); - -struct opd_vec3_data { - const float_t* x; - const float_t* y; - const float_t* z; -}; - -static_assert(sizeof(opd_vec3_data) == 0x18, "\"opd_vec3_data\" struct should have a size of 0x18"); - -struct opd_node_data { - float_t length; - vec3 rotation; -}; - -static_assert(sizeof(opd_node_data) == 0x10, "\"opd_node_data\" struct should have a size of 0x10"); - -struct opd_node_data_pair { - opd_node_data curr; - opd_node_data prev; -}; - -static_assert(sizeof(opd_node_data_pair) == 0x20, "\"opd_node_data_pair\" struct should have a size of 0x20"); - -struct RobOsageNode { - float_t length; - vec3 pos; - vec3 fixed_pos; - vec3 delta_pos; - vec3 vel; - float_t child_length; - bone_node* bone_node_ptr; - mat4* bone_node_mat; - mat4 mat; - RobOsageNode* sibling_node; - float_t max_distance; - vec3 rel_pos; - RobOsageNodeResetData reset_data; - float_t hit; - float_t friction; - vec3 external_force; - float_t force; - RobOsageNodeData* data_ptr; - RobOsageNodeData data; - prj::vector opd_data; - opd_node_data_pair opd_node_data; -}; - -static_assert(sizeof(RobOsageNode) == 0x1D0, "\"RobOsageNode\" struct should have a size of 0x1D0"); - -namespace SkinParam { - struct CollisionParam { - CollisionType type; - int32_t node_idx[2]; - float_t radius; - vec3 pos[2]; - - CollisionParam(); - }; - - static_assert(sizeof(SkinParam::CollisionParam) == 0x28, "\"SkinParam::CollisionParam\" struct should have a size of 0x28"); -}; - -struct skin_param_osage_root_normal_ref { - prj::string n; - prj::string u; - prj::string d; - prj::string l; - prj::string r; -}; - -static_assert(sizeof(skin_param_osage_root_normal_ref) == 0xA0, "\"skin_param_osage_root_normal_ref\" struct should have a size of 0xA0"); - -struct skin_param_osage_root_boc { - int32_t ed_node; - prj::string ed_root; - int32_t st_node; -}; - -static_assert(sizeof(skin_param_osage_root_boc) == 0x30, "\"skin_param_osage_root_boc\" struct should have a size of 0x30"); - -struct skin_param_osage_root { - int32_t field_0; - float_t force; - float_t force_gain; - float_t air_res; - float_t rot_y; - float_t rot_z; - float_t init_rot_y; - float_t init_rot_z; - float_t hinge_y; - float_t hinge_z; - const char* name; - prj::vector coli; - float_t coli_r; - float_t friction; - float_t wind_afc; - int32_t yz_order; - prj::vector boc; - SkinParam::RootCollisionType coli_type; - float_t stiffness; - float_t move_cancel; - prj::string colli_tgt_osg; - prj::vector normal_ref; -}; - -static_assert(sizeof(skin_param_osage_root) == 0xB8, "\"skin_param_osage_root\" struct should have a size of 0xB8"); - -struct skin_param { - prj::vector coli; - float_t friction; - float_t wind_afc; - float_t air_res; - vec3 rot; - vec3 init_rot; - SkinParam::RootCollisionType coli_type; - float_t stiffness; - float_t move_cancel; - float_t coli_r; - skin_param_hinge hinge; - float_t force; - float_t force_gain; - prj::vector* colli_tgt_osg; -}; - -static_assert(sizeof(skin_param) == 0x70, "\"skin_param\" struct should have a size of 0x70"); - -struct OsageCollision { - struct Work { - SkinParam::CollisionType type; - float_t radius; - vec3 pos[2]; - vec3 vec_center; - float_t vec_center_length; - float_t vec_center_length_squared; - float_t friction; - }; - - static_assert(sizeof(OsageCollision::Work) == 0x38, "\"OsageCollision::Work\" struct should have a size of 0x38"); - - prj::vector work_list; -}; - -static_assert(sizeof(OsageCollision) == 0x18, "\"OsageCollision\" struct should have a size of 0x18"); - -struct osage_ring_data { - float_t ring_rectangle_x; - float_t ring_rectangle_y; - float_t ring_rectangle_width; - float_t ring_rectangle_height; - float_t ring_height; - float_t ring_out_height; - bool init; - OsageCollision coli; - prj::vector skp_root_coli; -}; - -static_assert(sizeof(osage_ring_data) == 0x50, "\"OsageCollision\" struct should have a size of 0x50"); - -struct skin_param_file_data; - -struct CLOTHNode { - uint32_t flags; - vec3 pos; - vec3 fixed_pos; - vec3 prev_pos; - vec3 delta_pos; - vec3 normal; - vec3 tangent; - vec3 binormal; - float_t tangent_sign; - vec2 texcoord; - vec3 direction; - float_t dist_up; - float_t dist_down; - float_t dist_right; - float_t dist_left; - vec3 field_80; - RobOsageNodeResetData reset_data; - prj::vector opd_data; - opd_node_data_pair opd_node_data; -}; - -static_assert(sizeof(CLOTHNode) == 0xF0, "\"CLOTHNode\" struct should have a size of 0xF0"); - -struct CLOTHLine { - size_t idx[2]; - float_t length; -}; - -static_assert(sizeof(CLOTHLine) == 0x18, "\"CLOTHLine\" struct should have a size of 0x18"); - -class CLOTH; - -struct CLOTH_vtbl { - CLOTH* (FASTCALL* Dispose)(CLOTH* This, uint8_t); - void(FASTCALL* Field_8)(CLOTH* This); - void(FASTCALL* Field_10)(CLOTH* This); - void(FASTCALL* Field_18)(CLOTH* This, int32_t stage, bool disable_external_force); - void(FASTCALL* Field_20)(CLOTH* This); - void(FASTCALL* SetOsagePlayData)(CLOTH* This); - void(FASTCALL* Disp)(CLOTH* This); - void(FASTCALL* Reset)(CLOTH* This); - void(FASTCALL* Field_40)(CLOTH* This); - void(FASTCALL* Field_48)(CLOTH* This); - void(FASTCALL* Field_50)(CLOTH* This); - void(FASTCALL* Field_58)(CLOTH* This); -}; - -static_assert(sizeof(CLOTH_vtbl) == 0x60, "\"CLOTH_vtbl\" struct should have a size of 0x60"); - -class CLOTH { -public: - CLOTH_vtbl* __vftable; - int32_t field_8; - size_t root_count; - size_t nodes_count; - prj::vector nodes; - vec3 wind_direction; - float_t field_44; - bool set_external_force; - vec3 external_force; - prj::vector lines; - skin_param* skin_param_ptr; - skin_param skin_param; - OsageCollision::Work coli[64]; - OsageCollision::Work coli_ring[64]; - osage_ring_data ring; - mat4* mats; -}; - -static_assert(sizeof(CLOTH) == 0x1D40, "\"CLOTH\" struct should have a size of 0x1D40"); - -struct RobClothRoot { - vec3 pos; - vec3 normal; - vec4 tangent; - bone_node* node[4]; - mat4* node_mat[4]; - mat4* mat[4]; - float_t weight[4]; - mat4 field_98; - mat4 field_D8; - mat4 field_118; -}; - -static_assert(sizeof(RobClothRoot) == 0x158, "\"RobClothRoot\" struct should have a size of 0x158"); - -struct RobClothSubMeshArray { - obj_sub_mesh arr[4]; -}; - -static_assert(sizeof(RobClothSubMeshArray) == 0x1C0, "\"RobClothSubMeshArray\" struct should have a size of 0x1C0"); - -class RobCloth : public CLOTH { -public: - prj::vector root; - rob_chara_item_equip_object* itm_eq_obj; - struct obj_skin_block_cloth_root* cls_root; - struct obj_skin_block_cloth* cls_data; - float_t move_cancel; - bool osage_reset; - obj_mesh mesh[2]; - RobClothSubMeshArray submesh[2]; - obj_axis_aligned_bounding_box axis_aligned_bounding_box; -#if SHARED_OBJECT_BUFFER - obj_mesh_vertex_buffer_aft vertex_buffer[2]; -#else - obj_mesh_vertex_buffer vertex_buffer[2]; -#endif - obj_mesh_index_buffer index_buffer[2]; - prj::map, prj::list> motion_reset_data; - prj::list* reset_data_list; -}; - -static_assert(sizeof(RobCloth) == 0x23C0, "\"RobCloth\" struct should have a size of 0x23C0"); - -class ExClothBlock : public ExNodeBlock { -public: - RobCloth rob; - struct obj_skin_block_cloth* cls_data; - mat4* mats; - size_t index; -}; - -static_assert(sizeof(ExClothBlock) == 0x2438, "\"ExClothBlock\" struct should have a size of 0x2438"); - -struct skin_param_file_data { - skin_param skin_param; - prj::vector nodes_data; - bool field_88; -}; - -static_assert(sizeof(skin_param_file_data) == 0x90, "\"skin_param_file_data\" struct should have a size of 0x90"); - -struct osage_setting_osg_cat { - rob_osage_parts parts; - size_t exf; -}; - -static_assert(sizeof(osage_setting_osg_cat) == 0x10, "\"osage_setting_osg_cat\" struct should have a size of 0x10"); - -struct RobOsage { - skin_param* skin_param_ptr; - bone_node_expression_data exp_data; - prj::vector nodes; - RobOsageNode end_node; - skin_param skin_param; - osage_setting_osg_cat osage_setting; - bool field_2A0; - bool field_2A1; - float_t field_2A4; - OsageCollision::Work coli[64]; - OsageCollision::Work coli_ring[64]; - vec3 wind_direction; - float_t field_1EB4; - int32_t yz_order; - int32_t field_1EBC; - mat4* root_matrix_ptr; - mat4 root_matrix; - float_t move_cancel; - bool field_1F0C; - bool osage_reset; - bool prev_osage_reset; - bool disable_collision; - osage_ring_data ring; - prj::map, prj::list> motion_reset_data; - prj::list* reset_data_list; - bool set_external_force; - vec3 external_force; - - void SetAirRes(float_t air_res); - void SetColiR(float_t coli_r); - void SetForce(float_t force, float_t force_gain); - void SetHinge(float_t hinge_y, float_t hinge_z); - void SetInitRot(float_t init_rot_y, float_t init_rot_z); - void SetMotionResetData(uint32_t motion_id, float_t frame); - void SetNodesExternalForce(vec3* external_force, float_t strength); - void SetNodesForce(float_t force); - void SetRot(float_t rot_y, float_t rot_z); -}; - -static_assert(sizeof(RobOsage) == 0x1F88, "\"RobOsage\" struct should have a size of 0x1F88"); - -class ExOsageBlock : public ExNodeBlock { -public: - size_t index; - RobOsage rob; - mat4* mats; - int32_t field_1FF8; - float_t step; -}; - -static_assert(sizeof(ExOsageBlock) == 0x2000, "\"ExOsageBlock\" struct should have a size of 0x2000"); - -struct rob_chara_item_equip; - -struct rob_chara_item_equip_object { - size_t index; - mat4* mats; - object_info obj_info; - int32_t field_14; - prj::vector texture_pattern; - texture_data_struct texture_data; - bool null_blocks_data_set; - bone_node_expression_data exp_data; - float_t alpha; - mdl::ObjFlags obj_flags; - bool can_disp; - int32_t field_A4; - mat4* mat; - int32_t osage_iterations; - bone_node* bone_nodes; - prj::vector node_blocks; - prj::vector ex_data_bone_nodes; - prj::vector ex_data_bone_mats; - prj::vector ex_data_mats; - prj::vector_pair ex_bones; - int64_t field_138; - prj::vector null_blocks; - prj::vector osage_blocks; - prj::vector constraint_blocks; - prj::vector expression_blocks; - prj::vector cloth_blocks; - bool field_1B8; - size_t osage_nodes_count; - bool use_opd; - obj_skin_ex_data* skin_ex_data; - obj_skin* skin; - rob_chara_item_equip* item_equip; - - void disp(const mat4& mat); - int32_t get_bone_index(const char* name); - bone_node* get_bone_node(int32_t bone_index); - bone_node* get_bone_node(const char* name); - void skp_load(void* can_prop); // CanonicalProperties -}; - -static_assert(sizeof(rob_chara_item_equip_object) == 0x1E8, "\"rob_chara_item_equip_object\" struct should have a size of 0x1E8"); - -struct rob_chara_item_equip { - bone_node* bone_nodes; - mat4* matrices; - rob_chara_item_equip_object* item_equip_object; - int32_t field_18[31]; - bool item_equip_range; - item_id first_item_equip_object; - item_id max_item_equip_object; - int32_t field_A0; - shadow_type_enum shadow_type; - vec3 position; - prj::vector texture_pattern; - object_info field_D0; - item_id field_D4; - bool disable_update; - int32_t field_DC; - vec4 texture_color_coefficients; - float_t wet; - float_t wind_strength; - bool chara_color; - bool npr_flag; - mat4 mat; - mat4 field_13C[30]; - int32_t field_8BC; - int32_t field_8C0; - int32_t field_8C4; - int32_t field_8C8; - int32_t field_8CC; - int32_t field_8D0; - int32_t field_8D4; - int32_t field_8D8; - int32_t field_8DC; - int32_t field_8E0; - int32_t field_8E4; - int32_t field_8E8; - int32_t field_8EC; - int32_t field_8F0; - int32_t field_8F4; - int32_t field_8F8; - int32_t field_8FC; - int64_t field_900; - int64_t field_908; - int64_t field_910; - int64_t field_918; - int64_t field_920; - int64_t field_928; - int64_t field_930; - float_t osage_step; - bool use_opd; - prj::vector opd_blend_data; - bool parts_short; - bool parts_append; - bool parts_white_one_l; - - rob_chara_item_equip_object* get_item_equip_object(item_id id); -}; - -static_assert(sizeof(rob_chara_item_equip) == 0x960, "\"rob_chara_item_equip\" struct should have a size of 0x960"); - -struct item_cos_texture_change_tex { - texture* org; - texture* chg; - bool changed; -}; - -static_assert(sizeof(item_cos_texture_change_tex) == 0x18, "\"rob_chara_item_cos_data\" struct should have a size of 0x18"); - -struct rob_chara_item_cos_data { - ::chara_index chara_index; - ::chara_index chara_index_2nd; - item_cos_data cos; - item_cos_data cos_2nd; - prj::map> texture_change; - prj::map> item_change; - prj::map field_F0; - prj::map field_100; - std::vector texture_pattern[31]; - std::map head_replace; -}; - -static_assert(sizeof(rob_chara_item_cos_data) == 0x408, "\"rob_chara_item_cos_data\" struct should have a size of 0x408"); - -struct struc_264 { - uint8_t data[0x1D8]; -}; - -static_assert(sizeof(struc_264) == 0x1D8, "\"struc_264\" struct should have a size of 0x1D8"); - -struct RobSubAction { - uint8_t data[0xB0]; -}; - -static_assert(sizeof(RobSubAction) == 0xB0, "\"RobSubAction\" struct should have a size of 0xB0"); - -struct struc_389 { - float_t frame; - float_t prev_frame; - float_t last_set_frame; -}; - -static_assert(sizeof(struc_389) == 0x0C, "\"struc_389\" struct should have a size of 0x0C"); - -struct struc_406 { - float_t frame; - float_t field_4; - float_t step; -}; - -static_assert(sizeof(struc_406) == 0x0C, "\"struc_406\" struct should have a size of 0x0C"); - -struct rob_chara_data_hand_adjust { - bool enable; - int16_t scale_select; - rob_chara_data_hand_adjust_type type; - float_t current_scale; - float_t scale; - float_t duration; - float_t current_time; - float_t rotation_blend; - float_t scale_blend; - bool enable_scale; - bool disable_x; - bool disable_y; - bool disable_z; - vec3 offset; - vec3 field_30; - float_t arm_length; - int32_t field_40; -}; - -static_assert(sizeof(rob_chara_data_hand_adjust) == 0x44, "\"rob_chara_data_hand_adjust\" struct should have a size of 0x44"); - -struct rob_chara_motion { - uint32_t motion_id; - uint32_t prev_motion_id; - struc_389 frame_data; - struc_406 step_data; - uint8_t data[0x1198]; - rob_chara_data_hand_adjust hand_adjust[2]; - rob_chara_data_hand_adjust hand_adjust_prev[2]; - uint8_t data1[0x30]; -}; - -static_assert(sizeof(rob_chara_motion) == 0x12F8, "\"rob_chara_motion\" struct should have a size of 0x12F8"); - -struct struc_526 { - int32_t field_0; - int32_t field_4; -}; - -struct struc_228 { - int32_t field_0; - int32_t field_4; - uint32_t field_8; - int32_t field_C; -}; - -struct struc_227 { - int32_t field_0; - float_t field_4; - float_t field_8; -}; - -struct struc_652 { - int32_t motion_id; - float_t frame_count; - float_t frame; - int16_t field_C; - struc_228 field_10; - struc_228 field_20; - struc_228 field_30; - struc_228 field_40; - int16_t field_50; - int16_t field_52; - int16_t field_54; - int32_t field_58; - int32_t field_5C; - int32_t field_60; - int32_t field_64; - int32_t field_68; - int32_t loop_count; - float_t loop_begin; - float_t loop_end; - float_t field_78; - float_t field_7C; - float_t field_80; - int8_t field_84; - int32_t field_88; - int32_t field_8C; - int32_t field_90; - int16_t field_94; - int16_t field_96; - int16_t field_98; - int32_t field_9C; - int16_t field_A0; - int32_t field_A4; - int64_t field_A8; - struc_227 field_B0[26]; - int32_t field_1E8; - float_t field_1EC; - float_t field_1F0; - float_t field_1F4; - float_t field_1F8; - float_t field_1FC; - float_t field_200; - int32_t field_204; - int32_t field_208; - int32_t field_20C; - int64_t field_210; - float_t field_218; - float_t field_21C; - int16_t field_220; - prj::list field_228; - int16_t field_238; - float_t field_23C; - int32_t field_240; - int16_t field_244; - const void* field_248; - int64_t field_250; - float_t field_258; - int32_t field_25C; - struc_526 field_260; - struc_526 field_268; - int32_t field_270; - int16_t field_274; - int16_t field_276; - int32_t field_278; - int32_t field_27C; - int32_t field_280; - int16_t field_284; - int64_t field_288; - int32_t field_290; - int32_t field_294; - int32_t field_298; - float_t field_29C; - int8_t field_2A0; - float_t field_2A4; - float_t field_2A8; - float_t field_2AC; - int64_t field_2B0; - int16_t field_2B8; - int32_t field_2BC; - float_t field_2C0; - float_t field_2C4; - int32_t field_2C8; - int32_t field_2CC; - int64_t field_2D0; - int64_t field_2D8; - int64_t field_2E0; - int16_t field_2E8; - int32_t field_2EC; - int32_t field_2F0; - struc_526 field_2F4; - int32_t field_2FC; - int8_t field_300; - int32_t field_304; - int32_t field_308; - float_t field_30C; - int32_t field_310; - int16_t field_314; - vec3 field_318; - float_t field_324; - float_t field_328; - int32_t iterations; -}; - -struct struc_377 { - struct mothead_data* current; - struct mothead_data* data; -}; - -struct struc_226 { - int8_t field_0[27]; -}; - -struct struc_225 { - float_t field_0[27]; -}; - -struct struc_224 { - int32_t field_0[27]; -}; - -struct struc_306 { - int16_t field_0; - float_t frame; - float_t field_8; - int16_t field_C; - int16_t field_E; - vec3 field_10; - vec3 field_1C; - vec3 field_28; - int32_t field_34; - int32_t field_38; - int32_t field_3C; - int32_t field_40; - int32_t field_44; - int32_t field_48; -}; - -struct struc_651 { - struc_377 field_0; - int32_t field_10; - int32_t field_14; - int32_t field_18; - float_t field_1C; - vec3 field_20; - struc_226 field_2C[3]; - struc_225 field_80[3]; - struc_224 field_1C4[3]; - int64_t field_308; - float_t field_310; - float_t field_314; - int8_t field_318; - int32_t field_31C; - float_t field_320; - float_t field_324; - float_t field_328; - float_t field_32C; - float_t field_330; - float_t field_334; - int8_t field_338; - struc_306 field_33C[4]; -}; - -struct struc_223 { - struc_652 field_0; - struc_651 field_330; - int64_t* field_7A0; - int32_t motion_set_id; -}; - -static_assert(sizeof(struc_223) == 0x7B0, "\"struc_223\" struct should have a size of 0x7B0"); - -struct rob_chara_data_miku_rot { - uint8_t data[0xAC]; -}; - -static_assert(sizeof(rob_chara_data_miku_rot) == 0xAC, "\"rob_chara_data_miku_rot\" struct should have a size of 0xAC"); - -struct rob_chara_adjust_data { - float_t scale; - bool height_adjust; - float_t pos_adjust_y; - vec3 pos_adjust; - vec3 offset; - bool offset_x; - bool offset_y; - bool offset_z; - bool get_global_position; - vec3 pos; - mat4 mat; - float_t left_hand_scale; - float_t right_hand_scale; - float_t left_hand_scale_default; - float_t right_hand_scale_default; -}; - -static_assert(sizeof(rob_chara_adjust_data) == 0x84, "\"rob_chara_adjust_data\" struct should have a size of 0x84"); - -struct struc_209 { - uint8_t data[0x1F28]; -}; - -static_assert(sizeof(struc_209) == 0x1F28, "\"struc_209\" struct should have a size of 0x1F28"); - -struct rob_chara_data { - uint8_t field_0; - uint8_t field_1; - uint8_t field_2; - uint8_t field_3; - int32_t field_4; - struc_264 field_8; - RobSubAction rob_sub_action; - rob_chara_motion motion; - struc_223 field_1588; - rob_chara_data_miku_rot miku_rot; - rob_chara_adjust_data adjust_data; - struc_209 field_1E68; - float_t field_3D90; - int32_t field_3D94; - int16_t field_3D98; - int16_t field_3D9A; - int32_t field_3D9C; - int32_t field_3DA0; - int8_t field_3DA4; - int64_t field_3DA8; - int64_t field_3DB0; - int32_t field_3DB8; - int32_t field_3DBC; - int32_t field_3DC0; - int32_t field_3DC4; - int32_t field_3DC8; - int32_t field_3DCC; - int32_t field_3DD0; - float_t field_3DD4; - int32_t field_3DD8; - float_t field_3DDC; - int8_t field_3DE0; -}; - -static_assert(sizeof(rob_chara_data) == 0x3DE8, "\"rob_chara_data\" struct should have a size of 0x3DE8"); - -struct rob_touch { - uint8_t data[0x28]; -}; - -static_assert(sizeof(rob_touch) == 0x28, "\"rob_touch\" struct should have a size of 0x28"); - -struct rob_chara { - int8_t chara_id; - int8_t field_1; - int8_t field_2; - int8_t field_3; - int32_t type; - int16_t field_8; - int16_t field_A; - bool field_C; - bool field_D; - chara_index chara_index; - int32_t cos_id; - int32_t field_18; - float_t frame_speed; - void* field_20; - struct rob_chara_bone_data* bone_data; - rob_chara_item_equip* item_equip; - rob_chara_item_cos_data item_cos_data; - rob_chara_data data; - rob_chara_data data_prev; - struct chara_init_data* chara_init_data; - struct rob_detail* rob_detail; - rob_chara_pv_data pv_data; - int32_t field_80E4; - rob_touch rob_touch; - - inline bool is_visible() { - return !!(data.field_0 & 0x01); - } -}; - -static_assert(sizeof(rob_chara) == 0x8110, "\"rob_chara\" struct should have a size of 0x8110"); - -#define ROB_CHARA_COUNT 6 - -extern const mat4* (FASTCALL* rob_chara_bone_data_get_mats_mat)(size_t rob_bone_data, size_t index); -extern bool (FASTCALL* pv_osage_manager_array_get_disp)(int32_t* chara_id); -extern const char* (FASTCALL* chara_index_get_auth_3d_name)(chara_index chara_index); -extern void(FASTCALL* sub_1405163C0)(rob_chara* rob_chr, int32_t index, mat4* mat); -extern float_t(FASTCALL* rob_chara_get_max_face_depth)(rob_chara* rob_chr); -extern const mat4* (FASTCALL* rob_chara_get_bone_data_mat)(rob_chara* rob_chr, mot_bone_index index); -extern const mat4* (FASTCALL* sub_140516740)(rob_chara* rob_chr); -extern bool(FASTCALL* rob_chara_array_check_visibility)(size_t rob_chr_smth, int32_t chara_id); -extern rob_chara* (FASTCALL* rob_chara_array_get)(size_t rob_chr_smth, int32_t chara_id); -extern size_t(FASTCALL* get_rob_chara_smth)(); -extern rob_chara_item_equip* (FASTCALL* rob_chara_array_get_item_equip)(size_t rob_chr_smth, int32_t chara_id); -extern size_t(FASTCALL* rob_chara_array_get_bone_data)(size_t rob_chr_smth, int32_t chara_id); -extern bool (FASTCALL* rob_chara_pv_data_array_check_chara_id)(size_t rob_chr_smth, int32_t chara_id); +#include "../../AFTModsShared/rob/rob.hpp" extern const mat4* rob_chara_item_equip_mat; -extern const mat4* rob_chara_get_adjust_data_mat(rob_chara* rob_chr); extern const mat4* rob_chara_get_item_adjust_data_mat(rob_chara* rob_chr); extern void rob_patch(); diff --git a/src/DivaGL/screen_shot.hpp b/src/DivaGL/screen_shot.hpp index e1cff6c..b71315e 100644 --- a/src/DivaGL/screen_shot.hpp +++ b/src/DivaGL/screen_shot.hpp @@ -5,6 +5,6 @@ #pragma once -#include "types.hpp" +#include "../AFTModsShared/types.hpp" extern void screen_shot_patch(); diff --git a/src/DivaGL/shader.hpp b/src/DivaGL/shader.hpp index ac91761..d5d4e95 100644 --- a/src/DivaGL/shader.hpp +++ b/src/DivaGL/shader.hpp @@ -11,8 +11,8 @@ #include "../KKdLib/farc.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/uniform.hpp" #include "gl.hpp" -#include "uniform.hpp" struct shader_sub_table { uint32_t sub_index; diff --git a/src/DivaGL/shader_ft.cpp b/src/DivaGL/shader_ft.cpp index 57a6f4a..e3a0f81 100644 --- a/src/DivaGL/shader_ft.cpp +++ b/src/DivaGL/shader_ft.cpp @@ -5,9 +5,9 @@ #include "shader_ft.hpp" #include "../KKdLib/str_utils.hpp" +#include "../AFTModsShared/uniform.hpp" #include "gl_state.hpp" #include "render_context.hpp" -#include "uniform.hpp" enum shader_ft_sub_enum { SHADER_FT_SUB_SHADER_FFP = 0, @@ -1348,6 +1348,75 @@ const shader_bind_func shader_ft_bind_func_table[] = { const size_t shader_ft_bind_func_table_size = sizeof(shader_ft_bind_func_table) / sizeof(shader_bind_func); +const int32_t shader_ft_shader_name_map_table[] = { + SHADER_FT_FFP, + SHADER_FT_BLINN, + SHADER_FT_ITEM, + SHADER_FT_STAGE, + SHADER_FT_SKIN, + SHADER_FT_SSS_SKIN, + SHADER_FT_SSS_FILT, + SHADER_FT_HAIR, + SHADER_FT_CLOTH, + SHADER_FT_TIGHTS, + SHADER_FT_SKY, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_GLASEYE, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_ESMGAUSS, + SHADER_FT_ESMFILT, + SHADER_FT_LITPROJ, + SHADER_FT_SIMPLE, + SHADER_FT_SIL, + SHADER_FT_LAMBERT, + SHADER_FT_CONSTANT, + SHADER_FT_FFP, + SHADER_FT_TONEMAP, + SHADER_FT_REDUCE, + SHADER_FT_MAGNIFY, + SHADER_FT_MLAA, + SHADER_FT_CONTOUR, + SHADER_FT_EXPOSURE, + SHADER_FT_GAUSS, + SHADER_FT_SUN, + SHADER_FT_FFP, + SHADER_FT_WATER01, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_W_PTCL, + SHADER_FT_SNOW_PT, + SHADER_FT_LEAF_PT, + SHADER_FT_STAR, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_FLOOR, + SHADER_FT_PUDDLE, + SHADER_FT_S_REFL, + SHADER_FT_S_REFR, + SHADER_FT_RIPEMIT, + SHADER_FT_RAIN, + SHADER_FT_FFP, + SHADER_FT_FFP, + SHADER_FT_RIPPLE, + SHADER_FT_FOGPTCL, + SHADER_FT_PARTICL, + SHADER_FT_GLITTER_PT, + SHADER_FT_FFP, + SHADER_FT_FONT, + SHADER_FT_FFP, + SHADER_FT_IMGFILT, + SHADER_FT_SPRITE, + SHADER_FT_FFP, +}; + +const size_t shader_ft_shader_name_map_table_size = + sizeof(shader_ft_shader_name_map_table) / sizeof(int32_t); + shader_set_data shaders_ft; static glass_eye_struct glass_eye = { diff --git a/src/DivaGL/shader_ft.hpp b/src/DivaGL/shader_ft.hpp index e9643b1..aa1fa68 100644 --- a/src/DivaGL/shader_ft.hpp +++ b/src/DivaGL/shader_ft.hpp @@ -66,6 +66,8 @@ extern const shader_table shader_ft_table[]; extern const size_t shader_ft_table_size; extern const shader_bind_func shader_ft_bind_func_table[]; extern const size_t shader_ft_bind_func_table_size; +extern const int32_t shader_ft_shader_name_map_table[]; +extern const size_t shader_ft_shader_name_map_table_size; extern shader_set_data shaders_ft; diff --git a/src/DivaGL/shadow.cpp b/src/DivaGL/shadow.cpp index f6ada16..0ea15c3 100644 --- a/src/DivaGL/shadow.cpp +++ b/src/DivaGL/shadow.cpp @@ -4,6 +4,7 @@ */ #include "shadow.hpp" +#include "../AFTModsShared/light_param/light.hpp" #include "render_context.hpp" #include "render_manager.hpp" #include diff --git a/src/DivaGL/shadow.hpp b/src/DivaGL/shadow.hpp index b84c27c..521f078 100644 --- a/src/DivaGL/shadow.hpp +++ b/src/DivaGL/shadow.hpp @@ -9,15 +9,10 @@ #include "../KKdLib/time.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/shadow.hpp" +#include "../AFTModsShared/types.hpp" #include "render_texture.hpp" #include "shared.hpp" -#include "types.hpp" - -enum shadow_type_enum { - SHADOW_CHARA = 0, - SHADOW_STAGE, - SHADOW_MAX, -}; struct Shadow { void* __vftable; diff --git a/src/DivaGL/sprite.cpp b/src/DivaGL/sprite.cpp index cd68dbb..864031f 100644 --- a/src/DivaGL/sprite.cpp +++ b/src/DivaGL/sprite.cpp @@ -112,29 +112,12 @@ namespace spr { static void draw_sprite_scale(spr::SprArgs* args); } -vec4& spr_color = *(vec4*)0x00000001411ACC30; - -void (FASTCALL* sprite_manager_unload_set)(int32_t set_id) - = (void (FASTCALL*)(int32_t set_id))0x000000014063F8D0; -size_t(FASTCALL* sprite_manager_get_reqlist_count)(int32_t index) - = (size_t(FASTCALL*)(int32_t index))0x000000014063FA90; -void (FASTCALL* sprite_manager_read_file)(int32_t set_id, const prj::string mdata_dir) - = (void (FASTCALL*)(int32_t set_id, const prj::string mdata_dir))0x0000000140640E10; -bool (FASTCALL* sprite_manager_load_file)(int32_t set_id) - = (bool (FASTCALL*)(int32_t set_id))0x0000000140640FB0; - spr::SpriteManager* sprite_manager = (spr::SpriteManager*)0x000000014CC611C0; -spr::SpriteVertexData& sprite_vertex_data = *(spr::SpriteVertexData*)0x000000014CC62480; - -const size_t sprite_vertex_array_max_count = 0x2000; -spr::SpriteVertex* sprite_vertex_array = (spr::SpriteVertex*)0x000000014CC62480; - -size_t& sprite_vertex_array_count = *(size_t*)0x000000014CC611B0; - static mat4 view_projection_aet; -static bool break_sprite_vertex_limit = false; +extern bool sprite_break_sprite_vertex_limit; + static spr::SpriteManager::RenderData* sprite_manager_render_data; static const GLenum spr_blend_param[6][4] = { @@ -147,207 +130,6 @@ static const GLenum spr_blend_param[6][4] = { }; namespace spr { - void(FASTCALL* put_cross)(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z) - = (void(FASTCALL*)(const mat4 & mat, color4u8 color_x, color4u8 color_y, color4u8 color_z))0x00000001404BC920; - void(FASTCALL* put_rgb_cross)(const mat4& mat) = (void(FASTCALL*)(const mat4 & mat))0x00000001404BC8F0; - spr::SprArgs* (FASTCALL* put_sprite)(const spr::SprArgs& args) - = (spr::SprArgs * (FASTCALL*)(const spr::SprArgs & args))0x0000000140640740; - - SprArgs::SprArgs() : kind(), attr(), blend(), index(), layer(), - prio(), resolution_mode_screen(), resolution_mode_sprite(), texture(), - shader(), vertex_array(), num_vertex(), flags(), field_CC(), next() { - Reset(); - } - - SpriteVertex* SprArgs::GetVertexArray() { - if (break_sprite_vertex_limit) - return sprite_vertex_data.array + vertex_array; - else - return vertex_array_ptr; - } - - void SprArgs::Reset() { - kind = SPR_KIND_NORMAL; - id = {}; - color = 0xFFFFFFFF; - attr = (SprAttr)0; - blend = 0; - index = -1; - layer = 0; - prio = SPR_PRIO_DEFAULT; - resolution_mode_screen = RESOLUTION_MODE_HD; - resolution_mode_sprite = RESOLUTION_MODE_HD; - center = 0.0f; - trans = 0.0f; - scale = 1.0f; - rot = 0.0f; - skew_angle = 0.0f; - mat = mat4_identity; - texture = 0; - shader = SHADER_FT_FFP; - if (break_sprite_vertex_limit) - vertex_array = -1; - else - vertex_array = 0; - num_vertex = 0; - flags = (SprArgs::Flags)0; - sprite_size = 0.0f; - field_CC = 0; - texture_pos = 0.0f; - texture_size = 1.0f; - next = 0; - } - - void SprArgs::SetSpriteSize(vec2 size) { - if (flags & SPRITE_SIZE) - return; - - enum_or(flags, SPRITE_SIZE); - sprite_size = size; - field_CC = 0; - } - - void SprArgs::SetTexturePosSize(float_t x, float_t y, float_t width, float_t height) { - if (flags & TEXTURE_POS_SIZE) - return; - - enum_or(flags, TEXTURE_POS_SIZE); - texture_pos.x = x; - texture_pos.y = y; - texture_size.x = width; - texture_size.y = height; - } - - void SprArgs::SetVertexArray(SpriteVertex* vertex_array, size_t num_vertex) { - void (FASTCALL * spr__SprArgs__SetVertexArray)(spr::SprArgs * This, - spr::SpriteVertex * vertex_array, size_t num_vertex) - = (void (FASTCALL*)(spr::SprArgs * This, - spr::SpriteVertex * vertex_array, size_t num_vertex))0x000000014063F040; - spr__SprArgs__SetVertexArray(this, vertex_array, num_vertex); - } - - void SprArgs::SetNext(SprArgs* args, SprArgs* next) { - while (args->next) - args = args->next; - args->next = next; - next->kind = SPR_KIND_LINE; - } - - vec2 proj_sprite_3d_line(vec3 vec, bool offset) { - mat4 view; - mat4_transpose(&camera_data.view, &view); - - mat4_transform_point(&view, &vec, &vec); - if (fabsf(vec.z) < 1.0e-10f) - return 0.0f; - - vec2 sc_vec = camera_data.depth * *(vec2*)&vec.x * (1.0f / vec.z); - - resolution_struct* res_wind_int = res_window_internal_get(); - sc_vec.x = (float_t)res_wind_int->width * 0.5f - sc_vec.x; - sc_vec.y = (float_t)res_wind_int->height * 0.5f + sc_vec.y; - if (offset) { - resolution_struct* res_wind = res_window_get(); - sc_vec.x = (float_t)res_wind_int->x_offset + sc_vec.x; - sc_vec.y = (float_t)(res_wind->height - - res_wind_int->y_offset - res_wind_int->height) + sc_vec.y; - } - return sc_vec; - } - - void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color) { - vec2 sc_p1 = proj_sprite_3d_line(p1, true); - vec2 sc_p2 = proj_sprite_3d_line(p2, true); - spr::put_sprite_line(sc_p1, sc_p2, RESOLUTION_MODE_MAX, SPR_PRIO_DEBUG, color, 0); - } - - void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { - spr::SprArgs args; - args.trans.x = p1.x; - args.trans.y = p1.y; - args.trans.z = 0.0f; - args.layer = layer; - args.kind = SPR_KIND_LINES; - args.resolution_mode_screen = mode; - args.resolution_mode_sprite = mode; - args.prio = prio; - args.color = color; - args.SetSpriteSize({ p2.x - p1.x, p2.y - p1.y }); - enum_or(args.attr, SPR_ATTR_MATRIX); - spr::put_sprite(args); - } - - void put_sprite_line_list(vec2* points, size_t count, resolution_mode mode, - spr::SprPrio prio, color4u8 color, int32_t layer) { - spr::SprArgs args; - args.kind = SPR_KIND_ARROW_AB; - args.layer = layer; - args.resolution_mode_screen = mode; - args.resolution_mode_sprite = mode; - args.prio = prio; - args.color = color; - - std::vector vertex_array; - vertex_array.reserve(count); - - for (size_t i = 0; i < count; i++, points++) { - spr::SpriteVertex vert = {}; - *(vec2*)&vert.pos = *points; - vertex_array.push_back(vert); - } - - args.SetVertexArray(vertex_array.data(), vertex_array.size()); - spr::put_sprite(args); - } - - void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { - spr::SprArgs args; - args.trans.x = rect.pos.x; - args.trans.y = rect.pos.y; - args.trans.z = 0.0f; - args.layer = layer; - args.kind = SPR_KIND_MULTI; - args.resolution_mode_screen = mode; - args.resolution_mode_sprite = mode; - args.prio = prio; - args.color = color; - args.SetSpriteSize(rect.size); - enum_or(args.attr, SPR_ATTR_MATRIX); - spr::put_sprite(args); - } - - void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer) { - spr::SprArgs args; - args.trans.x = rect.pos.x; - args.trans.y = rect.pos.y; - args.trans.z = 0.0f; - args.layer = layer; - args.kind = SPR_KIND_RECT; - args.resolution_mode_screen = mode; - args.resolution_mode_sprite = mode; - args.prio = prio; - args.color = color; - args.SetSpriteSize(rect.size); - enum_or(args.attr, SPR_ATTR_MATRIX); - spr::put_sprite(args); - } - - void put_sprite_triangles(SpriteVertex* vert, size_t num, resolution_mode mode, - SprPrio prio, int32_t spr_id, int32_t layer) { - spr::SprArgs args; - args.layer = layer; - args.kind = SPR_KIND_TRIANGLE; - args.resolution_mode_screen = mode; - args.resolution_mode_sprite = mode; - args.prio = prio; - args.color = vert[0].color; - if (spr_id != -1) - args.id.info = sprite_database_get_spr_by_id(spr_id)->info; - enum_or(args.attr, SPR_ATTR_MATRIX); - args.SetVertexArray(vert, num); - spr::put_sprite(args); - } - SpriteManager::RenderData::RenderData() { glGenVertexArrays(1, &vao); gl_state_bind_vertex_array(vao, true); @@ -899,7 +681,7 @@ namespace spr { } } - draw_param.shader = args.shader; + draw_param.shader = shader_ft_shader_name_map_table[args.shader]; if (draw_param.shader == SHADER_FT_FFP) { draw_param.shader = SHADER_FT_SPRITE; draw_param.tex_0_type = 0; @@ -1398,32 +1180,7 @@ namespace spr { } } -const spr_db_spr* sprite_database_get_spr_by_id(int32_t id) { - const spr_db_spr* (FASTCALL* sprite_database_struct__get_spr_by_id) - (size_t _this, int32_t id) - = (const spr_db_spr * (FASTCALL*)(size_t _this, int32_t id))0x000000014063C800; - return sprite_database_struct__get_spr_by_id(0x000000014CC62290, id); -} - -int32_t sprite_database_get_spr_set_id_by_name(const prj::string& name) { - int32_t(FASTCALL * sprite_database_struct__get_spr_set_id_by_name) - (size_t _this, const prj::string & name) - = (int32_t(FASTCALL*)(size_t _this, const prj::string & name))0x00000001401121A0; - return sprite_database_struct__get_spr_set_id_by_name(0x000000014CC62290, name); -} - void sprite_manager_init() { - const uint8_t orig_spr__SprArgs__SetVertexArray[] = { - 0x40, 0x53, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x8B, - 0x05, 0x63, 0x21, 0x62, 0x0C, 0x4C, 0x8B, 0xC9, - }; - - if (memcmp((void*)0x000000014063F040, (void*)orig_spr__SprArgs__SetVertexArray, - sizeof(orig_spr__SprArgs__SetVertexArray))) - break_sprite_vertex_limit = true; - else - break_sprite_vertex_limit = false; - if (!sprite_manager_render_data) sprite_manager_render_data = new spr::SpriteManager::RenderData; } diff --git a/src/DivaGL/sprite.hpp b/src/DivaGL/sprite.hpp index 4996738..16a98d6 100644 --- a/src/DivaGL/sprite.hpp +++ b/src/DivaGL/sprite.hpp @@ -9,285 +9,9 @@ #include "../KKdLib/mat.hpp" #include "../KKdLib/rectangle.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/sprite.hpp" #include "render_context.hpp" -#include "resolution_mode.hpp" #include "texture.hpp" -#include "types.hpp" - -struct spr_info { - uint16_t index; - uint16_t set_index; - - inline spr_info() { - this->index = (uint16_t)-1; - this->set_index = (uint16_t)-1; - } - - inline spr_info(uint16_t index, uint16_t set_index) { - this->index = index; - this->set_index = set_index; - } - - inline bool is_null() const { - return index == (uint16_t)-1 && set_index == (uint16_t)-1; - } - - inline bool not_null() const { - return index != (uint16_t)-1 || set_index != (uint16_t)-1; - } -}; - -constexpr bool operator==(const spr_info& left, const spr_info& right) { - return *(uint32_t*)&left == *(uint32_t*)&right; -} - -constexpr bool operator!=(const spr_info& left, const spr_info& right) { - return !(left == right); -} - -constexpr bool operator<(const spr_info& left, const spr_info& right) { - return *(uint32_t*)&left < *(uint32_t*)&right; -} - -constexpr bool operator>(const spr_info& left, const spr_info& right) { - return right < left; -} - -constexpr bool operator<=(const spr_info& left, const spr_info& right) { - return !(right < left); -} - -constexpr bool operator>=(const spr_info& left, const spr_info& right) { - return !(left < right); -} - -struct spr_db_spr { - uint32_t id; - prj::string name; - spr_info info; -}; - -struct SpriteHeaderFile { - uint32_t flag; - uint32_t texofs; - int32_t num_of_texture; - int32_t num_of_sprite; - uint32_t sprinfo_offset; - uint32_t texname_offset; - uint32_t sprname_offset; - uint32_t sprdata_offset; -}; - -namespace spr { - struct SprInfo { - uint32_t texid; - int32_t rotate; - float_t su; - float_t sv; - float_t eu; - float_t ev; - float_t px; - float_t py; - float_t width; - float_t height; - }; -}; - -struct SpriteData { - uint32_t attr; - resolution_mode resolution_mode; -}; - -struct SpriteHeader { - uint32_t flag; - uint32_t texofs; - int32_t num_of_texture; - int32_t num_of_sprite; - spr::SprInfo* sprinfo; - const char** texname; - const char** sprname; - SpriteData* sprdata; -}; - -struct SprSet { - void* vftable; - int32_t flag; - int32_t index; - SpriteHeaderFile* header_file; - SpriteHeader* header; - texture** textures; - int32_t load_count; - void* file_handler; - bool ready; - prj::shared_ptr alloc_handler; // prj::stack_allocator - prj::string file; -}; - -namespace spr { - enum SprAttr : uint32_t { - SPR_ATTR_FLIP_H = 0x00010000, - SPR_ATTR_FLIP_V = 0x00020000, - SPR_ATTR_CTR_LT = 0x00040000, - SPR_ATTR_CTR_CT = 0x00080000, - SPR_ATTR_CTR_RT = 0x00100000, - SPR_ATTR_CTR_LC = 0x00200000, - SPR_ATTR_CTR_CC = 0x00400000, - SPR_ATTR_CTR_RC = 0x00800000, - SPR_ATTR_CTR_LB = 0x01000000, - SPR_ATTR_CTR_CB = 0x02000000, - SPR_ATTR_CTR_RB = 0x04000000, - SPR_ATTR_MATRIX = 0x08000000, - SPR_ATTR_10000000 = 0x10000000, - SPR_ATTR_NOBLEND = 0x20000000, - - SPR_ATTR_CTR = 0x07FC0000, - }; - - enum SprKind { - SPR_KIND_NORMAL = 0, - SPR_KIND_LINE, - SPR_KIND_LINES, - SPR_KIND_RECT, - SPR_KIND_MULTI, - SPR_KIND_ARROW_A, - SPR_KIND_ARROW_B, - SPR_KIND_ARROW_AB, - SPR_KIND_TRIANGLE, - SPR_KIND_CIRCLE, - }; - - enum SprPrio { - SPR_PRIO_00 = 0, - SPR_PRIO_01, - SPR_PRIO_02, - SPR_PRIO_03, - SPR_PRIO_04, - SPR_PRIO_05, - SPR_PRIO_06, - SPR_PRIO_07, - SPR_PRIO_08, - SPR_PRIO_09, - SPR_PRIO_10, - SPR_PRIO_11, - SPR_PRIO_12, - SPR_PRIO_13, - SPR_PRIO_14, - SPR_PRIO_15, - SPR_PRIO_16, - SPR_PRIO_17, - SPR_PRIO_18, - SPR_PRIO_19, - SPR_PRIO_20, - SPR_PRIO_21, - SPR_PRIO_22, - SPR_PRIO_23, - SPR_PRIO_24, - SPR_PRIO_25, - SPR_PRIO_26, - SPR_PRIO_27, - SPR_PRIO_28, - SPR_PRIO_29, - SPR_PRIO_30, - SPR_PRIO_31, - SPR_PRIO_MAX, - - SPR_PRIO_BACKGROUND = SPR_PRIO_03, - SPR_PRIO_DEFAULT = SPR_PRIO_07, - SPR_PRIO_DEBUG = SPR_PRIO_29, - }; - - struct SpriteVertex { - vec3 pos; - vec2 uv; - color4u8 color; - }; - - struct SprArgs { - enum Flags : uint32_t { - SPRITE_SIZE = 0x01, - TEXTURE_POS_SIZE = 0x02, - }; - - union IDUnion { - int32_t index; - uint32_t id; - spr_info info; - - IDUnion() { - index = -1; - id = -1; - info = {}; - } - }; - - SprKind kind; - IDUnion id; - color4u8_bgra color; - SprAttr attr; - int32_t blend; - int32_t index; - int32_t layer; - SprPrio prio; - resolution_mode resolution_mode_screen; - resolution_mode resolution_mode_sprite; - vec3 center; - vec3 trans; - vec3 scale; - vec3 rot; - vec2 skew_angle; - mat4 mat; - texture* texture; - int32_t shader; - union { - size_t vertex_array; - SpriteVertex* vertex_array_ptr; - }; - size_t num_vertex; - Flags flags; - vec2 sprite_size; - int32_t field_CC; - vec2 texture_pos; - vec2 texture_size; - spr::SprArgs* next; - - SprArgs(); - - SpriteVertex* GetVertexArray(); - void Reset(); - void SetSpriteSize(vec2 size); - void SetTexturePosSize(float_t x, float_t y, float_t width, float_t height); - void SetVertexArray(SpriteVertex* vertex_array, size_t num_vertex); - - static void SetNext(SprArgs* args, SprArgs* next); - }; - - static_assert(sizeof(spr::SprArgs) == 0xE8, "\"spr::SprArgs\" struct should have a size of 0xE8"); - - extern void(FASTCALL* put_cross)(const mat4& mat, color4u8 color_x, color4u8 color_y, color4u8 color_z); - extern void(FASTCALL* put_rgb_cross)(const mat4& mat); - extern spr::SprArgs* (FASTCALL* put_sprite)(const spr::SprArgs& args); - - vec2 proj_sprite_3d_line(vec3 vec, bool offset); - - void put_sprite_3d_line(vec3 p1, vec3 p2, color4u8 color); - void put_sprite_line(vec2 p1, vec2 p2, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); - void put_sprite_line_list(vec2* points, size_t count, resolution_mode mode, - spr::SprPrio prio, color4u8 color, int32_t layer); - void put_sprite_multi(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); - void put_sprite_rect(rectangle rect, resolution_mode mode, spr::SprPrio prio, color4u8 color, int32_t layer); - void put_sprite_triangles(SpriteVertex* vert, size_t num, resolution_mode mode, - SprPrio prio, int32_t spr_id, int32_t layer); -} - -extern vec4& spr_color; - -extern void (FASTCALL* sprite_manager_unload_set)(int32_t set_id); -extern size_t(FASTCALL* sprite_manager_get_reqlist_count)(int32_t index); -extern void (FASTCALL* sprite_manager_read_file)(int32_t set_id, const prj::string mdata_dir); -extern bool (FASTCALL* sprite_manager_load_file)(int32_t set_id); - -extern const spr_db_spr* sprite_database_get_spr_by_id(int32_t id); -extern int32_t sprite_database_get_spr_set_id_by_name(const prj::string& name); extern void sprite_manager_init(); extern void sprite_manager_draw(int32_t index, bool font, texture* tex); diff --git a/src/DivaGL/stage_param.hpp b/src/DivaGL/stage_param.hpp index c388912..3d1c8cb 100644 --- a/src/DivaGL/stage_param.hpp +++ b/src/DivaGL/stage_param.hpp @@ -7,8 +7,8 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/types.hpp" #include "object.hpp" -#include "types.hpp" /*struct stage_param_data_coli { int32_t pv_id; diff --git a/src/DivaGL/texture.cpp b/src/DivaGL/texture.cpp index 9568387..b87101c 100644 --- a/src/DivaGL/texture.cpp +++ b/src/DivaGL/texture.cpp @@ -5,7 +5,7 @@ #include "texture.hpp" #include "gl_state.hpp" -#include "types.hpp" +#include "../AFTModsShared/types.hpp" #include struct texture_handler { @@ -33,157 +33,17 @@ struct texture_manager { static_assert(sizeof(texture_manager) == 0x48, "\"texture_manager\" struct should have a size of 0x48"); -int32_t(FASTCALL* texture_info_get_id)(const char* name) - = (int32_t(FASTCALL*)(const char* name))0x000000014069CBD0; -void (FASTCALL* txp_set_load)(const void* data, texture*** textures, uint32_t* texture_ids) - = (void (FASTCALL*)(const void* data, texture * **textures, uint32_t * texture_ids))0x000000014069D4B0; - -texture_manager*& texture_manager_work_ptr = *(texture_manager**)0x000000014CC96988; - static void texture_bind(GLenum target, GLuint texture); static void texture_get_format_type_by_internal_format(GLenum internal_format, GLenum* format, GLenum* type); static GLuint texture_get_working_internal_format(GLuint internal_format); -static int32_t texture_get_size(GLenum internal_format, int32_t width, int32_t height); static int32_t texture_load_pixels(GLenum target, GLenum internal_format, int32_t width, int32_t height, int32_t level, const void* data); static texture* texture_load_tex(texture_id id, GLenum target, GLenum internal_format, int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy); +static void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy); -texture::texture() : ref_count(), flags(), width(), height(), -glid(), target(), internal_format(), max_mipmap_level(), size_texmem() { - -} - -int32_t texture::get_height_align_mip_level(uint8_t mip_level) const { - if (flags & TEXTURE_BLOCK_COMPRESSION) - return max_def((uint32_t)height >> mip_level, 4u); - else - return max_def((uint32_t)height >> mip_level, 1u); -} - -int32_t texture::get_size_mip_level(uint8_t mip_level) const { - return texture_get_size(internal_format, - get_width_mip_level(mip_level), get_height_mip_level(mip_level)); -} - -int32_t texture::get_width_align_mip_level(uint8_t mip_level) const { - if (flags & TEXTURE_BLOCK_COMPRESSION) - return max_def((uint32_t)width >> mip_level, 4u); - else - return max_def((uint32_t)width >> mip_level, 1u); -} - -texture* texture_alloc(texture_id id) { - if (!texture_manager_work_ptr) - return 0; - - auto elem = texture_manager_work_ptr->textures.find(id); - if (elem != texture_manager_work_ptr->textures.end()) { - elem->second.tex.ref_count++; - texture_manager_work_ptr->entry_count++; - return &elem->second.tex; - } - - auto ret = texture_manager_work_ptr->textures.insert({ id, texture_handler() }); - if (!ret.second) - return 0; - - texture* tex = &ret.first->second.tex; - tex->ref_count = 1; - tex->id = id; - texture_manager_work_ptr->alloc_count++; - texture_manager_work_ptr->entry_count++; - return tex; -} - -void texture_apply_color_tone(texture* chg_tex, texture* org_tex, const color_tone* col_tone) { - if (!chg_tex || !org_tex || !col_tone - || chg_tex->internal_format != org_tex->internal_format - || chg_tex->width != org_tex->width - || chg_tex->height != org_tex->height - || chg_tex->max_mipmap_level != org_tex->max_mipmap_level) - return; - - for (int32_t i = 0; i <= org_tex->max_mipmap_level; i++) { - int32_t size = org_tex->get_size_mip_level(i); - void* data = prj::HeapCMallocAllocate(prj::HeapCMallocTemp, size, "imgf_color_tone_cpu()"); - if (!data) - break; - - if (org_tex->flags & TEXTURE_BLOCK_COMPRESSION) { - int32_t width_align = org_tex->get_width_align_mip_level(i); - int32_t height_align = org_tex->get_height_align_mip_level(i); - - texture_bind(org_tex->target, org_tex->glid); - glGetCompressedTexImage(org_tex->target, i, data); - if (org_tex->internal_format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) - dxt1_image_apply_color_tone(width_align, height_align, size, (dxt1_block*)data, col_tone); - else - dxt5_image_apply_color_tone(width_align, height_align, size, (dxt5_block*)data, col_tone); - - texture_bind(chg_tex->target, chg_tex->glid); - int32_t width = org_tex->get_width_mip_level(i); - int32_t height = org_tex->get_height_mip_level(i); - glCompressedTexSubImage2D(chg_tex->target, i, 0, 0, width, height, - chg_tex->internal_format, size, data); - } - else if (org_tex->internal_format == GL_RGB5) { - int32_t width_align = org_tex->get_width_align_mip_level(i); - int32_t height_align = org_tex->get_height_align_mip_level(i); - - texture_bind(org_tex->target, org_tex->glid); - glGetTexImageDLL(org_tex->target, i, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); - rgb565_image_apply_color_tone(width_align, height_align, size, (rgb565*)data, col_tone); - - texture_bind(chg_tex->target, chg_tex->glid); - int32_t width = org_tex->get_width_mip_level(i); - int32_t height = org_tex->get_height_mip_level(i); - glTexSubImage2DDLL(chg_tex->target, i, 0, 0, width, height, - GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); - } - gl_state_get_error(); - prj::HeapCMallocFree(prj::HeapCMallocTemp, data); - } - texture_bind(org_tex->target, 0); -} - -texture* texture_create_copy_texture(texture_id id, texture* org_tex) { - if (org_tex->target != GL_TEXTURE_2D) - return 0; - - GLenum format = GL_ZERO; - GLenum type = GL_ZERO; - if (!(org_tex->flags & TEXTURE_BLOCK_COMPRESSION)) - texture_get_format_type_by_internal_format(org_tex->internal_format, &format, &type); - - prj::vector vec_data; - vec_data.reserve((size_t)org_tex->max_mipmap_level + 1); - - texture_bind(org_tex->target, org_tex->glid); - for (int32_t i = 0; i <= org_tex->max_mipmap_level; i++) { - void* data = prj::HeapCMallocAllocate(prj::HeapCMallocTemp, - org_tex->get_size_mip_level(i), "create_copy_texture()"); - if (!data) - break; - - if (org_tex->flags & TEXTURE_BLOCK_COMPRESSION) - glGetCompressedTexImage(org_tex->target, i, data); - else - glGetTexImageDLL(org_tex->target, i, format, type, data); - gl_state_get_error(); - vec_data.push_back(data); - } - texture_bind(org_tex->target, 0); - - texture* tex = texture_load_tex_2d(id, org_tex->internal_format, - org_tex->width, org_tex->height, org_tex->max_mipmap_level, (const void**)vec_data.data(), true); - - for (void*& i : vec_data) - prj::HeapCMallocFree(prj::HeapCMallocTemp, i); - - return tex; -} +texture_manager*& texture_manager_work_ptr = *(texture_manager**)0x000000014CC96988; texture* texture_create_copy_texture_apply_color_tone( texture_id id, texture* org_tex, const color_tone* col_tone) { @@ -239,19 +99,195 @@ texture* texture_create_copy_texture_apply_color_tone( return tex; } -texture* texture_load_tex_2d(texture_id id, GLenum internal_format, int32_t width, int32_t height, - int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy) { - return texture_load_tex(id, GL_TEXTURE_2D, internal_format, - width, height, max_mipmap_level, data_ptr, use_high_anisotropy); +inline texture_id texture_manager_get_copy_id(uint32_t id) { + if (!texture_manager_work_ptr || id != 0x30) + return texture_id(-1, -1); + + int32_t& copy_count = texture_manager_work_ptr->copy_count; + texture_id tex_id(0x30, copy_count); + if (copy_count < 0x0FFFFFFF) + copy_count++; + else + copy_count = 0; + return tex_id; + } -texture* texture_load_tex_cube_map(texture_id id, GLenum internal_format, int32_t width, int32_t height, +HOOK(void, FASTCALL, texture_apply_color_tone, 0x00000001403B5DF0, + texture* chg_tex, texture* org_tex, color_tone* col_tone) { + if (!chg_tex || !org_tex || !col_tone + || chg_tex->internal_format != org_tex->internal_format + || chg_tex->width != org_tex->width + || chg_tex->height != org_tex->height + || chg_tex->max_mipmap_level != org_tex->max_mipmap_level) + return; + + for (int32_t i = 0; i <= org_tex->max_mipmap_level; i++) { + int32_t size = org_tex->get_size_mip_level(i); + void* data = prj::HeapCMallocAllocate(prj::HeapCMallocTemp, size, "imgf_color_tone_cpu()"); + if (!data) + break; + + if (org_tex->flags & TEXTURE_BLOCK_COMPRESSION) { + int32_t width_align = org_tex->get_width_align_mip_level(i); + int32_t height_align = org_tex->get_height_align_mip_level(i); + + texture_bind(org_tex->target, org_tex->glid); + glGetCompressedTexImage(org_tex->target, i, data); + if (org_tex->internal_format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) + dxt1_image_apply_color_tone(width_align, height_align, size, (dxt1_block*)data, col_tone); + else + dxt5_image_apply_color_tone(width_align, height_align, size, (dxt5_block*)data, col_tone); + + texture_bind(chg_tex->target, chg_tex->glid); + int32_t width = org_tex->get_width_mip_level(i); + int32_t height = org_tex->get_height_mip_level(i); + glCompressedTexSubImage2D(chg_tex->target, i, 0, 0, width, height, + chg_tex->internal_format, size, data); + } + else if (org_tex->internal_format == GL_RGB5) { + int32_t width_align = org_tex->get_width_align_mip_level(i); + int32_t height_align = org_tex->get_height_align_mip_level(i); + + texture_bind(org_tex->target, org_tex->glid); + glGetTexImageDLL(org_tex->target, i, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); + rgb565_image_apply_color_tone(width_align, height_align, size, (rgb565*)data, col_tone); + + texture_bind(chg_tex->target, chg_tex->glid); + int32_t width = org_tex->get_width_mip_level(i); + int32_t height = org_tex->get_height_mip_level(i); + glTexSubImage2DDLL(chg_tex->target, i, 0, 0, width, height, + GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); + } + gl_state_get_error(); + prj::HeapCMallocFree(prj::HeapCMallocTemp, data); + } + texture_bind(org_tex->target, 0); +} + +HOOK(texture*, FASTCALL, texture_alloc, 0x000000014069A390, texture_id id) { + if (!texture_manager_work_ptr) + return 0; + + auto elem = texture_manager_work_ptr->textures.find(id); + if (elem != texture_manager_work_ptr->textures.end()) { + elem->second.tex.ref_count++; + texture_manager_work_ptr->entry_count++; + return &elem->second.tex; + } + + auto ret = texture_manager_work_ptr->textures.insert({ id, texture_handler() }); + if (!ret.second) + return 0; + + texture* tex = &ret.first->second.tex; + tex->ref_count = 1; + tex->id = id; + texture_manager_work_ptr->alloc_count++; + texture_manager_work_ptr->entry_count++; + return tex; +} + +HOOK(int32_t, FASTCALL, texture_get_size, 0x000000014069A6D0, GLenum internal_format, int32_t width, int32_t height) { + int32_t size = width * height; + switch (internal_format) { + case GL_ALPHA8: + case GL_LUMINANCE8: + case GL_INTENSITY8: + case GL_R8: + return size; + case GL_LUMINANCE8_ALPHA8: + case GL_RGB5: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_DEPTH_COMPONENT16: + case GL_RG8: + return size * 2; + case GL_RGB8: + case GL_RGBA8: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + case GL_R32F: + case GL_RGBA16F: + case GL_DEPTH24_STENCIL8: + case GL_DEPTH_COMPONENT32F: + case GL_R11F_G11F_B10F: + case GL_RGB9_E5: + return size * 4; + case GL_RG32F: + return size * 8; + case GL_RGBA32F: + return size * 16; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RED_RGTC1: + width = align_val(width, 4); + height = align_val(height, 4); + return width * height / 2; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_RG_RGTC2: + width = align_val(width, 4); + height = align_val(height, 4); + return width * height; + default: + return 0; + } +} + +HOOK(texture*, FASTCALL, texture_create_copy_texture, 0x000000014069B550, + texture_id id, texture* org_tex) { + if (org_tex->target != GL_TEXTURE_2D) + return 0; + + GLenum format = GL_ZERO; + GLenum type = GL_ZERO; + if (!(org_tex->flags & TEXTURE_BLOCK_COMPRESSION)) + texture_get_format_type_by_internal_format(org_tex->internal_format, &format, &type); + + prj::vector vec_data; + vec_data.reserve((size_t)org_tex->max_mipmap_level + 1); + + texture_bind(org_tex->target, org_tex->glid); + for (int32_t i = 0; i <= org_tex->max_mipmap_level; i++) { + void* data = prj::HeapCMallocAllocate(prj::HeapCMallocTemp, + org_tex->get_size_mip_level(i), "create_copy_texture()"); + if (!data) + break; + + if (org_tex->flags & TEXTURE_BLOCK_COMPRESSION) + glGetCompressedTexImage(org_tex->target, i, data); + else + glGetTexImageDLL(org_tex->target, i, format, type, data); + gl_state_get_error(); + vec_data.push_back(data); + } + texture_bind(org_tex->target, 0); + + texture* tex = texture_load_tex_2d(id, org_tex->internal_format, + org_tex->width, org_tex->height, org_tex->max_mipmap_level, (const void**)vec_data.data(), true); + + for (void*& i : vec_data) + prj::HeapCMallocFree(prj::HeapCMallocTemp, i); + + return tex; +} + +HOOK(texture*, FASTCALL, texture_load_tex_cube_map, 0x000000014069B860, + texture_id id, GLenum internal_format, int32_t width, int32_t height, int32_t max_mipmap_level, const void** data_ptr) { return texture_load_tex(id, GL_TEXTURE_CUBE_MAP, internal_format, width, height, max_mipmap_level, data_ptr, false); } -void texture_release(texture* tex) { +HOOK(texture*, FASTCALL, texture_load_tex_2d, 0x000000014069B8E0, + texture_id id, GLenum internal_format, int32_t width, int32_t height, + int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy) { + return texture_load_tex(id, GL_TEXTURE_2D, internal_format, + width, height, max_mipmap_level, data_ptr, use_high_anisotropy); +} + +HOOK(void, FASTCALL, texture_release, 0x000000014069DA70, texture* tex) { if (!texture_manager_work_ptr || !tex) return; @@ -272,102 +308,22 @@ void texture_release(texture* tex) { texture_manager_work_ptr->textures.erase(tex->id); } -void texture_array_free(texture** arr) { - if (!arr) - return; - - for (texture** i = arr; *i; i++) - texture_release(*i); - free_def(arr); -} - -void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy) { - glTexParameteriDLL(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteriDLL(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteriDLL(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - static const vec4 border_color = 0.0f; - glTexParameterfvDLL(target, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color); - glTexParameteriDLL(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteriDLL(target, GL_TEXTURE_MIN_FILTER, - max_mipmap_level > 0 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); - glTexParameteriDLL(target, GL_TEXTURE_BASE_LEVEL, 0); - glTexParameteriDLL(target, GL_TEXTURE_MAX_LEVEL, max_mipmap_level); - - float_t max_anisotropy; - if (use_high_anisotropy) - max_anisotropy = 16.0f; - else - max_anisotropy = 1.0f; - glTexParameterfDLL(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy); -} - -inline texture_id texture_manager_get_copy_id(uint32_t id) { - if (!texture_manager_work_ptr || id != 0x30) - return texture_id(-1, -1); - - int32_t& copy_count = texture_manager_work_ptr->copy_count; - texture_id tex_id(0x30, copy_count); - if (copy_count < 0x0FFFFFFF) - copy_count++; - else - copy_count = 0; - return tex_id; - -} - -inline texture* texture_manager_get_texture(uint32_t id) { - auto elem = texture_manager_work_ptr->textures.find(texture_id(0x00, id)); - if (elem != texture_manager_work_ptr->textures.end()) - return &elem->second.tex; - return 0; -} - -inline texture* texture_manager_get_texture(texture_id id) { - auto elem = texture_manager_work_ptr->textures.find(id); - if (elem != texture_manager_work_ptr->textures.end()) - return &elem->second.tex; - return 0; -} - -HOOK(void, FASTCALL, texture_apply_color_tone, 0x00000001403B5DF0, - texture* chg_tex, texture* org_tex, color_tone* col_tone) { - texture_apply_color_tone(chg_tex, org_tex, col_tone); -} - -HOOK(texture*, FASTCALL, texture_create_copy_texture, 0x000000014069B550, - texture_id id, texture* org_tex) { - return texture_create_copy_texture(id, org_tex); -} - -HOOK(texture*, FASTCALL, texture_load_tex_cube_map, 0x000000014069B860, - texture_id id, GLenum internal_format, int32_t width, int32_t height, - int32_t max_mipmap_level, const void** data_ptr) { - return texture_load_tex(id, GL_TEXTURE_CUBE_MAP, internal_format, - width, height, max_mipmap_level, data_ptr, false); -} - -HOOK(texture*, FASTCALL, texture_load_tex_2d, 0x000000014069B8E0, - texture_id id, GLenum internal_format, int32_t width, int32_t height, - int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy) { - return texture_load_tex(id, GL_TEXTURE_2D, internal_format, - width, height, max_mipmap_level, data_ptr, use_high_anisotropy); -} - HOOK(texture*, FASTCALL, texture_manager_get_texture, 0x000000014069CD70, uint32_t id) { - return texture_manager_get_texture(*(texture_id*)&id); -} - -HOOK(void, FASTCALL, texture_release, 0x000000014069DA70, texture* tex) { - texture_release(tex); + auto elem = texture_manager_work_ptr->textures.find(*(texture_id*)&id); + if (elem != texture_manager_work_ptr->textures.end()) + return &elem->second.tex; + return 0; } void texture_patch() { INSTALL_HOOK(texture_apply_color_tone); + INSTALL_HOOK(texture_alloc); + INSTALL_HOOK(texture_get_size); INSTALL_HOOK(texture_create_copy_texture); INSTALL_HOOK(texture_load_tex_cube_map); INSTALL_HOOK(texture_load_tex_2d); - INSTALL_HOOK(texture_manager_get_texture); INSTALL_HOOK(texture_release); + INSTALL_HOOK(texture_manager_get_texture); } texture_handler::texture_handler() : field_2C(), field_30(), field_34() { @@ -509,53 +465,6 @@ inline static GLuint texture_get_working_internal_format(GLuint internal_format) } } -static int32_t texture_get_size(GLenum internal_format, int32_t width, int32_t height) { - int32_t size = width * height; - switch (internal_format) { - case GL_ALPHA8: - case GL_LUMINANCE8: - case GL_INTENSITY8: - case GL_R8: - return size; - case GL_LUMINANCE8_ALPHA8: - case GL_RGB5: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_DEPTH_COMPONENT16: - case GL_RG8: - return size * 2; - case GL_RGB8: - case GL_RGBA8: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - case GL_R32F: - case GL_RGBA16F: - case GL_DEPTH24_STENCIL8: - case GL_DEPTH_COMPONENT32F: - case GL_R11F_G11F_B10F: - case GL_RGB9_E5: - return size * 4; - case GL_RG32F: - return size * 8; - case GL_RGBA32F: - return size * 16; - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RED_RGTC1: - width = align_val(width, 4); - height = align_val(height, 4); - return width * height / 2; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_RG_RGTC2: - width = align_val(width, 4); - height = align_val(height, 4); - return width * height; - default: - return 0; - } -} - static int32_t texture_load_pixels(GLenum target, GLenum internal_format, int32_t width, int32_t height, int32_t level, const void* data) { glPixelStoreiDLL(GL_UNPACK_ALIGNMENT, 1); @@ -713,3 +622,23 @@ fail: texture_release(tex); return 0; } + +static void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy) { + glTexParameteriDLL(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteriDLL(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteriDLL(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + static const vec4 border_color = 0.0f; + glTexParameterfvDLL(target, GL_TEXTURE_BORDER_COLOR, (GLfloat*)&border_color); + glTexParameteriDLL(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteriDLL(target, GL_TEXTURE_MIN_FILTER, + max_mipmap_level > 0 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); + glTexParameteriDLL(target, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteriDLL(target, GL_TEXTURE_MAX_LEVEL, max_mipmap_level); + + float_t max_anisotropy; + if (use_high_anisotropy) + max_anisotropy = 16.0f; + else + max_anisotropy = 1.0f; + glTexParameterfDLL(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropy); +} diff --git a/src/DivaGL/texture.hpp b/src/DivaGL/texture.hpp index 7aa9a7c..924934a 100644 --- a/src/DivaGL/texture.hpp +++ b/src/DivaGL/texture.hpp @@ -7,102 +7,10 @@ #include "../KKdLib/default.hpp" #include "../KKdLib/image.hpp" +#include "../AFTModsShared/texture.hpp" #include "wrap.hpp" -enum texture_flags { - TEXTURE_BLOCK_COMPRESSION = 0x01, -}; - -struct texture_id { - uint32_t index : 24; - uint32_t id : 8; - - inline texture_id() { - id = 0; - index = 0; - } - - inline texture_id(uint8_t id, uint32_t index) { - this->id = id; - this->index = index; - } -}; - -static_assert(sizeof(texture_id) == 0x04, "\"texture_id\" struct should have a size of 0x04"); - -constexpr bool operator==(const texture_id& left, const texture_id& right) { - return (((uint64_t)left.id << 32) | left.index) == (((uint64_t)right.id << 32) | right.index); -} - -constexpr bool operator!=(const texture_id& left, const texture_id& right) { - return !(left == right); -} - -constexpr bool operator<(const texture_id& left, const texture_id& right) { - return (((uint64_t)left.id << 32) | left.index) < (((uint64_t)right.id << 32) | right.index); -} - -constexpr bool operator>(const texture_id& left, const texture_id& right) { - return right < left; -} - -constexpr bool operator<=(const texture_id& left, const texture_id& right) { - return !(right < left); -} - -constexpr bool operator>=(const texture_id& left, const texture_id& right) { - return !(left < right); -} - -struct texture { - int32_t ref_count; - texture_id id; - texture_flags flags; - int16_t width; - int16_t height; - GLuint glid; - GLenum target; - GLenum internal_format; - int32_t max_mipmap_level; - int32_t size_texmem; - - texture(); - - int32_t get_height_align_mip_level(uint8_t mip_level = 0) const; - int32_t get_size_mip_level(uint8_t mip_level = 0) const; - int32_t get_width_align_mip_level(uint8_t mip_level = 0) const; - - inline int32_t get_height_mip_level(uint8_t mip_level) const { - return max_def(height >> mip_level, 1); - } - inline int32_t get_width_mip_level(uint8_t mip_level) const { - return max_def(width >> mip_level, 1); - } -}; - -static_assert(sizeof(texture) == 0x24, "\"texture\" struct should have a size of 0x24"); - -extern int32_t(FASTCALL* texture_info_get_id)(const char* name); -extern void (FASTCALL* txp_set_load)(const void* data, texture*** textures, uint32_t* texture_ids); - -extern texture* texture_alloc(texture_id id); -extern void texture_apply_color_tone(texture* chg_tex, - texture* org_tex, const color_tone* col_tone); -extern texture* texture_create_copy_texture(texture_id id, texture* org_tex); extern texture* texture_create_copy_texture_apply_color_tone( texture_id id, texture* org_tex, const color_tone* col_tone); -extern texture* texture_load_tex_2d(texture_id id, GLenum internal_format, int32_t width, int32_t height, - int32_t max_mipmap_level, const void** data_ptr, bool use_high_anisotropy); -extern texture* texture_load_tex_cube_map(texture_id id, GLenum internal_format, int32_t width, int32_t height, - int32_t max_mipmap_level, const void** data_ptr); -extern void texture_release(texture* tex); - -extern void texture_array_free(texture** arr); - -extern void texture_set_params(GLenum target, int32_t max_mipmap_level, bool use_high_anisotropy); - -extern texture_id texture_manager_get_copy_id(uint32_t id); -extern texture* texture_manager_get_texture(uint32_t id); -extern texture* texture_manager_get_texture(texture_id id); extern void texture_patch(); diff --git a/src/DivaGL/wrap.cpp b/src/DivaGL/wrap.cpp index e0a8f98..8d721f6 100644 --- a/src/DivaGL/wrap.cpp +++ b/src/DivaGL/wrap.cpp @@ -7,8 +7,8 @@ #include "../KKdLib/half_t.hpp" #include "../KKdLib/mat.hpp" #include "../KKdLib/vec.hpp" +#include "../AFTModsShared/uniform.hpp" #include "print.hpp" -#include "uniform.hpp" #include #include