mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-13 01:28:10 +03:00
Temp commit. Cloth
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "classes.h"
|
||||
#include "classes.hpp"
|
||||
|
||||
bool data_test_shared_lock;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../CRE/lock.h"
|
||||
#include "../CRE/lock.hpp"
|
||||
#include "../CRE/render_context.hpp"
|
||||
#include "../CRE/task.hpp"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "data_test.h"
|
||||
#include "data_test.hpp"
|
||||
#include "data_test/auth_3d_test.hpp"
|
||||
#include "data_test/glitter_test.hpp"
|
||||
#include "data_test/stage_test.hpp"
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../classes.h"
|
||||
#include "../classes.hpp"
|
||||
|
||||
enum data_test_classes_enum {
|
||||
DATA_TEST_AUTH_3D_TEST,
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../../../CRE/stage.hpp"
|
||||
#include "../../input.hpp"
|
||||
#include "../data_test.h"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../data_test.hpp"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
struct data_test_auth_3d_test_uid {
|
||||
const char* name;
|
||||
@@ -148,7 +148,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
int32_t auth_3d_category_index = auth_3d_test_window->auth_3d_category_index;
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
if (ImGui::BeginCombo("##Auth 3D Category Index", auth_3d_category_index > -1
|
||||
? auth_3d_db_cat[auth_3d_category_index].name : "", 0)) {
|
||||
for (data_test_auth_3d_test_category& i : auth_3d_db_cat) {
|
||||
@@ -156,7 +156,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(&i);
|
||||
if (ImGui::Selectable(i.name, auth_3d_category_index == auth_3d_category_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && auth_3d_category_index != auth_3d_category_idx)) {
|
||||
auth_3d_category_index = auth_3d_category_idx;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::Checkbox("OBJ Link", &auth_3d_test_task.window.obj_link);
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
bool auth_3d_category_found = false;
|
||||
for (data_test_auth_3d_test_category& i : auth_3d_db_cat) {
|
||||
if (auth_3d_category_index != &i - auth_3d_db_cat.data())
|
||||
@@ -208,7 +208,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(&j);
|
||||
if (ImGui::Selectable(j.name, auth_3d_index == auth_3d_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && auth_3d_index != auth_3d_idx)) {
|
||||
auth_3d_test_window->auth_3d_index = -1;
|
||||
auth_3d_index = auth_3d_idx;
|
||||
@@ -241,8 +241,8 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
float_t frame = auth_3d_test_window->frame;
|
||||
ImGui::Text("frame[ 0,%4.0f)", auth_3d_test_window->last_frame);
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
igSliderFloatButton("##frame slider", &frame, 1.0f,
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::SliderFloatButton("##frame slider", &frame, 1.0f,
|
||||
0.0f, auth_3d_test_window->last_frame, "%5.0f", 0);
|
||||
if (ImGui::IsItemActivated())
|
||||
auth_3d_test_window->paused = true;
|
||||
@@ -268,23 +268,21 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
auth_3d_test_window->frame = frame;
|
||||
}
|
||||
|
||||
imguiColumnSliderFloat("transX", &auth_3d_test_task.trans_value.x, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("transZ", &auth_3d_test_task.trans_value.z, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("rotY", &auth_3d_test_task.rot_y_value, 1.0f, -360.0f, 360.0f, "%.0f", 0, true);
|
||||
ImGui::ColumnSliderFloat("transX", &auth_3d_test_task.trans_value.x, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("transZ", &auth_3d_test_task.trans_value.z, 0.1f, -5.0f, 5.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("rotY", &auth_3d_test_task.rot_y_value, 1.0f, -360.0f, 360.0f, "%.0f", 0, true);
|
||||
|
||||
if (ImGui::Button("cam reset", { 72.0f, 0.0f }) && rctx_ptr && rctx_ptr->camera) {
|
||||
camera* cam = rctx_ptr->camera;
|
||||
camera_set_fov(cam, 32.2673416137695);
|
||||
camera_set_roll(cam, 0.0);
|
||||
vec3 view_point = { 0.0f, 1.0f, 6.0f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
vec3 interest = { 0.0f, 1.0f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
cam->set_fov(32.2673416137695);
|
||||
cam->set_roll(0.0);
|
||||
cam->set_view_point({ 0.0f, 1.0f, 6.0f });
|
||||
cam->set_interest({ 0.0f, 1.0f, 0.0f });
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
imguiColumnSliderFloat("Frame Speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Frame Speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
|
||||
|
||||
data->imgui_focus |= ImGui::IsWindowFocused();
|
||||
ImGui::End();
|
||||
@@ -318,7 +316,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
int32_t stage_index = auth_3d_test_task.stage_index;
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
if (ImGui::BeginCombo("##Stage Index", stage_index > -1
|
||||
? auth_3d_test_window->stage[stage_index] : "", 0)) {
|
||||
for (const char*& i : auth_3d_test_window->stage) {
|
||||
@@ -326,7 +324,7 @@ void data_test_auth_3d_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable(i, stage_index == stage_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && stage_index != stage_idx))
|
||||
stage_index = stage_idx;
|
||||
ImGui::PopID();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_test_auth_3d_test_init(class_data* data, render_context* rctx);
|
||||
extern void data_test_auth_3d_test_ctrl(class_data* data);
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../../../CRE/stage.hpp"
|
||||
#include "../../input.hpp"
|
||||
#include "../data_test.h"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../data_test.hpp"
|
||||
#include "../imgui_helper.hpp"
|
||||
#include "stage_test.hpp"
|
||||
|
||||
class TaskDataTestGlitterParticle : public app::TaskWindow {
|
||||
@@ -109,11 +109,9 @@ bool TaskDataTestGlitterParticle::Init() {
|
||||
clear_color = { 0x60, 0x60, 0x60, 0xFF };
|
||||
|
||||
camera* cam = rctx_ptr->camera;
|
||||
camera_reset(cam);
|
||||
vec3 view_point = { 0.0f, 0.88f, 4.3f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
vec3 interest = { 0.0f, 1.0f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
cam->reset();
|
||||
cam->set_view_point({ 0.0f, 0.88f, 4.3f });
|
||||
cam->set_interest({ 0.0f, 1.0f, 0.0f });
|
||||
|
||||
hash = hash_fnv1a64m_empty;
|
||||
scene_counter = 0;
|
||||
@@ -206,47 +204,47 @@ void TaskDataTestGlitterParticle::Window() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (imguiColumnComboBoxConfigFile("File", files.data(),
|
||||
if (ImGui::ColumnComboBoxConfigFile("File", files.data(),
|
||||
files.size(), &file_index, 0, false, &window_focus)) {
|
||||
load_file = true;
|
||||
input_stop = true;
|
||||
}
|
||||
|
||||
if (imguiButton("Reset Camera (R)"))
|
||||
if (ImGui::ButtonEnterKeyPressed("Reset Camera (R)"))
|
||||
input_reset = true;
|
||||
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Play (F)", { w, 0.0f }) || ImGui::IsKeyPressed(GLFW_KEY_F))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Play (F)", { w, 0.0f }) || ImGui::IsKeyPressed(GLFW_KEY_F))
|
||||
input_play = true;
|
||||
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Stop (V)", { w, 0.0f }) || ImGui::IsKeyPressed(GLFW_KEY_V))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Stop (V)", { w, 0.0f }) || ImGui::IsKeyPressed(GLFW_KEY_V))
|
||||
input_stop = true;
|
||||
|
||||
bool pause = Glitter::glt_particle_manager.GetPause();
|
||||
imguiCheckbox("Pause (G)", &pause);
|
||||
ImGui::CheckboxEnterKeyPressed("Pause (G)", &pause);
|
||||
if (ImGui::IsKeyPressed(GLFW_KEY_G))
|
||||
pause ^= true;
|
||||
Glitter::glt_particle_manager.SetPause(pause);
|
||||
|
||||
imguiCheckbox("Auto (T)", &auto_and_repeat);
|
||||
ImGui::CheckboxEnterKeyPressed("Auto (T)", &auto_and_repeat);
|
||||
if (ImGui::IsKeyPressed(GLFW_KEY_T))
|
||||
auto_and_repeat ^= true;
|
||||
|
||||
imguiCheckbox("PV Mode (P)", &pv_mode);
|
||||
ImGui::CheckboxEnterKeyPressed("PV Mode (P)", &pv_mode);
|
||||
if (ImGui::IsKeyPressed(GLFW_KEY_P))
|
||||
pv_mode ^= true;
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
imguiColumnSliderFloat("Emission", &Glitter::glt_particle_manager.emission, 0.01f, 1.0f, 2.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Emission", &Glitter::glt_particle_manager.emission, 0.01f, 1.0f, 2.0f, "%.2f", 0, true);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
imguiCheckbox("Show Grid", &draw_grid_3d);
|
||||
ImGui::CheckboxEnterKeyPressed("Show Grid", &draw_grid_3d);
|
||||
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Stage", { w, 0.0f }))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Stage", { w, 0.0f }))
|
||||
stage_test = true;
|
||||
|
||||
window_focus |= ImGui::IsWindowFocused();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_test_glitter_test_init(class_data* data, render_context* rctx);
|
||||
extern void data_test_glitter_test_ctrl(class_data* data);
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../../../CRE/stage.hpp"
|
||||
#include "../../input.hpp"
|
||||
#include "../data_test.h"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../data_test.hpp"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
struct data_test_stage_test_stage_pv {
|
||||
int32_t pv_id;
|
||||
@@ -121,7 +121,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
ImGui::PushID(&i);
|
||||
sprintf_s(buf, sizeof(buf), "%03d", i.pv_id);
|
||||
if (ImGui::Selectable(buf, pv_id == i.pv_id)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && pv_id != i.pv_id))
|
||||
pv_id = i.pv_id;
|
||||
ImGui::PopID();
|
||||
@@ -155,7 +155,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(j);
|
||||
if (ImGui::Selectable(stg_data[j].name.c_str(), pv_index == pv_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && pv_index != pv_idx)) {
|
||||
dtw_stg->pv_index = -1;
|
||||
pv_index = pv_idx;
|
||||
@@ -195,7 +195,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable(stg_data[stage_ns[i]].name.c_str(), ns_index == ns_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && ns_index != ns_idx)) {
|
||||
dtw_stg->ns_index = -1;
|
||||
ns_index = ns_idx;
|
||||
@@ -228,7 +228,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(i);
|
||||
if (ImGui::Selectable(stg_data[i].name.c_str(), other_index == other_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && other_index != other_idx)) {
|
||||
dtw_stg->other_index = -1;
|
||||
other_index = other_idx;
|
||||
@@ -251,7 +251,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
int32_t stage_index = dtw_stg->stage_index;
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
if (ImGui::BeginCombo("##Stage Index", stage_index > -1
|
||||
? stg_data[stage_index].name.c_str() : "", 0)) {
|
||||
for (stage_data& i : stg_data) {
|
||||
@@ -259,7 +259,7 @@ void data_test_stage_test_imgui(class_data* data) {
|
||||
|
||||
ImGui::PushID(&i);
|
||||
if (ImGui::Selectable(i.name.c_str(), stage_index == stage_idx)
|
||||
|| imguiItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| ImGui::ItemKeyPressed(GLFW_KEY_ENTER, true)
|
||||
|| (ImGui::IsItemFocused() && stage_index != stage_idx)) {
|
||||
dtw_stg->stage_index = -1;
|
||||
stage_index = stage_idx;
|
||||
@@ -329,12 +329,10 @@ static bool stage_test_load() {
|
||||
clear_color = { 96, 96, 96, 255 };
|
||||
|
||||
camera* cam = rctx_ptr->camera;
|
||||
camera_reset(cam);
|
||||
vec3 view_point = { 0.0f, 0.88f, 4.3f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
vec3 interest = { 0.0f, 1.0f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
app::TaskWork::AppendTask(&dtm_stg, "DATA_TEST_STAGE");
|
||||
cam->reset();
|
||||
cam->set_view_point({ 0.0f, 0.88f, 4.3f });
|
||||
cam->set_interest({ 0.0f, 1.0f, 0.0f });
|
||||
app::TaskWork::AppendTask(dtm_stg, "DATA_TEST_STAGE");
|
||||
|
||||
if (!dtw_stg)
|
||||
dtw_stg = new DtwStg();
|
||||
@@ -344,7 +342,7 @@ static bool stage_test_load() {
|
||||
}
|
||||
|
||||
static bool stage_test_unload() {
|
||||
dtm_stg.SetDest();
|
||||
dtm_stg->SetDest();
|
||||
|
||||
classes_data* c = &data_test_classes[DATA_TEST_STAGE_TEST];
|
||||
enum_or(c->data.flags, CLASS_HIDE);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_test_stage_test_init(class_data* data, render_context* rctx);
|
||||
extern void data_test_stage_test_ctrl(class_data* data);
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "data_view.h"
|
||||
#include "data_view/auth_3d.h"
|
||||
#include "data_view/draw_task.h"
|
||||
#include "data_view/glitter.h"
|
||||
#include "data_view/object.h"
|
||||
#include "data_view/texture.h"
|
||||
#include "data_view.hpp"
|
||||
#include "data_view/auth_3d.hpp"
|
||||
#include "data_view/draw_task.hpp"
|
||||
#include "data_view/glitter.hpp"
|
||||
#include "data_view/object.hpp"
|
||||
#include "data_view/texture.hpp"
|
||||
|
||||
classes_data data_view_classes[] = {
|
||||
{
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../classes.h"
|
||||
#include "../classes.hpp"
|
||||
|
||||
enum data_view_classes_enum {
|
||||
DATA_VIEW_AUTH_3D,
|
||||
@@ -3,10 +3,10 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "auth_3d.h"
|
||||
#include "auth_3d.hpp"
|
||||
#include "../../../CRE/auth_3d.hpp"
|
||||
#include "../../input.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
static const char* auth_3d_fog_name[] = {
|
||||
"Depth",
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_view_auth_3d_init(class_data* data, render_context* rctx);
|
||||
extern void data_view_auth_3d_imgui(class_data* data);
|
||||
@@ -3,11 +3,11 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "draw_task.h"
|
||||
#include "draw_task.hpp"
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../../../KKdLib/hash.hpp"
|
||||
#include "../../../KKdLib/sort.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
static const char* draw_object_type_name[] = {
|
||||
"Opaque",
|
||||
@@ -124,10 +124,10 @@ void data_view_draw_task_imgui(class_data* data) {
|
||||
std::vector<draw_task*>& draw_tasks = draw_task_array[i];
|
||||
size_t count = draw_tasks.size();
|
||||
bool enable = count > 0;
|
||||
imguiDisableElementPush(enable);
|
||||
ImGui::DisableElementPush(enable);
|
||||
if (!ImGui::TreeNodeEx("", tree_node_flags,
|
||||
"%s; Count: %llu", draw_object_type_name[i], count)) {
|
||||
imguiDisableElementPop(enable);
|
||||
ImGui::DisableElementPop(enable);
|
||||
ImGui::PopID();
|
||||
continue;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ void data_view_draw_task_imgui(class_data* data) {
|
||||
draw_tasks_sort.clear();
|
||||
|
||||
ImGui::TreePop();
|
||||
imguiDisableElementPop(enable);
|
||||
ImGui::DisableElementPop(enable);
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_view_draw_task_init(class_data* data, render_context* rctx);
|
||||
extern void data_view_draw_task_imgui(class_data* data);
|
||||
@@ -3,10 +3,10 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.h"
|
||||
#include "glitter.hpp"
|
||||
#include "../../../CRE/Glitter/glitter.hpp"
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
struct data_view_glitter {
|
||||
render_context* rctx;
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_view_glitter_init(class_data* data, render_context* rctx);
|
||||
extern void data_view_glitter_imgui(class_data* data);
|
||||
@@ -3,9 +3,9 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "object.h"
|
||||
#include "object.hpp"
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
struct data_view_object {
|
||||
render_context* rctx;
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_view_object_init(class_data* data, render_context* rctx);
|
||||
extern void data_view_object_imgui(class_data* data);
|
||||
@@ -3,9 +3,9 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "texture.h"
|
||||
#include "texture.hpp"
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
struct data_view_texture {
|
||||
render_context* rctx;
|
||||
@@ -30,7 +30,7 @@ void data_view_texture_imgui(class_data* data) {
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
ImFont* font = ImGui::GetFont();
|
||||
|
||||
float_t w = min((float_t)width, 560.0f);
|
||||
float_t w = min((float_t)width, 580.0f);
|
||||
float_t h = min((float_t)height, 480.0f);
|
||||
|
||||
ImGui::SetNextWindowPos({ 0, 0 }, ImGuiCond_Appearing);
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool data_view_texture_init(class_data* data, render_context* rctx);
|
||||
extern void data_view_texture_imgui(class_data* data);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../classes.h"
|
||||
#include "../classes.hpp"
|
||||
|
||||
extern bool glitter_editor_init(class_data* data, render_context* rctx);
|
||||
extern void glitter_editor_ctrl(class_data* data);
|
||||
@@ -3,7 +3,11 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "graphics.h"
|
||||
#include "graphics.hpp"
|
||||
#include "graphics/background_color.hpp"
|
||||
#include "graphics/glitter.hpp"
|
||||
#include "graphics/post_process.hpp"
|
||||
#include "graphics/render_settings.hpp"
|
||||
|
||||
classes_data graphics_classes[] = {
|
||||
{
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../classes.h"
|
||||
#include "graphics/background_color.h"
|
||||
#include "graphics/glitter.h"
|
||||
#include "graphics/post_process.h"
|
||||
#include "graphics/render_settings.h"
|
||||
|
||||
extern classes_data graphics_classes[];
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../classes.hpp"
|
||||
|
||||
extern classes_data graphics_classes[];
|
||||
+4
-4
@@ -3,9 +3,9 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "background_color.h"
|
||||
#include "background_color.hpp"
|
||||
#include "../../../KKdLib/vec.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -51,7 +51,7 @@ void graphics_background_color_imgui(class_data* data) {
|
||||
color_edit_flags |= ImGuiColorEditFlags_NoSidePreview;
|
||||
color_edit_flags |= ImGuiColorEditFlags_NoDragDrop;
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
vec4 _clear_color;
|
||||
vec4u8_to_vec4(clear_color, _clear_color);
|
||||
vec4_mult_scalar(_clear_color, (float_t)(1.0 / 255.0), _clear_color);
|
||||
@@ -62,7 +62,7 @@ void graphics_background_color_imgui(class_data* data) {
|
||||
}
|
||||
ImGui::Checkbox("Set Clear Color", &set_clear_color);
|
||||
|
||||
if (imguiButton("Reset Color")) {
|
||||
if (ImGui::ButtonEnterKeyPressed("Reset Color")) {
|
||||
clear_color = { 0x60, 0x60, 0x60, 0xFF };
|
||||
set_clear_color = true;
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool graphics_background_color_init(class_data* data, render_context* rctx);
|
||||
extern void graphics_background_color_imgui(class_data* data);
|
||||
@@ -3,10 +3,10 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "glitter.h"
|
||||
#include "glitter.hpp"
|
||||
#include "../../../CRE/Glitter/glitter.hpp"
|
||||
#include "../../../CRE/render_context.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool graphics_glitter_init(class_data* data, render_context* rctx);
|
||||
extern void graphics_glitter_imgui(class_data* data);
|
||||
+38
-38
@@ -4,9 +4,9 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "post_process.h"
|
||||
#include "post_process.hpp"
|
||||
#include "../../../CRE/stage.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -62,30 +62,30 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
"cone(2tap)",
|
||||
};
|
||||
|
||||
imguiColumnComboBox("MAG Filter", mag_filter_labels, POST_PROCESS_MAG_FILTER_MAX,
|
||||
ImGui::ColumnComboBox("MAG Filter", mag_filter_labels, POST_PROCESS_MAG_FILTER_MAX,
|
||||
(int32_t*)&pp->mag_filter, 0, false, &data->imgui_focus);
|
||||
|
||||
imguiCheckbox("Morphological AA", &pp->mlaa);
|
||||
ImGui::CheckboxEnterKeyPressed("Morphological AA", &pp->mlaa);
|
||||
|
||||
imguiSetColumnSpace(1.0f / 4.0f);
|
||||
ImGui::SetColumnSpace(1.0f / 4.0f);
|
||||
if (ImGui::TreeNode("Tone Trans")) {
|
||||
vec3 tone_trans_start = tone_map->get_tone_trans_start();
|
||||
imguiColumnSliderVec3("Start", &tone_trans_start, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderVec3("Start", &tone_trans_start, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
tone_map->set_tone_trans_start(tone_trans_start);
|
||||
|
||||
vec3 tone_trans_end = tone_map->get_tone_trans_end();
|
||||
imguiColumnSliderVec3("End", &tone_trans_end, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderVec3("End", &tone_trans_end, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
tone_map->set_tone_trans_end(tone_trans_end);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Scene Fade")) {
|
||||
float_t scene_fade_alpha = tone_map->get_scene_fade_alpha();
|
||||
imguiColumnSliderFloat("Alpha", &scene_fade_alpha, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Alpha", &scene_fade_alpha, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
tone_map->set_scene_fade_alpha(scene_fade_alpha);
|
||||
|
||||
vec3 scene_fade_color = tone_map->get_scene_fade_color();
|
||||
imguiColumnSliderVec3("Color", &scene_fade_color, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderVec3("Color", &scene_fade_color, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
tone_map->set_scene_fade_color(scene_fade_color);
|
||||
|
||||
const char* scene_fade_blend_func_labels[] = {
|
||||
@@ -95,7 +95,7 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
};
|
||||
|
||||
int32_t scene_fade_blend_func = tone_map->get_scene_fade_blend_func();
|
||||
imguiColumnComboBox("Blend Func", scene_fade_blend_func_labels, 3,
|
||||
ImGui::ColumnComboBox("Blend Func", scene_fade_blend_func_labels, 3,
|
||||
&scene_fade_blend_func, 0, false, &data->imgui_focus);
|
||||
tone_map->set_scene_fade_blend_func(scene_fade_blend_func);
|
||||
ImGui::TreePop();
|
||||
@@ -109,66 +109,66 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
};
|
||||
|
||||
int32_t _tone_map_method = tone_map->get_tone_map_method();
|
||||
imguiColumnComboBox("Tone Map", tone_map_method_labels, 3,
|
||||
ImGui::ColumnComboBox("Tone Map", tone_map_method_labels, 3,
|
||||
&_tone_map_method, 0, false, &data->imgui_focus);
|
||||
tone_map->set_tone_map_method((tone_map_method)_tone_map_method);
|
||||
|
||||
float_t exposure = tone_map->get_exposure();
|
||||
imguiColumnSliderFloat("Exposure", &exposure, 0.02f, 0.0f, 4.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Exposure", &exposure, 0.02f, 0.0f, 4.0f, "%.2f", 0, true);
|
||||
exposure = roundf(exposure / 0.02f) * 0.02f;
|
||||
tone_map->set_exposure(exposure);
|
||||
|
||||
bool auto_exposure = tone_map->get_auto_exposure();
|
||||
imguiCheckbox("Auto Exposure", &auto_exposure);
|
||||
ImGui::CheckboxEnterKeyPressed("Auto Exposure", &auto_exposure);
|
||||
tone_map->set_auto_exposure(auto_exposure);
|
||||
|
||||
float_t gamma = tone_map->get_gamma();
|
||||
imguiColumnSliderFloat("Gamma", &gamma, 0.01f, 0.2f, 2.2f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Gamma", &gamma, 0.01f, 0.2f, 2.2f, "%.2f", 0, true);
|
||||
tone_map->set_gamma(gamma);
|
||||
|
||||
int32_t saturate1 = tone_map->get_saturate_power();
|
||||
imguiColumnSliderInt("Saturate 1", &saturate1, 1, 6, "%d", 0, true);
|
||||
ImGui::ColumnSliderInt("Saturate 1", &saturate1, 1, 6, "%d", 0, true);
|
||||
tone_map->set_saturate_power(saturate1);
|
||||
|
||||
float_t saturate2 = tone_map->get_saturate_coeff();
|
||||
imguiColumnSliderFloat("Saturate 2", &saturate2, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Saturate 2", &saturate2, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
tone_map->set_saturate_coeff(saturate2);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNodeEx("Glare", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
vec3 radius = blur->get_radius();
|
||||
imguiColumnSliderFloat("Radius R", &radius.x, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("Radius G", &radius.y, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("Radius B", &radius.z, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Radius R", &radius.x, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Radius G", &radius.y, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Radius B", &radius.z, 0.1f, 1.0f, 3.0f, "%.2f", 0, true);
|
||||
blur->set_radius(radius);
|
||||
|
||||
vec3 intensity = blur->get_intensity();
|
||||
imguiColumnSliderFloat("Inten R", &intensity.x, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("Inten G", &intensity.y, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("Inten B", &intensity.z, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Inten R", &intensity.x, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Inten G", &intensity.y, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
ImGui::ColumnSliderFloat("Inten B", &intensity.z, 0.05f, 0.0f, 2.0f, "%.2f", 0, true);
|
||||
blur->set_intensity(intensity);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
imguiSetDefaultColumnSpace();
|
||||
ImGui::SetDefaultColumnSpace();
|
||||
|
||||
if (ImGui::TreeNodeEx("DOF", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
bool use_ui_params = dof->data.debug.flags & DOF_DEBUG_USE_UI_PARAMS;
|
||||
bool phys = use_ui_params && dof->data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF;
|
||||
bool f2 = use_ui_params && ~dof->data.debug.flags & DOF_DEBUG_ENABLE_PHYS_DOF;
|
||||
|
||||
float_t alpha = style.Alpha * imgui_alpha_disabled_scale;
|
||||
float_t alpha = style.Alpha * ImGui::AlphaDisabledScale;
|
||||
|
||||
imguiCheckboxFlags("use UI params",
|
||||
ImGui::CheckboxFlagsEnterKeyPressed("use UI params",
|
||||
(uint32_t*)&dof->data.debug.flags, DOF_DEBUG_USE_UI_PARAMS);
|
||||
|
||||
if (!use_ui_params) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
}
|
||||
imguiCheckboxFlags("enable DOF",
|
||||
ImGui::CheckboxFlagsEnterKeyPressed("enable DOF",
|
||||
(uint32_t*)&dof->data.debug.flags, DOF_DEBUG_ENABLE_DOF);
|
||||
imguiCheckboxFlags("enable physical DOF",
|
||||
ImGui::CheckboxFlagsEnterKeyPressed("enable physical DOF",
|
||||
(uint32_t*)&dof->data.debug.flags, DOF_DEBUG_ENABLE_PHYS_DOF);
|
||||
if (!use_ui_params) {
|
||||
ImGui::PopItemFlag();
|
||||
@@ -179,27 +179,27 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
}
|
||||
imguiCheckboxFlags("auto focus",
|
||||
ImGui::CheckboxFlagsEnterKeyPressed("auto focus",
|
||||
(uint32_t*)&dof->data.debug.flags, DOF_DEBUG_AUTO_FOCUS);
|
||||
if (!phys) {
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
imguiSetColumnSpace(16.0f / 31.0f);
|
||||
ImGui::SetColumnSpace(16.0f / 31.0f);
|
||||
if (!phys) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
}
|
||||
imguiColumnSliderFloat("distance to focus[m]",
|
||||
ImGui::ColumnSliderFloat("distance to focus[m]",
|
||||
&dof->data.debug.focus, 0.01f, 0.01f, 30.0f, "%.2f", 0, true);
|
||||
|
||||
float_t focal_length = dof->data.debug.focal_length * 1000.0f;
|
||||
imguiColumnSliderFloat("focal length[mm]",
|
||||
ImGui::ColumnSliderFloat("focal length[mm]",
|
||||
&focal_length, 0.01f, 0.1f, 100.0f, "%.2f", 0, true);
|
||||
dof->data.debug.focal_length = focal_length / 1000.0f;
|
||||
|
||||
imguiColumnSliderFloat("F-Number",
|
||||
ImGui::ColumnSliderFloat("F-Number",
|
||||
&dof->data.debug.f_number, 0.01f, 0.1f, 40.0f, "%.2f", 0, true);
|
||||
if (!phys) {
|
||||
ImGui::PopItemFlag();
|
||||
@@ -210,23 +210,23 @@ void graphics_post_process_imgui(class_data* data) {
|
||||
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
}
|
||||
imguiColumnSliderFloat("f2 distance to focus[m]",
|
||||
ImGui::ColumnSliderFloat("f2 distance to focus[m]",
|
||||
&dof->data.debug.f2.focus, 0.01f, 0.01f, 30.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("f2 focus range[m]",
|
||||
ImGui::ColumnSliderFloat("f2 focus range[m]",
|
||||
&dof->data.debug.f2.focus_range, 0.01f, 0.0f, 10.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("f2 fuzzing range[m]",
|
||||
ImGui::ColumnSliderFloat("f2 fuzzing range[m]",
|
||||
&dof->data.debug.f2.fuzzing_range, 0.01f, 0.0f, 10.0f, "%.2f", 0, true);
|
||||
imguiColumnSliderFloat("f2 ratio",
|
||||
ImGui::ColumnSliderFloat("f2 ratio",
|
||||
&dof->data.debug.f2.ratio, 0.01f, 0.0f, 1.0f, "%.2f", 0, true);
|
||||
if (!f2) {
|
||||
ImGui::PopItemFlag();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
imguiSetDefaultColumnSpace();
|
||||
ImGui::SetDefaultColumnSpace();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (imguiButton("Reset Post Process", { 0, 0 })) {
|
||||
if (ImGui::ButtonEnterKeyPressed("Reset Post Process", { 0, 0 })) {
|
||||
stage* stg = task_stage_get_current_stage();
|
||||
light_param_storage_data_set_stage(stg->index);
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool graphics_post_process_init(class_data* data, render_context* rctx);
|
||||
extern void graphics_post_process_imgui(class_data* data);
|
||||
+13
-13
@@ -3,17 +3,17 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "render_settings.h"
|
||||
#include "../../../CRE/lock.h"
|
||||
#include "../../../CRE/static_var.h"
|
||||
#include "../../../CRE/timer.h"
|
||||
#include "../imgui_helper.h"
|
||||
#include "render_settings.hpp"
|
||||
#include "../../../CRE/lock.hpp"
|
||||
#include "../../../CRE/static_var.hpp"
|
||||
#include "../../../CRE/timer.hpp"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
|
||||
extern timer render_timer;
|
||||
extern timer sound_timer;
|
||||
extern timer* render_timer;
|
||||
extern timer* sound_timer;
|
||||
|
||||
extern size_t render_scale_table_count;
|
||||
extern double_t render_get_scale();
|
||||
@@ -74,17 +74,17 @@ void graphics_render_settings_imgui(class_data* data) {
|
||||
int32_t scale_index = render_get_scale_index();
|
||||
char buf[0x80];
|
||||
sprintf_s(buf, sizeof(buf), "%g%%%%", scale);
|
||||
if (imguiColumnSliderInt("Scale", &scale_index, 0,
|
||||
if (ImGui::ColumnSliderInt("Scale", &scale_index, 0,
|
||||
(int32_t)render_scale_table_count, buf, ImGuiSliderFlags_NoInput, true))
|
||||
render_set_scale_index(scale_index);
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
ImGui::Separator();
|
||||
|
||||
double_t render_freq = timer_get_freq(&render_timer);
|
||||
double_t sound_freq = timer_get_freq(&sound_timer);
|
||||
double_t render_freq_hist = timer_get_freq_hist(&render_timer);
|
||||
double_t sound_freq_hist = timer_get_freq_hist(&sound_timer);
|
||||
double_t render_freq = render_timer->get_freq();
|
||||
double_t sound_freq = sound_timer->get_freq();
|
||||
double_t render_freq_hist = render_timer->get_freq_hist();
|
||||
double_t sound_freq_hist = sound_timer->get_freq_hist();
|
||||
|
||||
char render_freq_str[0x20];
|
||||
char sound_freq_str[0x20];
|
||||
@@ -117,7 +117,7 @@ void graphics_render_settings_imgui(class_data* data) {
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (imguiButton("Reset Render Settings"))
|
||||
if (ImGui::ButtonEnterKeyPressed("Reset Render Settings"))
|
||||
render_set_scale(1.0);
|
||||
|
||||
data->imgui_focus |= ImGui::IsWindowFocused();
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool graphics_render_settings_init(class_data* data, render_context* rctx);
|
||||
extern void graphics_render_settings_imgui(class_data* data);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/imgui_internal.h>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
extern const float_t imgui_alpha_disabled_scale;
|
||||
|
||||
extern bool imgui_is_item_active;
|
||||
extern bool imgui_is_item_focused;
|
||||
extern bool imgui_is_item_visible;
|
||||
extern bool imgui_is_item_edited;
|
||||
extern bool imgui_is_item_activated;
|
||||
extern bool imgui_is_item_deactivated;
|
||||
extern bool imgui_is_item_deactivated_after_edit;
|
||||
extern bool imgui_is_item_toggled_open;
|
||||
|
||||
extern bool imguiItemKeyDown(int32_t key);
|
||||
extern bool imguiItemKeyPressed(int32_t key, bool repeat);
|
||||
extern bool imguiItemKeyReleased(int32_t key);
|
||||
extern float_t imguiGetColumnSpace();
|
||||
extern void imguiSetColumnSpace(float_t val);
|
||||
extern void imguiSetDefaultColumnSpace();
|
||||
extern void imguiDisableElementPush(bool enable);
|
||||
extern void imguiDisableElementPop(bool enable);
|
||||
extern float_t imguiGetContentRegionAvailWidth();
|
||||
extern float_t imguiGetContentRegionAvailHeight();
|
||||
extern void imguiGetContentRegionAvailSetNextItemWidth();
|
||||
|
||||
extern void imguiStartPropertyColumn(const char* label);
|
||||
extern void imguiEndPropertyColumn();
|
||||
|
||||
bool igSliderFloatButton(const char* label, float_t* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
bool igSliderIntButton(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
|
||||
extern bool imguiButton(const char* label, const ImVec2& size = ImVec2(0, 0));
|
||||
extern bool imguiButtonEx(const char* label, const ImVec2& size = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
extern bool imguiCheckbox(const char* label, bool* v);
|
||||
extern bool imguiCheckboxFlags(const char* label, int* flags, int flags_value);
|
||||
extern bool imguiCheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||
extern bool imguiComboBox(const char* label, const char** items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiComboBox(const char* label, const char** items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnColorEdit3(const char* label, vec3* val, ImGuiColorEditFlags flags);
|
||||
extern bool imguiColumnColorEdit4(const char* label, vec4* val, ImGuiColorEditFlags flags);
|
||||
extern bool imguiColumnComboBox(const char* label, const char** items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnComboBox(const char* label, const char** items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool imguiColumnDragFloat(const char* label, float_t* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec2(const char* label, vec2* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec3(const char* label, vec3* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec4(const char* label, vec4* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragInt(const char* label, int32_t* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec2I(const char* label, vec2i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec3I(const char* label, vec3i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnDragVec4I(const char* label, vec4i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnInputText(const char* label, char* buf, size_t buf_size,
|
||||
ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data);
|
||||
extern bool imguiColumnSliderFloat(const char* label, float_t* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec2(const char* label, vec2* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec3(const char* label, vec3* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec4(const char* label, vec4* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderInt(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec2I(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec3I(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderVec4I(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button);
|
||||
extern bool imguiColumnSliderLogInt(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnSliderLogVec2I(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnSliderLogVec3I(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnSliderLogVec4I(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool imguiColumnInputScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags);
|
||||
extern bool imguiColumnDragFloatFlag(const char* label, float_t* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec2Flag(const char* label, vec2* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec3Flag(const char* label, vec3* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec4Flag(const char* label, vec4* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragIntFlag(const char* label, int32_t* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec2IFlag(const char* label, vec2i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec3IFlag(const char* label, vec3i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnDragVec4IFlag(const char* label, vec4i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderFloatFlag(const char* label, float_t* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec2Flag(const char* label, vec2* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec3Flag(const char* label, vec3* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec4Flag(const char* label, vec4* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderIntFlag(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec2IFlag(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec3IFlag(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool imguiColumnSliderVec4IFlag(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/imgui_internal.h>
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace ImGui {
|
||||
extern const float_t AlphaDisabledScale;
|
||||
|
||||
extern bool IsItemActiveAccum;
|
||||
extern bool IsItemFocusedAccum;
|
||||
extern bool IsItemVisibleAccum;
|
||||
extern bool IsItemEditedAccum;
|
||||
extern bool IsItemActivatedAccum;
|
||||
extern bool IsItemDeactivatedAccum;
|
||||
extern bool IsItemDeactivatedAfterEditAccum;
|
||||
extern bool IsItemToggledOpenAccum;
|
||||
|
||||
extern bool ItemKeyDown(int32_t key);
|
||||
extern bool ItemKeyPressed(int32_t key, bool repeat);
|
||||
extern bool ItemKeyReleased(int32_t key);
|
||||
extern float_t GetColumnSpace();
|
||||
extern void SetColumnSpace(float_t val);
|
||||
extern void SetDefaultColumnSpace();
|
||||
extern void DisableElementPush(bool enable);
|
||||
extern void DisableElementPop(bool enable);
|
||||
extern float_t GetContentRegionAvailWidth();
|
||||
extern float_t GetContentRegionAvailHeight();
|
||||
extern void GetContentRegionAvailSetNextItemWidth();
|
||||
|
||||
extern void StartPropertyColumn(const char* label);
|
||||
extern void EndPropertyColumn();
|
||||
|
||||
bool SliderFloatButton(const char* label, float_t* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
bool SliderIntButton(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
|
||||
extern bool ButtonEnterKeyPressed(const char* label, const ImVec2& size = ImVec2(0, 0));
|
||||
extern bool ButtonExEnterKeyPressed(const char* label, const ImVec2& size = ImVec2(0, 0), ImGuiButtonFlags flags = 0);
|
||||
extern bool CheckboxEnterKeyPressed(const char* label, bool* v);
|
||||
extern bool CheckboxFlagsEnterKeyPressed(const char* label, int* flags, int flags_value);
|
||||
extern bool CheckboxFlagsEnterKeyPressed(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||
extern bool ComboBox(const char* label, const char** items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ComboBox(const char* label, const char** items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnColorEdit3(const char* label, vec3* val, ImGuiColorEditFlags flags);
|
||||
extern bool ColumnColorEdit4(const char* label, vec4* val, ImGuiColorEditFlags flags);
|
||||
extern bool ColumnComboBox(const char* label, const char** items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnComboBox(const char* label, const char** items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnComboBoxString(const char* label, std::string* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
int32_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnComboBoxConfigFile(const char* label, void* items, const size_t size,
|
||||
size_t* selected_idx, ImGuiComboFlags flags, bool include_last, bool* focus);
|
||||
extern bool ColumnDragFloat(const char* label, float_t* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec2(const char* label, vec2* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec3(const char* label, vec3* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec4(const char* label, vec4* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragInt(const char* label, int32_t* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec2I(const char* label, vec2i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec3I(const char* label, vec3i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnDragVec4I(const char* label, vec4i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnInputText(const char* label, char* buf, size_t buf_size,
|
||||
ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data);
|
||||
extern bool ColumnSliderFloat(const char* label, float_t* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec2(const char* label, vec2* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec3(const char* label, vec3* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec4(const char* label, vec4* val, float_t step,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderInt(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec2I(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec3I(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderVec4I(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, bool button = true);
|
||||
extern bool ColumnSliderLogInt(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnSliderLogVec2I(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnSliderLogVec3I(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnSliderLogVec4I(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags);
|
||||
extern bool ColumnInputScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags);
|
||||
extern bool ColumnDragFloat(const char* label, float_t* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec2(const char* label, vec2* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec3(const char* label, vec3* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec4(const char* label, vec4* val, float_t speed,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragInt(const char* label, int32_t* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec2I(const char* label, vec2i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec3I(const char* label, vec3i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnDragVec4I(const char* label, vec4i* val, float_t speed,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderFloat(const char* label, float_t* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec2(const char* label, vec2* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec3(const char* label, vec3* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec4(const char* label, vec4* val,
|
||||
float_t min, float_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderInt(const char* label, int32_t* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec2I(const char* label, vec2i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec3I(const char* label, vec3i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
extern bool ColumnSliderVec4I(const char* label, vec4i* val,
|
||||
int32_t min, int32_t max, const char* format, ImGuiSliderFlags flags, int32_t bit_flag);
|
||||
}
|
||||
@@ -3,9 +3,9 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "information.h"
|
||||
#include "information/frame_speed.h"
|
||||
#include "information/task.h"
|
||||
#include "information.hpp"
|
||||
#include "information/frame_speed.hpp"
|
||||
#include "information/task.hpp"
|
||||
|
||||
classes_data information_classes[] = {
|
||||
{
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../classes.h"
|
||||
#include "../classes.hpp"
|
||||
|
||||
enum information_classes_enum {
|
||||
INFORMATION_FRAME_SPEED,
|
||||
+4
-4
@@ -3,8 +3,8 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "frame_speed.h"
|
||||
#include "../imgui_helper.h"
|
||||
#include "frame_speed.hpp"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -44,8 +44,8 @@ void information_frame_speed_imgui(class_data* data) {
|
||||
return;
|
||||
}
|
||||
|
||||
imguiGetContentRegionAvailSetNextItemWidth();
|
||||
imguiColumnSliderFloat("frame speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
|
||||
ImGui::GetContentRegionAvailSetNextItemWidth();
|
||||
ImGui::ColumnSliderFloat("frame speed", &frame_speed, 0.01f, 0.0f, 3.0f, "%.2f", 0, true);
|
||||
|
||||
data->imgui_focus |= ImGui::IsWindowFocused();
|
||||
ImGui::End();
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool information_frame_speed_init(class_data* data, render_context* rctx);
|
||||
extern void information_frame_speed_imgui(class_data* data);
|
||||
@@ -3,11 +3,11 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "task.h"
|
||||
#include "task.hpp"
|
||||
#include "../../../KKdLib/sort.hpp"
|
||||
#include "../../../KKdLib/str_utils.hpp"
|
||||
#include "../../../CRE/task.hpp"
|
||||
#include "../imgui_helper.h"
|
||||
#include "../imgui_helper.hpp"
|
||||
|
||||
extern int32_t width;
|
||||
extern int32_t height;
|
||||
@@ -6,7 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../../KKdLib/default.hpp"
|
||||
#include "../../classes.h"
|
||||
#include "../../classes.hpp"
|
||||
|
||||
extern bool information_task_init(class_data* data, render_context* rctx);
|
||||
extern void information_task_imgui(class_data* data);
|
||||
-3147
File diff suppressed because it is too large
Load Diff
+302
-184
@@ -8,7 +8,7 @@
|
||||
#include "input.hpp"
|
||||
#include <map>
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "../CRE/timer.h"
|
||||
#include "../CRE/timer.hpp"
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <timeapi.h>
|
||||
|
||||
@@ -19,12 +19,11 @@ vec2d input_rotate;
|
||||
double_t input_roll;
|
||||
bool input_reset;
|
||||
bool input_reset_mouse_position;
|
||||
bool input_shaders_reload;
|
||||
bool input_locked;
|
||||
|
||||
extern bool close;
|
||||
extern lock render_lock;
|
||||
extern timer render_timer;
|
||||
extern timer* render_timer;
|
||||
extern HWND window_handle;
|
||||
extern ImGuiContext* imgui_context;
|
||||
extern lock imgui_context_lock;
|
||||
@@ -43,148 +42,143 @@ namespace Input {
|
||||
int32_t mods;
|
||||
};
|
||||
|
||||
std::map<int32_t, Key> keys;
|
||||
std::map<int32_t, MouseButton> mouse_buttons;
|
||||
std::vector<Key> keys;
|
||||
std::vector<MouseButton> mouse_buttons;
|
||||
POINT pos;
|
||||
|
||||
std::map<int32_t, Key> keys_prev;
|
||||
std::map<int32_t, MouseButton> mouse_buttons_prev;
|
||||
std::vector<Key> keys_prev;
|
||||
std::vector<MouseButton> mouse_buttons_prev;
|
||||
POINT pos_prev;
|
||||
|
||||
static bool is_key_mod(int32_t key);
|
||||
static bool is_key_numpad(int32_t key);
|
||||
static void KeyboardCallback(GLFWwindow* window,
|
||||
int32_t key, int32_t scancode, int32_t action, int32_t mods);
|
||||
static void MouseButtonCallback(GLFWwindow* window,
|
||||
int32_t button, int32_t action, int32_t mods);
|
||||
static Key* vector_Key_find(std::vector<Key>& keys, int32_t key);
|
||||
static MouseButton* vector_MouseButton_find(
|
||||
std::vector<MouseButton>& mouse_buttons, int32_t button);
|
||||
|
||||
bool IsKeyDown(int32_t key, int32_t mods) {
|
||||
auto elem = keys.find(key);
|
||||
if (elem != keys.end())
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE;
|
||||
Key* k = vector_Key_find(keys, key);
|
||||
if (k && (mods == -1 || k->mods == mods))
|
||||
return k->action != GLFW_RELEASE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsKeyUp(int32_t key, int32_t mods) {
|
||||
auto elem = keys.find(key);
|
||||
if (elem != keys.end())
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE;
|
||||
Key* k = vector_Key_find(keys, key);
|
||||
if (k && (mods == -1 || k->mods == mods))
|
||||
return k->action == GLFW_RELEASE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsKeyTapped(int32_t key, int32_t mods) {
|
||||
auto elem = keys.find(key);
|
||||
auto elem_prev = keys_prev.find(key);
|
||||
if (elem != keys.end())
|
||||
if (elem_prev != keys_prev.end()) {
|
||||
if (elem->second.mods == mods && elem_prev->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE && elem_prev->second.action == GLFW_RELEASE;
|
||||
Key* k = vector_Key_find(keys, key);
|
||||
Key* k_prev = vector_Key_find(keys_prev, key);
|
||||
if (k)
|
||||
if (k_prev) {
|
||||
if (mods == -1 || (k->mods == mods && k_prev->mods == mods))
|
||||
return k->action != GLFW_RELEASE && k_prev->action == GLFW_RELEASE;
|
||||
}
|
||||
else {
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE;
|
||||
if (mods == -1 || k->mods == mods)
|
||||
return k->action != GLFW_RELEASE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsKeyReleased(int32_t key, int32_t mods) {
|
||||
auto elem = keys.find(key);
|
||||
auto elem_prev = keys_prev.find(key);
|
||||
if (elem != keys.end())
|
||||
if (elem_prev != keys_prev.end()) {
|
||||
if (elem->second.mods == mods && elem_prev->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE && elem_prev->second.action != GLFW_RELEASE;
|
||||
Key* k = vector_Key_find(keys, key);
|
||||
Key* k_prev = vector_Key_find(keys_prev, key);
|
||||
if (k)
|
||||
if (k_prev) {
|
||||
if ((k->mods == mods && k_prev->mods == mods))
|
||||
return k->action == GLFW_RELEASE && k_prev->action != GLFW_RELEASE;
|
||||
}
|
||||
else {
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE;
|
||||
if (mods == -1 || k->mods == mods)
|
||||
return k->action == GLFW_RELEASE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMouseButtonDown(int32_t button, int32_t mods) {
|
||||
auto elem = mouse_buttons.find(button);
|
||||
if (elem != mouse_buttons.end())
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE;
|
||||
MouseButton* mb = vector_MouseButton_find(mouse_buttons, button);
|
||||
if (mb && (mods == -1 || mb->mods == mods))
|
||||
return mb->action != GLFW_RELEASE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMouseButtonUp(int32_t button, int32_t mods) {
|
||||
auto elem = mouse_buttons.find(button);
|
||||
if (elem != mouse_buttons.end())
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE;
|
||||
MouseButton* mb = vector_MouseButton_find(mouse_buttons, button);
|
||||
if (mb && (mods == -1 || mb->mods == mods))
|
||||
return mb->action == GLFW_RELEASE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMouseButtonTapped(int32_t button, int32_t mods) {
|
||||
auto elem = mouse_buttons.find(button);
|
||||
auto elem_prev = mouse_buttons_prev.find(button);
|
||||
if (elem != mouse_buttons.end())
|
||||
if (elem_prev != mouse_buttons_prev.end()) {
|
||||
if (elem->second.mods == mods && elem_prev->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE && elem_prev->second.action == GLFW_RELEASE;
|
||||
MouseButton* mb = vector_MouseButton_find(mouse_buttons, button);
|
||||
MouseButton* mb_prev = vector_MouseButton_find(mouse_buttons_prev, button);
|
||||
if (mb)
|
||||
if (mb_prev) {
|
||||
if ((mods == -1 || mb->mods == mods && mb_prev->mods == mods))
|
||||
return mb->action != GLFW_RELEASE && mb_prev->action == GLFW_RELEASE;
|
||||
}
|
||||
else {
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action != GLFW_RELEASE;
|
||||
if (mods == -1 || mb->mods == mods)
|
||||
return mb->action != GLFW_RELEASE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsMouseButtonReleased(int32_t button, int32_t mods) {
|
||||
auto elem = mouse_buttons.find(button);
|
||||
auto elem_prev = mouse_buttons_prev.find(button);
|
||||
if (elem != mouse_buttons.end())
|
||||
if (elem_prev != mouse_buttons_prev.end()) {
|
||||
if (elem->second.mods == mods && elem_prev->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE && elem_prev->second.action != GLFW_RELEASE;
|
||||
MouseButton* mb = vector_MouseButton_find(mouse_buttons, button);
|
||||
MouseButton* mb_prev = vector_MouseButton_find(mouse_buttons_prev, button);
|
||||
if (mb)
|
||||
if (mb_prev) {
|
||||
if ((mods == -1 || mb->mods == mods && mb_prev->mods == mods))
|
||||
return mb->action == GLFW_RELEASE && mb_prev->action != GLFW_RELEASE;
|
||||
}
|
||||
else {
|
||||
if (elem->second.mods == mods)
|
||||
return elem->second.action == GLFW_RELEASE;
|
||||
if (mods == -1 || mb->mods == mods)
|
||||
return mb->action == GLFW_RELEASE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WasKeyDown(int32_t key, int32_t mods) {
|
||||
auto elem_prev = keys_prev.find(key);
|
||||
if (elem_prev != keys_prev.end())
|
||||
if (elem_prev->second.mods == mods)
|
||||
return elem_prev->second.action != GLFW_RELEASE;
|
||||
Key* k_prev = vector_Key_find(keys_prev, key);
|
||||
if (k_prev && (mods == -1 || k_prev->mods == mods))
|
||||
return k_prev->action != GLFW_RELEASE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WasKeyUp(int32_t key, int32_t mods) {
|
||||
auto elem_prev = keys_prev.find(key);
|
||||
if (elem_prev != keys_prev.end())
|
||||
if (elem_prev->second.mods == mods)
|
||||
return elem_prev->second.action == GLFW_RELEASE;
|
||||
Key* k_prev = vector_Key_find(keys_prev, key);
|
||||
if (k_prev && (mods == -1 || k_prev->mods == mods))
|
||||
return k_prev->action == GLFW_RELEASE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WasMouseButtonDown(int32_t button, int32_t mods) {
|
||||
auto elem_prev = mouse_buttons_prev.find(button);
|
||||
if (elem_prev != mouse_buttons_prev.end())
|
||||
if (elem_prev->second.mods == mods)
|
||||
return elem_prev->second.action != GLFW_RELEASE;
|
||||
MouseButton* mb_prev = vector_MouseButton_find(mouse_buttons_prev, button);
|
||||
if (mb_prev && (mods == -1 || mb_prev->mods == mods))
|
||||
return mb_prev->action != GLFW_RELEASE;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WasMouseButtonUp(int32_t button, int32_t mods) {
|
||||
auto elem_prev = mouse_buttons_prev.find(button);
|
||||
if (elem_prev != mouse_buttons_prev.end())
|
||||
if (elem_prev->second.mods == mods)
|
||||
return elem_prev->second.action == GLFW_RELEASE;
|
||||
MouseButton* mb_prev = vector_MouseButton_find(mouse_buttons_prev, button);
|
||||
if (mb_prev && (mods == -1 || mb_prev->mods == mods))
|
||||
return mb_prev->action == GLFW_RELEASE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void EndFrame() {
|
||||
for (auto& i : keys)
|
||||
keys_prev.insert_or_assign(i.first, i.second);
|
||||
for (auto& i : mouse_buttons)
|
||||
mouse_buttons_prev.insert_or_assign(i.first, i.second);
|
||||
keys_prev = keys;
|
||||
mouse_buttons_prev = mouse_buttons;
|
||||
}
|
||||
|
||||
void NewFrame() {
|
||||
@@ -204,113 +198,132 @@ namespace Input {
|
||||
if (!window_handle || window_handle != GetForegroundWindow())
|
||||
return;
|
||||
|
||||
double_t freq = timer_get_freq(&render_timer);
|
||||
double_t freq_hist = timer_get_freq_hist(&render_timer);
|
||||
double_t freq = render_timer->get_freq();
|
||||
double_t freq_hist = render_timer->get_freq_hist();
|
||||
double_t frame_speed = freq / freq_hist;
|
||||
|
||||
input_locked = false;
|
||||
classes_process_input(classes, classes_count);
|
||||
|
||||
if (!input_locked) {
|
||||
double_t speed = input_movement_speed;
|
||||
double_t speed_fast = input_movement_speed * 10.0;
|
||||
double_t speed_slow = input_movement_speed / 10.0;
|
||||
speed *= frame_speed;
|
||||
speed_fast *= frame_speed;
|
||||
speed_slow *= frame_speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_W) || IsKeyDown(GLFW_KEY_W, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.x += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_W, GLFW_MOD_SHIFT))
|
||||
input_move.x += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_W, GLFW_MOD_CONTROL))
|
||||
input_move.x += speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_S) || IsKeyDown(GLFW_KEY_S, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.x -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_S, GLFW_MOD_SHIFT))
|
||||
input_move.x -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_S, GLFW_MOD_CONTROL))
|
||||
input_move.x -= speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_A) || IsKeyDown(GLFW_KEY_A, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.y -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_A, GLFW_MOD_SHIFT))
|
||||
input_move.y -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_A, GLFW_MOD_CONTROL))
|
||||
input_move.y -= speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_D) || IsKeyDown(GLFW_KEY_D, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.y += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_D, GLFW_MOD_SHIFT))
|
||||
input_move.y += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_D, GLFW_MOD_CONTROL))
|
||||
input_move.y += speed_slow;
|
||||
|
||||
speed = input_movement_speed;
|
||||
speed_fast = input_movement_speed * 2.0;
|
||||
speed_slow = input_movement_speed / 2.0;
|
||||
speed *= frame_speed;
|
||||
speed_fast *= frame_speed;
|
||||
speed_slow *= frame_speed;
|
||||
speed *= freq / freq_hist;
|
||||
speed_fast *= freq / freq_hist;
|
||||
speed_slow *= freq / freq_hist;
|
||||
speed *= 10.0;
|
||||
speed_fast *= 10.0;
|
||||
speed_slow *= 10.0;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_UP) || IsKeyDown(GLFW_KEY_UP, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.y += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_UP, GLFW_MOD_SHIFT))
|
||||
input_rotate.y += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_UP, GLFW_MOD_CONTROL))
|
||||
input_rotate.y += speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_DOWN) || IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.y -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_SHIFT))
|
||||
input_rotate.y -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_CONTROL))
|
||||
input_rotate.y -= speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_LEFT) || IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.x -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_SHIFT))
|
||||
input_rotate.x -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_CONTROL))
|
||||
input_rotate.x -= speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_RIGHT) || IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.x += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_SHIFT))
|
||||
input_rotate.x += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_CONTROL))
|
||||
input_rotate.x += speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_Q) || IsKeyDown(GLFW_KEY_Q, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_roll += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_Q, GLFW_MOD_SHIFT))
|
||||
input_roll += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_Q, GLFW_MOD_CONTROL))
|
||||
input_roll += speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_E) || IsKeyDown(GLFW_KEY_E, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_roll += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_E, GLFW_MOD_SHIFT))
|
||||
input_roll += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_E, GLFW_MOD_CONTROL))
|
||||
input_roll += speed_slow;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_R, GLFW_MOD_CONTROL))
|
||||
input_shaders_reload = true;
|
||||
else if (IsKeyDown(GLFW_KEY_R))
|
||||
input_reset = true;
|
||||
if (input_locked) {
|
||||
input_reset_mouse_position = true;
|
||||
return;
|
||||
}
|
||||
|
||||
lock_lock(&imgui_context_lock);
|
||||
ImGui::SetCurrentContext(imgui_context);
|
||||
if (!ImGui::GetIO().WantCaptureMouse && Input::IsMouseButtonDown(GLFW_MOUSE_BUTTON_MIDDLE)) {
|
||||
double_t speed = input_movement_speed;
|
||||
double_t speed_fast = input_movement_speed * 10.0;
|
||||
double_t speed_slow = input_movement_speed / 10.0;
|
||||
speed *= frame_speed;
|
||||
speed_fast *= frame_speed;
|
||||
speed_slow *= frame_speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_W) || IsKeyDown(GLFW_KEY_W, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.x += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_W, GLFW_MOD_SHIFT))
|
||||
input_move.x += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_W, GLFW_MOD_CONTROL))
|
||||
input_move.x += speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_W, -1))
|
||||
input_move.x += speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_S) || IsKeyDown(GLFW_KEY_S, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.x -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_S, GLFW_MOD_SHIFT))
|
||||
input_move.x -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_S, GLFW_MOD_CONTROL))
|
||||
input_move.x -= speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_S, -1))
|
||||
input_move.x -= speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_A) || IsKeyDown(GLFW_KEY_A, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.y -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_A, GLFW_MOD_SHIFT))
|
||||
input_move.y -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_A, GLFW_MOD_CONTROL))
|
||||
input_move.y -= speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_A, -1))
|
||||
input_move.y -= speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_D) || IsKeyDown(GLFW_KEY_D, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_move.y += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_D, GLFW_MOD_SHIFT))
|
||||
input_move.y += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_D, GLFW_MOD_CONTROL))
|
||||
input_move.y += speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_D, -1))
|
||||
input_move.y += speed;
|
||||
|
||||
speed = input_movement_speed;
|
||||
speed_fast = input_movement_speed * 2.0;
|
||||
speed_slow = input_movement_speed / 2.0;
|
||||
speed *= frame_speed;
|
||||
speed_fast *= frame_speed;
|
||||
speed_slow *= frame_speed;
|
||||
speed *= freq / freq_hist;
|
||||
speed_fast *= freq / freq_hist;
|
||||
speed_slow *= freq / freq_hist;
|
||||
speed *= 10.0;
|
||||
speed_fast *= 10.0;
|
||||
speed_slow *= 10.0;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_UP) || IsKeyDown(GLFW_KEY_UP, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.y += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_UP, GLFW_MOD_SHIFT))
|
||||
input_rotate.y += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_UP, GLFW_MOD_CONTROL))
|
||||
input_rotate.y += speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_UP, -1))
|
||||
input_rotate.y += speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_DOWN) || IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.y -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_SHIFT))
|
||||
input_rotate.y -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_DOWN, GLFW_MOD_CONTROL))
|
||||
input_rotate.y -= speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_DOWN, -1))
|
||||
input_rotate.y -= speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_LEFT) || IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.x -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_SHIFT))
|
||||
input_rotate.x -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_LEFT, GLFW_MOD_CONTROL))
|
||||
input_rotate.x -= speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_LEFT, -1))
|
||||
input_rotate.x -= speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_RIGHT) || IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_rotate.x += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_SHIFT))
|
||||
input_rotate.x += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_RIGHT, GLFW_MOD_CONTROL))
|
||||
input_rotate.x += speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_RIGHT, -1))
|
||||
input_rotate.x += speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_Q) || IsKeyDown(GLFW_KEY_Q, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_roll += speed;
|
||||
else if (IsKeyDown(GLFW_KEY_Q, GLFW_MOD_SHIFT))
|
||||
input_roll += speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_Q, GLFW_MOD_CONTROL))
|
||||
input_roll += speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_Q, -1))
|
||||
input_roll += speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_E) || IsKeyDown(GLFW_KEY_E, GLFW_MOD_CONTROL | GLFW_MOD_SHIFT))
|
||||
input_roll -= speed;
|
||||
else if (IsKeyDown(GLFW_KEY_E, GLFW_MOD_SHIFT))
|
||||
input_roll -= speed_fast;
|
||||
else if (IsKeyDown(GLFW_KEY_E, GLFW_MOD_CONTROL))
|
||||
input_roll -= speed_slow;
|
||||
else if (IsKeyDown(GLFW_KEY_E, -1))
|
||||
input_roll -= speed;
|
||||
|
||||
if (IsKeyDown(GLFW_KEY_R))
|
||||
input_reset = true;
|
||||
|
||||
if (IsMouseButtonDown(GLFW_MOUSE_BUTTON_MIDDLE, -1)) {
|
||||
if (!input_reset_mouse_position) {
|
||||
input_rotate.y += ((double_t)pos_prev.y - (double_t)pos.y) * input_rotation_sensitivity;
|
||||
input_rotate.x += ((double_t)pos.x - (double_t)pos_prev.x) * input_rotation_sensitivity;
|
||||
@@ -319,7 +332,6 @@ namespace Input {
|
||||
}
|
||||
else
|
||||
input_reset_mouse_position = true;
|
||||
lock_unlock(&imgui_context_lock);
|
||||
}
|
||||
|
||||
void SetInputs(GLFWwindow* window) {
|
||||
@@ -327,21 +339,127 @@ namespace Input {
|
||||
glfwSetMouseButtonCallback(window, (GLFWmousebuttonfun)MouseButtonCallback);
|
||||
}
|
||||
|
||||
static bool is_key_mod(int32_t key) {
|
||||
switch (key) {
|
||||
case GLFW_KEY_LEFT_SHIFT:
|
||||
case GLFW_KEY_LEFT_CONTROL:
|
||||
case GLFW_KEY_LEFT_ALT:
|
||||
case GLFW_KEY_LEFT_SUPER:
|
||||
case GLFW_KEY_RIGHT_SHIFT:
|
||||
case GLFW_KEY_RIGHT_CONTROL:
|
||||
case GLFW_KEY_RIGHT_ALT:
|
||||
case GLFW_KEY_RIGHT_SUPER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_key_numpad(int32_t key) {
|
||||
switch (key) {
|
||||
case GLFW_KEY_KP_0:
|
||||
case GLFW_KEY_KP_1:
|
||||
case GLFW_KEY_KP_2:
|
||||
case GLFW_KEY_KP_3:
|
||||
case GLFW_KEY_KP_4:
|
||||
case GLFW_KEY_KP_5:
|
||||
case GLFW_KEY_KP_6:
|
||||
case GLFW_KEY_KP_7:
|
||||
case GLFW_KEY_KP_8:
|
||||
case GLFW_KEY_KP_9:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void KeyboardCallback(GLFWwindow* window,
|
||||
int32_t key, int32_t scancode, int32_t action, int32_t mods) {
|
||||
auto elem = keys.find(key);
|
||||
if (elem != keys.end())
|
||||
elem->second = { key, scancode, action, mods };
|
||||
if (mods & GLFW_MOD_CAPS_LOCK)
|
||||
mods &= ~GLFW_MOD_CAPS_LOCK;
|
||||
|
||||
if (mods & GLFW_MOD_NUM_LOCK)
|
||||
mods &= ~GLFW_MOD_NUM_LOCK;
|
||||
|
||||
bool is_mod = false;
|
||||
switch (key) {
|
||||
case GLFW_KEY_LEFT_SHIFT:
|
||||
case GLFW_KEY_RIGHT_SHIFT:
|
||||
mods = GLFW_MOD_SHIFT;
|
||||
is_mod = true;
|
||||
break;
|
||||
case GLFW_KEY_LEFT_CONTROL:
|
||||
case GLFW_KEY_RIGHT_CONTROL:
|
||||
mods = GLFW_MOD_CONTROL;
|
||||
is_mod = true;
|
||||
break;
|
||||
case GLFW_KEY_LEFT_ALT:
|
||||
case GLFW_KEY_RIGHT_ALT:
|
||||
mods = GLFW_MOD_ALT;
|
||||
is_mod = true;
|
||||
break;
|
||||
case GLFW_KEY_LEFT_SUPER:
|
||||
case GLFW_KEY_RIGHT_SUPER:
|
||||
mods = GLFW_MOD_SUPER;
|
||||
is_mod = true;
|
||||
break;
|
||||
case GLFW_MOD_CAPS_LOCK:
|
||||
mods = 0;
|
||||
break;
|
||||
case GLFW_KEY_NUM_LOCK:
|
||||
mods = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_mod) {
|
||||
if (action != GLFW_RELEASE) {
|
||||
for (Key& i : keys)
|
||||
if (!is_key_mod(i.key))
|
||||
i.mods |= mods;
|
||||
|
||||
for (MouseButton& i : mouse_buttons)
|
||||
i.mods |= mods;
|
||||
}
|
||||
else {
|
||||
mods = ~mods;
|
||||
for (Key& i : keys)
|
||||
if (!is_key_mod(i.key))
|
||||
i.mods &= mods;
|
||||
|
||||
for (MouseButton& i : mouse_buttons)
|
||||
i.mods &= mods;
|
||||
}
|
||||
mods = 0;
|
||||
}
|
||||
|
||||
Key* k = vector_Key_find(keys, key);
|
||||
if (k)
|
||||
*k = { key, scancode, action, mods };
|
||||
else
|
||||
keys.insert({ key, { key, scancode, action, mods } });
|
||||
keys.push_back({ key, scancode, action, mods });
|
||||
}
|
||||
|
||||
static void MouseButtonCallback(GLFWwindow* window,
|
||||
int32_t button, int32_t action, int32_t mods) {
|
||||
auto elem = mouse_buttons.find(button);
|
||||
if (elem != mouse_buttons.end())
|
||||
elem->second = { button, action, mods };
|
||||
MouseButton* mb = vector_MouseButton_find(mouse_buttons, button);
|
||||
if (mb)
|
||||
*mb = { button, action, mods };
|
||||
else
|
||||
mouse_buttons.insert({ button, { button, action, mods } });
|
||||
mouse_buttons.push_back({ button, action, mods });
|
||||
}
|
||||
|
||||
static Key* vector_Key_find(std::vector<Key>& keys, int32_t key) {
|
||||
for (Key& i : keys)
|
||||
if (i.key == key)
|
||||
return &i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static MouseButton* vector_MouseButton_find(
|
||||
std::vector<MouseButton>& mouse_buttons, int32_t button) {
|
||||
for (MouseButton& i : mouse_buttons)
|
||||
if (i.button == button)
|
||||
return &i;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared.h"
|
||||
#include "shared.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace Input {
|
||||
|
||||
-260
@@ -1,260 +0,0 @@
|
||||
// Copyright (C) 2014 Hykem <hykem@hotmail.com>
|
||||
// Licensed under the terms of the GNU GPL, version 3
|
||||
// http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
#include "lz.h"
|
||||
|
||||
void decode_range(unsigned int *range, unsigned int *code, unsigned char **src)
|
||||
{
|
||||
if (!((*range) >> 24))
|
||||
{
|
||||
(*range) <<= 8;
|
||||
*code = ((*code) << 8) + (*src)++[5];
|
||||
}
|
||||
}
|
||||
|
||||
int decode_bit(unsigned int *range, unsigned int *code, int *index, unsigned char **src, unsigned char *c)
|
||||
{
|
||||
decode_range(range, code, src);
|
||||
|
||||
unsigned int val = ((*range) >> 8) * (*c);
|
||||
|
||||
*c -= ((*c) >> 3);
|
||||
if (index) (*index) <<= 1;
|
||||
|
||||
if (*code < val)
|
||||
{
|
||||
*range = val;
|
||||
*c += 31;
|
||||
if (index) (*index)++;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
*code -= val;
|
||||
*range -= val;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int decode_number(unsigned char *ptr, int index, int *bit_flag, unsigned int *range, unsigned int *code, unsigned char **src)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (index >= 3)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 0x18);
|
||||
if (index >= 4)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 0x18);
|
||||
if (index >= 5)
|
||||
{
|
||||
decode_range(range, code, src);
|
||||
for (; index >= 5; index--)
|
||||
{
|
||||
i <<= 1;
|
||||
(*range) >>= 1;
|
||||
if (*code < *range)
|
||||
i++;
|
||||
else
|
||||
(*code) -= *range;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*bit_flag = decode_bit(range, code, &i, src, ptr);
|
||||
|
||||
if (index >= 1)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 0x8);
|
||||
if (index >= 2)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 0x10);
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int decode_word(unsigned char *ptr, int index, int *bit_flag, unsigned int *range, unsigned int *code, unsigned char **src)
|
||||
{
|
||||
int i = 1;
|
||||
index /= 8;
|
||||
|
||||
if (index >= 3)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 4);
|
||||
if (index >= 4)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 4);
|
||||
if (index >= 5)
|
||||
{
|
||||
decode_range(range, code, src);
|
||||
for (; index >= 5; index--)
|
||||
{
|
||||
i <<= 1;
|
||||
(*range) >>= 1;
|
||||
if (*code < *range)
|
||||
i++;
|
||||
else
|
||||
(*code) -= *range;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*bit_flag = decode_bit(range, code, &i, src, ptr);
|
||||
|
||||
if (index >= 1)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 1);
|
||||
if (index >= 2)
|
||||
{
|
||||
decode_bit(range, code, &i, src, ptr + 2);
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
int decompress(unsigned char* out, unsigned char* in, unsigned int size)
|
||||
{
|
||||
int result;
|
||||
|
||||
unsigned char tmp[0xCC8];
|
||||
|
||||
int offset = 0;
|
||||
int bit_flag = 0;
|
||||
int data_length = 0;
|
||||
int data_offset = 0;
|
||||
|
||||
unsigned char* tmp_sect1, * tmp_sect2, * tmp_sect3;
|
||||
unsigned char* buf_start, * buf_end;
|
||||
unsigned char prev = 0;
|
||||
|
||||
unsigned char* start = out;
|
||||
unsigned char* end = (out + size);
|
||||
unsigned char head = in[0];
|
||||
|
||||
unsigned int range = 0xFFFFFFFF;
|
||||
unsigned int code = (in[1] << 24) | (in[2] << 16) | (in[3] << 8) | in[4];
|
||||
|
||||
if (head > 0x80) { // Check if we have a valid starting byte.
|
||||
// The dictionary header is invalid, the data is not compressed.
|
||||
result = -1;
|
||||
if (code <= size) {
|
||||
memcpy(out, in + 5, code);
|
||||
result = (int)(start - out);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Set up a temporary buffer (sliding window).
|
||||
memset(tmp, 0x80, 0xCA8);
|
||||
while (1) {
|
||||
// Start reading at 0xB68.
|
||||
tmp_sect1 = tmp + offset + 0xB68;
|
||||
if (!decode_bit(&range, &code, 0, &in, tmp_sect1)) { // Raw char.
|
||||
// Adjust offset and check for stream end.
|
||||
if (offset > 0) offset--;
|
||||
if (start == end) return (int)(start - out);
|
||||
|
||||
// Locate first section.
|
||||
int sect = (((((((int)(start - out)) & 7) << 8) + prev) >> head) & 7) * 0xFF - 1;
|
||||
tmp_sect1 = tmp + sect;
|
||||
int index = 1;
|
||||
|
||||
// Read, decode and write back.
|
||||
do {
|
||||
decode_bit(&range, &code, &index, &in, tmp_sect1 + index);
|
||||
} while ((index >> 8) == 0);
|
||||
|
||||
// Save index.
|
||||
*start++ = index;
|
||||
}
|
||||
else { // Compressed char stream.
|
||||
int index = -1;
|
||||
|
||||
// Identify the data length bit field.
|
||||
do {
|
||||
tmp_sect1 += 8;
|
||||
bit_flag = decode_bit(&range, &code, 0, &in, tmp_sect1);
|
||||
index += bit_flag;
|
||||
} while ((bit_flag != 0) && (index < 6));
|
||||
|
||||
// Default block size is 0x160.
|
||||
int b_size = 0x160;
|
||||
tmp_sect2 = tmp + index + 0x7F1;
|
||||
|
||||
// If the data length was found, parse it as a number.
|
||||
if ((index >= 0) || (bit_flag != 0)) {
|
||||
// Locate next section.
|
||||
int sect = (index << 5) | (((((int)(start - out)) << index) & 3) << 3) | (offset & 7);
|
||||
tmp_sect1 = tmp + 0xBA8 + sect;
|
||||
|
||||
// Decode the data length (8 bit fields).
|
||||
data_length = decode_number(tmp_sect1, index, &bit_flag, &range, &code, &in);
|
||||
if (data_length == 0xFF) return (int)(start - out); // End of stream.
|
||||
}
|
||||
else
|
||||
// Assume one byte of advance.
|
||||
data_length = 1;
|
||||
|
||||
// If we got valid parameters, seek to find data offset.
|
||||
if ((data_length <= 2)) {
|
||||
tmp_sect2 += 0xF8;
|
||||
b_size = 0x40; // Block size is now 0x40.
|
||||
}
|
||||
|
||||
int diff = 0;
|
||||
int shift = 1;
|
||||
|
||||
// Identify the data offset bit field.
|
||||
do {
|
||||
diff = (shift << 4) - b_size;
|
||||
bit_flag = decode_bit(&range, &code, &shift, &in, tmp_sect2 + ((size_t)shift << 3));
|
||||
} while (diff < 0);
|
||||
|
||||
// If the data offset was found, parse it as a number.
|
||||
if ((diff > 0) || (bit_flag != 0)) {
|
||||
// Adjust diff if needed.
|
||||
if (bit_flag == 0)
|
||||
diff -= 8;
|
||||
|
||||
// Locate section.
|
||||
tmp_sect3 = tmp + 0x928 + diff;
|
||||
|
||||
// Decode the data offset (1 bit fields).
|
||||
data_offset = decode_word(tmp_sect3, diff, &bit_flag, &range, &code, &in);
|
||||
}
|
||||
else
|
||||
// Assume one byte of advance.
|
||||
data_offset = 1;
|
||||
|
||||
// Set buffer start/end.
|
||||
buf_start = start - data_offset;
|
||||
buf_end = start + data_length + 1;
|
||||
|
||||
// Underflow.
|
||||
if (buf_start < out)
|
||||
return -1;
|
||||
|
||||
// Overflow.
|
||||
if (buf_end > end)
|
||||
return -1;
|
||||
|
||||
// Update offset.
|
||||
offset = ((((int)(buf_end - out)) + 1) & 1) + 6;
|
||||
|
||||
// Copy data.
|
||||
do {
|
||||
*start++ = *buf_start++;
|
||||
} while (start < buf_end);
|
||||
|
||||
}
|
||||
prev = *(start - 1);
|
||||
}
|
||||
result = (int)(start - out);
|
||||
return result;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Copyright (C) 2014 Hykem <hykem@hotmail.com>
|
||||
// Licensed under the terms of the GNU GPL, version 3
|
||||
// http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
|
||||
// Reverse-engineered custom Lempel–Ziv–Markov based compression.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern void decode_range(unsigned int *range, unsigned int *code, unsigned char **src);
|
||||
extern int decode_bit(unsigned int *range, unsigned int *code, int *index, unsigned char **src, unsigned char *c);
|
||||
extern int decode_number(unsigned char *ptr, int index, int *bit_flag, unsigned int *range, unsigned int *code, unsigned char **src);
|
||||
extern int decode_word(unsigned char *ptr, int index, int *bit_flag, unsigned int *range, unsigned int *code, unsigned char **src);
|
||||
extern int decompress(unsigned char *out, unsigned char *in, unsigned int size);
|
||||
@@ -7,10 +7,8 @@
|
||||
#include "../KKdLib/dsc.hpp"
|
||||
#include "../KKdLib/f2/struct.hpp"
|
||||
#include "../CRE/auth_3d.hpp"
|
||||
#include "elf.h"
|
||||
#include "main.h"
|
||||
#include "shared.h"
|
||||
#include "unedat.h"
|
||||
#include "main.hpp"
|
||||
#include "shared.hpp"
|
||||
#include <intrin.h>
|
||||
#include <processthreadsapi.h>
|
||||
#include <timeapi.h>
|
||||
@@ -31,18 +29,6 @@ inline static void next_rand_uint8_t_pointer(uint8_t* arr, size_t length, uint32
|
||||
}
|
||||
}
|
||||
|
||||
static void decrypt_edat() {
|
||||
uint8_t klic[16] = { 0xe2, 0x2d, 0x52, 0x46, 0x10, 0xa4, 0x4b, 0xb1,
|
||||
0xb5, 0x00, 0xf0, 0x66, 0xe7, 0xa0, 0xed, 0x49 };
|
||||
|
||||
stream f0;
|
||||
stream f1;
|
||||
f0.open("misc\\shader_ps3.edat", "rb");
|
||||
f1.open("misc\\shader_ps3.dat", "wb");
|
||||
if (f0.io.stream && f1.io.stream)
|
||||
DecryptEDAT(f0, f1, 8, "misc\\EP0177-NPEB02013_00-PJDF2MOMJTNSDAYO.rap", klic);
|
||||
}
|
||||
|
||||
struct dof_data {
|
||||
int32_t flags;
|
||||
float_t focus;
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "input.hpp"
|
||||
#include "render.h"
|
||||
#include "sound.h"
|
||||
#include "render.hpp"
|
||||
#include "sound.hpp"
|
||||
+215
-103
@@ -17,7 +17,7 @@
|
||||
#include "../KKdLib/farc.hpp"
|
||||
#include "../KKdLib/sort.hpp"
|
||||
#include "input.hpp"
|
||||
#include "classes/imgui_helper.h"
|
||||
#include "classes/imgui_helper.hpp"
|
||||
|
||||
enum dsc_ft_func {
|
||||
DSC_FT_END,
|
||||
@@ -129,7 +129,7 @@ enum dsc_ft_func {
|
||||
DSC_FT_MAX,
|
||||
};
|
||||
|
||||
pv_game pv_game_data;
|
||||
pv_game_old pv_game_old_data;
|
||||
|
||||
extern render_context* rctx_ptr;
|
||||
|
||||
@@ -138,16 +138,176 @@ static int32_t expression_id_to_mottbl_index(int32_t expression_id);
|
||||
static int32_t hand_anim_id_to_mottbl_index(int32_t hand_anim_id);
|
||||
static int32_t look_anim_id_to_mottbl_index(int32_t look_anim_id);
|
||||
static int32_t mouth_anim_id_to_mottbl_index(int32_t mouth_anim_id);
|
||||
static void pv_game_change_field(pv_game* pvgm, int32_t field, int64_t dsc_time, int64_t curr_time);
|
||||
static bool pv_game_dsc_process(pv_game* pvgm, int64_t curr_time);
|
||||
static void pv_game_reset_field(pv_game* pvgm);
|
||||
static void pv_game_change_field(pv_game_old* pvgm, int32_t field, int64_t dsc_time, int64_t curr_time);
|
||||
static bool pv_game_dsc_process(pv_game_old* pvgm, int64_t curr_time);
|
||||
static void pv_game_reset_field(pv_game_old* pvgm);
|
||||
|
||||
static dsc_data* sub_1401216D0(pv_game* a1, dsc_ft_func func_name,
|
||||
static dsc_data* sub_1401216D0(pv_game_old* a1, dsc_ft_func func_name,
|
||||
int32_t* time, int32_t* pv_branch_mode, dsc_data* start, dsc_data* end);
|
||||
static void sub_140121A80(pv_game* a1, int32_t chara_id);
|
||||
static void sub_140122770(pv_game* a1, int32_t chara_id);
|
||||
static void sub_140121A80(pv_game_old* a1, int32_t chara_id);
|
||||
static void sub_140122770(pv_game_old* a1, int32_t chara_id);
|
||||
|
||||
pv_game::pv_game() : state(), frame(), frame_float(), time(), rob_chara_ids(),
|
||||
pv_play_data_motion_data::pv_play_data_motion_data() : rob_chr(), current_time(),
|
||||
duration(), start_pos(), end_pos(), start_rot(), end_rot() {
|
||||
mot_smooth_len = 12.0f;
|
||||
}
|
||||
|
||||
pv_play_data_motion_data::~pv_play_data_motion_data() {
|
||||
|
||||
}
|
||||
|
||||
void pv_play_data_motion_data::reset() {
|
||||
rob_chr = 0;
|
||||
current_time = 0.0f;
|
||||
duration = 0.0f;
|
||||
start_pos = vec3_null;
|
||||
end_pos = vec3_null;
|
||||
start_rot = 0.0f;
|
||||
end_rot = 0.0f;
|
||||
mot_smooth_len = 12.0f;
|
||||
set_motion.clear();
|
||||
set_motion.shrink_to_fit();
|
||||
set_item.clear();
|
||||
set_item.shrink_to_fit();
|
||||
}
|
||||
|
||||
pv_play_data::pv_play_data() : rob_chr(), disp() {
|
||||
|
||||
}
|
||||
|
||||
pv_play_data::~pv_play_data() {
|
||||
|
||||
}
|
||||
|
||||
void pv_play_data::reset() {
|
||||
motion.clear();
|
||||
motion.shrink_to_fit();
|
||||
rob_chr = 0;
|
||||
set_motion.clear();
|
||||
disp = true;
|
||||
motion_data.reset();
|
||||
}
|
||||
|
||||
pv_disp2d::pv_disp2d() : pv_id(), title_start_2d_field(), title_end_2d_field(),
|
||||
title_start_2d_low_field(), title_end_2d_low_field(), title_start_3d_field(), title_end_3d_field(),
|
||||
target_shadow_type(), pv_spr_set_id(), pv_aet_set_id(), pv_main_aet_id() {
|
||||
|
||||
}
|
||||
|
||||
pv_disp2d::~pv_disp2d() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_dsc_data::pv_game_dsc_data() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_dsc_data::~pv_game_dsc_data() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_chara::pv_game_data_chara() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_chara::~pv_game_data_chara() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_field::pv_game_data_field() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_field::~pv_game_data_field() {
|
||||
|
||||
}
|
||||
|
||||
struc_78::struc_78() {
|
||||
|
||||
}
|
||||
|
||||
struc_78::~struc_78() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_chreff::pv_game_data_chreff() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data_chreff::~pv_game_data_chreff() {
|
||||
|
||||
}
|
||||
|
||||
pv_effect_resource::pv_effect_resource() {
|
||||
|
||||
}
|
||||
|
||||
pv_effect_resource::~pv_effect_resource() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data::pv_game_data() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_data::~pv_game_data() {
|
||||
|
||||
}
|
||||
|
||||
pv_game::pv_game() {
|
||||
|
||||
}
|
||||
|
||||
pv_game::~pv_game() {
|
||||
|
||||
}
|
||||
|
||||
TaskPvGame::Data::Data() {
|
||||
|
||||
}
|
||||
|
||||
TaskPvGame::Data::~Data() {
|
||||
|
||||
}
|
||||
|
||||
TaskPvGame::TaskPvGame() {
|
||||
|
||||
}
|
||||
|
||||
TaskPvGame::~TaskPvGame() {
|
||||
|
||||
}
|
||||
|
||||
bool TaskPvGame::Init() {
|
||||
TaskPvGame::Load(&data);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskPvGame::Ctrl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TaskPvGame::Dest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TaskPvGame::Disp() {
|
||||
|
||||
}
|
||||
|
||||
void TaskPvGame::Window() {
|
||||
|
||||
}
|
||||
|
||||
void TaskPvGame::Load(TaskPvGame::Data* data) {
|
||||
|
||||
}
|
||||
|
||||
void TaskPvGame::Unload() {
|
||||
|
||||
}
|
||||
|
||||
pv_game_old::pv_game_old() : state(), frame(), frame_float(), time(), rob_chara_ids(),
|
||||
dsc_time(), dsc_data_ptr(), dsc_data_ptr_end(), play(), success(), chara_id(),
|
||||
pv_end(), playdata(), scene_rot_y(), branch_mode(), pause(), step_frame() {
|
||||
pv_id = -1;
|
||||
@@ -158,16 +318,16 @@ pv_end(), playdata(), scene_rot_y(), branch_mode(), pause(), step_frame() {
|
||||
scene_rot_mat = mat4u_identity;
|
||||
}
|
||||
|
||||
pv_game::~pv_game() {
|
||||
pv_game_old::~pv_game_old() {
|
||||
|
||||
}
|
||||
|
||||
bool pv_game::Init() {
|
||||
bool pv_game_old::Init() {
|
||||
task_stage_load("PV_GAME_STAGE");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pv_game::Ctrl() {
|
||||
bool pv_game_old::Ctrl() {
|
||||
switch (state) {
|
||||
case 0:
|
||||
return false;
|
||||
@@ -415,13 +575,13 @@ bool pv_game::Ctrl() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void pv_game::Disp() {
|
||||
void pv_game_old::Disp() {
|
||||
if (state != 10)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
bool pv_game::Dest() {
|
||||
bool pv_game_old::Dest() {
|
||||
Unload();
|
||||
task_stage_unload();
|
||||
|
||||
@@ -439,7 +599,7 @@ bool pv_game::Dest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void pv_game::Window() {
|
||||
void pv_game_old::Window() {
|
||||
if (state != 10)
|
||||
return;
|
||||
|
||||
@@ -476,35 +636,35 @@ void pv_game::Window() {
|
||||
return;
|
||||
}
|
||||
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::BeginTable("buttons", 2)) {
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, w * 0.5f);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton(pause || (!pause && step_frame) ? "Play (K)" : "Pause (K)", { w, 0.0f }))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed(pause || (!pause && step_frame) ? "Play (K)" : "Pause (K)", { w, 0.0f }))
|
||||
pause ^= true;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Step Frame (L)", { w, 0.0f })) {
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Step Frame (L)", { w, 0.0f })) {
|
||||
pause = true;
|
||||
step_frame = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Stop (Ctrl+K)", { w, 0.0f }))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Stop (Ctrl+K)", { w, 0.0f }))
|
||||
state = 11;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
char buf[0x100];
|
||||
sprintf_s(buf, sizeof(buf), "%d", frame);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
imguiButtonEx(buf, { w, 0.0f }, ImGuiButtonFlags_DontClosePopups
|
||||
ImGui::ButtonExEnterKeyPressed(buf, { w, 0.0f }, ImGuiButtonFlags_DontClosePopups
|
||||
| ImGuiButtonFlags_NoNavFocus | ImGuiButtonFlags_NoHoveredOnFocus);
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::EndTable();
|
||||
@@ -515,7 +675,7 @@ void pv_game::Window() {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void pv_game::Load(int32_t pv_id, chara_index charas[6], int32_t modules[6]) {
|
||||
void pv_game_old::Load(int32_t pv_id, chara_index charas[6], int32_t modules[6]) {
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
motion_database* aft_mot_db = &aft_data->data_ft.mot_db;
|
||||
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
|
||||
@@ -580,7 +740,7 @@ void pv_game::Load(int32_t pv_id, chara_index charas[6], int32_t modules[6]) {
|
||||
Glitter::glt_particle_manager.draw_all = false;
|
||||
}
|
||||
|
||||
void pv_game::Unload() {
|
||||
void pv_game_old::Unload() {
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
motion_database* aft_mot_db = &aft_data->data_ft.mot_db;
|
||||
|
||||
@@ -662,54 +822,6 @@ void pv_game::Unload() {
|
||||
pv_param_task::post_process_task.SetDest();
|
||||
}
|
||||
|
||||
struc_104::struc_104() : rob_chr(), current_time(),
|
||||
duration(), start_pos(), end_pos(), start_rot(), end_rot() {
|
||||
mot_smooth_len = 12.0f;
|
||||
}
|
||||
|
||||
struc_104::~struc_104() {
|
||||
|
||||
}
|
||||
|
||||
void struc_104::reset() {
|
||||
rob_chr = 0;
|
||||
current_time = 0.0f;
|
||||
duration = 0.0f;
|
||||
start_pos = vec3_null;
|
||||
end_pos = vec3_null;
|
||||
start_rot = 0.0f;
|
||||
end_rot = 0.0f;
|
||||
mot_smooth_len = 12.0f;
|
||||
set_motion.clear();
|
||||
set_item.clear();
|
||||
}
|
||||
|
||||
pv_play_data::pv_play_data() : rob_chr(), disp() {
|
||||
|
||||
}
|
||||
|
||||
pv_play_data::~pv_play_data() {
|
||||
|
||||
}
|
||||
|
||||
void pv_play_data::reset() {
|
||||
motion.clear();
|
||||
rob_chr = 0;
|
||||
set_motion.clear();
|
||||
disp = true;
|
||||
field_38.reset();
|
||||
}
|
||||
|
||||
pv_disp2d::pv_disp2d() : pv_id(), title_start_2d_field(), title_end_2d_field(),
|
||||
title_start_2d_low_field(), title_end_2d_low_field(), title_start_3d_field(), title_end_3d_field(),
|
||||
target_shadow_type(), pv_spr_set_id(), pv_aet_set_id(), pv_main_aet_id() {
|
||||
|
||||
}
|
||||
|
||||
pv_disp2d::~pv_disp2d() {
|
||||
|
||||
}
|
||||
|
||||
static float_t dsc_time_to_frame(int64_t time) {
|
||||
return (float_t)time / 1000000000.0f * 60.0f;
|
||||
}
|
||||
@@ -775,13 +887,13 @@ static int32_t mouth_anim_id_to_mottbl_index(int32_t mouth_anim_id) {
|
||||
return 131;
|
||||
}
|
||||
|
||||
static void sub_140122B60(pv_game* a1, int32_t chara_id, int32_t motion_index, int64_t disp_time) {
|
||||
static void sub_140122B60(pv_game_old* a1, int32_t chara_id, int32_t motion_index, int64_t disp_time) {
|
||||
if (chara_id < 0 || chara_id > ROB_CHARA_COUNT || motion_index < 0)
|
||||
return;
|
||||
|
||||
pv_play_data* playdata = &a1->playdata[chara_id];
|
||||
int64_t dsc_time = a1->dsc_time;
|
||||
for (dsc_set_motion& i : playdata->field_38.set_motion) {
|
||||
for (dsc_set_motion& i : playdata->motion_data.set_motion) {
|
||||
int64_t time = (int64_t)i.time * 10000;
|
||||
if (time > dsc_time && i.motion_index == motion_index
|
||||
&& (!a1->branch_mode || a1->branch_mode == i.pv_branch_mode)) {
|
||||
@@ -793,11 +905,11 @@ static void sub_140122B60(pv_game* a1, int32_t chara_id, int32_t motion_index, i
|
||||
}
|
||||
}
|
||||
|
||||
static void pv_game_change_field(pv_game* pvgm, int32_t field, int64_t dsc_time, int64_t curr_time) {
|
||||
static void pv_game_change_field(pv_game_old* pvgm, int32_t field, int64_t dsc_time, int64_t curr_time) {
|
||||
light_param_storage_data_set_pv_cut(field);
|
||||
}
|
||||
|
||||
static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
static bool pv_game_dsc_process(pv_game_old* a1, int64_t curr_time) {
|
||||
dsc_ft_func func = (dsc_ft_func)a1->dsc_data_ptr->func;
|
||||
uint32_t* data = a1->dsc_m.get_func_data(a1->dsc_data_ptr);
|
||||
if (a1->branch_mode) {
|
||||
@@ -885,7 +997,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
sub_1405430F0(chara_id, 2);
|
||||
}*/
|
||||
|
||||
//pv_game::set_data_itmpv_visibility(a1->pv_game, a1->chara_id, true);
|
||||
//pv_game_old::set_data_itmpv_visibility(a1->pv_game_old, a1->chara_id, true);
|
||||
for (pv_play_data_set_motion& i : playdata->set_motion) {
|
||||
bool v45 = rob_chr->set_motion_id(i.motion_id, i.frame,
|
||||
i.duration, i.field_10, 0, i.blend_type, aft_bone_data, aft_mot_db);
|
||||
@@ -894,14 +1006,14 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
rob_chr->data.motion.step_data.step = i.frame_speed;
|
||||
//if (v45)
|
||||
// pv_expression_array_set_motion(a1->chara_id, i.motion_id);
|
||||
//if (!a1->pv_game->data.pv->disable_calc_motfrm_limit)
|
||||
//if (!a1->pv_game_old->data.pv->disable_calc_motfrm_limit)
|
||||
sub_140122B60(a1, a1->chara_id, i.motion_index, i.dsc_time);
|
||||
}
|
||||
playdata->set_motion.clear();
|
||||
}
|
||||
else {
|
||||
rob_chr->set_visibility(false);
|
||||
//pv_game::set_data_itmpv_visibility(a1->pv_game, a1->chara_id, false);
|
||||
//pv_game_old::set_data_itmpv_visibility(a1->pv_game_old, a1->chara_id, false);
|
||||
}
|
||||
} break;
|
||||
case DSC_FT_MIKU_SHADOW: {
|
||||
@@ -1027,7 +1139,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
rob_chr->data.motion.step_data.step = v519.frame_speed;
|
||||
//if (v84)
|
||||
// pv_expression_array_set_motion(a1->chara_id, motion_id);
|
||||
//if (!a1->pv_game->data.pv->disable_calc_motfrm_limit)
|
||||
//if (!a1->pv_game_old->data.pv->disable_calc_motfrm_limit)
|
||||
sub_140122B60(a1, a1->chara_id, motion_index, v56 ? v56->time : 0);
|
||||
}
|
||||
else {
|
||||
@@ -1120,7 +1232,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
duration /= a1->anim_frame_speed;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_eyelid_mottbl_motion_from_face(v115, duration, -1.0f, offset, aft_mot_db);
|
||||
@@ -1193,11 +1305,11 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
int32_t mottbl_index = mouth_anim_id_to_mottbl_index(mouth_anim_id);
|
||||
duration /= a1->anim_frame_speed;
|
||||
|
||||
//if (a1->pv_game->data.field_2D090 && mottbl_index != 144)
|
||||
//if (a1->pv_game_old->data.field_2D090 && mottbl_index != 144)
|
||||
// value = 0.0f;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_mouth_mottbl_motion(0, mottbl_index, value,
|
||||
@@ -1241,7 +1353,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
duration /= a1->anim_frame_speed;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
switch (hand_index) {
|
||||
@@ -1292,7 +1404,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
duration /= a1->anim_frame_speed;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_eyes_mottbl_motion(0, mottbl_index, value,
|
||||
@@ -1336,11 +1448,11 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
duration /= a1->anim_frame_speed;
|
||||
|
||||
bool v168 = true;
|
||||
//if (a1->has_perf_id && (a1->pv_game->data.pv->edit - 1) <= 1)
|
||||
//if (a1->has_perf_id && (a1->pv_game_old->data.pv->edit - 1) <= 1)
|
||||
// v168 = false;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_face_mottbl_motion(0, mottbl_index, value, mottbl_index >= 214
|
||||
@@ -1393,10 +1505,10 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
|
||||
bool v237 = true;
|
||||
//if (a1->has_perf_id)
|
||||
// v237 = (a1->pv_game->data.pv->edit - 1) > 1;
|
||||
// v237 = (a1->pv_game_old->data.pv->edit - 1) > 1;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_face_mottbl_motion(0, mottbl_index, 1.0f, mottbl_index >= 214
|
||||
@@ -1406,7 +1518,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
int32_t mottbl_index = mouth_anim_id_to_mottbl_index(v234);
|
||||
|
||||
float_t value = 1.0f;
|
||||
//if (a1->pv_game->data.field_2D090 && mottbl_index != 144)
|
||||
//if (a1->pv_game_old->data.field_2D090 && mottbl_index != 144)
|
||||
// value = 0.0f;
|
||||
|
||||
rob_chr->set_mouth_mottbl_motion(0, mottbl_index, value, 0,
|
||||
@@ -1448,11 +1560,11 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
duration *= a1->target_anim_fps;
|
||||
|
||||
float_t value = 1.0f;
|
||||
//if (a1->pv_game->data.field_2D090 && mottbl_index != 144)
|
||||
//if (a1->pv_game_old->data.field_2D090 && mottbl_index != 144)
|
||||
// value = 0.0f;
|
||||
|
||||
float_t offset = 0.0f;
|
||||
//if (a1->pv_game->data.pv->is_old_pv)
|
||||
//if (a1->pv_game_old->data.pv->is_old_pv)
|
||||
// offset = 1.0f;
|
||||
|
||||
rob_chr->set_mouth_mottbl_motion(0, mottbl_index, value,
|
||||
@@ -1577,7 +1689,7 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
//if (a1->chara_id < a1->pp->chara.size())
|
||||
// chara_index = (::chara_index)a1->pp->chara[a1->chara_id].chara_effect.base_chara;
|
||||
|
||||
//chara_index chara_index = pv_db_pv::get_performer_chara(a1->pv_game->data.pv, a1->chara_id);
|
||||
//chara_index chara_index = pv_db_pv::get_performer_chara(a1->pv_game_old->data.pv, a1->chara_id);
|
||||
chara_size_index = chara_init_data_get_chara_size_index(chara_index);
|
||||
}
|
||||
else if (chara_size == 2)
|
||||
@@ -1833,13 +1945,13 @@ static bool pv_game_dsc_process(pv_game* a1, int64_t curr_time) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static void pv_game_reset_field(pv_game* pvgm) {
|
||||
static void pv_game_reset_field(pv_game_old* pvgm) {
|
||||
task_stage_info v14;
|
||||
task_stage_set_stage(&v14);
|
||||
Glitter::glt_particle_manager.FreeScenes();
|
||||
}
|
||||
|
||||
static dsc_data* sub_1401216D0(pv_game* a1, dsc_ft_func func_name,
|
||||
static dsc_data* sub_1401216D0(pv_game_old* a1, dsc_ft_func func_name,
|
||||
int32_t* time, int32_t* pv_branch_mode, dsc_data* start, dsc_data* end) {
|
||||
int32_t _time = -1;
|
||||
for (dsc_data* i = start; i != end; i++)
|
||||
@@ -1865,14 +1977,14 @@ static dsc_data* sub_1401216D0(pv_game* a1, dsc_ft_func func_name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void sub_140121A80(pv_game* a1, int32_t chara_id) {
|
||||
static void sub_140121A80(pv_game_old* a1, int32_t chara_id) {
|
||||
if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT)
|
||||
return;
|
||||
|
||||
int32_t pv_branch_mode = 0;
|
||||
int32_t time = -1;
|
||||
int32_t prev_time = -1;
|
||||
a1->playdata[chara_id].field_38.set_item.clear();
|
||||
a1->playdata[chara_id].motion_data.set_item.clear();
|
||||
|
||||
dsc_data* i = a1->dsc_m.data.data();
|
||||
dsc_data* i_end = a1->dsc_m.data.data() + a1->dsc_m.data.size();
|
||||
@@ -1893,21 +2005,21 @@ static void sub_140121A80(pv_game* a1, int32_t chara_id) {
|
||||
v14.item_index = data[1];
|
||||
v14.time = time;
|
||||
v14.pv_branch_mode = pv_branch_mode;
|
||||
a1->playdata[chara_id].field_38.set_item.push_back(v14);
|
||||
a1->playdata[chara_id].motion_data.set_item.push_back(v14);
|
||||
}
|
||||
prev_time = time;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
static void sub_140122770(pv_game* a1, int32_t chara_id) {
|
||||
static void sub_140122770(pv_game_old* a1, int32_t chara_id) {
|
||||
if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT)
|
||||
return;
|
||||
|
||||
int32_t pv_branch_mode = 0;
|
||||
int32_t time = -1;
|
||||
int32_t prev_time = -1;
|
||||
a1->playdata[chara_id].field_38.set_motion.clear();
|
||||
a1->playdata[chara_id].motion_data.set_motion.clear();
|
||||
|
||||
dsc_data* i = a1->dsc_m.data.data();
|
||||
dsc_data* i_end = a1->dsc_m.data.data() + a1->dsc_m.data.size();
|
||||
@@ -1928,7 +2040,7 @@ static void sub_140122770(pv_game* a1, int32_t chara_id) {
|
||||
v14.motion_index = data[1];
|
||||
v14.time = time;
|
||||
v14.pv_branch_mode = pv_branch_mode;
|
||||
a1->playdata[chara_id].field_38.set_motion.push_back(v14);
|
||||
a1->playdata[chara_id].motion_data.set_motion.push_back(v14);
|
||||
}
|
||||
prev_time = time;
|
||||
i++;
|
||||
|
||||
+404
-132
@@ -3,7 +3,6 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#if defined(CLOUD_DEV)
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
@@ -13,12 +12,12 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "../KKdLib/dsc.hpp"
|
||||
#include "../CRE/rob/rob.hpp"
|
||||
#include "../CRE/auth_3d.hpp"
|
||||
#include "../CRE/pv_db.hpp"
|
||||
#include "../CRE/rob.hpp"
|
||||
#include "../CRE/stage.hpp"
|
||||
#include "../CRE/task.hpp"
|
||||
#include "classes.h"
|
||||
#include "classes.hpp"
|
||||
|
||||
struct pv_play_data_set_motion {
|
||||
float_t frame_speed;
|
||||
@@ -51,7 +50,7 @@ struct dsc_set_motion {
|
||||
int32_t pv_branch_mode;
|
||||
};
|
||||
|
||||
struct struc_104 {
|
||||
struct pv_play_data_motion_data {
|
||||
rob_chara* rob_chr;
|
||||
float_t current_time;
|
||||
float_t duration;
|
||||
@@ -63,8 +62,8 @@ struct struc_104 {
|
||||
std::vector<dsc_set_motion> set_motion;
|
||||
std::vector<dsc_set_item> set_item;
|
||||
|
||||
struc_104();
|
||||
~struc_104();
|
||||
pv_play_data_motion_data();
|
||||
~pv_play_data_motion_data();
|
||||
|
||||
void reset();
|
||||
};
|
||||
@@ -74,7 +73,9 @@ struct pv_play_data {
|
||||
rob_chara* rob_chr;
|
||||
std::list<pv_play_data_set_motion> set_motion;
|
||||
bool disp;
|
||||
struc_104 field_38;
|
||||
int8_t field_31;
|
||||
int32_t field_34;
|
||||
pv_play_data_motion_data motion_data;
|
||||
|
||||
pv_play_data();
|
||||
~pv_play_data();
|
||||
@@ -100,19 +101,242 @@ struct pv_disp2d {
|
||||
virtual ~pv_disp2d();
|
||||
};
|
||||
|
||||
struct pv_data_camera {
|
||||
bool enable;
|
||||
int32_t id;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct pv_data_set_motion {
|
||||
int32_t motion_id;
|
||||
float_t frame;
|
||||
int32_t stage_index;
|
||||
};
|
||||
|
||||
struct pv_game_dsc_data_change_field {
|
||||
int32_t time;
|
||||
int32_t field;
|
||||
};
|
||||
|
||||
struct struc_540 {
|
||||
int32_t field_0;
|
||||
vec2 field_4;
|
||||
vec2 field_C;
|
||||
int32_t field_14;
|
||||
int32_t field_18;
|
||||
int32_t field_1C;
|
||||
int32_t field_20;
|
||||
};
|
||||
|
||||
struct struc_498 {
|
||||
int32_t field_0;
|
||||
struc_540 field_4[4];
|
||||
int32_t field_94;
|
||||
int64_t field_98;
|
||||
int64_t field_A0;
|
||||
int32_t field_A8;
|
||||
int32_t field_AC;
|
||||
};
|
||||
|
||||
struct struc_563 {
|
||||
int64_t field_0;
|
||||
int64_t field_8;
|
||||
int64_t field_10;
|
||||
int64_t field_18;
|
||||
int64_t dsc_time;
|
||||
int64_t field_28;
|
||||
};
|
||||
|
||||
struct struc_676 {
|
||||
bool field_0[6];
|
||||
pv_play_data_set_motion field_8[6];
|
||||
int64_t field_128;
|
||||
int64_t field_130;
|
||||
int64_t field_138;
|
||||
int64_t field_140;
|
||||
bool field_148[6];
|
||||
struc_563 field_150[6];
|
||||
float_t field_270[6];
|
||||
bool field_288[6];
|
||||
int32_t field_290[6];
|
||||
float_t field_2A8[6];
|
||||
int8_t field_2C0;
|
||||
int32_t field_2C4;
|
||||
int32_t field_2C8;
|
||||
float_t field_2CC;
|
||||
int64_t field_2D0;
|
||||
};
|
||||
|
||||
struct pv_game;
|
||||
|
||||
struct pv_game_dsc_data {
|
||||
int8_t field_0;
|
||||
int32_t state;
|
||||
bool play;
|
||||
uint32_t dsc_buffer[45000];
|
||||
int32_t dsc_buffer_counter;
|
||||
int64_t field_2BF30;
|
||||
int64_t field_2BF38;
|
||||
int64_t curr_time;
|
||||
float_t curr_time_float;
|
||||
float_t prev_time_float;
|
||||
int8_t field_2BF50;
|
||||
int64_t field_2BF58;
|
||||
int8_t field_2BF60;
|
||||
int32_t field_2BF64;
|
||||
int64_t field_2BF68;
|
||||
int32_t chara_id;
|
||||
pv_game* pv_game;
|
||||
//struc_162* field_2BF80;
|
||||
//struc_646* field_2BF88;
|
||||
p_file_handler dsc_file_handler;
|
||||
float_t target_anim_fps;
|
||||
float_t anim_frame_speed;
|
||||
float_t target_flying_time;
|
||||
int32_t time_signature;
|
||||
ssize_t dsc_time;
|
||||
int32_t field_2BFB0;
|
||||
int32_t field_2BFB4;
|
||||
int32_t field_2BFB8;
|
||||
int32_t field_2BFBC;
|
||||
int8_t field_2BFC0;
|
||||
bool music_play;
|
||||
int32_t field_2BFC4;
|
||||
bool pv_end;
|
||||
float_t fov;
|
||||
float_t min_dist;
|
||||
int8_t field_2BFD4;
|
||||
int8_t field_2BFD5;
|
||||
pv_play_data playdata[6];
|
||||
pv_data_camera data_camera[3];
|
||||
std::vector<int32_t> data_camera_branch_fail;
|
||||
std::vector<int32_t> data_camera_branch_success;
|
||||
std::vector<pv_data_set_motion> set_motion[6];
|
||||
std::vector<pv_game_dsc_data_change_field> change_field_branch_fail;
|
||||
std::vector<pv_game_dsc_data_change_field> change_field_branch_success;
|
||||
int64_t change_field_branch_time;
|
||||
bool scene_fade_enable;
|
||||
float_t scene_fade_frame;
|
||||
float_t scene_fade_duration;
|
||||
float_t scene_fade_start_alpha;
|
||||
float_t scene_fade_end_alpha;
|
||||
vec3 scene_fade_color;
|
||||
bool has_signature;
|
||||
bool has_perf_id;
|
||||
int32_t field_2C4E4;
|
||||
std::vector<struc_498> field_2C4E8;
|
||||
int64_t field_2C500;
|
||||
float_t scene_rot_y;
|
||||
mat4 scene_rot_mat;
|
||||
float_t field_2C54C;
|
||||
int32_t field_2C550;
|
||||
int32_t branch_mode;
|
||||
int32_t first_challenge_note;
|
||||
int32_t last_challenge_note;
|
||||
struc_676 field_2C560;
|
||||
|
||||
pv_game_dsc_data();
|
||||
~pv_game_dsc_data();
|
||||
};
|
||||
|
||||
struct pv_game_data_chara {
|
||||
chara_index chara_index;
|
||||
int32_t module_index;
|
||||
int32_t chara_id;
|
||||
rob_chara_pv_data pv_data;
|
||||
rob_chara* rob_chr;
|
||||
std::vector<uint32_t> motion_ids;
|
||||
std::vector<uint32_t> motion_face_ids;
|
||||
|
||||
pv_game_data_chara();
|
||||
~pv_game_data_chara();
|
||||
};
|
||||
|
||||
struct struc_675 {
|
||||
int8_t field_0;
|
||||
float_t field_4;
|
||||
float_t field_8;
|
||||
float_t field_C;
|
||||
float_t field_10;
|
||||
int8_t field_14;
|
||||
};
|
||||
|
||||
struct pv_game_data_field {
|
||||
int32_t stage_index;
|
||||
std::vector<int32_t> auth_3d_uids;
|
||||
std::vector<int32_t> auth_3d_ids;
|
||||
std::map<int32_t, int32_t> auth_3d_frame_list;
|
||||
int32_t light_auth_3d_uid;
|
||||
int32_t light_auth_3d_id;
|
||||
int32_t light_frame;
|
||||
std::vector<std::string> aet_set_names[4];
|
||||
std::vector<std::string> aet_set_ids[4];
|
||||
std::map<std::pair<std::string, std::string>, int32_t> aet[4];
|
||||
int32_t spr_set_back_id;
|
||||
bool stage_flag;
|
||||
int32_t npr_type;
|
||||
int32_t cam_blur;
|
||||
bool sdw_off;
|
||||
std::vector<uint64_t> play_eff_list;
|
||||
std::vector<uint64_t> stop_eff_list;
|
||||
std::vector<uint64_t> field_1A0;
|
||||
|
||||
pv_game_data_field();
|
||||
~pv_game_data_field();
|
||||
};
|
||||
|
||||
struct pv_game_data_itmpv {
|
||||
int32_t auth_3d_id;
|
||||
int32_t field_4;
|
||||
int64_t time;
|
||||
};
|
||||
|
||||
struct struc_78 {
|
||||
std::vector<int32_t*> field_0;
|
||||
std::vector<int32_t> field_18;
|
||||
int32_t field_30;
|
||||
int32_t field_34;
|
||||
|
||||
struc_78();
|
||||
~struc_78();
|
||||
};
|
||||
|
||||
struct pv_game_data_chreff {
|
||||
chara_index src_chara_index;
|
||||
chara_index dst_chara_index;
|
||||
std::bitset<128>* type;
|
||||
std::string src_auth_3d;
|
||||
std::string dst_auth_3d;
|
||||
std::string src_auth_3d_category;
|
||||
std::string dst_auth_3d_category;
|
||||
int32_t src_auth_3d_uid;
|
||||
int32_t dst_auth_3d_uid;
|
||||
|
||||
pv_game_data_chreff();
|
||||
~pv_game_data_chreff();
|
||||
};
|
||||
|
||||
struct pv_effect_resource {
|
||||
std::string name;
|
||||
float_t emission;
|
||||
|
||||
pv_effect_resource();
|
||||
~pv_effect_resource();
|
||||
};
|
||||
|
||||
struct pv_game_data {
|
||||
//struc_490 field_0;
|
||||
//struc_155 field_2C838;
|
||||
int field_2CE98;
|
||||
char field_2CE9C[128];
|
||||
int field_2CF1C;
|
||||
char field_2CF20;
|
||||
int field_2CF24;
|
||||
pv_game_dsc_data dsc_data;
|
||||
//pv_game_ui_data ui_data;
|
||||
int32_t field_2CE98;
|
||||
int8_t field_2CE9C[128];
|
||||
int32_t field_2CF1C;
|
||||
int8_t field_2CF20;
|
||||
int32_t field_2CF24;
|
||||
float_t field_2CF28;
|
||||
float_t field_2CF2C;
|
||||
int field_2CF30;
|
||||
int field_2CF34;
|
||||
int field_2CF38;
|
||||
int32_t field_2CF30;
|
||||
int32_t field_2CF34;
|
||||
int32_t field_2CF38;
|
||||
int32_t life_gauge;
|
||||
int32_t score_final;
|
||||
int32_t challenge_time_total_bonus;
|
||||
@@ -123,40 +347,40 @@ struct pv_game_data {
|
||||
int32_t hit_count[5];
|
||||
int32_t current_reference_score;
|
||||
int32_t target_count;
|
||||
int field_2CF84;
|
||||
int field_2CF88;
|
||||
int32_t field_2CF84;
|
||||
int32_t field_2CF88;
|
||||
float_t field_2CF8C;
|
||||
int32_t score_slide_chain_bonus;
|
||||
int32_t slide_chain_length;
|
||||
int field_2CF98;
|
||||
int field_2CF9C;
|
||||
int32_t field_2CF98;
|
||||
int32_t field_2CF9C;
|
||||
__int16 field_2CFA0;
|
||||
int field_2CFA4;
|
||||
int32_t field_2CFA4;
|
||||
pv_db_pv* pv;
|
||||
int field_2CFB0;
|
||||
int field_2CFB4;
|
||||
int32_t field_2CFB0;
|
||||
int32_t field_2CFB4;
|
||||
int32_t reference_score;
|
||||
int field_2CFBC;
|
||||
int field_2CFC0;
|
||||
int field_2CFC4;
|
||||
int32_t field_2CFBC;
|
||||
int32_t field_2CFC0;
|
||||
int32_t field_2CFC4;
|
||||
std::vector<int32_t> field_2CFC8;
|
||||
int field_2CFE0;
|
||||
int field_2CFE4;
|
||||
int32_t field_2CFE0;
|
||||
int32_t field_2CFE4;
|
||||
size_t notes_passed;
|
||||
int field_2CFF0;
|
||||
int32_t field_2CFF0;
|
||||
float_t score_percentage;
|
||||
float_t score_percentage_clear;
|
||||
float_t score_percentage_border;
|
||||
int32_t life_gauge_safety_time;
|
||||
int32_t life_gauge_border;
|
||||
int field_2D008;
|
||||
char field_2D00C;
|
||||
int32_t field_2D008;
|
||||
int8_t field_2D00C;
|
||||
bool no_fail;
|
||||
char field_2D00E;
|
||||
int8_t field_2D00E;
|
||||
bool field_2D00F;
|
||||
int64_t challenge_time_start;
|
||||
int64_t challenge_time_end;
|
||||
uint64_t max_time;
|
||||
int64_t max_time;
|
||||
float_t max_time_float;
|
||||
float_t current_time_float;
|
||||
uint64_t current_time;
|
||||
@@ -170,51 +394,51 @@ struct pv_game_data {
|
||||
pv_disp2d* pv_disp2d;
|
||||
int32_t life_gauge_final;
|
||||
bool hit_border;
|
||||
char field_2D05D;
|
||||
char field_2D05E;
|
||||
char field_2D05F;
|
||||
char field_2D060;
|
||||
char field_2D061;
|
||||
char field_2D062;
|
||||
char field_2D063;
|
||||
bool field_2D064;
|
||||
char field_2D065;
|
||||
char field_2D066[2];
|
||||
char field_2D068;
|
||||
char field_2D069;
|
||||
char field_2D06A[2];
|
||||
int field_2D06C;
|
||||
uint32_t field_2D070;
|
||||
int field_2D074;
|
||||
int field_2D078;
|
||||
int field_2D07C;
|
||||
int field_2D080;
|
||||
int field_2D084;
|
||||
int8_t field_2D05D;
|
||||
int8_t field_2D05E;
|
||||
int8_t field_2D05F;
|
||||
bool title_image_init;
|
||||
int8_t field_2D061;
|
||||
int8_t field_2D062;
|
||||
int8_t field_2D063;
|
||||
bool has_auth_3d_frame;
|
||||
bool has_light_frame;
|
||||
int8_t field_2D066[2];
|
||||
int8_t field_2D068;
|
||||
int8_t field_2D069;
|
||||
int8_t field_2D06A[2];
|
||||
int32_t field_2D06C;
|
||||
uint32_t field_index;
|
||||
int32_t edit_effect_index;
|
||||
int32_t slidertouch_counter;
|
||||
int32_t change_field_branch_success_counter;
|
||||
int32_t field_2D080;
|
||||
int32_t field_2D084;
|
||||
int32_t life_gauge_bonus;
|
||||
int32_t life_gauge_total_bonus;
|
||||
char field_2D090;
|
||||
char field_2D091;
|
||||
char field_2D092;
|
||||
char field_2D093;
|
||||
int8_t field_2D090;
|
||||
int8_t field_2D091;
|
||||
int8_t field_2D092;
|
||||
int8_t field_2D093;
|
||||
uint8_t field_2D094;
|
||||
char field_2D095;
|
||||
char field_2D096;
|
||||
int8_t field_2D095;
|
||||
int8_t field_2D096;
|
||||
bool success;
|
||||
int field_2D098;
|
||||
int field_2D09C;
|
||||
char field_2D0A0;
|
||||
int32_t field_2D098;
|
||||
int32_t field_2D09C;
|
||||
int8_t field_2D0A0;
|
||||
bool pv_end_fadeout;
|
||||
float_t rival_percentage;
|
||||
int field_2D0A8;
|
||||
int field_2D0AC;
|
||||
int field_2D0B0[3];
|
||||
int32_t field_2D0A8;
|
||||
int32_t field_2D0AC;
|
||||
int32_t field_2D0B0[3];
|
||||
bool field_2D0BC;
|
||||
char field_2D0BD;
|
||||
char field_2D0BE;
|
||||
char field_2D0BF;
|
||||
int field_2D0C0;
|
||||
int field_2D0C4;
|
||||
//struc_154 chrcam_chrmot[6];
|
||||
int8_t field_2D0BD;
|
||||
int8_t field_2D0BE;
|
||||
int8_t field_2D0BF;
|
||||
int32_t field_2D0C0;
|
||||
int32_t field_2D0C4;
|
||||
pv_game_data_chara chara[6];
|
||||
std::vector<uint32_t> motion_set_ids;
|
||||
std::vector<uint32_t> motion_set_face_ids;
|
||||
std::vector<int32_t> obj_set_itmpv;
|
||||
@@ -225,75 +449,126 @@ struct pv_game_data {
|
||||
std::vector<int32_t> ex_song_ex_auth_obj_set_ids;
|
||||
std::vector<int32_t> stage_indices;
|
||||
std::vector<task_stage_info> stage_infos;
|
||||
char field_2D7E8;
|
||||
int field_2D7EC;
|
||||
std::vector<int32_t> field_2D7F0;
|
||||
int field_2D808;
|
||||
int field_2D80C;
|
||||
std::vector<int32_t> field_2D810;
|
||||
std::vector<int32_t> field_2D828;
|
||||
std::vector<int32_t> field_2D840;
|
||||
int field_2D858;
|
||||
float_t field_2D85C;
|
||||
float_t field_2D860;
|
||||
float_t field_2D864;
|
||||
float_t field_2D868;
|
||||
char field_2D86C;
|
||||
int camera_auth_3d_uid;
|
||||
int field_2D874;
|
||||
int8_t field_2D7E8;
|
||||
int32_t field_2D7EC;
|
||||
std::vector<int32_t> spr_set_back_ids;
|
||||
int32_t field_2D808;
|
||||
int32_t field_2D80C;
|
||||
std::vector<int32_t> edit_effect_aet_set_ids;
|
||||
std::vector<int32_t> edit_effect_spr_set_ids;
|
||||
std::vector<int32_t> edit_effect_aet_ids;
|
||||
struc_675 field_2D858;
|
||||
int32_t camera_auth_3d_uid;
|
||||
int32_t field_2D874;
|
||||
bool field_2D878;
|
||||
int field_2D87C;
|
||||
int32_t field_2D87C;
|
||||
size_t current_field;
|
||||
//std::vector<pv_game_data_field_data> field_data;
|
||||
char field_2D8A0;
|
||||
int field_2D8A4;
|
||||
__int64 field_2D8A8;
|
||||
int field_2D8B0;
|
||||
int field_2D8B4;
|
||||
__int64 field_2D8B8;
|
||||
__int64 field_2D8C0;
|
||||
int field_2D8C8;
|
||||
int field_2D8CC;
|
||||
int field_2D8D0;
|
||||
int field_2D8D4;
|
||||
int field_2D8D8;
|
||||
int field_2D8DC;
|
||||
int field_2D8E0;
|
||||
int field_2D8E4;
|
||||
int field_2D8E8;
|
||||
int field_2D8EC;
|
||||
int field_2D8F0;
|
||||
int field_2D8F4;
|
||||
int field_2D8F8;
|
||||
int field_2D8FC;
|
||||
int field_2D900;
|
||||
int field_2D904;
|
||||
std::vector<pv_game_data_field> field_data;
|
||||
int8_t field_2D8A0;
|
||||
int32_t field_2D8A4;
|
||||
std::map<int32_t, int64_t> auth_3d_time;
|
||||
std::map<int32_t, int64_t> light_time;
|
||||
std::map<std::pair<std::string, std::string>, int64_t> aet_time[4];
|
||||
std::string campv_string;
|
||||
std::vector<int32_t> campv_auth_3d_uids;
|
||||
std::map<int32_t, int32_t> campv;
|
||||
int data_camera_id;
|
||||
int field_2D954;
|
||||
int32_t data_camera_id;
|
||||
int32_t field_2D954;
|
||||
std::string itmpv_string;
|
||||
std::vector<int32_t> itmpv_auth_3d_uids;
|
||||
//std::map<int32_t, struc_644> itmpv[6];
|
||||
std::map<int32_t, pv_game_data_itmpv> itmpv[6];
|
||||
std::vector<std::string> field_2D9F0;
|
||||
//struc_78 field_2DA08[3];
|
||||
struc_78 field_2DA08[3];
|
||||
std::vector<int32_t> loaded_auth_3d_uids;
|
||||
char field_2DAC8;
|
||||
int field_2DACC;
|
||||
int8_t field_2DAC8;
|
||||
int32_t field_2DACC;
|
||||
std::vector<std::string> auth_3d_categories;
|
||||
std::map<int32_t, int32_t> auth_3d;
|
||||
//std::vector<pv_game_data_chreff> chreff_auth_3d;
|
||||
//std::vector<pv_game_data_chreff> chreff_auth_3d_obj;
|
||||
char field_2DB28;
|
||||
std::vector<pv_game_data_chreff> chreff_auth_3d;
|
||||
std::vector<pv_game_data_chreff> chreff_auth_3d_obj;
|
||||
int8_t field_2DB28;
|
||||
vec2 field_2DB2C;
|
||||
int field_2DB34;
|
||||
int32_t field_2DB34;
|
||||
time_struct field_2DB38;
|
||||
std::vector<uint64_t> field_2DB48;
|
||||
//std::vector<struc_12> field_2DB60;
|
||||
std::vector<uint64_t> effect_rs_list_hashes;
|
||||
std::vector<pv_effect_resource> effect_rs_list;
|
||||
|
||||
pv_game_data();
|
||||
~pv_game_data();
|
||||
};
|
||||
|
||||
class pv_game : public app::TaskWindow {
|
||||
struct struc_653 {
|
||||
bool field_0[4];
|
||||
};
|
||||
|
||||
struct pv_game {
|
||||
bool loaded;
|
||||
bool field_1;
|
||||
bool field_2;
|
||||
bool end_pv;
|
||||
int32_t field_4;
|
||||
int32_t state;
|
||||
int32_t field_C;
|
||||
int32_t pv_id;
|
||||
int32_t field_14;
|
||||
int32_t modules[6];
|
||||
rob_chara_pv_data_item items[6];
|
||||
struc_653 field_90[6];
|
||||
pv_game_data data;
|
||||
|
||||
pv_game();
|
||||
~pv_game();
|
||||
};
|
||||
|
||||
class TaskPvGame : public app::TaskWindow {
|
||||
public:
|
||||
struct Data {
|
||||
int32_t field_0;
|
||||
int32_t field_4;
|
||||
int64_t field_8;
|
||||
int32_t score_percentage_clear;
|
||||
int32_t life_gauge_safety_time;
|
||||
int32_t life_gauge_border;
|
||||
int32_t field_1C;
|
||||
int32_t modules[6];
|
||||
rob_chara_pv_data_item items[6];
|
||||
int64_t field_98;
|
||||
int64_t field_A0;
|
||||
int64_t field_A8;
|
||||
std::string field_B0;
|
||||
std::string field_D0;
|
||||
std::string field_F0;
|
||||
std::string field_110;
|
||||
std::string field_130;
|
||||
std::string field_150;
|
||||
std::string field_170;
|
||||
int8_t field_190;
|
||||
int8_t field_191;
|
||||
bool no_fail;
|
||||
int8_t field_193;
|
||||
int8_t field_194;
|
||||
int8_t field_195;
|
||||
int8_t field_196;
|
||||
int32_t field_198;
|
||||
|
||||
Data();
|
||||
~Data();
|
||||
} data;
|
||||
|
||||
TaskPvGame();
|
||||
virtual ~TaskPvGame() override;
|
||||
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
virtual void Disp() override;
|
||||
virtual void Window() override;
|
||||
|
||||
static void Load(Data* data);
|
||||
static void Unload();
|
||||
};
|
||||
|
||||
class pv_game_old : public app::TaskWindow {
|
||||
public:
|
||||
int32_t pv_id;
|
||||
|
||||
@@ -334,8 +609,9 @@ public:
|
||||
bool pause;
|
||||
bool step_frame;
|
||||
|
||||
pv_game();
|
||||
virtual ~pv_game() override;
|
||||
pv_game_old();
|
||||
virtual ~pv_game_old() override;
|
||||
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
@@ -345,7 +621,3 @@ public:
|
||||
void Load(int32_t pv_id, chara_index charas[6], int32_t modules[6]);
|
||||
void Unload();
|
||||
};
|
||||
|
||||
extern pv_game pv_game_data;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
Some code is from LearnOpenGL
|
||||
*/
|
||||
|
||||
#include "render.h"
|
||||
#include "render.hpp"
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
@@ -15,30 +15,31 @@
|
||||
#include <imgui/imgui_impl_glfw.h>
|
||||
#include <imgui/imgui_impl_opengl3.h>
|
||||
#include "../CRE/Glitter/glitter.hpp"
|
||||
#include "../CRE/camera.h"
|
||||
#include "../CRE/rob/rob.hpp"
|
||||
#include "../CRE/camera.hpp"
|
||||
#include "../CRE/data.hpp"
|
||||
#include "../CRE/fbo.hpp"
|
||||
#include "../CRE/file_handler.hpp"
|
||||
#include "../CRE/gl_state.h"
|
||||
#include "../CRE/gl_state.hpp"
|
||||
#include "../CRE/light_param.hpp"
|
||||
#include "../CRE/lock.h"
|
||||
#include "../CRE/lock.hpp"
|
||||
#include "../CRE/object.hpp"
|
||||
#include "../CRE/pv_db.hpp"
|
||||
#include "../CRE/rob.hpp"
|
||||
#include "../CRE/shader.h"
|
||||
#include "../CRE/shader_ft.h"
|
||||
#include "../CRE/shader.hpp"
|
||||
#include "../CRE/shader_ft.hpp"
|
||||
#include "../CRE/shader_glsl.hpp"
|
||||
#include "../CRE/stage.hpp"
|
||||
#include "../CRE/static_var.h"
|
||||
#include "../CRE/stage_modern.hpp"
|
||||
#include "../CRE/static_var.hpp"
|
||||
#include "../CRE/task.hpp"
|
||||
#include "../CRE/texture.hpp"
|
||||
#include "../CRE/timer.h"
|
||||
#include "../CRE/timer.hpp"
|
||||
#include "../CRE/post_process.hpp"
|
||||
#include "../KKdLib/io/path.hpp"
|
||||
#include "../KKdLib/database/item_table.hpp"
|
||||
#include "../KKdLib/sort.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "classes/imgui_helper.h"
|
||||
#include "classes/imgui_helper.hpp"
|
||||
#include "input.hpp"
|
||||
#include "pv_game.hpp"
|
||||
#include "x_pv_game.hpp"
|
||||
@@ -51,11 +52,11 @@
|
||||
#define CUBE_LINE_SIZE (0.0025f)
|
||||
#define CUBE_LINE_POINT_SIZE (CUBE_LINE_SIZE * 1.5f)
|
||||
|
||||
shader_glsl cube_line_shader;
|
||||
shader_glsl cube_line_point_shader;
|
||||
shader_glsl grid_shader;
|
||||
shader_glsl* cube_line_shader;
|
||||
shader_glsl* cube_line_point_shader;
|
||||
shader_glsl* grid_shader;
|
||||
|
||||
timer render_timer;
|
||||
timer* render_timer;
|
||||
|
||||
#define grid_size 50.0f
|
||||
#define grid_spacing 1.0f
|
||||
@@ -144,18 +145,18 @@ lock imgui_context_lock;
|
||||
bool global_context_menu;
|
||||
extern size_t frame_counter;
|
||||
render_context* rctx_ptr;
|
||||
int32_t stage_index = -1;
|
||||
bool task_stage_is_modern;
|
||||
|
||||
int32_t render_main(void* arg) {
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||
timeBeginPeriod(1);
|
||||
timer_init(&render_timer, 60.0);
|
||||
render_timer = new timer(60.0);
|
||||
|
||||
state = RENDER_UNINITIALIZED;
|
||||
|
||||
lock_init(&render_lock);
|
||||
if (!lock_check_init(&render_lock)) {
|
||||
timer_dispose(&render_timer);
|
||||
delete render_timer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -279,9 +280,9 @@ int32_t render_main(void* arg) {
|
||||
gl_state_disable_stencil_test();
|
||||
#pragma endregion
|
||||
|
||||
timer_reset(&render_timer);
|
||||
render_timer->reset();
|
||||
while (!close && !reload_render) {
|
||||
timer_start_of_cycle(&render_timer);
|
||||
render_timer->start_of_cycle();
|
||||
glfwPollEvents();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
@@ -295,7 +296,7 @@ int32_t render_main(void* arg) {
|
||||
close |= !!glfwWindowShouldClose(window);
|
||||
frame_counter++;
|
||||
Input::EndFrame();
|
||||
timer_end_of_cycle(&render_timer);
|
||||
render_timer->end_of_cycle();
|
||||
}
|
||||
|
||||
lock_lock(&state_lock);
|
||||
@@ -303,13 +304,13 @@ int32_t render_main(void* arg) {
|
||||
lock_unlock(&state_lock);
|
||||
|
||||
bool threads_wait = false;
|
||||
timer_reset(&render_timer);
|
||||
render_timer->reset();
|
||||
do {
|
||||
timer_start_of_cycle(&render_timer);
|
||||
render_timer->start_of_cycle();
|
||||
lock_lock(&state_lock);
|
||||
threads_wait = thread_flags & ~THREAD_RENDER;
|
||||
lock_unlock(&state_lock);
|
||||
timer_end_of_cycle(&render_timer);
|
||||
render_timer->end_of_cycle();
|
||||
} while (threads_wait);
|
||||
|
||||
lock_lock(&render_lock);
|
||||
@@ -327,7 +328,7 @@ int32_t render_main(void* arg) {
|
||||
glfwTerminate();
|
||||
#pragma endregion
|
||||
lock_free(&render_lock);
|
||||
timer_dispose(&render_timer);
|
||||
delete render_timer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -412,7 +413,11 @@ static render_context* render_load() {
|
||||
app::task_work_init();
|
||||
rob_init();
|
||||
auth_3d_data_init();
|
||||
task_stage_init();
|
||||
dtm_stg_init();
|
||||
task_stage_modern_init();
|
||||
light_param_storage_data_init();
|
||||
task_pv_db_init();
|
||||
|
||||
Glitter::glt_particle_manager.bone_data = aft_bone_data;
|
||||
|
||||
@@ -559,17 +564,20 @@ static render_context* render_load() {
|
||||
" gl_FragDepth = texelFetch(g_depth, ivec2(gl_FragCoord.xy), 0).r;\n"
|
||||
"}\n";
|
||||
|
||||
cube_line_shader = new shader_glsl;
|
||||
shader_glsl_param param = {};
|
||||
param.name = "Cube Line";
|
||||
cube_line_shader.load(cube_line_vert_shader, cube_line_frag_shader, 0, ¶m);
|
||||
cube_line_shader->load(cube_line_vert_shader, cube_line_frag_shader, 0, ¶m);
|
||||
|
||||
cube_line_point_shader = new shader_glsl;
|
||||
param = {};
|
||||
param.name = "Cube Line Point";
|
||||
cube_line_point_shader.load(cube_line_point_vert_shader, cube_line_point_frag_shader, 0, ¶m);
|
||||
cube_line_point_shader->load(cube_line_point_vert_shader, cube_line_point_frag_shader, 0, ¶m);
|
||||
|
||||
grid_shader = new shader_glsl;
|
||||
param = {};
|
||||
param.name = "Grid";
|
||||
grid_shader.load(grid_vert_shader, grid_frag_shader, 0, ¶m);
|
||||
grid_shader->load(grid_vert_shader, grid_frag_shader, 0, ¶m);
|
||||
|
||||
render_resize_fb(rctx, false);
|
||||
|
||||
@@ -602,14 +610,18 @@ static render_context* render_load() {
|
||||
//object_storage_load_set(aft_obj_db, "MIKITM681");
|
||||
//object_storage_load_set(aft_obj_db, "MIKITM981");
|
||||
|
||||
timer_reset(&render_timer);
|
||||
for (int32_t i = 0; i < 30; i++) {
|
||||
timer_start_of_cycle(&render_timer);
|
||||
uint32_t dbg_set_id = aft_obj_db->get_object_set_id("DBG");
|
||||
object_storage_load_set(aft_data, aft_obj_db, dbg_set_id);
|
||||
|
||||
render_timer->reset();
|
||||
for (int32_t i = 0; i < 30 || object_storage_load_obj_set_check_not_read(dbg_set_id); i++) {
|
||||
render_timer->start_of_cycle();
|
||||
lock_lock(&render_lock);
|
||||
app::TaskWork::Ctrl();
|
||||
file_handler_storage_ctrl();
|
||||
app::TaskWork::Basic();
|
||||
lock_unlock(&render_lock);
|
||||
timer_end_of_cycle(&render_timer);
|
||||
render_timer->end_of_cycle();
|
||||
}
|
||||
|
||||
motion_set_load_motion(aft_mot_db->get_motion_set_id("CMN"), 0, aft_mot_db);
|
||||
@@ -706,20 +718,16 @@ static render_context* render_load() {
|
||||
|
||||
camera* cam = rctx->camera;
|
||||
|
||||
camera_initialize(cam, aspect, internal_3d_res.x, internal_3d_res.y);
|
||||
//camera_set_position(cam, &((vec3){ 1.35542f, 1.41634f, 1.27852f }));
|
||||
//camera_rotate(cam, &((vec2d){ -45.0, -32.5 }));
|
||||
//camera_set_position(cam, &((vec3){ -6.67555f, 4.68882f, -3.67537f }));
|
||||
//camera_rotate(cam, &((vec2d){ 136.5, -20.5 }));
|
||||
vec3 view_point = { 0.0f, 1.0f, 3.45f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
vec3 interest = { 0.0f, 1.0f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
//camera_set_fov(cam, 70.0);
|
||||
view_point = { 0.0f, 1.375f, 1.0f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
interest = { 0.0f, 1.375f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
cam->initialize(aspect, internal_3d_res.x, internal_3d_res.y);
|
||||
//cam->set_position(cam, { 1.35542f, 1.41634f, 1.27852f });
|
||||
//cam->rotate(cam, { -45.0, -32.5 });
|
||||
//cam->set_position(cam, { -6.67555f, 4.68882f, -3.67537f });
|
||||
//cam->rotate(cam, { 136.5, -20.5 });
|
||||
cam->set_view_point({ 0.0f, 1.0f, 3.45f });
|
||||
cam->set_interest({ 0.0f, 1.0f, 0.0f });
|
||||
//cam->set_fov(cam, 70.0);
|
||||
cam->set_view_point({ 0.0f, 1.375f, 1.0f });
|
||||
cam->set_interest({ 0.0f, 1.375f, 0.0f });
|
||||
|
||||
imgui_context = ImGui::CreateContext(0);
|
||||
lock_init(&imgui_context_lock);
|
||||
@@ -738,39 +746,38 @@ static render_context* render_load() {
|
||||
clear_color = { 0x60, 0x60, 0x60, 0xFF };
|
||||
set_clear_color = true;
|
||||
|
||||
/*chara_index charas[6];
|
||||
charas[0] = CHARA_MIKU;
|
||||
charas[1] = CHARA_MIKU;//CHARA_RIN;
|
||||
charas[2] = CHARA_MIKU;//CHARA_LEN;
|
||||
charas[3] = CHARA_MIKU;//CHARA_LUKA;
|
||||
charas[4] = CHARA_MIKU;//CHARA_KAITO;
|
||||
charas[5] = CHARA_MIKU;//CHARA_MEIKO;
|
||||
|
||||
int32_t modules[6];
|
||||
modules[0] = 0;//168;
|
||||
modules[1] = 0;//46;
|
||||
modules[2] = 0;//39;
|
||||
modules[3] = 0;//41;
|
||||
modules[4] = 0;//40;
|
||||
modules[5] = 0;//31;
|
||||
pv_game_data.Load(739, charas, modules);*/
|
||||
|
||||
chara_index charas[6];
|
||||
int32_t modules[6];
|
||||
|
||||
charas[0] = CHARA_MIKU;
|
||||
charas[1] = CHARA_MIKU;//CHARA_RIN;
|
||||
charas[2] = CHARA_MIKU;//CHARA_LEN;
|
||||
charas[3] = CHARA_MIKU;//CHARA_LUKA;
|
||||
charas[4] = CHARA_MIKU;//CHARA_KAITO;
|
||||
charas[5] = CHARA_MIKU;//CHARA_MEIKO;
|
||||
charas[4] = CHARA_MIKU;//CHARA_MEIKO;
|
||||
charas[5] = CHARA_MIKU;//CHARA_KAITO;
|
||||
|
||||
int32_t modules[6];
|
||||
modules[0] = 0;//168;
|
||||
modules[1] = 0;//46;
|
||||
modules[2] = 0;//39;
|
||||
modules[3] = 0;//41;
|
||||
modules[4] = 0;//40;
|
||||
modules[5] = 0;//31;
|
||||
x_pv_game_data.Load(826, 26, charas, modules);
|
||||
//pv_game_data.Load(739, charas, modules);
|
||||
|
||||
charas[0] = CHARA_LUKA;
|
||||
charas[1] = CHARA_LUKA;//CHARA_RIN;
|
||||
charas[2] = CHARA_LUKA;//CHARA_LEN;
|
||||
charas[3] = CHARA_LUKA;//CHARA_LUKA;
|
||||
charas[4] = CHARA_LUKA;//CHARA_KAITO;
|
||||
charas[5] = CHARA_LUKA;//CHARA_MEIKO;
|
||||
|
||||
modules[0] = 0;//168;
|
||||
modules[1] = 0;//46;
|
||||
modules[2] = 0;//39;
|
||||
modules[3] = 0;//41;
|
||||
modules[4] = 0;//40;
|
||||
modules[5] = 0;//31;
|
||||
x_pv_game_data.Load(824, 24, charas, modules);
|
||||
|
||||
shaders_ft.env_vert_set(3, vec4_identity);
|
||||
shaders_ft.env_vert_set(4, vec4_null);
|
||||
@@ -782,7 +789,6 @@ extern vec2d input_move;
|
||||
extern vec2d input_rotate;
|
||||
extern double_t input_roll;
|
||||
extern bool input_reset;
|
||||
extern bool input_shaders_reload;
|
||||
|
||||
int32_t global_ctrl_frames = 0;
|
||||
|
||||
@@ -807,7 +813,7 @@ static void render_ctrl(render_context* rctx) {
|
||||
|
||||
if (old_width != width || old_height != height || old_scale != scale) {
|
||||
render_resize_fb(rctx, true);
|
||||
camera_set_res(cam, internal_3d_res.x, internal_3d_res.y);
|
||||
cam->set_res(internal_3d_res.x, internal_3d_res.y);
|
||||
}
|
||||
old_width = width;
|
||||
old_height = height;
|
||||
@@ -825,30 +831,24 @@ static void render_ctrl(render_context* rctx) {
|
||||
}
|
||||
lock_unlock(&imgui_context_lock);
|
||||
|
||||
if (input_shaders_reload) {
|
||||
input_shaders_reload = false;
|
||||
render_shaders_free();
|
||||
render_shaders_load();
|
||||
}
|
||||
|
||||
if (window_handle == GetForegroundWindow()) {
|
||||
if (input_reset) {
|
||||
input_reset = false;
|
||||
camera_reset(cam);
|
||||
//camera_set_position(cam, &((vec3){ 1.35542f, 1.41634f, 1.27852f }));
|
||||
//camera_rotate(cam, &((vec2d){ -45.0, -32.5 }));
|
||||
//camera_set_position(cam, &((vec3){ -6.67555f, 4.68882f, -3.67537f }));
|
||||
//camera_rotate(cam, &((vec2d){ 136.5, -20.5 }));
|
||||
vec3 view_point = { 0.0f, 1.0f, 3.45f };
|
||||
camera_set_view_point(cam, &view_point);
|
||||
vec3 interest = { 0.0f, 1.0f, 0.0f };
|
||||
camera_set_interest(cam, &interest);
|
||||
//camera_set_fov(cam, 70.0);
|
||||
cam->reset();
|
||||
//cam->set_position({ 1.35542f, 1.41634f, 1.27852f });
|
||||
//cam->rotate({ -45.0, -32.5 });
|
||||
//cam->set_position({ -6.67555f, 4.68882f, -3.67537f });
|
||||
//cam->rotate({ 136.5, -20.5 });
|
||||
cam->set_view_point({ 0.0f, 1.0f, 3.45f });
|
||||
cam->set_interest({ 0.0f, 1.0f, 0.0f });
|
||||
//cam->set_fov(70.0);
|
||||
cam->set_fast_change_hist0(true);
|
||||
}
|
||||
else {
|
||||
camera_rotate(cam, &input_rotate);
|
||||
camera_move(cam, &input_move);
|
||||
camera_roll(cam, input_roll);
|
||||
cam->rotate(input_rotate);
|
||||
cam->move(input_move);
|
||||
if (input_roll != 0.0)
|
||||
cam->set_roll(cam->get_roll() + input_roll);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -882,8 +882,8 @@ static void render_ctrl(render_context* rctx) {
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, COMMON_DATA_SIZE, &common_data);
|
||||
gl_state_bind_uniform_buffer(0);
|
||||
|
||||
cube_line_shader.set("vp", false, cam->view_projection);
|
||||
cube_line_point_shader.set("vp", false, cam->view_projection);
|
||||
cube_line_shader->set("vp", false, cam->view_projection);
|
||||
cube_line_point_shader->set("vp", false, cam->view_projection);
|
||||
}
|
||||
|
||||
static void cube_line_draw(shader_glsl* shader, camera* cam, vec3* trans, float_t line_size, vec4* color) {
|
||||
@@ -956,7 +956,7 @@ static void render_draw(render_context* rctx) {
|
||||
|
||||
glViewport(0, 0, internal_3d_res.x, internal_3d_res.y);
|
||||
|
||||
render_texture_bind(&rctx->post_process.rend_texture, 0);
|
||||
rctx->post_process.rend_texture.bind();
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
glClearBufferfv(GL_COLOR, 0, color_clear);
|
||||
glClearBufferfv(GL_DEPTH, 0, &depth_clear);
|
||||
@@ -969,14 +969,14 @@ static void render_draw(render_context* rctx) {
|
||||
glClearBufferfv(GL_COLOR, 0, (GLfloat*)&_clear_color);
|
||||
}
|
||||
|
||||
camera_update(cam);
|
||||
cam->update();
|
||||
|
||||
rctx->disp();
|
||||
|
||||
int32_t screen_x_offset = (width - internal_2d_res.x) / 2 + (width - internal_2d_res.x) % 2;
|
||||
int32_t screen_y_offset = (height - internal_2d_res.y) / 2 + (width - internal_2d_res.x) % 2;
|
||||
glViewport(screen_x_offset, screen_y_offset, internal_2d_res.x, internal_2d_res.y);
|
||||
render_texture_bind(&rctx->post_process.screen_texture, 0);
|
||||
rctx->post_process.screen_texture.bind();
|
||||
gl_state_bind_uniform_buffer_base(0, common_data_ubo);
|
||||
classes_process_draw(classes, classes_count);
|
||||
|
||||
@@ -1000,7 +1000,7 @@ static void render_draw(render_context* rctx) {
|
||||
size_t object_bone_count = rob_bone_data->object_bone_count;
|
||||
size_t total_bone_count = rob_bone_data->total_bone_count;
|
||||
size_t ik_bone_count = rob_bone_data->ik_bone_count;
|
||||
cube_line_shader.use();
|
||||
cube_line_shader->use();
|
||||
for (bone_node& j : rob_bone_data->nodes) {
|
||||
if (!j.parent)
|
||||
continue;
|
||||
@@ -1010,7 +1010,7 @@ static void render_draw(render_context* rctx) {
|
||||
mat4_get_translation(j.mat, &trans[1]);
|
||||
|
||||
if (memcmp(&trans[0], &trans[1], sizeof(vec3)))
|
||||
cube_line_draw(&cube_line_shader, cam, trans, CUBE_LINE_SIZE, &bone_color);
|
||||
cube_line_draw(cube_line_shader, cam, trans, CUBE_LINE_SIZE, &bone_color);
|
||||
}
|
||||
gl_state_bind_array_buffer(0);
|
||||
|
||||
@@ -1059,11 +1059,11 @@ static void render_draw(render_context* rctx) {
|
||||
mat4_mult_vec3(&cam->inv_view_rot, &trans[3], &trans[3]);
|
||||
|
||||
gl_state_bind_vertex_array(cube_line_point_vao);
|
||||
cube_line_point_shader.use();
|
||||
cube_line_point_shader.set("trans", 4, trans);
|
||||
cube_line_point_shader.set("dark_border_end",
|
||||
cube_line_point_shader->use();
|
||||
cube_line_point_shader->set("trans", 4, trans);
|
||||
cube_line_point_shader->set("dark_border_end",
|
||||
((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE)));
|
||||
cube_line_point_shader.set("dark_border_start",
|
||||
cube_line_point_shader->set("dark_border_start",
|
||||
(1.0f - ((CUBE_LINE_POINT_SIZE - (CUBE_LINE_SIZE * 1.125f)) / (2.0f * CUBE_LINE_POINT_SIZE))));
|
||||
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, (GLsizei)cube_line_points.size());
|
||||
cube_line_points.clear();
|
||||
@@ -1090,6 +1090,11 @@ static void render_dispose(render_context* rctx) {
|
||||
ImGui::DestroyContext(imgui_context);
|
||||
lock_free(&imgui_context_lock);
|
||||
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
motion_database* aft_mot_db = &aft_data->data_ft.mot_db;
|
||||
object_database* aft_obj_db = &aft_data->data_ft.obj_db;
|
||||
motion_set_unload_motion(aft_mot_db->get_motion_set_id("CMN"));
|
||||
|
||||
task_rob_manager_free_task();
|
||||
//pv_game_data.SetDest();
|
||||
x_pv_game_data.SetDest();
|
||||
@@ -1098,19 +1103,41 @@ static void render_dispose(render_context* rctx) {
|
||||
task_pv_db_free_task();
|
||||
|
||||
//rob_chara_array_free_chara_id(0);
|
||||
timer_reset(&render_timer);
|
||||
render_timer->reset();
|
||||
for (int32_t i = 0; i < 30; i++) {
|
||||
timer_start_of_cycle(&render_timer);
|
||||
render_timer->start_of_cycle();
|
||||
lock_lock(&render_lock);
|
||||
app::TaskWork::Ctrl();
|
||||
file_handler_storage_ctrl();
|
||||
app::TaskWork::Basic();
|
||||
lock_unlock(&render_lock);
|
||||
timer_end_of_cycle(&render_timer);
|
||||
render_timer->end_of_cycle();
|
||||
}
|
||||
|
||||
light_param_data_storage::unload();
|
||||
|
||||
if (grid_shader) {
|
||||
delete grid_shader;
|
||||
grid_shader = 0;
|
||||
}
|
||||
|
||||
if (cube_line_point_shader) {
|
||||
delete cube_line_point_shader;
|
||||
cube_line_point_shader = 0;
|
||||
}
|
||||
|
||||
if (cube_line_shader) {
|
||||
delete cube_line_shader;
|
||||
cube_line_shader = 0;
|
||||
}
|
||||
|
||||
object_storage_unload_set(aft_obj_db, "DBG");
|
||||
|
||||
task_pv_db_free();
|
||||
light_param_storage_data_free();
|
||||
task_stage_modern_free();
|
||||
dtm_stg_free();
|
||||
task_stage_free();
|
||||
auth_3d_data_free();
|
||||
rob_free();
|
||||
app::task_work_free();
|
||||
@@ -1120,10 +1147,6 @@ static void render_dispose(render_context* rctx) {
|
||||
|
||||
render_shaders_free();
|
||||
|
||||
grid_shader.unload();
|
||||
cube_line_point_shader.unload();
|
||||
cube_line_shader.unload();
|
||||
|
||||
glDeleteBuffers(1, &common_data_ubo);
|
||||
glDeleteBuffers(1, &grid_vbo);
|
||||
glDeleteBuffers(1, &cube_line_point_instance_vbo);
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared.h"
|
||||
#include "shared.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct render_init_struct {
|
||||
@@ -3,12 +3,12 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "shared.h"
|
||||
#include "classes/data_test.h"
|
||||
#include "classes/data_view.h"
|
||||
#include "classes/glitter_editor.h"
|
||||
#include "classes/graphics.h"
|
||||
#include "classes/information.h"
|
||||
#include "shared.hpp"
|
||||
#include "classes/data_test.hpp"
|
||||
#include "classes/data_view.hpp"
|
||||
#include "classes/glitter_editor.hpp"
|
||||
#include "classes/graphics.hpp"
|
||||
#include "classes/information.hpp"
|
||||
|
||||
classes_data classes[] = {
|
||||
{
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "classes.h"
|
||||
#include "classes.hpp"
|
||||
#define CIMGUI_DEFINE_ENUMS_AND_STRUCTS
|
||||
#include <imgui/imgui.h>
|
||||
#include <imgui/imgui_internal.h>
|
||||
@@ -3,18 +3,18 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "sound.h"
|
||||
#include "../CRE/timer.h"
|
||||
#include "sound.hpp"
|
||||
#include "../CRE/timer.hpp"
|
||||
#include <timeapi.h>
|
||||
|
||||
timer sound_timer;
|
||||
timer* sound_timer;
|
||||
|
||||
extern bool close;
|
||||
|
||||
int32_t sound_main(void* arg) {
|
||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
|
||||
timeBeginPeriod(1);
|
||||
timer_init(&sound_timer, 60.0);
|
||||
sound_timer = new timer(60.0);
|
||||
|
||||
bool state_wait = false;
|
||||
bool state_disposed = false;
|
||||
@@ -24,10 +24,10 @@ int32_t sound_main(void* arg) {
|
||||
state_disposed = state == RENDER_DISPOSING;
|
||||
lock_unlock(&state_lock);
|
||||
if (state_disposed) {
|
||||
timer_dispose(&sound_timer);
|
||||
delete sound_timer;
|
||||
return 0;
|
||||
}
|
||||
timer_sleep(&sound_timer, 0.0625);
|
||||
sound_timer->sleep(0.0625);
|
||||
} while (state_wait);
|
||||
|
||||
lock_lock(&state_lock);
|
||||
@@ -35,17 +35,17 @@ int32_t sound_main(void* arg) {
|
||||
lock_unlock(&state_lock);
|
||||
|
||||
bool local_close = false;
|
||||
timer_reset(&sound_timer);
|
||||
sound_timer->reset();
|
||||
while (!close && !local_close) {
|
||||
timer_start_of_cycle(&sound_timer);
|
||||
sound_timer->start_of_cycle();
|
||||
lock_lock(&state_lock);
|
||||
local_close = state == RENDER_DISPOSING;
|
||||
lock_unlock(&state_lock);
|
||||
|
||||
classes_process_sound(classes, classes_count);
|
||||
timer_end_of_cycle(&sound_timer);
|
||||
sound_timer->end_of_cycle();
|
||||
}
|
||||
timer_dispose(&sound_timer);
|
||||
delete sound_timer;
|
||||
|
||||
lock_lock(&state_lock);
|
||||
enum_and(thread_flags, ~THREAD_SOUND);
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared.h"
|
||||
#include "shared.hpp"
|
||||
|
||||
extern int32_t sound_main(void* arg);
|
||||
@@ -1,426 +0,0 @@
|
||||
#include "unedat.h"
|
||||
#define AES128
|
||||
#include "../KKdLib/aes.hpp"
|
||||
#include "lz.h"
|
||||
#include <math.h>
|
||||
|
||||
void aescbc128_decrypt(uint8_t* key, uint8_t* iv, uint8_t* in, uint8_t* out, int len) {
|
||||
aes128_ctx ctx;
|
||||
aes128_init_ctx_iv(&ctx, key, iv);
|
||||
memcpy(out, in, len);
|
||||
aes128_cbc_decrypt_buffer(&ctx, out, len);
|
||||
|
||||
// Reset the IV.
|
||||
memset(iv, 0, 0x10);
|
||||
}
|
||||
|
||||
void aescbc128_encrypt(uint8_t* key, uint8_t* iv, uint8_t* in, uint8_t* out, int len) {
|
||||
aes128_ctx ctx;
|
||||
aes128_init_ctx_iv(&ctx, key, iv);
|
||||
memcpy(out, in, len);
|
||||
aes128_cbc_encrypt_buffer(&ctx, out, len);
|
||||
|
||||
// Reset the IV.
|
||||
memset(iv, 0, 0x10);
|
||||
}
|
||||
|
||||
void aesecb128_encrypt(uint8_t* key, uint8_t* in, uint8_t* out) {
|
||||
aes128_ctx ctx;
|
||||
aes128_init_ctx(&ctx, key);
|
||||
memcpy(out, in, 0x10);
|
||||
aes128_ecb_encrypt(&ctx, out);
|
||||
}
|
||||
|
||||
void rap_to_rif(uint8_t* rap, uint8_t* rif) {
|
||||
int i;
|
||||
int round;
|
||||
aes128_ctx ctx;
|
||||
|
||||
uint8_t key[0x10];
|
||||
uint8_t iv[0x10];
|
||||
memcpy(key, rap, 0x10);
|
||||
memset(iv, 0, 0x10);
|
||||
|
||||
// Initial decrypt.
|
||||
aes128_init_ctx_iv(&ctx, RAP_KEY, iv);
|
||||
aes128_cbc_decrypt_buffer(&ctx, key, 0x10);
|
||||
|
||||
// rap2rifkey round.
|
||||
for (round = 0; round < 5; ++round) {
|
||||
for (i = 0; i < 16; ++i) {
|
||||
int p = RAP_PBOX[i];
|
||||
key[p] ^= RAP_E1[p];
|
||||
}
|
||||
|
||||
for (i = 15; i > 0; --i) {
|
||||
int p = RAP_PBOX[i];
|
||||
int pp = RAP_PBOX[i - 1];
|
||||
key[p] ^= key[pp];
|
||||
}
|
||||
|
||||
uint8_t o = 0;
|
||||
for (i = 0; i < 16; ++i) {
|
||||
int p = RAP_PBOX[i];
|
||||
uint8_t kc = key[p] - o;
|
||||
uint8_t ec2 = RAP_E2[p];
|
||||
if (!o || kc != 0xFF)
|
||||
o = kc < ec2 ? 1 : 0;
|
||||
key[p] = kc - ec2;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(rif, key, 0x10);
|
||||
}
|
||||
|
||||
void generate_key(int crypto_mode, int version, uint8_t* key_final, uint8_t* iv_final, uint8_t* key, uint8_t* iv) {
|
||||
int mode = crypto_mode & 0xF0000000;
|
||||
switch (mode) {
|
||||
case 0x10000000:
|
||||
// Encrypted ERK.
|
||||
// Decrypt the key with EDAT_KEY + EDAT_IV and copy the original IV.
|
||||
aescbc128_decrypt(version ? EDAT_KEY_1 : EDAT_KEY_0, EDAT_IV, key, key_final, 0x10);
|
||||
memcpy(iv_final, iv, 0x10);
|
||||
break;
|
||||
case 0x20000000:
|
||||
// Default ERK.
|
||||
// Use EDAT_KEY and EDAT_IV.
|
||||
memcpy(key_final, version ? EDAT_KEY_1 : EDAT_KEY_0, 0x10);
|
||||
memcpy(iv_final, EDAT_IV, 0x10);
|
||||
break;
|
||||
case 0x00000000:
|
||||
// Unencrypted ERK.
|
||||
// Use the original key and iv.
|
||||
memcpy(key_final, key, 0x10);
|
||||
memcpy(iv_final, iv, 0x10);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void generate_hash(int hash_mode, int version, uint8_t* hash_final, uint8_t* hash) {
|
||||
int mode = hash_mode & 0xF0000000;
|
||||
switch (mode) {
|
||||
case 0x10000000:
|
||||
// Encrypted HASH.
|
||||
// Decrypt the hash with EDAT_KEY + EDAT_IV.
|
||||
aescbc128_decrypt(version ? EDAT_KEY_1 : EDAT_KEY_0, EDAT_IV, hash, hash_final, 0x10);
|
||||
break;
|
||||
case 0x20000000:
|
||||
// Default HASH.
|
||||
// Use EDAT_HASH.
|
||||
memcpy(hash_final, version ? EDAT_HASH_1 : EDAT_HASH_0, 0x10);
|
||||
break;
|
||||
case 0x00000000:
|
||||
// Unencrypted ERK.
|
||||
// Use the original hash.
|
||||
memcpy(hash_final, hash, 0x10);
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
bool decrypt(int crypto_mode, int version, uint8_t* in, uint8_t* out, int length, uint8_t* key, uint8_t* iv) {
|
||||
// Setup buffers for key, iv and hash.
|
||||
uint8_t key_final[0x10];
|
||||
uint8_t iv_final[0x10];
|
||||
|
||||
memset(key_final, 0, 0x10);
|
||||
memset(iv_final, 0, 0x10);
|
||||
|
||||
// Generate crypto key and hash.
|
||||
generate_key(crypto_mode, version, key_final, iv_final, key, iv);
|
||||
|
||||
if ((crypto_mode & 0xFF) == 0x01) // No algorithm.
|
||||
memcpy(out, in, length);
|
||||
else if ((crypto_mode & 0xFF) == 0x02) // AES128-CBC
|
||||
aescbc128_decrypt(key_final, iv_final, in, out, length);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// EDAT/SDAT functions.
|
||||
void get_block_key(int block, NPD_HEADER* npd, uint8_t* dest_key) {
|
||||
uint8_t empty_key[0x10];
|
||||
memset(empty_key, 0, 0x10);
|
||||
uint8_t* src_key = (npd->version <= 1) ? empty_key : npd->dev_hash;
|
||||
memcpy(dest_key, src_key, 0xC);
|
||||
store_reverse_endianness_int32_t(block, &dest_key[0xC]);
|
||||
}
|
||||
|
||||
// for out data, allocate a buffer the size of 'edat->block_size'
|
||||
// Also, set 'in file' to the beginning of the encrypted data, which may be offset
|
||||
// if inside another file, but normally just reset to beginning of file
|
||||
// returns number of bytes written, -1 for error
|
||||
int decrypt_block(stream& in, uint8_t* out, EDAT_HEADER* edat, NPD_HEADER* npd,
|
||||
uint8_t* crypt_key, uint32_t block_num, uint32_t total_blocks, int64_t size_left) {
|
||||
// Get metadata info and setup buffers.
|
||||
const int64_t metadata_section_size = edat->flags & (EDAT_COMPRESSED_FLAG | EDAT_FLAG_0x20) ? 0x20 : 0x10;
|
||||
const int metadata_offset = 0x100;
|
||||
|
||||
uint8_t key_result[0x10] = { 0 };
|
||||
|
||||
uint64_t offset = 0;
|
||||
uint64_t metadata_sec_offset = 0;
|
||||
int32_t length = 0;
|
||||
int32_t compression_end = 0;
|
||||
uint8_t empty_iv[0x10];
|
||||
memset(empty_iv, 0, 0x10);
|
||||
|
||||
size_t file_offset = in.get_position();
|
||||
|
||||
// Decrypt the metadata.
|
||||
if (edat->flags & EDAT_COMPRESSED_FLAG) {
|
||||
metadata_sec_offset = metadata_offset + block_num * metadata_section_size;
|
||||
|
||||
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
|
||||
|
||||
uint8_t metadata[0x20];
|
||||
memset(metadata, 0, 0x20);
|
||||
in.read(metadata, 0x20);
|
||||
|
||||
// If the data is compressed, decrypt the metadata.
|
||||
// NOTE: For NPD version 1 the metadata is not encrypted.
|
||||
if (npd->version <= 1) {
|
||||
offset = load_reverse_endianness_uint64_t(&metadata[0x10]);
|
||||
length = load_reverse_endianness_int32_t(&metadata[0x18]);
|
||||
compression_end = load_reverse_endianness_int32_t(&metadata[0x1C]);
|
||||
}
|
||||
else {
|
||||
uint8_t dec[0x10];
|
||||
dec[0x00] = metadata[0xC] ^ metadata[0x8] ^ metadata[0x10];
|
||||
dec[0x01] = metadata[0xD] ^ metadata[0x9] ^ metadata[0x11];
|
||||
dec[0x02] = metadata[0xE] ^ metadata[0xA] ^ metadata[0x12];
|
||||
dec[0x03] = metadata[0xF] ^ metadata[0xB] ^ metadata[0x13];
|
||||
dec[0x04] = metadata[0x4] ^ metadata[0x8] ^ metadata[0x14];
|
||||
dec[0x05] = metadata[0x5] ^ metadata[0x9] ^ metadata[0x15];
|
||||
dec[0x06] = metadata[0x6] ^ metadata[0xA] ^ metadata[0x16];
|
||||
dec[0x07] = metadata[0x7] ^ metadata[0xB] ^ metadata[0x17];
|
||||
dec[0x08] = metadata[0xC] ^ metadata[0x0] ^ metadata[0x18];
|
||||
dec[0x09] = metadata[0xD] ^ metadata[0x1] ^ metadata[0x19];
|
||||
dec[0x0A] = metadata[0xE] ^ metadata[0x2] ^ metadata[0x1A];
|
||||
dec[0x0B] = metadata[0xF] ^ metadata[0x3] ^ metadata[0x1B];
|
||||
dec[0x0C] = metadata[0x4] ^ metadata[0x0] ^ metadata[0x1C];
|
||||
dec[0x0D] = metadata[0x5] ^ metadata[0x1] ^ metadata[0x1D];
|
||||
dec[0x0E] = metadata[0x6] ^ metadata[0x2] ^ metadata[0x1E];
|
||||
dec[0x0F] = metadata[0x7] ^ metadata[0x3] ^ metadata[0x1F];
|
||||
|
||||
offset = load_reverse_endianness_uint64_t(&dec[0x00]);
|
||||
length = load_reverse_endianness_int32_t(&dec[0x08]);
|
||||
compression_end = load_reverse_endianness_int32_t(&dec[0x0C]);
|
||||
}
|
||||
}
|
||||
else if (edat->flags & EDAT_FLAG_0x20) {
|
||||
// If FLAG 0x20, the metadata precedes each data block.
|
||||
metadata_sec_offset = metadata_offset + block_num * (metadata_section_size + edat->block_size);
|
||||
|
||||
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
|
||||
|
||||
uint8_t metadata[0x20];
|
||||
memset(metadata, 0, 0x20);
|
||||
in.read(metadata, 0x20);
|
||||
|
||||
offset = metadata_sec_offset + 0x20;
|
||||
length = edat->block_size;
|
||||
|
||||
if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size))
|
||||
length = (int32_t)(edat->file_size % edat->block_size);
|
||||
}
|
||||
else {
|
||||
metadata_sec_offset = metadata_offset + (uint64_t)block_num * metadata_section_size;
|
||||
in.set_position(file_offset + metadata_sec_offset, SEEK_SET);
|
||||
offset = metadata_offset + (uint64_t)block_num * edat->block_size + total_blocks * metadata_section_size;
|
||||
length = edat->block_size;
|
||||
|
||||
if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size))
|
||||
length = (int32_t)(edat->file_size % edat->block_size);
|
||||
}
|
||||
|
||||
// Locate the real data.
|
||||
const int pad_length = length;
|
||||
length = (pad_length + 0xF) & 0xFFFFFFF0;
|
||||
|
||||
// Setup buffers for decryption and read the data.
|
||||
memset(key_result, 0, 0x10);
|
||||
|
||||
uint8_t* enc_data = force_malloc_s(uint8_t, length);
|
||||
uint8_t* dec_data = force_malloc_s(uint8_t, length);
|
||||
in.set_position(file_offset + offset, 0);
|
||||
in.read(enc_data, length);
|
||||
|
||||
// Generate a key for the current block.
|
||||
uint8_t b_key[16];
|
||||
get_block_key(block_num, npd, b_key);
|
||||
|
||||
// Encrypt the block key with the crypto key.
|
||||
aesecb128_encrypt(crypt_key, b_key, key_result);
|
||||
|
||||
// Setup the crypto and hashing mode based on the extra flags.
|
||||
int crypto_mode = ((edat->flags & EDAT_FLAG_0x02) == 0) ? 0x2 : 0x1;
|
||||
|
||||
if (edat->flags & EDAT_ENCRYPTED_KEY_FLAG)
|
||||
crypto_mode |= 0x10000000;
|
||||
|
||||
if (edat->flags & EDAT_DEBUG_DATA_FLAG) {
|
||||
// Reset the flags.
|
||||
crypto_mode |= 0x01000000;
|
||||
// Simply copy the data without the header or the footer.
|
||||
memcpy(dec_data, enc_data, length);
|
||||
}
|
||||
else {
|
||||
// IV is null if NPD version is 1 or 0.
|
||||
uint8_t* iv = (npd->version <= 1) ? empty_iv : npd->digest;
|
||||
// Call main crypto routine on this data block.
|
||||
if (!decrypt(crypto_mode, (npd->version == 4), enc_data, dec_data, length, key_result, iv))
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Apply additional de-compression if needed and write the decrypted data.
|
||||
if ((edat->flags & EDAT_COMPRESSED_FLAG) && compression_end) {
|
||||
int res = decompress(out, dec_data, edat->block_size);
|
||||
size_left -= res;
|
||||
|
||||
if (size_left == 0 && res < 0)
|
||||
return -1;
|
||||
return res;
|
||||
}
|
||||
|
||||
memcpy(out, dec_data, pad_length);
|
||||
return pad_length;
|
||||
}
|
||||
|
||||
// EDAT/SDAT decryption.
|
||||
// reset file to beginning of data before calling
|
||||
int decrypt_data(stream& in, stream& out, EDAT_HEADER* edat, NPD_HEADER* npd, unsigned char* crypt_key) {
|
||||
const int total_blocks = (int)((edat->file_size + edat->block_size - 1) / edat->block_size);
|
||||
int64_t size_left = edat->file_size;
|
||||
uint8_t* data = force_malloc_s(uint8_t, edat->block_size);
|
||||
|
||||
for (int i = 0; i < total_blocks; i++) {
|
||||
in.set_position(0, 0);
|
||||
memset(data, 0, edat->block_size);
|
||||
int res = decrypt_block(in, data, edat, npd, crypt_key, i, total_blocks, size_left);
|
||||
if (res == -1)
|
||||
return 1;
|
||||
|
||||
size_left -= res;
|
||||
out.write(data, res);
|
||||
}
|
||||
free(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void read_npd_edat_header(stream& input, NPD_HEADER* NPD, EDAT_HEADER* EDAT) {
|
||||
char npd_header[0x80];
|
||||
char edat_header[0x10];
|
||||
input.read(npd_header, sizeof(npd_header));
|
||||
input.read(edat_header, sizeof(edat_header));
|
||||
|
||||
memcpy(&NPD->magic, npd_header, 0x04);
|
||||
NPD->version = load_reverse_endianness_int32_t(&npd_header[0x04]);
|
||||
NPD->license = load_reverse_endianness_int32_t(&npd_header[0x08]);
|
||||
NPD->type = load_reverse_endianness_int32_t(&npd_header[0x0C]);
|
||||
memcpy(&NPD->content_id, &npd_header[0x10], 0x30);
|
||||
memcpy(&NPD->digest, &npd_header[0x40], 0x10);
|
||||
memcpy(&NPD->title_hash, &npd_header[0x50], 0x10);
|
||||
memcpy(&NPD->dev_hash, &npd_header[0x60], 0x10);
|
||||
NPD->unk1 = load_reverse_endianness_int64_t(&npd_header[0x70]);
|
||||
NPD->unk2 = load_reverse_endianness_int64_t(&npd_header[0x78]);
|
||||
|
||||
EDAT->flags = load_reverse_endianness_int32_t(&edat_header[0x00]);
|
||||
EDAT->block_size = load_reverse_endianness_int32_t(&edat_header[0x04]);
|
||||
EDAT->file_size = load_reverse_endianness_int64_t(&edat_header[0x08]);
|
||||
}
|
||||
|
||||
bool extract_all_data(stream& input, stream& output, uint8_t* devKlic, uint8_t* rifKey) {
|
||||
// Setup NPD and EDAT/SDAT structs.
|
||||
NPD_HEADER NPD;
|
||||
EDAT_HEADER EDAT;
|
||||
|
||||
// Read in the NPD and EDAT/SDAT headers.
|
||||
read_npd_edat_header(input, &NPD, &EDAT);
|
||||
|
||||
const char* npd_magic = "NPD";
|
||||
if (memcmp(&NPD.magic, npd_magic, 0x04))
|
||||
return 1;
|
||||
|
||||
// Set decryption key.
|
||||
uint8_t key[16];
|
||||
|
||||
// Check EDAT/SDAT flag.
|
||||
if ((EDAT.flags & SDAT_FLAG) == SDAT_FLAG)
|
||||
// Generate SDAT key.
|
||||
for (int i = 0; i < 16; i++)
|
||||
key[i] = NPD.dev_hash[i] ^ SDAT_KEY[i];
|
||||
else if (NPD.license == 0x3) // Type 3: Use supplied devklic.
|
||||
memcpy(key, devKlic, 0x10);
|
||||
else if (NPD.license == 0x2) // Type 2: Use key from RAP file (RIF key).
|
||||
memcpy(key, rifKey, 0x10);
|
||||
else if (NPD.license == 0x1) // Type 1: Use network activation.
|
||||
memcpy(key, rifKey, 0x10);
|
||||
|
||||
input.set_position(0, 0);
|
||||
if (decrypt_data(input, output, &EDAT, &NPD, key))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetEdatRifKeyFromRapFile(stream& rap_file, uint8_t* rifKey) {
|
||||
uint8_t rapKey[0x10];
|
||||
rap_file.read(rapKey, 0x10);
|
||||
rap_to_rif(rapKey, rifKey);
|
||||
}
|
||||
|
||||
// Decrypts full file
|
||||
void DecryptEDAT(stream& input, stream& output, int mode, const char* rap_file_name, uint8_t* custom_klic) {
|
||||
if (!rap_file_name)
|
||||
return;
|
||||
|
||||
// Prepare the files.
|
||||
input.set_position(0, 0);
|
||||
|
||||
// Set keys (RIF and DEVKLIC).
|
||||
uint8_t rifKey[16];
|
||||
uint8_t devklic[16];
|
||||
|
||||
// Select the EDAT key mode.
|
||||
switch (mode) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
memcpy(devklic, NP_KLIC_FREE, 0x10);
|
||||
break;
|
||||
case 2:
|
||||
memcpy(devklic, NP_OMAC_KEY_2, 0x10);
|
||||
break;
|
||||
case 3:
|
||||
memcpy(devklic, NP_OMAC_KEY_3, 0x10);
|
||||
break;
|
||||
case 4:
|
||||
memcpy(devklic, NP_KLIC_KEY, 0x10);
|
||||
break;
|
||||
case 5:
|
||||
memcpy(devklic, NP_PSX_KEY, 0x10);
|
||||
break;
|
||||
case 6:
|
||||
memcpy(devklic, NP_PSP_KEY_1, 0x10);
|
||||
break;
|
||||
case 7:
|
||||
memcpy(devklic, NP_PSP_KEY_2, 0x10);
|
||||
break;
|
||||
case 8:
|
||||
if (custom_klic)
|
||||
memcpy(devklic, custom_klic, 0x10);
|
||||
break;
|
||||
}
|
||||
|
||||
// Read the RAP file, if provided.
|
||||
if (*rap_file_name) {
|
||||
stream rap;
|
||||
rap.open(rap_file_name, "rb");
|
||||
if (rap.io.stream)
|
||||
GetEdatRifKeyFromRapFile(rap, rifKey);
|
||||
}
|
||||
|
||||
extract_all_data(input, output, devklic, rifKey);
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/io/stream.hpp"
|
||||
|
||||
#define SDAT_FLAG 0x01000000
|
||||
#define EDAT_COMPRESSED_FLAG 0x00000001
|
||||
#define EDAT_FLAG_0x02 0x00000002
|
||||
#define EDAT_ENCRYPTED_KEY_FLAG 0x00000008
|
||||
#define EDAT_FLAG_0x10 0x00000010
|
||||
#define EDAT_FLAG_0x20 0x00000020
|
||||
#define EDAT_DEBUG_DATA_FLAG 0x80000000
|
||||
|
||||
static uint8_t NP_KLIC_FREE[0x10] = {
|
||||
0x72, 0xF9, 0x90, 0x78, 0x8F, 0x9C, 0xFF, 0x74, 0x57, 0x25, 0xF0, 0x8E, 0x4C, 0x12, 0x83, 0x87
|
||||
};
|
||||
|
||||
static uint8_t NP_OMAC_KEY_2[0x10] = {
|
||||
0x6B, 0xA5, 0x29, 0x76, 0xEF, 0xDA, 0x16, 0xEF, 0x3C, 0x33, 0x9F, 0xB2, 0x97, 0x1E, 0x25, 0x6B
|
||||
};
|
||||
|
||||
static uint8_t NP_OMAC_KEY_3[0x10] = {
|
||||
0x9B, 0x51, 0x5F, 0xEA, 0xCF, 0x75, 0x06, 0x49, 0x81, 0xAA, 0x60, 0x4D, 0x91, 0xA5, 0x4E, 0x97
|
||||
};
|
||||
|
||||
static uint8_t NP_KLIC_KEY[0x10] = {
|
||||
0xF2, 0xFB, 0xCA, 0x7A, 0x75, 0xB0, 0x4E, 0xDC, 0x13, 0x90, 0x63, 0x8C, 0xCD, 0xFD, 0xD1, 0xEE
|
||||
};
|
||||
|
||||
static uint8_t NP_RIF_KEY[0x10] = {
|
||||
0xDA, 0x7D, 0x4B, 0x5E, 0x49, 0x9A, 0x4F, 0x53, 0xB1, 0xC1, 0xA1, 0x4A, 0x74, 0x84, 0x44, 0x3B
|
||||
};
|
||||
|
||||
// PSP Minis
|
||||
static uint8_t NP_PSP_KEY_1[0x10] = {
|
||||
0x2A, 0x6A, 0xFB, 0xCF, 0x43, 0xD1, 0x57, 0x9F, 0x7D, 0x73, 0x87, 0x41, 0xA1, 0x3B, 0xD4, 0x2E
|
||||
};
|
||||
|
||||
// PSP Remasters
|
||||
static uint8_t NP_PSP_KEY_2[0x10] = {
|
||||
0x0D, 0xB8, 0x57, 0x32, 0x36, 0x6C, 0xD7, 0x34, 0xFC, 0x87, 0x9E, 0x74, 0x33, 0x43, 0xBB, 0x4F
|
||||
};
|
||||
|
||||
static uint8_t NP_PSX_KEY[0x10] = {
|
||||
0x52, 0xC0, 0xB5, 0xCA, 0x76, 0xD6, 0x13, 0x4B, 0xB4, 0x5F, 0xC6, 0x6C, 0xA6, 0x37, 0xF2, 0xC1
|
||||
};
|
||||
|
||||
static uint8_t RAP_KEY[0x10] = {
|
||||
0x86, 0x9F, 0x77, 0x45, 0xC1, 0x3F, 0xD8, 0x90, 0xCC, 0xF2, 0x91, 0x88, 0xE3, 0xCC, 0x3E, 0xDF
|
||||
};
|
||||
|
||||
static uint8_t RAP_PBOX[0x10] = {
|
||||
0x0C, 0x03, 0x06, 0x04, 0x01, 0x0B, 0x0F, 0x08, 0x02, 0x07, 0x00, 0x05, 0x0A, 0x0E, 0x0D, 0x09
|
||||
};
|
||||
|
||||
static uint8_t RAP_E1[0x10] = {
|
||||
0xA9, 0x3E, 0x1F, 0xD6, 0x7C, 0x55, 0xA3, 0x29, 0xB7, 0x5F, 0xDD, 0xA6, 0x2A, 0x95, 0xC7, 0xA5
|
||||
};
|
||||
|
||||
static uint8_t RAP_E2[0x10] = {
|
||||
0x67, 0xD4, 0x5D, 0xA3, 0x29, 0x6D, 0x00, 0x6A, 0x4E, 0x7C, 0x53, 0x7B, 0xF5, 0x53, 0x8C, 0x74
|
||||
};
|
||||
|
||||
static uint8_t SDAT_KEY[0x10] = {
|
||||
0x0D, 0x65, 0x5E, 0xF8, 0xE6, 0x74, 0xA9, 0x8A, 0xB8, 0x50, 0x5C, 0xFA, 0x7D, 0x01, 0x29, 0x33
|
||||
};
|
||||
|
||||
static uint8_t EDAT_KEY_0[0x10] = {
|
||||
0xBE, 0x95, 0x9C, 0xA8, 0x30, 0x8D, 0xEF, 0xA2, 0xE5, 0xE1, 0x80, 0xC6, 0x37, 0x12, 0xA9, 0xAE
|
||||
};
|
||||
|
||||
static uint8_t EDAT_HASH_0[0x10] = {
|
||||
0xEF, 0xFE, 0x5B, 0xD1, 0x65, 0x2E, 0xEB, 0xC1, 0x19, 0x18, 0xCF, 0x7C, 0x04, 0xD4, 0xF0, 0x11
|
||||
};
|
||||
|
||||
static uint8_t EDAT_KEY_1[0x10] = {
|
||||
0x4C, 0xA9, 0xC1, 0x4B, 0x01, 0xC9, 0x53, 0x09, 0x96, 0x9B, 0xEC, 0x68, 0xAA, 0x0B, 0xC0, 0x81
|
||||
};
|
||||
|
||||
static uint8_t EDAT_HASH_1[0x10] = {
|
||||
0x3D, 0x92, 0x69, 0x9B, 0x70, 0x5B, 0x07, 0x38, 0x54, 0xD8, 0xFC, 0xC6, 0xC7, 0x67, 0x27, 0x47
|
||||
};
|
||||
|
||||
static uint8_t EDAT_IV[0x10] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
typedef struct NPD_HEADER {
|
||||
uint32_t magic;
|
||||
int32_t version;
|
||||
int32_t license;
|
||||
int32_t type;
|
||||
uint8_t content_id[0x30];
|
||||
uint8_t digest[0x10];
|
||||
uint8_t title_hash[0x10];
|
||||
uint8_t dev_hash[0x10];
|
||||
int64_t unk1;
|
||||
int64_t unk2;
|
||||
} NPD_HEADER;
|
||||
|
||||
typedef struct EDAT_HEADER {
|
||||
int32_t flags;
|
||||
int32_t block_size;
|
||||
int64_t file_size;
|
||||
} EDAT_HEADER;
|
||||
|
||||
// Decrypts full file, or null/empty file
|
||||
extern void rap_to_rif(uint8_t* rap, uint8_t* rif);
|
||||
extern void DecryptEDAT(stream& input, stream& output, int mode, const char* rap_file_name, uint8_t* custom_klic);
|
||||
extern void GetEdatRifKeyFromRapFile(stream& rap_file, uint8_t* rifKey);
|
||||
+21
-17
@@ -18,7 +18,7 @@
|
||||
#include "../KKdLib/farc.hpp"
|
||||
#include "../KKdLib/sort.hpp"
|
||||
#include "input.hpp"
|
||||
#include "classes/imgui_helper.h"
|
||||
#include "classes/imgui_helper.hpp"
|
||||
|
||||
enum dsc_x_func {
|
||||
DSC_X_END = 0,
|
||||
@@ -395,10 +395,7 @@ bool x_pv_game::Ctrl() {
|
||||
|
||||
auth_3d_data_load_category(light_category.c_str());
|
||||
|
||||
for (pvpp_chara& i : pp->chara)
|
||||
if (i.chara_effect_init)
|
||||
for (pvpp_chara_effect_a3da& j : i.chara_effect.effect_a3da)
|
||||
auth_3d_data_load_category(x_data, camera_category.c_str(), camera_category_hash);
|
||||
auth_3d_data_load_category(camera_category.c_str());
|
||||
|
||||
bool pv_glt = pv_glitter->hash != hash_murmurhash_empty;
|
||||
bool stg_glt = stage_glitter->hash != hash_murmurhash_empty;
|
||||
@@ -1016,35 +1013,35 @@ void x_pv_game::Window() {
|
||||
return;
|
||||
}
|
||||
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::BeginTable("buttons", 2)) {
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, w * 0.5f);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton(pause || (!pause && step_frame) ? "Play (K)" : "Pause (K)", { w, 0.0f }))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed(pause || (!pause && step_frame) ? "Play (K)" : "Pause (K)", { w, 0.0f }))
|
||||
pause ^= true;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Step Frame (L)", { w, 0.0f })) {
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Step Frame (L)", { w, 0.0f })) {
|
||||
pause = true;
|
||||
step_frame = true;
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
if (imguiButton("Stop (Ctrl+K)", { w, 0.0f }))
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
if (ImGui::ButtonEnterKeyPressed("Stop (Ctrl+K)", { w, 0.0f }))
|
||||
state = 11;
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
w = imguiGetContentRegionAvailWidth();
|
||||
w = ImGui::GetContentRegionAvailWidth();
|
||||
char buf[0x100];
|
||||
sprintf_s(buf, sizeof(buf), "%d", frame);
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, { 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
imguiButtonEx(buf, { w, 0.0f }, ImGuiButtonFlags_DontClosePopups
|
||||
ImGui::ButtonExEnterKeyPressed(buf, { w, 0.0f }, ImGuiButtonFlags_DontClosePopups
|
||||
| ImGuiButtonFlags_NoNavFocus | ImGuiButtonFlags_NoHoveredOnFocus);
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::EndTable();
|
||||
@@ -1520,7 +1517,7 @@ bool mot_write_motion(void* data, const char* path, const char* file, uint32_t h
|
||||
}
|
||||
|
||||
void x_pv_game::Unload() {
|
||||
if (pv_id == 826) {
|
||||
if (false && pv_id == 826) {
|
||||
data_struct* aft_data = &data_list[DATA_AFT];
|
||||
motion_database* aft_mot_db = &aft_data->data_ft.mot_db;
|
||||
|
||||
@@ -1626,6 +1623,8 @@ void x_pv_game::Unload() {
|
||||
|
||||
auth_3d_data_unload_category(light_category.c_str());
|
||||
|
||||
auth_3d_data_unload_category(camera_category.c_str());
|
||||
|
||||
category_load.clear();
|
||||
category_load.shrink_to_fit();
|
||||
effchrpv_category_load.clear();
|
||||
@@ -1725,7 +1724,9 @@ void x_struc_104::reset() {
|
||||
end_rot = 0.0f;
|
||||
mot_smooth_len = 12.0f;
|
||||
set_motion.clear();
|
||||
set_motion.shrink_to_fit();
|
||||
set_item.clear();
|
||||
set_item.shrink_to_fit();
|
||||
}
|
||||
|
||||
x_pv_play_data::x_pv_play_data() : rob_chr(), disp() {
|
||||
@@ -1738,6 +1739,7 @@ x_pv_play_data::~x_pv_play_data() {
|
||||
|
||||
void x_pv_play_data::reset() {
|
||||
motion.clear();
|
||||
motion.shrink_to_fit();
|
||||
rob_chr = 0;
|
||||
set_motion.clear();
|
||||
disp = true;
|
||||
@@ -3627,10 +3629,12 @@ static void sub_140122770(x_pv_game* a1, int32_t chara_id) {
|
||||
if (chara_id < 0 || chara_id >= ROB_CHARA_COUNT)
|
||||
return;
|
||||
|
||||
x_pv_play_data* playdata = &a1->playdata[chara_id];
|
||||
|
||||
int32_t pv_branch_mode = 0;
|
||||
int32_t time = -1;
|
||||
int32_t prev_time = -1;
|
||||
a1->playdata[chara_id].field_38.set_motion.clear();
|
||||
playdata->field_38.set_motion.clear();
|
||||
|
||||
dsc_data* i = a1->dsc_m.data.data();
|
||||
dsc_data* i_end = a1->dsc_m.data.data() + a1->dsc_m.data.size();
|
||||
@@ -3651,7 +3655,7 @@ static void sub_140122770(x_pv_game* a1, int32_t chara_id) {
|
||||
motion.motion_index = data[1];
|
||||
motion.time = time;
|
||||
motion.pv_branch_mode = pv_branch_mode;
|
||||
a1->playdata[chara_id].field_38.set_motion.push_back(motion);
|
||||
playdata->field_38.set_motion.push_back(motion);
|
||||
}
|
||||
prev_time = time;
|
||||
i++;
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
#include "../KKdLib/dsc.hpp"
|
||||
#include "../KKdLib/pvpp.hpp"
|
||||
#include "../KKdLib/pvsr.hpp"
|
||||
#include "../CRE/rob/rob.hpp"
|
||||
#include "../CRE/auth_3d.hpp"
|
||||
#include "../CRE/rob.hpp"
|
||||
#include "../CRE/task.hpp"
|
||||
#include "classes.h"
|
||||
#include "classes.hpp"
|
||||
|
||||
struct x_pv_game_glitter {
|
||||
std::string name;
|
||||
@@ -265,6 +265,7 @@ public:
|
||||
|
||||
x_pv_game();
|
||||
virtual ~x_pv_game() override;
|
||||
|
||||
virtual bool Init() override;
|
||||
virtual bool Ctrl() override;
|
||||
virtual bool Dest() override;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../../KKdLib/str_utils.hpp"
|
||||
#include "../rob/rob.hpp"
|
||||
#include "../auth_3d.hpp"
|
||||
#include "../rob.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
EffectInst::EffectInst(GPM, GLT, Effect* eff,
|
||||
|
||||
@@ -574,7 +574,7 @@ namespace Glitter {
|
||||
bool mult = true;
|
||||
mat4 dir_mat;
|
||||
switch (data.direction) {
|
||||
case DIRECTION_BILLBOARD:
|
||||
case DIRECTION_BILLBOARD: {
|
||||
if (eff_inst->data.flags & EFFECT_LOCAL) {
|
||||
dir_mat = ((render_context*)GPM_VAL->rctx)->camera->view;
|
||||
mat4_clear_trans(&dir_mat, &dir_mat);
|
||||
@@ -587,7 +587,7 @@ namespace Glitter {
|
||||
mat4_from_mat3(&((render_context*)GPM_VAL->rctx)->camera->inv_view_mat3, &inv_view_mat);
|
||||
mat4_mult(&dir_mat, &inv_view_mat, &dir_mat);
|
||||
mat4_clear_trans(&dir_mat, &dir_mat);
|
||||
break;
|
||||
} break;
|
||||
case DIRECTION_Y_AXIS:
|
||||
mat4_rotate_y((float_t)M_PI_2, &dir_mat);
|
||||
break;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../file_handler.hpp"
|
||||
#include "../frame_rate_control.hpp"
|
||||
#include "../static_var.h"
|
||||
#include "../static_var.hpp"
|
||||
#include "../task.hpp"
|
||||
#include "../texture.hpp"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../gl_state.h"
|
||||
#include "../gl_state.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
RenderGroup::RenderGroup() : flags(), type(), draw_type(), pivot(),
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
|
||||
#include "glitter.hpp"
|
||||
#include "../draw_task.h"
|
||||
#include "../gl_state.h"
|
||||
#include "../draw_task.hpp"
|
||||
#include "../gl_state.hpp"
|
||||
#include "../render_context.hpp"
|
||||
#include "../shader.h"
|
||||
#include "../shader_ft.h"
|
||||
#include "../static_var.h"
|
||||
#include "../shader.hpp"
|
||||
#include "../shader_ft.hpp"
|
||||
#include "../static_var.hpp"
|
||||
|
||||
namespace Glitter {
|
||||
RenderScene::RenderScene() : ctrl_quad(), ctrl_line(), ctrl_locus(),
|
||||
|
||||
+155
-468
@@ -6,10 +6,12 @@
|
||||
#include "auth_3d.hpp"
|
||||
#include "../KKdLib/hash.hpp"
|
||||
#include "../KKdLib/interpolation.h"
|
||||
#include "../KKdLib/sort.hpp"
|
||||
#include "../KKdLib/str_utils.hpp"
|
||||
#include "draw_task.h"
|
||||
#include "rob/rob.hpp"
|
||||
#include "draw_task.hpp"
|
||||
#include "object.hpp"
|
||||
#include "rob.hpp"
|
||||
#include "pv_db.hpp"
|
||||
#include "stage.hpp"
|
||||
|
||||
namespace auth_3d_detail {
|
||||
@@ -347,10 +349,10 @@ void auth_3d::ctrl(render_context* rctx) {
|
||||
mat4_mult_vec3_trans(&mat, &view_point, &view_point);
|
||||
|
||||
camera* cam = rctx->camera;
|
||||
camera_set_interest(cam, &interest);
|
||||
camera_set_view_point(cam, &view_point);
|
||||
camera_set_fov(cam, fov * RAD_TO_DEG);
|
||||
camera_set_roll(cam, roll * RAD_TO_DEG);
|
||||
cam->set_interest(interest);
|
||||
cam->set_view_point(view_point);
|
||||
cam->set_fov(fov * RAD_TO_DEG);
|
||||
cam->set_roll(roll * RAD_TO_DEG);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1605,344 +1607,6 @@ bool Auth3dTestTask::Dest() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void __fastcall sub_140248480(string *a1, list_int32_t *a2)
|
||||
{
|
||||
list_int32_t_node *v4; // rcx
|
||||
list_int32_t_node *v5; // rbx
|
||||
char *v6; // rcx
|
||||
int32_t *i; // rbx
|
||||
const char *v8; // rax
|
||||
size_t v9; // r8
|
||||
size_t v10; // rsi
|
||||
char *v11; // rdi
|
||||
_BYTE *v12; // rax
|
||||
_BYTE *v13; // r9
|
||||
int v14; // ecx
|
||||
char *v15; // rax
|
||||
ssize_t v16; // r9
|
||||
char *v17; // rcx
|
||||
list_int32_t_node *v18; // rdi
|
||||
list_int32_t_node *v19; // rax
|
||||
size_t v20; // rdx
|
||||
int32_t v21; // eax
|
||||
pv_db_pv *v22; // rax
|
||||
pv_db_pv_difficulty *v23; // rcx
|
||||
string_union v24; // kr00_16
|
||||
pv_item *__shifted(pv_item,8) v25; // rbx
|
||||
const char *v26; // rcx
|
||||
object_info v27; // eax
|
||||
list_int32_t_node *v28; // rdi
|
||||
list_int32_t_node *v29; // rax
|
||||
size_t v30; // rdx
|
||||
pv_item *__shifted(pv_item,0x20) v31; // rbx
|
||||
char *v32; // rcx
|
||||
list_int32_t_node *v33; // rbx
|
||||
list_int32_t_node *v34; // rdx
|
||||
size_t v35; // rax
|
||||
ssize_t v36; // rax
|
||||
string *v37; // rbx
|
||||
ssize_t v38; // rax
|
||||
string *v39; // rbx
|
||||
char *v40; // rcx
|
||||
list_int32_t_node *v41; // rbx
|
||||
list_int32_t_node *v42; // rdx
|
||||
size_t v43; // rax
|
||||
char *v44; // rcx
|
||||
list_int32_t_node *v45; // rbx
|
||||
list_int32_t_node *v46; // rcx
|
||||
size_t v47; // rax
|
||||
int32_t a4; // [rsp+20h] [rbp-49h] BYREF
|
||||
__int64 v49; // [rsp+28h] [rbp-41h]
|
||||
string Dst; // [rsp+30h] [rbp-39h] BYREF
|
||||
string v51; // [rsp+30h] [rbp-39h] FORCED BYREF
|
||||
string Memory; // [rsp+50h] [rbp-19h] BYREF
|
||||
vector_int32_t uids; // [rsp+70h] [rbp+7h] BYREF
|
||||
|
||||
v49 = -2i64;
|
||||
v4 = a2->head->next;
|
||||
a2->head->next = a2->head;
|
||||
a2->head->prev = a2->head;
|
||||
a2->size = 0i64;
|
||||
if ( v4 != a2->head )
|
||||
{
|
||||
do
|
||||
{
|
||||
v5 = v4->next;
|
||||
operator delete(v4);
|
||||
v4 = v5;
|
||||
}
|
||||
while ( v5 != a2->head );
|
||||
}
|
||||
uids.begin = 0i64;
|
||||
uids.end = 0i64;
|
||||
uids.capacity_end = 0i64;
|
||||
if ( a1->capacity < 0x10 )
|
||||
v6 = (char *)a1;
|
||||
else
|
||||
v6 = a1->data.ptr;
|
||||
auth_3d_data_get_category_uids(v6, &uids);
|
||||
for ( i = uids.begin; i != uids.end; ++i )
|
||||
{
|
||||
v8 = auth_3d_data_get_uid_name(*i);
|
||||
Dst.capacity = 15i64;
|
||||
Dst.length = 0i64;
|
||||
Dst.data.data[0] = 0;
|
||||
if ( *v8 )
|
||||
{
|
||||
v9 = -1i64;
|
||||
do
|
||||
++v9;
|
||||
while ( v8[v9] );
|
||||
}
|
||||
else
|
||||
{
|
||||
v9 = 0i64;
|
||||
}
|
||||
string_assign_char_str(&Dst, v8, v9);
|
||||
v10 = Dst.length;
|
||||
if ( Dst.length )
|
||||
{
|
||||
v11 = (char *)&Dst;
|
||||
if ( Dst.capacity >= 0x10 )
|
||||
v11 = Dst.data.ptr;
|
||||
while ( v10 )
|
||||
{
|
||||
v12 = memchr(v11, '_', v10);
|
||||
v13 = v12;
|
||||
if ( !v12 )
|
||||
break;
|
||||
if ( *v12 == asc_14096CDF0[0] )
|
||||
v14 = 0;
|
||||
else
|
||||
v14 = *v12 < asc_14096CDF0[0] ? -1 : 1;
|
||||
if ( !v14 )
|
||||
{
|
||||
v15 = (char *)&Dst;
|
||||
if ( Dst.capacity >= 0x10 )
|
||||
v15 = Dst.data.ptr;
|
||||
v16 = v13 - v15;
|
||||
if ( v16 != -1 )
|
||||
{
|
||||
sub_1400215A0(&Dst, &Memory, 0i64, v16);
|
||||
v17 = (char *)&Memory;
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
v17 = Memory.data.ptr;
|
||||
a4 = obj_database_get_object_set(v17);
|
||||
if ( a4 != -1 )
|
||||
{
|
||||
v18 = a2->head;
|
||||
v19 = list_int32_t_buy_node(a2, a2->head, a2->head->prev, &a4);
|
||||
v20 = a2->size;
|
||||
if ( v20 == 0xAAAAAAAAAAAAAA9i64 )
|
||||
ThrowException("list<T> too long");
|
||||
a2->size = v20 + 1;
|
||||
v18->prev = v19;
|
||||
v19->prev->next = v19;
|
||||
}
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
operator delete(Memory.data.ptr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
v10 += v11 - v12 - 1;
|
||||
v11 = v12 + 1;
|
||||
}
|
||||
}
|
||||
if ( Dst.capacity >= 0x10 )
|
||||
operator delete(Dst.data.ptr);
|
||||
}
|
||||
if ( !string::find(a1, "ITMPV", 0i64, 5ui64) )
|
||||
{
|
||||
sub_1400215A0(a1, &Memory, 5i64, -1i64);
|
||||
v21 = sub_1400D29A0(&Memory, 0xAu);
|
||||
v22 = task_pv_db_get_pv(v21);
|
||||
if ( v22 )
|
||||
{
|
||||
v23 = v22->difficulty[2].begin;
|
||||
if ( v22->difficulty[2].end - v23 )
|
||||
{
|
||||
v51.data = 0ui64;
|
||||
v51.length = 0i64;
|
||||
sub_14023FDE0((vector_pv_item *)&v51, &v23->pv_item);
|
||||
v24 = v51.data;
|
||||
if ( v51.data.ptr != *(char **)&v51.data.data[8] )
|
||||
{
|
||||
v25 = (pv_item *__shifted(pv_item,8))(v51.data.ptr + 8);
|
||||
do
|
||||
{
|
||||
if ( ADJ(v25)->index > 0 )
|
||||
{
|
||||
if ( ADJ(v25)->name.capacity < 0x10 )
|
||||
v26 = (const char *)v25;
|
||||
else
|
||||
v26 = ADJ(v25)->name.data.ptr;
|
||||
v27 = obj_database_get_object_info(v26);
|
||||
if ( v27 != -1 )
|
||||
{
|
||||
a4 = HIWORD(*(unsigned int *)&v27);
|
||||
v28 = a2->head;
|
||||
v29 = sub_14023B3E0(a2, a2->head, a2->head->prev, &a4);
|
||||
v30 = a2->size;
|
||||
if ( v30 == 0xAAAAAAAAAAAAAA9i64 )
|
||||
ThrowException("list<T> too long");
|
||||
a2->size = v30 + 1;
|
||||
v28->prev = v29;
|
||||
v29->prev->next = v29;
|
||||
}
|
||||
}
|
||||
++v25;
|
||||
}
|
||||
while ( ADJ(v25) != *(pv_item *__shifted(pv_item,8) *)&v24.data[8] );
|
||||
}
|
||||
if ( v24.ptr )
|
||||
{
|
||||
if ( v24.ptr != *(char **)&v24.data[8] )
|
||||
{
|
||||
v31 = (pv_item *__shifted(pv_item,0x20))(v24.ptr + 32);
|
||||
do
|
||||
{
|
||||
if ( ADJ(v31)->name.capacity >= 0x10 )
|
||||
operator delete(ADJ(v31)->name.data.ptr);
|
||||
ADJ(v31)->name.capacity = 15i64;
|
||||
ADJ(v31)->name.length = 0i64;
|
||||
ADJ(v31++)->name.data.data[0] = 0;
|
||||
}
|
||||
while ( ADJ(v31) != *(pv_item *__shifted(pv_item,0x20) *)&v24.data[8] );
|
||||
}
|
||||
operator delete(v24.ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
operator delete(Memory.data.ptr);
|
||||
}
|
||||
if ( !string::find(a1, "EFFCHRPV", 0i64, 8ui64) )
|
||||
{
|
||||
if ( a1->capacity < 0x10 )
|
||||
v32 = (char *)a1;
|
||||
else
|
||||
v32 = a1->data.ptr;
|
||||
a4 = obj_database_get_object_set(v32);
|
||||
if ( a4 != -1 )
|
||||
{
|
||||
v33 = a2->head;
|
||||
v34 = list_int32_t_buy_node(a2, a2->head, a2->head->prev, &a4);
|
||||
v35 = a2->size;
|
||||
if ( v35 == 0xAAAAAAAAAAAAAA9i64 )
|
||||
ThrowException("list<T> too long");
|
||||
a2->size = v35 + 1;
|
||||
v33->prev = v34;
|
||||
v34->prev->next = v34;
|
||||
}
|
||||
}
|
||||
sub_14023EF10(a2);
|
||||
sub_14023F860(a2);
|
||||
v51.capacity = 15i64;
|
||||
v51.length = 0i64;
|
||||
v51.data.data[0] = 0;
|
||||
string_assign_char_str(&v51, null_string, 0i64);
|
||||
v36 = string::find(a1, "STGPV", 0i64, 5ui64);
|
||||
if ( v36 != -1 )
|
||||
{
|
||||
v37 = sub_1400215A0(a1, &Memory, v36, 8i64);
|
||||
if ( &v51 != v37 )
|
||||
{
|
||||
if ( v51.capacity >= 0x10 )
|
||||
operator delete(v51.data.ptr);
|
||||
v51.capacity = 15i64;
|
||||
v51.length = 0i64;
|
||||
v51.data.data[0] = 0;
|
||||
if ( v37->capacity >= 0x10 )
|
||||
{
|
||||
v51.data.ptr = v37->data.ptr;
|
||||
v37->data.ptr = 0i64;
|
||||
}
|
||||
else if ( v37->length != -1i64 )
|
||||
{
|
||||
memmove(&v51, v37, v37->length + 1);
|
||||
}
|
||||
v51.length = v37->length;
|
||||
v51.capacity = v37->capacity;
|
||||
v37->capacity = 15i64;
|
||||
v37->length = 0i64;
|
||||
v37->data.data[0] = 0;
|
||||
}
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
operator delete(Memory.data.ptr);
|
||||
}
|
||||
v38 = string::find(a1, "STGD2PV", 0i64, 7ui64);
|
||||
if ( v38 != -1 )
|
||||
{
|
||||
v39 = sub_1400215A0(a1, &Memory, v38, 10i64);
|
||||
if ( &v51 != v39 )
|
||||
{
|
||||
if ( v51.capacity >= 0x10 )
|
||||
operator delete(v51.data.ptr);
|
||||
v51.capacity = 15i64;
|
||||
v51.length = 0i64;
|
||||
v51.data.data[0] = 0;
|
||||
if ( v39->capacity >= 0x10 )
|
||||
{
|
||||
v51.data.ptr = v39->data.ptr;
|
||||
v39->data.ptr = 0i64;
|
||||
}
|
||||
else if ( v39->length != -1i64 )
|
||||
{
|
||||
memmove(&v51, v39, v39->length + 1);
|
||||
}
|
||||
v51.length = v39->length;
|
||||
v51.capacity = v39->capacity;
|
||||
v39->capacity = 15i64;
|
||||
v39->length = 0i64;
|
||||
v39->data.data[0] = 0;
|
||||
}
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
operator delete(Memory.data.ptr);
|
||||
}
|
||||
if ( v51.length )
|
||||
{
|
||||
v40 = (char *)&v51;
|
||||
if ( v51.capacity >= 0x10 )
|
||||
v40 = v51.data.ptr;
|
||||
a4 = obj_database_get_object_set(v40);
|
||||
if ( a4 != -1 )
|
||||
{
|
||||
v41 = a2->head->next;
|
||||
v42 = list_int32_t_buy_node(a2, v41, v41->prev, &a4);
|
||||
v43 = a2->size;
|
||||
if ( v43 == 0xAAAAAAAAAAAAAA9i64 )
|
||||
ThrowException("list<T> too long");
|
||||
a2->size = v43 + 1;
|
||||
v41->prev = v42;
|
||||
v42->prev->next = v42;
|
||||
}
|
||||
}
|
||||
sub_14000BF30(&Memory, &v51, "HRC");
|
||||
v44 = (char *)&Memory;
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
v44 = Memory.data.ptr;
|
||||
a4 = obj_database_get_object_set(v44);
|
||||
if ( a4 != -1 )
|
||||
{
|
||||
v45 = a2->head;
|
||||
v46 = list_int32_t_buy_node(a2, a2->head, a2->head->prev, &a4);
|
||||
v47 = a2->size;
|
||||
if ( 0xAAAAAAAAAAAAAA9i64 == v47 )
|
||||
ThrowException("list<T> too long");
|
||||
a2->size = v47 + 1;
|
||||
v45->prev = v46;
|
||||
v46->prev->next = v46;
|
||||
}
|
||||
if ( Memory.capacity >= 0x10 )
|
||||
operator delete(Memory.data.ptr);
|
||||
if ( v51.capacity >= 0x10 )
|
||||
operator delete(v51.data.ptr);
|
||||
if ( uids.begin )
|
||||
operator delete(uids.begin);
|
||||
}
|
||||
*/
|
||||
|
||||
void auth_3d_data_init() {
|
||||
auth_3d_data = new auth_3d_data_struct;
|
||||
}
|
||||
@@ -2128,24 +1792,6 @@ bool auth_3d_data_get_left_right_reverse(int32_t* id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool auth_3d_data_get_paused(int32_t* 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->paused;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool auth_3d_data_get_repeat(int32_t* 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->repeat;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
float_t auth_3d_data_get_play_control_begin(int32_t* id) {
|
||||
if (*id >= 0 && ((*id & 0x7FFF) < AUTH_3D_DATA_COUNT)) {
|
||||
auth_3d* auth = &auth_3d_data->data[*id & 0x7FFF];
|
||||
@@ -2164,20 +1810,96 @@ float_t auth_3d_data_get_play_control_size(int32_t* id) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
void auth_3d_data_load_auth_3d_db(auth_3d_database* auth_3d_db) {
|
||||
auth_3d_data->farcs.clear();
|
||||
auth_3d_data->farcs.resize(auth_3d_db->category.size());
|
||||
bool auth_3d_data_get_paused(int32_t* 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->paused;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t cat_index = 0;
|
||||
for (auth_3d_farc& i : auth_3d_data->farcs)
|
||||
i.name = auth_3d_db->category[cat_index++].name;
|
||||
bool auth_3d_data_get_repeat(int32_t* 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->repeat;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
auth_3d_data->uid_files.clear();
|
||||
auth_3d_data->uid_files.resize(auth_3d_db->uid.size());
|
||||
void auth_3d_data_get_obj_sets_from_category(std::string& name, std::vector<uint32_t>& obj_sets,
|
||||
auth_3d_database* auth_3d_db, object_database* obj_db) {
|
||||
obj_sets.clear();
|
||||
|
||||
size_t uid_index = 0;
|
||||
for (auth_3d_uid_file& i : auth_3d_data->uid_files)
|
||||
i.uid = (int32_t)(uid_index++);
|
||||
std::vector<int32_t> uid;
|
||||
auth_3d_db->get_category_uids(name.c_str(), uid);
|
||||
for (int32_t& i : uid) {
|
||||
const char* uid_name = auth_3d_data_get_uid_name(i, auth_3d_db);
|
||||
if (!uid_name)
|
||||
continue;
|
||||
|
||||
const char* s = strchr(uid_name, '_');
|
||||
if (!s)
|
||||
break;
|
||||
|
||||
uint32_t obj_set = obj_db->get_object_set_id(std::string(uid_name, s - uid_name).c_str());
|
||||
if (obj_set != -1)
|
||||
obj_sets.push_back(obj_set);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!name.find("ITMPV")) {
|
||||
int32_t pv_id = atoi(name.substr(5, 3).c_str());
|
||||
pv_db_pv* pv = task_pv_db_get_pv(pv_id);
|
||||
if (pv && pv->difficulty[PV_DIFFICULTY_HARD].size()) {
|
||||
pv_db_pv_difficulty& diff = pv->difficulty[PV_DIFFICULTY_HARD][0];
|
||||
|
||||
for (pv_db_pv_item& i : diff.pv_item) {
|
||||
if (i.index <= 0)
|
||||
continue;
|
||||
|
||||
object_info info = obj_db->get_object_info(i.name.c_str());
|
||||
if (info.not_null())
|
||||
obj_sets.push_back(info.set_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!name.find("EFFCHRPV")) {
|
||||
uint32_t obj_set = obj_db->get_object_set_id(name.c_str());
|
||||
if (obj_set != -1)
|
||||
obj_sets.push_back(obj_set);
|
||||
}
|
||||
|
||||
uint32_t prev_obj_set = -1;
|
||||
radix_sort_uint32_t(obj_sets.data(), obj_sets.size());
|
||||
for (std::vector<uint32_t>::iterator i = obj_sets.begin(); i != obj_sets.end();)
|
||||
if (*i != prev_obj_set)
|
||||
prev_obj_set = *i++;
|
||||
else
|
||||
i = obj_sets.erase(i);
|
||||
|
||||
std::string stgpv;
|
||||
size_t stgpv_offset = name.find("STGPV");
|
||||
if (stgpv_offset != -1)
|
||||
stgpv = name.substr(stgpv_offset, 8);
|
||||
|
||||
size_t stgd2pv_offset = name.find("STGD2PV");
|
||||
if (stgd2pv_offset != -1)
|
||||
stgpv = name.substr(stgd2pv_offset, 10);
|
||||
|
||||
if (stgpv.size()) {
|
||||
uint32_t obj_set = obj_db->get_object_set_id(stgpv.c_str());
|
||||
if (obj_set != -1)
|
||||
obj_sets.push_back(obj_set);
|
||||
}
|
||||
|
||||
stgpv += "HRC";
|
||||
|
||||
uint32_t obj_set = obj_db->get_object_set_id(stgpv.c_str());
|
||||
if (obj_set != -1)
|
||||
obj_sets.push_back(obj_set);
|
||||
}
|
||||
|
||||
int32_t auth_3d_data_get_uid(int32_t* id) {
|
||||
@@ -2199,6 +1921,22 @@ const char* auth_3d_data_get_uid_name(int32_t uid, auth_3d_database* auth_3d_db)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void auth_3d_data_load_auth_3d_db(auth_3d_database* auth_3d_db) {
|
||||
auth_3d_data->farcs.clear();
|
||||
auth_3d_data->farcs.resize(auth_3d_db->category.size());
|
||||
|
||||
size_t cat_index = 0;
|
||||
for (auth_3d_farc& i : auth_3d_data->farcs)
|
||||
i.name = auth_3d_db->category[cat_index++].name;
|
||||
|
||||
auth_3d_data->uid_files.clear();
|
||||
auth_3d_data->uid_files.resize(auth_3d_db->uid.size());
|
||||
|
||||
size_t uid_index = 0;
|
||||
for (auth_3d_uid_file& i : auth_3d_data->uid_files)
|
||||
i.uid = (int32_t)(uid_index++);
|
||||
}
|
||||
|
||||
void auth_3d_data_load_category(const char* category_name, const char* mdata_dir) {
|
||||
auth_3d_data_struct_load_category(auth_3d_data, category_name, mdata_dir);
|
||||
}
|
||||
@@ -2436,6 +2174,10 @@ void task_auth_3d_append_task() {
|
||||
app::TaskWork::AppendTask(&task_auth_3d, "AUTH_3D");
|
||||
}
|
||||
|
||||
bool task_auth_3d_check_task_ready() {
|
||||
return app::TaskWork::CheckTaskReady(&task_auth_3d);
|
||||
}
|
||||
|
||||
void task_auth_3d_free_task() {
|
||||
task_auth_3d.SetDest();
|
||||
}
|
||||
@@ -2931,7 +2673,7 @@ static void auth_3d_camera_root_ctrl(auth_3d_camera_root* cr,
|
||||
|| auth_3d_key_detect_fast_change(&cr->interest.translation.y, frame, 0.3f)
|
||||
|| auth_3d_key_detect_fast_change(&cr->interest.translation.z, frame, 0.3f)) {
|
||||
frame = (float_t)(int32_t)frame;
|
||||
camera_set_fast_change(cam, true);
|
||||
cam->set_fast_change(true);
|
||||
}
|
||||
else {
|
||||
float_t frame_prev = frame - get_delta_frame();
|
||||
@@ -2943,7 +2685,7 @@ static void auth_3d_camera_root_ctrl(auth_3d_camera_root* cr,
|
||||
|| auth_3d_key_detect_fast_change(&cr->interest.translation.x, frame_prev, 0.3f)
|
||||
|| auth_3d_key_detect_fast_change(&cr->interest.translation.y, frame_prev, 0.3f)
|
||||
|| auth_3d_key_detect_fast_change(&cr->interest.translation.z, frame_prev, 0.3f))
|
||||
camera_set_fast_change_hist0(cam, true);
|
||||
cam->set_fast_change_hist0(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3052,7 +2794,7 @@ static void auth_3d_dof_set(auth_3d_dof* d, render_context* rctx) {
|
||||
return;
|
||||
|
||||
vec3 view_point;
|
||||
camera_get_view_point(rctx->camera, &view_point);
|
||||
rctx->camera->get_view_point(view_point);
|
||||
|
||||
float_t focus;
|
||||
vec3_distance(d->model_transform.translation_value, view_point, focus);
|
||||
@@ -3132,20 +2874,18 @@ static void auth_3d_fog_restore_prev_value(auth_3d_fog* f, render_context* rctx)
|
||||
if (id < FOG_DEPTH || id > FOG_BUMP)
|
||||
return;
|
||||
|
||||
fog* data = &rctx->fog_data[id];
|
||||
if (f->flags_init & AUTH_3D_FOG_COLOR) {
|
||||
vec4 color = f->color_init;
|
||||
fog_set_color(data, &color);
|
||||
}
|
||||
fog* data = &rctx->fog[id];
|
||||
if (f->flags_init & AUTH_3D_FOG_COLOR)
|
||||
data->set_color(f->color_init);
|
||||
|
||||
if (f->flags_init & AUTH_3D_FOG_DENSITY)
|
||||
fog_set_density(data, f->density_value);
|
||||
data->set_density(f->density_value);
|
||||
|
||||
if (f->flags_init & AUTH_3D_FOG_END)
|
||||
fog_set_end(data, f->end_value);
|
||||
data->set_end(f->end_value);
|
||||
|
||||
if (f->flags_init & AUTH_3D_FOG_START)
|
||||
fog_set_start(data, f->start_value);
|
||||
data->set_start(f->start_value);
|
||||
}
|
||||
|
||||
static void auth_3d_fog_set(auth_3d_fog* f, render_context* rctx) {
|
||||
@@ -3153,44 +2893,43 @@ static void auth_3d_fog_set(auth_3d_fog* f, render_context* rctx) {
|
||||
if (id < FOG_DEPTH || id > FOG_BUMP)
|
||||
return;
|
||||
|
||||
fog* data = &rctx->fog_data[id];
|
||||
fog* data = &rctx->fog[id];
|
||||
if (f->flags & AUTH_3D_FOG_COLOR) {
|
||||
if (~f->flags_init & AUTH_3D_FOG_COLOR) {
|
||||
vec4 color_init;
|
||||
fog_get_color(data, &color_init);
|
||||
data->get_color(color_init);
|
||||
f->color_init = color_init;
|
||||
enum_or(f->flags_init, AUTH_3D_FOG_COLOR);
|
||||
}
|
||||
|
||||
vec4 color = f->color.value;
|
||||
fog_set_color(data, &color);
|
||||
data->set_color(f->color.value);
|
||||
}
|
||||
|
||||
if (f->flags & AUTH_3D_FOG_DENSITY) {
|
||||
if (~f->flags_init & AUTH_3D_FOG_DENSITY) {
|
||||
f->density_init = fog_get_density(data);
|
||||
f->density_init = data->get_density();
|
||||
enum_or(f->flags_init, AUTH_3D_FOG_DENSITY);
|
||||
}
|
||||
|
||||
fog_set_density(data, f->density_value);
|
||||
data->set_density(f->density_value);
|
||||
}
|
||||
|
||||
if (f->flags & AUTH_3D_FOG_END) {
|
||||
if (~f->flags_init & AUTH_3D_FOG_END) {
|
||||
f->end_init = fog_get_end(data);
|
||||
f->end_init = data->get_end();
|
||||
enum_or(f->flags_init, AUTH_3D_FOG_END);
|
||||
}
|
||||
|
||||
fog_set_end(data, f->end_value);
|
||||
data->set_end(f->end_value);
|
||||
}
|
||||
|
||||
if (f->flags & AUTH_3D_FOG_START) {
|
||||
if (~f->flags_init & AUTH_3D_FOG_START) {
|
||||
f->start_init = fog_get_start(data);
|
||||
f->start_init = data->get_start();
|
||||
enum_or(f->flags_init, AUTH_3D_FOG_START);
|
||||
}
|
||||
|
||||
fog_set_start(data, f->start_value);
|
||||
data->set_start(f->start_value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3296,34 +3035,28 @@ static void auth_3d_light_load(auth_3d* auth, auth_3d_light* l, auth_3d_light_fi
|
||||
}
|
||||
|
||||
static void auth_3d_light_restore_prev_value(auth_3d_light* l, render_context* rctx) {
|
||||
light_set* set_data = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_set* set_data = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
|
||||
light_id id = l->id;
|
||||
if (id < LIGHT_CHARA || id > LIGHT_PROJECTION)
|
||||
return;
|
||||
|
||||
light_data* data = &set_data->lights[id];
|
||||
if (l->flags_init & AUTH_3D_LIGHT_AMBIENT) {
|
||||
vec4 ambient_init = l->ambient_init;
|
||||
light_set_ambient(data, &ambient_init);
|
||||
}
|
||||
if (l->flags_init & AUTH_3D_LIGHT_AMBIENT)
|
||||
data->set_ambient(l->ambient_init);
|
||||
|
||||
if (l->flags_init & AUTH_3D_LIGHT_DIFFUSE) {
|
||||
vec4 diffuse_init = l->diffuse_init;
|
||||
light_set_diffuse(data, &diffuse_init);
|
||||
}
|
||||
if (l->flags_init & AUTH_3D_LIGHT_DIFFUSE)
|
||||
data->set_diffuse(l->diffuse_init);
|
||||
|
||||
if (l->flags_init & AUTH_3D_LIGHT_SPECULAR) {
|
||||
vec4 specular_init = l->specular_init;
|
||||
light_set_specular(data, &specular_init);
|
||||
}
|
||||
if (l->flags_init & AUTH_3D_LIGHT_SPECULAR)
|
||||
data->set_specular(l->specular_init);
|
||||
|
||||
if (l->flags_init & AUTH_3D_LIGHT_TONE_CURVE)
|
||||
light_set_tone_curve(data, &l->tone_curve_init);
|
||||
data->set_tone_curve(l->tone_curve_init);
|
||||
}
|
||||
|
||||
static void auth_3d_light_set(auth_3d_light* l, render_context* rctx) {
|
||||
light_set* set_data = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_set* set_data = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
|
||||
light_id id = l->id;
|
||||
if (id < LIGHT_CHARA || id > LIGHT_PROJECTION)
|
||||
@@ -3333,52 +3066,49 @@ static void auth_3d_light_set(auth_3d_light* l, render_context* rctx) {
|
||||
if (l->flags & AUTH_3D_LIGHT_AMBIENT) {
|
||||
if (~l->flags_init & AUTH_3D_LIGHT_AMBIENT) {
|
||||
vec4 ambient_init;
|
||||
light_get_ambient(data, &ambient_init);
|
||||
data->get_ambient(ambient_init);
|
||||
l->ambient_init = ambient_init;
|
||||
enum_or(l->flags_init, AUTH_3D_LIGHT_AMBIENT);
|
||||
}
|
||||
|
||||
vec4 ambient = l->ambient.value;
|
||||
light_set_ambient(data, &ambient);
|
||||
data->set_ambient(l->ambient.value);
|
||||
}
|
||||
|
||||
if (l->flags & AUTH_3D_LIGHT_DIFFUSE) {
|
||||
if (~l->flags_init & AUTH_3D_LIGHT_DIFFUSE) {
|
||||
vec4 diffuse_init;
|
||||
light_get_diffuse(data, &diffuse_init);
|
||||
data->get_diffuse(diffuse_init);
|
||||
l->diffuse_init = diffuse_init;
|
||||
enum_or(l->flags_init, AUTH_3D_LIGHT_DIFFUSE);
|
||||
}
|
||||
|
||||
vec4 diffuse = l->diffuse.value;
|
||||
light_set_diffuse(data, &diffuse);
|
||||
data->set_diffuse(l->diffuse.value);
|
||||
}
|
||||
|
||||
if (l->flags & AUTH_3D_LIGHT_POSITION)
|
||||
light_set_position(data, &l->position.translation_value);
|
||||
data->set_position(l->position.translation_value);
|
||||
|
||||
if (l->flags & AUTH_3D_LIGHT_SPECULAR) {
|
||||
if (~l->flags_init & AUTH_3D_LIGHT_SPECULAR) {
|
||||
vec4 specular_init;
|
||||
light_get_specular(data, &specular_init);
|
||||
data->get_specular(specular_init);
|
||||
l->specular_init = specular_init;
|
||||
enum_or(l->flags_init, AUTH_3D_LIGHT_SPECULAR);
|
||||
}
|
||||
|
||||
vec4 specular = l->specular.value;
|
||||
light_set_specular(data, &specular);
|
||||
data->set_specular(l->specular.value);
|
||||
}
|
||||
|
||||
if (l->flags & AUTH_3D_LIGHT_SPOT_DIRECTION)
|
||||
light_set_spot_direction(data, &l->spot_direction.translation_value);
|
||||
data->set_spot_direction(l->spot_direction.translation_value);
|
||||
|
||||
if (l->flags & AUTH_3D_LIGHT_TONE_CURVE) {
|
||||
if (~l->flags_init & AUTH_3D_LIGHT_TONE_CURVE) {
|
||||
light_get_tone_curve(data, &l->tone_curve_init);
|
||||
data->get_tone_curve(l->tone_curve_init);
|
||||
enum_or(l->flags_init, AUTH_3D_LIGHT_TONE_CURVE);
|
||||
}
|
||||
|
||||
light_set_tone_curve(data, (vec3*)&l->tone_curve.value);
|
||||
data->set_tone_curve(*(vec3*)&l->tone_curve.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4508,7 +4238,7 @@ static void auth_3d_data_struct_unload_category(
|
||||
|
||||
static void auth_3d_farc_free_data(auth_3d_farc* a3da_farc) {
|
||||
if (a3da_farc->state == 1)
|
||||
a3da_farc->file_handler.call_free_func_free_data();
|
||||
a3da_farc->file_handler.call_free_callback();
|
||||
else if (a3da_farc->state == 2) {
|
||||
delete a3da_farc->farc;
|
||||
a3da_farc->farc = 0;
|
||||
@@ -4719,53 +4449,10 @@ static void Auth3dTestTask__SetAuth3dId(Auth3dTestTask* tt) {
|
||||
|
||||
if (tt->field_394 == 1) {
|
||||
data_struct* data = rctx_ptr->data;
|
||||
auth_3d_database* auth_3d_db = &data->data_ft.auth_3d_db;
|
||||
object_database* obj_db = &data->data_ft.obj_db;
|
||||
|
||||
const char* cat_str = tt->category.c_str();
|
||||
size_t cat_len = tt->category.size();
|
||||
|
||||
if (!memcmp(cat_str, "ITMPV", 5)) {
|
||||
uint32_t set_id = obj_db->get_object_set_id(cat_str);
|
||||
if (set_id != (uint32_t)-1) {
|
||||
object_storage_load_set(data, obj_db, set_id);
|
||||
tt->obj_sets.push_back(set_id);
|
||||
}
|
||||
}
|
||||
|
||||
if (!memcmp(cat_str, "EFFCHRPV", 8)) {
|
||||
uint32_t set_id = obj_db->get_object_set_id(cat_str);
|
||||
if (set_id != (uint32_t)-1) {
|
||||
object_storage_load_set(data, obj_db, set_id);
|
||||
tt->obj_sets.push_back(set_id);
|
||||
}
|
||||
}
|
||||
|
||||
size_t off;
|
||||
std::string obj;
|
||||
if ((off = tt->category.find("STGNS", 0)) != -1)
|
||||
obj = std::string(&cat_str[off], 8);
|
||||
|
||||
if ((off = tt->category.find("STGD2NS", 0)) != -1)
|
||||
obj = std::string(&cat_str[off], 10);
|
||||
|
||||
if ((off = tt->category.find("STGPV", 0)) != -1)
|
||||
obj = std::string(&cat_str[off], 8);
|
||||
|
||||
if ((off = tt->category.find("STGD2PV", 0)) != -1)
|
||||
obj = std::string(&cat_str[off], 10);
|
||||
|
||||
uint32_t set_id = obj_db->get_object_set_id(obj.c_str());
|
||||
if (set_id != (uint32_t)-1) {
|
||||
object_storage_load_set(data, obj_db, set_id);
|
||||
tt->obj_sets.push_back(set_id);
|
||||
}
|
||||
|
||||
obj += "HRC";
|
||||
uint32_t hrc_set_id = obj_db->get_object_set_id(obj.c_str());
|
||||
if (hrc_set_id != (uint32_t)-1) {
|
||||
object_storage_load_set(data, obj_db, hrc_set_id);
|
||||
tt->obj_sets.push_back(hrc_set_id);
|
||||
}
|
||||
auth_3d_data_get_obj_sets_from_category(tt->category, tt->obj_sets, auth_3d_db, obj_db);
|
||||
|
||||
for (uint32_t& i : tt->obj_sets)
|
||||
object_storage_load_set(data, obj_db, i);
|
||||
|
||||
@@ -863,6 +863,8 @@ extern bool auth_3d_data_get_paused(int32_t* id);
|
||||
extern float_t auth_3d_data_get_play_control_begin(int32_t* id);
|
||||
extern float_t auth_3d_data_get_play_control_size(int32_t* id);
|
||||
extern bool auth_3d_data_get_repeat(int32_t* id);
|
||||
void auth_3d_data_get_obj_sets_from_category(std::string& name, std::vector<uint32_t>& obj_sets,
|
||||
auth_3d_database* auth_3d_db, object_database* obj_db);
|
||||
extern int32_t auth_3d_data_get_uid(int32_t* id);
|
||||
extern const char* auth_3d_data_get_uid_name(int32_t uid, auth_3d_database* auth_3d_db);
|
||||
extern void auth_3d_data_load_auth_3d_db(auth_3d_database* auth_3d_db);
|
||||
@@ -893,4 +895,5 @@ extern void auth_3d_data_unload_id(int32_t id, render_context* rctx);
|
||||
extern void auth_3d_data_free();
|
||||
|
||||
extern void task_auth_3d_append_task();
|
||||
extern bool task_auth_3d_check_task_ready();
|
||||
extern void task_auth_3d_free_task();
|
||||
|
||||
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "camera.h"
|
||||
|
||||
camera* camera_init() {
|
||||
camera* c = force_malloc_s(camera, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void camera_calculate_projection(camera* c);
|
||||
static void camera_calculate_view(camera* c);
|
||||
static void camera_calculate_forward(camera* c);
|
||||
|
||||
void camera_initialize(camera* c, double_t aspect, int32_t width, int32_t height) {
|
||||
c->aspect = aspect;
|
||||
c->fov = 0.0;
|
||||
c->forward = { 0.0f, 0.0f, -1.0f };
|
||||
c->rotation = { 0.0f, 0.0f, 0.0f };
|
||||
c->view_point = { 0.0, 0.0f, 0.0f };
|
||||
c->interest = { 0.0f, 0.0f, -1.0f };
|
||||
c->width = width;
|
||||
c->height = height;
|
||||
c->view = mat4_identity;
|
||||
c->inv_view = mat4_identity;
|
||||
c->projection = mat4_identity;
|
||||
c->inv_projection = mat4_identity;
|
||||
c->view_projection = mat4_identity;
|
||||
c->inv_view_projection = mat4_identity;
|
||||
c->view_projection_prev = mat4_identity;
|
||||
c->inv_view_projection_prev = mat4_identity;
|
||||
c->min_distance = 0.05;
|
||||
c->max_distance = 6000.0;
|
||||
c->changed_proj = true;
|
||||
c->changed_view = true;
|
||||
camera_set_pitch(c, 0.0);
|
||||
camera_set_yaw(c, 0.0);
|
||||
camera_set_roll(c, 0.0);
|
||||
camera_set_fov(c, 32.2673416137695);
|
||||
camera_calculate_forward(c);
|
||||
camera_set_position(c, &vec3_null);
|
||||
camera_update(c);
|
||||
}
|
||||
|
||||
double_t camera_get_min_distance(camera* c) {
|
||||
return c->min_distance;
|
||||
}
|
||||
|
||||
void camera_set_min_distance(camera* c, double_t value) {
|
||||
if (value != c->min_distance) {
|
||||
c->min_distance = value;
|
||||
c->changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_max_distance(camera* c) {
|
||||
return c->max_distance;
|
||||
}
|
||||
|
||||
void camera_set_max_distance(camera* c, double_t value) {
|
||||
if (value != c->max_distance) {
|
||||
c->max_distance = value;
|
||||
c->changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_aspect(camera* c) {
|
||||
return c->aspect;
|
||||
}
|
||||
|
||||
void camera_set_aspect(camera* c, double_t value) {
|
||||
if (value != c->aspect) {
|
||||
c->aspect = value;
|
||||
c->changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_fov(camera* c) {
|
||||
return c->fov;
|
||||
}
|
||||
|
||||
void camera_set_fov(camera* c, double_t value) {
|
||||
value = clamp(value, 1.0, 180.0);
|
||||
if (value != c->fov) {
|
||||
c->fov = value;
|
||||
c->fov_rad = value * DEG_TO_RAD;
|
||||
c->changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_pitch(camera* c) {
|
||||
return c->pitch;
|
||||
}
|
||||
|
||||
void camera_set_pitch(camera* c, double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
value = clamp(value, -89.5, 89.5);
|
||||
if (c->pitch != value) {
|
||||
c->pitch = value;
|
||||
c->changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_yaw(camera* c) {
|
||||
return c->yaw;
|
||||
}
|
||||
|
||||
void camera_set_yaw(camera* c, double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
if (c->yaw != value) {
|
||||
c->yaw = value;
|
||||
c->changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera_get_roll(camera* c) {
|
||||
return -c->roll;
|
||||
}
|
||||
|
||||
void camera_set_roll(camera* c, double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
if (c->roll != value) {
|
||||
c->roll = value;
|
||||
c->changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera_get_view_point(camera* c, vec3* value) {
|
||||
*value = c->view_point;
|
||||
}
|
||||
|
||||
void camera_set_view_point(camera* c, const vec3* value) {
|
||||
if (c->view_point.x != value->x
|
||||
|| c->view_point.y != value->y
|
||||
|| c->view_point.z != value->z) {
|
||||
c->view_point = *value;
|
||||
c->changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera_get_interest(camera* c, vec3* value) {
|
||||
*value = c->interest;
|
||||
}
|
||||
|
||||
void camera_set_interest(camera* c, const vec3* value) {
|
||||
if (c->interest.x != value->x
|
||||
|| c->interest.y != value->y
|
||||
|| c->interest.z != value->z) {
|
||||
c->interest = *value;
|
||||
c->changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera_get_res(camera* c, int32_t* width, int32_t* height) {
|
||||
*width = c->width;
|
||||
*height = c->height;
|
||||
}
|
||||
|
||||
void camera_set_res(camera* c, int32_t width, int32_t height) {
|
||||
if (c->width != width || c->height != height) {
|
||||
c->width = width;
|
||||
c->height = height;
|
||||
c->changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera_set_fast_change(camera* c, bool value) {
|
||||
c->fast_change = value;
|
||||
}
|
||||
|
||||
void camera_set_fast_change_hist0(camera* c, bool value) {
|
||||
c->fast_change_hist0 = value;
|
||||
}
|
||||
|
||||
void camera_reset(camera* c) {
|
||||
camera_set_pitch(c, 0.0);
|
||||
camera_set_yaw(c, 0.0);
|
||||
camera_set_roll(c, 0.0);
|
||||
camera_set_fov(c, 32.2673416137695);
|
||||
camera_calculate_forward(c);
|
||||
camera_set_position(c, (vec3*)&vec3_null);
|
||||
camera_update(c);
|
||||
}
|
||||
|
||||
void camera_move(camera* c, vec2d* move) {
|
||||
if (move->x != 0.0 || move->y != 0.0) {
|
||||
vec3 temp;
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
vec3 up = { 0.0f, 1.0f, 0.0f };
|
||||
vec3_cross(c->forward, up, temp);
|
||||
vec3_normalize(temp, temp);
|
||||
vec3_mult_scalar(temp, (float_t)move->y, temp);
|
||||
vec3_add(c->view_point, temp, view_point);
|
||||
vec3_mult_scalar(c->forward, (float_t)move->x, temp);
|
||||
vec3_add(view_point, temp, view_point);
|
||||
|
||||
vec3_add(view_point, c->forward, interest);
|
||||
camera_set_view_point(c, &view_point);
|
||||
camera_set_interest(c, &interest);
|
||||
}
|
||||
}
|
||||
|
||||
void camera_rotate(camera* c, vec2d* rotate) {
|
||||
if (rotate->x != 0.0)
|
||||
camera_set_yaw(c, camera_get_yaw(c) + rotate->x);
|
||||
|
||||
if (rotate->y != 0.0)
|
||||
camera_set_pitch(c, camera_get_pitch(c) + rotate->y);
|
||||
|
||||
if (rotate->x != 0.0 || rotate->y != 0.0) {
|
||||
camera_calculate_forward(c);
|
||||
|
||||
vec3 interest;
|
||||
vec3_add(c->view_point, c->forward, interest);
|
||||
camera_set_interest(c, &interest);
|
||||
}
|
||||
}
|
||||
|
||||
void camera_roll(camera* c, double_t roll) {
|
||||
if (roll != 0.0f)
|
||||
camera_set_roll(c, -camera_get_roll(c) - roll);
|
||||
}
|
||||
|
||||
void camera_set(camera* c, const vec3* view_point, const vec3* interest,
|
||||
const vec3* trans, const vec3* rot, const vec3* scale, double_t roll, double_t fov) {
|
||||
vec3 _vp;
|
||||
vec3 _int;
|
||||
double_t _roll;
|
||||
double_t _fov;
|
||||
|
||||
_vp = *view_point;
|
||||
_int = *interest;
|
||||
_roll = roll;
|
||||
_fov = fov;
|
||||
|
||||
mat4 cam;
|
||||
mat4_translate(trans->x, trans->y, trans->z, &cam);
|
||||
mat4_rotate_mult(&cam, rot->x, rot->y, rot->z, &cam);
|
||||
mat4_scale_rot(&cam, scale->x, scale->y, scale->z, &cam);
|
||||
mat4_mult_vec3_trans(&cam, &_vp, &_vp);
|
||||
mat4_mult_vec3_trans(&cam, &_int, &_int);
|
||||
|
||||
camera_set_view_point(c, &_vp);
|
||||
camera_set_interest(c, &_int);
|
||||
camera_set_roll(c, _roll);
|
||||
camera_set_fov(c, _fov);
|
||||
}
|
||||
|
||||
void camera_set_position(camera* c, const vec3* pos) {
|
||||
vec3 interest;
|
||||
vec3_add(*pos, c->forward, interest);
|
||||
camera_set_view_point(c, pos);
|
||||
camera_set_interest(c, &interest);
|
||||
}
|
||||
|
||||
void camera_update(camera* c) {
|
||||
if (c->changed_proj)
|
||||
camera_calculate_projection(c);
|
||||
|
||||
if (c->changed_view)
|
||||
camera_calculate_view(c);
|
||||
|
||||
if (c->changed_proj || c->changed_view) {
|
||||
mat4_mult(&c->view, &c->projection, &c->view_projection);
|
||||
mat4_inverse(&c->view_projection, &c->inv_view_projection);
|
||||
}
|
||||
|
||||
c->changed_proj = false;
|
||||
c->changed_view = false;
|
||||
|
||||
c->fast_change_hist1 = c->fast_change_hist0;
|
||||
c->fast_change_hist0 = c->fast_change;
|
||||
c->fast_change = false;
|
||||
}
|
||||
|
||||
void camera_dispose(camera* c) {
|
||||
free(c);
|
||||
}
|
||||
|
||||
static void camera_calculate_forward(camera* c) {
|
||||
c->forward.x = (float_t)(cos(c->pitch * DEG_TO_RAD) * sin(c->yaw * DEG_TO_RAD));
|
||||
c->forward.y = (float_t)sin(c->pitch * DEG_TO_RAD);
|
||||
c->forward.z = (float_t)(cos(c->pitch * DEG_TO_RAD) * -cos(c->yaw * DEG_TO_RAD));
|
||||
}
|
||||
|
||||
static void camera_calculate_projection(camera* c) {
|
||||
mat4_persp(c->fov_rad, c->aspect, c->min_distance, c->max_distance, &c->projection);
|
||||
mat4_inverse(&c->projection, &c->inv_projection);
|
||||
|
||||
float_t fov_correct_height = (float_t)(((double_t)c->height * 0.5) / tan(c->fov_rad * 0.5));
|
||||
float_t height = (float_t)c->height * 0.5f;
|
||||
float_t width = (float_t)c->height * (float_t)c->aspect * 0.5f;
|
||||
|
||||
c->field_1E4.x = fov_correct_height;
|
||||
c->field_1E4.y = 0.0f;
|
||||
c->field_1E4.z = -width;
|
||||
vec3_normalize(c->field_1E4, c->field_1E4);
|
||||
c->field_1F0.x = -fov_correct_height;
|
||||
c->field_1F0.y = 0.0f;
|
||||
c->field_1F0.z = -width;
|
||||
vec3_normalize(c->field_1F0, c->field_1F0);
|
||||
c->field_1FC.x = 0.0f;
|
||||
c->field_1FC.y = fov_correct_height;
|
||||
c->field_1FC.z = -height;
|
||||
vec3_normalize(c->field_1FC, c->field_1FC);
|
||||
c->field_208.x = 0.0f;
|
||||
c->field_208.y = -fov_correct_height;
|
||||
c->field_208.z = -height;
|
||||
vec3_normalize(c->field_208, c->field_208);
|
||||
}
|
||||
|
||||
static void camera_calculate_view(camera* c) {
|
||||
vec3 dist;
|
||||
vec3_sub(c->view_point, c->interest, dist);
|
||||
|
||||
vec3 rotation;
|
||||
rotation.x = atan2f(-dist.y, sqrtf(dist.x * dist.x + dist.z * dist.z));
|
||||
rotation.y = atan2f(dist.x, dist.z);
|
||||
rotation.z = (float_t)(c->roll * DEG_TO_RAD);
|
||||
|
||||
c->rotation = rotation;
|
||||
vec3_negate(rotation, rotation);
|
||||
|
||||
vec3 view_point;
|
||||
vec3_negate(c->view_point, view_point);
|
||||
|
||||
c->view = mat4_identity;
|
||||
mat4_rot_z(&c->view, rotation.z, &c->view);
|
||||
mat4_rot_x(&c->view, rotation.x, &c->view);
|
||||
mat4_rot_y(&c->view, rotation.y, &c->view);
|
||||
mat4_translate_mult(&c->view, view_point.x, view_point.y, view_point.z, &c->view);
|
||||
|
||||
mat4_inverse(&c->view, &c->inv_view);
|
||||
mat3_from_mat4(&c->view, &c->view_mat3);
|
||||
mat3_inverse(&c->view_mat3, &c->inv_view_mat3);
|
||||
mat4_from_mat3(&c->view_mat3, &c->view_rot);
|
||||
mat4_from_mat3(&c->inv_view_mat3, &c->inv_view_rot);
|
||||
|
||||
if (fabs(c->rotation.x * RAD_TO_DEG - c->pitch) > 0.01
|
||||
|| fabs(-c->rotation.y * RAD_TO_DEG - c->yaw) > 0.01) {
|
||||
c->pitch = c->rotation.x * RAD_TO_DEG;
|
||||
c->yaw = -c->rotation.y * RAD_TO_DEG;
|
||||
camera_calculate_forward(c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "camera.hpp"
|
||||
|
||||
static void camera_calculate_projection(camera* c);
|
||||
static void camera_calculate_view(camera* c);
|
||||
static void camera_calculate_forward(camera* c);
|
||||
|
||||
camera::camera() : view(), inv_view(), projection(), inv_projection(), view_projection(),
|
||||
inv_view_projection(), view_projection_prev(), inv_view_projection_prev(), view_mat3(), inv_view_mat3(),
|
||||
view_rot(), inv_view_rot(), forward(), rotation(), view_point(), interest(), width(), height(), field_1E4(),
|
||||
field_1F0(), field_1FC(), field_208(), yaw(), pitch(), roll(), aspect(), fov(), fov_rad(),max_distance(),
|
||||
min_distance(), changed_view(), changed_proj(), fast_change(), fast_change_hist0(), fast_change_hist1() {
|
||||
|
||||
}
|
||||
|
||||
camera::~camera() {
|
||||
|
||||
}
|
||||
|
||||
void camera::initialize(double_t aspect, int32_t width, int32_t height) {
|
||||
this->aspect = aspect;
|
||||
fov = 0.0;
|
||||
forward = { 0.0f, 0.0f, -1.0f };
|
||||
rotation = { 0.0f, 0.0f, 0.0f };
|
||||
view_point = { 0.0, 0.0f, 0.0f };
|
||||
interest = { 0.0f, 0.0f, -1.0f };
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
view = mat4_identity;
|
||||
inv_view = mat4_identity;
|
||||
projection = mat4_identity;
|
||||
inv_projection = mat4_identity;
|
||||
view_projection = mat4_identity;
|
||||
inv_view_projection = mat4_identity;
|
||||
view_projection_prev = mat4_identity;
|
||||
inv_view_projection_prev = mat4_identity;
|
||||
min_distance = 0.05;
|
||||
max_distance = 6000.0;
|
||||
changed_proj = true;
|
||||
changed_view = true;
|
||||
set_pitch(0.0);
|
||||
set_yaw(0.0);
|
||||
set_roll(0.0);
|
||||
set_fov(32.2673416137695);
|
||||
camera_calculate_forward(this);
|
||||
set_position(vec3_null);
|
||||
update();
|
||||
}
|
||||
|
||||
double_t camera::get_min_distance() {
|
||||
return min_distance;
|
||||
}
|
||||
|
||||
void camera::set_min_distance(double_t value) {
|
||||
if (value != min_distance) {
|
||||
min_distance = value;
|
||||
changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_max_distance() {
|
||||
return max_distance;
|
||||
}
|
||||
|
||||
void camera::set_max_distance(double_t value) {
|
||||
if (value != max_distance) {
|
||||
max_distance = value;
|
||||
changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_aspect() {
|
||||
return aspect;
|
||||
}
|
||||
|
||||
void camera::set_aspect(double_t value) {
|
||||
if (value != aspect) {
|
||||
aspect = value;
|
||||
changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_fov() {
|
||||
return fov;
|
||||
}
|
||||
|
||||
void camera::set_fov(double_t value) {
|
||||
value = clamp(value, 1.0, 180.0);
|
||||
if (value != fov) {
|
||||
fov = value;
|
||||
fov_rad = value * DEG_TO_RAD;
|
||||
changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_pitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
void camera::set_pitch(double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
value = clamp(value, -89.5, 89.5);
|
||||
if (pitch != value) {
|
||||
pitch = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_yaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
void camera::set_yaw(double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
if (yaw != value) {
|
||||
yaw = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
double_t camera::get_roll() {
|
||||
return roll;
|
||||
}
|
||||
|
||||
void camera::set_roll(double_t value) {
|
||||
value = fmod(value, 360.0);
|
||||
if (roll != value) {
|
||||
roll = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::get_view_point(vec3& value) {
|
||||
value = view_point;
|
||||
}
|
||||
|
||||
void camera::set_view_point(const vec3& value) {
|
||||
if (memcmp(&value, &view_point, sizeof(vec3))) {
|
||||
view_point = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::set_view_point(const vec3&& value) {
|
||||
if (memcmp(&value, &view_point, sizeof(vec3))) {
|
||||
view_point = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::get_interest(vec3& value) {
|
||||
value = interest;
|
||||
}
|
||||
|
||||
void camera::set_interest(const vec3& value) {
|
||||
if (memcmp(&value, &interest, sizeof(vec3))) {
|
||||
interest = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::set_interest(const vec3&& value) {
|
||||
if (memcmp(&value, &interest, sizeof(vec3))) {
|
||||
interest = value;
|
||||
changed_view = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::get_res(int32_t& width, int32_t& height) {
|
||||
width = this->width;
|
||||
height = this->height;
|
||||
}
|
||||
|
||||
void camera::set_res(int32_t width, int32_t height) {
|
||||
if (this->width != width || this->height != height) {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
changed_proj = true;
|
||||
}
|
||||
}
|
||||
|
||||
void camera::set_fast_change(bool value) {
|
||||
fast_change = value;
|
||||
}
|
||||
|
||||
void camera::set_fast_change_hist0(bool value) {
|
||||
fast_change_hist0 = value;
|
||||
}
|
||||
|
||||
void camera::set_fast_change_hist1(bool value) {
|
||||
fast_change_hist1 = value;
|
||||
}
|
||||
|
||||
void camera::reset() {
|
||||
set_pitch(0.0);
|
||||
set_yaw(0.0);
|
||||
set_roll(0.0);
|
||||
set_fov(32.2673416137695);
|
||||
camera_calculate_forward(this);
|
||||
set_position(vec3_null);
|
||||
update();
|
||||
}
|
||||
|
||||
void camera::move(vec2d& move) {
|
||||
if (memcmp(&move, &vec2d_null, sizeof(vec2d))) {
|
||||
vec3 temp;
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
vec3 up = { 0.0f, 1.0f, 0.0f };
|
||||
vec3_cross(forward, up, temp);
|
||||
vec3_normalize(temp, temp);
|
||||
vec3_mult_scalar(temp, (float_t)move.y, temp);
|
||||
vec3_add(this->view_point, temp, view_point);
|
||||
vec3_mult_scalar(forward, (float_t)move.x, temp);
|
||||
vec3_add(view_point, temp, view_point);
|
||||
|
||||
vec3_add(view_point, forward, interest);
|
||||
set_view_point(view_point);
|
||||
set_interest(interest);
|
||||
}
|
||||
}
|
||||
|
||||
void camera::move(vec2d&& move) {
|
||||
this->move(*(vec2d*)&move);
|
||||
}
|
||||
|
||||
void camera::rotate(vec2d& rotate) {
|
||||
if (rotate.x != 0.0)
|
||||
set_yaw(get_yaw() + rotate.x);
|
||||
|
||||
if (rotate.y != 0.0)
|
||||
set_pitch(get_pitch() + rotate.y);
|
||||
|
||||
if (memcmp(&rotate, &vec2d_null, sizeof(vec2d))) {
|
||||
camera_calculate_forward(this);
|
||||
|
||||
vec3 interest;
|
||||
vec3_add(view_point, forward, interest);
|
||||
set_interest(interest);
|
||||
}
|
||||
}
|
||||
|
||||
void camera::rotate(vec2d&& rotate) {
|
||||
this->rotate(*(vec2d*)&rotate);
|
||||
}
|
||||
|
||||
void camera::set(const vec3& view_point, const vec3& interest,
|
||||
const vec3& trans, const vec3& rot, const vec3& scale, double_t roll, double_t fov) {
|
||||
vec3 _vp;
|
||||
vec3 _int;
|
||||
double_t _roll;
|
||||
double_t _fov;
|
||||
|
||||
_vp = view_point;
|
||||
_int = interest;
|
||||
_roll = roll;
|
||||
_fov = fov;
|
||||
|
||||
mat4 cam;
|
||||
mat4_translate(trans.x, trans.y, trans.z, &cam);
|
||||
mat4_rotate_mult(&cam, rot.x, rot.y, rot.z, &cam);
|
||||
mat4_scale_rot(&cam, scale.x, scale.y, scale.z, &cam);
|
||||
mat4_mult_vec3_trans(&cam, &_vp, &_vp);
|
||||
mat4_mult_vec3_trans(&cam, &_int, &_int);
|
||||
|
||||
set_view_point(_vp);
|
||||
set_interest(_int);
|
||||
set_roll(_roll);
|
||||
set_fov(_fov);
|
||||
}
|
||||
|
||||
void camera::set(const vec3&& view_point, const vec3&& interest,
|
||||
const vec3&& trans, const vec3&& rot, const vec3&& scale, double_t roll, double_t fov) {
|
||||
set(*(vec3*)&view_point, *(vec3*)&interest, *(vec3*)&trans, *(vec3*)&rot, *(vec3*)&scale, roll, fov);
|
||||
}
|
||||
|
||||
void camera::set_position(const vec3& pos) {
|
||||
vec3 interest;
|
||||
vec3_add(pos, forward, interest);
|
||||
set_view_point(pos);
|
||||
set_interest(interest);
|
||||
}
|
||||
|
||||
void camera::set_position(const vec3&& pos) {
|
||||
vec3 interest;
|
||||
vec3_add(pos, forward, interest);
|
||||
set_view_point(pos);
|
||||
set_interest(interest);
|
||||
}
|
||||
|
||||
void camera::update() {
|
||||
if (changed_proj)
|
||||
camera_calculate_projection(this);
|
||||
|
||||
if (changed_view)
|
||||
camera_calculate_view(this);
|
||||
|
||||
if (changed_proj || changed_view) {
|
||||
mat4_mult(&view, &projection, &view_projection);
|
||||
mat4_inverse(&view_projection, &inv_view_projection);
|
||||
}
|
||||
|
||||
changed_proj = false;
|
||||
changed_view = false;
|
||||
|
||||
fast_change_hist1 = fast_change_hist0;
|
||||
fast_change_hist0 = fast_change;
|
||||
fast_change = false;
|
||||
}
|
||||
|
||||
static void camera_calculate_forward(camera* c) {
|
||||
c->forward.x = (float_t)(cos(c->pitch * DEG_TO_RAD) * sin(c->yaw * DEG_TO_RAD));
|
||||
c->forward.y = (float_t)sin(c->pitch * DEG_TO_RAD);
|
||||
c->forward.z = (float_t)(cos(c->pitch * DEG_TO_RAD) * -cos(c->yaw * DEG_TO_RAD));
|
||||
}
|
||||
|
||||
static void camera_calculate_projection(camera* c) {
|
||||
mat4_persp(c->fov_rad, c->aspect, c->min_distance, c->max_distance, &c->projection);
|
||||
mat4_inverse(&c->projection, &c->inv_projection);
|
||||
|
||||
float_t fov_correct_height = (float_t)(((double_t)c->height * 0.5) / tan(c->fov_rad * 0.5));
|
||||
float_t height = (float_t)c->height * 0.5f;
|
||||
float_t width = (float_t)c->height * (float_t)c->aspect * 0.5f;
|
||||
|
||||
c->field_1E4.x = fov_correct_height;
|
||||
c->field_1E4.y = 0.0f;
|
||||
c->field_1E4.z = -width;
|
||||
vec3_normalize(c->field_1E4, c->field_1E4);
|
||||
c->field_1F0.x = -fov_correct_height;
|
||||
c->field_1F0.y = 0.0f;
|
||||
c->field_1F0.z = -width;
|
||||
vec3_normalize(c->field_1F0, c->field_1F0);
|
||||
c->field_1FC.x = 0.0f;
|
||||
c->field_1FC.y = fov_correct_height;
|
||||
c->field_1FC.z = -height;
|
||||
vec3_normalize(c->field_1FC, c->field_1FC);
|
||||
c->field_208.x = 0.0f;
|
||||
c->field_208.y = -fov_correct_height;
|
||||
c->field_208.z = -height;
|
||||
vec3_normalize(c->field_208, c->field_208);
|
||||
}
|
||||
|
||||
static void camera_calculate_view(camera* c) {
|
||||
vec3 dist;
|
||||
vec3_sub(c->view_point, c->interest, dist);
|
||||
|
||||
vec3 rotation;
|
||||
rotation.x = atan2f(-dist.y, sqrtf(dist.x * dist.x + dist.z * dist.z));
|
||||
rotation.y = atan2f(dist.x, dist.z);
|
||||
rotation.z = (float_t)(c->roll * DEG_TO_RAD);
|
||||
|
||||
c->rotation = rotation;
|
||||
vec3_negate(rotation, rotation);
|
||||
|
||||
vec3 view_point;
|
||||
vec3_negate(c->view_point, view_point);
|
||||
|
||||
c->view = mat4_identity;
|
||||
mat4_rot_z(&c->view, rotation.z, &c->view);
|
||||
mat4_rot_x(&c->view, rotation.x, &c->view);
|
||||
mat4_rot_y(&c->view, rotation.y, &c->view);
|
||||
mat4_translate_mult(&c->view, view_point.x, view_point.y, view_point.z, &c->view);
|
||||
|
||||
mat4_inverse(&c->view, &c->inv_view);
|
||||
mat3_from_mat4(&c->view, &c->view_mat3);
|
||||
mat3_inverse(&c->view_mat3, &c->inv_view_mat3);
|
||||
mat4_from_mat3(&c->view_mat3, &c->view_rot);
|
||||
mat4_from_mat3(&c->inv_view_mat3, &c->inv_view_rot);
|
||||
|
||||
if (fabs(c->rotation.x * RAD_TO_DEG - c->pitch) > 0.01
|
||||
|| fabs(-c->rotation.y * RAD_TO_DEG - c->yaw) > 0.01) {
|
||||
c->pitch = c->rotation.x * RAD_TO_DEG;
|
||||
c->yaw = -c->rotation.y * RAD_TO_DEG;
|
||||
camera_calculate_forward(c);
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct camera {
|
||||
mat4 view;
|
||||
mat4 inv_view;
|
||||
mat4 projection;
|
||||
mat4 inv_projection;
|
||||
mat4 view_projection;
|
||||
mat4 inv_view_projection;
|
||||
mat4 view_projection_prev;
|
||||
mat4 inv_view_projection_prev;
|
||||
mat3 view_mat3;
|
||||
mat3 inv_view_mat3;
|
||||
mat4 view_rot;
|
||||
mat4 inv_view_rot;
|
||||
vec3 forward;
|
||||
vec3 rotation;
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
vec3 field_1E4;
|
||||
vec3 field_1F0;
|
||||
vec3 field_1FC;
|
||||
vec3 field_208;
|
||||
double_t yaw;
|
||||
double_t pitch;
|
||||
double_t roll;
|
||||
double_t aspect;
|
||||
double_t fov;
|
||||
double_t fov_rad;
|
||||
double_t max_distance;
|
||||
double_t min_distance;
|
||||
bool changed_view;
|
||||
bool changed_proj;
|
||||
bool fast_change;
|
||||
bool fast_change_hist0;
|
||||
bool fast_change_hist1;
|
||||
};
|
||||
|
||||
extern camera* camera_init();
|
||||
extern void camera_initialize(camera* c, double_t aspect, int32_t width, int32_t height);
|
||||
extern double_t camera_get_min_distance(camera* c);
|
||||
extern void camera_set_min_distance(camera* c, double_t value);
|
||||
extern double_t camera_get_max_distance(camera* c);
|
||||
extern void camera_set_max_distance(camera* c, double_t value);
|
||||
extern double_t camera_get_aspect(camera* c);
|
||||
extern void camera_set_aspect(camera* c, double_t value);
|
||||
extern double_t camera_get_fov(camera* c);
|
||||
extern void camera_set_fov(camera* c, double_t value);
|
||||
extern double_t camera_get_pitch(camera* c);
|
||||
extern void camera_set_pitch(camera* c, double_t value);
|
||||
extern double_t camera_get_yaw(camera* c);
|
||||
extern void camera_set_yaw(camera* c, double_t value);
|
||||
extern double_t camera_get_roll(camera* c);
|
||||
extern void camera_set_roll(camera* c, double_t value);
|
||||
extern void camera_get_view_point(camera* c, vec3* value);
|
||||
extern void camera_set_view_point(camera* c, const vec3* value);
|
||||
extern void camera_get_interest(camera* c, vec3* value);
|
||||
extern void camera_set_interest(camera* c, const vec3* value);
|
||||
extern void camera_get_res(camera* c, int32_t* width, int32_t* height);
|
||||
extern void camera_set_res(camera* c, int32_t width, int32_t height);
|
||||
extern void camera_set_fast_change(camera* c, bool value);
|
||||
extern void camera_set_fast_change_hist0(camera* c, bool value);
|
||||
extern void camera_reset(camera* c);
|
||||
extern void camera_move(camera* c, vec2d* move);
|
||||
extern void camera_rotate(camera* c, vec2d* rotate);
|
||||
extern void camera_roll(camera* c, double_t roll);
|
||||
extern void camera_set(camera* c, const vec3* view_point, const vec3* interest,
|
||||
const vec3* trans, const vec3* rot, const vec3* scale, double_t roll, double_t fov);
|
||||
extern void camera_set_position(camera* c, const vec3* pos);
|
||||
extern void camera_update(camera* c);
|
||||
extern void camera_dispose(camera* c);
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
|
||||
struct camera {
|
||||
mat4 view;
|
||||
mat4 inv_view;
|
||||
mat4 projection;
|
||||
mat4 inv_projection;
|
||||
mat4 view_projection;
|
||||
mat4 inv_view_projection;
|
||||
mat4 view_projection_prev;
|
||||
mat4 inv_view_projection_prev;
|
||||
mat3 view_mat3;
|
||||
mat3 inv_view_mat3;
|
||||
mat4 view_rot;
|
||||
mat4 inv_view_rot;
|
||||
vec3 forward;
|
||||
vec3 rotation;
|
||||
vec3 view_point;
|
||||
vec3 interest;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
vec3 field_1E4;
|
||||
vec3 field_1F0;
|
||||
vec3 field_1FC;
|
||||
vec3 field_208;
|
||||
double_t yaw;
|
||||
double_t pitch;
|
||||
double_t roll;
|
||||
double_t aspect;
|
||||
double_t fov;
|
||||
double_t fov_rad;
|
||||
double_t max_distance;
|
||||
double_t min_distance;
|
||||
bool changed_view;
|
||||
bool changed_proj;
|
||||
bool fast_change;
|
||||
bool fast_change_hist0;
|
||||
bool fast_change_hist1;
|
||||
|
||||
camera();
|
||||
virtual ~camera();
|
||||
|
||||
void initialize(double_t aspect, int32_t width, int32_t height);
|
||||
double_t get_min_distance();
|
||||
void set_min_distance(double_t value);
|
||||
double_t get_max_distance();
|
||||
void set_max_distance(double_t value);
|
||||
double_t get_aspect();
|
||||
void set_aspect(double_t value);
|
||||
double_t get_fov();
|
||||
void set_fov(double_t value);
|
||||
double_t get_pitch();
|
||||
void set_pitch(double_t value);
|
||||
double_t get_yaw();
|
||||
void set_yaw(double_t value);
|
||||
double_t get_roll();
|
||||
void set_roll(double_t value);
|
||||
void get_view_point(vec3& value);
|
||||
void set_view_point(const vec3& value);
|
||||
void set_view_point(const vec3&& value);
|
||||
void get_interest(vec3& value);
|
||||
void set_interest(const vec3& value);
|
||||
void set_interest(const vec3&& value);
|
||||
void get_res(int32_t& width, int32_t& height);
|
||||
void set_res(int32_t width, int32_t height);
|
||||
void set_fast_change(bool value);
|
||||
void set_fast_change_hist0(bool value);
|
||||
void set_fast_change_hist1(bool value);
|
||||
void reset();
|
||||
void move(vec2d& move);
|
||||
void move(vec2d&& move);
|
||||
void rotate(vec2d& rotate);
|
||||
void rotate(vec2d&& rotate);
|
||||
void set(const vec3& view_point, const vec3& interest,
|
||||
const vec3& trans, const vec3& rot, const vec3& scale, double_t roll, double_t fov);
|
||||
void set(const vec3&& view_point, const vec3&& interest,
|
||||
const vec3&& trans, const vec3&& rot, const vec3&& scale, double_t roll, double_t fov);
|
||||
void set_position(const vec3& pos);
|
||||
void set_position(const vec3&& pos);
|
||||
void update();
|
||||
};
|
||||
@@ -3,10 +3,10 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "draw_object.h"
|
||||
#include "draw_object.hpp"
|
||||
#include "light_param/light.hpp"
|
||||
#include "shader_ft.h"
|
||||
#include "static_var.h"
|
||||
#include "shader_ft.hpp"
|
||||
#include "static_var.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
#define enable_vertex_attrib_array(index) \
|
||||
@@ -44,14 +44,10 @@ void draw_object_draw(render_context* rctx, draw_object* draw, mat4* model,
|
||||
shaders_ft.state_matrix_set_program(7, mat);
|
||||
}
|
||||
|
||||
mat4 mat;
|
||||
for (int32_t i = 0; i < draw->mat_count; i++, mats++) {
|
||||
union {
|
||||
mat4 m;
|
||||
vec4 v[4];
|
||||
} mat;
|
||||
|
||||
mat4_transpose(mats, &mat.m);
|
||||
shaders_ft.buffer_set((size_t)i * 3, 3, mat.v);
|
||||
mat4_transpose(mats, &mat);
|
||||
shaders_ft.buffer_set((size_t)i * 3, 3, &mat.row0);
|
||||
}
|
||||
|
||||
shaders_ft.state_matrix_set_modelview(0, rctx->view_mat, true);
|
||||
@@ -416,11 +412,11 @@ static bool draw_object_blend_set(render_context* rctx,
|
||||
GLenum src_blend_factor = blend_factor_table[attrib.src_blend_factor];
|
||||
GLenum dst_blend_factor = blend_factor_table[attrib.dst_blend_factor];
|
||||
if (draw->chara_color) {
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
light_data* chara_color = &set->lights[LIGHT_CHARA_COLOR];
|
||||
vec4 specular;
|
||||
light_get_specular(chara_color, &specular);
|
||||
if (specular.w >= 4.0f && light_get_type(chara_color) == LIGHT_PARALLEL
|
||||
chara_color->get_specular(specular);
|
||||
if (specular.w >= 4.0f && chara_color->get_type() == LIGHT_PARALLEL
|
||||
&& (src_blend_factor != GL_ONE || dst_blend_factor)) {
|
||||
int32_t shader_index = rctx->draw_state.shader_index;
|
||||
if (rctx->draw_state.shader_index == -1) {
|
||||
@@ -453,11 +449,11 @@ static bool draw_object_blend_set(render_context* rctx,
|
||||
static void draw_object_chara_color_fog_set(render_context* rctx, draw_object* draw, bool disable_fog) {
|
||||
uniform_value[U_CHARA_COLOR] = 0;
|
||||
if (draw->chara_color) {
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
light_data* chara_color = &set->lights[LIGHT_CHARA_COLOR];
|
||||
vec4 specular;
|
||||
light_get_specular(chara_color, &specular);
|
||||
if (specular.w > 0.0f && light_get_type(chara_color) == LIGHT_PARALLEL)
|
||||
chara_color->get_specular(specular);
|
||||
if (specular.w > 0.0f && chara_color->get_type() == LIGHT_PARALLEL)
|
||||
uniform_value[U_CHARA_COLOR] = 1;
|
||||
}
|
||||
|
||||
@@ -884,7 +880,7 @@ static void draw_object_vertex_attrib_reset_default(draw_object* draw) {
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -909,7 +905,7 @@ static void draw_object_vertex_attrib_reset_default_compressed(draw_object* draw
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -939,7 +935,7 @@ static void draw_object_vertex_attrib_reset_reflect(draw_object* draw) {
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -962,7 +958,7 @@ inline static void draw_object_vertex_attrib_reset_reflect_compressed(draw_objec
|
||||
draw->vertex_attrib_array[i] = false;
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
uniform_value[U_BONE_MAT] = 0;
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -989,7 +985,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -997,7 +993,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(0, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(2);
|
||||
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1005,7 +1001,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(2, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(6);
|
||||
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1013,7 +1009,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(5, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BINORMAL)
|
||||
if (vertex_format & OBJ_VERTEX_BINORMAL)
|
||||
offset += 12;
|
||||
|
||||
bool texcoord_mat_set[4] = { false };
|
||||
@@ -1030,7 +1026,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
if (material->material.texdata[i].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
|
||||
j++;
|
||||
|
||||
if (vertex_format & (OBJ_VERTEX_FORMAT_TEXCOORD0 << sub_mesh->uv_index[l])) {
|
||||
if (vertex_format & (OBJ_VERTEX_TEXCOORD0 << sub_mesh->uv_index[l])) {
|
||||
enable_vertex_attrib_array(8 + texcoord_index);
|
||||
glVertexAttribPointer(8 + texcoord_index, 2, GL_FLOAT, GL_FALSE,
|
||||
size_vertex, (void*)(offset + 8ULL * sub_mesh->uv_index[l]));
|
||||
@@ -1058,16 +1054,16 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
if (!draw->vertex_attrib_array[8 + i])
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 8;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
enable_vertex_attrib_array(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1075,10 +1071,10 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR1)
|
||||
if (vertex_format & OBJ_VERTEX_COLOR1)
|
||||
offset += 16;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA) {
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
uniform_value[U_BONE_MAT] = 1;
|
||||
|
||||
enable_vertex_attrib_array(1);
|
||||
@@ -1090,11 +1086,11 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
offset += 16;
|
||||
}
|
||||
else {
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN) {
|
||||
if (vertex_format & OBJ_VERTEX_UNKNOWN) {
|
||||
enable_vertex_attrib_array(7);
|
||||
glVertexAttribPointer(7, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1108,7 +1104,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(10);
|
||||
glVertexAttribPointer(10, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1116,7 +1112,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(10, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(11);
|
||||
glVertexAttribPointer(11, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1124,7 +1120,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(11, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(12);
|
||||
glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1132,10 +1128,10 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(12, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BINORMAL)
|
||||
if (vertex_format & OBJ_VERTEX_BINORMAL)
|
||||
offset += 12;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(13);
|
||||
glVertexAttribPointer(13, 2, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1143,7 +1139,7 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(13, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
enable_vertex_attrib_array(14);
|
||||
glVertexAttribPointer(14, 2, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1151,12 +1147,12 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(14, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 8;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
uniform_value[U_MORPH_COLOR] = 1;
|
||||
|
||||
enable_vertex_attrib_array(5);
|
||||
@@ -1166,13 +1162,13 @@ static void draw_object_vertex_attrib_set_default(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(5, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR1)
|
||||
if (vertex_format & OBJ_VERTEX_COLOR1)
|
||||
offset += 16;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
offset += 32;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN)
|
||||
if (vertex_format & OBJ_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
@@ -1194,7 +1190,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1202,7 +1198,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(0, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(2);
|
||||
glVertexAttribPointer(2, 3, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1210,7 +1206,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(2, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(6);
|
||||
glVertexAttribPointer(6, 4, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1232,7 +1228,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
if (material->material.texdata[i].shader_info.m.tex_type == OBJ_MATERIAL_TEXTURE_COLOR)
|
||||
j++;
|
||||
|
||||
if (vertex_format & (OBJ_VERTEX_FORMAT_TEXCOORD0 << sub_mesh->uv_index[l])) {
|
||||
if (vertex_format & (OBJ_VERTEX_TEXCOORD0 << sub_mesh->uv_index[l])) {
|
||||
enable_vertex_attrib_array(8 + texcoord_index);
|
||||
glVertexAttribPointer(8 + texcoord_index, 2, GL_HALF_FLOAT, GL_FALSE,
|
||||
size_vertex, (void*)(offset + 4ULL * sub_mesh->uv_index[l]));
|
||||
@@ -1260,16 +1256,16 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
if (!draw->vertex_attrib_array[8 + i])
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 4;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
enable_vertex_attrib_array(3);
|
||||
glVertexAttribPointer(3, 4, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1277,7 +1273,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA) {
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
uniform_value[U_BONE_MAT] = 1;
|
||||
|
||||
enable_vertex_attrib_array(1);
|
||||
@@ -1289,8 +1285,8 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
offset += 8;
|
||||
}
|
||||
else {
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -1299,7 +1295,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(10);
|
||||
glVertexAttribPointer(10, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1307,7 +1303,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(10, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(11);
|
||||
glVertexAttribPointer(11, 3, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1315,7 +1311,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(11, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(12);
|
||||
glVertexAttribPointer(12, 4, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1323,7 +1319,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(12, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(13);
|
||||
glVertexAttribPointer(13, 2, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 4;
|
||||
@@ -1331,7 +1327,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(13, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
enable_vertex_attrib_array(14);
|
||||
glVertexAttribPointer(14, 2, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 4;
|
||||
@@ -1339,12 +1335,12 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(14, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 4;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
uniform_value[U_MORPH_COLOR] = 1;
|
||||
|
||||
enable_vertex_attrib_array(5);
|
||||
@@ -1354,7 +1350,7 @@ inline static void draw_object_vertex_attrib_set_default_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(5, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
offset += 16;
|
||||
|
||||
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
@@ -1381,7 +1377,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1389,7 +1385,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(0, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(2);
|
||||
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1397,15 +1393,15 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(2, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT)
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT)
|
||||
offset += 16;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BINORMAL)
|
||||
if (vertex_format & OBJ_VERTEX_BINORMAL)
|
||||
offset += 12;
|
||||
|
||||
obj_material_data* material = draw->material;
|
||||
if (material->material.texdata[0].tex_index != -1) {
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(8);
|
||||
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE,
|
||||
size_vertex, (void*)(offset + 8ULL * sub_mesh->uv_index[0]));
|
||||
@@ -1429,16 +1425,16 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
for (int32_t i = 1; i < 4; i++)
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 8;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
enable_vertex_attrib_array(3);
|
||||
glVertexAttribPointer(3, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1446,10 +1442,10 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR1)
|
||||
if (vertex_format & OBJ_VERTEX_COLOR1)
|
||||
offset += 16;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA) {
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
uniform_value[U_BONE_MAT] = 1;
|
||||
|
||||
enable_vertex_attrib_array(1);
|
||||
@@ -1461,11 +1457,11 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
offset += 16;
|
||||
}
|
||||
else {
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN)
|
||||
if (vertex_format & OBJ_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -1474,7 +1470,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(10);
|
||||
glVertexAttribPointer(10, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1482,7 +1478,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(10, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(11);
|
||||
glVertexAttribPointer(11, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1490,7 +1486,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(11, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(12);
|
||||
glVertexAttribPointer(12, 4, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 16;
|
||||
@@ -1498,10 +1494,10 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(12, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BINORMAL)
|
||||
if (vertex_format & OBJ_VERTEX_BINORMAL)
|
||||
offset += 12;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(13);
|
||||
glVertexAttribPointer(13, 2, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1509,7 +1505,7 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(13, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
enable_vertex_attrib_array(14);
|
||||
glVertexAttribPointer(14, 2, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1517,12 +1513,12 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(14, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 8;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 8;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
uniform_value[U_MORPH_COLOR] = 1;
|
||||
|
||||
enable_vertex_attrib_array(5);
|
||||
@@ -1532,13 +1528,13 @@ static void draw_object_vertex_attrib_set_reflect(draw_object* draw) {
|
||||
else
|
||||
glVertexAttrib4f(5, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR1)
|
||||
if (vertex_format & OBJ_VERTEX_COLOR1)
|
||||
offset += 16;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
offset += 32;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_UNKNOWN)
|
||||
if (vertex_format & OBJ_VERTEX_UNKNOWN)
|
||||
offset += 16;
|
||||
|
||||
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
@@ -1557,7 +1553,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
gl_state_bind_array_buffer(draw->array_buffer);
|
||||
|
||||
size_t offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1565,7 +1561,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(0, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(2);
|
||||
glVertexAttribPointer(2, 3, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1573,12 +1569,12 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(2, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT)
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT)
|
||||
offset += 8;
|
||||
|
||||
obj_material_data* material = draw->material;
|
||||
if (material->material.texdata[0].tex_index != -1) {
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(8);
|
||||
glVertexAttribPointer(8, 2, GL_HALF_FLOAT, GL_FALSE,
|
||||
size_vertex, (void*)(offset + 4ULL * sub_mesh->uv_index[0]));
|
||||
@@ -1602,16 +1598,16 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
for (int32_t i = 1; i < 4; i++)
|
||||
glVertexAttrib4f(8 + i, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 4;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
enable_vertex_attrib_array(3);
|
||||
glVertexAttribPointer(3, 4, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1619,7 +1615,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(3, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA) {
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA) {
|
||||
uniform_value[U_BONE_MAT] = 1;
|
||||
|
||||
enable_vertex_attrib_array(1);
|
||||
@@ -1631,8 +1627,8 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
offset += 8;
|
||||
}
|
||||
else {
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glVertexAttrib4f(1, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glVertexAttrib4f(15, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (draw->morph_array_buffer) {
|
||||
@@ -1641,7 +1637,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
gl_state_bind_array_buffer(draw->morph_array_buffer);
|
||||
|
||||
offset = 0;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_POSITION) {
|
||||
if (vertex_format & OBJ_VERTEX_POSITION) {
|
||||
enable_vertex_attrib_array(10);
|
||||
glVertexAttribPointer(10, 3, GL_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 12;
|
||||
@@ -1649,7 +1645,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(10, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_NORMAL) {
|
||||
if (vertex_format & OBJ_VERTEX_NORMAL) {
|
||||
enable_vertex_attrib_array(11);
|
||||
glVertexAttribPointer(11, 3, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1657,7 +1653,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(11, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TANGENT) {
|
||||
if (vertex_format & OBJ_VERTEX_TANGENT) {
|
||||
enable_vertex_attrib_array(12);
|
||||
glVertexAttribPointer(12, 4, GL_SHORT, GL_TRUE, size_vertex, (void*)offset);
|
||||
offset += 8;
|
||||
@@ -1665,7 +1661,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(12, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD0) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD0) {
|
||||
enable_vertex_attrib_array(13);
|
||||
glVertexAttribPointer(13, 2, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 4;
|
||||
@@ -1673,7 +1669,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(13, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD1) {
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD1) {
|
||||
enable_vertex_attrib_array(14);
|
||||
glVertexAttribPointer(14, 2, GL_HALF_FLOAT, GL_FALSE, size_vertex, (void*)offset);
|
||||
offset += 4;
|
||||
@@ -1681,12 +1677,12 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(14, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD2)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD2)
|
||||
offset += 4;
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_TEXCOORD3)
|
||||
if (vertex_format & OBJ_VERTEX_TEXCOORD3)
|
||||
offset += 4;
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_COLOR0) {
|
||||
if (vertex_format & OBJ_VERTEX_COLOR0) {
|
||||
uniform_value[U_MORPH_COLOR] = 1;
|
||||
|
||||
enable_vertex_attrib_array(5);
|
||||
@@ -1696,7 +1692,7 @@ inline static void draw_object_vertex_attrib_set_reflect_compressed(draw_object*
|
||||
else
|
||||
glVertexAttrib4f(5, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (vertex_format & OBJ_VERTEX_FORMAT_BONE_DATA)
|
||||
if (vertex_format & OBJ_VERTEX_BONE_DATA)
|
||||
offset += 16;
|
||||
|
||||
shaders_ft.env_vert_set(13, draw->morph_value, 1.0f - draw->morph_value, 0.0f, 0.0f);
|
||||
@@ -3,17 +3,17 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "draw_pass.h"
|
||||
#include "draw_pass.hpp"
|
||||
#include "Glitter/glitter.hpp"
|
||||
#include "light_param/fog.hpp"
|
||||
#include "light_param/light.hpp"
|
||||
#include "gl_state.h"
|
||||
#include "rob/rob.hpp"
|
||||
#include "gl_state.hpp"
|
||||
#include "post_process.hpp"
|
||||
#include "rob.hpp"
|
||||
#include "render_texture.h"
|
||||
#include "shader_ft.h"
|
||||
#include "render_texture.hpp"
|
||||
#include "shader_ft.hpp"
|
||||
#include "shader_glsl.hpp"
|
||||
#include "static_var.h"
|
||||
#include "static_var.hpp"
|
||||
#include "texture.hpp"
|
||||
|
||||
struct draw_preprocess {
|
||||
@@ -55,7 +55,7 @@ static void texture_params_restore(texture_param* tex_0_param,
|
||||
texture_param* tex_1_param, texture_param* tex_2_param);
|
||||
|
||||
extern bool draw_grid_3d;
|
||||
extern shader_glsl grid_shader;
|
||||
extern shader_glsl* grid_shader;
|
||||
extern GLuint grid_vbo;
|
||||
extern size_t grid_vertex_count;
|
||||
extern vec4u8 clear_color;
|
||||
@@ -107,7 +107,7 @@ void draw_pass_main(render_context* rctx) {
|
||||
draw_pass_pre_process(rctx, &rctx->draw_pass);
|
||||
break;
|
||||
case DRAW_PASS_CLEAR: {
|
||||
render_texture_bind(&rctx->post_process.rend_texture, 0);
|
||||
rctx->post_process.rend_texture.bind();
|
||||
vec4 _clear_color;
|
||||
vec4u8_to_vec4(clear_color, _clear_color);
|
||||
vec4_mult_scalar(_clear_color, (float_t)(1.0 / 255.0), _clear_color);
|
||||
@@ -139,7 +139,7 @@ void draw_pass_main(render_context* rctx) {
|
||||
inline static void draw_pass_begin(draw_pass* a1) {
|
||||
if (a1->wait_for_gpu)
|
||||
glFinish();
|
||||
time_struct_get_timestamp(&a1->time);
|
||||
a1->time.get_timestamp();
|
||||
}
|
||||
|
||||
static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
@@ -158,7 +158,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
if (draw_pass_shadow_litproj(rctx, rctx->litproj)) {
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_data_set(&rctx->light_set_data[i], &rctx->face, (light_set_id)i);
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
gl_state_bind_vertex_array(rctx->vao);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_OPAQUE, 0, 0, true, -1);
|
||||
draw_task_draw_objects_by_type(rctx, DRAW_OBJECT_TRANSPARENT, 0, 0, true, -1);
|
||||
@@ -197,7 +197,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
int32_t index = v11[i];
|
||||
|
||||
texture* tex = shad->field_158[0]->color_texture;
|
||||
render_texture_bind(shad->field_158[0], 0);
|
||||
shad->field_158[0]->bind();
|
||||
glViewport(0, 0, tex->width, tex->height);
|
||||
glScissor(0, 0, tex->width, tex->height);
|
||||
gl_state_enable_depth_test();
|
||||
@@ -261,29 +261,29 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
if (v5 && v6 && v7) {
|
||||
texture_param tex_params[3];
|
||||
texture_params_get(v5, &tex_params[0], v7, &tex_params[1], v6, &tex_params[2]);
|
||||
render_texture_bind(&shad->field_8[6], 0);
|
||||
shad->field_8[6].bind();
|
||||
uniform_value[U_ESM_FILTER] = 0;
|
||||
shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
shaders_ft.local_frag_set(0, 1.0f / (float_t)tex_params[1].width,
|
||||
1.0f / (float_t)tex_params[1].height, 0.0f, 0.0f);
|
||||
gl_state_active_bind_texture_2d(0, v7);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
|
||||
render_texture_bind(&shad->field_8[5], 0);
|
||||
shad->field_8[5].bind();
|
||||
uniform_value[U_ESM_FILTER] = 1;
|
||||
shaders_ft.set(SHADER_FT_ESMFILT);
|
||||
shaders_ft.local_frag_set(0, 0.75f / (float_t)tex_params[2].width,
|
||||
0.75f / (float_t)tex_params[2].height, 0.0f, 0.0f);
|
||||
gl_state_active_bind_texture_2d(0, v6);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
texture_params_restore(&tex_params[0], &tex_params[1], &tex_params[2]);
|
||||
}
|
||||
}
|
||||
|
||||
render_texture* rend_tex = shad->field_158[1 + index];
|
||||
render_texture_bind(rend_tex, 0);
|
||||
rend_tex->bind();
|
||||
|
||||
GLuint v11 = shad->field_158[1 + index]->color_texture->tex;
|
||||
GLuint v12 = shad->field_158[0]->color_texture->tex;
|
||||
@@ -303,11 +303,11 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
shaders_ft.state_matrix_set_texture(7, mat4_identity);
|
||||
gl_state_active_bind_texture_2d(0, v12);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
texture_params_restore(&tex_params[0], &tex_params[1], 0);
|
||||
}
|
||||
|
||||
render_texture_bind(rend_tex, 0);
|
||||
rend_tex->bind();
|
||||
if (shad->blur_filter_enable[index])
|
||||
for (int32_t i = 0; i < shad->near_blur; i++)
|
||||
blur_filter_apply(rend_tex->color_texture->tex,
|
||||
@@ -331,7 +331,7 @@ static void draw_pass_shadow(render_context* rctx, draw_pass* a1) {
|
||||
|
||||
for (int32_t i = 1; i < 3; i++)
|
||||
for (int32_t j = 0; j < 4; j++) {
|
||||
render_texture_bind(shad->field_158[i], j);
|
||||
shad->field_158[i]->bind(j);
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ static void draw_pass_shadow_filter(render_texture* a1, render_texture* a2,
|
||||
for (int32_t i = 0; i < 8; i++)
|
||||
((float_t*)v15)[i] = (float_t)(exp((double_t)((ssize_t)i * i) * v8) * v6);
|
||||
|
||||
render_texture_bind(a2, 0);
|
||||
a2->bind();
|
||||
uniform_value[U_LIGHT_PROJ] = enable_lit_proj ? 1 : 0;
|
||||
shaders_ft.set(SHADER_FT_ESMGAUSS);
|
||||
shaders_ft.local_frag_set(0, 1.0f / (float_t)tex_params[0].width, 0.0f, 0.0f, 0.0f);
|
||||
@@ -383,16 +383,16 @@ static void draw_pass_shadow_filter(render_texture* a1, render_texture* a2,
|
||||
}
|
||||
gl_state_active_bind_texture_2d(0, v11);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
|
||||
render_texture_bind(a1, 0);
|
||||
a1->bind();
|
||||
shaders_ft.local_frag_set(0, 0.0f, 1.0f / (float_t)tex_params[0].height, 0.0f, 0.0f);
|
||||
shaders_ft.local_frag_set(1, v15[0]);
|
||||
shaders_ft.local_frag_set(2, v15[1]);
|
||||
shaders_ft.local_frag_set(3, far_texel_offset, far_texel_offset, 0.0f, 0.0f);
|
||||
gl_state_active_bind_texture_2d(0, v9);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
shader::unbind();
|
||||
texture_params_restore(&tex_params[0], &tex_params[1], 0);
|
||||
}
|
||||
@@ -405,7 +405,7 @@ static bool draw_pass_shadow_litproj(render_context* rctx, light_proj* litproj)
|
||||
if (!tex)
|
||||
return false;
|
||||
|
||||
render_texture_bind(&litproj->draw_texture, 0);
|
||||
litproj->draw_texture.bind();
|
||||
|
||||
glViewport(0, 0, litproj->draw_texture.color_texture->width,
|
||||
litproj->draw_texture.color_texture->height);
|
||||
@@ -448,11 +448,11 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
// sss->npr_contour = false;
|
||||
|
||||
if (sss->npr_contour) {
|
||||
render_texture_bind(&pp->rend_texture, 0);
|
||||
pp->rend_texture.bind();
|
||||
glViewport(0, 0, pp->render_width, pp->render_height);
|
||||
}
|
||||
else {
|
||||
render_texture_bind(&sss->textures[0], 0);
|
||||
sss->textures[0].bind();
|
||||
glViewport(0, 0, 640, 360);
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_data_set(&rctx->light_set_data[i], &rctx->face, (light_set_id)i);
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
|
||||
if (a1->shadow)
|
||||
draw_pass_3d_shadow_set(a1->shadow_ptr, rctx);
|
||||
@@ -485,7 +485,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
draw_pass_sss_contour(rctx, pp);
|
||||
}
|
||||
else if (a1->npr) {
|
||||
render_texture_bind(&pp->rend_texture, 0);
|
||||
pp->rend_texture.bind();
|
||||
glViewport(0, 0, pp->render_width, pp->render_height);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
rctx->draw_state.shader_index = SHADER_FT_SSS_SKIN;
|
||||
@@ -506,7 +506,7 @@ static void draw_pass_sss(render_context* rctx, draw_pass* a1) {
|
||||
}
|
||||
|
||||
static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
|
||||
render_texture_bind(&pp->sss_contour_texture, 0);
|
||||
pp->sss_contour_texture.bind();
|
||||
shaders_ft.state_matrix_set_modelview(0, mat4_identity, false);
|
||||
shaders_ft.state_matrix_set_projection(mat4_identity, true);
|
||||
gl_state_enable_depth_test();
|
||||
@@ -543,7 +543,7 @@ static void draw_pass_sss_contour(render_context* rctx, post_process* pp) {
|
||||
v9 = 0.0f;
|
||||
|
||||
shaders_ft.local_frag_set(4, v9 * 0.004f + 0.0027f, 0.003f, v3 * 0.35f, 0.0008f);
|
||||
render_texture_draw_params(&shaders_ft, pp->render_width, pp->render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
render_texture::draw_params(&shaders_ft, pp->render_width, pp->render_height, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
static void draw_pass_sss_filter_calc_coef(double_t a1, size_t a2, double_t a3, size_t a4,
|
||||
@@ -655,7 +655,7 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
|
||||
gl_state_active_texture(0);
|
||||
if (a1->npr_contour) {
|
||||
render_texture_bind(a1->textures, 0);
|
||||
a1->textures->bind();
|
||||
glViewport(0, 0, 640, 360);
|
||||
post_process* pp = &rctx->post_process;
|
||||
gl_state_bind_texture_2d(pp->rend_texture.color_texture->tex);
|
||||
@@ -663,15 +663,15 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
shaders_ft.set(SHADER_FT_REDUCE);
|
||||
|
||||
shaders_ft.state_matrix_set_texture(0, mat4_identity);
|
||||
render_texture_draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
render_texture::draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
render_texture_bind(&a1->textures[2], 0);
|
||||
a1->textures[2].bind();
|
||||
glViewport(0, 0, 320, 180);
|
||||
gl_state_bind_texture_2d(a1->textures[0].color_texture->tex);
|
||||
uniform_value[U_SSS_FILTER] = 0;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
render_texture_draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
render_texture_bind(&a1->textures[1], 0);
|
||||
render_texture::draw_params(&shaders_ft, 640, 360, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
|
||||
a1->textures[1].bind();
|
||||
uniform_value[U_SSS_FILTER] = 3;
|
||||
shaders_ft.set(SHADER_FT_SSS_FILT);
|
||||
shaders_ft.local_frag_set(1, 5.0f, 0.0f, 0.0f, 0.0f);
|
||||
@@ -697,36 +697,36 @@ static void draw_pass_sss_filter(render_context* rctx, sss_data* a1) {
|
||||
shaders_ft.local_frag_set(1, (float_t)(sss_count - 1), 0.0f, 1.0f, 1.0f);
|
||||
glViewport(0, 0, 320, 180);
|
||||
gl_state_bind_texture_2d(a1->textures[2].color_texture->tex);
|
||||
render_texture_draw_params(&shaders_ft, 320, 180, 1.0f, 1.0f, 0.96f, 1.0f, 0.0f);
|
||||
render_texture::draw_params(&shaders_ft, 320, 180, 1.0f, 1.0f, 0.96f, 1.0f, 0.0f);
|
||||
gl_state_bind_texture_2d(0);
|
||||
}
|
||||
|
||||
static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
render_texture* reflect_texture = &rctx->draw_pass.reflect_texture;
|
||||
render_texture_bind(reflect_texture, 0);
|
||||
render_texture& reflect_texture = rctx->draw_pass.reflect_texture;
|
||||
reflect_texture.bind();
|
||||
if (draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_OPAQUE)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_TRANSPARENT)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_TRANSLUCENT)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_CHARA_OPAQUE)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_CHARA_TRANSPARENT)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFLECT_CHARA_TRANSLUCENT)) {
|
||||
texture* refl_tex = reflect_texture->color_texture;
|
||||
texture* refl_tex = reflect_texture.color_texture;
|
||||
glViewport(0, 0, refl_tex->width, refl_tex->height);
|
||||
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_data_set(&rctx->light_set_data[i], &rctx->face, (light_set_id)i);
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
for (int32_t i = FOG_DEPTH; i < FOG_BUMP; i++)
|
||||
fog_data_set(&rctx->fog_data[i], (fog_id)i);
|
||||
rctx->fog[i].data_set((fog_id)i);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
rctx->draw_state.shader_index = SHADER_FT_S_REFL;
|
||||
bool clip_plane[4];
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_get_clip_plane(&set->lights[LIGHT_SPOT], clip_plane);
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
set->lights[LIGHT_SPOT].get_clip_plane(clip_plane);
|
||||
uniform_value[U_REFLECT] = 2;
|
||||
uniform_value[U_CLIP_PLANE] = clip_plane[1];
|
||||
gl_state_bind_vertex_array(rctx->vao);
|
||||
@@ -751,10 +751,10 @@ static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
uniform_value[U_REFLECT] = 0;
|
||||
rctx->draw_state.shader_index = -1;
|
||||
|
||||
render_texture_bind(reflect_texture, 0);
|
||||
reflect_texture.bind();
|
||||
for (int32_t i = a1->reflect_blur_num; i > 0; i--)
|
||||
blur_filter_apply(reflect_texture->color_texture->tex,
|
||||
reflect_texture->color_texture->tex, a1->reflect_blur_filter);
|
||||
blur_filter_apply(reflect_texture.color_texture->tex,
|
||||
reflect_texture.color_texture->tex, a1->reflect_blur_filter);
|
||||
}
|
||||
else {
|
||||
vec4 clear_color;
|
||||
@@ -766,20 +766,20 @@ static void draw_pass_reflect(render_context* rctx, draw_pass* a1) {
|
||||
}
|
||||
|
||||
static void draw_pass_refract(render_context* rctx, draw_pass* a1) {
|
||||
render_texture* refract_texture = &rctx->draw_pass.refract_texture;
|
||||
render_texture_bind(refract_texture, 0);
|
||||
render_texture& refract_texture = rctx->draw_pass.refract_texture;
|
||||
refract_texture.bind();
|
||||
if (draw_task_get_count(rctx, DRAW_OBJECT_REFRACT_OPAQUE)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFRACT_TRANSPARENT)
|
||||
|| draw_task_get_count(rctx, DRAW_OBJECT_REFRACT_TRANSLUCENT)) {
|
||||
texture* refr_tex = refract_texture->color_texture;
|
||||
texture* refr_tex = refract_texture.color_texture;
|
||||
glViewport(0, 0, refr_tex->width, refr_tex->height);
|
||||
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_data_set(&rctx->light_set_data[i], &rctx->face, (light_set_id)i);
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
for (int32_t i = FOG_DEPTH; i < FOG_BUMP; i++)
|
||||
fog_data_set(&rctx->fog_data[i], (fog_id)i);
|
||||
rctx->fog[i].data_set((fog_id)i);
|
||||
|
||||
vec4 clear_color;
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, (GLfloat*)&clear_color);
|
||||
@@ -813,7 +813,7 @@ static void draw_pass_pre_process(render_context* rctx, draw_pass* a1) {
|
||||
|
||||
static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
rctx->view_mat = rctx->camera->view;
|
||||
render_texture_bind(&rctx->post_process.rend_texture, 0);
|
||||
rctx->post_process.rend_texture.bind();
|
||||
glViewport(0, 0, rctx->post_process.render_width, rctx->post_process.render_height);
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
if (!a1->sss_data.enable || !a1->sss_data.npr_contour || draw_pass_3d_get_translucent_count(rctx))
|
||||
@@ -822,9 +822,9 @@ static void draw_pass_3d(render_context* rctx, draw_pass* a1) {
|
||||
gl_state_bind_vertex_array(rctx->vao);
|
||||
|
||||
for (int32_t i = LIGHT_SET_MAIN; i < LIGHT_SET_MAX; i++)
|
||||
light_set_data_set(&rctx->light_set_data[i], &rctx->face, (light_set_id)i);
|
||||
rctx->light_set[i].data_set(rctx->face, (light_set_id)i);
|
||||
for (int32_t i = FOG_DEPTH; i < FOG_MAX; i++)
|
||||
fog_data_set(&rctx->fog_data[i], (fog_id)i);
|
||||
rctx->fog[i].data_set((fog_id)i);
|
||||
|
||||
if (a1->shadow)
|
||||
draw_pass_3d_shadow_set(a1->shadow_ptr, rctx);
|
||||
@@ -1038,12 +1038,12 @@ static void draw_pass_3d_shadow_set(shadow* shad, render_context* rctx) {
|
||||
}
|
||||
gl_state_active_texture(0);
|
||||
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
light_data* data = &set->lights[LIGHT_SHADOW];
|
||||
|
||||
vec4 ambient;
|
||||
if (light_get_type(data) == LIGHT_PARALLEL)
|
||||
light_get_ambient(data, &ambient);
|
||||
if (data->get_type() == LIGHT_PARALLEL)
|
||||
data->get_ambient(ambient);
|
||||
else {
|
||||
ambient.x = shad->ambient;
|
||||
ambient.y = shad->ambient;
|
||||
@@ -1070,7 +1070,7 @@ static void draw_pass_show_vector(render_context* rctx, draw_pass* a1) {
|
||||
return;
|
||||
|
||||
rctx->view_mat = rctx->camera->view;
|
||||
render_texture_bind(&rctx->post_process.rend_texture, 0);
|
||||
rctx->post_process.rend_texture.bind();
|
||||
glViewport(0, 0, rctx->post_process.render_width, rctx->post_process.render_height);
|
||||
draw_pass_set_camera(rctx->camera);
|
||||
|
||||
@@ -1094,8 +1094,8 @@ static void draw_pass_post_process(render_context* rctx, draw_pass* a1) {
|
||||
texture* light_proj_tex = 0;
|
||||
light_proj* litproj = rctx->litproj;
|
||||
if (litproj && litproj->enable) {
|
||||
light_set* set = &rctx->light_set_data[LIGHT_SET_MAIN];
|
||||
if (light_get_type(&set->lights[LIGHT_PROJECTION]) == LIGHT_SPOT
|
||||
light_set* set = &rctx->light_set[LIGHT_SET_MAIN];
|
||||
if (set->lights[LIGHT_PROJECTION].get_type() == LIGHT_SPOT
|
||||
&& texture_storage_get_texture(litproj->texture_id))
|
||||
light_proj_tex = litproj->draw_texture.color_texture;
|
||||
}
|
||||
@@ -1107,12 +1107,11 @@ static void draw_pass_sprite(render_context* rctx, draw_pass* a1) {
|
||||
}
|
||||
|
||||
inline static void draw_pass_end(draw_pass* pass, draw_pass_type type) {
|
||||
pass->cpu_time[type] = time_struct_calc_time(&pass->time);
|
||||
pass->cpu_time[type] = pass->time.calc_time();
|
||||
if (pass->wait_for_gpu) {
|
||||
time_struct t;
|
||||
time_struct_get_timestamp(&t);
|
||||
glFinish();
|
||||
pass->gpu_time[type] = time_struct_calc_time(&t);
|
||||
pass->gpu_time[type] = t.calc_time();
|
||||
}
|
||||
else
|
||||
pass->gpu_time[type] = 0;
|
||||
@@ -1126,8 +1125,8 @@ static void draw_pass_3d_grid(render_context* rctx) {
|
||||
gl_state_set_depth_func(GL_LEQUAL);
|
||||
gl_state_set_depth_mask(GL_TRUE);
|
||||
|
||||
grid_shader.use();
|
||||
grid_shader.set("vp", false, rctx->camera->view_projection);
|
||||
grid_shader->use();
|
||||
grid_shader->set("vp", false, rctx->camera->view_projection);
|
||||
gl_state_bind_array_buffer(grid_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
|
||||
@@ -1281,6 +1280,6 @@ static void blur_filter_apply(GLuint tex_0, GLuint tex_1, blur_filter_mode filte
|
||||
}
|
||||
gl_state_active_bind_texture_2d(0, tex_1);
|
||||
shaders_ft.state_matrix_set_mvp(mat4_identity);
|
||||
render_texture_draw_custom(&shaders_ft);
|
||||
render_texture::draw_custom(&shaders_ft);
|
||||
texture_params_restore(&tex_params[0], &tex_params[1], 0);
|
||||
}
|
||||
@@ -8,6 +8,6 @@
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "draw_task.h"
|
||||
#include "draw_task.hpp"
|
||||
|
||||
extern void draw_pass_main(render_context* rctx);
|
||||
@@ -3,4 +3,4 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "draw_object.h"
|
||||
#include "draw_object.hpp"
|
||||
@@ -8,4 +8,4 @@
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "gl_state.h"
|
||||
#include "gl_state.hpp"
|
||||
@@ -3,13 +3,13 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "draw_task.h"
|
||||
#include "draw_task.hpp"
|
||||
#include "../KKdLib/hash.hpp"
|
||||
#include "../KKdLib/sort.hpp"
|
||||
#include "camera.h"
|
||||
#include "camera.hpp"
|
||||
#include "fbo.hpp"
|
||||
#include "post_process.hpp"
|
||||
#include "shader_ft.h"
|
||||
#include "shader_ft.hpp"
|
||||
|
||||
static void draw_task_add(render_context* rctx, draw_object_type type, draw_task* task);
|
||||
static void draw_task_object_init(draw_task* task, object_data* object_data, mat4* mat,
|
||||
@@ -253,12 +253,12 @@ void draw_task_draw_objects_by_type_translucent(render_context* rctx, bool opaqu
|
||||
gl_state_disable_blend();
|
||||
}
|
||||
|
||||
render_texture_bind(&rctx->post_process.buf_texture, 0);
|
||||
render_texture_shader_set_glsl(&rctx->post_process.alpha_layer_shader);
|
||||
rctx->post_process.buf_texture.bind();
|
||||
render_texture::shader_set_glsl(&rctx->post_process.alpha_layer_shader);
|
||||
gl_state_active_bind_texture_2d(0, rctx->post_process.alpha_layer_texture.color_texture->tex);
|
||||
gl_state_active_bind_texture_2d(1, rctx->post_process.rend_texture.color_texture->tex);
|
||||
glUniform1f(0, (float_t)(alpha * (1.0 / 255.0)));
|
||||
render_texture_draw_custom_glsl();
|
||||
render_texture::draw_custom_glsl();
|
||||
|
||||
fbo::blit(rctx->post_process.buf_texture.fbos[0],
|
||||
rctx->post_process.rend_texture.fbos[0],
|
||||
@@ -290,8 +290,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
obj_mesh* mesh = &object->mesh_array[i];
|
||||
obj_mesh* mesh_morph = 0;
|
||||
if (obj_vertex_buf && obj_morph_vertex_buf) {
|
||||
if (obj_mesh_vertex_buffer_get_size(&obj_vertex_buf[i])
|
||||
!= obj_mesh_vertex_buffer_get_size(&obj_morph_vertex_buf[i]))
|
||||
if (obj_vertex_buf[i].get_size() != obj_morph_vertex_buf[i].get_size())
|
||||
continue;
|
||||
|
||||
if (object_morph && i < object_morph->num_mesh)
|
||||
@@ -313,7 +312,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
for (uint32_t j = 0; j < mesh->num_submesh; j++) {
|
||||
obj_sub_mesh* sub_mesh = &mesh->submesh_array[j];
|
||||
obj_sub_mesh* sub_mesh_morph = 0;
|
||||
if (sub_mesh->attrib.m.flag_3)
|
||||
if (sub_mesh->attrib.m.cloth)
|
||||
continue;
|
||||
|
||||
if (object_data->object_culling && !instances_count && !bone_mat) {
|
||||
@@ -384,7 +383,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
|
||||
GLuint morph_array_buffer = 0;
|
||||
if (obj_morph_vertex_buf)
|
||||
morph_array_buffer = obj_mesh_vertex_buffer_get_buffer(&obj_morph_vertex_buf[i]);
|
||||
morph_array_buffer = obj_morph_vertex_buf[i].get_buffer();
|
||||
|
||||
GLuint element_array_buffer = 0;
|
||||
if (obj_index_buf)
|
||||
@@ -392,7 +391,7 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
|
||||
GLuint array_buffer = 0;
|
||||
if (obj_vertex_buf)
|
||||
array_buffer = obj_mesh_vertex_buffer_get_buffer(&obj_vertex_buf[i]);
|
||||
array_buffer = obj_vertex_buf[i].get_buffer();
|
||||
|
||||
uint32_t material_hash = hash_utf8_murmurhash(material->material.name);
|
||||
|
||||
@@ -621,6 +620,18 @@ bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void draw_task_add_draw_object_by_obj(render_context* rctx, mat4* mat, obj* obj, std::vector<GLuint>* textures,
|
||||
obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha) {
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
vec4 blend_color = { 1.0f, 1.0f, 1.0f, alpha };
|
||||
vec4* blend_color_ptr = alpha < 1.0f ? &blend_color : 0;
|
||||
|
||||
draw_task_add_draw_object(rctx, obj, obj_vert_buf, obj_index_buf, mat, textures, blend_color_ptr,
|
||||
bone_mat, 0, 0, 0, 0, 0, !!bone_mat);
|
||||
}
|
||||
|
||||
inline bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
object_info obj_info, mat4* bone_mat) {
|
||||
vec4 blend_color = vec4_identity;
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "../KKdLib/default.hpp"
|
||||
#include "../KKdLib/mat.hpp"
|
||||
#include "../KKdLib/vec.hpp"
|
||||
#include "draw_object.h"
|
||||
#include "draw_primitive.h"
|
||||
#include "draw_object.hpp"
|
||||
#include "draw_primitive.hpp"
|
||||
|
||||
extern void draw_task_draw_objects_by_type(render_context* rctx, draw_object_type type,
|
||||
int32_t a2, int32_t a3, bool a4, int32_t alpha);
|
||||
@@ -22,6 +22,8 @@ extern bool draw_task_add_draw_object(render_context* rctx, obj* object,
|
||||
std::vector<GLuint>* textures, vec4* blend_color, mat4* bone_mat, obj* object_morph,
|
||||
obj_mesh_vertex_buffer* obj_morph_vertex_buf, int32_t instances_count,
|
||||
mat4* instances_mat, void(*draw_object_func)(draw_object*), bool enable_bone_mat);
|
||||
extern void draw_task_add_draw_object_by_obj(render_context* rctx, mat4* mat, obj* obj, std::vector<GLuint>* textures,
|
||||
obj_mesh_vertex_buffer* obj_vert_buf, obj_mesh_index_buffer* obj_index_buf, mat4* bone_mat, float_t alpha);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
object_info obj_info, mat4* bone_mat = 0);
|
||||
extern bool draw_task_add_draw_object_by_object_info(render_context* rctx, mat4* mat,
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "fbo.hpp"
|
||||
#include "gl_state.h"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
fbo::fbo() : flags(), width(), height(), buffer(), count(), textures() {
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared.h"
|
||||
#include "shared.hpp"
|
||||
|
||||
enum fbo_flags {
|
||||
FBO_DEPTH_ATTACHMENT = 0x01,
|
||||
|
||||
@@ -331,13 +331,13 @@ p_file_handler::p_file_handler() {
|
||||
p_file_handler::~p_file_handler() {
|
||||
if (ptr) {
|
||||
if (check_not_ready())
|
||||
call_free_func_free_data();
|
||||
call_free_callback();
|
||||
else
|
||||
free_data();
|
||||
}
|
||||
}
|
||||
|
||||
void p_file_handler::call_free_func_free_data() {
|
||||
void p_file_handler::call_free_callback() {
|
||||
if (ptr)
|
||||
ptr->call_callback(1);
|
||||
free_data();
|
||||
|
||||
@@ -50,7 +50,7 @@ struct p_file_handler {
|
||||
p_file_handler();
|
||||
virtual ~p_file_handler();
|
||||
|
||||
void call_free_func_free_data();
|
||||
void call_free_callback();
|
||||
bool check_not_ready();
|
||||
void free_data();
|
||||
const void* get_data();
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "frame_rate_control.hpp"
|
||||
#include "static_var.h"
|
||||
#include "static_var.hpp"
|
||||
|
||||
SysFrameRate sys_frame_rate;
|
||||
DivaPvFrameRate diva_pv_frame_rate;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "gl_state.h"
|
||||
#include "gl_state.hpp"
|
||||
|
||||
gl_state_struct gl_state;
|
||||
|
||||
@@ -152,7 +152,7 @@ static int32_t light_param_storage_load_file(light_param_data_storage* a1, bool
|
||||
|
||||
if (load_error) {
|
||||
for (int32_t i = 0; i < 6; i++)
|
||||
a1->file_handlers[i].call_free_func_free_data();
|
||||
a1->file_handlers[i].call_free_callback();
|
||||
a1->state = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ static void light_param_storage_load_stages(light_param_data_storage* a1, std::v
|
||||
if (a1->state)
|
||||
for (int32_t i = 0; i < 6; ++i)
|
||||
if (a1->file_handlers[i].check_not_ready())
|
||||
a1->file_handlers[i].call_free_func_free_data();
|
||||
a1->file_handlers[i].call_free_callback();
|
||||
|
||||
a1->stage_index = -1;
|
||||
a1->stage.clear();
|
||||
@@ -537,7 +537,7 @@ static void light_param_storage_load_stages(light_param_data_storage* a1,
|
||||
if (a1->state)
|
||||
for (int32_t i = 0; i < 6; ++i)
|
||||
if (a1->file_handlers[i].check_not_ready())
|
||||
a1->file_handlers[i].call_free_func_free_data();
|
||||
a1->file_handlers[i].call_free_callback();
|
||||
|
||||
a1->stage_index = -1;
|
||||
a1->stage.clear();
|
||||
|
||||
@@ -12,34 +12,42 @@ face::face() {
|
||||
direction = vec3_null;
|
||||
}
|
||||
|
||||
inline float_t face_get_offset(face* face) {
|
||||
return face->offset;
|
||||
float_t face::get_offset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
inline void face_set_offset(face* face, float_t value) {
|
||||
face->scale = value;
|
||||
void face::set_offset(float_t value) {
|
||||
scale = value;
|
||||
}
|
||||
|
||||
inline float_t face_get_scale(face* face) {
|
||||
return face->scale;
|
||||
float_t face::get_scale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
inline void face_set_scale(face* face, float_t value) {
|
||||
face->scale = value;
|
||||
void face::set_scale(float_t value) {
|
||||
scale = value;
|
||||
}
|
||||
|
||||
inline void face_get_position(face* face, vec3* value) {
|
||||
*value = face->position;
|
||||
void face::get_position(vec3& value) {
|
||||
value = position;
|
||||
}
|
||||
|
||||
inline void face_set_position(face* face, vec3* value) {
|
||||
face->position = *value;
|
||||
void face::set_position(vec3& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
inline void face_get_direction(face* face, vec3* value) {
|
||||
*value = face->direction;
|
||||
void face::set_position(vec3&& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
inline void face_set_direction(face* face, vec3* value) {
|
||||
face->direction = *value;
|
||||
void face::get_direction(vec3& value) {
|
||||
value = direction;
|
||||
}
|
||||
|
||||
void face::set_direction(vec3& value) {
|
||||
direction = value;
|
||||
}
|
||||
|
||||
void face::set_direction(vec3&& value) {
|
||||
direction = value;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/face.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../static_var.h"
|
||||
#include "../static_var.hpp"
|
||||
|
||||
struct face {
|
||||
float_t offset;
|
||||
@@ -17,13 +17,15 @@ struct face {
|
||||
vec3 direction;
|
||||
|
||||
face();
|
||||
};
|
||||
|
||||
extern float_t face_get_offset(face* face);
|
||||
extern void face_set_offset(face* face, float_t value);
|
||||
extern float_t face_get_scale(face* face);
|
||||
extern void face_set_scale(face* face, float_t value);
|
||||
extern void face_get_position(face* face, vec3* value);
|
||||
extern void face_set_position(face* face, vec3* value);
|
||||
extern void face_get_direction(face* face, vec3* value);
|
||||
extern void face_set_direction(face* face, vec3* value);
|
||||
float_t get_offset();
|
||||
void set_offset(float_t value);
|
||||
float_t get_scale();
|
||||
void set_scale(float_t value);
|
||||
void get_position(vec3& value);
|
||||
void set_position(vec3& value);
|
||||
void set_position(vec3&& value);
|
||||
void get_direction(vec3& value);
|
||||
void set_direction(vec3& value);
|
||||
void set_direction(vec3&& value);
|
||||
};
|
||||
|
||||
+36
-32
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
#include "fog.hpp"
|
||||
#include "../shader_ft.h"
|
||||
#include "../shader_ft.hpp"
|
||||
|
||||
fog::fog() {
|
||||
type = FOG_NONE;
|
||||
@@ -15,62 +15,66 @@ fog::fog() {
|
||||
color = { 1.0f, 1.0f, 1.0f, 0.0f };
|
||||
}
|
||||
|
||||
inline fog_type fog_get_type(fog* fog) {
|
||||
return fog->type;
|
||||
fog_type fog::get_type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
inline void fog_set_type(fog* fog, fog_type value) {
|
||||
fog->type = value;
|
||||
void fog::set_type(fog_type value) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
inline float_t fog_get_density(fog* fog) {
|
||||
return fog->density;
|
||||
float_t fog::get_density() {
|
||||
return density;
|
||||
}
|
||||
|
||||
inline void fog_set_density(fog* fog, float_t value) {
|
||||
fog->density = value;
|
||||
void fog::set_density(float_t value) {
|
||||
density = value;
|
||||
}
|
||||
|
||||
inline float_t fog_get_start(fog* fog) {
|
||||
return fog->start;
|
||||
float_t fog::get_start() {
|
||||
return start;
|
||||
}
|
||||
|
||||
inline void fog_set_start(fog* fog, float_t value) {
|
||||
fog->start = value;
|
||||
void fog::set_start(float_t value) {
|
||||
start = value;
|
||||
}
|
||||
|
||||
inline float_t fog_get_end(fog* fog) {
|
||||
return fog->end;
|
||||
float_t fog::get_end() {
|
||||
return end;
|
||||
}
|
||||
|
||||
inline void fog_set_end(fog* fog, float_t value) {
|
||||
fog->end = value;
|
||||
void fog::set_end(float_t value) {
|
||||
end = value;
|
||||
}
|
||||
|
||||
inline int32_t fog_get_index(fog* fog) {
|
||||
return fog->index;
|
||||
int32_t fog::get_index() {
|
||||
return index;
|
||||
}
|
||||
|
||||
inline void fog_set_index(fog* fog, int32_t value) {
|
||||
fog->index = value;
|
||||
void fog::set_index(int32_t value) {
|
||||
index = value;
|
||||
}
|
||||
|
||||
inline void fog_get_color(fog* fog, vec4* value) {
|
||||
*value = fog->color;
|
||||
void fog::get_color(vec4& value) {
|
||||
value = color;
|
||||
}
|
||||
|
||||
inline void fog_set_color(fog* fog, vec4* value) {
|
||||
fog->color = *value;
|
||||
void fog::set_color(vec4& value) {
|
||||
color = value;
|
||||
}
|
||||
|
||||
void fog_data_set(fog* fog, fog_id id) {
|
||||
fog_type type = fog_get_type(fog);
|
||||
void fog::set_color(vec4&& value) {
|
||||
color = value;
|
||||
}
|
||||
|
||||
void fog::data_set(fog_id id) {
|
||||
fog_type type = get_type();
|
||||
if (type == FOG_NONE)
|
||||
return;
|
||||
|
||||
float_t density = fog_get_density(fog);
|
||||
float_t start = fog_get_start(fog);
|
||||
float_t end = fog_get_end(fog);
|
||||
float_t density = get_density();
|
||||
float_t start = get_start();
|
||||
float_t end = get_end();
|
||||
if (start >= end)
|
||||
start = end - 0.01f;
|
||||
|
||||
@@ -83,7 +87,7 @@ void fog_data_set(fog* fog, fog_id id) {
|
||||
switch (id) {
|
||||
case FOG_DEPTH: {
|
||||
vec4 color;
|
||||
fog_get_color(fog, &color);
|
||||
get_color(color);
|
||||
shaders_ft.env_vert_set(29, color);
|
||||
shaders_ft.env_frag_set(4, color);
|
||||
|
||||
@@ -93,7 +97,7 @@ void fog_data_set(fog* fog, fog_id id) {
|
||||
} break;
|
||||
case FOG_HEIGHT: {
|
||||
vec4 color;
|
||||
fog_get_color(fog, &color);
|
||||
get_color(color);
|
||||
shaders_ft.env_vert_set(30, color);
|
||||
shaders_ft.env_frag_set(11, color);
|
||||
shaders_ft.env_vert_set(14, params);
|
||||
|
||||
+16
-15
@@ -8,7 +8,7 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/fog.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../static_var.h"
|
||||
#include "../static_var.hpp"
|
||||
|
||||
struct fog {
|
||||
fog_type type;
|
||||
@@ -19,18 +19,19 @@ struct fog {
|
||||
vec4 color;
|
||||
|
||||
fog();
|
||||
};
|
||||
|
||||
extern fog_type fog_get_type(fog* fog);
|
||||
extern void fog_set_type(fog* fog, fog_type value);
|
||||
extern float_t fog_get_density(fog* fog);
|
||||
extern void fog_set_density(fog* fog, float_t value);
|
||||
extern float_t fog_get_start(fog* fog);
|
||||
extern void fog_set_start(fog* fog, float_t value);
|
||||
extern float_t fog_get_end(fog* fog);
|
||||
extern void fog_set_end(fog* fog, float_t value);
|
||||
extern int32_t fog_get_index(fog* fog);
|
||||
extern void fog_set_index(fog* fog, int32_t value);
|
||||
extern void fog_get_color(fog* fog, vec4* value);
|
||||
extern void fog_set_color(fog* fog, vec4* value);
|
||||
extern void fog_data_set(fog* fog, fog_id id);
|
||||
fog_type get_type();
|
||||
void set_type(fog_type value);
|
||||
float_t get_density();
|
||||
void set_density(float_t value);
|
||||
float_t get_start();
|
||||
void set_start(float_t value);
|
||||
float_t get_end();
|
||||
void set_end(float_t value);
|
||||
int32_t get_index();
|
||||
void set_index(int32_t value);
|
||||
void get_color(vec4& value);
|
||||
void set_color(vec4& value);
|
||||
void set_color(vec4&& value);
|
||||
void data_set(fog_id id);
|
||||
};
|
||||
|
||||
+209
-167
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "light.hpp"
|
||||
#include "../../KKdLib/mat.hpp"
|
||||
#include "../shader_ft.h"
|
||||
#include "../shader_ft.hpp"
|
||||
|
||||
extern bool light_chara_ambient;
|
||||
extern vec4 npr_spec_color;
|
||||
@@ -15,231 +15,272 @@ static void light_get_direction_from_position(vec4* pos_dir, light_data* light,
|
||||
light_data::light_data() : type(), ambient(), diffuse(), specular(), position(),
|
||||
spot_direction(), spot_exponent(), spot_cutoff(), constant(), linear(), quadratic(),
|
||||
ibl_specular(), ibl_back(), ibl_direction(), tone_curve(),clip_plane() {
|
||||
vec3 temp3;
|
||||
vec4 temp4;
|
||||
light_set_type(this, LIGHT_OFF);
|
||||
temp4 = { 0.0f, 0.0, 0.0f, 1.0f };
|
||||
light_set_ambient(this, &temp4);
|
||||
temp4 = { 1.0f, 1.0, 1.0f, 0.0f };
|
||||
light_set_diffuse(this, &temp4);
|
||||
temp4 = { 1.0f, 1.0f, 1.0f, 0.0f };
|
||||
light_set_specular(this, &temp4);
|
||||
temp3 = { 0.0f, 1.0f, 1.0f };
|
||||
light_set_position(this, &temp3);
|
||||
temp3 = { 0.0f, 0.0f, -1.0f };
|
||||
light_set_spot_direction(this, &temp3);
|
||||
light_set_spot_exponent(this, 0.0f);
|
||||
light_set_spot_cutoff(this, 45.0f);
|
||||
light_set_constant(this, 1.0f);
|
||||
light_set_linear(this, 0.0f);
|
||||
light_set_quadratic(this, 0.0f);
|
||||
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
light_set_ibl_specular(this, &temp4);
|
||||
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
light_set_ibl_back(this, &temp4);
|
||||
temp4 = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
light_set_ibl_direction(this, &temp4);
|
||||
temp3 = { 0.0f, 0.0f, 0.0f };
|
||||
light_set_tone_curve(this, &temp3);
|
||||
set_type(LIGHT_OFF);
|
||||
set_ambient({ 0.0f, 0.0, 0.0f, 1.0f });
|
||||
set_diffuse({ 1.0f, 1.0, 1.0f, 0.0f });
|
||||
set_specular({ 1.0f, 1.0f, 1.0f, 0.0f });
|
||||
set_position({ 0.0f, 1.0f, 1.0f, 0.0f });
|
||||
set_spot_direction({ 0.0f, 0.0f, -1.0f });
|
||||
set_spot_exponent(0.0f);
|
||||
set_spot_cutoff(45.0f);
|
||||
set_constant(1.0f);
|
||||
set_linear(0.0f);
|
||||
set_quadratic(0.0f);
|
||||
set_ibl_specular({ 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
set_ibl_back({ 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
set_ibl_direction({ 0.0f, 0.0f, 0.0f, 0.0f });
|
||||
set_tone_curve({ 0.0f, 0.0f, 0.0f });
|
||||
}
|
||||
|
||||
light_set::light_set() : ambient_intensity(),
|
||||
irradiance_r(), irradiance_g(), irradiance_b() {
|
||||
vec4 temp;
|
||||
temp = { 0.2f, 0.2f, 0.2f, 1.0f };
|
||||
light_set_set_ambient_intensity(this, &temp);
|
||||
temp = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
light_set_diffuse(&lights[LIGHT_CHARA], &temp);
|
||||
temp = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
light_set_specular(&lights[LIGHT_CHARA], &temp);
|
||||
light_set_set_irradiance(this, &mat4_identity, &mat4_identity, &mat4_identity);
|
||||
set_ambient_intensity({ 0.2f, 0.2f, 0.2f, 1.0f });
|
||||
lights[LIGHT_CHARA].set_diffuse({ 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
lights[LIGHT_CHARA].set_specular({ 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
set_irradiance(mat4_identity, mat4_identity, mat4_identity);
|
||||
}
|
||||
|
||||
inline light_type light_get_type(light_data* light) {
|
||||
return light->type;
|
||||
light_type light_data::get_type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
inline void light_set_type(light_data* light, light_type value) {
|
||||
light->type = value;
|
||||
void light_data::set_type(light_type value) {
|
||||
type = value;
|
||||
if (value < LIGHT_POINT)
|
||||
light->position.w = 0.0f;
|
||||
position.w = 0.0f;
|
||||
else
|
||||
light->position.w = 1.0f;
|
||||
position.w = 1.0f;
|
||||
}
|
||||
|
||||
inline void light_get_ambient(light_data* light, vec4* value) {
|
||||
*value = light->ambient;
|
||||
void light_data::get_ambient(vec4& value) {
|
||||
value = ambient;
|
||||
}
|
||||
|
||||
inline void light_set_ambient(light_data* light, const vec4* value) {
|
||||
light->ambient = *value;
|
||||
void light_data::set_ambient(const vec4& value) {
|
||||
ambient = value;
|
||||
}
|
||||
|
||||
inline void light_get_diffuse(light_data* light, vec4* value) {
|
||||
*value = light->diffuse;
|
||||
void light_data::set_ambient(const vec4&& value) {
|
||||
ambient = value;
|
||||
}
|
||||
|
||||
inline void light_set_diffuse(light_data* light, const vec4* value) {
|
||||
light->diffuse = *value;
|
||||
void light_data::get_diffuse(vec4& value) {
|
||||
value = diffuse;
|
||||
}
|
||||
|
||||
inline void light_get_specular(light_data* light, vec4* value) {
|
||||
*value = light->specular;
|
||||
void light_data::set_diffuse(const vec4& value) {
|
||||
diffuse = value;
|
||||
}
|
||||
|
||||
inline void light_set_specular(light_data* light, const vec4* value) {
|
||||
light->specular = *value;
|
||||
void light_data::set_diffuse(const vec4&& value) {
|
||||
diffuse = value;
|
||||
}
|
||||
|
||||
inline void light_get_position(light_data* light, vec3* value) {
|
||||
*value = *(vec3*)&light->position;
|
||||
void light_data::get_specular(vec4& value) {
|
||||
value = specular;
|
||||
}
|
||||
|
||||
inline void light_set_position(light_data* light, const vec3* value) {
|
||||
*(vec3*)&light->position = *value;
|
||||
void light_data::set_specular(const vec4& value) {
|
||||
specular = value;
|
||||
}
|
||||
|
||||
inline void light_get_position_vec4(light_data* light, vec4* value) {
|
||||
*value = light->position;
|
||||
void light_data::set_specular(const vec4&& value) {
|
||||
specular = value;
|
||||
}
|
||||
|
||||
inline void light_set_position_vec4(light_data* light, const vec4* value) {
|
||||
light->position = *value;
|
||||
void light_data::get_position(vec3& value) {
|
||||
value = *(vec3*)&position;
|
||||
}
|
||||
|
||||
inline void light_get_spot_direction(light_data* light, vec3* value) {
|
||||
*value = light->spot_direction;
|
||||
void light_data::set_position(const vec3& value) {
|
||||
*(vec3*)&position = value;
|
||||
}
|
||||
|
||||
inline void light_set_spot_direction(light_data* light, const vec3* value) {
|
||||
light->spot_direction = *value;
|
||||
void light_data::set_position(const vec3&& value) {
|
||||
*(vec3*)&position = value;
|
||||
}
|
||||
|
||||
inline float_t light_get_spot_exponent(light_data* light) {
|
||||
return light->spot_exponent;
|
||||
void light_data::get_position(vec4& value) {
|
||||
value = position;
|
||||
}
|
||||
|
||||
inline void light_set_spot_exponent(light_data* light, float_t value) {
|
||||
light->spot_exponent = value;
|
||||
void light_data::set_position(const vec4& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
inline float_t light_get_spot_cutoff(light_data* light) {
|
||||
return light->spot_cutoff;
|
||||
void light_data::set_position(const vec4&& value) {
|
||||
position = value;
|
||||
}
|
||||
|
||||
inline void light_set_spot_cutoff(light_data* light, float_t value) {
|
||||
light->spot_cutoff = value;
|
||||
void light_data::get_spot_direction(vec3& value) {
|
||||
value = spot_direction;
|
||||
}
|
||||
|
||||
inline float_t light_get_constant(light_data* light) {
|
||||
return light->constant;
|
||||
void light_data::set_spot_direction(const vec3& value) {
|
||||
spot_direction = value;
|
||||
}
|
||||
|
||||
inline void light_set_constant(light_data* light, float_t value) {
|
||||
light->constant = value;
|
||||
void light_data::set_spot_direction(const vec3&& value) {
|
||||
spot_direction = value;
|
||||
}
|
||||
|
||||
inline float_t light_get_linear(light_data* light) {
|
||||
return light->linear;
|
||||
float_t light_data::get_spot_exponent() {
|
||||
return spot_exponent;
|
||||
}
|
||||
|
||||
inline void light_set_linear(light_data* light, float_t value) {
|
||||
light->linear = value;
|
||||
void light_data::set_spot_exponent(float_t value) {
|
||||
spot_exponent = value;
|
||||
}
|
||||
|
||||
inline float_t light_get_quadratic(light_data* light) {
|
||||
return light->quadratic;
|
||||
float_t light_data::get_spot_cutoff() {
|
||||
return spot_cutoff;
|
||||
}
|
||||
|
||||
inline void light_set_quadratic(light_data* light, float_t value) {
|
||||
light->quadratic = value;
|
||||
void light_data::set_spot_cutoff(float_t value) {
|
||||
spot_cutoff = value;
|
||||
}
|
||||
|
||||
inline void light_get_attenuation(light_data* light, vec3* value) {
|
||||
value->x = light->constant;
|
||||
value->y = light->linear;
|
||||
value->z = light->quadratic;
|
||||
float_t light_data::get_constant() {
|
||||
return constant;
|
||||
}
|
||||
|
||||
inline void light_set_attenuation(light_data* light, const vec3* value) {
|
||||
light->constant = value->x;
|
||||
light->linear = value->y;
|
||||
light->quadratic = value->z;
|
||||
void light_data::set_constant(float_t value) {
|
||||
constant = value;
|
||||
}
|
||||
|
||||
inline void light_get_ibl_specular(light_data* light, vec4* value) {
|
||||
*value = light->ibl_specular;
|
||||
float_t light_data::get_linear() {
|
||||
return linear;
|
||||
}
|
||||
|
||||
inline void light_set_ibl_specular(light_data* light, const vec4* value) {
|
||||
light->ibl_specular = *value;
|
||||
void light_data::set_linear(float_t value) {
|
||||
linear = value;
|
||||
}
|
||||
|
||||
inline void light_get_ibl_back(light_data* light, vec4* value) {
|
||||
*value = light->ibl_back;
|
||||
float_t light_data::get_quadratic() {
|
||||
return quadratic;
|
||||
}
|
||||
|
||||
inline void light_set_ibl_back(light_data* light, const vec4* value) {
|
||||
light->ibl_back = *value;
|
||||
void light_data::set_quadratic(float_t value) {
|
||||
quadratic = value;
|
||||
}
|
||||
|
||||
inline void light_get_ibl_direction(light_data* light, vec4* value) {
|
||||
*value = light->ibl_direction;
|
||||
void light_data::get_attenuation(vec3& value) {
|
||||
value.x = constant;
|
||||
value.y = linear;
|
||||
value.z = quadratic;
|
||||
}
|
||||
|
||||
inline void light_set_ibl_direction(light_data* light, const vec4* value) {
|
||||
light->ibl_direction = *value;
|
||||
void light_data::set_attenuation(const vec3& value) {
|
||||
constant = value.x;
|
||||
linear = value.y;
|
||||
quadratic = value.z;
|
||||
}
|
||||
|
||||
inline void light_get_tone_curve(light_data* light, vec3* value) {
|
||||
*value = light->tone_curve;
|
||||
void light_data::set_attenuation(const vec3&& value) {
|
||||
constant = value.x;
|
||||
linear = value.y;
|
||||
quadratic = value.z;
|
||||
}
|
||||
|
||||
inline void light_set_tone_curve(light_data* light, const vec3* value) {
|
||||
light->tone_curve = *value;
|
||||
void light_data::get_ibl_specular(vec4& value) {
|
||||
value = ibl_specular;
|
||||
}
|
||||
|
||||
inline void light_get_clip_plane(light_data* light, bool value[4]) {
|
||||
value[0] = light->clip_plane[0];
|
||||
value[1] = light->clip_plane[1];
|
||||
value[2] = light->clip_plane[2];
|
||||
value[3] = light->clip_plane[3];
|
||||
void light_data::set_ibl_specular(const vec4& value) {
|
||||
ibl_specular = value;
|
||||
}
|
||||
|
||||
inline void light_set_clip_plane(light_data* light, const bool value[4]) {
|
||||
light->clip_plane[0] = value[0];
|
||||
light->clip_plane[1] = value[1];
|
||||
light->clip_plane[2] = value[2];
|
||||
light->clip_plane[3] = value[3];
|
||||
void light_data::set_ibl_specular(const vec4&& value) {
|
||||
ibl_specular = value;
|
||||
}
|
||||
|
||||
inline void light_set_get_ambient_intensity(light_set* set, vec4* value) {
|
||||
*value = set->ambient_intensity;
|
||||
void light_data::get_ibl_back(vec4& value) {
|
||||
value = ibl_back;
|
||||
}
|
||||
|
||||
inline void light_set_set_ambient_intensity(light_set* set, const vec4* value) {
|
||||
set->ambient_intensity = *value;
|
||||
void light_data::set_ibl_back(const vec4& value) {
|
||||
ibl_back = value;
|
||||
}
|
||||
|
||||
inline void light_set_get_irradiance(light_set* set, mat4* r, mat4* g, mat4* b) {
|
||||
*r = set->irradiance_r;
|
||||
*g = set->irradiance_g;
|
||||
*b = set->irradiance_b;
|
||||
void light_data::set_ibl_back(const vec4&& value) {
|
||||
ibl_back = value;
|
||||
}
|
||||
|
||||
inline void light_set_set_irradiance(light_set* set, const mat4* r, const mat4* g, const mat4* b) {
|
||||
set->irradiance_r = *r;
|
||||
set->irradiance_g = *g;
|
||||
set->irradiance_b = *b;
|
||||
void light_data::get_ibl_direction(vec4& value) {
|
||||
value = ibl_direction;
|
||||
}
|
||||
|
||||
void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
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(vec3& value) {
|
||||
value = tone_curve;
|
||||
}
|
||||
|
||||
void light_data::set_tone_curve(const vec3& value) {
|
||||
tone_curve = value;
|
||||
}
|
||||
|
||||
void light_data::set_tone_curve(const vec3&& value) {
|
||||
tone_curve = value;
|
||||
}
|
||||
|
||||
void light_data::get_clip_plane(bool value[4]) {
|
||||
value[0] = clip_plane[0];
|
||||
value[1] = clip_plane[1];
|
||||
value[2] = clip_plane[2];
|
||||
value[3] = clip_plane[3];
|
||||
}
|
||||
|
||||
void light_data::set_clip_plane(const bool value[4]) {
|
||||
clip_plane[0] = value[0];
|
||||
clip_plane[1] = value[1];
|
||||
clip_plane[2] = value[2];
|
||||
clip_plane[3] = value[3];
|
||||
}
|
||||
|
||||
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(face& face, light_set_id id) {
|
||||
vec4 ambient_intensity;
|
||||
light_set_get_ambient_intensity(set, &ambient_intensity);
|
||||
get_ambient_intensity(ambient_intensity);
|
||||
shaders_ft.state_lightmodel_set_ambient(false, ambient_intensity);
|
||||
|
||||
for (int32_t i = LIGHT_CHARA; i <= LIGHT_PROJECTION; i++) {
|
||||
light_data* light = &set->lights[i];
|
||||
light_data* light = &lights[i];
|
||||
if (light_chara_ambient || i != LIGHT_CHARA) {
|
||||
vec4 ambient = light->ambient;
|
||||
shaders_ft.state_light_set_ambient(i, ambient);
|
||||
@@ -276,12 +317,12 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
vec4 ibl_back;
|
||||
vec4 ibl_direction;
|
||||
vec4 temp;
|
||||
light_get_position_vec4(&set->lights[LIGHT_CHARA], &position);
|
||||
light_get_direction_from_position(&position, &set->lights[LIGHT_CHARA], false);
|
||||
light_get_ibl_specular(&set->lights[LIGHT_CHARA], &ibl_specular);
|
||||
light_get_ibl_back(&set->lights[LIGHT_CHARA], &ibl_back);
|
||||
light_get_diffuse(&set->lights[LIGHT_CHARA], &diffuse);
|
||||
light_get_specular(&set->lights[LIGHT_CHARA], &specular);
|
||||
lights[LIGHT_CHARA].get_position(position);
|
||||
light_get_direction_from_position(&position, &lights[LIGHT_CHARA], false);
|
||||
lights[LIGHT_CHARA].get_ibl_specular(ibl_specular);
|
||||
lights[LIGHT_CHARA].get_ibl_back(ibl_back);
|
||||
lights[LIGHT_CHARA].get_diffuse(diffuse);
|
||||
lights[LIGHT_CHARA].get_specular(specular);
|
||||
|
||||
shaders_ft.env_vert_set(5, position);
|
||||
shaders_ft.env_frag_set(5, position);
|
||||
@@ -304,11 +345,11 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
shaders_ft.env_vert_set(9, temp);
|
||||
shaders_ft.env_frag_set(9, temp);
|
||||
|
||||
light_get_position_vec4(&set->lights[LIGHT_STAGE], &position);
|
||||
light_get_direction_from_position(&position, &set->lights[LIGHT_STAGE], false);
|
||||
light_get_ibl_specular(&set->lights[LIGHT_STAGE], &ibl_specular);
|
||||
light_get_diffuse(&set->lights[LIGHT_STAGE], &diffuse);
|
||||
light_get_specular(&set->lights[LIGHT_STAGE], &specular);
|
||||
lights[LIGHT_STAGE].get_position(position);
|
||||
light_get_direction_from_position(&position, &lights[LIGHT_STAGE], false);
|
||||
lights[LIGHT_STAGE].get_ibl_specular(ibl_specular);
|
||||
lights[LIGHT_STAGE].get_diffuse(diffuse);
|
||||
lights[LIGHT_STAGE].get_specular(specular);
|
||||
|
||||
shaders_ft.env_vert_set(10, position);
|
||||
shaders_ft.env_frag_set(14, position);
|
||||
@@ -325,20 +366,20 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
mat4 irradiance_r;
|
||||
mat4 irradiance_g;
|
||||
mat4 irradiance_b;
|
||||
light_set_get_irradiance(set, &irradiance_r, &irradiance_g, &irradiance_b);
|
||||
get_irradiance(irradiance_r, irradiance_g, irradiance_b);
|
||||
shaders_ft.state_matrix_set_program(0, irradiance_r);
|
||||
shaders_ft.state_matrix_set_program(1, irradiance_g);
|
||||
shaders_ft.state_matrix_set_program(2, irradiance_b);
|
||||
|
||||
float_t offset = face_get_offset(face);
|
||||
float_t offset = face.get_offset();
|
||||
float_t v28 = (float_t)(1.0 - exp(offset * -0.44999999)) * 2.0f;
|
||||
offset = max(offset, 0.0f);
|
||||
shaders_ft.env_vert_set(0x11, v28 * 0.1f, offset * 0.06f, 1.0, 1.0);
|
||||
|
||||
if (light_get_type(&set->lights[LIGHT_CHARA_COLOR]) == LIGHT_PARALLEL) {
|
||||
light_get_ambient(&set->lights[LIGHT_CHARA_COLOR], &ambient);
|
||||
light_get_diffuse(&set->lights[LIGHT_CHARA_COLOR], &diffuse);
|
||||
light_get_specular(&set->lights[LIGHT_CHARA_COLOR], &specular);
|
||||
if (lights[LIGHT_CHARA_COLOR].get_type() == LIGHT_PARALLEL) {
|
||||
lights[LIGHT_CHARA_COLOR].get_ambient(ambient);
|
||||
lights[LIGHT_CHARA_COLOR].get_diffuse(diffuse);
|
||||
lights[LIGHT_CHARA_COLOR].get_specular(specular);
|
||||
if (specular.w > 1.0)
|
||||
specular.w = 1.0;
|
||||
shaders_ft.env_frag_set(33, ambient);
|
||||
@@ -351,15 +392,16 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
shaders_ft.env_frag_set(35, vec4_null);
|
||||
}
|
||||
|
||||
if (light_get_type(&set->lights[LIGHT_TONE_CURVE]) == LIGHT_PARALLEL) {
|
||||
if (lights[LIGHT_TONE_CURVE].get_type() == LIGHT_PARALLEL) {
|
||||
uniform_value[U_TONE_CURVE] = 1;
|
||||
light_get_position_vec4(&set->lights[LIGHT_TONE_CURVE], &position);
|
||||
light_get_direction_from_position(&position, &set->lights[LIGHT_TONE_CURVE], false);
|
||||
light_get_ambient(&set->lights[LIGHT_TONE_CURVE], &ambient);
|
||||
light_get_diffuse(&set->lights[LIGHT_TONE_CURVE], &diffuse);
|
||||
light_get_specular(&set->lights[LIGHT_TONE_CURVE], &specular);
|
||||
lights[LIGHT_TONE_CURVE].get_position(position);
|
||||
light_get_direction_from_position(&position, &lights[LIGHT_TONE_CURVE], false);
|
||||
lights[LIGHT_TONE_CURVE].get_ambient(ambient);
|
||||
lights[LIGHT_TONE_CURVE].get_diffuse(diffuse);
|
||||
lights[LIGHT_TONE_CURVE].get_specular(specular);
|
||||
|
||||
vec3 tone_curve;
|
||||
light_get_tone_curve(&set->lights[LIGHT_TONE_CURVE], &tone_curve);
|
||||
lights[LIGHT_TONE_CURVE].get_tone_curve(tone_curve);
|
||||
tone_curve.y = min(tone_curve.y, 1.0f) - tone_curve.x;
|
||||
if (tone_curve.y > 0.0f)
|
||||
tone_curve.y = 1.0f / tone_curve.y;
|
||||
@@ -381,7 +423,7 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
shaders_ft.env_frag_set(40, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
light_get_position_vec4(&set->lights[LIGHT_CHARA], &position);
|
||||
lights[LIGHT_CHARA].get_position(position);
|
||||
if (fabs(position.x) <= 0.000001f && fabs(position.z) <= 0.000001f && fabs(position.z) <= 0.000001f)
|
||||
position = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
else {
|
||||
@@ -394,19 +436,19 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
shaders_ft.env_vert_set(15, position.x, position.y, position.z, 1.0f);
|
||||
shaders_ft.env_vert_set(16, -position.x, -position.y, -position.z, 1.0f);
|
||||
|
||||
if (light_get_type(&set->lights[LIGHT_REFLECT]) == LIGHT_SPOT) {
|
||||
if (lights[LIGHT_REFLECT].get_type() == LIGHT_SPOT) {
|
||||
vec4 spot_direction;
|
||||
light_get_spot_direction(&set->lights[LIGHT_REFLECT], (vec3*)&spot_direction);
|
||||
lights[LIGHT_REFLECT].get_spot_direction(*(vec3*)&spot_direction);
|
||||
vec3_negate(*(vec3*)&spot_direction, *(vec3*)&spot_direction);
|
||||
light_get_direction_from_position(&spot_direction, &set->lights[LIGHT_REFLECT], true);
|
||||
light_get_position_vec4(&set->lights[LIGHT_REFLECT], &position);
|
||||
light_get_direction_from_position(&spot_direction, &lights[LIGHT_REFLECT], true);
|
||||
lights[LIGHT_REFLECT].get_position(position);
|
||||
vec3_dot(*(vec3*)&position, *(vec3*)&spot_direction, spot_direction.w);
|
||||
spot_direction.w = -spot_direction.w;
|
||||
|
||||
shaders_ft.env_vert_set(28, spot_direction);
|
||||
shaders_ft.env_frag_set(22, spot_direction);
|
||||
}
|
||||
else if (light_get_type(&set->lights[LIGHT_REFLECT]) == LIGHT_POINT) {
|
||||
else if (lights[LIGHT_REFLECT].get_type() == LIGHT_POINT) {
|
||||
shaders_ft.env_vert_set(28, 0.0f, -1.0f, 0.0f, 9999.0f);
|
||||
shaders_ft.env_frag_set(22, 0.0f, -1.0f, 0.0f, 9999.0f);
|
||||
}
|
||||
@@ -418,8 +460,8 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
mat4 v63 = mat4_identity;
|
||||
mat4 v64 = mat4_identity;
|
||||
|
||||
light_get_ibl_direction(&set->lights[LIGHT_CHARA], &ibl_direction);
|
||||
light_get_position_vec4(&set->lights[LIGHT_CHARA], &position);
|
||||
lights[LIGHT_CHARA].get_ibl_direction(ibl_direction);
|
||||
lights[LIGHT_CHARA].get_position(position);
|
||||
|
||||
float_t length;
|
||||
vec3_length(*(vec3*)&ibl_direction, length);
|
||||
@@ -457,7 +499,7 @@ void light_set_data_set(light_set* set, face* face, light_set_id id) {
|
||||
}
|
||||
|
||||
static void light_get_direction_from_position(vec4* pos_dir, light_data* light, bool force) {
|
||||
if (force || light_get_type(light) == LIGHT_PARALLEL) {
|
||||
if (force || light->get_type() == LIGHT_PARALLEL) {
|
||||
float_t length;
|
||||
vec3_length(*(vec3*)pos_dir, length);
|
||||
if (length <= 0.000001)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/light.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../static_var.h"
|
||||
#include "../static_var.hpp"
|
||||
#include "face.hpp"
|
||||
|
||||
struct light_data {
|
||||
@@ -30,6 +30,54 @@ struct light_data {
|
||||
bool clip_plane[4];
|
||||
|
||||
light_data();
|
||||
|
||||
light_type get_type();
|
||||
void set_type(light_type value);
|
||||
void get_ambient(vec4& value);
|
||||
void set_ambient(const vec4& value);
|
||||
void set_ambient(const vec4&& value);
|
||||
void get_diffuse(vec4& value);
|
||||
void set_diffuse(const vec4& value);
|
||||
void set_diffuse(const vec4&& value);
|
||||
void get_specular(vec4& value);
|
||||
void set_specular(const vec4& value);
|
||||
void set_specular(const vec4&& value);
|
||||
void get_position(vec3& value);
|
||||
void set_position(const vec3& value);
|
||||
void set_position(const vec3&& value);
|
||||
void get_position(vec4& value);
|
||||
void set_position(const vec4& value);
|
||||
void set_position(const vec4&& value);
|
||||
void get_spot_direction(vec3& value);
|
||||
void set_spot_direction(const vec3& value);
|
||||
void set_spot_direction(const vec3&& value);
|
||||
float_t get_spot_exponent();
|
||||
void set_spot_exponent(float_t value);
|
||||
float_t get_spot_cutoff();
|
||||
void set_spot_cutoff(float_t value);
|
||||
float_t get_constant();
|
||||
void set_constant(float_t value);
|
||||
float_t get_linear();
|
||||
void set_linear(float_t value);
|
||||
float_t get_quadratic();
|
||||
void set_quadratic(float_t value);
|
||||
void get_attenuation(vec3& value);
|
||||
void set_attenuation(const vec3& value);
|
||||
void set_attenuation(const vec3&& value);
|
||||
void get_ibl_specular(vec4& value);
|
||||
void set_ibl_specular(const vec4& value);
|
||||
void set_ibl_specular(const vec4&& value);
|
||||
void get_ibl_back(vec4& value);
|
||||
void set_ibl_back(const vec4& value);
|
||||
void set_ibl_back(const vec4&& value);
|
||||
void get_ibl_direction(vec4& value);
|
||||
void set_ibl_direction(const vec4& value);
|
||||
void set_ibl_direction(const vec4&& value);
|
||||
void get_tone_curve(vec3& value);
|
||||
void set_tone_curve(const vec3& value);
|
||||
void set_tone_curve(const vec3&& value);
|
||||
void get_clip_plane(bool value[4]);
|
||||
void set_clip_plane(const bool value[4]);
|
||||
};
|
||||
|
||||
struct light_set {
|
||||
@@ -40,45 +88,12 @@ struct light_set {
|
||||
mat4u irradiance_b;
|
||||
|
||||
light_set();
|
||||
|
||||
void get_ambient_intensity(vec4& value);
|
||||
void set_ambient_intensity(const vec4& value);
|
||||
void set_ambient_intensity(const vec4&& value);
|
||||
void get_irradiance(mat4& r, mat4& g, mat4& b);
|
||||
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(face& face, light_set_id id);
|
||||
};
|
||||
extern light_type light_get_type(light_data* light);
|
||||
extern void light_set_type(light_data* light, light_type value);
|
||||
extern void light_get_ambient(light_data* light, vec4* value);
|
||||
extern void light_set_ambient(light_data* light, const vec4* value);
|
||||
extern void light_get_diffuse(light_data* light, vec4* value);
|
||||
extern void light_set_diffuse(light_data* light, const vec4* value);
|
||||
extern void light_get_specular(light_data* light, vec4* value);
|
||||
extern void light_set_specular(light_data* light, const vec4* value);
|
||||
extern void light_get_position(light_data* light, vec3* value);
|
||||
extern void light_set_position(light_data* light, const vec3* value);
|
||||
extern void light_get_position_vec4(light_data* light, vec4* value);
|
||||
extern void light_set_position_vec4(light_data* light, const vec4* value);
|
||||
extern void light_get_spot_direction(light_data* light, vec3* value);
|
||||
extern void light_set_spot_direction(light_data* light, const vec3* value);
|
||||
extern float_t light_get_spot_exponent(light_data* light);
|
||||
extern void light_set_spot_exponent(light_data* light, float_t value);
|
||||
extern float_t light_get_spot_cutoff(light_data* light);
|
||||
extern void light_set_spot_cutoff(light_data* light, float_t value);
|
||||
extern float_t light_get_constant(light_data* light);
|
||||
extern void light_set_constant(light_data* light, float_t value);
|
||||
extern float_t light_get_linear(light_data* light);
|
||||
extern void light_set_linear(light_data* light, float_t value);
|
||||
extern float_t light_get_quadratic(light_data* light);
|
||||
extern void light_set_quadratic(light_data* light, float_t value);
|
||||
extern void light_get_attenuation(light_data* light, vec3* value);
|
||||
extern void light_set_attenuation(light_data* light, const vec3* value);
|
||||
extern void light_get_ibl_specular(light_data* light, vec4* value);
|
||||
extern void light_set_ibl_specular(light_data* light, const vec4* value);
|
||||
extern void light_get_ibl_back(light_data* light, vec4* value);
|
||||
extern void light_set_ibl_back(light_data* light, const vec4* value);
|
||||
extern void light_get_ibl_direction(light_data* light, vec4* value);
|
||||
extern void light_set_ibl_direction(light_data* light, const vec4* value);
|
||||
extern void light_get_tone_curve(light_data* light, vec3* value);
|
||||
extern void light_set_tone_curve(light_data* light, const vec3* value);
|
||||
extern void light_get_clip_plane(light_data* light, bool value[4]);
|
||||
extern void light_set_clip_plane(light_data* light, const bool value[4]);
|
||||
extern void light_set_get_ambient_intensity(light_set* set, vec4* value);
|
||||
extern void light_set_set_ambient_intensity(light_set* set, const vec4* value);
|
||||
extern void light_set_get_irradiance(light_set* set, mat4* r, mat4* g, mat4* b);
|
||||
extern void light_set_set_irradiance(light_set* set, const mat4* r, const mat4* g, const mat4* b);
|
||||
extern void light_set_data_set(light_set* set, face* face, light_set_id id);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "../../KKdLib/default.hpp"
|
||||
#include "../../KKdLib/light_param/wind.hpp"
|
||||
#include "../../KKdLib/vec.hpp"
|
||||
#include "../static_var.h"
|
||||
#include "../static_var.hpp"
|
||||
#include "../task.hpp"
|
||||
|
||||
struct wind_spc {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "lock.h"
|
||||
#include "lock.hpp"
|
||||
|
||||
inline void lock_init(lock* l) {
|
||||
l->init = InitializeCriticalSectionAndSpinCount(&l->cs, 0);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user