This commit is contained in:
korenkonder
2021-05-11 21:04:48 +03:00
parent ce11d391e4
commit 2a031c7dde
215 changed files with 26266 additions and 14539 deletions
+86 -13
View File
@@ -6,34 +6,107 @@
#include "animation.h"
#include "curve.h"
void FASTCALL glitter_animation_parse_file(f2_struct* st, vector_ptr_glitter_curve* vec) {
if (!st || !st->header.data_size)
void FASTCALL glitter_animation_copy(GPM,
vector_ptr_glitter_curve* src, vector_ptr_glitter_curve* dst) {
if (!dst)
return;
vector_ptr_glitter_curve_free(dst, glitter_curve_dispose);
if (!src)
return;
vector_ptr_glitter_curve_append(dst, src->end - src->begin);
for (glitter_curve** i = src->begin; i != src->end; i++)
if (*i) {
glitter_curve* c = glitter_curve_copy(GPM_VAL, *i);
if (c)
vector_ptr_glitter_curve_push_back(dst, &c);
}
}
bool FASTCALL glitter_animation_parse_file(GPM, f2_struct* st,
vector_ptr_glitter_curve* vec, glitter_curve_type_flags flags) {
glitter_curve* c;
if (!st || !st->header.data_size)
return false;
for (f2_struct* i = st->sub_structs.begin; i != st->sub_structs.end; i++) {
if (!i->header.data_size)
continue;
if (i->header.signature == 0x56525543)
glitter_curve_parse_file(i, vec);
if (i->header.signature == reverse_endianess_uint32_t('CURV')
&& glitter_curve_parse_file(GPM_VAL, i, st->header.version, &c))
if (flags & 1 << (size_t)(int32_t)c->type)
vector_ptr_glitter_curve_push_back(vec, &c);
else
glitter_curve_dispose(c);
}
return true;
}
bool FASTCALL glitter_animation_unparse_file(f2_struct* st, vector_ptr_glitter_curve* vec, bool use_big_endian) {
bool FASTCALL glitter_animation_unparse_file(GPM, f2_struct* st,
vector_ptr_glitter_curve* vec, glitter_curve_type_flags flags) {
memset(st, 0, sizeof(f2_struct));
if (vec->end - vec->begin <= 0)
return false;
f2_struct* s = f2_struct_init();
for (glitter_curve** i = vec->begin; i != vec->end; i++)
if (*i) {
glitter_curve_unparse_file(s, *i, use_big_endian);
vector_f2_struct_push_back(&st->sub_structs, s);
}
free(s);
static const glitter_curve_type order[] = {
GLITTER_CURVE_COLOR_A,
GLITTER_CURVE_COLOR_R,
GLITTER_CURVE_COLOR_G,
GLITTER_CURVE_COLOR_B,
GLITTER_CURVE_COLOR_RGB_SCALE,
GLITTER_CURVE_COLOR_A_2ND,
GLITTER_CURVE_COLOR_R_2ND,
GLITTER_CURVE_COLOR_G_2ND,
GLITTER_CURVE_COLOR_B_2ND,
GLITTER_CURVE_COLOR_RGB_SCALE_2ND,
GLITTER_CURVE_TRANSLATION_X,
GLITTER_CURVE_TRANSLATION_Y,
GLITTER_CURVE_TRANSLATION_Z,
GLITTER_CURVE_ROTATION_X,
GLITTER_CURVE_ROTATION_Y,
GLITTER_CURVE_ROTATION_Z,
GLITTER_CURVE_SCALE_X,
GLITTER_CURVE_SCALE_Y,
GLITTER_CURVE_SCALE_Z,
GLITTER_CURVE_SCALE_ALL,
GLITTER_CURVE_EMISSION_INTERVAL,
GLITTER_CURVE_PARTICLES_PER_EMISSION,
GLITTER_CURVE_U_SCROLL,
GLITTER_CURVE_V_SCROLL,
GLITTER_CURVE_U_SCROLL_ALPHA,
GLITTER_CURVE_V_SCROLL_ALPHA,
GLITTER_CURVE_U_SCROLL_2ND,
GLITTER_CURVE_V_SCROLL_2ND,
GLITTER_CURVE_U_SCROLL_ALPHA_2ND,
GLITTER_CURVE_V_SCROLL_ALPHA_2ND,
};
st->header.signature = 0x4D494E41;
for (int32_t i = GLITTER_CURVE_TRANSLATION_X; i <= GLITTER_CURVE_V_SCROLL_ALPHA_2ND; i++) {
if (!(flags & 1 << (size_t)order[i]))
continue;
for (glitter_curve** j = vec->begin; j != vec->end; j++) {
glitter_curve* c = *j;
if (!c || c->type != order[i])
continue;
f2_struct s;
if (glitter_curve_unparse_file(GPM_VAL, &s, c)) {
vector_f2_struct_push_back(&st->sub_structs, &s);
break;
}
}
}
if (st->sub_structs.end - st->sub_structs.begin < 1)
return false;
st->header.signature = reverse_endianess_uint32_t('ANIM');
st->header.length = 0x20;
st->header.use_big_endian = false;
st->header.use_section_size = true;
+6 -2
View File
@@ -7,5 +7,9 @@
#include "glitter.h"
extern void FASTCALL glitter_animation_parse_file(f2_struct* st, vector_ptr_glitter_curve* vec);
extern bool FASTCALL glitter_animation_unparse_file(f2_struct* st, vector_ptr_glitter_curve* vec, bool use_big_endian);
extern void FASTCALL glitter_animation_copy(GPM,
vector_ptr_glitter_curve* src, vector_ptr_glitter_curve* dst);
extern bool FASTCALL glitter_animation_parse_file(GPM, f2_struct* st,
vector_ptr_glitter_curve* vec, glitter_curve_type_flags flags);
extern bool FASTCALL glitter_animation_unparse_file(GPM, f2_struct* st,
vector_ptr_glitter_curve* vec, glitter_curve_type_flags flags);
+2 -14
View File
@@ -5,18 +5,6 @@
#include "counter.h"
extern glitter_particle_manager* gpm;
int32_t FASTCALL glitter_counter_get() {
if (gpm->f2)
return gpm->counter & 0xFF;
else
return gpm->counter & 0xFFF;
}
void FASTCALL glitter_counter_increment() {
if (gpm->f2)
gpm->counter++;
else
gpm->counter++;
int32_t FASTCALL glitter_counter_get(GPM) {
return ++gpm->counter;
}
+1 -2
View File
@@ -7,5 +7,4 @@
#include "glitter.h"
extern int32_t FASTCALL glitter_counter_get();
extern void FASTCALL glitter_counter_increment();
extern int32_t FASTCALL glitter_counter_get(GPM);
+926 -490
View File
File diff suppressed because it is too large Load Diff
+12 -5
View File
@@ -7,9 +7,16 @@
#include "glitter.h"
extern glitter_curve* FASTCALL glitter_curve_init();
extern bool FASTCALL glitter_curve_get_value(glitter_curve* c,
float_t frame, float_t* value, int32_t random);
extern void FASTCALL glitter_curve_parse_file(f2_struct* st, vector_ptr_glitter_curve* vec);
extern void FASTCALL glitter_curve_unparse_file(f2_struct* st, glitter_curve* c, bool use_big_endian);
extern glitter_curve* FASTCALL glitter_curve_init(GPM);
extern glitter_curve* FASTCALL glitter_curve_copy(GPM, glitter_curve* c);
extern bool FASTCALL glitter_curve_get_value(GPM, glitter_curve* c,
float_t frame, float_t* value, int32_t random_value, glitter_random* random);
extern bool FASTCALL glitter_curve_parse_file(GPM,
f2_struct* st, uint32_t version, glitter_curve** c);
#if defined(CRE_DEV) || defined(CLOUD_DEV)
extern void FASTCALL glitter_curve_recalculate(GPM,
glitter_curve* curve, vector_glitter_curve_key* dest);
#endif
extern bool FASTCALL glitter_curve_unparse_file(GPM,
f2_struct* st, glitter_curve* c);
extern void FASTCALL glitter_curve_dispose(glitter_curve* c);
+198
View File
@@ -0,0 +1,198 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "curve.h"
#include "random.h"
static void FASTCALL glitter_curve_get_key_indexes(vector_glitter_curve_key* keys,
float_t frame, size_t* curr, size_t* next);
static float_t FASTCALL glitter_curve_interpolate(GPM, glitter_curve* c, float_t frame,
glitter_curve_key* curr, glitter_curve_key* next, glitter_key_type key_type, glitter_random* random);
static float_t FASTCALL glitter_curve_randomize(GPM,
glitter_curve* c, float_t value, glitter_random* random);
static float_t FASTCALL glitter_curve_randomize_key(GPM,
glitter_curve* c, glitter_curve_key* key, glitter_random* random);
bool FASTCALL glitter_curve_get_value(GPM, glitter_curve* c,
float_t frame, float_t* value, int32_t random_value, glitter_random* random) {
size_t keys_count;
int32_t random_val;
bool negate;
float_t _value;
keys_count = c->keys.end - c->keys.begin;
if (!keys_count)
return false;
random_val = glitter_random_get_value(random);
glitter_random_set_value(random, random_value);
negate = c->flags & GLITTER_CURVE_NEGATE
&& glitter_random_get_int_min_max(GPM_VAL, random, 0, 0xFFFF) > 0x7FFF;
if (c->flags & GLITTER_CURVE_STEP)
glitter_random_set_value(random, random_val + 1);
if (keys_count == 1) {
glitter_curve_key* key = &c->keys.begin[keys_count - 1];
_value = glitter_curve_randomize_key(GPM_VAL, c, key, random);
goto End;
}
float_t start_time = (float_t)c->start_time;
float_t end_time = (float_t)c->end_time;
if (c->repeat && (start_time > frame || frame >= end_time)) {
float_t t = (frame - start_time) / (end_time - start_time);
t = t <= 0.0f ? (float_t)(int32_t)t - 1.0f : (float_t)(int32_t)t;
frame -= t * (end_time - start_time);
}
if (end_time <= frame) {
glitter_curve_key* key = &c->keys.begin[keys_count - 1];
_value = glitter_curve_randomize_key(GPM_VAL, c, key, random);
}
else if (start_time > frame) {
glitter_curve_key* key = &c->keys.begin[0];
_value = glitter_curve_randomize_key(GPM_VAL, c, key, random);
}
else if (c->flags & GLITTER_CURVE_BAKED) {
size_t key_index;
if (frame >= end_time)
key_index = keys_count - 1;
else if (frame > start_time) {
key_index = (size_t)frame - c->start_time;
if (glt_type == GLITTER_F2)
key_index /= 2;
if (key_index >= keys_count)
key_index = keys_count - 1;
}
else
key_index = 0;
glitter_curve_key* key = &c->keys.begin[key_index];
_value = glitter_curve_randomize_key(GPM_VAL, c, key, random);
}
else {
size_t curr_key_index = 0;
size_t next_key_index = 0;
if (keys_count > 3)
glitter_curve_get_key_indexes(&c->keys, frame, &curr_key_index, &next_key_index);
else if (keys_count == 3 && frame >= c->keys.begin[1].frame) {
curr_key_index = 1;
next_key_index = 2;
}
else {
curr_key_index = 0;
next_key_index = 1;
}
glitter_curve_key* curr_key = &c->keys.begin[curr_key_index];
glitter_curve_key* next_key = &c->keys.begin[next_key_index];
_value = glitter_curve_interpolate(GPM_VAL, c, frame, curr_key, next_key, curr_key->type, random);
}
End:
_value = glitter_curve_randomize(GPM_VAL, c, _value, random);
*value = negate ? -_value : _value;
glitter_random_set_value(random, random_val + 1);
return true;
}
static void FASTCALL glitter_curve_get_key_indexes(vector_glitter_curve_key* keys,
float_t frame, size_t* curr, size_t* next) {
size_t v4;
glitter_curve_key* v6;
size_t count;
size_t v9;
size_t v10;
count = keys->end - keys->begin;
if (count <= 1) {
*curr = 0;
*next = 0;
return;
}
v4 = 0;
v6 = keys->begin;
v9 = count - 1;
v10 = v9 / 2;
while (v4 <= v9) {
v10 = (v9 + v4) / 2;
if (frame <= v6[(v10 + 1) % count].frame) {
if (frame >= v6[v10].frame)
goto LABEL_12;
v9 = v10 - 1;
}
else
v4 = v10 + 1;
}
if (frame > v6[v10].frame) {
LABEL_12:
*curr = v10;
*next = v10 + 1;
}
else {
*curr = v10 - 1;
*next = v10;
}
*next %= count;
}
static float_t FASTCALL glitter_curve_interpolate(GPM, glitter_curve* c, float_t frame,
glitter_curve_key* curr, glitter_curve_key* next, glitter_key_type key_type, glitter_random* random) {
float_t next_val;
float_t curr_val;
float_t val;
if (key_type == GLITTER_KEY_CONSTANT)
return glitter_curve_randomize_key(GPM_VAL, c, curr, random);
float_t df = frame - (float_t)curr->frame;
float_t t = df / (float_t)(next->frame - curr->frame);
if (key_type == GLITTER_KEY_HERMITE) {
float_t t_1 = t - 1.0f;
next_val = glitter_curve_randomize_key(GPM_VAL, c, next, random);
curr_val = glitter_curve_randomize_key(GPM_VAL, c, curr, random);
val = glitter_curve_randomize_key(GPM_VAL, c, curr, random);
val += t * t * (3.0f - 2.0f * t) * (next_val - curr_val)
+ (t_1 * curr->tangent2 + t * next->tangent1) * df * t_1;
}
else {
curr_val = glitter_curve_randomize_key(GPM_VAL, c, curr, random);
next_val = glitter_curve_randomize_key(GPM_VAL, c, next, random);
val = curr_val + (next_val - curr_val) * t;
}
return val;
}
static float_t FASTCALL glitter_curve_randomize(GPM,
glitter_curve* c, float_t value, glitter_random* random) {
float_t rand;
if (~c->flags & GLITTER_CURVE_RANDOM_RANGE)
return value;
rand = glitter_random_get_float_min_max(GPM_VAL, random,
c->flags & GLITTER_CURVE_RANDOM_RANGE_NEGATE ? -c->random_range : 0.0f, c->random_range);
if (c->flags & GLITTER_CURVE_RANDOM_RANGE_MULT)
rand *= value * 0.01f;
return rand + value;
}
static float_t FASTCALL glitter_curve_randomize_key(GPM,
glitter_curve* c, glitter_curve_key* key, glitter_random* random) {
float_t rand;
if (~c->flags & GLITTER_CURVE_KEY_RANDOM_RANGE)
return key->value;
rand = glitter_random_get_float_min_max(GPM_VAL, random,
c->flags & GLITTER_CURVE_RANDOM_RANGE_NEGATE ? -key->random_range : 0.0f, key->random_range);
if (c->flags & GLITTER_CURVE_RANDOM_RANGE_MULT)
rand *= key->value * 0.01f;
return rand + key->value;
}
+6 -8
View File
@@ -6,21 +6,19 @@
#include "diva_effect.h"
#include "effect_group.h"
extern glitter_particle_manager* gpm;
bool FASTCALL glitter_diva_effect_parse_file(glitter_file_reader* fr, f2_struct* st) {
bool FASTCALL glitter_diva_effect_parse_file(GPM, glitter_file_reader* fr, f2_struct* st) {
glitter_effect_group* effect_group;
if (!st || !st->header.data_size)
return false;
effect_group = glitter_effect_group_init();
effect_group = glitter_effect_group_init(GPM_VAL);
effect_group->hash = fr->hash;
effect_group->emission = fr->emission;
if (fr->emission <= 0.0)
if (fr->emission <= 0.0f)
effect_group->emission = gpm->emission;
effect_group->version = st->header.version;
if (!glitter_effect_group_parse_file(effect_group, st)) {
if (!glitter_effect_group_parse_file(GPM_VAL, effect_group, st)) {
glitter_effect_group_dispose(effect_group);
return false;
}
@@ -28,7 +26,7 @@ bool FASTCALL glitter_diva_effect_parse_file(glitter_file_reader* fr, f2_struct*
return true;
}
bool FASTCALL glitter_diva_effect_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
return glitter_effect_group_unparse_file(a1, st, use_big_endian);
bool FASTCALL glitter_diva_effect_unparse_file(GPM, glitter_effect_group* a1, f2_struct* st) {
return glitter_effect_group_unparse_file(GPM_VAL, a1, st);
}
+2 -2
View File
@@ -7,5 +7,5 @@
#include "glitter.h"
extern bool FASTCALL glitter_diva_effect_parse_file(glitter_file_reader* fr, f2_struct* st);
extern bool FASTCALL glitter_diva_effect_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_diva_effect_parse_file(GPM, glitter_file_reader* fr, f2_struct* st);
extern bool FASTCALL glitter_diva_effect_unparse_file(GPM, glitter_effect_group* a1, f2_struct* st);
+6 -6
View File
@@ -25,17 +25,17 @@ bool FASTCALL glitter_diva_list_parse_file(glitter_effect_group* a1, f2_struct*
return true;
}
bool FASTCALL glitter_diva_list_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
bool FASTCALL glitter_diva_list_unparse_file(glitter_effect_group* a1, f2_struct* st) {
memset(st, 0, sizeof(f2_struct));
f2_struct* s = f2_struct_init();
if (!glitter_list_pack_file(a1, s, use_big_endian)) {
f2_struct_dispose(s);
f2_struct s;
memset(&s, 0, sizeof(f2_struct));
if (!glitter_list_pack_file(a1, &s)) {
f2_struct_free(&s);
return false;
}
vector_f2_struct_push_back(&st->sub_structs, s);
free(s);
vector_f2_struct_push_back(&st->sub_structs, &s);
st->header.signature = 0x5453494C;
st->header.length = 0x20;
+1 -1
View File
@@ -8,4 +8,4 @@
#include "glitter.h"
extern bool FASTCALL glitter_diva_list_parse_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_diva_list_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_diva_list_unparse_file(glitter_effect_group* a1, f2_struct* st);
+6 -6
View File
@@ -25,17 +25,17 @@ bool FASTCALL glitter_diva_resource_parse_file(glitter_effect_group* a1, f2_stru
return true;
}
bool FASTCALL glitter_diva_resource_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
bool FASTCALL glitter_diva_resource_unparse_file(glitter_effect_group* a1, f2_struct* st) {
memset(st, 0, sizeof(f2_struct));
f2_struct* s = f2_struct_init();
if (!glitter_texture_resource_pack_file(a1, s, use_big_endian)) {
f2_struct_dispose(s);
f2_struct s;
memset(&s, 0, sizeof(f2_struct));
if (!glitter_texture_resource_pack_file(a1, &s)) {
f2_struct_free(&s);
return false;
}
vector_f2_struct_push_back(&st->sub_structs, s);
free(s);
vector_f2_struct_push_back(&st->sub_structs, &s);
st->header.signature = 0x53525644;
st->header.length = 0x20;
+1 -1
View File
@@ -8,4 +8,4 @@
#include "glitter.h"
extern bool FASTCALL glitter_diva_resource_parse_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_diva_resource_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_diva_resource_unparse_file(glitter_effect_group* a1, f2_struct* st);
+422 -206
View File
@@ -8,28 +8,58 @@
#include "curve.h"
#include "emitter.h"
extern glitter_particle_manager* gpm;
static bool FASTCALL glitter_effect_pack_file(GPM, f2_struct* st, glitter_effect* a3);
static bool FASTCALL glitter_effect_unpack_file(GPM,
void* data, glitter_effect* a3, bool use_big_endian);
static bool FASTCALL glitter_effect_pack_file(f2_struct* st, glitter_effect* a3, bool use_big_endian);
static bool FASTCALL glitter_effect_unpack_file(int32_t* data, glitter_effect* a3, bool use_big_endian);
glitter_effect* FASTCALL glitter_effect_init() {
glitter_effect* FASTCALL glitter_effect_init(GPM) {
glitter_effect* e = force_malloc(sizeof(glitter_effect));
e->data.name_hash = gpm->f2 ? 0x0CAD3078 : 0xCBF29CE44FD0BFC1;
e->scale = vec3_identity;
e->data.start_time = 0;
e->data.ext_anim = 0;
e->data.flags = 0;
e->data.name_hash = glt_type != GLITTER_AFT ? hash_murmurhash_empty : hash_fnv1a64_empty;
e->data.seed = 0;
return e;
}
bool FASTCALL glitter_effect_parse_file(glitter_effect_group* a1,
f2_struct* st, vector_ptr_glitter_effect* vec) {
glitter_effect* FASTCALL glitter_effect_copy(GPM, glitter_effect* e) {
if (!e)
return 0;
glitter_effect* ec = force_malloc(sizeof(glitter_effect));
*ec = *e;
if (e->data.ext_anim) {
ec->data.ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
memcpy(ec->data.ext_anim, e->data.ext_anim, sizeof(glitter_effect_ext_anim));
}
ec->emitters = (vector_ptr_glitter_emitter){ 0, 0, 0 };
vector_ptr_glitter_emitter_append(&ec->emitters, e->emitters.end - e->emitters.begin);
for (glitter_emitter** i = e->emitters.begin; i != e->emitters.end; i++)
if (*i) {
glitter_emitter* e = glitter_emitter_copy(GPM_VAL, *i);
if (e)
vector_ptr_glitter_emitter_push_back(&ec->emitters, &e);
}
ec->curve = (vector_ptr_glitter_curve){ 0, 0, 0 };
glitter_animation_copy(GPM_VAL, &e->curve, &ec->curve);
return ec;
}
bool FASTCALL glitter_effect_parse_file(GPM,
glitter_effect_group* a1, f2_struct* st, vector_ptr_glitter_effect* vec) {
f2_struct* i;
glitter_effect* effect;
if (!st || !st->header.data_size)
return false;
effect = glitter_effect_init();
effect = glitter_effect_init(GPM_VAL);
effect->version = st->header.version;
if (!glitter_effect_unpack_file(st->data, effect, st->header.use_big_endian)) {
if (!glitter_effect_unpack_file(GPM_VAL, st->data, effect, st->header.use_big_endian)) {
glitter_effect_dispose(effect);
return false;
}
@@ -38,253 +68,439 @@ bool FASTCALL glitter_effect_parse_file(glitter_effect_group* a1,
if (!i->header.data_size)
continue;
if (i->header.signature == 0x4D494E41)
glitter_animation_parse_file(i, &effect->curve);
else if (i->header.signature == 0x54494D45)
glitter_emitter_parse_file(a1, i, &effect->emitters, effect);
if (i->header.signature == reverse_endianess_uint32_t('ANIM'))
glitter_animation_parse_file(GPM_VAL, i, &effect->curve, glitter_effect_curve_flags);
else if (i->header.signature == reverse_endianess_uint32_t('EMIT'))
glitter_emitter_parse_file(GPM_VAL, a1, i, &effect->emitters, effect);
}
vector_ptr_glitter_effect_push_back(vec, &effect);
return true;
}
bool FASTCALL glitter_effect_unparse_file(glitter_effect_group* a1,
f2_struct* st, glitter_effect* a3, bool use_big_endian) {
if (!glitter_effect_pack_file(st, a3, use_big_endian))
bool FASTCALL glitter_effect_unparse_file(GPM,
glitter_effect_group* a1, f2_struct* st, glitter_effect* a3) {
if (!glitter_effect_pack_file(GPM_VAL, st, a3))
return false;
f2_struct s;
if (glitter_animation_unparse_file(&s, &a3->curve, use_big_endian))
if (glitter_animation_unparse_file(GPM_VAL, &s, &a3->curve, glitter_effect_curve_flags))
vector_f2_struct_push_back(&st->sub_structs, &s);
for (glitter_emitter** i = a3->emitters.begin; i != a3->emitters.end; i++)
if (*i && glitter_emitter_unparse_file(a1, &s, *i, a3, use_big_endian))
for (glitter_emitter** i = a3->emitters.begin; i != a3->emitters.end; i++) {
if (!*i)
continue;
f2_struct s;
if (glitter_emitter_unparse_file(GPM_VAL, a1, &s, *i, a3))
vector_f2_struct_push_back(&st->sub_structs, &s);
}
return true;
}
void FASTCALL glitter_effect_dispose(glitter_effect* e) {
free(e->data.a3da);
vector_ptr_glitter_curve_free(&e->curve, (void*)glitter_curve_dispose);
vector_ptr_glitter_emitter_free(&e->emitters, (void*)glitter_emitter_dispose);
free(e->data.ext_anim);
vector_ptr_glitter_curve_free(&e->curve, glitter_curve_dispose);
vector_ptr_glitter_emitter_free(&e->emitters, glitter_emitter_dispose);
free(e);
}
static bool FASTCALL glitter_effect_pack_file(f2_struct* st, glitter_effect* a2, bool use_big_endian) {
static bool FASTCALL glitter_effect_pack_file(GPM, f2_struct* st, glitter_effect* a2) {
size_t l;
int32_t* d;
glitter_effect_a3da* a3da;
size_t d;
glitter_effect_ext_anim* ext_anim;
glitter_effect_file_flag flags;
if (a2->version != 6 && a2->version != 7)
return false;
a3da = a2->data.a3da;
ext_anim = a2->data.ext_anim;
memset(st, 0, sizeof(f2_struct));
l = 52;
l = 0;
if (a2->version == 7)
l += 4;
uint32_t o;
vector_enrs_entry e = { 0, 0, 0 };
enrs_entry ee;
if (a2->data.flags & GLITTER_EFFECT_FLAG_LOCAL)
l += 4;
else if (a3da)
if (a3da->flags & GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX)
l += 16;
else
l += 144;
l = align_val(l, 0x10);
d = force_malloc(l);
st->length = l;
st->data = d;
flags = 0;
if (a2->data.flags & GLITTER_EFFECT_FLAG_ALPHA)
flags |= GLITTER_EFFECT_FILE_FLAG_ALPHA;
if (a2->data.flags & GLITTER_EFFECT_FLAG_FOG)
flags |= GLITTER_EFFECT_FILE_FLAG_FOG;
else if (a2->data.flags & GLITTER_EFFECT_FLAG_FOG_HEIGHT)
flags |= GLITTER_EFFECT_FILE_FLAG_FOG_HEIGHT;
if (a2->data.flags & GLITTER_EFFECT_FLAG_EMISSION)
flags |= GLITTER_EFFECT_FILE_FLAG_EMISSION;
if (use_big_endian) {
*(uint64_t*)d = reverse_endianess_uint64_t(a2->data.name_hash);
d[2] = reverse_endianess_int32_t((int32_t)roundf(a2->data.appear_time));
d[3] = reverse_endianess_int32_t((int32_t)roundf(a2->data.life_time));
d[4] = reverse_endianess_int32_t((int32_t)roundf(a2->data.start_time));
d[5] = 0xFFFFFFFF;
d[6] = reverse_endianess_int32_t(a2->data.flags & GLITTER_EFFECT_FLAG_LOOP ? 1 : 0);
*(float_t*)&d[7] = reverse_endianess_float_t(a2->translation.x);
*(float_t*)&d[8] = reverse_endianess_float_t(a2->translation.y);
*(float_t*)&d[9] = reverse_endianess_float_t(a2->translation.z);
*(float_t*)&d[10] = reverse_endianess_float_t(a2->rotation.x);
*(float_t*)&d[11] = reverse_endianess_float_t(a2->rotation.y);
*(float_t*)&d[12] = reverse_endianess_float_t(a2->rotation.z);
d[13] = reverse_endianess_int32_t(flags);
}
else {
*(uint64_t*)d = a2->data.name_hash;
d[2] = (int32_t)roundf(a2->data.appear_time);
d[3] = (int32_t)roundf(a2->data.life_time);
d[4] = (int32_t)roundf(a2->data.start_time);
d[5] = 0xFFFFFFFF;
d[6] = a2->data.flags & GLITTER_EFFECT_FLAG_LOOP ? 1 : 0;
*(vec3*)&d[7] = a2->translation;
*(vec3*)&d[10] = a2->rotation;
d[13] = flags;
}
ee = (enrs_entry){ 0, 2, 56, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_QWORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 12, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 56;
if (a2->version == 7) {
if (use_big_endian)
*(float_t*)&d[14] = reverse_endianess_float_t(a2->data.emission);
else
*(float_t*)&d[14] = a2->data.emission;
d++;
ee = (enrs_entry){ 0, 1, 4, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 4;
}
if (a2->data.flags & GLITTER_EFFECT_FLAG_LOCAL)
d[14] = 1;
else if (a3da)
if (a3da->flags & GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX) {
d[14] = 2;
d += 15;
glitter_effect_a3da_flag a3da_flag = a3da->flags & ~GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX;
if (use_big_endian) {
d[0] = reverse_endianess_int32_t(a3da->object_index);
d[1] = reverse_endianess_int32_t(a3da_flag);
d[2] = reverse_endianess_int32_t(a3da->index);
}
else {
d[0] = a3da->object_index;
d[1] = a3da_flag;
d[2] = a3da->index;
}
ee = (enrs_entry){ 0, 1, 4, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 4;
if (~a2->data.flags & GLITTER_EFFECT_LOCAL && ext_anim)
if (ext_anim->flags & GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM) {
ee = (enrs_entry){ 0, 1, 12, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 3, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 12;
}
else {
d[14] = 3;
d += 15;
if (use_big_endian) {
*(uint64_t*)d = reverse_endianess_uint64_t(a3da->object_hash);
d[2] = reverse_endianess_int32_t(a3da->flags);
}
else {
*(uint64_t*)d = a3da->object_hash;
d[2] = a3da->flags;
a3da->flags = d[2];
}
memcpy((char*)(d + 12), a3da->mesh_name, 128);
ee = (enrs_entry){ 0, 2, 140, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_QWORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 140;
}
st->header.signature = 0x54434645;
l = align_val(l, 0x10);
d = (size_t)force_malloc(l);
st->length = l;
st->data = (void*)d;
st->enrs = e;
flags = 0;
if (a2->data.flags & GLITTER_EFFECT_ALPHA)
flags |= GLITTER_EFFECT_FILE_ALPHA;
if (a2->data.flags & GLITTER_EFFECT_FOG)
flags |= GLITTER_EFFECT_FILE_FOG;
else if (a2->data.flags & GLITTER_EFFECT_FOG_HEIGHT)
flags |= GLITTER_EFFECT_FILE_FOG_HEIGHT;
if (a2->data.flags & GLITTER_EFFECT_EMISSION)
flags |= GLITTER_EFFECT_FILE_EMISSION;
*(uint64_t*)d = glt_type != GLITTER_AFT
? hash_char_murmurhash(a2->name, 0, false) : hash_char_fnv1a64(a2->name);;
*(int32_t*)(d + 8) = a2->data.appear_time;
*(int32_t*)(d + 12) = a2->data.life_time;
*(int32_t*)(d + 16) = a2->data.start_time;
*(int32_t*)(d + 20) = 0xFFFFFFFF;
*(int32_t*)(d + 24) = a2->data.flags & GLITTER_EFFECT_LOOP ? 1 : 0;
*(vec3*)(d + 28) = a2->translation;
*(vec3*)(d + 40) = a2->rotation;
*(int32_t*)(d + 52) = flags;
d += 56;
if (a2->version == 7) {
*(float_t*)d = a2->data.emission;
d += 4;
}
if (a2->data.flags & GLITTER_EFFECT_LOCAL) {
*(int32_t*)d = 1;
d += 4;
}
else if (ext_anim)
if (ext_anim->flags & GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM) {
*(int32_t*)d = 2;
d += 4;
glitter_effect_ext_anim_flag ext_anim_flag = ext_anim->flags & ~GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM;
*(int32_t*)d = ext_anim->index;
*(int32_t*)(d + 4) = ext_anim_flag;
*(int32_t*)(d + 8) = ext_anim->node_index;
}
else {
*(int32_t*)d = 3;
d += 4;
*(uint64_t*)d = ext_anim->object_hash;
*(int32_t*)(d + 8) = ext_anim->flags;
memcpy((char*)(d + 12), ext_anim->mesh_name, 128);
}
else {
*(int32_t*)d = 0;
d += 4;
}
st->header.signature = reverse_endianess_uint32_t('EFCT');
st->header.length = 0x20;
st->header.use_big_endian = use_big_endian ? true : false;
st->header.use_big_endian = false;
st->header.use_section_size = true;
st->header.version = a2->version;
return true;
}
static bool FASTCALL glitter_effect_unpack_file(int32_t* data, glitter_effect* a2, bool use_big_endian) {
glitter_effect_a3da* a3da;
static bool FASTCALL glitter_effect_unpack_file(GPM,
void* data, glitter_effect* a2, bool use_big_endian) {
size_t d;
glitter_effect_ext_anim* ext_anim;
glitter_effect_file_flag flags;
a2->scale = vec3_identity;
a2->data.start_time = 0.0f;
a2->data.a3da = 0;
a2->data.flags = 0;
a2->data.name_hash = gpm->f2 ? 0x0CAD3078 : 0xCBF29CE44FD0BFC1;
if (a2->version != 6 && a2->version != 7)
return false;
if (glt_type == GLITTER_X) {
a2->scale = vec3_identity;
a2->data.start_time = 0;
a2->data.ext_anim = 0;
a2->data.flags = 0;
a2->data.name_hash = hash_murmurhash_empty;
a2->data.seed = 0;
if (use_big_endian) {
a2->data.name_hash = reverse_endianess_uint64_t(*(uint64_t*)data);
a2->data.appear_time = (float_t)reverse_endianess_int32_t(data[2]);
a2->data.life_time = (float_t)reverse_endianess_int32_t(data[3]);
a2->data.start_time = (float_t)reverse_endianess_int32_t(data[4]);
if (reverse_endianess_int32_t(data[6]))
a2->data.flags |= GLITTER_EFFECT_FLAG_LOOP;
a2->translation.x = reverse_endianess_float_t(*(float_t*)&data[7]);
a2->translation.y = reverse_endianess_float_t(*(float_t*)&data[8]);
a2->translation.z = reverse_endianess_float_t(*(float_t*)&data[9]);
a2->rotation.x = reverse_endianess_float_t(*(float_t*)&data[10]);
a2->rotation.y = reverse_endianess_float_t(*(float_t*)&data[11]);
a2->rotation.z = reverse_endianess_float_t(*(float_t*)&data[12]);
flags = reverse_endianess_int32_t(data[13]);
}
else {
a2->data.name_hash = *(uint64_t*)data;
a2->data.appear_time = (float_t)data[2];
a2->data.life_time = (float_t)data[3];
a2->data.start_time = (float_t)data[4];
if (data[6])
a2->data.flags |= GLITTER_EFFECT_FLAG_LOOP;
a2->translation = *(vec3*)&data[7];
a2->rotation = *(vec3*)&data[10];
flags = data[13];
}
if (a2->version < 8 || a2->version > 12)
return false;
if (flags & GLITTER_EFFECT_FILE_FLAG_ALPHA)
a2->data.flags |= GLITTER_EFFECT_FLAG_ALPHA;
if (flags & GLITTER_EFFECT_FILE_FLAG_FOG)
a2->data.flags |= GLITTER_EFFECT_FLAG_FOG;
else if (flags & GLITTER_EFFECT_FILE_FLAG_FOG_HEIGHT)
a2->data.flags |= GLITTER_EFFECT_FLAG_FOG_HEIGHT;
if (flags & GLITTER_EFFECT_FILE_FLAG_EMISSION)
a2->data.flags |= GLITTER_EFFECT_FLAG_EMISSION;
if (a2->version == 7) {
if (use_big_endian)
a2->data.emission = reverse_endianess_float_t(*(float_t*)&data[14]);
else
a2->data.emission = *(float_t*)&data[14];
data++;
}
if (data[14] == 1)
a2->data.flags |= GLITTER_EFFECT_FLAG_LOCAL;
else if (data[14] == 2) {
data += 15;
a3da = force_malloc(sizeof(glitter_effect_a3da));
a2->data.a3da = a3da;
if (a3da) {
if (use_big_endian) {
a3da->object_index = reverse_endianess_int32_t(data[0]);
a3da->flags = reverse_endianess_int32_t(data[1]);
a3da->index = reverse_endianess_int32_t(data[2]);
}
else {
a3da->object_index = data[0];
a3da->flags = data[1];
a3da->index = data[2];
}
a3da->flags |= GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX;
a3da->mesh_name[0] = 0;
d = (size_t)data;
if (use_big_endian) {
a2->data.name_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
a2->data.appear_time = reverse_endianess_int32_t(*(int32_t*)(d + 8));
a2->data.life_time = reverse_endianess_int32_t(*(int32_t*)(d + 12));
a2->data.start_time = reverse_endianess_int32_t(*(int32_t*)(d + 16));
if (reverse_endianess_int32_t(*(int32_t*)(d + 24)))
a2->data.flags |= GLITTER_EFFECT_LOOP;
a2->translation.x = reverse_endianess_float_t(*(float_t*)(d + 28));
a2->translation.y = reverse_endianess_float_t(*(float_t*)(d + 32));
a2->translation.z = reverse_endianess_float_t(*(float_t*)(d + 36));
a2->rotation.x = reverse_endianess_float_t(*(float_t*)(d + 40));
a2->rotation.y = reverse_endianess_float_t(*(float_t*)(d + 44));
a2->rotation.z = reverse_endianess_float_t(*(float_t*)(d + 48));
flags = reverse_endianess_int32_t(*(int32_t*)(d + 52));
}
}
else if (data[14] == 3) {
data += 15;
//v10 = sub_14045A570(*(uint64_t*)data);
//if (v10 != -1) {
a3da = force_malloc(sizeof(glitter_effect_a3da));
a2->data.a3da = a3da;
if (a3da) {
//a3da->object_index = v10;
else {
a2->data.name_hash = *(uint64_t*)data;
a2->data.appear_time = *(int32_t*)(d + 8);
a2->data.life_time = *(int32_t*)(d + 12);
a2->data.start_time = *(int32_t*)(d + 16);
if (*(int32_t*)(d + 24))
a2->data.flags |= GLITTER_EFFECT_LOOP;
a2->translation = *(vec3*)(d + 28);
a2->rotation = *(vec3*)(d + 40);
flags = *(int32_t*)(d + 52);
}
if (flags & GLITTER_EFFECT_FILE_ALPHA)
a2->data.flags |= GLITTER_EFFECT_ALPHA;
if (flags & GLITTER_EFFECT_FILE_FOG)
a2->data.flags |= GLITTER_EFFECT_FOG;
else if (flags & GLITTER_EFFECT_FILE_FOG_HEIGHT)
a2->data.flags |= GLITTER_EFFECT_FOG_HEIGHT;
if (flags & GLITTER_EFFECT_FILE_EMISSION)
a2->data.flags |= GLITTER_EFFECT_EMISSION;
if (flags & GLITTER_EFFECT_FILE_USE_SEED)
a2->data.flags |= GLITTER_EFFECT_USE_SEED;
if (a2->version != 8 && flags & 0x20)
a2->data.flags |= 0x80;
if (use_big_endian) {
a2->data.emission = reverse_endianess_float_t(*(float_t*)(d + 56));
a2->data.seed = reverse_endianess_int32_t(*(int32_t*)(d + 60));
}
else {
a2->data.emission = *(float_t*)(d + 56);
a2->data.seed = *(int32_t*)(d + 60);
}
int32_t type = a2->version != 8 ? *(int32_t*)(d + 76) : *(int32_t*)(d + 80);
if (use_big_endian)
type = reverse_endianess_int32_t(type);
d += a2->version != 8 ? 80 : 88;
if (type == 1)
a2->data.flags |= GLITTER_EFFECT_LOCAL;
else if (type == 2) {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
if (use_big_endian) {
a3da->object_hash = reverse_endianess_uint64_t(*(uint64_t*)data);
a3da->flags = reverse_endianess_int32_t(data[2]);
ext_anim->index = reverse_endianess_int32_t(*(int32_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 4));
ext_anim->node_index = reverse_endianess_int32_t(*(int32_t*)(d + 8));
}
else {
a3da->object_hash = *(uint64_t*)data;
a3da->flags = data[2];
ext_anim->index = *(int32_t*)d;
ext_anim->flags = *(int32_t*)(d + 4);
ext_anim->node_index = *(int32_t*)(d + 8);
}
a3da->index = 201;
memcpy(a3da->mesh_name, (char*)(data + 12), 128);
ext_anim->flags |= GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM;
ext_anim->mesh_name[0] = 0;
}
//}
}
else if (type == 3) {
if (a2->version == 8) {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
if (use_big_endian) {
ext_anim->object_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 8));
}
else {
ext_anim->object_hash = *(uint64_t*)d;
ext_anim->flags = *(int32_t*)(d + 8);
}
ext_anim->instance_id = 0;
ext_anim->some_hash = 0xCAD3078;
ext_anim->index = -1;
ext_anim->node_index = 18;
if (*(char*)(d + 12)) {
strncpy_s(ext_anim->mesh_name, 0x80, (char*)(d + 20), 0x80);
ext_anim->mesh_name[0x7F] = '\0';
}
else
ext_anim->mesh_name[0] = 0;
}
}
else if (a2->version == 10) {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
if (use_big_endian) {
ext_anim->object_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 8));
}
else {
ext_anim->object_hash = *(uint64_t*)d;
ext_anim->flags = *(int32_t*)(d + 8);
}
ext_anim->instance_id = 0;
ext_anim->some_hash = 0xCAD3078;
ext_anim->index = -1;
ext_anim->node_index = 18;
if (*(char*)(d + 16)) {
strncpy_s(ext_anim->mesh_name, 0x80, (char*)(d + 16), 0x80);
ext_anim->mesh_name[0x7F] = '\0';
}
else
ext_anim->mesh_name[0] = 0;
}
}
else {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
if (use_big_endian) {
ext_anim->object_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 8));
ext_anim->instance_id = reverse_endianess_int32_t(*(int32_t*)(d + 12));
ext_anim->some_hash = reverse_endianess_uint64_t(*(uint64_t*)(d + 16));
}
else {
ext_anim->object_hash = *(uint64_t*)d;
ext_anim->flags = *(int32_t*)(d + 8);
ext_anim->instance_id = *(int32_t*)(d + 12);
ext_anim->some_hash = *(uint64_t*)(d + 16);
}
ext_anim->index = -1;
ext_anim->node_index = 18;
if (*(char*)(d + 32)) {
strncpy_s(ext_anim->mesh_name, 0x80, (char*)(d + 32), 0x80);
ext_anim->mesh_name[0x7F] = '\0';
}
else
ext_anim->mesh_name[0] = 0;
}
}
}
}
else {
a2->scale = vec3_identity;
a2->data.start_time = 0;
a2->data.ext_anim = 0;
a2->data.flags = 0;
a2->data.name_hash = glt_type != GLITTER_AFT ? hash_murmurhash_empty : hash_fnv1a64_empty;
a2->data.seed = 0;
if (a2->version != 6 && a2->version != 7)
return false;
d = (size_t)data;
if (use_big_endian) {
a2->data.name_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
a2->data.appear_time = reverse_endianess_int32_t(*(int32_t*)(d + 8));
a2->data.life_time = reverse_endianess_int32_t(*(int32_t*)(d + 12));
a2->data.start_time = reverse_endianess_int32_t(*(int32_t*)(d + 16));
if (reverse_endianess_int32_t(*(int32_t*)(d + 24)))
a2->data.flags |= GLITTER_EFFECT_LOOP;
a2->translation.x = reverse_endianess_float_t(*(float_t*)(d + 28));
a2->translation.y = reverse_endianess_float_t(*(float_t*)(d + 32));
a2->translation.z = reverse_endianess_float_t(*(float_t*)(d + 36));
a2->rotation.x = reverse_endianess_float_t(*(float_t*)(d + 40));
a2->rotation.y = reverse_endianess_float_t(*(float_t*)(d + 44));
a2->rotation.z = reverse_endianess_float_t(*(float_t*)(d + 48));
flags = reverse_endianess_int32_t(*(int32_t*)(d + 52));
}
else {
a2->data.name_hash = *(uint64_t*)data;
a2->data.appear_time = *(int32_t*)(d + 8);
a2->data.life_time = *(int32_t*)(d + 12);
a2->data.start_time = *(int32_t*)(d + 16);
if (*(int32_t*)(d + 24))
a2->data.flags |= GLITTER_EFFECT_LOOP;
a2->translation = *(vec3*)(d + 28);
a2->rotation = *(vec3*)(d + 40);
flags = *(int32_t*)(d + 52);
}
d += 56;
if (flags & GLITTER_EFFECT_FILE_ALPHA)
a2->data.flags |= GLITTER_EFFECT_ALPHA;
if (flags & GLITTER_EFFECT_FILE_FOG)
a2->data.flags |= GLITTER_EFFECT_FOG;
else if (flags & GLITTER_EFFECT_FILE_FOG_HEIGHT)
a2->data.flags |= GLITTER_EFFECT_FOG_HEIGHT;
if (flags & GLITTER_EFFECT_FILE_EMISSION)
a2->data.flags |= GLITTER_EFFECT_EMISSION;
if (a2->version == 7) {
if (use_big_endian)
a2->data.emission = reverse_endianess_float_t(*(float_t*)d);
else
a2->data.emission = *(float_t*)d;
d += 4;
}
int32_t type = *(int32_t*)d;
if (use_big_endian)
type = reverse_endianess_int32_t(type);
d += 4;
if (type == 1)
a2->data.flags |= GLITTER_EFFECT_LOCAL;
else if (type == 2) {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
if (use_big_endian) {
ext_anim->index = reverse_endianess_int32_t(*(int32_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 4));
ext_anim->node_index = reverse_endianess_int32_t(*(int32_t*)(d + 8));
}
else {
ext_anim->index = *(int32_t*)d;
ext_anim->flags = *(int32_t*)(d + 4);
ext_anim->node_index = *(int32_t*)(d + 8);
}
ext_anim->flags |= GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM;
ext_anim->mesh_name[0] = 0;
}
}
else if (type == 3) {
ext_anim = force_malloc(sizeof(glitter_effect_ext_anim));
a2->data.ext_anim = ext_anim;
if (ext_anim) {
ext_anim->index = -1;
if (use_big_endian) {
ext_anim->object_hash = reverse_endianess_uint64_t(*(uint64_t*)d);
ext_anim->flags = reverse_endianess_int32_t(*(int32_t*)(d + 8));
}
else {
ext_anim->object_hash = *(uint64_t*)d;
ext_anim->flags = *(int32_t*)(d + 8);
}
ext_anim->node_index = 18;
if (*(char*)(d + 12)) {
strncpy_s(ext_anim->mesh_name, 0x80, (char*)(d + 12), 0x80);
ext_anim->mesh_name[0x7F] = 0;
}
else
ext_anim->mesh_name[0x00] = 0;
}
}
}
return true;
}
+6 -5
View File
@@ -7,9 +7,10 @@
#include "glitter.h"
extern glitter_effect* FASTCALL glitter_effect_init();
extern bool FASTCALL glitter_effect_parse_file(glitter_effect_group* a1,
f2_struct* st, vector_ptr_glitter_effect* vec);
extern bool FASTCALL glitter_effect_unparse_file(glitter_effect_group* a1,
f2_struct* st, glitter_effect* a3, bool use_big_endian);
extern glitter_effect* FASTCALL glitter_effect_init(GPM);
extern glitter_effect* FASTCALL glitter_effect_copy(GPM, glitter_effect* e);
extern bool FASTCALL glitter_effect_parse_file(GPM,
glitter_effect_group* a1, f2_struct* st, vector_ptr_glitter_effect* vec);
extern bool FASTCALL glitter_effect_unparse_file(GPM,
glitter_effect_group* a1, f2_struct* st, glitter_effect* a3);
extern void FASTCALL glitter_effect_dispose(glitter_effect* e);
+20 -20
View File
@@ -8,18 +8,19 @@
#include "scene.h"
#include "texture.h"
glitter_effect_group* FASTCALL glitter_effect_group_init() {
glitter_effect_group* FASTCALL glitter_effect_group_init(GPM) {
glitter_effect_group* eg = force_malloc(sizeof(glitter_effect_group));
eg->emission = 1.0f;
eg->version = glt_type == GLITTER_X ? 0x0C : 0x09;
return eg;
}
bool FASTCALL glitter_effect_group_parse_file(glitter_effect_group* a1, f2_struct* st) {
bool FASTCALL glitter_effect_group_parse_file(GPM, glitter_effect_group* a1, f2_struct* st) {
for (f2_struct* i = st->sub_structs.begin; i != st->sub_structs.end; i++) {
if (!i->header.data_size)
continue;
if (i->header.signature == 0x54434645 && !glitter_effect_parse_file(a1, i, &a1->effects))
if (i->header.signature == 0x54434645 && !glitter_effect_parse_file(GPM_VAL, a1, i, &a1->effects))
return false;
else if (i->header.signature == 0x53525644 && !glitter_texture_hashes_unpack_file(a1, i))
return false;
@@ -27,21 +28,23 @@ bool FASTCALL glitter_effect_group_parse_file(glitter_effect_group* a1, f2_struc
return true;
}
bool FASTCALL glitter_effect_group_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
bool FASTCALL glitter_effect_group_unparse_file(GPM, glitter_effect_group* a1, f2_struct* st) {
memset(st, 0, sizeof(f2_struct));
f2_struct* s = f2_struct_init();
for (glitter_effect** i = a1->effects.begin; i != a1->effects.end; i++)
if (*i && glitter_effect_unparse_file(a1, s, *i, use_big_endian))
vector_f2_struct_push_back(&st->sub_structs, s);
for (glitter_effect** i = a1->effects.begin; i != a1->effects.end; i++) {
if (!*i)
continue;
if (!glitter_texture_hashes_pack_file(a1, s, use_big_endian)) {
f2_struct_dispose(s);
return false;
f2_struct s;
memset(&s, 0, sizeof(f2_struct));
if (glitter_effect_unparse_file(GPM_VAL, a1, &s, *i))
vector_f2_struct_push_back(&st->sub_structs, &s);
}
vector_f2_struct_push_back(&st->sub_structs, s);
free(s);
f2_struct s;
memset(&s, 0, sizeof(f2_struct));
if (glitter_texture_hashes_pack_file(a1, &s))
vector_f2_struct_push_back(&st->sub_structs, &s);
st->header.signature = 0x46455644;
st->header.length = 0x20;
@@ -52,12 +55,9 @@ bool FASTCALL glitter_effect_group_unparse_file(glitter_effect_group* a1, f2_str
}
void FASTCALL glitter_effect_group_dispose(glitter_effect_group* eg) {
vector_ptr_glitter_effect_free(&eg->effects, (void*)glitter_effect_dispose);
free(eg->resource_hashes);
if (eg->resources)
glDeleteTextures(eg->resources_count, eg->resources);
free(eg->resources);
if (eg->resources_tex)
txp_dispose(eg->resources_tex);
vector_ptr_glitter_effect_free(&eg->effects, glitter_effect_dispose);
vector_uint64_t_free(&eg->resource_hashes);
glitter_texture_unload(eg);
tex_set_free(&eg->resources_tex);
free(eg);
}
+3 -3
View File
@@ -7,7 +7,7 @@
#include "glitter.h"
extern glitter_effect_group* FASTCALL glitter_effect_group_init();
extern bool FASTCALL glitter_effect_group_parse_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_effect_group_unparse_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern glitter_effect_group* FASTCALL glitter_effect_group_init(GPM);
extern bool FASTCALL glitter_effect_group_parse_file(GPM, glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_effect_group_unparse_file(GPM, glitter_effect_group* a1, f2_struct* st);
extern void FASTCALL glitter_effect_group_dispose(glitter_effect_group* eg);
+434 -364
View File
@@ -4,19 +4,24 @@
*/
#include "effect_inst.h"
#include "counter.h"
#include "curve.h"
#include "emitter_inst.h"
#include "random.h"
#include "scene.h"
#include "render_group.h"
static int32_t FASTCALL glitter_effect_inst_get_a3da_index(int32_t index);
static void FASTCALL glitter_effect_inst_get_ext_anim(GPM, glitter_effect_inst* a1);
static int32_t FASTCALL glitter_aft_effect_inst_get_ext_anim_bone_index(int32_t index);
static int32_t FASTCALL glitter_f2_effect_inst_get_ext_anim_bone_index(int32_t index);
static void FASTCALL glitter_effect_inst_get_value(GPM, glitter_effect_inst* a1, float_t frame);
static void FASTCALL glitter_effect_inst_reset_sub(GPM, glitter_effect_inst* a1, float_t emission);
glitter_effect_inst* FASTCALL glitter_effect_inst_init(glitter_effect* a1,
glitter_scene* a2, size_t id, bool appear_now) {
glitter_effect_inst* FASTCALL glitter_effect_inst_init(GPM,
glitter_effect* a1, size_t id, float_t emission, bool appear_now) {
glitter_effect_inst_ext_anim* inst_ext_anim;
glitter_effect_ext_anim* ext_anim;
glitter_emitter** i;
glitter_effect_inst_a3da* inst_a3da;
glitter_effect_a3da* a3da;
glitter_emitter_inst* emitter;
glitter_emitter_inst* emitter_inst;
glitter_effect_inst* ei = force_malloc(sizeof(glitter_effect_inst));
ei->effect = a1;
@@ -24,145 +29,260 @@ glitter_effect_inst* FASTCALL glitter_effect_inst_init(glitter_effect* a1,
ei->color = vec4_identity;
ei->scale_all = 1.0f;
ei->id = id;
glitter_random_set(ei->data.name_hash % glitter_random_get_max());
ei->translation = a1->translation;
ei->rotation = a1->rotation;
ei->scale = a1->scale;
glitter_random_reset(&ei->random_shared);
glitter_random_reset(&ei->random);
if (appear_now)
ei->data.appear_time = 0.0f;
ei->frame = 0.0f;
else
ei->frame = -ei->data.appear_time;
ei->frame = (float_t)-ei->data.appear_time;
if (ei->data.a3da) {
inst_a3da = force_malloc(sizeof(glitter_effect_inst_a3da));
inst_a3da->dword00 = -1;
inst_a3da->object_index = -1;
inst_a3da->index = -1;
inst_a3da->mat = mat4_identity;
if (~a1->data.flags & GLITTER_EFFECT_LOCAL && ei->data.ext_anim) {
inst_ext_anim = force_malloc(sizeof(glitter_effect_inst_ext_anim));
inst_ext_anim->dword00 = -1;
inst_ext_anim->object_hash = glt_type != GLITTER_AFT
? hash_murmurhash_empty : hash_fnv1a64_empty;
inst_ext_anim->chara_index = -1;
inst_ext_anim->node_index = -1;
inst_ext_anim->mat = mat4_identity;
if (inst_a3da) {
a3da = ei->data.a3da;
if (a3da->flags & GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_ONCE)
ei->flags |= GLITTER_EFFECT_INST_FLAG_SET_A3DA_ONCE;
if (a3da->flags & GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_TRANS_ONLY)
ei->flags |= GLITTER_EFFECT_INST_FLAG_SET_A3DA_TRANS_ONLY;
if (a3da->flags & GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX) {
inst_a3da->index = glitter_effect_inst_get_a3da_index(a3da->index);
ei->flags |= GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_INDEX;
if (inst_ext_anim) {
ext_anim = ei->data.ext_anim;
if (ext_anim->flags & GLITTER_EFFECT_EXT_ANIM_SET_EXT_ANIM_ONCE)
ei->flags |= GLITTER_EFFECT_INST_SET_EXT_ANIM_ONCE;
if (ext_anim->flags & GLITTER_EFFECT_EXT_ANIM_EXT_ANIM_TRANS_ONLY)
ei->flags |= GLITTER_EFFECT_INST_EXT_ANIM_TRANS_ONLY;
if (ext_anim->flags & GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM) {
inst_ext_anim->chara_index = ext_anim->index;
inst_ext_anim->node_index = glt_type == GLITTER_AFT
? glitter_aft_effect_inst_get_ext_anim_bone_index(ext_anim->node_index)
: glitter_f2_effect_inst_get_ext_anim_bone_index(ext_anim->node_index);
ei->flags |= GLITTER_EFFECT_INST_CHARA_ANIM;
}
else {
inst_ext_anim->object_hash = ext_anim->object_hash;
inst_ext_anim->some_hash = ext_anim->some_hash;
inst_ext_anim->instance_id = ext_anim->instance_id;
}
inst_a3da->object_index = a3da->object_index;
size_t mesh_name_len = strlen(a3da->mesh_name);
if (mesh_name_len) {
inst_a3da->mesh_name = force_malloc(mesh_name_len + 1);
memcpy(inst_a3da->mesh_name, a3da->mesh_name, mesh_name_len);
size_t name_len = strlen(ext_anim->mesh_name);
if (name_len) {
inst_ext_anim->name = force_malloc(name_len + 1);
memcpy(inst_ext_anim->name, ext_anim->mesh_name, name_len);
}
else
inst_a3da->mesh_name = 0;
inst_ext_anim->name = 0;
}
ei->a3da = inst_a3da;
ei->flags |= GLITTER_EFFECT_INST_FLAG_HAS_A3DA;
ei->flags |= GLITTER_EFFECT_INST_FLAG_HAS_A3DA_NON_INIT;
ei->flags |= GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_NAME;
ei->ext_anim = inst_ext_anim;
ei->flags |= GLITTER_EFFECT_INST_HAS_EXT_ANIM;
ei->flags |= GLITTER_EFFECT_INST_HAS_EXT_ANIM_NON_INIT;
ei->flags |= GLITTER_EFFECT_INST_SET_EXT_ANIM_BY_OBJECT_NAME;
}
glitter_random_set_value(&ei->random_shared, ei->data.name_hash % glitter_random_get_max(GPM_VAL));
ei->random.value = glitter_random_get_value(&ei->random_shared);
ei->mat = mat4_identity;
ei->random = glitter_random_get();
vector_ptr_glitter_emitter_inst_resize(&ei->emitters, a1->emitters.end - a1->emitters.begin);
vector_ptr_glitter_emitter_inst_append(&ei->emitters, a1->emitters.end - a1->emitters.begin);
for (i = a1->emitters.begin; i != a1->emitters.end; i++) {
if (!*i)
continue;
emitter = glitter_emitter_inst_init(*i, a2, ei);
vector_ptr_glitter_emitter_inst_push_back(&ei->emitters, &emitter);
emitter_inst = glitter_emitter_inst_init(GPM_VAL, *i, ei, emission);
vector_ptr_glitter_emitter_inst_push_back(&ei->emitters, &emitter_inst);
}
glitter_effect_inst_reset_sub(ei, a2);
glitter_effect_inst_reset_sub(GPM_VAL, ei, emission);
return ei;
}
void FASTCALL glitter_effect_inst_copy(glitter_effect_inst* a1,
glitter_effect_inst* a2, glitter_scene* a3) {
int64_t emitters_count; // rbp
int64_t i; // rbx
void FASTCALL glitter_effect_inst_calc_draw(GPM, glitter_effect_inst* a1,
bool(FASTCALL* render_add_list_func)(glitter_particle_mesh*, vec4*, mat4*, mat4*)) {
glitter_render_group** i;
glitter_render_group* render_group;
a2->frame = a1->frame;
a2->color = a1->color;
a2->translation = a1->translation;
a2->rotation = a1->rotation;
a2->scale = a1->scale;
a2->mat = a1->mat;
a2->random = a1->random;
for (i = a1->render_groups.begin; i != a1->render_groups.end; i++) {
if (!*i)
continue;
emitters_count = a1->emitters.end - a1->emitters.begin;
if (emitters_count != a2->emitters.end - a2->emitters.begin)
render_group = *i;
if (render_group && (!glitter_render_group_cannot_draw(render_group) || gpm->draw_all))
glitter_render_group_calc_draw(GPM_VAL, render_group, render_add_list_func);
}
}
void FASTCALL glitter_effect_inst_draw(GPM, glitter_effect_inst* a1, int32_t alpha) {
glitter_render_group** i;
glitter_render_group* render_group;
for (i = a1->render_groups.begin; i != a1->render_groups.end; i++) {
if (!*i)
continue;
render_group = *i;
if (render_group && (render_group)->alpha == alpha
&& (!glitter_render_group_cannot_draw(render_group) || gpm->draw_all))
glitter_render_group_draw(GPM_VAL, render_group);
}
}
int32_t FASTCALL glitter_effect_inst_get_alpha(glitter_effect_inst* a1) {
return (a1->data.flags & GLITTER_EFFECT_ALPHA) ? 2 : 1;
}
size_t FASTCALL glitter_effect_inst_get_ctrl_count(glitter_effect_inst* a1, glitter_particle_type type) {
glitter_render_group** i;
glitter_render_group* render_group;
size_t ctrl;
ctrl = 0;
for (i = a1->render_groups.begin; i != a1->render_groups.end; i++) {
if (!*i)
continue;
render_group = *i;
if (render_group->type == type)
ctrl += render_group->ctrl;
}
return ctrl;
}
size_t FASTCALL glitter_effect_inst_get_disp_count(glitter_effect_inst* a1, glitter_particle_type type) {
glitter_render_group** i;
glitter_render_group* render_group;
size_t disp;
disp = 0;
for (i = a1->render_groups.begin; i != a1->render_groups.end; i++) {
if (!*i)
continue;
render_group = *i;
if (render_group->type == type)
disp += render_group->disp;
}
return disp;
}
int32_t FASTCALL glitter_effect_inst_get_fog(glitter_effect_inst* a1) {
if (a1->data.flags & GLITTER_EFFECT_FOG)
return 1;
else if (a1->data.flags & GLITTER_EFFECT_FOG_HEIGHT)
return 2;
else
return 0;
}
bool FASTCALL glitter_effect_inst_has_ended(glitter_effect_inst* effect, bool a2) {
glitter_emitter_inst** i;
if (~effect->flags & GLITTER_EFFECT_INST_FREE)
return false;
else if (!a2)
return true;
for (i = effect->emitters.begin; i != effect->emitters.end; i++)
if (!glitter_emitter_inst_has_ended(*i, a2))
return false;
return true;
}
void FASTCALL glitter_effect_inst_reset(GPM, glitter_effect_inst* a1, float_t emission) {
glitter_emitter_inst** i;
a1->frame = (float_t)-a1->data.appear_time;
a1->flags = 0;
for (i = a1->emitters.begin; i != a1->emitters.end; i++)
glitter_emitter_inst_reset(*i);
glitter_effect_inst_reset_sub(GPM_VAL, a1, emission);
}
void FASTCALL glitter_effect_inst_update_value_frame(GPM,
glitter_effect_inst* effect, float_t delta_frame, float_t emission) {
vec3 scale;
glitter_emitter_inst** i;
glitter_render_group** j;
mat4 mat;
vec3 translation;
vec3 rotation;
glitter_effect_inst_get_ext_anim(GPM_VAL, effect);
glitter_effect_inst_get_value(GPM_VAL, effect, effect->frame);
vec3_mult_scalar(effect->scale, effect->scale_all, scale);
rotation = effect->rotation;
if (effect->flags & GLITTER_EFFECT_INST_HAS_EXT_ANIM_TRANS && effect->ext_anim) {
vec3_add(effect->translation, effect->ext_anim->translation, translation);
mat4_translate_mult(&effect->ext_anim->mat, translation.x, translation.y, translation.z, &mat);
}
else {
translation = effect->translation;
mat4_translate(translation.x, translation.y, translation.z, &mat);
}
mat4_rot(&mat, rotation.x, rotation.y, rotation.z, &mat);
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &effect->mat);
for (i = effect->emitters.begin; i != effect->emitters.end; ++i)
if (*i)
glitter_emitter_inst_update_value_frame(GPM_VAL, *i, effect, delta_frame);
if (effect->frame >= 0.0f)
if (effect->frame < (float_t)effect->data.life_time) {
for (i = effect->emitters.begin; i != effect->emitters.end; i++)
if (*i)
glitter_emitter_inst_emit(GPM_VAL, *i, delta_frame, emission);
}
else if (effect->data.flags & GLITTER_EFFECT_LOOP)
effect->frame -= (float_t)effect->data.life_time;
else {
effect->flags |= GLITTER_EFFECT_INST_FREE;
for (i = effect->emitters.begin; i != effect->emitters.end; ++i)
if (*i)
glitter_emitter_inst_free(GPM_VAL, *i, emission);
}
for (j = effect->render_groups.begin; j != effect->render_groups.end; j++)
if (*j)
glitter_render_group_get_value(GPM_VAL, *j, delta_frame, true);
effect->frame += delta_frame;
}
void FASTCALL glitter_effect_inst_dispose(glitter_effect_inst* ei) {
if (ei->ext_anim) {
free(ei->ext_anim->name);
free(ei->ext_anim);
}
vector_ptr_glitter_render_group_free(&ei->render_groups, glitter_render_group_dispose);
vector_ptr_glitter_emitter_inst_free(&ei->emitters, glitter_emitter_inst_dispose);
free(ei);
}
static void FASTCALL glitter_effect_inst_get_ext_anim(GPM, glitter_effect_inst* a1) {
glitter_effect_inst_ext_anim* ext_anim;
if (!a1->ext_anim)
return;
for (i = 0; i < emitters_count; i++)
glitter_emitter_inst_copy(a1->emitters.begin[i], a2->emitters.begin[i], a3);
}
ext_anim = a1->ext_anim;
ext_anim->mat = mat4_identity;
ext_anim->translation = vec3_null;
void FASTCALL glitter_effect_inst_emit(glitter_effect_inst* a1, glitter_scene* a2, float_t delta_frame) {
glitter_emitter_inst** i; // rbx
if (~a1->flags & GLITTER_EFFECT_INST_HAS_EXT_ANIM
|| (a1->flags & GLITTER_EFFECT_INST_SET_EXT_ANIM_ONCE
&& a1->flags & GLITTER_EFFECT_INST_HAS_EXT_ANIM_TRANS))
return;
if (a1->frame >= 0.0f) {
if (a1->frame < a1->data.life_time)
for (i = a1->emitters.begin; i != a1->emitters.end; ++i)
glitter_emitter_inst_emit_step(*i, a2, a1, delta_frame);
else if (a1->data.flags & GLITTER_EFFECT_FLAG_LOOP)
a1->frame -= a1->data.life_time;
else
glitter_effect_inst_free(a1, a2, false);
}
a1->frame += delta_frame;
}
void FASTCALL glitter_effect_inst_emit_init(glitter_effect_inst* a1, glitter_scene* a2, float_t delta_frame) {
glitter_emitter_inst** i;
if (a1->frame >= 0.0f) {
if (a1->frame < a1->data.life_time)
for (i = a1->emitters.begin; i != a1->emitters.end; i++)
glitter_emitter_inst_emit_init(*i, a2, a1, delta_frame);
else if (a1->data.flags & GLITTER_EFFECT_FLAG_LOOP)
a1->frame -= a1->data.life_time;
else
glitter_effect_inst_free(a1, a2, 0);
for (i = a1->emitters.begin; i != a1->emitters.end; i++)
glitter_emitter_inst_render_group_init(*i, delta_frame);
}
a1->frame += delta_frame;
}
void FASTCALL glitter_effect_inst_free(glitter_effect_inst* a1, glitter_scene* a2, bool free) {
glitter_emitter_inst** i;
a1->flags |= GLITTER_EFFECT_INST_FLAG_FREE;
for (i = a1->emitters.begin; i != a1->emitters.end; ++i)
glitter_emitter_inst_free(*i, a2, free);
}
void FASTCALL glitter_effect_inst_get_a3da(glitter_effect_inst* a1) {
glitter_effect_inst_a3da* v3; // rax
char* v4; // rax
int64_t v6; // rbx
mat4* v15; // r8
int64_t v24; // rsi
int32_t v26; // ebx
char* v27; // r14
int64_t v43; // rbx
/*char* v4;
int64_t v6;
mat4* v15;
int64_t v24;
int32_t chara_index;
int64_t v43;
vec3 a2;
mat4 mat0;
mat4 mat1;
if (~a1->flags & GLITTER_EFFECT_INST_FLAG_HAS_A3DA || !a1->a3da
|| (a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_ONCE
&& a1->flags & GLITTER_EFFECT_INST_FLAG_HAS_A3DA_TRANS))
return;
return;
mat4 mat;
int32_t(FASTCALL * sub_1401D5010)(int32_t a1)
= (void*)0x00000001401D5010;
@@ -185,295 +305,105 @@ void FASTCALL glitter_effect_inst_get_a3da(glitter_effect_inst* a1) {
mat4* (FASTCALL * sub_140516750)(int64_t a1)
= (void*)0x0000000140516750;
v3 = a1->a3da;
if (a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_INDEX) {
if (a1->flags & GLITTER_EFFECT_INST_CHARA_ANIM) {
v4 = sub_1405320E0();
if (v4 && sub_1405327B0(v4, v3->object_index) && (v6 = sub_140532030(v4, v3->object_index))) {
mat0 = *sub_140516750(v6);
vec4_length(mat0.row0, a2.x);
vec4_length(mat0.row1, a2.y);
if (v4 && sub_1405327B0(v4, ext_anim->chara_index) && (v6 = sub_140532030(v4, ext_anim->chara_index))) {
mat = *sub_140516750(v6);
vec4_length(mat.row0, a2.x);
vec4_length(mat.row1, a2.y);
vec2_sub(*(vec2*)&a2, vec2_identity, *(vec2*)&a2);
a2.z = 0.0f;
a1->a3da_scale = a2;
a1->flags |= GLITTER_EFFECT_INST_FLAG_HAS_A3DA_SCALE;
if (v3->index != 201) {
v15 = sub_140516730(v6, v3->index);
if (v15) {
mat1 = *v15;
mat4_mult(&mat0, &mat1, &mat0);
if (a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_TRANS_ONLY) {
v3->mat = mat4_identity;
v3->translation = *(vec3*)&mat0.row3;
}
else
v3->mat = mat0;
goto SetFlags;
}
}
else {
if (a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_TRANS_ONLY) {
v3->mat = mat4_identity;
v3->translation = *(vec3*)&mat0.row3;
}
else
v3->mat = mat0;
goto SetFlags;
a1->ext_anim_scale = a2;
a1->flags |= GLITTER_EFFECT_INST_HAS_EXT_ANIM_SCALE;
if (ext_anim->node_index == 201)
goto set_mat;
else if (v15 = sub_140516730(v6, ext_anim->node_index)) {
mat4_mult(&mat, v15, &mat);
goto set_mat;
}
}
}
else if (~a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_NAME) {
if (v3->index < 0) {
if (!v3->mesh_name)
else if (~a1->flags & GLITTER_EFFECT_INST_SET_EXT_ANIM_BY_OBJECT_NAME) {
if (ext_anim->node_index < 0) {
if (!ext_anim->name)
return;
v3->index = sub_140459DE0(v3->object_index, v3->mesh_name);
ext_anim->node_index = sub_140459DE0(ext_anim->object_hash, ext_anim->name);
}
if (v3->index >= 0) {
v43 = sub_140459D40(v3->object_index, v3->index);
if (ext_anim->node_index >= 0) {
v43 = sub_140459D40(ext_anim->object_hash, ext_anim->node_index);
if (v43) {
v3->translation = *(vec3*)(v43 + 4);
goto SetFlags;
ext_anim->translation = *(vec3*)(v43 + 4);
goto set_flags;
}
}
}
else {
if (v3->dword00 == -1 || !(v24 = sub_1401D5BC0(v3->dword00, v3->dword08, v3->object_is_hrc))) {
v3->dword00 = sub_1401D6090(v3->object_index, &v3->dword08, &v3->object_is_hrc);
if (v3->dword00 == -1)
if (ext_anim->dword00 == -1 || !(v24 = sub_1401D5BC0(ext_anim->dword00,
ext_anim->dword08, ext_anim->object_is_hrc))) {
ext_anim->dword00 = sub_1401D6090(ext_anim->object_hash,
&ext_anim->dword08, &ext_anim->object_is_hrc);
if (ext_anim->dword00 == -1)
return;
v3->index = -1;
v24 = sub_1401D5BC0(v3->dword00, v3->dword08, v3->object_is_hrc);
ext_anim->node_index = -1;
v24 = sub_1401D5BC0(ext_anim->dword00, ext_anim->dword08, ext_anim->object_is_hrc);
if (!v24)
return;
}
mat0 = mat4_identity;
v26 = sub_1401D5010(v3->dword00);
if (v26 >= 0 && v26 <= 5) {
v27 = sub_1405320E0();
if (sub_1405327B0(v27, v26)) {
mat0 = *sub_140516750(sub_140532030(v27, v26));
vec4_length(mat0.row0, a2.x);
vec4_length(mat0.row1, a2.y);
mat = mat4_identity;
chara_index = sub_1401D5010(ext_anim->dword00);
if (chara_index >= 0 && chara_index <= 5) {
v4 = sub_1405320E0();
if (sub_1405327B0(v4, chara_index) && (v6 = sub_140532030(v4, chara_index))) {
mat = *sub_140516750(v6);
vec4_length(mat.row0, a2.x);
vec4_length(mat.row1, a2.y);
vec2_sub(*(vec2*)&a2, vec2_identity, *(vec2*)&a2);
a2.z = 0.0f;
a1->a3da_scale = a2;
a1->flags |= GLITTER_EFFECT_INST_FLAG_HAS_A3DA_SCALE;
a1->ext_anim_scale = a2;
a1->flags |= GLITTER_EFFECT_INST_HAS_EXT_ANIM_SCALE;
}
}
mat1 = *(mat4*)v24;
if (v3->mesh_name) {
if (v3->index < 0) {
v3->index = sub_140459DE0(v3->object_index, v3->mesh_name);
}
if (ext_anim->name) {
if (ext_anim->node_index < 0)
ext_anim->node_index = sub_140459DE0(ext_anim->object_hash, ext_anim->name);
if (v3->index >= 0) {
v43 = sub_140459D40(v3->object_index, v3->index);
if (ext_anim->node_index >= 0) {
v43 = sub_140459D40(ext_anim->object_hash, ext_anim->node_index);
if (v43) {
mat4_mult(&mat0, &mat1, &v3->mat);
v3->translation = *(vec3*)(v43 + 4);
goto SetFlags;
mat4_mult(&mat, (mat4*)v24, &ext_anim->mat);
ext_anim->translation = *(vec3*)(v43 + 4);
goto set_flags;
}
}
}
else {
mat4_mult(&mat0, &mat1, &mat0);
if (a1->flags & GLITTER_EFFECT_INST_FLAG_SET_A3DA_TRANS_ONLY) {
v3->mat = mat4_identity;
v3->translation = *(vec3*)&mat0.row3;
}
else
v3->mat = mat0;
goto SetFlags;
mat4_mult(&mat, (mat4*)v24, &mat);
goto set_mat;
}
}
return;
SetFlags:
if (a1->flags & GLITTER_EFFECT_INST_FLAG_HAS_A3DA_NON_INIT) {
a1->flags &= ~GLITTER_EFFECT_INST_FLAG_HAS_A3DA_NON_INIT;
a1->flags |= GLITTER_EFFECT_INST_FLAG_HAS_A3DA_TRANS;
set_mat:
if (a1->flags & GLITTER_EFFECT_INST_EXT_ANIM_TRANS_ONLY) {
ext_anim->mat = mat4_identity;
mat4_get_translation(&mat, ext_anim->translation);
}
}
int32_t FASTCALL glitter_effect_inst_get_alpha(glitter_effect_inst* a1) {
return (a1->data.flags & GLITTER_EFFECT_FLAG_ALPHA) ? 2 : 1;
}
int32_t FASTCALL glitter_effect_inst_get_fog(glitter_effect_inst* a1) {
if (a1->data.flags & GLITTER_EFFECT_FLAG_FOG)
return 1;
else if (a1->data.flags & GLITTER_EFFECT_FLAG_FOG_HEIGHT)
return 2;
else
return 0;
ext_anim->mat = mat;
set_flags:
if (a1->flags & GLITTER_EFFECT_INST_HAS_EXT_ANIM_NON_INIT) {
a1->flags &= ~GLITTER_EFFECT_INST_HAS_EXT_ANIM_NON_INIT;
a1->flags |= GLITTER_EFFECT_INST_HAS_EXT_ANIM_TRANS;
}*/
}
void FASTCALL glitter_effect_inst_get_value(glitter_effect_inst* a1, float_t frame, int32_t random) {
int64_t length;
glitter_curve* curve;
float_t value;
length = a1->effect->curve.end - a1->effect->curve.begin;
if (!length)
return;
for (int32_t i = 0; i < length; i++) {
curve = a1->effect->curve.begin[i];
if (!glitter_curve_get_value(curve, frame, &value, random + i))
continue;
switch (curve->type) {
case GLITTER_CURVE_TRANSLATION_X:
a1->translation.x = value;
break;
case GLITTER_CURVE_TRANSLATION_Y:
a1->translation.y = value;
break;
case GLITTER_CURVE_TRANSLATION_Z:
a1->translation.z = value;
break;
case GLITTER_CURVE_ROTATION_X:
a1->rotation.x = value;
break;
case GLITTER_CURVE_ROTATION_Y:
a1->rotation.y = value;
break;
case GLITTER_CURVE_ROTATION_Z:
a1->rotation.z = value;
break;
case GLITTER_CURVE_SCALE_X:
a1->scale.x = value;
break;
case GLITTER_CURVE_SCALE_Y:
a1->scale.y = value;
break;
case GLITTER_CURVE_SCALE_Z:
a1->scale.z = value;
break;
case GLITTER_CURVE_SCALE_ALL:
a1->scale_all = value;
break;
case GLITTER_CURVE_COLOR_R:
a1->color.x = value;
break;
case GLITTER_CURVE_COLOR_G:
a1->color.y = value;
break;
case GLITTER_CURVE_COLOR_B:
a1->color.z = value;
break;
case GLITTER_CURVE_COLOR_A:
a1->color.w = value;
break;
}
}
}
bool FASTCALL glitter_effect_inst_has_ended(glitter_effect_inst* effect, bool a2) {
glitter_emitter_inst** i;
if (~effect->flags & GLITTER_EFFECT_INST_FLAG_FREE)
return false;
else if (!a2)
return true;
for (i = effect->emitters.begin; i != effect->emitters.end; i++)
if (!glitter_emitter_inst_has_ended(*i, a2))
return false;
return true;
}
void FASTCALL glitter_effect_inst_reset(glitter_effect_inst* a1, glitter_scene* a2) {
glitter_emitter_inst** i;
a1->frame = -a1->data.appear_time;
a1->flags = 0;
for (i = a1->emitters.begin; i != a1->emitters.end; i++)
glitter_emitter_inst_reset(*i);
glitter_effect_inst_reset_sub(a1, a2);
}
void FASTCALL glitter_effect_inst_reset_sub(glitter_effect_inst* a1, glitter_scene* a2) {
float_t delta_frame;
float_t start_time;
if (a1->data.start_time <= 0.0f)
return;
delta_frame = 2.0f;
for (start_time = a1->data.start_time; start_time > 0.0f; start_time -= delta_frame) {
a1->flags |= GLITTER_EFFECT_INST_FLAG_JUST_INIT;
if (start_time < delta_frame)
delta_frame -= start_time;
glitter_effect_inst_update_value_init(a1, delta_frame);
glitter_effect_inst_emit_init(a1, a2, delta_frame);
}
glitter_effect_inst_update_mat(a1);
}
void FASTCALL glitter_effect_inst_update_mat(glitter_effect_inst* a1) {
glitter_emitter_inst** i;
vec3 scale;
if (a1->flags & GLITTER_EFFECT_INST_FLAG_JUST_INIT) {
mat4_translate(a1->translation.x, a1->translation.y, a1->translation.z, &a1->mat);
mat4_rot(&a1->mat, a1->rotation.x, a1->rotation.y, a1->rotation.z, &a1->mat);
vec3_mult_scalar(a1->scale, a1->scale_all, scale);
mat4_scale_rot(&a1->mat, scale.x, scale.y, scale.z, &a1->mat);
for (i = a1->emitters.begin; i != a1->emitters.end; ++i)
glitter_emitter_inst_update_mat(*i, a1);
a1->flags &= ~GLITTER_EFFECT_INST_FLAG_JUST_INIT;
}
}
void FASTCALL glitter_effect_inst_update_value_frame(glitter_effect_inst* effect, float_t delta_frame) {
vec3 scale;
glitter_emitter_inst** i;
mat4 mat;
vec3 translation;
glitter_effect_inst_get_value(effect, effect->frame, effect->random);
vec3_mult_scalar(effect->scale, effect->scale_all, scale);
glitter_effect_inst_get_a3da(effect);
if (~effect->flags & GLITTER_EFFECT_INST_FLAG_HAS_A3DA_TRANS || !effect->a3da)
translation = effect->translation;
else
vec3_add(effect->translation, effect->a3da->translation, translation);
mat4_translate(translation.x, translation.y, translation.z, &mat);
mat4_rot(&mat, effect->rotation.x, effect->rotation.y, effect->rotation.z, &mat);
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &mat);
effect->mat = mat;
for (i = effect->emitters.begin; i != effect->emitters.end; ++i)
glitter_emitter_inst_update_value_frame(*i, effect, delta_frame);
}
void FASTCALL glitter_effect_inst_update_value_init(glitter_effect_inst* a1, float_t delta_frame) {
glitter_emitter_inst** i;
if (a1->frame < 0.0f)
return;
glitter_effect_inst_get_value(a1, a1->frame, a1->random);
for (i = a1->emitters.begin; i != a1->emitters.end; ++i)
glitter_emitter_inst_update_value_init(*i, a1->frame, delta_frame);
}
void FASTCALL glitter_effect_inst_dispose(glitter_effect_inst* ei) {
if (ei->a3da) {
free(ei->a3da->mesh_name);
free(ei->a3da);
}
vector_ptr_glitter_emitter_inst_free(&ei->emitters, (void*)glitter_emitter_inst_dispose);
free(ei);
}
static int32_t FASTCALL glitter_effect_inst_get_a3da_index(int32_t index) {
static int32_t FASTCALL glitter_aft_effect_inst_get_ext_anim_bone_index(int32_t index) {
switch (index) {
case 0:
return 15;
@@ -515,3 +445,143 @@ static int32_t FASTCALL glitter_effect_inst_get_a3da_index(int32_t index) {
return 201;
}
}
static int32_t FASTCALL glitter_f2_effect_inst_get_ext_anim_bone_index(int32_t index) {
switch (index) {
case 0:
return 15;
case 1:
return 54;
case 2:
return 0;
case 3:
return 7;
case 4:
return 98;
case 5:
return 100;
case 6:
return 101;
case 7:
return 115;
case 8:
return 132;
case 9:
return 136;
case 10:
return 137;
case 11:
return 151;
case 12:
return 186;
case 13:
return 176;
case 14:
return 175;
case 15:
return 189;
case 16:
return 183;
case 17:
return 182;
default:
return 193;
}
}
static void FASTCALL glitter_effect_inst_get_value(GPM, glitter_effect_inst* a1, float_t frame) {
int64_t length;
glitter_curve* curve;
float_t value;
length = a1->effect->curve.end - a1->effect->curve.begin;
if (!length)
return;
for (int32_t i = 0; i < length; i++) {
curve = a1->effect->curve.begin[i];
if (!glitter_curve_get_value(GPM_VAL, curve, frame, &value, a1->random.value + i, &a1->random_shared))
continue;
switch (curve->type) {
case GLITTER_CURVE_TRANSLATION_X:
a1->translation.x = value;
break;
case GLITTER_CURVE_TRANSLATION_Y:
a1->translation.y = value;
break;
case GLITTER_CURVE_TRANSLATION_Z:
a1->translation.z = value;
break;
case GLITTER_CURVE_ROTATION_X:
a1->rotation.x = value;
break;
case GLITTER_CURVE_ROTATION_Y:
a1->rotation.y = value;
break;
case GLITTER_CURVE_ROTATION_Z:
a1->rotation.z = value;
break;
case GLITTER_CURVE_SCALE_X:
a1->scale.x = value;
break;
case GLITTER_CURVE_SCALE_Y:
a1->scale.y = value;
break;
case GLITTER_CURVE_SCALE_Z:
a1->scale.z = value;
break;
case GLITTER_CURVE_SCALE_ALL:
a1->scale_all = value;
break;
/*case GLITTER_CURVE_COLOR_R:
a1->color.x = value;
break;
case GLITTER_CURVE_COLOR_G:
a1->color.y = value;
break;
case GLITTER_CURVE_COLOR_B:
a1->color.z = value;
break;
case GLITTER_CURVE_COLOR_A:
a1->color.w = value;
break;*/
}
}
}
static void FASTCALL glitter_effect_inst_reset_sub(GPM, glitter_effect_inst* a1, float_t emission) {
glitter_emitter_inst** i;
glitter_render_group** j;
vec3 scale;
float_t delta_frame;
float_t start_time;
if (a1->data.start_time <= 0)
return;
delta_frame = 2.0f;
for (start_time = (float_t)a1->data.start_time; start_time > 0.0f; start_time -= delta_frame) {
if (start_time < delta_frame)
delta_frame -= start_time;
glitter_effect_inst_get_value(GPM_VAL, a1, a1->frame);
mat4_translate(a1->translation.x, a1->translation.y, a1->translation.z, &a1->mat);
mat4_rot(&a1->mat, a1->rotation.x, a1->rotation.y, a1->rotation.z, &a1->mat);
vec3_mult_scalar(a1->scale, a1->scale_all, scale);
mat4_scale_rot(&a1->mat, scale.x, scale.y, scale.z, &a1->mat);
for (i = a1->emitters.begin; i != a1->emitters.end; ++i) {
if (!*i)
continue;
glitter_emitter_inst_update_value_init(GPM_VAL, *i, a1, delta_frame);
glitter_emitter_inst_emit(GPM_VAL, *i, delta_frame, emission);
}
for (j = a1->render_groups.begin; j != a1->render_groups.end; j++)
if (*j)
glitter_render_group_get_value(GPM_VAL, *j, delta_frame, true);
a1->frame += delta_frame;
}
}
+10 -16
View File
@@ -7,23 +7,17 @@
#include "glitter.h"
extern glitter_effect_inst* FASTCALL glitter_effect_inst_init(glitter_effect* a1,
glitter_scene* a2, size_t id, bool appear_now);
extern void FASTCALL glitter_effect_inst_copy(glitter_effect_inst* a1,
glitter_effect_inst* a2, glitter_scene* a3);
extern void FASTCALL glitter_effect_inst_emit(glitter_effect_inst* a1,
glitter_scene* a2, float_t delta_frame);
extern void FASTCALL glitter_effect_inst_emit_init(glitter_effect_inst* a1,
glitter_scene* a2, float_t delta_frame);
extern void FASTCALL glitter_effect_inst_free(glitter_effect_inst* a1, glitter_scene* a2, bool a3);
extern void FASTCALL glitter_effect_inst_get_a3da(glitter_effect_inst* a1);
extern glitter_effect_inst* FASTCALL glitter_effect_inst_init(GPM,
glitter_effect* a1, size_t id, float_t emission, bool appear_now);
extern void FASTCALL glitter_effect_inst_calc_draw(GPM, glitter_effect_inst* a1,
bool(FASTCALL* render_add_list_func)(glitter_particle_mesh*, vec4*, mat4*, mat4*));
extern void FASTCALL glitter_effect_inst_draw(GPM, glitter_effect_inst* a1, int32_t alpha);
extern int32_t FASTCALL glitter_effect_inst_get_alpha(glitter_effect_inst* a1);
extern size_t FASTCALL glitter_effect_inst_get_ctrl_count(glitter_effect_inst* a1, glitter_particle_type type);
extern size_t FASTCALL glitter_effect_inst_get_disp_count(glitter_effect_inst* a1, glitter_particle_type type);
extern int32_t FASTCALL glitter_effect_inst_get_fog(glitter_effect_inst* a1);
extern void FASTCALL glitter_effect_inst_get_value(glitter_effect_inst* a1, float_t frame, int32_t random);
extern bool FASTCALL glitter_effect_inst_has_ended(glitter_effect_inst* effect, bool a2);
extern void FASTCALL glitter_effect_inst_reset(glitter_effect_inst* a1, glitter_scene* a2);
extern void FASTCALL glitter_effect_inst_reset_sub(glitter_effect_inst* a1, glitter_scene* a2);
extern void FASTCALL glitter_effect_inst_update_mat(glitter_effect_inst* a1);
extern void FASTCALL glitter_effect_inst_update_value_frame(glitter_effect_inst* a1, float_t delta_frame);
extern void FASTCALL glitter_effect_inst_update_value_init(glitter_effect_inst* a1, float_t delta_frame);
extern void FASTCALL glitter_effect_inst_reset(GPM, glitter_effect_inst* a1, float_t emission);
extern void FASTCALL glitter_effect_inst_update_value_frame(GPM, glitter_effect_inst* a1,
float_t delta_frame, float_t emission);
extern void FASTCALL glitter_effect_inst_dispose(glitter_effect_inst* ei);
+369 -248
View File
@@ -8,15 +8,37 @@
#include "curve.h"
#include "particle.h"
static bool FASTCALL glitter_emitter_pack_file(f2_struct* st, glitter_emitter* a2, bool use_big_endian);
static bool FASTCALL glitter_emitter_unpack_file(int32_t* data, glitter_emitter* a2, bool use_big_endian);
static bool FASTCALL glitter_emitter_pack_file(GPM, f2_struct* st, glitter_emitter* a2);
static bool FASTCALL glitter_emitter_unpack_file(GPM, int32_t* data, glitter_emitter* a2, bool use_big_endian);
glitter_emitter* FASTCALL glitter_emitter_init() {
glitter_emitter* FASTCALL glitter_emitter_init(GPM) {
glitter_emitter* e = force_malloc(sizeof(glitter_emitter));
e->version = glt_type == GLITTER_X ? 0x04 : 0x02;
return e;
}
bool FASTCALL glitter_emitter_parse_file(glitter_effect_group* a1,
glitter_emitter* FASTCALL glitter_emitter_copy(GPM, glitter_emitter* e) {
if (!e)
return 0;
glitter_emitter* ec = force_malloc(sizeof(glitter_emitter));
*ec = *e;
ec->particles = (vector_ptr_glitter_particle){ 0, 0, 0 };
vector_ptr_glitter_particle_append(&ec->particles, e->particles.end - e->particles.begin);
for (glitter_particle** i = e->particles.begin; i != e->particles.end; i++)
if (*i) {
glitter_particle* p = glitter_particle_copy(GPM_VAL, *i);
if (p)
vector_ptr_glitter_particle_push_back(&ec->particles, &p);
}
ec->curve = (vector_ptr_glitter_curve){ 0, 0, 0 };
glitter_animation_copy(GPM_VAL, &e->curve, &ec->curve);
return ec;
}
bool FASTCALL glitter_emitter_parse_file(GPM, glitter_effect_group* a1,
f2_struct* st, vector_ptr_glitter_emitter* vec, glitter_effect* effect) {
f2_struct* i;
glitter_emitter* emitter;
@@ -24,9 +46,9 @@ bool FASTCALL glitter_emitter_parse_file(glitter_effect_group* a1,
if (!st || !st->header.data_size)
return false;
emitter = glitter_emitter_init();
emitter = glitter_emitter_init(GPM_VAL);
emitter->version = st->header.version;
if (!glitter_emitter_unpack_file(st->data, emitter, st->header.use_big_endian)) {
if (!glitter_emitter_unpack_file(GPM_VAL, st->data, emitter, st->header.use_big_endian)) {
glitter_emitter_dispose(emitter);
return false;
}
@@ -35,294 +57,393 @@ bool FASTCALL glitter_emitter_parse_file(glitter_effect_group* a1,
if (!i->header.data_size)
continue;
if (i->header.signature == 0x4D494E41)
glitter_animation_parse_file(i, &emitter->curve);
else if (i->header.signature == 0x4C435450)
glitter_particle_parse_file(a1, i, &emitter->particles, effect);
if (i->header.signature == reverse_endianess_uint32_t('ANIM'))
glitter_animation_parse_file(GPM_VAL, i, &emitter->curve, glitter_emitter_curve_flags);
else if (i->header.signature == reverse_endianess_uint32_t('PTCL'))
glitter_particle_parse_file(GPM_VAL, a1, i, &emitter->particles, effect);
}
vector_ptr_glitter_emitter_push_back(vec, &emitter);
return true;
}
bool FASTCALL glitter_emitter_unparse_file(glitter_effect_group* a1,
f2_struct* st, glitter_emitter* a3, glitter_effect* effect, bool use_big_endian) {
if (!glitter_emitter_pack_file(st, a3, use_big_endian))
bool FASTCALL glitter_emitter_unparse_file(GPM, glitter_effect_group* a1,
f2_struct* st, glitter_emitter* a3, glitter_effect* effect) {
if (!glitter_emitter_pack_file(GPM_VAL, st, a3))
return false;
f2_struct s;
if (glitter_animation_unparse_file(&s, &a3->curve, use_big_endian))
if (glitter_animation_unparse_file(GPM_VAL, &s, &a3->curve, glitter_emitter_curve_flags))
vector_f2_struct_push_back(&st->sub_structs, &s);
for (glitter_particle** i = a3->particles.begin; i != a3->particles.end; i++)
if (*i && glitter_particle_unparse_file(a1, &s, *i, effect, use_big_endian))
for (glitter_particle** i = a3->particles.begin; i != a3->particles.end; i++) {
if (!*i)
continue;
f2_struct s;
if (glitter_particle_unparse_file(GPM_VAL, a1, &s, *i, effect))
vector_f2_struct_push_back(&st->sub_structs, &s);
}
return true;
}
void FASTCALL glitter_emitter_dispose(glitter_emitter* e) {
vector_ptr_glitter_curve_free(&e->curve, (void*)glitter_curve_dispose);
vector_ptr_glitter_particle_free(&e->particles, (void*)glitter_particle_dispose);
vector_ptr_glitter_curve_free(&e->curve, glitter_curve_dispose);
vector_ptr_glitter_particle_free(&e->particles, glitter_particle_dispose);
free(e);
}
static bool FASTCALL glitter_emitter_pack_file(f2_struct* st, glitter_emitter* a2, bool use_big_endian) {
static bool FASTCALL glitter_emitter_pack_file(GPM, f2_struct* st, glitter_emitter* a2) {
size_t l;
int32_t* d;
size_t d;
if (!a2->version)
if (a2->version != 1 && a2->version != 2)
return false;
memset(st, 0, sizeof(f2_struct));
l = 96;
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
l += 12;
break;
case GLITTER_EMITTER_CYLINDER:
l += 20;
break;
case GLITTER_EMITTER_SPHERE:
l += 16;
break;
case GLITTER_EMITTER_POLYGON:
l += 8;
break;
default:
return false;
}
memset(st, 0, sizeof(f2_struct));
l = 0;
uint32_t o;
vector_enrs_entry e = { 0, 0, 0 };
enrs_entry ee;
ee = (enrs_entry){ 0, 5, 96, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 5, ENRS_TYPE_DWORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 2, ENRS_TYPE_WORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 2, ENRS_TYPE_DWORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 2, ENRS_TYPE_WORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 15, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 96;
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
ee = (enrs_entry){ o, 1, 12, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 3, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 12;
break;
case GLITTER_EMITTER_CYLINDER:
ee = (enrs_entry){ o, 1, 20, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 5, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 20;
break;
case GLITTER_EMITTER_SPHERE:
ee = (enrs_entry){ o, 1, 16, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 4, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 16;
break;
case GLITTER_EMITTER_POLYGON:
ee = (enrs_entry){ o, 1, 8, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 2, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
l += o = 8;
break;
}
l = align_val(l, 0x10);
d = force_malloc(l);
d = (size_t)force_malloc(l);
st->length = l;
st->data = d;
st->data = (void*)d;
st->enrs = e;
if (use_big_endian) {
d[0] = reverse_endianess_int32_t((int32_t)roundf(a2->data.start_time));
d[1] = reverse_endianess_int32_t((int32_t)roundf(a2->data.life_time));
d[2] = reverse_endianess_int32_t((int32_t)roundf(a2->data.loop_start_time));
d[3] = reverse_endianess_int32_t((int32_t)roundf(a2->data.loop_end_time));
d[4] = reverse_endianess_int32_t(a2->data.flags);
*((int16_t*)d + 10) = reverse_endianess_int16_t((int16_t)a2->data.type);
*((int16_t*)d + 11) = reverse_endianess_int16_t((int16_t)a2->data.direction);
*(float_t*)&d[6] = reverse_endianess_float_t(a2->data.emission_interval);
*(float_t*)&d[7] = reverse_endianess_float_t(a2->data.particles_per_emission);
//*((int16_t*)data + 16) = reverse_endianess_int16_t((int16_t)a3->data.dword2C);
/*if (a2->version > 1)
*((int16_t*)data + 17) = reverse_endianess_uint16_t((int16_t)a3->data.dword30);*/
*(int32_t*)d = a2->data.start_time;
*(int32_t*)(d + 4) = a2->data.life_time;
*(int32_t*)(d + 8) = a2->data.loop_start_time;
*(int32_t*)(d + 12) = a2->data.loop_end_time;
*(int32_t*)(d + 16) = a2->data.flags;
*(int16_t*)(d + 20) = (int16_t)a2->data.type;
*(int16_t*)(d + 22) = (int16_t)a2->data.direction;
*(float_t*)(d + 24) = a2->data.emission_interval;
*(float_t*)(d + 28) = a2->data.particles_per_emission;
*(int16_t*)(d + 32) = 0;
*(int16_t*)(d + 34) = 0;
*(float_t*)&d[9] = reverse_endianess_float_t(a2->translation.x);
*(float_t*)&d[10] = reverse_endianess_float_t(a2->translation.y);
*(float_t*)&d[11] = reverse_endianess_float_t(a2->translation.z);
*(float_t*)&d[12] = reverse_endianess_float_t(a2->rotation.x);
*(float_t*)&d[13] = reverse_endianess_float_t(a2->rotation.y);
*(float_t*)&d[14] = reverse_endianess_float_t(a2->rotation.z);
*(float_t*)&d[15] = reverse_endianess_float_t(a2->scale.x);
*(float_t*)&d[16] = reverse_endianess_float_t(a2->scale.y);
*(float_t*)&d[17] = reverse_endianess_float_t(a2->scale.z);
*(float_t*)&d[18] = reverse_endianess_float_t(a2->data.rotation_add.x);
*(float_t*)&d[19] = reverse_endianess_float_t(a2->data.rotation_add.y);
*(float_t*)&d[20] = reverse_endianess_float_t(a2->data.rotation_add.z);
*(float_t*)&d[21] = reverse_endianess_float_t(a2->data.rotation_add_random.x);
*(float_t*)&d[22] = reverse_endianess_float_t(a2->data.rotation_add_random.y);
*(float_t*)&d[23] = reverse_endianess_float_t(a2->data.rotation_add_random.z);
*(vec3*)(d + 36) = a2->translation;
*(vec3*)(d + 48) = a2->rotation;
*(vec3*)(d + 60) = a2->scale;
*(vec3*)(d + 72) = a2->data.rotation_add;
*(vec3*)(d + 84) = a2->data.rotation_add_random;
d += 96;
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
*(vec3*)d = a2->data.box.size;
break;
case GLITTER_EMITTER_CYLINDER:
*(float_t*)d = a2->data.cylinder.radius;
*(float_t*)(d + 4) = a2->data.cylinder.height;
*(float_t*)(d + 8) = a2->data.cylinder.start_angle;
*(float_t*)(d + 12) = a2->data.cylinder.end_angle;
*(int32_t*)(d + 16) = ((int32_t)a2->data.cylinder.direction << 1)
| (a2->data.cylinder.on_edge ? 1 : 0);
break;
case GLITTER_EMITTER_SPHERE:
*(float_t*)d = a2->data.sphere.radius;
*(float_t*)(d + 4) = a2->data.sphere.latitude;
*(float_t*)(d + 8) = a2->data.sphere.longitude;
*(int32_t*)(d + 12) = ((int32_t)a2->data.sphere.direction << 1)
| (a2->data.sphere.on_edge ? 1 : 0);
break;
case GLITTER_EMITTER_POLYGON:
*(float_t*)d = a2->data.polygon.size;
*(int32_t*)(d + 4) = a2->data.polygon.count;
break;
}
else {
d[0] = (int32_t)roundf(a2->data.start_time);
d[1] = (int32_t)roundf(a2->data.life_time);
d[2] = (int32_t)roundf(a2->data.loop_start_time);
d[3] = (int32_t)roundf(a2->data.loop_end_time);
d[4] = a2->data.flags;
*((int16_t*)d + 10) = (int16_t)a2->data.type;
*((int16_t*)d + 11) = (int16_t)a2->data.direction;
*(float_t*)&d[6] = a2->data.emission_interval;
*(float_t*)&d[7] = a2->data.particles_per_emission;
//*((int16_t*)data + 16) = (int16_t)a3->data.dword2C;
/*if (a2->version > 1)
*((int16_t*)data + 17) = (int16_t)a3->data.dword30;*/
*(vec3*)&d[9] = a2->translation;
*(vec3*)&d[12] = a2->rotation;
*(vec3*)&d[15] = a2->scale;
*(vec3*)&d[18] = a2->data.rotation_add;
*(vec3*)&d[21] = a2->data.rotation_add_random;
}
d += 24;
if (use_big_endian)
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
*(float_t*)&d[0] = reverse_endianess_float_t(a2->data.box.size.x);
*(float_t*)&d[1] = reverse_endianess_float_t(a2->data.box.size.y);
*(float_t*)&d[2] = reverse_endianess_float_t(a2->data.box.size.z);
break;
case GLITTER_EMITTER_CYLINDER:
*(float_t*)&d[0] = reverse_endianess_float_t(a2->data.cylinder.radius);
*(float_t*)&d[1] = reverse_endianess_float_t(a2->data.cylinder.height);
*(float_t*)&d[2] = reverse_endianess_float_t(a2->data.cylinder.start_angle);
*(float_t*)&d[3] = reverse_endianess_float_t(a2->data.cylinder.end_angle);
d[4] = reverse_endianess_int32_t(((int32_t)a2->data.cylinder.direction << 1)
| (a2->data.cylinder.plain ? 1 : 0));
break;
case GLITTER_EMITTER_SPHERE:
*(float_t*)&d[0] = reverse_endianess_float_t(a2->data.sphere.radius);
*(float_t*)&d[1] = reverse_endianess_float_t(a2->data.sphere.latitude);
*(float_t*)&d[2] = reverse_endianess_float_t(a2->data.sphere.longitude);
d[3] = reverse_endianess_int32_t(((int32_t)a2->data.cylinder.direction << 1)
| (a2->data.cylinder.plain ? 1 : 0));
break;
case GLITTER_EMITTER_POLYGON:
*(float_t*)&d[0] = reverse_endianess_float_t(a2->data.polygon.scale);
d[1] = reverse_endianess_int32_t(a2->data.polygon.count);
break;
}
else
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
*(vec3*)&d[0] = a2->data.box.size;
break;
case GLITTER_EMITTER_CYLINDER:
*(float_t*)&d[0] = a2->data.cylinder.radius;
*(float_t*)&d[1] = a2->data.cylinder.height;
*(float_t*)&d[2] = a2->data.cylinder.start_angle;
*(float_t*)&d[3] = a2->data.cylinder.end_angle;
d[4] = ((int32_t)a2->data.cylinder.direction << 1)
| (a2->data.cylinder.plain ? 1 : 0);
break;
case GLITTER_EMITTER_SPHERE:
*(float_t*)&d[0] = a2->data.sphere.radius;
*(float_t*)&d[1] = a2->data.sphere.latitude;
*(float_t*)&d[2] = a2->data.sphere.longitude;
d[3] = ((int32_t)a2->data.cylinder.direction << 1)
| (a2->data.cylinder.plain ? 1 : 0);
break;
case GLITTER_EMITTER_POLYGON:
*(float_t*)&d[0] = a2->data.polygon.scale;
d[1] = a2->data.polygon.count;
break;
}
st->header.signature = 0x54494D45;
st->header.signature = reverse_endianess_uint32_t('EMIT');
st->header.length = 0x20;
st->header.use_big_endian = use_big_endian ? true : false;
st->header.use_big_endian = false;
st->header.use_section_size = true;
st->header.version = a2->version;
return true;
}
static bool FASTCALL glitter_emitter_unpack_file(int32_t* data, glitter_emitter* a2, bool use_big_endian) {
if (use_big_endian) {
a2->data.start_time = (float_t)reverse_endianess_int32_t(data[0]);
a2->data.life_time = (float_t)reverse_endianess_int32_t(data[1]);
a2->data.loop_start_time = (float_t)reverse_endianess_int32_t(data[2]);
a2->data.loop_end_time = (float_t)reverse_endianess_int32_t(data[3]);
a2->data.flags = reverse_endianess_int32_t(data[4]);
static bool FASTCALL glitter_emitter_unpack_file(GPM,
int32_t* data, glitter_emitter* a2, bool use_big_endian) {
if (glt_type == GLITTER_X) {
if (use_big_endian) {
a2->data.start_time = reverse_endianess_int32_t(data[0]);
a2->data.life_time = reverse_endianess_int32_t(data[1]);
a2->data.loop_start_time = reverse_endianess_int32_t(data[2]);
a2->data.loop_end_time = reverse_endianess_int32_t(data[3]);
a2->data.flags = reverse_endianess_int32_t(data[4]);
}
else {
a2->data.start_time = data[0];
a2->data.life_time = data[1];
a2->data.loop_start_time = data[2];
a2->data.loop_end_time = data[3];
a2->data.flags = data[4];
}
if (a2->version != 3 && a2->version != 4)
return false;
if (use_big_endian) {
a2->data.type = reverse_endianess_int16_t(*((int16_t*)data + 10));
a2->data.direction = reverse_endianess_int16_t(*((int16_t*)data + 11));
a2->data.emission_interval = reverse_endianess_float_t(*(float_t*)&data[6]);
a2->data.particles_per_emission = reverse_endianess_float_t(*(float_t*)&data[7]);
a2->data.timer = reverse_endianess_int16_t(*((int16_t*)data + 16));
a2->data.seed = reverse_endianess_int32_t(data[9]);
}
else {
a2->data.type = *((int16_t*)data + 10);
a2->data.direction = *((int16_t*)data + 11);
a2->data.emission_interval = *(float_t*)&data[6];
a2->data.particles_per_emission = *(float_t*)&data[7];
a2->data.timer = *((int16_t*)data + 16);
a2->data.seed = data[9];
}
data += a2->version == 3 ? 14 : 13;
if (use_big_endian) {
a2->translation.x = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->translation.y = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->translation.z = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->rotation.x = reverse_endianess_float_t(*(float_t*)&data[3]);
a2->rotation.y = reverse_endianess_float_t(*(float_t*)&data[4]);
a2->rotation.z = reverse_endianess_float_t(*(float_t*)&data[5]);
a2->scale.x = reverse_endianess_float_t(*(float_t*)&data[6]);
a2->scale.y = reverse_endianess_float_t(*(float_t*)&data[7]);
a2->scale.z = reverse_endianess_float_t(*(float_t*)&data[8]);
a2->data.rotation_add.x = reverse_endianess_float_t(*(float_t*)&data[9]);
a2->data.rotation_add.y = reverse_endianess_float_t(*(float_t*)&data[10]);
a2->data.rotation_add.z = reverse_endianess_float_t(*(float_t*)&data[11]);
a2->data.rotation_add_random.x = reverse_endianess_float_t(*(float_t*)&data[12]);
a2->data.rotation_add_random.y = reverse_endianess_float_t(*(float_t*)&data[13]);
a2->data.rotation_add_random.z = reverse_endianess_float_t(*(float_t*)&data[14]);
}
else {
a2->translation = *(vec3*)&data[0];
a2->rotation = *(vec3*)&data[3];
a2->scale = *(vec3*)&data[6];
a2->data.rotation_add = *(vec3*)&data[9];
a2->data.rotation_add_random = *(vec3*)&data[12];
}
data += 15;
if (use_big_endian)
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size.x = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.box.size.y = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.box.size.z = reverse_endianess_float_t(*(float_t*)&data[2]);
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.cylinder.height = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.cylinder.start_angle = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.cylinder.end_angle = reverse_endianess_float_t(*(float_t*)&data[3]);
a2->data.cylinder.on_edge = reverse_endianess_int32_t(data[4]) & 1 ? true : false;
a2->data.cylinder.direction = reverse_endianess_int32_t(data[4]) >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.sphere.latitude = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.sphere.longitude = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.sphere.on_edge = reverse_endianess_int32_t(data[3]) & 1 ? true : false;
a2->data.sphere.direction = reverse_endianess_int32_t(data[3]) >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.size = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.polygon.count = reverse_endianess_int32_t(data[1]);
a2->data.polygon.direction = reverse_endianess_int32_t(data[2]) >> 1;
return true;
default:
return false;
}
else
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size = *(vec3*)&data[0];
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = *(float_t*)&data[0];
a2->data.cylinder.height = *(float_t*)&data[1];
a2->data.cylinder.start_angle = *(float_t*)&data[2];
a2->data.cylinder.end_angle = *(float_t*)&data[3];
a2->data.cylinder.on_edge = data[4] & 1 ? true : false;
a2->data.cylinder.direction = data[4] >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = *(float_t*)&data[0];
a2->data.sphere.latitude = *(float_t*)&data[1];
a2->data.sphere.longitude = *(float_t*)&data[2];
a2->data.sphere.on_edge = data[3] & 1 ? true : false;
a2->data.sphere.direction = data[3] >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.size = *(float_t*)&data[0];
a2->data.polygon.count = data[1];
a2->data.polygon.direction = data[2] >> 1;
return true;
default:
return false;
}
}
else {
a2->data.start_time = (float_t)data[0];
a2->data.life_time = (float_t)data[1];
a2->data.loop_start_time = (float_t)data[2];
a2->data.loop_end_time = (float_t)data[3];
a2->data.flags = data[4];
}
//a3->data.dword30 = 0;
if (!a2->version)
return false;
if (use_big_endian) {
a2->data.type = reverse_endianess_int16_t(*((int16_t*)data + 10));
a2->data.direction = reverse_endianess_int16_t(*((int16_t*)data + 11));
a2->data.emission_interval = reverse_endianess_float_t(*(float_t*)&data[6]);
a2->data.particles_per_emission = reverse_endianess_float_t(*(float_t*)&data[7]);
//a3->data.dword2C = reverse_endianess_int16_t(*((int16_t*)data + 16));
/*if (a2->version > 1)
a3->data.dword30 = reverse_endianess_uint16_t(*((uint16_t*)data + 17));*/
a2->translation.x = reverse_endianess_float_t(*(float_t*)&data[9]);
a2->translation.y = reverse_endianess_float_t(*(float_t*)&data[10]);
a2->translation.z = reverse_endianess_float_t(*(float_t*)&data[11]);
a2->rotation.x = reverse_endianess_float_t(*(float_t*)&data[12]);
a2->rotation.y = reverse_endianess_float_t(*(float_t*)&data[13]);
a2->rotation.z = reverse_endianess_float_t(*(float_t*)&data[14]);
a2->scale.x = reverse_endianess_float_t(*(float_t*)&data[15]);
a2->scale.y = reverse_endianess_float_t(*(float_t*)&data[16]);
a2->scale.z = reverse_endianess_float_t(*(float_t*)&data[17]);
a2->data.rotation_add.x = reverse_endianess_float_t(*(float_t*)&data[18]);
a2->data.rotation_add.y = reverse_endianess_float_t(*(float_t*)&data[19]);
a2->data.rotation_add.z = reverse_endianess_float_t(*(float_t*)&data[20]);
a2->data.rotation_add_random.x = reverse_endianess_float_t(*(float_t*)&data[21]);
a2->data.rotation_add_random.y = reverse_endianess_float_t(*(float_t*)&data[22]);
a2->data.rotation_add_random.z = reverse_endianess_float_t(*(float_t*)&data[23]);
}
else {
a2->data.type = *((int16_t*)data + 10);
a2->data.direction = *((int16_t*)data + 11);
a2->data.emission_interval = *(float_t*)&data[6];
a2->data.particles_per_emission = *(float_t*)&data[7];
//a3->data.dword2C = *((int16_t*)data + 16);
/*if (emit_version > 1)
a3->data.dword30 = *((uint16_t*)data + 17);*/
a2->translation = *(vec3*)&data[9];
a2->rotation = *(vec3*)&data[12];
a2->scale = *(vec3*)&data[15];
a2->data.rotation_add = *(vec3*)&data[18];
a2->data.rotation_add_random = *(vec3*)&data[21];
}
data += 24;
if (use_big_endian)
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size.x = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.box.size.y = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.box.size.z = reverse_endianess_float_t(*(float_t*)&data[2]);
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.cylinder.height = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.cylinder.start_angle = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.cylinder.end_angle = reverse_endianess_float_t(*(float_t*)&data[3]);
a2->data.cylinder.plain = reverse_endianess_int32_t(data[4]) & 1 ? true : false;
a2->data.cylinder.direction = reverse_endianess_int32_t(data[4]) >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.sphere.latitude = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.sphere.longitude = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.sphere.plain = reverse_endianess_int32_t(data[3]) & 1 ? true : false;
a2->data.sphere.direction = reverse_endianess_int32_t(data[3]) >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.scale = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.polygon.count = reverse_endianess_int32_t(data[1]);
return true;
if (use_big_endian) {
a2->data.start_time = reverse_endianess_int32_t(data[0]);
a2->data.life_time = reverse_endianess_int32_t(data[1]);
a2->data.loop_start_time = reverse_endianess_int32_t(data[2]);
a2->data.loop_end_time = reverse_endianess_int32_t(data[3]);
a2->data.flags = reverse_endianess_int32_t(data[4]);
}
else
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size = *(vec3*)&data[0];
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = *(float_t*)&data[0];
a2->data.cylinder.height = *(float_t*)&data[1];
a2->data.cylinder.start_angle = *(float_t*)&data[2];
a2->data.cylinder.end_angle = *(float_t*)&data[3];
a2->data.cylinder.plain = data[4] & 1 ? true : false;
a2->data.cylinder.direction = data[4] >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = *(float_t*)&data[0];
a2->data.sphere.latitude = *(float_t*)&data[1];
a2->data.sphere.longitude = *(float_t*)&data[2];
a2->data.sphere.plain = data[3] & 1 ? true : false;
a2->data.sphere.direction = data[3] >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.scale = *(float_t*)&data[0];
a2->data.polygon.count = data[1];
return true;
else {
a2->data.start_time = data[0];
a2->data.life_time = data[1];
a2->data.loop_start_time = data[2];
a2->data.loop_end_time = data[3];
a2->data.flags = data[4];
}
return false;
a2->data.timer = GLITTER_EMITTER_TIMER_BY_TIME;
a2->data.seed = 0;
if (a2->version != 1 && a2->version != 2)
return false;
if (use_big_endian) {
a2->data.type = reverse_endianess_int16_t(*((int16_t*)data + 10));
a2->data.direction = reverse_endianess_int16_t(*((int16_t*)data + 11));
a2->data.emission_interval = reverse_endianess_float_t(*(float_t*)&data[6]);
a2->data.particles_per_emission = reverse_endianess_float_t(*(float_t*)&data[7]);
a2->translation.x = reverse_endianess_float_t(*(float_t*)&data[9]);
a2->translation.y = reverse_endianess_float_t(*(float_t*)&data[10]);
a2->translation.z = reverse_endianess_float_t(*(float_t*)&data[11]);
a2->rotation.x = reverse_endianess_float_t(*(float_t*)&data[12]);
a2->rotation.y = reverse_endianess_float_t(*(float_t*)&data[13]);
a2->rotation.z = reverse_endianess_float_t(*(float_t*)&data[14]);
a2->scale.x = reverse_endianess_float_t(*(float_t*)&data[15]);
a2->scale.y = reverse_endianess_float_t(*(float_t*)&data[16]);
a2->scale.z = reverse_endianess_float_t(*(float_t*)&data[17]);
a2->data.rotation_add.x = reverse_endianess_float_t(*(float_t*)&data[18]);
a2->data.rotation_add.y = reverse_endianess_float_t(*(float_t*)&data[19]);
a2->data.rotation_add.z = reverse_endianess_float_t(*(float_t*)&data[20]);
a2->data.rotation_add_random.x = reverse_endianess_float_t(*(float_t*)&data[21]);
a2->data.rotation_add_random.y = reverse_endianess_float_t(*(float_t*)&data[22]);
a2->data.rotation_add_random.z = reverse_endianess_float_t(*(float_t*)&data[23]);
}
else {
a2->data.type = *((int16_t*)data + 10);
a2->data.direction = *((int16_t*)data + 11);
a2->data.emission_interval = *(float_t*)&data[6];
a2->data.particles_per_emission = *(float_t*)&data[7];
a2->translation = *(vec3*)&data[9];
a2->rotation = *(vec3*)&data[12];
a2->scale = *(vec3*)&data[15];
a2->data.rotation_add = *(vec3*)&data[18];
a2->data.rotation_add_random = *(vec3*)&data[21];
}
data += 24;
if (use_big_endian)
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size.x = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.box.size.y = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.box.size.z = reverse_endianess_float_t(*(float_t*)&data[2]);
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.cylinder.height = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.cylinder.start_angle = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.cylinder.end_angle = reverse_endianess_float_t(*(float_t*)&data[3]);
a2->data.cylinder.on_edge = reverse_endianess_int32_t(data[4]) & 1 ? true : false;
a2->data.cylinder.direction = reverse_endianess_int32_t(data[4]) >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.sphere.latitude = reverse_endianess_float_t(*(float_t*)&data[1]);
a2->data.sphere.longitude = reverse_endianess_float_t(*(float_t*)&data[2]);
a2->data.sphere.on_edge = reverse_endianess_int32_t(data[3]) & 1 ? true : false;
a2->data.sphere.direction = reverse_endianess_int32_t(data[3]) >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.size = reverse_endianess_float_t(*(float_t*)&data[0]);
a2->data.polygon.count = reverse_endianess_int32_t(data[1]);
return true;
default:
return false;
}
else
switch (a2->data.type) {
case GLITTER_EMITTER_BOX:
a2->data.box.size = *(vec3*)&data[0];
return true;
case GLITTER_EMITTER_CYLINDER:
a2->data.cylinder.radius = *(float_t*)&data[0];
a2->data.cylinder.height = *(float_t*)&data[1];
a2->data.cylinder.start_angle = *(float_t*)&data[2];
a2->data.cylinder.end_angle = *(float_t*)&data[3];
a2->data.cylinder.on_edge = data[4] & 1 ? true : false;
a2->data.cylinder.direction = data[4] >> 1;
return true;
case GLITTER_EMITTER_SPHERE:
a2->data.sphere.radius = *(float_t*)&data[0];
a2->data.sphere.latitude = *(float_t*)&data[1];
a2->data.sphere.longitude = *(float_t*)&data[2];
a2->data.sphere.on_edge = data[3] & 1 ? true : false;
a2->data.sphere.direction = data[3] >> 1;
return true;
case GLITTER_EMITTER_POLYGON:
a2->data.polygon.size = *(float_t*)&data[0];
a2->data.polygon.count = data[1];
return true;
default:
return false;
}
}
}
+5 -4
View File
@@ -7,9 +7,10 @@
#include "glitter.h"
extern glitter_emitter* FASTCALL glitter_emitter_init();;
extern bool FASTCALL glitter_emitter_parse_file(glitter_effect_group* a1,
extern glitter_emitter* FASTCALL glitter_emitter_init(GPM);;
extern glitter_emitter* FASTCALL glitter_emitter_copy(GPM, glitter_emitter* e);
extern bool FASTCALL glitter_emitter_parse_file(GPM, glitter_effect_group* a1,
f2_struct* st, vector_ptr_glitter_emitter* vec, glitter_effect* effect);
extern bool FASTCALL glitter_emitter_unparse_file(glitter_effect_group* a1,
f2_struct* st, glitter_emitter* a3, glitter_effect* effect, bool use_big_endian);
extern bool FASTCALL glitter_emitter_unparse_file(GPM, glitter_effect_group* a1,
f2_struct* st, glitter_emitter* a3, glitter_effect* effect);
extern void FASTCALL glitter_emitter_dispose(glitter_emitter* e);
+268 -385
View File
@@ -5,19 +5,40 @@
#include "emitter_inst.h"
#include "curve.h"
#include "effect_inst.h"
#include "particle_inst.h"
#include "random.h"
#include "../camera.h"
glitter_emitter_inst* FASTCALL glitter_emitter_inst_init(glitter_emitter* a1,
glitter_scene* a2, glitter_effect_inst* a3) {
extern camera* cam;
static void FASTCALL glitter_emitter_inst_emit_particle(GPM,
glitter_emitter_inst* a1, float_t emission);
static void FASTCALL glitter_emitter_inst_get_value(GPM,
glitter_emitter_inst* a1, float_t frame);
static void FASTCALL glitter_emitter_inst_update_mat(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2);
glitter_emitter_inst* FASTCALL glitter_emitter_inst_init(GPM,
glitter_emitter* a1, glitter_effect_inst* a2, float_t emission) {
glitter_particle** i;
glitter_particle_inst* particle;
switch (a1->data.type) {
case GLITTER_EMITTER_BOX:
case GLITTER_EMITTER_CYLINDER:
case GLITTER_EMITTER_SPHERE:
case GLITTER_EMITTER_POLYGON:
break;
default:
return 0;
}
glitter_emitter_inst* ei = force_malloc(sizeof(glitter_emitter_inst));
ei->emitter = a1;
ei->data = a1->data;
ei->random_ptr = &a2->random_shared;
ei->random.step = 1;
ei->translation = a1->translation;
ei->rotation = a1->rotation;
ei->scale = a1->scale;
@@ -26,56 +47,239 @@ glitter_emitter_inst* FASTCALL glitter_emitter_inst_init(glitter_emitter* a1,
ei->scale_all = 1.0f;
ei->emission_interval = ei->data.emission_interval;
ei->particles_per_emission = ei->data.particles_per_emission;
ei->frame = -ei->data.start_time;
ei->frame = (float_t)-ei->data.start_time;
if (ei->data.emission_interval >= -0.000001f)
ei->emission = fabs(ei->data.emission_interval) <= 0.000001f
? GLITTER_EMITTER_EMISSION_ON_START : GLITTER_EMITTER_EMISSION_ON_TIMER;
else
ei->emission = GLITTER_EMITTER_EMISSION_ON_END;
ei->loop = ei->data.flags & GLITTER_EMITTER_FLAG_LOOP ? true : false;
ei->loop = ei->data.flags & GLITTER_EMITTER_LOOP ? true : false;
vector_ptr_glitter_particle_inst_resize(&ei->particles, a1->particles.end - a1->particles.begin);
vector_ptr_glitter_particle_inst_append(&ei->particles, a1->particles.end - a1->particles.begin);
for (i = a1->particles.begin; i != a1->particles.end; i++) {
if (!*i)
continue;
particle = glitter_particle_inst_init(*i, a2, a3);
particle = glitter_particle_inst_init(GPM_VAL, *i, a2, ei, ei->random_ptr, emission);
vector_ptr_glitter_particle_inst_push_back(&ei->particles, &particle);
}
ei->random = glitter_random_get();
glitter_random_set(glitter_random_get() + 1);
ei->random.value = glitter_random_get_value(ei->random_ptr);
glitter_random_step_value(ei->random_ptr);
return ei;
}
void FASTCALL glitter_emitter_inst_copy(glitter_emitter_inst* a1, glitter_emitter_inst* a2, glitter_scene* a3) {
int64_t particles_count; // rbp
int64_t i; // rbx
void FASTCALL glitter_emitter_inst_free(GPM, glitter_emitter_inst* a1, float_t emission) {
glitter_particle_inst** i;
a2->translation = a1->translation;
a2->rotation = a1->rotation;
a2->scale = a1->scale;
a2->mat = a1->mat;
a2->mat_no_scale = a1->mat_no_scale;
a2->scale_all = a1->scale_all;
a2->emission_timer = a1->emission_timer;
a2->emission_interval = a1->emission_interval;
a2->particles_per_emission = a1->particles_per_emission;
a2->random = a1->random;
a2->loop = a1->loop;
a2->emission = a1->emission;
a2->frame = a1->frame;
a2->ended = a1->ended;
particles_count = a1->particles.end - a1->particles.begin;
if (particles_count != a2->particles.end - a2->particles.begin)
if (a1->ended)
return;
for (i = 0; i < particles_count; ++i)
glitter_particle_inst_copy(a1->particles.begin[i], a2->particles.begin[i], a3);
if (a1->emission == GLITTER_EMITTER_EMISSION_ON_END) {
glitter_emitter_inst_emit_particle(GPM_VAL, a1, emission);
a1->emission = GLITTER_EMITTER_EMISSION_EMITTED;
}
if (a1->loop && a1->data.loop_end_time >= 0.0f)
a1->loop = false;
a1->ended = true;
if (a1->data.flags & GLITTER_EMITTER_KILL_ON_END)
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_free(*i, true);
else
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_free(*i, false);
}
void FASTCALL glitter_emitter_inst_emit(glitter_emitter_inst* a1, glitter_scene* a2) {
void FASTCALL glitter_emitter_inst_emit(GPM,
glitter_emitter_inst* a1, float_t delta_frame, float_t emission) {
if (a1->frame < 0.0f) {
a1->frame += delta_frame;
return;
}
if (!a1->ended) {
if (a1->emission == GLITTER_EMITTER_EMISSION_ON_TIMER) {
if (a1->emission_timer >= 0.0f || a1->emission_interval >= 0.0f) {
a1->emission_timer -= delta_frame;
while (a1->emission_timer <= 0.0) {
glitter_emitter_inst_emit_particle(GPM_VAL, a1, emission);
if (a1->emission_interval > 0.0f)
a1->emission_timer += a1->emission_interval;
else
a1->emission_timer = -1.0;
}
}
}
else if (a1->emission == GLITTER_EMITTER_EMISSION_ON_START && a1->data.timer == GLITTER_EMITTER_TIMER_BY_TIME) {
a1->emission_timer -= delta_frame;
if (a1->emission_timer < 0.0) {
glitter_emitter_inst_emit_particle(GPM_VAL, a1, emission);
a1->emission = GLITTER_EMITTER_EMISSION_EMITTED;
}
}
}
if (!a1->loop && a1->frame >= a1->data.life_time)
glitter_emitter_inst_free(GPM_VAL, a1, emission);
a1->frame += delta_frame;
}
void FASTCALL glitter_emitter_inst_get_mesh_by_type(GPM, glitter_emitter_inst* a1,
int32_t index, vec3* scale, vec3* base_translation, vec3* direction, glitter_random* random) {
float_t radius;
float_t angle;
float_t longitude;
float_t latitude;
vec3 dir;
switch (a1->data.type) {
case GLITTER_EMITTER_BOX:
vec3_mult(a1->data.box.size, *scale, dir);
vec3_mult_scalar(dir, 0.5f, dir);
glitter_random_get_vec3(GPM_VAL, random, &dir, base_translation);
break;
case GLITTER_EMITTER_CYLINDER:
radius = a1->data.cylinder.radius * scale->x;
if (!a1->data.cylinder.on_edge)
radius = glitter_random_get_float_min_max(GPM_VAL, random, 0.0f, radius);
angle = glitter_random_get_float_min_max(GPM_VAL, random,
a1->data.cylinder.start_angle, a1->data.cylinder.end_angle);
dir.x = cosf(angle);
dir.y = 0.0f;
dir.z = sinf(angle);
base_translation->x = dir.x * radius;
base_translation->y = glitter_random_get_float(GPM_VAL, random,
a1->data.cylinder.height * scale->y * 0.5f);
base_translation->z = dir.z * radius;
if (a1->data.cylinder.direction == GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD)
*direction = dir;
else if (a1->data.cylinder.direction == GLITTER_EMITTER_EMISSION_DIRECTION_INWARD)
vec3_xor(dir, ((vec3){ -0.0f, 0.0f, -0.0f }), *direction);
break;
case GLITTER_EMITTER_SPHERE:
radius = a1->data.sphere.radius * scale->x;
if (!a1->data.sphere.on_edge)
radius = glitter_random_get_float_min_max(GPM_VAL, random, 0.0f, radius);
longitude = glitter_random_get_float_min_max(GPM_VAL, random,
a1->data.sphere.longitude * -0.5f, a1->data.sphere.longitude * 0.5f);
latitude = (float_t)M_PI_2 - glitter_random_get_float_min_max(GPM_VAL, random,
0.0f, a1->data.sphere.latitude);
dir.x = sinf(longitude) * cosf(latitude);
dir.y = sinf(latitude);
dir.z = cosf(longitude) * cosf(latitude);
vec3_mult_scalar(dir, radius, *base_translation);
if (a1->data.sphere.direction == GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD)
*direction = dir;
else if (a1->data.sphere.direction == GLITTER_EMITTER_EMISSION_DIRECTION_INWARD)
vec3_negate(dir, *direction);
break;
case GLITTER_EMITTER_POLYGON:
base_translation->x = sinf((float_t)index / (float_t)a1->data.polygon.count * 2.0f
* (float_t)M_PI + (float_t)M_PI_2) * a1->data.polygon.size * scale->x;
base_translation->y = 0.0f;
break;
}
}
bool FASTCALL glitter_emitter_inst_has_ended(glitter_emitter_inst* emitter, bool a2) {
glitter_particle_inst** i;
if (!emitter->ended)
return false;
else if (!a2)
return true;
for (i = emitter->particles.begin; i != emitter->particles.end; i++)
if (!glitter_particle_inst_has_ended(*i, a2))
return false;
return true;
}
uint8_t FASTCALL glitter_emitter_inst_random_get_step(glitter_emitter_inst* emitter) {
emitter->random.step++;
emitter->random.step++;
return (uint8_t)(emitter->random.step % 60);
}
void FASTCALL glitter_emitter_inst_reset(glitter_emitter_inst* a1) {
glitter_particle_inst** i;
a1->loop = a1->data.flags & GLITTER_EMITTER_LOOP ? true : false;
a1->frame = (float_t)-a1->data.start_time;
a1->ended = false;
a1->emission_timer = 0.0f;
if (a1->emission_interval >= -0.000001f)
a1->emission = fabsf(a1->emission_interval) <= 0.000001f
? GLITTER_EMITTER_EMISSION_ON_START : GLITTER_EMITTER_EMISSION_ON_TIMER;
else
a1->emission = GLITTER_EMITTER_EMISSION_ON_END;
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_reset(*i);
}
void FASTCALL glitter_emitter_inst_update_value_frame(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2, float_t delta_frame) {
vec3 rotation_add;
if (a1->frame < 0.0f)
return;
if (a1->loop) {
if (a1->data.loop_end_time < 0.0f || a1->frame < a1->data.loop_end_time) {
if (a1->frame >= a1->data.life_time) {
a1->frame -= a1->data.life_time;
if (a1->emission == GLITTER_EMITTER_EMISSION_EMITTED && a1->emission_interval > 0.0f)
a1->emission = GLITTER_EMITTER_EMISSION_ON_TIMER;
}
}
else
while (a1->frame > a1->data.loop_end_time)
a1->frame -= a1->data.loop_end_time - a1->data.loop_start_time;
}
glitter_emitter_inst_get_value(GPM_VAL, a1, a1->frame);
vec3_mult_scalar(a1->data.rotation_add, delta_frame, rotation_add);
vec3_add(a1->rotation, rotation_add, a1->rotation);
glitter_emitter_inst_update_mat(GPM_VAL, a1, a2);
}
void FASTCALL glitter_emitter_inst_update_value_init(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2, float_t delta_frame) {
vec3 rotation_add;
a1->has_distance = false;
if (a1->frame < 0.0f)
return;
if (a1->loop) {
if (a1->data.loop_end_time < 0.0f || a1->frame < a1->data.loop_end_time) {
if (a1->frame >= a1->data.life_time)
a1->frame -= a1->data.life_time;
}
else
while (a1->frame > a1->data.loop_end_time)
a1->frame -= a1->data.loop_end_time - a1->data.loop_start_time;
}
if (a1->frame < 0.0f)
return;
glitter_emitter_inst_get_value(GPM_VAL, a1, a1->frame);
vec3_mult_scalar(a1->data.rotation_add, delta_frame, rotation_add);
vec3_add(a1->rotation, rotation_add, a1->rotation);
glitter_emitter_inst_update_mat(GPM_VAL, a1, a2);
}
void FASTCALL glitter_emitter_inst_dispose(glitter_emitter_inst* ei) {
vector_ptr_glitter_particle_inst_free(&ei->particles, glitter_particle_inst_dispose);
free(ei);
}
static void FASTCALL glitter_emitter_inst_emit_particle(GPM,
glitter_emitter_inst* a1, float_t emission) {
int32_t count;
glitter_particle_inst** i;
@@ -85,173 +289,11 @@ void FASTCALL glitter_emitter_inst_emit(glitter_emitter_inst* a1, glitter_scene*
count = 1;
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_emit(*i, a2, a1, (int32_t)a1->particles_per_emission, count);
glitter_particle_inst_emit(GPM_VAL, *i, (int32_t)roundf(a1->particles_per_emission), count, emission);
}
void FASTCALL glitter_emitter_inst_emit_init(glitter_emitter_inst* a1,
glitter_scene* a2, glitter_effect_inst* a3, float_t delta_frame) {
if (a1->frame < 0.0f) {
a1->frame += delta_frame;
return;
}
if (!a1->ended) {
if (a1->emission == GLITTER_EMITTER_EMISSION_ON_TIMER) {
if (a1->emission_timer >= 0.0f || a1->emission_interval >= 0.0f) {
a1->emission_timer -= delta_frame;
if (a1->emission_timer <= 0.0f) {
glitter_effect_inst_update_mat(a3);
glitter_emitter_inst_emit(a1, a2);
if (a1->emission_interval > 0.0f)
a1->emission_timer += a1->emission_interval;
else
a1->emission_timer = -1.0f;
}
}
}
else if (a1->emission == GLITTER_EMITTER_EMISSION_ON_START) {
glitter_effect_inst_update_mat(a3);
glitter_emitter_inst_emit(a1, a2);
a1->emission = GLITTER_EMITTER_EMISSION_EMITTED;
}
}
if (!a1->loop && a1->data.life_time <= a1->frame)
glitter_emitter_inst_free(a1, a2, 0);
a1->frame += delta_frame;
}
void FASTCALL glitter_emitter_inst_emit_step(glitter_emitter_inst* a1,
glitter_scene* a2, glitter_effect_inst* a3, float_t delta_frame) {
if (a1->frame < 0.0f) {
a1->frame += delta_frame;
return;
}
if (!a1->ended) {
if (a1->emission == GLITTER_EMITTER_EMISSION_ON_TIMER) {
if (a1->emission_timer >= 0.0f || a1->emission_interval >= 0.0f) {
a1->emission_timer -= delta_frame;
if (a1->emission_timer <= 0.0f) {
glitter_emitter_inst_emit(a1, a2);
if (a1->emission_interval > 0.0f)
a1->emission_timer += a1->emission_interval;
else
a1->emission_timer = -1.0f;
}
}
}
else if (a1->emission == GLITTER_EMITTER_EMISSION_ON_START) {
a1->emission_timer -= delta_frame;
if (a1->emission_timer <= 0.0f) {
glitter_emitter_inst_emit(a1, a2);
a1->emission = GLITTER_EMITTER_EMISSION_EMITTED;
}
}
}
if (!a1->loop && a1->data.life_time <= a1->frame)
glitter_emitter_inst_free(a1, a2, 0);
a1->frame += delta_frame;
}
void FASTCALL glitter_emitter_inst_free(glitter_emitter_inst* a1, glitter_scene* a2, bool free) {
glitter_particle_inst** i;
if (a1->ended) {
if (free)
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_free(*i, true);
}
else {
if (a1->emission == GLITTER_EMITTER_EMISSION_ON_END) {
glitter_emitter_inst_emit(a1, a2);
a1->emission = GLITTER_EMITTER_EMISSION_EMITTED;
}
if (a1->loop && a1->data.loop_end_time >= 0.0f)
a1->loop = false;
a1->ended = true;
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_free(*i, false);
}
}
void FASTCALL glitter_emitter_inst_get_mesh_by_type(glitter_emitter_inst* a1,
int32_t index, vec3* scale, vec3* base_translation, vec3* direction) {
float_t radius; // xmm8_4
float_t angle; // xmm6_4
float_t v15; // xmm7_4
float_t v16; // xmm0_4
float_t v17; // xmm2_4
float_t v18; // xmm7_4
float_t v19; // xmm6_4
float_t longitude; // xmm8_4
float_t latitude; // xmm6_4
float_t v26; // xmm7_4
vec3 v27;
switch (a1->data.type) {
case GLITTER_EMITTER_BOX:
base_translation->x = glitter_random_get_float_clamp_min_max(a1->data.box.size.x * scale->x * 0.5f);
base_translation->y = glitter_random_get_float_clamp_min_max(a1->data.box.size.y * scale->y * 0.5f);
base_translation->z = glitter_random_get_float_clamp_min_max(a1->data.box.size.z * scale->z * 0.5f);
break;
case GLITTER_EMITTER_CYLINDER:
radius = a1->data.cylinder.radius * scale->x;
if (!a1->data.cylinder.plain)
radius = glitter_random_get_float_clamp(0.0f, radius);
angle = glitter_random_get_float_clamp(a1->data.cylinder.start_angle, a1->data.cylinder.end_angle);
v15 = cosf(angle);
v16 = sinf(angle);
v17 = 1.0f / sqrtf(v16 * v16 + v15 * v15);
v18 = v15 * v17;
v19 = v16 * v17;
base_translation->x = v18 * radius;
base_translation->y = glitter_random_get_float_clamp_min_max(a1->data.cylinder.height * scale->y * 0.5f);
base_translation->z = v19 * radius;
if (a1->data.cylinder.direction == GLITTER_EMITTER_EMISSION_DIRECTION_INWARD) {
direction->x = v18;
direction->y = 0.0f;
direction->z = v19;
}
else if(a1->data.cylinder.direction == GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD) {
direction->x = -v18;
direction->y = 0.0f;
direction->z = -v19;
}
break;
case GLITTER_EMITTER_SPHERE:
radius = a1->data.sphere.radius * scale->x;
if (!a1->data.sphere.plain)
radius = glitter_random_get_float_clamp(0.0f, radius);
longitude = glitter_random_get_float_clamp(a1->data.sphere.longitude * -0.5f,
a1->data.sphere.longitude * 0.5f);
latitude = (float_t)M_PI_2 - glitter_random_get_float_clamp(0.0f, a1->data.sphere.latitude);
v26 = cosf(latitude);
v27.x = sinf(longitude) * v26;
v27.y = sinf(latitude);
v27.z = cosf(longitude) * v26;
vec3_mult_scalar(v27, radius, *base_translation);
if (a1->data.sphere.direction == GLITTER_EMITTER_EMISSION_DIRECTION_INWARD)
*direction = v27;
else if (a1->data.sphere.direction == GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD)
vec3_negate(v27, *direction);
break;
case GLITTER_EMITTER_MESH:
break;
case GLITTER_EMITTER_POLYGON:
base_translation->x = sinf(((float_t)index / (float_t)a1->data.polygon.count * 2.0f)
/ (float_t)M_PI + (float_t)M_PI_2) * a1->data.polygon.scale * scale->x;
base_translation->y = 0.0f;
break;
}
}
void FASTCALL glitter_emitter_inst_get_value(glitter_emitter_inst* a1, float_t frame, int32_t random) {
static void FASTCALL glitter_emitter_inst_get_value(GPM,
glitter_emitter_inst* a1, float_t frame) {
int64_t length;
glitter_curve* curve;
float_t value;
@@ -262,7 +304,7 @@ void FASTCALL glitter_emitter_inst_get_value(glitter_emitter_inst* a1, float_t f
for (int32_t i = 0; i < length; i++) {
curve = a1->emitter->curve.begin[i];
if (!glitter_curve_get_value(curve, frame, &value, random + i))
if (!glitter_curve_get_value(GPM_VAL, curve, frame, &value, a1->random.value + i, a1->random_ptr))
continue;
switch (curve->type) {
@@ -306,208 +348,49 @@ void FASTCALL glitter_emitter_inst_get_value(glitter_emitter_inst* a1, float_t f
}
}
bool FASTCALL glitter_emitter_inst_has_ended(glitter_emitter_inst* emitter, bool a2) {
glitter_particle_inst** i;
if (!emitter->ended)
return false;
else if (!a2)
return true;
for (i = emitter->particles.begin; i != emitter->particles.end; i++)
if (!glitter_particle_inst_has_ended(*i, a2))
return false;
return true;
}
void FASTCALL glitter_emitter_inst_render_group_init(glitter_emitter_inst* emitter, float_t delta_frame) {
glitter_particle_inst** i;
for (i = emitter->particles.begin; i != emitter->particles.end; ++i)
glitter_particle_inst_render_group_init(*i, delta_frame);
}
void FASTCALL glitter_emitter_inst_reset(glitter_emitter_inst* a1) {
glitter_particle_inst** i; // rbx
a1->loop = a1->data.flags & GLITTER_EMITTER_FLAG_LOOP ? true : false;
a1->frame = 0.0f;
a1->ended = false;
if (a1->emission_interval >= -0.000001f)
a1->emission = fabsf(a1->emission_interval) <= 0.000001f
? GLITTER_EMITTER_EMISSION_ON_START : GLITTER_EMITTER_EMISSION_ON_TIMER;
else
a1->emission = GLITTER_EMITTER_EMISSION_ON_END;
for (i = a1->particles.begin; i != a1->particles.end; ++i)
glitter_particle_inst_reset(*i);
}
void FASTCALL glitter_emitter_inst_update_mat(glitter_emitter_inst* a1, glitter_effect_inst* a2) {
static void FASTCALL glitter_emitter_inst_update_mat(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2) {
bool mult;
vec3 trans;
vec3 rot;
vec3 scale;
bool v12; // bl
int64_t v14; // rax
int64_t v15; // r14
glitter_particle_inst* v17; // rbx
mat4 mat1;
mat4 mat2;
mat4 mat;
mat4 direction_mat;
trans = a1->translation;
rot = a1->rotation;
vec3_mult_scalar(a1->scale, a1->scale_all, scale);
mat1 = a2->mat;
v12 = true;
mult = true;
switch (a1->data.direction) {
case GLITTER_DIRECTION_BILLBOARD:
mat2 = cam->view;
mat2.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
mat4_inverse(&mat2, &mat2);
mat4_mult(&mat1, &mat2, &mat2);
mat2.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
break;
case GLITTER_DIRECTION_BILLBOARD: {
mat4_invrot(&cam->view, &direction_mat);
direction_mat.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
mat4_mult(&a2->mat, &direction_mat, &direction_mat);
direction_mat.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
} break;
case GLITTER_DIRECTION_Y_AXIS:
mat4_rotate_y((float_t)-M_PI_2, &mat2);
mat4_rotate_y((float_t)-M_PI_2, &direction_mat);
break;
case GLITTER_DIRECTION_X_AXIS:
mat4_rotate_x((float_t)-M_PI_2, &mat2);
mat4_rotate_x((float_t)-M_PI_2, &direction_mat);
break;
case GLITTER_DIRECTION_Z_AXIS:
mat4_rotate_z((float_t)-M_PI_2, &mat2);
mat4_rotate_z((float_t)-M_PI_2, &direction_mat);
break;
case GLITTER_DIRECTION_BILLBOARD_Y_ONLY:
mat4_rotate_y(cam->rotation.y, &mat2);
mat4_rotate_y(cam->rotation.y, &direction_mat);
break;
default:
v12 = false;
mult = false;
break;
}
mat4_translate_mult(&mat1, a1->translation.x, a1->translation.y, a1->translation.z, &mat1);
mat4_normalize_rotation(&mat1, &mat1);
if (v12)
mat4_mult(&mat2, &mat1, &mat1);
mat4_rot(&mat1, a1->rotation.x, a1->rotation.y, a1->rotation.z, &mat1);
a1->mat_no_scale = mat1;
mat4_scale_rot(&mat1, scale.x, scale.y, scale.z, &a1->mat);
v14 = a1->particles.end - a1->particles.begin;
for (v15 = 0; v14 > 0; v15++, v14--) {
if (!a1->particles.begin[v15])
continue;
v17 = a1->particles.begin[v15];
v17->mat = a1->mat;
v17->mat_no_scale = a1->mat_no_scale;
v17->mat_no_scale.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
glitter_particle_inst_set_mat(v17);
}
}
void FASTCALL glitter_emitter_inst_update_value_frame(glitter_emitter_inst* a1,
glitter_effect_inst* a2, float_t delta_frame) {
int64_t v7; // r14
vec3 rotation_add;
vec3 scale;
bool v22; // si
int64_t v24; // rbp
glitter_particle_inst* v26; // rsi
mat4 mat1;
mat4 mat2;
if (a1->frame < 0.0f)
return;
if (a1->loop) {
if (a1->data.loop_end_time < 0.0f || a1->frame < a1->data.loop_end_time) {
if (a1->frame >= a1->data.life_time) {
a1->frame -= a1->data.life_time;
if (a1->emission == GLITTER_EMITTER_EMISSION_EMITTED && a1->emission_interval > 0.0f)
a1->emission = GLITTER_EMITTER_EMISSION_ON_TIMER;
}
}
else
while (a1->frame > a1->data.loop_end_time)
a1->frame -= a1->data.loop_end_time - a1->data.loop_start_time;
}
glitter_emitter_inst_get_value(a1, a1->frame, a1->random);
vec3_mult_scalar(a1->data.rotation_add, delta_frame, rotation_add);
vec3_add(a1->rotation, rotation_add, a1->rotation);
vec3_mult_scalar(a1->scale, a1->scale_all, scale);
mat1 = a2->mat;
v22 = true;
switch (a1->data.direction) {
case GLITTER_DIRECTION_BILLBOARD:
mat2 = cam->view;
mat2.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
mat4_inverse(&mat2, &mat2);
mat4_mult(&mat1, &mat2, &mat2);
mat2.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
break;
case GLITTER_DIRECTION_Y_AXIS:
mat4_rotate_y((float_t)-M_PI_2, &mat2);
break;
case GLITTER_DIRECTION_X_AXIS:
mat4_rotate_x((float_t)-M_PI_2, &mat2);
break;
case GLITTER_DIRECTION_Z_AXIS:
mat4_rotate_z((float_t)-M_PI_2, &mat2);
break;
case GLITTER_DIRECTION_BILLBOARD_Y_ONLY:
mat4_rotate_y(cam->rotation.y, &mat2);
break;
default:
v22 = false;
break;
}
mat4_translate_mult(&mat1, a1->translation.x, a1->translation.y, a1->translation.z, &mat1);
mat4_normalize_rotation(&mat1, &mat1);
if (v22)
mat4_mult(&mat2, &mat1, &mat1);
mat4_rot(&mat1, a1->rotation.x, a1->rotation.y, a1->rotation.z, &mat1);
a1->mat_no_scale = mat1;
mat4_scale_rot(&mat1, scale.x, scale.y, scale.z, &a1->mat);
v24 = a1->particles.end - a1->particles.begin;
for (v7 = 0; v24 > 0; v7++, v24--) {
if (!a1->particles.begin[v7])
continue;
v26 = a1->particles.begin[v7];
v26->mat = a1->mat;
v26->mat_no_scale = a1->mat_no_scale;
v26->mat_no_scale.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
glitter_particle_inst_set_mat(v26);
}
}
void FASTCALL glitter_emitter_inst_update_value_init(glitter_emitter_inst* a1, float_t frame, float_t delta_frame) {
vec3 rotation_add;
if (a1->frame < 0.0f)
return;
if (a1->loop) {
if (a1->data.loop_end_time < 0.0f || a1->frame < a1->data.loop_end_time) {
if (a1->frame >= a1->data.life_time)
a1->frame = a1->frame - a1->data.life_time;
}
else
while (a1->frame > a1->data.loop_end_time)
a1->frame -= a1->data.loop_end_time - a1->data.loop_start_time;
}
if (a1->frame < 0.0f)
return;
glitter_emitter_inst_get_value(a1, a1->frame, a1->random);
vec3_mult_scalar(a1->data.rotation_add, delta_frame, rotation_add);
vec3_add(a1->rotation, rotation_add, a1->rotation);
}
void FASTCALL glitter_emitter_inst_dispose(glitter_emitter_inst* ei) {
vector_ptr_glitter_particle_inst_free(&ei->particles, (void*)glitter_particle_inst_dispose);
free(ei);
mat4_translate_mult(&a2->mat, trans.x, trans.y, trans.z, &mat);
mat4_normalize_rotation(&mat, &mat);
if (mult)
mat4_mult(&direction_mat, &mat, &mat);
mat4_rot(&mat, rot.x, rot.y, rot.z, &mat);
mat4_scale_rot(&mat, scale.x, scale.y, scale.z, &a1->mat);
a1->mat_no_scale = mat;
}
+13 -19
View File
@@ -7,25 +7,19 @@
#include "glitter.h"
extern glitter_emitter_inst* FASTCALL glitter_emitter_inst_init(glitter_emitter* a1,
glitter_scene* a2, glitter_effect_inst* a3);
extern void FASTCALL glitter_emitter_inst_copy(glitter_emitter_inst* a1,
glitter_emitter_inst* a2, glitter_scene* a3);
extern void FASTCALL glitter_emitter_inst_emit(glitter_emitter_inst* a1, glitter_scene* a2);
extern void FASTCALL glitter_emitter_inst_emit_init(glitter_emitter_inst* a1,
glitter_scene* a2, glitter_effect_inst* a3, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_emit_step(glitter_emitter_inst* a1,
glitter_scene* a2, glitter_effect_inst* a3, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_free(glitter_emitter_inst* a1, glitter_scene* a2, bool free);
extern void FASTCALL glitter_emitter_inst_get_mesh_by_type(glitter_emitter_inst* a1,
int32_t index, vec3* scale, vec3* base_translation, vec3* direction);
extern void FASTCALL glitter_emitter_inst_get_value(glitter_emitter_inst* a1, float_t frame, int32_t random);
extern glitter_emitter_inst* FASTCALL glitter_emitter_inst_init(GPM,
glitter_emitter* a1, glitter_effect_inst* a2, float_t emission);
extern void FASTCALL glitter_emitter_inst_free(GPM,
glitter_emitter_inst* a1, float_t emission);
extern void FASTCALL glitter_emitter_inst_emit(GPM,
glitter_emitter_inst* a1, float_t delta_frame, float_t emission);
extern void FASTCALL glitter_emitter_inst_get_mesh_by_type(GPM, glitter_emitter_inst* a1,
int32_t index, vec3* scale, vec3* base_translation, vec3* direction, glitter_random* random);
extern bool FASTCALL glitter_emitter_inst_has_ended(glitter_emitter_inst* emitter, bool a2);
extern void FASTCALL glitter_emitter_inst_render_group_init(glitter_emitter_inst* emitter, float_t delta_frame);
extern uint8_t FASTCALL glitter_emitter_inst_random_get_step(glitter_emitter_inst* emitter);
extern void FASTCALL glitter_emitter_inst_reset(glitter_emitter_inst* a1);
extern void FASTCALL glitter_emitter_inst_update_mat(glitter_emitter_inst* a1, glitter_effect_inst* a2);
extern void FASTCALL glitter_emitter_inst_update_value_frame(glitter_emitter_inst* a1,
glitter_effect_inst* a2, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_update_value_init(glitter_emitter_inst* a1,
float_t frame, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_update_value_frame(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_update_value_init(GPM,
glitter_emitter_inst* a1, glitter_effect_inst* a2, float_t delta_frame);
extern void FASTCALL glitter_emitter_inst_dispose(glitter_emitter_inst* ei);
+55 -52
View File
@@ -11,79 +11,82 @@
#include "particle_manager.h"
#include "scene.h"
glitter_file_reader* FASTCALL glitter_file_reader_init(wchar_t* path,
wchar_t* file, bool f2, float_t emission) {
glitter_file_reader* FASTCALL glitter_file_reader_init(GPM,
char* path, char* file, float_t emission) {
glitter_file_reader* fr = force_malloc(sizeof(glitter_file_reader));
fr->path = path_wadd_extension(path ? path : L"rom\\particle\\", 0);
fr->file = path_wadd_extension(file ? file : 0, 0);
fr->path = char_string_to_wchar_t_string(path ? path : "rom\\particle\\");
fr->file = char_string_to_wchar_t_string(file ? file : 0);
fr->emission = emission;
fr->hash = f2
? hash_wchar_t_murmurhash(file, 0, false)
: hash_wchar_t_fnv1a64(file);
fr->hash = glt_type != GLITTER_AFT
? hash_wchar_t_murmurhash(fr->file, 0, false)
: hash_wchar_t_fnv1a64(fr->file);
return fr;
}
bool FASTCALL glitter_file_reader_read(glitter_file_reader* fr) {
glitter_file_reader* FASTCALL glitter_file_reader_winit(GPM,
wchar_t* path, wchar_t* file, float_t emission) {
glitter_file_reader* fr = force_malloc(sizeof(glitter_file_reader));
fr->path = str_utils_wcopy(path ? path : L"rom\\particle\\");
fr->file = str_utils_wcopy(file);
fr->emission = emission;
fr->hash = glt_type != GLITTER_AFT
? hash_wchar_t_murmurhash(fr->file, 0, false)
: hash_wchar_t_fnv1a64(fr->file);
return fr;
}
bool FASTCALL glitter_file_reader_read(GPM, glitter_file_reader* fr) {
farc* f = farc_init();
wchar_t* path_temp0;
wchar_t* path_temp1;
path_temp0 = path_wadd_extension(fr->file, L".farc");
path_temp1 = path_wadd_extension(fr->path, path_temp0);
free(path_temp0);
farc_wread(f, path_temp1, true, false);
free(path_temp1);
wchar_t* file_temp;
wchar_t* path_temp;
file_temp = str_utils_wadd(fr->file, L".farc");
path_temp = str_utils_wadd(fr->path, file_temp);
free(file_temp);
farc_wread(f, path_temp, true, false);
free(path_temp);
farc_file* ff;
bool ret = false;
path_temp0 = path_wadd_extension(fr->file, L".dve");
ff = farc_wread_file(f, path_temp0);
free(path_temp0);
file_temp = str_utils_wadd(fr->file, L".dve");
ff = farc_wread_file(f, file_temp);
free(file_temp);
if (!ff)
goto End;
f2_struct* st;
st = f2_struct_init();
f2_struct_read_memory(st, ff->data, ff->size_uncompressed);
if (st->header.signature == 0x46455644)
ret = glitter_diva_effect_parse_file(fr, st);
f2_struct st;
f2_struct_read_memory(&st, ff->data, ff->size);
if (st.header.signature == 0x46455644)
ret = glitter_diva_effect_parse_file(GPM_VAL, fr, &st);
else
ret = false;
f2_struct_dispose(st);
f2_struct_free(&st);
if (!ret)
goto End;
path_temp0 = path_wadd_extension(fr->file, L".drs");
ff = farc_wread_file(f, path_temp0);
free(path_temp0);
file_temp = str_utils_wadd(fr->file, L".drs");
ff = farc_wread_file(f, file_temp);
free(file_temp);
ret = false;
if (!ff)
goto End;
if (ff) {
f2_struct st;
f2_struct_read_memory(&st, ff->data, ff->size);
if (st.header.signature == 0x53525644)
glitter_diva_resource_parse_file(fr->effect_group, &st);
f2_struct_free(&st);
}
st = f2_struct_init();
f2_struct_read_memory(st, ff->data, ff->size_uncompressed);
if (st->header.signature == 0x53525644)
ret = glitter_diva_resource_parse_file(fr->effect_group, st);
else
ret = false;
f2_struct_dispose(st);
file_temp = str_utils_wadd(fr->file, L".lst");
ff = farc_wread_file(f, file_temp);
free(file_temp);
if (!ret)
goto End;
path_temp0 = path_wadd_extension(fr->file, L".lst");
ff = farc_wread_file(f, path_temp0);
free(path_temp0);
if (!ff)
goto End;
st = f2_struct_init();
f2_struct_read_memory(st, ff->data, ff->size_uncompressed);
if (st->header.signature == 0x5453494C)
glitter_diva_list_parse_file(fr->effect_group, st);
f2_struct_dispose(st);
if (ff) {
f2_struct st;
f2_struct_read_memory(&st, ff->data, ff->size);
if (st.header.signature == 0x5453494C)
glitter_diva_list_parse_file(fr->effect_group, &st);
f2_struct_free(&st);
}
End:
farc_dispose(f);
+5 -3
View File
@@ -7,7 +7,9 @@
#include "glitter.h"
extern glitter_file_reader* FASTCALL glitter_file_reader_init(wchar_t* path,
wchar_t* file, bool f2, float_t emission);
extern bool FASTCALL glitter_file_reader_read(glitter_file_reader* fr);
extern glitter_file_reader* FASTCALL glitter_file_reader_init(GPM,
char* path, char* file, float_t emission);
extern glitter_file_reader* FASTCALL glitter_file_reader_winit(GPM,
wchar_t* path, wchar_t* file, float_t emission);
extern bool FASTCALL glitter_file_reader_read(GPM, glitter_file_reader* fr);
extern void FASTCALL glitter_file_reader_dispose(glitter_file_reader* fr);
+34
View File
@@ -18,3 +18,37 @@ vector_ptr_func(glitter_particle)
vector_ptr_func(glitter_particle_inst)
vector_ptr_func(glitter_render_group)
vector_ptr_func(glitter_scene)
const float_t glitter_min_emission = 0.01f;
const glitter_curve_type_flags glitter_effect_curve_flags = 0
| GLITTER_CURVE_TYPE_TRANSLATION_XYZ
| GLITTER_CURVE_TYPE_ROTATION_XYZ
| GLITTER_CURVE_TYPE_SCALE_XYZ
| GLITTER_CURVE_TYPE_SCALE_ALL;
const glitter_curve_type_flags glitter_emitter_curve_flags = 0
| GLITTER_CURVE_TYPE_TRANSLATION_XYZ
| GLITTER_CURVE_TYPE_ROTATION_XYZ
| GLITTER_CURVE_TYPE_SCALE_XYZ
| GLITTER_CURVE_TYPE_SCALE_ALL
| GLITTER_CURVE_TYPE_EMISSION_INTERVAL
| GLITTER_CURVE_TYPE_PARTICLES_PER_EMISSION;
const glitter_curve_type_flags glitter_particle_curve_flags = 0
| GLITTER_CURVE_TYPE_TRANSLATION_XYZ
| GLITTER_CURVE_TYPE_ROTATION_XYZ
| GLITTER_CURVE_TYPE_SCALE_XYZ
| GLITTER_CURVE_TYPE_SCALE_ALL
| GLITTER_CURVE_TYPE_COLOR_RGBA
| GLITTER_CURVE_TYPE_UV_SCROLL;
const glitter_curve_type_flags glitter_particle_x_curve_flags = 0
| GLITTER_CURVE_TYPE_TRANSLATION_XYZ
| GLITTER_CURVE_TYPE_ROTATION_XYZ
| GLITTER_CURVE_TYPE_SCALE_XYZ
| GLITTER_CURVE_TYPE_SCALE_ALL
| GLITTER_CURVE_TYPE_COLOR_RGBA
| GLITTER_CURVE_TYPE_COLOR_RGB_SCALE
| GLITTER_CURVE_TYPE_UV_SCROLL
| GLITTER_CURVE_TYPE_UV_SCROLL_2ND;
+270 -153
View File
@@ -8,14 +8,14 @@
#include "shared.h"
typedef enum glitter_curve_flag {
GLITTER_CURVE_FLAG_RANDOMIZE = 0x01,
GLITTER_CURVE_FLAG_RANDOM_RANGE = 0x02,
GLITTER_CURVE_FLAG_NEGATIVE_RANDOM = 0x04,
GLITTER_CURVE_FLAG_ABSOLUTE = 0x04,
GLITTER_CURVE_FLAG_STEP = 0x08,
GLITTER_CURVE_FLAG_NEGATE = 0x10,
GLITTER_CURVE_FLAG_MULT = 0x20,
GLITTER_CURVE_FLAG_PLAIN = 0x40,
GLITTER_CURVE_RANDOM_RANGE = 0x01,
GLITTER_CURVE_KEY_RANDOM_RANGE = 0x02,
GLITTER_CURVE_RANDOM_RANGE_NEGATE = 0x04,
GLITTER_CURVE_STEP = 0x08,
GLITTER_CURVE_NEGATE = 0x10,
GLITTER_CURVE_RANDOM_RANGE_MULT = 0x20,
GLITTER_CURVE_BAKED = 0x40,
GLITTER_CURVE_BAKED_FULL = 0x80,
} glitter_curve_flag;
typedef enum glitter_curve_type {
@@ -33,70 +33,129 @@ typedef enum glitter_curve_type {
GLITTER_CURVE_COLOR_G = 11,
GLITTER_CURVE_COLOR_B = 12,
GLITTER_CURVE_COLOR_A = 13,
GLITTER_CURVE_UNK14 = 14,
GLITTER_CURVE_UNK15 = 15,
GLITTER_CURVE_UNK16 = 16,
GLITTER_CURVE_UNK17 = 17,
GLITTER_CURVE_UNK18 = 18,
GLITTER_CURVE_UNK19 = 19,
GLITTER_CURVE_COLOR_RGB_SCALE = 14,
GLITTER_CURVE_COLOR_R_2ND = 15,
GLITTER_CURVE_COLOR_G_2ND = 16,
GLITTER_CURVE_COLOR_B_2ND = 17,
GLITTER_CURVE_COLOR_A_2ND = 18,
GLITTER_CURVE_COLOR_RGB_SCALE_2ND = 19,
GLITTER_CURVE_EMISSION_INTERVAL = 20,
GLITTER_CURVE_PARTICLES_PER_EMISSION = 21,
GLITTER_CURVE_U_SCROLL = 22,
GLITTER_CURVE_V_SCROLL = 23,
GLITTER_CURVE_U_SCROLL_ALPHA = 24,
GLITTER_CURVE_V_SCROLL_ALPHA = 25,
GLITTER_CURVE_U_SCROLL_2ND = 26,
GLITTER_CURVE_V_SCROLL_2ND = 27,
GLITTER_CURVE_U_SCROLL_ALPHA_2ND = 28,
GLITTER_CURVE_V_SCROLL_ALPHA_2ND = 29,
} glitter_curve_type;
typedef enum glitter_curve_type_flags {
GLITTER_CURVE_TYPE_TRANSLATION_X = 0x00000001,
GLITTER_CURVE_TYPE_TRANSLATION_Y = 0x00000002,
GLITTER_CURVE_TYPE_TRANSLATION_Z = 0x00000004,
GLITTER_CURVE_TYPE_ROTATION_X = 0x00000008,
GLITTER_CURVE_TYPE_ROTATION_Y = 0x00000010,
GLITTER_CURVE_TYPE_ROTATION_Z = 0x00000020,
GLITTER_CURVE_TYPE_SCALE_X = 0x00000040,
GLITTER_CURVE_TYPE_SCALE_Y = 0x00000080,
GLITTER_CURVE_TYPE_SCALE_Z = 0x00000100,
GLITTER_CURVE_TYPE_SCALE_ALL = 0x00000200,
GLITTER_CURVE_TYPE_COLOR_R = 0x00000400,
GLITTER_CURVE_TYPE_COLOR_G = 0x00000800,
GLITTER_CURVE_TYPE_COLOR_B = 0x00001000,
GLITTER_CURVE_TYPE_COLOR_A = 0x00002000,
GLITTER_CURVE_TYPE_COLOR_RGB_SCALE = 0x00004000,
GLITTER_CURVE_TYPE_COLOR_R_2ND = 0x00008000,
GLITTER_CURVE_TYPE_COLOR_G_2ND = 0x00010000,
GLITTER_CURVE_TYPE_COLOR_B_2ND = 0x00020000,
GLITTER_CURVE_TYPE_COLOR_A_2ND = 0x00040000,
GLITTER_CURVE_TYPE_COLOR_RGB_SCALE_2ND = 0x00080000,
GLITTER_CURVE_TYPE_EMISSION_INTERVAL = 0x00100000,
GLITTER_CURVE_TYPE_PARTICLES_PER_EMISSION = 0x00200000,
GLITTER_CURVE_TYPE_U_SCROLL = 0x00400000,
GLITTER_CURVE_TYPE_V_SCROLL = 0x00800000,
GLITTER_CURVE_TYPE_U_SCROLL_ALPHA = 0x01000000,
GLITTER_CURVE_TYPE_V_SCROLL_ALPHA = 0x02000000,
GLITTER_CURVE_TYPE_U_SCROLL_2ND = 0x04000000,
GLITTER_CURVE_TYPE_V_SCROLL_2ND = 0x08000000,
GLITTER_CURVE_TYPE_U_SCROLL_ALPHA_2ND = 0x10000000,
GLITTER_CURVE_TYPE_V_SCROLL_ALPHA_2ND = 0x20000000,
GLITTER_CURVE_TYPE_TRANSLATION_XYZ = 0x00000001 | 0x00000002 | 0x00000004,
GLITTER_CURVE_TYPE_ROTATION_XYZ = 0x00000008 | 0x00000010 | 0x00000020,
GLITTER_CURVE_TYPE_SCALE_XYZ = 0x00000040 | 0x00000080 | 0x00000100,
GLITTER_CURVE_TYPE_COLOR_RGBA = 0x00000400 | 0x00000800 | 0x00001000 | 0x00002000,
GLITTER_CURVE_TYPE_COLOR_RGBA_2ND = 0x00008000 | 0x00010000 | 0x00020000 | 0x00040000,
GLITTER_CURVE_TYPE_UV_SCROLL = 0x00400000 | 0x00800000,
GLITTER_CURVE_TYPE_UV_SCROLL_ALPHA = 0x01000000 | 0x02000000,
GLITTER_CURVE_TYPE_UV_SCROLL_2ND = 0x04000000 | 0x08000000,
GLITTER_CURVE_TYPE_UV_SCROLL_ALPHA_2ND = 0x10000000 | 0x20000000,
} glitter_curve_type_flags;
typedef enum glitter_direction {
GLITTER_DIRECTION_BILLBOARD = 0,
GLITTER_DIRECTION_EMITTER_DIRECTION = 1,
GLITTER_DIRECTION_TYPE_2_DIR_ANGLE = 2,
GLITTER_DIRECTION_TYPE_3_DIR_ANGLE = 3,
GLITTER_DIRECTION_PREV_POSITION = 2,
GLITTER_DIRECTION_POSITION = 3,
GLITTER_DIRECTION_Y_AXIS = 4,
GLITTER_DIRECTION_X_AXIS = 5,
GLITTER_DIRECTION_Z_AXIS = 6,
GLITTER_DIRECTION_BILLBOARD_Y_ONLY = 7,
GLITTER_DIRECTION_TYPE_8_DIR_ANGLE = 8,
GLITTER_DIRECTION_PREV_POSITION_DUP = 8,
GLITTER_DIRECTION_EMITTER_ROTATION = 9,
GLITTER_DIRECTION_EFFECT_ROTATION = 10,
GLITTER_DIRECTION_PARTICLE_ROTATION = 11,
} glitter_direction;
typedef enum glitter_effect_a3da_flag {
GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_ONCE = 0x00001,
GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_TRANS_ONLY = 0x00002,
GLITTER_EFFECT_A3DA_FLAG_SET_A3DA_BY_OBJECT_INDEX = 0x10000,
} glitter_effect_a3da_flag;
typedef enum glitter_effect_ext_anim_flag {
GLITTER_EFFECT_EXT_ANIM_SET_EXT_ANIM_ONCE = 0x00001,
GLITTER_EFFECT_EXT_ANIM_EXT_ANIM_TRANS_ONLY = 0x00002,
GLITTER_EFFECT_EXT_ANIM_NO_TRANS_X = 0x00004,
GLITTER_EFFECT_EXT_ANIM_NO_TRANS_Y = 0x00008,
GLITTER_EFFECT_EXT_ANIM_NO_TRANS_Z = 0x00010,
GLITTER_EFFECT_EXT_ANIM_NO_DRAW_IF_NO_DATA = 0x00020,
GLITTER_EFFECT_EXT_ANIM_GET_THEN_UPDATE = 0x00040,
GLITTER_EFFECT_EXT_ANIM_CHARA_ANIM = 0x10000,
} glitter_effect_ext_anim_flag;
typedef enum glitter_effect_flag {
GLITTER_EFFECT_FLAG_NONE = 0x00,
GLITTER_EFFECT_FLAG_LOOP = 0x01,
GLITTER_EFFECT_FLAG_LOCAL = 0x02,
GLITTER_EFFECT_FLAG_ALPHA = 0x04,
GLITTER_EFFECT_FLAG_FOG = 0x08,
GLITTER_EFFECT_FLAG_FOG_HEIGHT = 0x10,
GLITTER_EFFECT_FLAG_EMISSION = 0x20,
GLITTER_EFFECT_NONE = 0x00,
GLITTER_EFFECT_LOOP = 0x01,
GLITTER_EFFECT_LOCAL = 0x02,
GLITTER_EFFECT_ALPHA = 0x04,
GLITTER_EFFECT_FOG = 0x08,
GLITTER_EFFECT_FOG_HEIGHT = 0x10,
GLITTER_EFFECT_EMISSION = 0x20,
GLITTER_EFFECT_USE_SEED = 0x40,
} glitter_effect_flag;
typedef enum glitter_effect_file_flag {
GLITTER_EFFECT_FILE_FLAG_ALPHA = 0x01,
GLITTER_EFFECT_FILE_FLAG_FOG = 0x02,
GLITTER_EFFECT_FILE_FLAG_FOG_HEIGHT = 0x04,
GLITTER_EFFECT_FILE_FLAG_EMISSION = 0x08,
GLITTER_EFFECT_FILE_ALPHA = 0x01,
GLITTER_EFFECT_FILE_FOG = 0x02,
GLITTER_EFFECT_FILE_FOG_HEIGHT = 0x04,
GLITTER_EFFECT_FILE_EMISSION = 0x08,
GLITTER_EFFECT_FILE_USE_SEED = 0x10,
} glitter_effect_file_flag;
typedef enum glitter_effect_inst_flag {
GLITTER_EFFECT_INST_FLAG_NONE = 0x000,
GLITTER_EFFECT_INST_FLAG_FREE = 0x001,
GLITTER_EFFECT_INST_FLAG_JUST_INIT = 0x002,
GLITTER_EFFECT_INST_FLAG_HAS_A3DA = 0x004,
GLITTER_EFFECT_INST_FLAG_HAS_A3DA_TRANS = 0x008,
GLITTER_EFFECT_INST_FLAG_HAS_A3DA_NON_INIT = 0x010,
GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_INDEX = 0x020,
GLITTER_EFFECT_INST_FLAG_SET_A3DA_BY_OBJECT_NAME = 0x040,
GLITTER_EFFECT_INST_FLAG_SET_A3DA_ONCE = 0x080,
GLITTER_EFFECT_INST_FLAG_SET_A3DA_TRANS_ONLY = 0x100,
GLITTER_EFFECT_INST_FLAG_SET_MIN_COLOR = 0x200,
GLITTER_EFFECT_INST_FLAG_SET_ADD_MIN_COLOR = 0x400,
GLITTER_EFFECT_INST_FLAG_HAS_A3DA_SCALE = 0x800,
GLITTER_EFFECT_INST_NONE = 0x0000,
GLITTER_EFFECT_INST_FREE = 0x0001,
GLITTER_EFFECT_INST_JUST_INIT = 0x0002,
GLITTER_EFFECT_INST_HAS_EXT_ANIM = 0x0004,
GLITTER_EFFECT_INST_HAS_EXT_ANIM_TRANS = 0x0008,
GLITTER_EFFECT_INST_HAS_EXT_ANIM_NON_INIT = 0x0010,
GLITTER_EFFECT_INST_CHARA_ANIM = 0x0020,
GLITTER_EFFECT_INST_SET_EXT_ANIM_BY_OBJECT_NAME = 0x0040,
GLITTER_EFFECT_INST_SET_EXT_ANIM_ONCE = 0x0080,
GLITTER_EFFECT_INST_EXT_ANIM_TRANS_ONLY = 0x0100,
GLITTER_EFFECT_INST_HAS_EXT_ANIM_SCALE = 0x0200,
GLITTER_EFFECT_INST_NO_EXT_ANIM_TRANS_X = 0x0400,
GLITTER_EFFECT_INST_NO_EXT_ANIM_TRANS_Y = 0x0800,
GLITTER_EFFECT_INST_NO_EXT_ANIM_TRANS_Z = 0x1000,
GLITTER_EFFECT_INST_NO_EXT_ANIM_MAT = 0x2000,
GLITTER_EFFECT_INST_GET_EXT_ANIM_THEN_UPDATE = 0x4000,
} glitter_effect_inst_flag;
typedef enum glitter_emitter_emission {
@@ -107,16 +166,23 @@ typedef enum glitter_emitter_emission {
} glitter_emitter_emission;
typedef enum glitter_emitter_emission_direction {
GLITTER_EMITTER_EMISSION_DIRECTION_PARTICLE_VELOCITY = 0,
GLITTER_EMITTER_EMISSION_DIRECTION_INWARD = 1,
GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD = 2,
GLITTER_EMITTER_EMISSION_DIRECTION_NONE = 0,
GLITTER_EMITTER_EMISSION_DIRECTION_OUTWARD = 1,
GLITTER_EMITTER_EMISSION_DIRECTION_INWARD = 2,
} glitter_emitter_emission_direction;
typedef enum glitter_emitter_flag {
GLITTER_EMITTER_FLAG_NONE = 0x00,
GLITTER_EMITTER_FLAG_LOOP = 0x01,
GLITTER_EMITTER_NONE = 0x00,
GLITTER_EMITTER_LOOP = 0x01,
GLITTER_EMITTER_KILL_ON_END = 0x02,
GLITTER_EMITTER_USE_SEED = 0x04,
} glitter_emitter_flag;
typedef enum glitter_emitter_timer_type {
GLITTER_EMITTER_TIMER_BY_TIME = 0,
GLITTER_EMITTER_TIMER_BY_DISTANCE = 1,
} glitter_emitter_timer_type;
typedef enum glitter_emitter_type {
GLITTER_EMITTER_BOX = 0,
GLITTER_EMITTER_CYLINDER = 1,
@@ -140,28 +206,36 @@ typedef enum glitter_particle_blend {
GLITTER_PARTICLE_BLEND_PUNCH_THROUGH = 5,
} glitter_particle_blend;
typedef enum glitter_particle_draw_flags {
GLITTER_PARTICLE_DRAW_NONE = 0x0,
GLITTER_PARTICLE_DRAW_NO_BILLBOARD_CULL = 0x1,
} glitter_particle_draw_flags;
typedef enum glitter_particle_flag {
GLITTER_PARTICLE_FLAG_NONE = 0x00000,
GLITTER_PARTICLE_FLAG_LOOP = 0x00001,
GLITTER_PARTICLE_FLAG_USE_MODEL_MAT = 0x00004,
GLITTER_PARTICLE_FLAG_SCALE_Y_BY_X = 0x00010,
GLITTER_PARTICLE_FLAG_REBOUND_PLANE = 0x00020,
GLITTER_PARTICLE_FLAG_TRANSLATE_BY_EMITTER = 0x00040,
GLITTER_PARTICLE_FLAG_SCALE = 0x00080,
GLITTER_PARTICLE_FLAG_SECOND_TEXTURE = 0x00100,
GLITTER_PARTICLE_FLAG_LOCAL = 0x10000,
GLITTER_PARTICLE_FLAG_EMISSION = 0x20000,
GLITTER_PARTICLE_NONE = 0x00000,
GLITTER_PARTICLE_LOOP = 0x00001,
GLITTER_PARTICLE_EMITTER_LOCAL = 0x00004,
GLITTER_PARTICLE_SCALE_Y_BY_X = 0x00010,
GLITTER_PARTICLE_REBOUND_PLANE = 0x00020,
GLITTER_PARTICLE_ROTATE_BY_EMITTER = 0x00040,
GLITTER_PARTICLE_SCALE = 0x00080,
GLITTER_PARTICLE_SECOND_TEXTURE = 0x00100,
GLITTER_PARTICLE_DEPTH_TEST = 0x00200,
GLITTER_PARTICLE_ROTATE_LOCUS = 0x00800,
GLITTER_PARTICLE_LOCAL = 0x10000,
GLITTER_PARTICLE_EMISSION = 0x20000,
} glitter_particle_flag;
typedef enum glitter_particle_inst_flag {
GLITTER_PARTICLE_INST_FLAG_NONE = 0x00,
GLITTER_PARTICLE_INST_FLAG_ENDED = 0x01,
GLITTER_PARTICLE_INST_FLAG_NO_CHILD = 0x02,
GLITTER_PARTICLE_INST_NONE = 0x00,
GLITTER_PARTICLE_INST_ENDED = 0x01,
GLITTER_PARTICLE_INST_NO_CHILD = 0x02,
} glitter_particle_inst_flag;
typedef enum glitter_particle_sub_flag {
GLITTER_PARTICLE_SUB_FLAG_NONE = 0x00000000,
GLITTER_PARTICLE_SUB_FLAG_USE_CURVE = 0x40000000,
GLITTER_PARTICLE_SUB_NONE = 0x00000000,
GLITTER_PARTICLE_SUB_USE_SECONDARY_UV = 0x00400000,
GLITTER_PARTICLE_SUB_USE_CURVE = 0x40000000,
} glitter_particle_sub_flag;
typedef enum glitter_particle_type {
@@ -183,6 +257,12 @@ typedef enum glitter_pivot {
GLITTER_PIVOT_BOTTOM_RIGHT = 8,
} glitter_pivot;
typedef enum glitter_type {
GLITTER_AFT = 0,
GLITTER_F2 = 1,
GLITTER_X = 2,
} glitter_type;
typedef enum glitter_uv_index_type {
GLITTER_UV_INDEX_FIXED = 0,
GLITTER_UV_INDEX_INITIAL_RANDOM_FIXED = 1,
@@ -197,11 +277,11 @@ typedef enum glitter_uv_index_type {
typedef struct glitter_buffer glitter_buffer;
typedef struct glitter_curve_key glitter_curve_key;
typedef struct glitter_curve glitter_curve;
typedef struct glitter_effect_a3da glitter_effect_a3da;
typedef struct glitter_effect_data glitter_effect_data;
typedef struct glitter_effect_ext_anim glitter_effect_ext_anim;
typedef struct glitter_effect glitter_effect;
typedef struct glitter_effect_group glitter_effect_group;
typedef struct glitter_effect_inst_a3da glitter_effect_inst_a3da;
typedef struct glitter_effect_inst_ext_anim glitter_effect_inst_ext_anim;
typedef struct glitter_effect_inst glitter_effect_inst;
typedef struct glitter_emitter_box glitter_emitter_box;
typedef struct glitter_emitter_cylinder glitter_emitter_cylinder;
@@ -214,16 +294,19 @@ typedef struct glitter_file_reader glitter_file_reader;
typedef struct glitter_particle_manager glitter_particle_manager;
typedef struct glitter_locus_history glitter_locus_history;
typedef struct glitter_locus_history_data glitter_locus_history_data;
typedef struct glitter_particle_mesh glitter_particle_mesh;
typedef struct glitter_particle_data glitter_particle_data;
typedef struct glitter_particle_sub glitter_particle_sub;
typedef struct glitter_particle glitter_particle;
typedef struct glitter_particle_inst_data glitter_particle_inst_data;
typedef struct glitter_particle_inst glitter_particle_inst;
typedef struct glitter_render_group_sub glitter_render_group_sub;
typedef struct glitter_random glitter_random;
typedef struct glitter_render_element glitter_render_element;
typedef struct glitter_render_group glitter_render_group;
typedef struct glitter_scene_sub glitter_scene_sub;
typedef struct glitter_scene glitter_scene;
#define GPM glitter_particle_manager* gpm, glitter_type glt_type
#define GPM_VAL gpm, glt_type
vector(glitter_curve_key)
vector_ptr(glitter_curve)
vector_ptr(glitter_effect)
@@ -238,10 +321,22 @@ vector_ptr(glitter_particle_inst)
vector_ptr(glitter_render_group)
vector_ptr(glitter_scene)
extern const float_t glitter_min_emission;
extern const glitter_curve_type_flags glitter_effect_curve_flags;
extern const glitter_curve_type_flags glitter_emitter_curve_flags;
extern const glitter_curve_type_flags glitter_particle_curve_flags;
extern const glitter_curve_type_flags glitter_particle_x_curve_flags;
struct glitter_random {
uint32_t value;
uint8_t step;
};
struct glitter_buffer {
vec3 position;
vec2 uv;
vec4 color;
vec3 color;
float_t alpha;
};
struct glitter_curve_key {
@@ -256,31 +351,37 @@ struct glitter_curve_key {
struct glitter_curve {
glitter_curve_type type;
bool repeat;
float_t start_time;
float_t end_time;
int32_t start_time;
int32_t end_time;
glitter_curve_flag flags;
float_t max_rand;
float_t random_range;
vector_glitter_curve_key keys;
#if defined(CRE_DEV) || defined(CLOUD_DEV)
vector_glitter_curve_key keys_rev;
#endif
uint32_t version;
uint32_t keys_version;
};
struct glitter_effect_a3da {
uint64_t object_hash;
int32_t object_index;
glitter_effect_a3da_flag flags;
int32_t index;
char mesh_name[128];
};
struct glitter_effect_data {
uint64_t name_hash;
float_t appear_time;
float_t life_time;
float_t start_time;
glitter_effect_a3da* a3da;
int32_t appear_time;
int32_t life_time;
int32_t start_time;
glitter_effect_ext_anim* ext_anim;
glitter_effect_flag flags;
float_t emission;
int32_t seed;
};
struct glitter_effect_ext_anim {
uint64_t object_hash;
glitter_effect_ext_anim_flag flags;
int32_t instance_id;
uint64_t some_hash;
int32_t index;
int32_t node_index;
char mesh_name[128];
};
struct glitter_effect {
@@ -299,22 +400,25 @@ struct glitter_effect_group {
uint64_t hash;
float_t emission;
uint32_t resources_count;
int64_t* resource_hashes;
int32_t* resources;
txp* resources_tex;
vector_uint64_t resource_hashes;
vector_txp resources_tex;
vector_int32_t resources;
bool scene_init;
bool buffer_init;
uint32_t version;
};
struct glitter_effect_inst_a3da {
struct glitter_effect_inst_ext_anim {
int32_t dword00;
int64_t dword08;
int32_t object_index;
int32_t index;
int32_t instance_id;
uint64_t some_hash;
uint64_t object_hash;
int32_t chara_index;
int32_t node_index;
mat4 mat;
vec3 translation;
char* mesh_name;
char* name;
bool object_is_hrc;
};
@@ -328,13 +432,15 @@ struct glitter_effect_inst {
vec3 scale;
float_t scale_all;
mat4 mat;
mat4 mat_ext_anim;
vector_ptr_glitter_emitter_inst emitters;
int32_t random;
glitter_random random_shared;
glitter_effect_inst_flag flags;
size_t id;
glitter_effect_inst_a3da* a3da;
vec4 min_color;
vec3 a3da_scale;
glitter_effect_inst_ext_anim* ext_anim;
vec3 ext_anim_scale;
vector_ptr_glitter_render_group render_groups;
glitter_random random;
};
struct glitter_emitter_box {
@@ -346,34 +452,34 @@ struct glitter_emitter_cylinder {
float_t height;
float_t start_angle;
float_t end_angle;
bool plain;
bool on_edge;
glitter_emitter_emission_direction direction;
};
struct glitter_emitter_polygon {
float_t scale;
float_t size;
int32_t count;
glitter_emitter_emission_direction direction;
};
struct glitter_emitter_sphere {
float_t radius;
float_t latitude;
float_t longitude;
bool plain;
bool on_edge;
glitter_emitter_emission_direction direction;
};
struct glitter_emitter_data {
float_t start_time;
float_t life_time;
float_t loop_start_time;
float_t loop_end_time;
int32_t start_time;
int32_t life_time;
int32_t loop_start_time;
int32_t loop_end_time;
glitter_emitter_flag flags;
vec3 rotation_add;
vec3 rotation_add_random;
//int32_t dword2C;
//int32_t dword30;
glitter_emitter_timer_type timer;
float_t emission_interval;
float_t particles_per_emission;
glitter_direction direction;
@@ -382,6 +488,7 @@ struct glitter_emitter_data {
glitter_emitter_cylinder cylinder;
glitter_emitter_sphere sphere;
glitter_emitter_polygon polygon;
int32_t seed;
};
@@ -408,11 +515,14 @@ struct glitter_emitter_inst {
glitter_emitter_data data;
float_t emission_interval;
float_t particles_per_emission;
int32_t random;
glitter_random* random_ptr;
bool loop;
glitter_emitter_emission emission;
float_t frame;
bool ended;
bool has_distance;
uint32_t counter;
glitter_random random;
};
struct glitter_file_reader {
@@ -429,9 +539,9 @@ struct glitter_particle_manager {
vector_ptr_glitter_effect_group effect_groups;
float_t delta_frame;
float_t emission;
uint32_t random;
uint32_t counter;
bool f2;
bool draw_all;
bool draw_all_mesh;
};
struct glitter_locus_history {
@@ -439,14 +549,26 @@ struct glitter_locus_history {
};
struct glitter_locus_history_data {
vec3 translation;
vec4 color;
vec3 translation;
float_t scale;
};
struct glitter_particle_mesh {
uint64_t object_name_hash;
uint64_t object_file_hash;
char object_mesh_name[64];
uint64_t some_hash;
};
struct glitter_particle_data {
glitter_particle_flag flags;
float_t life_time;
int32_t life_time;
int32_t life_time_random;
int32_t fade_in;
int32_t fade_in_random;
int32_t fade_out;
int32_t fade_out_random;
glitter_particle_type type;
glitter_pivot pivot;
glitter_direction draw_type;
@@ -463,21 +585,23 @@ struct glitter_particle_data {
float_t speed_random;
float_t deceleration;
float_t deceleration_random;
vec3 gravitational_acceleration;
vec3 external_acceleration;
vec3 external_acceleration_random;
vec3 gravity;
vec3 acceleration;
vec3 acceleration_random;
float_t reflection_coeff;
float_t reflection_coeff_random;
float_t rebound_plane_y;
vec4 color;
glitter_uv_index_type uv_index_type;
int32_t uv_index;
float_t frame_step_uv;
int32_t frame_step_uv;
int32_t uv_index_start;
int32_t uv_index_end;
int32_t uv_index_count;
vec2 uv_scroll_add;
float_t uv_scroll_add_scale;
vec2 uv_scroll_2nd_add;
float_t uv_scroll_2nd_add_scale;
vec2 split_uv;
uint8_t split_u;
uint8_t split_v;
@@ -487,23 +611,18 @@ struct glitter_particle_data {
int32_t count;
int32_t locus_history_size;
int32_t locus_history_size_random;
//int32_t dword118;
glitter_particle_draw_flags draw_flags;
float_t emission;
uint64_t tex_hash0;
uint64_t tex_hash1;
int32_t texture0;
int32_t texture1;
//char dword138[0x20];
};
struct glitter_particle_sub {
glitter_particle_data data;
int32_t max_count;
glitter_particle_mesh mesh;
};
struct glitter_particle {
vector_ptr_glitter_curve curve;
glitter_particle_sub data;
glitter_particle_data data;
int32_t version;
};
@@ -511,32 +630,33 @@ struct glitter_particle_inst_data {
glitter_particle_data data;
glitter_particle_inst_flag flags;
glitter_render_group* render_group;
glitter_effect_inst* effect_inst;
glitter_random* random_ptr;
glitter_effect_inst* effect;
glitter_emitter_inst* emitter;
glitter_particle_inst* parent;
glitter_particle* particle;
vector_ptr_glitter_particle_inst particle_insts;
vector_ptr_glitter_particle_inst children;
};
struct glitter_particle_inst {
glitter_particle* particle;
mat4 mat;
mat4 mat_no_scale;
glitter_particle_inst_data sub;
glitter_particle_inst_data data;
};
struct glitter_render_group_sub {
struct glitter_render_element {
bool alive;
uint8_t uv_index;
int32_t random;
bool draw;
float_t frame;
float_t life_time;
float_t rebound_time;
float_t rebound_frame;
float_t frame_step_uv;
float_t speed;
float_t deceleration;
vec2 uv;
vec4 color;
vec3 base_translation;
vec3 base_direction;
vec3 translation;
vec3 translation_prev;
vec3 direction;
@@ -545,12 +665,14 @@ struct glitter_render_group_sub {
vec3 scale;
vec3 rotation;
vec3 rotation_add;
float_t rot_z_cos;
float_t rot_z_sin;
float_t scale_all;
vec2 uv_scroll;
vec2 uv_scroll_2nd;
float_t fade_out_frames;
float_t fade_in_frames;
mat4 mat;
glitter_locus_history* locus_history;
glitter_random random;
};
struct glitter_render_group {
@@ -564,34 +686,30 @@ struct glitter_render_group {
int32_t split_v;
vec2 split_uv;
float_t z_offset;
int32_t count;
int32_t ctrl;
size_t count;
size_t ctrl;
size_t disp;
int32_t texture0;
int32_t texture1;
//char dword48[32];
float_t frame;
mat4 mat;
mat4 mat_no_scale;
int32_t has_texture1;
glitter_render_group_sub* sub;
mat4 mat_draw;
glitter_render_element* elements;
glitter_buffer* buffer;
int32_t max_count;
glitter_particle_inst* particle_inst;
size_t max_count;
glitter_particle_inst* particle;
glitter_random* random_ptr;
int32_t alpha;
int32_t fog;
int32_t buffer_index;
int32_t vao;
int32_t vbo;
int32_t ebo;
float_t emission;
};
struct glitter_scene_sub {
vector_ptr_glitter_render_group render_groups;
int32_t disp_quad;
int32_t disp_locus;
int32_t disp_line;
int32_t ctrl_quad;
int32_t ctrl_locus;
int32_t ctrl_line;
vector_int32_t vec_key;
vector_int32_t vec_val;
bool use_culling;
bool update_data;
};
struct glitter_scene {
@@ -599,5 +717,4 @@ struct glitter_scene {
uint64_t hash;
float_t emission;
glitter_effect_group* effect_group;
glitter_scene_sub sub;
};
+16 -11
View File
@@ -5,8 +5,8 @@
#include "texture.h"
bool FASTCALL glitter_list_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
char* data;
bool FASTCALL glitter_list_pack_file(glitter_effect_group* a1, f2_struct* st) {
size_t data;
glitter_effect** i;
size_t length;
@@ -15,30 +15,35 @@ bool FASTCALL glitter_list_pack_file(glitter_effect_group* a1, f2_struct* st, bo
memset(st, 0, sizeof(f2_struct));
vector_enrs_entry e = { 0, 0, 0 };
enrs_entry ee;
ee = (enrs_entry){ 0, 1, 4, 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_DWORD });
vector_enrs_entry_push_back(&e, &ee);
length = 0;
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i)
length++;
data = force_malloc(0x10 + 0x80 * length);
st->data = data;
data = (size_t)force_malloc(0x10 + 0x80 * length);
st->data = (void*)data;
st->length = 0x10 + 0x80 * length;
st->enrs = e;
if (use_big_endian)
*(uint32_t*)data = reverse_endianess_uint32_t((uint32_t)length);
else
*(uint32_t*)data = (uint32_t)length;
data += 0x04;
*(uint32_t*)data = (uint32_t)length;
data += 4;
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i) {
memcpy(data, (*i)->name, 0x80);
memcpy((void*)data, (*i)->name, 0x80);
data += 0x80;
}
st->header.signature = 0x46464547;
st->header.length = 0x20;
st->header.use_big_endian = use_big_endian ? true : false;
st->header.use_big_endian = false;
st->header.use_section_size = true;
return true;
}
+1 -1
View File
@@ -7,5 +7,5 @@
#include "glitter.h"
extern bool FASTCALL glitter_list_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_list_pack_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_list_unpack_file(glitter_effect_group* a1, f2_struct* st);
+20 -17
View File
@@ -7,48 +7,51 @@
glitter_locus_history* FASTCALL glitter_locus_history_init(size_t size) {
glitter_locus_history* lh = force_malloc(sizeof(glitter_locus_history));
vector_glitter_locus_history_data_resize(&lh->data, size);
vector_glitter_locus_history_data_append(&lh->data, size);
return lh;
}
void FASTCALL glitter_locus_history_append(glitter_locus_history* a1,
glitter_render_group_sub* a2, glitter_particle_inst* a3) {
glitter_locus_history_data* v5;
int64_t size;
int64_t i;
void FASTCALL glitter_locus_history_append(GPM, glitter_locus_history* a1,
glitter_render_element* a2, glitter_particle_inst* a3) {
glitter_locus_history_data* data;
glitter_locus_history_data locus_history;
glitter_emitter_inst* emitter;
ssize_t size;
ssize_t i;
vec3 temp;
vec3 temp1;
v5 = a1->data.begin;
data = a1->data.begin;
size = a1->data.end - a1->data.begin;
if (a3->sub.data.flags & GLITTER_PARTICLE_FLAG_USE_MODEL_MAT)
temp = *(vec3*)&a3->mat.row3;
else
temp = a2->translation;
temp = a2->translation;
if (a3->data.data.flags & GLITTER_PARTICLE_EMITTER_LOCAL && (emitter = a3->data.emitter)) {
vec3 emit_trans;
mat4_get_translation(&emitter->mat, &emit_trans);
vec3_add(temp, emit_trans, temp);
}
locus_history.translation = temp;
locus_history.color = a2->color;
locus_history.translation = temp;
locus_history.scale = a2->scale_particle.x * a2->scale.x * a2->scale_all;
if (size < 1)
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
else if (size == 1) {
locus_history.translation = v5->translation;
locus_history.translation = data->translation;
if (a1->data.capacity_end - a1->data.begin > 1)
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
v5->translation = temp;
data->translation = temp;
}
else {
temp1 = v5[size - 1].translation;
temp1 = data[size - 1].translation;
for (i = size - 1; i > 0; i--)
v5[i].translation = v5[i - 1].translation;
data[i].translation = data[i - 1].translation;
if (size < a1->data.capacity_end - a1->data.begin) {
locus_history.translation = temp1;
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
}
v5->translation = temp;
data->translation = temp;
}
}
+2 -2
View File
@@ -8,6 +8,6 @@
#include "glitter.h"
extern glitter_locus_history* FASTCALL glitter_locus_history_init(size_t size);
extern void FASTCALL glitter_locus_history_append(glitter_locus_history* a1,
glitter_render_group_sub* a2, glitter_particle_inst* a3);
extern void FASTCALL glitter_locus_history_append(GPM, glitter_locus_history* a1,
glitter_render_element* a2, glitter_particle_inst* a3);
extern void FASTCALL glitter_locus_history_dispose(glitter_locus_history* lh);
+602 -391
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -7,9 +7,10 @@
#include "glitter.h"
extern glitter_particle* FASTCALL glitter_particle_init();
extern bool FASTCALL glitter_particle_parse_file(glitter_effect_group* a1,
extern glitter_particle* FASTCALL glitter_particle_init(GPM);
extern glitter_particle* FASTCALL glitter_particle_copy(GPM, glitter_particle* p);
extern bool FASTCALL glitter_particle_parse_file(GPM, glitter_effect_group* a1,
f2_struct* st, vector_ptr_glitter_particle* vec, glitter_effect* effect);
extern bool FASTCALL glitter_particle_unparse_file(glitter_effect_group* a1,
f2_struct* st, glitter_particle* a3, glitter_effect* effect, bool use_big_endian);
extern bool FASTCALL glitter_particle_unparse_file(GPM, glitter_effect_group* a1,
f2_struct* st, glitter_particle* a3, glitter_effect* effect);
extern void FASTCALL glitter_particle_dispose(glitter_particle* p);
+88 -226
View File
@@ -4,291 +4,153 @@
*/
#include "particle_inst.h"
#include "curve.h"
#include "effect_inst.h"
#include "random.h"
#include "render_group.h"
glitter_particle_inst* FASTCALL glitter_particle_inst_init(glitter_particle* a1,
glitter_scene* a2, glitter_effect_inst* a3) {
static glitter_particle_inst* FASTCALL glitter_particle_inst_init_child(GPM,
glitter_particle_inst* a1, float_t emission);
glitter_particle_inst* FASTCALL glitter_particle_inst_init(GPM, glitter_particle* a1,
glitter_effect_inst* a2, glitter_emitter_inst* a3, glitter_random* random, float_t emission) {
glitter_render_group* render_group;
glitter_particle_inst* pi = force_malloc(sizeof(glitter_particle_inst));
pi->particle = a1;
pi->mat = mat4_identity;
pi->mat_no_scale = mat4_identity;
pi->sub.effect_inst = a3;
pi->sub.particle = a1;
pi->sub.data = a1->data.data;
pi->data.effect = a2;
pi->data.emitter = a3;
pi->data.particle = a1;
pi->data.data = a1->data;
pi->data.random_ptr = random;
if (pi->sub.data.type != GLITTER_PARTICLE_LOCUS) {
render_group = glitter_particle_inst_init_render_group(&a2->sub, pi);
render_group->alpha = glitter_effect_inst_get_alpha(a3);
render_group->fog = glitter_effect_inst_get_fog(a3);
if (pi->sub.data.blend_mode0 == GLITTER_PARTICLE_BLEND_PUNCH_THROUGH && pi->sub.data.type == GLITTER_PARTICLE_QUAD)
if (pi->data.data.type != GLITTER_PARTICLE_LOCUS) {
render_group = glitter_render_group_init(GPM_VAL, pi);
render_group->alpha = glitter_effect_inst_get_alpha(a2);
render_group->fog = glitter_effect_inst_get_fog(a2);
if (pi->data.data.blend_mode0 == GLITTER_PARTICLE_BLEND_PUNCH_THROUGH
&& pi->data.data.type == GLITTER_PARTICLE_QUAD)
render_group->alpha = 0;
if (pi->sub.data.emission >= 0.0099999998f)
render_group->emission = pi->sub.data.emission;
else if (a3->data.emission >= 0.0099999998f)
render_group->emission = a3->data.emission;
if (pi->data.data.draw_flags & GLITTER_PARTICLE_DRAW_NO_BILLBOARD_CULL)
render_group->use_culling = false;
else
render_group->emission = a2->emission;
pi->sub.render_group = render_group;
render_group->use_culling = true;
if (pi->data.data.emission >= glitter_min_emission)
render_group->emission = pi->data.data.emission;
else if (a2->data.emission >= glitter_min_emission)
render_group->emission = a2->data.emission;
else
render_group->emission = emission;
pi->data.render_group = render_group;
vector_ptr_glitter_render_group_push_back(&a2->render_groups, &render_group);
}
else
pi->sub.flags |= GLITTER_PARTICLE_INST_FLAG_NO_CHILD;
pi->data.flags |= GLITTER_PARTICLE_INST_NO_CHILD;
return pi;
}
void FASTCALL glitter_particle_inst_copy(glitter_particle_inst* a1, glitter_particle_inst* a2, glitter_scene* a3) {
void FASTCALL glitter_particle_inst_emit(GPM,
glitter_particle_inst* a2, int32_t a3, int32_t count, float_t emission) {
glitter_particle_inst* particle;
glitter_particle_inst** i;
a2->mat = a1->mat;
a2->mat_no_scale = a1->mat_no_scale;
a2->sub.flags = a1->sub.flags;
if (a1->sub.render_group && a2->sub.render_group)
glitter_render_group_copy(a1->sub.render_group, a2->sub.render_group);
vector_ptr_glitter_particle_inst_clear(&a2->sub.particle_insts, (void*)glitter_particle_inst_dispose);
for (i = a1->sub.particle_insts.begin; i != a1->sub.particle_insts.end; i++) {
particle = glitter_particle_inst_init_child(a3, a1);
vector_ptr_glitter_particle_inst_push_back(&a2->sub.particle_insts, &particle);
particle->mat = a1->mat;
particle->mat_no_scale = a1->mat_no_scale;
glitter_particle_inst_copy(*i, particle, a3);
}
}
void FASTCALL glitter_particle_inst_emit(glitter_particle_inst* a1,
glitter_scene* a2, glitter_emitter_inst* a3, int32_t a4, int32_t count) {
glitter_particle_inst* particle_inst;
if (a1->sub.flags & GLITTER_PARTICLE_INST_FLAG_ENDED)
if (a2->data.flags & GLITTER_PARTICLE_INST_ENDED)
return;
while (!a1->sub.parent && a1->sub.flags & GLITTER_PARTICLE_INST_FLAG_NO_CHILD) {
particle_inst = glitter_particle_inst_init_child(a2, a1);
vector_ptr_glitter_particle_inst_push_back(&a1->sub.particle_insts, &particle_inst);
particle_inst->mat = a1->mat;
particle_inst->mat_no_scale = a1->mat_no_scale;
a1 = particle_inst;
if (particle_inst->sub.flags & GLITTER_PARTICLE_INST_FLAG_ENDED)
while (!a2->data.parent && a2->data.flags & GLITTER_PARTICLE_INST_NO_CHILD) {
particle = glitter_particle_inst_init_child(GPM_VAL, a2, emission);
vector_ptr_glitter_particle_inst_push_back(&a2->data.children, &particle);
a2 = particle;
if (particle->data.flags & GLITTER_PARTICLE_INST_ENDED)
return;
}
if (a1->sub.render_group)
glitter_render_group_emit(a1->sub.render_group, &a1->sub, a3, a4, count);
if (a2->data.render_group)
glitter_render_group_emit(GPM_VAL, a2->data.render_group, &a2->data, a2->data.emitter, a3, count);
}
void FASTCALL glitter_particle_inst_free(glitter_particle_inst* a1, bool free) {
glitter_particle_inst** i;
a1->sub.flags |= GLITTER_PARTICLE_INST_FLAG_ENDED;
if (free && a1->sub.render_group)
glitter_render_group_free(a1->sub.render_group);
a1->data.flags |= GLITTER_PARTICLE_INST_ENDED;
if (free && a1->data.render_group)
glitter_render_group_free(a1->data.render_group);
for (i = a1->sub.particle_insts.begin; i != a1->sub.particle_insts.end; i++)
for (i = a1->data.children.begin; i != a1->data.children.end; i++)
glitter_particle_inst_free(*i, free);
}
bool FASTCALL glitter_particle_inst_get_value(glitter_particle_inst* a1,
glitter_render_group_sub* a2, float_t frame) {
vec3 translation;
bool v4; // r13
int64_t length; // rbp
glitter_curve* curve; // rdi
float_t value; // [rsp+40h] [rbp-39h] BYREF
bool visible;
visible = true;
value = 0.0f;
v4 = false;
translation = vec3_null;
length = a1->particle->curve.end - a1->particle->curve.begin;
if (length) {
for (int32_t i = 0; i < length; i++) {
curve = a1->particle->curve.begin[i];
if (!glitter_curve_get_value(curve, frame, &value, a2->random + i))
continue;
switch (curve->type) {
case GLITTER_CURVE_TRANSLATION_X:
translation.x = value;
v4 = true;
break;
case GLITTER_CURVE_TRANSLATION_Y:
translation.y = value;
v4 = true;
break;
case GLITTER_CURVE_TRANSLATION_Z:
translation.z = value;
v4 = true;
break;
case GLITTER_CURVE_ROTATION_X:
a2->rotation.x = value;
break;
case GLITTER_CURVE_ROTATION_Y:
a2->rotation.y = value;
break;
case GLITTER_CURVE_ROTATION_Z:
a2->rotation.z = value;
break;
case GLITTER_CURVE_SCALE_X:
a2->scale.x = value;
break;
case GLITTER_CURVE_SCALE_Y:
a2->scale.y = value;
break;
case GLITTER_CURVE_SCALE_Z:
a2->scale.z = value;
break;
case GLITTER_CURVE_SCALE_ALL:
a2->scale_all = value;
break;
case GLITTER_CURVE_COLOR_R:
a2->color.x = value;
break;
case GLITTER_CURVE_COLOR_G:
a2->color.y = value;
break;
case GLITTER_CURVE_COLOR_B:
a2->color.z = value;
break;
case GLITTER_CURVE_COLOR_A:
a2->color.w = value;
if (value < 0.0099999998f)
visible = false;
break;
case GLITTER_CURVE_U_SCROLL:
a2->uv_scroll.x = value;
break;
case GLITTER_CURVE_V_SCROLL:
a2->uv_scroll.y = value;
break;
}
}
}
if (a1->sub.data.flags & GLITTER_PARTICLE_FLAG_TRANSLATE_BY_EMITTER || v4) {
vec3_add(translation, a2->base_translation, translation);
if (a1->sub.data.flags & GLITTER_PARTICLE_FLAG_TRANSLATE_BY_EMITTER) {
mat4_mult_vec3(&a2->mat, &translation, &translation);
vec3_add(translation, *(vec3*)&a2->mat.row3, translation);
}
a2->translation = translation;
}
return visible;
}
bool FASTCALL glitter_particle_inst_has_ended(glitter_particle_inst* particle, bool a2) {
glitter_particle_inst** i;
if (~particle->sub.flags & GLITTER_PARTICLE_INST_FLAG_ENDED)
if (~particle->data.flags & GLITTER_PARTICLE_INST_ENDED)
return false;
else if (!a2)
return true;
if (~particle->sub.flags & GLITTER_PARTICLE_INST_FLAG_NO_CHILD || particle->sub.parent) {
if (particle->sub.render_group && particle->sub.render_group->ctrl > 0)
if (~particle->data.flags & GLITTER_PARTICLE_INST_NO_CHILD || particle->data.parent) {
if (particle->data.render_group && particle->data.render_group->ctrl > 0)
return false;
return true;
}
for (i = particle->sub.particle_insts.begin; i != particle->sub.particle_insts.end; i++)
for (i = particle->data.children.begin; i != particle->data.children.end; i++)
if (!glitter_particle_inst_has_ended(*i, a2))
return false;
return true;
}
glitter_particle_inst* FASTCALL glitter_particle_inst_init_child(glitter_scene* a1, glitter_particle_inst* a2) {
void FASTCALL glitter_particle_inst_dispose(glitter_particle_inst* pi) {
if (pi->data.render_group) {
glitter_render_group_delete_buffers(pi->data.render_group, true);
pi->data.render_group = 0;
}
vector_ptr_glitter_particle_inst_free(&pi->data.children, glitter_particle_inst_dispose);
free(pi);
}
void FASTCALL glitter_particle_inst_reset(glitter_particle_inst* a1) {
glitter_particle_inst** i;
a1->data.flags = 0;
if (a1->data.render_group)
glitter_render_group_free(a1->data.render_group);
for (i = a1->data.children.begin; i != a1->data.children.end; ++i)
glitter_particle_inst_reset(*i);
}
glitter_particle_inst* FASTCALL glitter_particle_inst_init_child(GPM,
glitter_particle_inst* a1, float_t emission) {
glitter_render_group* render_group;
glitter_effect_inst* effect;
glitter_particle_inst* pi = force_malloc(sizeof(glitter_particle_inst));
pi->particle = a2->particle;
pi->mat = mat4_identity;
pi->mat_no_scale = mat4_identity;
pi->sub.parent = a2;
vector_ptr_glitter_particle_inst_resize(&pi->sub.particle_insts, 0x200);
pi->particle = a1->particle;
pi->data.effect = a1->data.effect;
pi->data.emitter = a1->data.emitter;
pi->data.parent = a1;
vector_ptr_glitter_particle_inst_append(&pi->data.children, 0x200);
pi->sub.data = a2->sub.data;
pi->data.random_ptr = a1->data.random_ptr;
pi->data.data = a1->data.data;
pi->sub.particle = a2->sub.particle;
render_group = glitter_particle_inst_init_render_group(&a1->sub, pi);
effect = a2->sub.effect_inst;
pi->data.particle = a1->data.particle;
render_group = glitter_render_group_init(GPM_VAL, pi);
effect = a1->data.effect;
render_group->alpha = glitter_effect_inst_get_alpha(effect);
render_group->fog = glitter_effect_inst_get_fog(effect);
if (pi->sub.data.blend_mode0 == GLITTER_PARTICLE_BLEND_PUNCH_THROUGH && pi->sub.data.type == GLITTER_PARTICLE_QUAD)
if (pi->data.data.blend_mode0 == GLITTER_PARTICLE_BLEND_PUNCH_THROUGH
&& pi->data.data.type == GLITTER_PARTICLE_QUAD)
render_group->alpha = 0;
if (effect->data.emission >= 0.0099999998f)
if (effect->data.emission >= glitter_min_emission)
render_group->emission = effect->data.emission;
else
render_group->emission = a1->emission;
pi->sub.render_group = render_group;
render_group->emission = emission;
pi->data.render_group = render_group;
vector_ptr_glitter_render_group_push_back(&a1->data.effect->render_groups, &render_group);
if (pi->sub.data.type == GLITTER_PARTICLE_LOCUS)
pi->sub.flags |= GLITTER_PARTICLE_INST_FLAG_NO_CHILD;
if (pi->data.data.type == GLITTER_PARTICLE_LOCUS)
pi->data.flags |= GLITTER_PARTICLE_INST_NO_CHILD;
return pi;
}
glitter_render_group* FASTCALL glitter_particle_inst_init_render_group(glitter_scene_sub* a1,
glitter_particle_inst* a2) {
int32_t count;
glitter_render_group* render_group;
count = a2->sub.data.count;
if (count < 1) {
count = 250;
if (a2->sub.data.type == GLITTER_PARTICLE_LOCUS)
count = 30;
}
render_group = glitter_render_group_init(count, a2);
vector_ptr_glitter_render_group_push_back(&a1->render_groups, &render_group);
return render_group;
}
void FASTCALL glitter_particle_inst_dispose(glitter_particle_inst* pi) {
if (pi->sub.render_group) {
glitter_render_group_delete_buffers(pi->sub.render_group, true);
pi->sub.render_group = 0;
}
vector_ptr_glitter_particle_inst_free(&pi->sub.particle_insts, (void*)glitter_particle_inst_dispose);
free(pi);
}
void FASTCALL glitter_particle_inst_render_group_init(glitter_particle_inst* particle, float_t delta_frame) {
glitter_particle_inst** i;
if (~particle->sub.flags & GLITTER_PARTICLE_INST_FLAG_NO_CHILD || particle->sub.parent) {
if (particle->sub.render_group)
glitter_render_group_copy_from_particle(particle->sub.render_group, delta_frame, false);
}
else
for (i = particle->sub.particle_insts.begin; i != particle->sub.particle_insts.end; i++)
glitter_particle_inst_render_group_init(*i, delta_frame);
}
void FASTCALL glitter_particle_inst_reset(glitter_particle_inst* a1) {
glitter_particle_inst** i; // rbx
a1->sub.flags = 0;
if (a1->sub.render_group)
glitter_render_group_free(a1->sub.render_group);
for (i = a1->sub.particle_insts.begin; i != a1->sub.particle_insts.end; ++i)
glitter_particle_inst_reset(*i);
}
void FASTCALL glitter_particle_inst_set_mat(glitter_particle_inst* a1) {
glitter_particle_inst** i;
for (i = a1->sub.particle_insts.begin; i != a1->sub.particle_insts.end; i++) {
(*i)->mat = a1->mat;
(*i)->mat_no_scale = a1->mat_no_scale;
}
}
+4 -14
View File
@@ -7,21 +7,11 @@
#include "glitter.h"
extern glitter_particle_inst* FASTCALL glitter_particle_inst_init(glitter_particle* a1,
glitter_scene* a2, glitter_effect_inst* a3);
extern void FASTCALL glitter_particle_inst_copy(glitter_particle_inst* a1,
glitter_particle_inst* a2, glitter_scene* a3);
extern void FASTCALL glitter_particle_inst_emit(glitter_particle_inst* a1,
glitter_scene* a2, glitter_emitter_inst* a3, int32_t a4, int32_t count);
extern glitter_particle_inst* FASTCALL glitter_particle_inst_init(GPM, glitter_particle* a1,
glitter_effect_inst* a2, glitter_emitter_inst* a3, glitter_random* random, float_t emission);
extern void FASTCALL glitter_particle_inst_emit(GPM,
glitter_particle_inst* a1, int32_t a3, int32_t count, float_t emission);
extern void FASTCALL glitter_particle_inst_free(glitter_particle_inst* a1, bool free);
extern bool FASTCALL glitter_particle_inst_get_value(glitter_particle_inst* a1,
glitter_render_group_sub* a2, float_t frame);
extern bool FASTCALL glitter_particle_inst_has_ended(glitter_particle_inst* particle, bool a2);
extern glitter_particle_inst* FASTCALL glitter_particle_inst_init_child(glitter_scene* a1,
glitter_particle_inst* a2);
extern glitter_render_group* FASTCALL glitter_particle_inst_init_render_group(glitter_scene_sub* a1,
glitter_particle_inst* a2);
extern void FASTCALL glitter_particle_inst_render_group_init(glitter_particle_inst* particle, float_t delta_frame);
extern void FASTCALL glitter_particle_inst_reset(glitter_particle_inst* a1);
extern void FASTCALL glitter_particle_inst_set_mat(glitter_particle_inst* a1);
extern void FASTCALL glitter_particle_inst_dispose(glitter_particle_inst* pi);
+138 -126
View File
@@ -9,19 +9,47 @@
#include "file_reader.h"
#include "render_group.h"
#include "scene.h"
#include "../GlitterX/effect_inst_x.h"
glitter_particle_manager* FASTCALL glitter_particle_manager_init() {
glitter_particle_manager* gpm = force_malloc(sizeof(glitter_particle_manager));
gpm->delta_frame = 2.0f;
gpm->emission = 1.0f;
vector_ptr_glitter_scene_resize(&gpm->scenes, 0x100);
vector_ptr_glitter_file_reader_resize(&gpm->file_readers, 0x100);
vector_ptr_glitter_effect_group_resize(&gpm->effect_groups, 0x100);
vector_ptr_glitter_scene_append(&gpm->scenes, 0x100);
vector_ptr_glitter_file_reader_append(&gpm->file_readers, 0x100);
vector_ptr_glitter_effect_group_append(&gpm->effect_groups, 0x100);
return gpm;
}
bool FASTCALL glitter_particle_manager_check_effect_group(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
void FASTCALL glitter_particle_manager_calc_draw(GPM,
bool(FASTCALL* render_add_list_func)(glitter_particle_mesh*, vec4*, mat4*, mat4*)) {
glitter_scene** i;
glitter_scene* scene;
glitter_effect_inst** j;
/*if (glt_type == GLITTER_X)
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
glitter_x_effect_inst_calc_draw(GPM_VAL, *j, render_add_list_func);
}
else*/
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
glitter_effect_inst_calc_draw(GPM_VAL, *j, render_add_list_func);
}
}
bool FASTCALL glitter_particle_manager_check_effect_group(GPM, uint64_t effect_group_hash) {
glitter_effect_group** i;
for (i = gpm->effect_groups.begin; i != gpm->effect_groups.end; i++) {
@@ -32,8 +60,7 @@ bool FASTCALL glitter_particle_manager_check_effect_group(glitter_particle_manag
return i != gpm->effect_groups.end;
}
bool FASTCALL glitter_particle_manager_check_file_reader(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
bool FASTCALL glitter_particle_manager_check_file_reader(GPM, uint64_t effect_group_hash) {
glitter_file_reader** i;
for (i = gpm->file_readers.begin; i != gpm->file_readers.end; i++) {
@@ -44,8 +71,7 @@ bool FASTCALL glitter_particle_manager_check_file_reader(glitter_particle_manage
return i != gpm->file_readers.end;
}
bool FASTCALL glitter_particle_manager_check_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
bool FASTCALL glitter_particle_manager_check_scene(GPM, uint64_t effect_group_hash) {
glitter_scene** i;
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
@@ -56,20 +82,34 @@ bool FASTCALL glitter_particle_manager_check_scene(glitter_particle_manager* gpm
return i != gpm->scenes.end;
}
void FASTCALL glitter_particle_manager_draw(glitter_particle_manager* gpm, int32_t alpha) {
for (glitter_scene** i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
void FASTCALL glitter_particle_manager_draw(GPM, int32_t alpha) {
glitter_scene** i;
glitter_scene* scene;
glitter_effect_inst** j;
glitter_scene_sub* scene = &(*i)->sub;
for (glitter_render_group** j = scene->render_groups.begin; j != scene->render_groups.end; j++)
if (*j && (*j)->alpha == alpha)
glitter_render_group_draw(scene, *j);
}
/*if (glt_type == GLITTER_X)
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
glitter_x_effect_inst_draw(GPM_VAL, *j, alpha);
}
else*/
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
glitter_effect_inst_draw(GPM_VAL, *j, alpha);
}
}
bool FASTCALL glitter_particle_manager_free_effect_group(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
bool FASTCALL glitter_particle_manager_free_effect_group(GPM, uint64_t effect_group_hash) {
glitter_effect_group** i;
glitter_effect_group* effect_group;
@@ -80,17 +120,18 @@ bool FASTCALL glitter_particle_manager_free_effect_group(glitter_particle_manage
continue;
}
if (effect_group)
glitter_effect_group_dispose(effect_group);
memmove(i, i + 1, sizeof(glitter_effect_group**) * (gpm->effect_groups.end - (i + 1)));
gpm->effect_groups.end--;
vector_ptr_glitter_effect_group_erase(&gpm->effect_groups,
i - gpm->effect_groups.begin, glitter_effect_group_dispose);
break;
}
return i != gpm->effect_groups.end;
}
bool FASTCALL glitter_particle_manager_free_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
void FASTCALL glitter_particle_manager_free_effect_groups(GPM) {
vector_ptr_glitter_effect_group_clear(&gpm->effect_groups, glitter_effect_group_dispose);
}
bool FASTCALL glitter_particle_manager_free_scene(GPM, uint64_t effect_group_hash) {
glitter_scene** i;
glitter_scene* scene;
@@ -101,61 +142,55 @@ bool FASTCALL glitter_particle_manager_free_scene(glitter_particle_manager* gpm,
continue;
}
glitter_scene_dispose(scene);
memmove(i, i + 1, sizeof(glitter_scene**) * (gpm->scenes.end - (i + 1)));
gpm->scenes.end--;
vector_ptr_glitter_scene_erase(&gpm->scenes, i - gpm->scenes.begin, glitter_scene_dispose);
break;
}
return i != gpm->scenes.end;
}
size_t FASTCALL glitter_particle_manager_get_ctrl_count(glitter_particle_manager* gpm,
glitter_particle_type type) {
void FASTCALL glitter_particle_manager_free_scenes(GPM) {
vector_ptr_glitter_scene_clear(&gpm->scenes, glitter_scene_dispose);
}
size_t FASTCALL glitter_particle_manager_get_ctrl_count(GPM, glitter_particle_type ptcl_type) {
size_t ctrl;
glitter_scene** i;
glitter_scene* scene;
glitter_effect_inst** j;
ctrl = 0;
switch (type) {
case GLITTER_PARTICLE_QUAD:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
ctrl += (*i)->sub.ctrl_quad;
break;
case GLITTER_PARTICLE_LINE:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
ctrl += (*i)->sub.ctrl_line;
break;
case GLITTER_PARTICLE_LOCUS:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
ctrl += (*i)->sub.ctrl_locus;
break;
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
ctrl += glitter_effect_inst_get_ctrl_count(*j, ptcl_type);
}
return ctrl;
}
size_t FASTCALL glitter_particle_manager_get_disp_count(glitter_particle_manager* gpm,
glitter_particle_type type) {
size_t FASTCALL glitter_particle_manager_get_disp_count(GPM, glitter_particle_type ptcl_type) {
size_t disp;
glitter_scene** i;
glitter_scene* scene;
glitter_effect_inst** j;
disp = 0;
switch (type) {
case GLITTER_PARTICLE_QUAD:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
disp += (*i)->sub.disp_quad;
break;
case GLITTER_PARTICLE_LINE:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
disp += (*i)->sub.disp_line;
break;
case GLITTER_PARTICLE_LOCUS:
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++)
disp += (*i)->sub.disp_locus;
break;
for (i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
scene = *i;
for (j = scene->effects.begin; j != scene->effects.end; j++)
if (*j)
disp += glitter_effect_inst_get_disp_count(*j, ptcl_type);
}
return disp;
}
void glitter_particle_manager_get_frame(glitter_particle_manager* gpm, float_t* frame, float_t* life_time) {
void glitter_particle_manager_get_frame(GPM, float_t* frame, float_t* life_time) {
glitter_scene* scene;
glitter_effect_inst** i;
glitter_effect_inst* effect;
@@ -172,15 +207,15 @@ void glitter_particle_manager_get_frame(glitter_particle_manager* gpm, float_t*
scene = *gpm->scenes.begin;
for (i = scene->effects.begin; i != scene->effects.end; i++) {
effect = *i;
if (effect && frame && life_time && effect->data.life_time > *life_time) {
if (effect && frame && life_time && (float_t)effect->data.life_time > *life_time) {
if (*frame < effect->frame)
*frame = effect->frame;
*life_time = effect->data.life_time;
*life_time = (float_t)effect->data.life_time;
}
}
}
void glitter_particle_manager_get_start_end_frame(glitter_particle_manager* gpm, float_t* start_frame, float_t* end_frame) {
void glitter_particle_manager_get_start_end_frame(GPM, float_t* start_frame, float_t* end_frame) {
glitter_scene* scene;
glitter_effect_inst** i;
glitter_effect_inst* effect;
@@ -206,9 +241,9 @@ void glitter_particle_manager_get_start_end_frame(glitter_particle_manager* gpm,
continue;
effect = *i;
life_time = effect->data.life_time;
if (start_frame && effect->data.appear_time < *start_frame)
*start_frame = effect->data.appear_time;
life_time = (float_t)effect->data.life_time;
if (start_frame && (float_t)effect->data.appear_time < *start_frame)
*start_frame = (float_t)effect->data.appear_time;
for (j = effect->emitters.begin; j != effect->emitters.end; j++) {
if (!*j)
@@ -216,18 +251,17 @@ void glitter_particle_manager_get_start_end_frame(glitter_particle_manager* gpm,
emitter = *j;
if (life_time < emitter->data.life_time)
life_time = emitter->data.life_time;
life_time = (float_t)emitter->data.life_time;
}
life_time += effect->data.appear_time;
life_time += (float_t)effect->data.appear_time;
if (end_frame && life_time > *end_frame)
*end_frame = life_time;
}
}
bool FASTCALL glitter_particle_manager_load_effect(glitter_particle_manager* gpm,
uint64_t effect_group_hash, uint64_t effect_hash) {
bool FASTCALL glitter_particle_manager_load_effect(GPM, uint64_t effect_group_hash, uint64_t effect_hash) {
glitter_effect_group** i;
glitter_effect_group* effect_group;
glitter_scene** j;
@@ -255,15 +289,14 @@ bool FASTCALL glitter_particle_manager_load_effect(glitter_particle_manager* gpm
for (k = effect_group->effects.begin, id = 1; k != effect_group->effects.end; k++, id++) {
effect = *k;
if (effect && effect->data.name_hash == effect_hash)
glitter_scene_init_effect(scene, effect, id, false);
glitter_scene_init_effect(GPM_VAL, scene, effect, id, false);
}
break;
}
return i != gpm->effect_groups.end;
}
bool FASTCALL glitter_particle_manager_load_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
bool FASTCALL glitter_particle_manager_load_scene(GPM, uint64_t effect_group_hash) {
glitter_effect_group** i;
glitter_effect_group* effect_group;
glitter_scene** j;
@@ -288,61 +321,50 @@ bool FASTCALL glitter_particle_manager_load_scene(glitter_particle_manager* gpm,
}
for (k = effect_group->effects.begin, id = 1; k != effect_group->effects.end; k++, id++)
glitter_scene_init_effect(scene, *k, id, false);
glitter_scene_init_effect(GPM_VAL, scene, *k, id, false);
break;
}
return i != gpm->effect_groups.end;
}
void FASTCALL glitter_particle_manager_reset_scene_disp_counter(glitter_particle_manager* gpm) {
for (glitter_scene** i = gpm->scenes.begin; i != gpm->scenes.end; i++) {
if (!*i)
continue;
glitter_scene* scene = *i;
scene->sub.disp_quad = 0;
scene->sub.disp_locus = 0;
scene->sub.disp_line = 0;
}
}
void FASTCALL glitter_particle_manager_set_frame(glitter_particle_manager* gpm, glitter_effect_group* effect_group,
glitter_scene** scene, float_t curr_frame, float_t prev_frame, uint32_t random, uint32_t counter, bool reset) {
void FASTCALL glitter_particle_manager_set_frame(GPM, glitter_effect_group* effect_group,
glitter_scene** scene, float_t curr_frame, float_t prev_frame, uint32_t counter, bool reset) {
if (curr_frame < prev_frame || reset) {
for (glitter_scene** i = gpm->scenes.begin; i != gpm->scenes.end; )
if (!*i)
vector_ptr_glitter_scene_erase(&gpm->scenes, i - gpm->scenes.begin);
else
for (glitter_scene** i = gpm->scenes.begin; i != gpm->scenes.end; ) {
if (*i != *scene) {
i++;
continue;
}
gpm->random = random;
vector_ptr_glitter_scene_erase(&gpm->scenes, i - gpm->scenes.begin, glitter_scene_dispose);
}
gpm->counter = counter;
glitter_scene* s = glitter_scene_init(effect_group);
vector_ptr_glitter_scene_push_back(&gpm->scenes, &s);
glitter_effect_group* eg = effect_group;
glitter_effect** i;
size_t id = 1;
for (i = eg->effects.begin, id = 1; i != eg->effects.end; i++, id++)
if (*i)
glitter_scene_init_effect(*scene, *i, id, false);
glitter_scene_init_effect(GPM_VAL, s, *i, id, false);
*scene = s;
prev_frame = 0.0f;
}
float_t delta = curr_frame - prev_frame;
float_t delta_frame = 2.0f;
float_t delta_frame = 1.0f;
for (; delta > 0.0f; delta -= delta_frame) {
if (delta_frame > delta)
delta_frame = delta;
glitter_scene* s = *scene;
if (s && !glitter_scene_has_ended(s, true)) {
glitter_scene_update_value_frame(s, delta_frame);
glitter_scene_emit(s, delta_frame);
glitter_scene_update_scene(s, delta_frame);
}
if (s && !glitter_scene_has_ended(s, true))
glitter_scene_update_value_frame(GPM_VAL, s, delta_frame);
}
}
bool FASTCALL glitter_particle_manager_test_load_effect(glitter_particle_manager* gpm,
bool FASTCALL glitter_particle_manager_test_load_effect(GPM,
uint64_t effect_group_hash, uint64_t effect_hash) {
glitter_effect_group** i;
glitter_effect_group* effect_group;
@@ -371,15 +393,14 @@ bool FASTCALL glitter_particle_manager_test_load_effect(glitter_particle_manager
for (k = effect_group->effects.begin, id = 1; k != effect_group->effects.end; k++, id++) {
effect = *k;
if (effect && effect->data.name_hash == effect_hash)
glitter_scene_init_effect(scene, effect, id, true);
glitter_scene_init_effect(GPM_VAL, scene, effect, id, true);
}
break;
}
return i != gpm->effect_groups.end;
}
bool FASTCALL glitter_particle_manager_test_load_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash) {
bool FASTCALL glitter_particle_manager_test_load_scene(GPM, uint64_t effect_group_hash, bool appear_now) {
glitter_effect_group** i;
glitter_effect_group* effect_group;
glitter_scene** j;
@@ -404,17 +425,17 @@ bool FASTCALL glitter_particle_manager_test_load_scene(glitter_particle_manager*
}
for (k = effect_group->effects.begin, id = 1; k != effect_group->effects.end; k++, id++)
glitter_scene_init_effect(scene, *k, id, true);
glitter_scene_init_effect(GPM_VAL, scene, *k, id, appear_now);
break;
}
return i != gpm->effect_groups.end;
}
void FASTCALL glitter_particle_manager_update_file_reader(glitter_particle_manager* gpm) {
void FASTCALL glitter_particle_manager_update_file_reader(GPM) {
for (glitter_file_reader** i = gpm->file_readers.begin; i != gpm->file_readers.end;) {
if (*i) {
glitter_file_reader* file_reader = *i;
if (glitter_file_reader_read(file_reader)) {
if (glitter_file_reader_read(GPM_VAL, file_reader)) {
file_reader->effect_group->emission = file_reader->emission;
if (file_reader->emission <= 0.0)
file_reader->effect_group->emission = gpm->emission;
@@ -422,37 +443,28 @@ void FASTCALL glitter_particle_manager_update_file_reader(glitter_particle_manag
}
else if (file_reader->effect_group)
glitter_effect_group_dispose(file_reader->effect_group);
glitter_file_reader_dispose(file_reader);
}
vector_ptr_glitter_file_reader_erase(&gpm->file_readers, i - gpm->file_readers.begin);
vector_ptr_glitter_file_reader_erase(&gpm->file_readers,
i - gpm->file_readers.begin, glitter_file_reader_dispose);
}
}
void FASTCALL glitter_particle_manager_update_scene(glitter_particle_manager* gpm) {
void FASTCALL glitter_particle_manager_update_scene(GPM) {
gpm->delta_frame = get_frame_speed();
for (glitter_scene** i = gpm->scenes.begin; i != gpm->scenes.end;) {
glitter_scene* scene = *i;
if (!scene)
goto copy_scenes;
if (glitter_scene_has_ended(scene, true)) {
glitter_scene_dispose(scene);
copy_scenes:
vector_ptr_glitter_scene_erase(&gpm->scenes, i - gpm->scenes.begin);
}
else {
glitter_scene_update_value_frame(scene, gpm->delta_frame);
glitter_scene_emit(scene, gpm->delta_frame);
glitter_scene_update_scene(scene, gpm->delta_frame);
if (scene && !glitter_scene_has_ended(scene, true)) {
glitter_scene_update_value_frame(GPM_VAL, scene, gpm->delta_frame);
i++;
}
else
vector_ptr_glitter_scene_erase(&gpm->scenes, i - gpm->scenes.begin, glitter_scene_dispose);
}
}
void FASTCALL glitter_particle_manager_dispose(glitter_particle_manager* gpm) {
vector_ptr_glitter_scene_free(&gpm->scenes, (void*)glitter_scene_dispose);
vector_ptr_glitter_file_reader_free(&gpm->file_readers, (void*)glitter_file_reader_dispose);
vector_ptr_glitter_effect_group_free(&gpm->effect_groups, (void*)glitter_effect_group_dispose);
vector_ptr_glitter_scene_free(&gpm->scenes, glitter_scene_dispose);
vector_ptr_glitter_file_reader_free(&gpm->file_readers, glitter_file_reader_dispose);
vector_ptr_glitter_effect_group_free(&gpm->effect_groups, glitter_effect_group_dispose);
free(gpm);
}
+22 -31
View File
@@ -8,37 +8,28 @@
#include "glitter.h"
extern glitter_particle_manager* FASTCALL glitter_particle_manager_init();
extern bool FASTCALL glitter_particle_manager_check_effect_group(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern bool FASTCALL glitter_particle_manager_check_file_reader(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern bool FASTCALL glitter_particle_manager_check_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_draw(glitter_particle_manager* gpm, int32_t alpha);
extern bool FASTCALL glitter_particle_manager_free_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern bool FASTCALL glitter_particle_manager_free_effect_group(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern size_t FASTCALL glitter_particle_manager_get_ctrl_count(glitter_particle_manager* gpm,
glitter_particle_type type);
extern size_t FASTCALL glitter_particle_manager_get_disp_count(glitter_particle_manager* gpm,
glitter_particle_type type);
extern void glitter_particle_manager_get_frame(glitter_particle_manager* gpm,
float_t* frame, float_t* life_time);
extern void glitter_particle_manager_get_start_end_frame(glitter_particle_manager* gpm,
float_t* start_frame, float_t* end_frame);
extern bool FASTCALL glitter_particle_manager_load_effect(glitter_particle_manager* gpm,
uint64_t effect_group_hash, uint64_t effect_hash);
extern bool FASTCALL glitter_particle_manager_load_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_reset_scene_disp_counter(glitter_particle_manager* gpm);
extern void FASTCALL glitter_particle_manager_set_frame(glitter_particle_manager* gpm,
extern void FASTCALL glitter_particle_manager_calc_draw(GPM,
bool(FASTCALL* render_add_list_func)(glitter_particle_mesh*, vec4*, mat4*, mat4*));
extern bool FASTCALL glitter_particle_manager_check_effect_group(GPM, uint64_t effect_group_hash);
extern bool FASTCALL glitter_particle_manager_check_file_reader(GPM, uint64_t effect_group_hash);
extern bool FASTCALL glitter_particle_manager_check_scene(GPM, uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_draw(GPM, int32_t alpha);
extern bool FASTCALL glitter_particle_manager_free_effect_group(GPM, uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_free_effect_groups(GPM);
extern bool FASTCALL glitter_particle_manager_free_scene(GPM, uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_free_scenes(GPM);
extern size_t FASTCALL glitter_particle_manager_get_ctrl_count(GPM, glitter_particle_type ptcl_type);
extern size_t FASTCALL glitter_particle_manager_get_disp_count(GPM, glitter_particle_type ptcl_type);
extern void glitter_particle_manager_get_frame(GPM, float_t* frame, float_t* life_time);
extern void glitter_particle_manager_get_start_end_frame(GPM, float_t* start_frame, float_t* end_frame);
extern bool FASTCALL glitter_particle_manager_load_effect(GPM, uint64_t effect_group_hash, uint64_t effect_hash);
extern bool FASTCALL glitter_particle_manager_load_scene(GPM, uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_set_frame(GPM,
glitter_effect_group* effect_group, glitter_scene** scene, float_t curr_frame,
float_t prev_frame, uint32_t random, uint32_t counter, bool reset);
extern bool FASTCALL glitter_particle_manager_test_load_effect(glitter_particle_manager* gpm,
float_t prev_frame, uint32_t counter, bool reset);
extern bool FASTCALL glitter_particle_manager_test_load_effect(GPM,
uint64_t effect_group_hash, uint64_t effect_hash);
extern bool FASTCALL glitter_particle_manager_test_load_scene(glitter_particle_manager* gpm,
uint64_t effect_group_hash);
extern void FASTCALL glitter_particle_manager_update_file_reader(glitter_particle_manager* gpm);
extern void FASTCALL glitter_particle_manager_update_scene(glitter_particle_manager* gpm);
extern bool FASTCALL glitter_particle_manager_test_load_scene(GPM, uint64_t effect_group_hash, bool appear_now);
extern void FASTCALL glitter_particle_manager_update_file_reader(GPM);
extern void FASTCALL glitter_particle_manager_update_scene(GPM);
extern void FASTCALL glitter_particle_manager_dispose(glitter_particle_manager* gpm);
+249 -38
View File
@@ -1105,67 +1105,278 @@ static const uint16_t glitter_short_int_table[] = {
0x31EB, 0x3F4F, 0x08A1, 0x5EC1, 0xD52D, 0xDAE8, 0x2363, 0x7A22,
};
extern glitter_particle_manager* gpm;
static const uint32_t glitter_x_float_table[] = {
0x3ED6C16C, 0x3E444444, 0x3EFA4FA5, 0x3ECFA4FA, 0x3F271C72, 0x3F244444,
0x3F1E93E9, 0x3F016C17, 0x3E527D28, 0x3E777777, 0x3E9DDDDE, 0x3F7D27D2,
0x3F666666, 0x3EF60B61, 0x3E7A4FA5, 0x3E4CCCCD, 0x3F4E38E4, 0x3F4B60B6,
0x3E0B60B6, 0x3E360B61, 0x3E666666, 0x3F51C71C, 0x3F47D27D, 0x3F19999A,
0x3F64FA50, 0x3F355555, 0x3F3A4FA5, 0x3F4FA4FA, 0x3F7F49F5, 0x3EE4FA50,
0x3DF49F4A, 0x3F177777, 0x3DC16C17, 0x3EDF49F5, 0x3F6B60B6, 0x3ECB60B6,
0x3F088889, 0x3F4EEEEF, 0x3F638E39, 0x3E749F4A, 0x3F49F49F, 0x3F36C16C,
0x3D4CCCCD, 0x3E000000, 0x3E5B05B0, 0x3F5BBBBC, 0x3EF49F4A, 0x3E24FA50,
0x3D088888, 0x3EEC16C1, 0x3E9F49F5, 0x3F58E38E, 0x3F11C71C, 0x3E7D27D2,
0x3F7E93E9, 0x3ECE38E4, 0x3C638E39, 0x3F7A4FA5, 0x3DCCCCCD, 0x3F0AAAAB,
0x3F533333, 0x3F416C17, 0x3C360B61, 0x3EB05B06, 0x3F4C16C1, 0x3EE7D27D,
0x3F488889, 0x3F511111, 0x3F111111, 0x3F0CCCCD, 0x3F160B61, 0x3F1A4FA5,
0x3F705B06, 0x3F105B06, 0x3DAAAAAB, 0x3EF33333, 0x3F400000, 0x3EAC16C1,
0x3F5F49F5, 0x3E927D28, 0x3F493E94, 0x3EF05B06, 0x3EAD82D8, 0x3EDB05B0,
0x3E8CCCCD, 0x3E89F49F, 0x3F45B05B, 0x3F155555, 0x3EFD27D2, 0x3F29F49F,
0x3F0FA4FA, 0x3F555555, 0x3CB60B61, 0x3E911111, 0x3E93E93F, 0x3ED9999A,
0x3E96C16C, 0x3F40B60B, 0x3E9B05B0, 0x3EF8E38E, 0x3F711111, 0x3F133333,
0x3EEEEEEF, 0x3F727D28, 0x3F093E94, 0x3F0B60B6, 0x3EFE93E9, 0x3F6EEEEF,
0x3F733333, 0x3E416C17, 0x3F071C72, 0x3F09F49F, 0x3F238E39, 0x3E3BBBBC,
0x3EC00000, 0x3E49F49F, 0x3F360B61, 0x3ECCCCCD, 0x3F305B06, 0x3F67D27D,
0x3F200000, 0x3EF1C71C, 0x3F4D82D8, 0x3F582D83, 0x3EDDDDDE, 0x3D93E93F,
0x3F327D28, 0x3ED82D83, 0x3F00B60B, 0x3F25B05B, 0x3F3DDDDE, 0x3EBA4FA5,
0x3E333333, 0x3E5DDDDE, 0x3EE0B60B, 0x3D8E38E3, 0x3F0E38E4, 0x3E222222,
0x3D82D82E, 0x3EDC71C7, 0x3F7DDDDE, 0x3EE93E94, 0x3E0E38E4, 0x3EA66666,
0x3F022222, 0x3E2AAAAB, 0x3E111111, 0x3EC71C72, 0x3CE38E39, 0x3E982D83,
0x3F288889, 0x3D582D83, 0x3E16C16C, 0x3E471C72, 0x3E800000, 0x3ED3E93F,
0x3EA93E94, 0x3EA38E39, 0x3F382D83, 0x3F38E38E, 0x3F3BBBBC, 0x3F293E94,
0x3F3B05B0, 0x3D99999A, 0x3F0D82D8, 0x3E1F49F5, 0x3F4CCCCD, 0x3F22D82E,
0x3F577777, 0x3E02D82E, 0x3DE38E39, 0x3DD27D28, 0x3EE66666, 0x3F6CCCCD,
0x3F149F4A, 0x3F44FA50, 0x3F600000, 0x3EC16C17, 0x3F2EEEEF, 0x3EB33333,
0x3F333333, 0x3F2C16C1, 0x3F5C71C7, 0x3F066666, 0x3F466666, 0x3EB60B61,
0x3F182D83, 0x3B360B62, 0x3F2AAAAB, 0x3C9F49F4, 0x3F2FA4FA, 0x3F3F49F5,
0x3DB60B61, 0x3F311111, 0x3F755555, 0x3ED55555, 0x3EC2D82E, 0x3F622222,
0x3EC5B05B, 0x3F7C71C7, 0x3F13E93F, 0x3F18E38E, 0x3D2AAAAB, 0x3E2D82D8,
0x3F377777, 0x3F038E39, 0x3F5E93E9, 0x3DC71C72, 0x3F59999A, 0x3F222222,
0x3DA4FA50, 0x3F53E93F, 0x3F1D27D2, 0x3BB60B62, 0x3EB8E38E, 0x3DBBBBBC,
0x3F422222, 0x3E582D83, 0x3EAAAAAB, 0x3F644444, 0x3F0C16C1, 0x3D1F49F5,
0x3DE93E94, 0x3F671C72, 0x3F04FA50, 0x3EE22222, 0x3CFA4FA5, 0x3F31C71C,
0x3EC44444, 0x3E05B05B, 0x3F2CCCCD, 0x3E9C71C7, 0x3DB05B06, 0x3E99999A,
0x3E8FA4FA, 0x3EA7D27D, 0x3F5A4FA5, 0x3F000000, 0x3E955555, 0x3E888889,
0x3F5D27D2, 0x3E871C72, 0x3DEEEEEF, 0x3F2E38E4, 0x3D638E39, 0x3EFBBBBC,
0x3F24FA50, 0x3F69F49F, 0x3E1C71C7, 0x3EBE93E9, 0x3D6EEEEF, 0x3DFA4FA5,
0x3E6EEEEF, 0x3F6C16C1, 0x3F6D82D8, 0x3F71C71C, 0x3F505B06, 0x3D416C17,
0x3DD82D83, 0x3F4AAAAB, 0x3F782D83, 0x3F349F4A, 0x3EB1C71C, 0x3F42D82E,
0x3EBBBBBC, 0x3F1B05B0, 0x3F1F49F5, 0x3E816C17, 0x3D9F49F5, 0x3EC88889,
0x3F127D28, 0x3F60B60B, 0x3F07D27D, 0x3E19999A, 0x3E693E94, 0x3EA22222,
0x3ED27D28, 0x3E27D27D, 0x3F39999A, 0x3EB77777, 0x3E844444, 0x3E8B60B6,
0x3D7A4FA5, 0x3E4FA4FA, 0x3EAEEEEF, 0x3F6AAAAB, 0x3F05B05B, 0x3F438E39,
0x3E60B60B, 0x3F56C16C, 0x3EE38E39, 0x3E3E93E9, 0x3F549F4A, 0x3E555555,
0x3EA0B60B, 0x3F2B60B6, 0x3F7BBBBC, 0x3F33E93F, 0x3EBD27D2, 0x3E71C71C,
0x3F6FA4FA, 0x3E305B06, 0x3E38E38E, 0x3EED82D8, 0x3F65B05B, 0x3D13E93F,
0x3F616C17, 0x3F0EEEEF, 0x3F1C71C7, 0x3E13E93F, 0x3DDDDDDE, 0x3F6E38E4,
0x3F27D27D, 0x3ED11111, 0x3F777777, 0x3EEAAAAB, 0x3F1BBBBC, 0x3F1DDDDE,
0x3F216C17, 0x3F78E38E, 0x3C888889, 0x3F3C71C7, 0x3F7B05B0, 0x3F3D27D2,
0x3F79999A, 0x3F688889, 0x3E82D82E, 0x3EF77777, 0x3F2D82D8, 0x3F471C72,
0x3C088888, 0x3F560B61, 0x3E088889, 0x3CCCCCCD, 0x3F266666, 0x3F20B60B,
0x3F527D28, 0x3F02D82E, 0x3F760B61, 0x3F044444, 0x3F73E93F, 0x3F749F4A,
0x3F76C16C, 0x3F693E94, 0x3E85B05B, 0x3F16C16C, 0x3F5B05B0, 0x3E638E39,
0x3D360B61, 0x3F5DDDDE, 0x3F800000, 0x3F3E93E9, 0x3E6C16C1, 0x3F62D82E,
0x3E8E38E4, 0x3EB49F4A, 0x3EA4FA50, 0x3D888889, 0x3EC9F49F, 0x3F444444,
0x00000000,
};
int32_t FASTCALL glitter_random_get() {
if (gpm->f2)
return gpm->random & 0xFF;
else
return gpm->random & 0xFFF;
static const uint32_t glitter_x_int_table[] = {
0x01663B, 0x0093BA, 0x00B6DF, 0x0055FA, 0x00056F, 0x0171E9,
0x0178BD, 0x011C5E, 0x00C875, 0x015832, 0x015785, 0x00C379,
0x0037A2, 0x000FF8, 0x015A7B, 0x000E5C, 0x00AAE9, 0x00FD61,
0x017CC5, 0x015F51, 0x005FF9, 0x00C80E, 0x0126BB, 0x002AAF,
0x000819, 0x003108, 0x01558D, 0x017865, 0x008D3E, 0x012244,
0x018678, 0x00D564, 0x005E24, 0x015636, 0x00A338, 0x0122E0,
0x01514C, 0x014F2D, 0x0068E0, 0x013B24, 0x00E6D9, 0x011423,
0x013816, 0x01781F, 0x00EF31, 0x003FAD, 0x00BEC7, 0x007246,
0x0075B9, 0x006AEE, 0x000F74, 0x01359E, 0x00DC34, 0x004403,
0x001824, 0x00EBE9, 0x015E3F, 0x00ED52, 0x0126D1, 0x016D82,
0x0091B7, 0x006BF1, 0x00BFEA, 0x001196, 0x011653, 0x001449,
0x0141B7, 0x00411C, 0x015AB9, 0x00801A, 0x00A886, 0x006090,
0x006D66, 0x01158A, 0x009F27, 0x01445E, 0x00A906, 0x00AB11,
0x00D04E, 0x017DB5, 0x0158C4, 0x016426, 0x006C1E, 0x009A72,
0x00282E, 0x000FA1, 0x017C80, 0x00C25A, 0x003199, 0x0173A9,
0x004F33, 0x015650, 0x00490F, 0x007A69, 0x0059BF, 0x016CD1,
0x0055EB, 0x012437, 0x00844E, 0x0090D4, 0x01556B, 0x00FD65,
0x00B7CD, 0x001B58, 0x017541, 0x011A31, 0x015541, 0x0127FE,
0x0145F8, 0x00217F, 0x00455F, 0x00FDD8, 0x01274D, 0x00A8B1,
0x001FF4, 0x001FB8, 0x004E42, 0x016D7F, 0x005B3C, 0x009095,
0x00164C, 0x0100CB, 0x0002AB, 0x0142A3, 0x01069B, 0x0006EB,
0x008435, 0x01515E, 0x0007F2, 0x018338, 0x014AAC, 0x00EE95,
0x014270, 0x01142A, 0x0096B8, 0x00B296, 0x010F88, 0x004CD4,
0x006AE6, 0x0171D5, 0x00AD6A, 0x00CCD6, 0x010438, 0x006666,
0x001999, 0x004F4B, 0x014C6C, 0x007EB4, 0x00E148, 0x013BE6,
0x000043, 0x016EEE, 0x009CE8, 0x0061EB, 0x00490F, 0x011738,
0x00C02B, 0x00B9ED, 0x00EE7A, 0x00D519, 0x011F19, 0x0075D6,
0x000F80, 0x0060D9, 0x004F77, 0x017B63, 0x007703, 0x0098D1,
0x00C6F4, 0x014926, 0x00E2B6, 0x00BBBF, 0x001F02, 0x00C3AA,
0x009C82, 0x0100A9, 0x00EA47, 0x0096D8, 0x012610, 0x018129,
0x012C41, 0x00F131, 0x00F16E, 0x015509, 0x00D544, 0x011686,
0x012F14, 0x016F80, 0x0012D6, 0x008D8D, 0x006245, 0x0155AF,
0x007E83, 0x00B8E7, 0x002165, 0x016124, 0x01190D, 0x00D764,
0x0127F5, 0x00163B, 0x0043C1, 0x010F0C, 0x00C855, 0x002D18,
0x014DA5, 0x0176B9, 0x0017B8, 0x01351C, 0x011656, 0x00D94F,
0x00FDAF, 0x015F3B, 0x00B41D, 0x013BAB, 0x0151CB, 0x00D8D3,
0x00FFF2, 0x003DE4, 0x000D45, 0x0148C2, 0x016F76, 0x01661C,
0x007CF7, 0x006069, 0x009101, 0x006D63, 0x00A21D, 0x006F29,
0x00E4D9, 0x00A2EF, 0x010C9B, 0x0172E4, 0x002BB3, 0x016C4E,
0x00C257, 0x010995, 0x0141F2, 0x013BE8, 0x005100, 0x01459E,
0x00DE88, 0x00FB44, 0x00F02D, 0x0050CA, 0x004BF9, 0x014505,
0x00083F, 0x006644, 0x008898, 0x00E94B, 0x005EB3, 0x0094D1,
0x008948, 0x0180C8, 0x00D50F, 0x01372D, 0x00204E, 0x00D42A,
0x0062EF, 0x001055, 0x00C41D, 0x0039A3, 0x002732, 0x004493,
0x01070E, 0x015484, 0x0068F3, 0x0084F1, 0x00A7E4, 0x00ABE7,
0x015650, 0x0063B1, 0x00A3C2, 0x00B8DD, 0x0128E3, 0x006306,
0x012526, 0x0104BD, 0x007589, 0x005E02, 0x008BB4, 0x00DDD3,
0x003A2C, 0x012687, 0x010E85, 0x017A83, 0x00F342, 0x00B1C4,
0x006B1F, 0x016D1E, 0x00FA31, 0x0039B6, 0x012987, 0x0006B8,
0x01319A, 0x009296, 0x0152B6, 0x007B87, 0x00E665, 0x012124,
0x004CF2, 0x0133C8, 0x01838B, 0x009530, 0x017C0A, 0x01196B,
0x0124EC, 0x01512F, 0x000008, 0x01019B, 0x00CA28, 0x00D76F,
0x001882, 0x002191, 0x015356, 0x00499B, 0x013138, 0x0170E2,
0x00F046, 0x01480E, 0x013456, 0x017BCB, 0x003691, 0x0004F3,
0x00ECAE, 0x004AEA, 0x01460E, 0x0053CA, 0x000D17, 0x011A78,
0x000869, 0x00C190, 0x0130BB, 0x00FFEF, 0x013B73, 0x0103DB,
0x00885A, 0x00A503, 0x0038BC, 0x005B4A, 0x0150B5, 0x016CAB,
0x0167AF, 0x006396, 0x00528E, 0x00156C, 0x016428, 0x00D508,
0x0178F0, 0x00512B, 0x005CFC, 0x004098, 0x005897, 0x001F27,
0x0073DA, 0x00F12C, 0x016CBA, 0x007417, 0x009A1C, 0x00D3D0,
0x000001,
};
int32_t FASTCALL glitter_random_get_value(glitter_random* random) {
return random->value;
}
float_t FASTCALL glitter_random_get_float_clamp(float_t min, float_t max) {
float_t FASTCALL glitter_random_get_float(GPM, glitter_random* random, float_t value) {
float_t val;
switch (glt_type) {
default:
case GLITTER_AFT:
val = *(float_t*)&glitter_full_float_table[random->value % 0x1000];
break;
case GLITTER_F2:
val = *(float_t*)&glitter_short_float_table[random->value % 0x100];
break;
case GLITTER_X:
val = *(float_t*)&glitter_x_float_table[random->value % 0x169];
break;
}
random->value += random->step;
return val * (value * 2.0f) - value;
}
float_t FASTCALL glitter_random_get_float_min_max(GPM, glitter_random* random, float_t min, float_t max) {
float_t value;
if (gpm->f2)
value = *(float_t*)&glitter_short_float_table[gpm->random++ & 0xFF];
else
value = *(float_t*)&glitter_full_float_table[gpm->random++ & 0xFFF];
switch (glt_type) {
default:
case GLITTER_AFT:
value = *(float_t*)&glitter_full_float_table[random->value % 0x1000];
break;
case GLITTER_F2:
value = *(float_t*)&glitter_short_float_table[random->value % 0x100];
break;
case GLITTER_X:
value = *(float_t*)&glitter_x_float_table[random->value % 0x169];
break;
}
random->value += random->step;
return value * (max - min) + min;
}
float_t FASTCALL glitter_random_get_float_clamp_min_max(float_t value) {
return glitter_random_get_float_clamp(-value, value);
void FASTCALL glitter_random_get_vec3(GPM, glitter_random* random, vec3* src, vec3* dst) {
vec3 val;
vec3 t;
switch (glt_type) {
default:
case GLITTER_AFT:
val.x = *(float_t*)&glitter_full_float_table[random->value % 0x1000];
random->value += random->step;
val.y = *(float_t*)&glitter_full_float_table[random->value % 0x1000];
random->value += random->step;
val.z = *(float_t*)&glitter_full_float_table[random->value % 0x1000];
random->value += random->step;
break;
case GLITTER_F2:
val.x = *(float_t*)&glitter_short_float_table[random->value % 0x100];
random->value += random->step;
val.y = *(float_t*)&glitter_short_float_table[random->value % 0x100];
random->value += random->step;
val.z = *(float_t*)&glitter_short_float_table[random->value % 0x100];
random->value += random->step;
break;
case GLITTER_X:
val.x = *(float_t*)&glitter_x_float_table[random->value % 0x169];
random->value += random->step;
val.y = *(float_t*)&glitter_x_float_table[random->value % 0x169];
random->value += random->step;
val.z = *(float_t*)&glitter_x_float_table[random->value % 0x169];
random->value += random->step;
break;
}
t = *src;
vec3_add(t, t, t);
vec3_mult(val, t, t);
vec3_sub(t, *src, *dst);
}
void FASTCALL glitter_random_get_float_vec3_clamp(vec3* src, vec3* dst) {
dst->x = glitter_random_get_float_clamp_min_max(src->x);
dst->y = glitter_random_get_float_clamp_min_max(src->y);
dst->z = glitter_random_get_float_clamp_min_max(src->z);
}
int32_t FASTCALL glitter_random_get_int(int32_t value) {
int32_t FASTCALL glitter_random_get_int(GPM, glitter_random* random, int32_t value) {
int32_t val;
if (gpm->f2)
val = glitter_short_int_table[gpm->random++ & 0xFF];
else
val = glitter_full_int_table[gpm->random++ & 0xFFF];
switch (glt_type) {
default:
case GLITTER_AFT:
val = glitter_full_int_table[random->value % 0x1000];
break;
case GLITTER_F2:
val = glitter_short_int_table[random->value % 0x100];
break;
case GLITTER_X:
val = glitter_x_int_table[random->value % 0x169];
break;
}
random->value += random->step;
return val % value;
}
int32_t FASTCALL glitter_random_get_int_clamp(int32_t min, int32_t max) {
int32_t FASTCALL glitter_random_get_int_min_max(GPM, glitter_random* random, int32_t min, int32_t max) {
int32_t value;
if (max == min)
return min;
if (gpm->f2)
value = glitter_short_int_table[gpm->random++ & 0xFF];
else
value = glitter_full_int_table[gpm->random++ & 0xFFF];
switch (glt_type) {
default:
case GLITTER_AFT:
value = glitter_full_int_table[random->value % 0x1000];
break;
case GLITTER_F2:
value = glitter_short_int_table[random->value % 0x100];
break;
case GLITTER_X:
value = glitter_x_int_table[random->value % 0x169];
break;
}
random->value += random->step;
return value % (max - min) + min;
}
int32_t FASTCALL glitter_random_get_max() {
if (gpm->f2)
return 0x100;
else
int32_t FASTCALL glitter_random_get_max(GPM) {
switch (glt_type) {
default:
case GLITTER_AFT:
return 0x1000;
case GLITTER_F2:
return 0x100;
case GLITTER_X:
return 0x169;
}
}
void FASTCALL glitter_random_set(int32_t value) {
if (gpm->f2)
gpm->random = value & 0xFF;
else
gpm->random = value & 0xFFF;
void FASTCALL glitter_random_reset(glitter_random* random) {
random->value = 0;
random->step = 1;
}
void FASTCALL glitter_random_set_step(glitter_random* random, uint8_t step) {
random->step = step;
}
void FASTCALL glitter_random_set_value(glitter_random* random, int32_t value) {
random->value = value;
}
void FASTCALL glitter_random_step_value(glitter_random* random) {
random->value += random->step;
}
+16 -8
View File
@@ -7,11 +7,19 @@
#include "glitter.h"
extern int32_t FASTCALL glitter_random_get();
extern float_t FASTCALL glitter_random_get_float_clamp(float_t min, float_t max);
extern float_t FASTCALL glitter_random_get_float_clamp_min_max(float_t value);
extern void FASTCALL glitter_random_get_float_vec3_clamp(vec3* src, vec3* dst);
extern int32_t FASTCALL glitter_random_get_int(int32_t value);
extern int32_t FASTCALL glitter_random_get_int_clamp(int32_t min, int32_t max);
extern int32_t FASTCALL glitter_random_get_max();
extern void FASTCALL glitter_random_set(int32_t value);
extern int32_t FASTCALL glitter_random_get_value(glitter_random* random);
extern float_t FASTCALL glitter_random_get_float(GPM,
glitter_random* random, float_t value);
extern float_t FASTCALL glitter_random_get_float_min_max(GPM,
glitter_random* random, float_t min, float_t max);
extern void FASTCALL glitter_random_get_vec3(GPM,
glitter_random* random, vec3* src, vec3* dst);
extern int32_t FASTCALL glitter_random_get_int(GPM,
glitter_random* random, int32_t value);
extern int32_t FASTCALL glitter_random_get_int_min_max(GPM,
glitter_random* random, int32_t min, int32_t max);
extern int32_t FASTCALL glitter_random_get_max(GPM);
extern void FASTCALL glitter_random_reset(glitter_random* random);
extern void FASTCALL glitter_random_set_step(glitter_random* random, uint8_t step);
extern void FASTCALL glitter_random_set_value(glitter_random* random, int32_t value);
extern void FASTCALL glitter_random_step_value(glitter_random* random);
+468
View File
@@ -0,0 +1,468 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "render_element.h"
#include "counter.h"
#include "curve.h"
#include "emitter_inst.h"
#include "locus_history.h"
#include "particle_inst.h"
#include "random.h"
static void FASTCALL glitter_render_element_accelerate(GPM, glitter_particle_inst* a1,
glitter_render_element* a2, float_t delta_frame, glitter_random* random);
static void FASTCALL glitter_render_element_step_uv(GPM, glitter_particle_inst* a1,
glitter_render_element* a2, float_t delta_frame, glitter_random* random);
void FASTCALL glitter_render_element_emit(GPM,
glitter_particle_inst* a1, glitter_render_element* a2, glitter_emitter_inst* a3,
glitter_particle_inst_data* a4, int32_t index, uint8_t step, glitter_random* random) {
float_t speed;
float_t deceleration;
vec3 direction;
vec3 base_translation;
vec3 scale;
vec3 external_acceleration;
vec3 direction_random;
int32_t max_uv;
bool copy_mat;
a2->random.value = glitter_random_get_value(random);
a2->random.step = step;
a2->frame = 0.0f;
a2->rebound_frame = 0.0f;
a2->uv = vec2_null;
a2->uv_index = a4->data.uv_index;
a2->fade_in_frames = 0.0f;
a2->fade_out_frames = 0.0f;
a2->life_time = (float_t)a4->data.life_time;
a2->color = a4->data.color;
if (a4->data.draw_type == GLITTER_DIRECTION_PARTICLE_ROTATION) {
a2->rotation.x = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_random.x)
+ a4->data.rotation.x;
a2->rotation_add.x = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_add_random.x)
+ a4->data.rotation_add.x;
a2->rotation.y = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_random.y)
+ a4->data.rotation.y;
a2->rotation_add.y = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_add_random.y)
+ a4->data.rotation_add.y;
}
else {
a2->rotation.x = 0.0f;
a2->rotation.y = 0.0f;
a2->rotation_add.x = 0.0f;
a2->rotation_add.y = 0.0f;
}
a2->rotation.z = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_random.z)
+ a4->data.rotation.z;
a2->rotation_add.z = glitter_random_get_float(GPM_VAL, random, a4->data.rotation_add_random.z)
+ a4->data.rotation_add.z;
a2->uv_scroll = vec2_null;
a2->uv_scroll_2nd = vec2_null;
a2->scale = vec3_identity;
a2->scale_all = 1.0f;
a2->frame_step_uv = (float_t)a4->data.frame_step_uv;
a2->scale_particle.x = glitter_random_get_float(GPM_VAL, random, a4->data.scale_random.x)
+ a4->data.scale.x;
if (a4->data.flags & GLITTER_PARTICLE_SCALE_Y_BY_X)
a2->scale_particle.y = a2->scale_particle.x;
else
a2->scale_particle.y = glitter_random_get_float(GPM_VAL, random, a4->data.scale_random.y)
+ a4->data.scale.y;
max_uv = a4->data.split_u * a4->data.split_v;
if (max_uv > 1 && a4->data.uv_index_count > 1) {
switch (a4->data.uv_index_type) {
case GLITTER_UV_INDEX_INITIAL_RANDOM_FIXED:
case GLITTER_UV_INDEX_INITIAL_RANDOM_FORWARD:
case GLITTER_UV_INDEX_INITIAL_RANDOM_REVERSE:
a2->uv_index += glitter_random_get_int(GPM_VAL, random, a4->data.uv_index_count);
break;
}
a2->uv_index = min(a2->uv_index, a4->data.uv_index_end);
a2->uv.x = (float_t)(a2->uv_index % a1->data.data.split_u) * a1->data.data.split_uv.x;
a2->uv.y = (float_t)(a2->uv_index / a1->data.data.split_u) * a1->data.data.split_uv.y;
}
if (a4->data.flags & (GLITTER_PARTICLE_EMITTER_LOCAL | GLITTER_PARTICLE_ROTATE_BY_EMITTER))
a2->base_translation = vec3_null;
else
mat4_get_translation(&a3->mat, &a2->base_translation);
direction = a4->data.direction;
base_translation = vec3_null;
if (a4->data.flags & GLITTER_PARTICLE_EMITTER_LOCAL) {
scale = vec3_identity;
glitter_emitter_inst_get_mesh_by_type(GPM_VAL, a3, index, &scale, &base_translation, &direction, random);
}
else {
vec3_mult_scalar(a3->scale, a3->scale_all, scale);
glitter_emitter_inst_get_mesh_by_type(GPM_VAL, a3, index, &scale, &base_translation, &direction, random);
mat4_mult_vec3(&a3->mat_no_scale, &base_translation, &base_translation);
}
vec3_add(a2->base_translation, base_translation, a2->base_translation);
a2->translation = a2->base_translation;
a2->translation_prev = a2->base_translation;
glitter_random_get_vec3(GPM_VAL, random, &a4->data.direction_random, &direction_random);
vec3_add(direction, direction_random, direction);
vec3_normalize(direction, direction);
if (~a4->data.flags & GLITTER_PARTICLE_EMITTER_LOCAL)
mat4_mult_vec3(&a3->mat_no_scale, &direction, &direction);
a2->base_direction = direction;
a2->direction = direction;
speed = glitter_random_get_float(GPM_VAL, random, a4->data.speed_random) + a4->data.speed;
deceleration = glitter_random_get_float(GPM_VAL, random, a4->data.deceleration_random) + a4->data.deceleration;
a2->speed = speed * 60.0f;
a2->deceleration = max(deceleration * 60.0f, 0.0f);
glitter_random_get_vec3(GPM_VAL, random, &a4->data.acceleration_random, &external_acceleration);
vec3_add(external_acceleration, a4->data.acceleration, external_acceleration);
vec3_add(external_acceleration, a4->data.gravity, a2->acceleration);
copy_mat = false;
if (a4->data.flags & GLITTER_PARTICLE_ROTATE_BY_EMITTER
|| a4->data.draw_type == GLITTER_DIRECTION_EMITTER_ROTATION) {
switch (a3->data.type) {
case GLITTER_EMITTER_CYLINDER:
if (a3->data.cylinder.direction != GLITTER_EMITTER_EMISSION_DIRECTION_NONE) {
float_t length;
vec3_length(a2->direction, length);
copy_mat = length <= 0.000001f;
}
else
copy_mat = true;
break;
case GLITTER_EMITTER_SPHERE:
if (a3->data.sphere.direction != GLITTER_EMITTER_EMISSION_DIRECTION_NONE) {
float_t length;
vec3_length(a2->direction, length);
copy_mat = length <= 0.000001f;
}
else
copy_mat = true;
break;
default:
copy_mat = true;
break;
}
}
if (copy_mat) {
a2->mat = a3->mat;
if (a4->data.flags & GLITTER_PARTICLE_EMITTER_LOCAL)
a2->mat.row3 = (vec4){ 0.0f, 0.0f, 0.0f, 1.0f };
}
else
a2->mat = mat4_identity;
if (a1->data.data.type == GLITTER_PARTICLE_LOCUS) {
uint32_t locus_history_size = glitter_random_get_int_min_max(GPM_VAL, random,
-a1->data.data.locus_history_size_random, a1->data.data.locus_history_size_random)
+ a1->data.data.locus_history_size;
a2->locus_history = glitter_locus_history_init(locus_history_size);
}
glitter_random_step_value(random);
}
void FASTCALL glitter_render_element_free(glitter_render_element* a1) {
a1->alive = false;
if (a1->locus_history) {
glitter_locus_history_dispose(a1->locus_history);
a1->locus_history = 0;
}
}
void FASTCALL glitter_render_element_get_value(GPM,
glitter_render_group* a1, glitter_render_element* a2, float_t delta_frame) {
glitter_particle_inst* v4;
vec2 uv_scroll;
vec2 uv_scroll_2nd;
vec3 translation;
bool has_translation;
size_t length;
glitter_curve* curve;
float_t value;
float_t color_scale;
glitter_random_set_step(a1->random_ptr, 1);
v4 = a1->particle;
if (!v4 || !((v4->data.data.flags & GLITTER_PARTICLE_LOOP
&& !glitter_particle_inst_has_ended(v4, false)) || a2->frame <= a2->life_time)) {
a1->ctrl--;
a2->alive = false;
if (a2->locus_history) {
glitter_locus_history_dispose(a2->locus_history);
a2->locus_history = 0;
}
return;
}
glitter_render_element_accelerate(GPM_VAL, v4, a2, delta_frame, a1->random_ptr);
if (v4->data.data.draw_type == GLITTER_DIRECTION_PARTICLE_ROTATION) {
a2->rotation.x += a2->rotation_add.x * delta_frame;
a2->rotation.y += a2->rotation_add.y * delta_frame;
}
a2->rotation.z += a2->rotation_add.z * delta_frame;
vec2_mult_scalar(v4->data.data.uv_scroll_add,
v4->data.data.uv_scroll_add_scale * delta_frame, uv_scroll);
vec2_add(a2->uv_scroll, uv_scroll, a2->uv_scroll);
vec2_mult_scalar(v4->data.data.uv_scroll_2nd_add,
v4->data.data.uv_scroll_2nd_add_scale * delta_frame, uv_scroll_2nd);
vec2_add(a2->uv_scroll_2nd, uv_scroll_2nd, a2->uv_scroll_2nd);
glitter_render_element_step_uv(GPM_VAL, v4, a2, delta_frame, a1->random_ptr);
a2->color = (vec4){ -1.0f, -1.0f, -1.0f, -1.0f };
color_scale = -1.0f;
a2->draw = true;
if (v4->data.data.sub_flags & GLITTER_PARTICLE_SUB_USE_CURVE) {
value = 0.0f;
has_translation = false;
translation = vec3_null;
vector_ptr_glitter_curve curv = v4->particle->curve;
length = curv.end - curv.begin;
for (size_t i = 0; i < length; i++) {
curve = curv.begin[i];
if (!glitter_curve_get_value(GPM_VAL, curve, a2->frame, &value,
(int32_t)(a2->random.value + i), a1->random_ptr))
continue;
switch (curve->type) {
case GLITTER_CURVE_TRANSLATION_X:
translation.x = value;
has_translation = true;
break;
case GLITTER_CURVE_TRANSLATION_Y:
translation.y = value;
has_translation = true;
break;
case GLITTER_CURVE_TRANSLATION_Z:
translation.z = value;
has_translation = true;
break;
case GLITTER_CURVE_ROTATION_X:
a2->rotation.x = value;
break;
case GLITTER_CURVE_ROTATION_Y:
a2->rotation.y = value;
break;
case GLITTER_CURVE_ROTATION_Z:
a2->rotation.z = value;
break;
case GLITTER_CURVE_SCALE_X:
a2->scale.x = value;
if (fabsf(value) < 0.000001f)
a2->draw = false;
break;
case GLITTER_CURVE_SCALE_Y:
a2->scale.y = value;
if (fabsf(value) < 0.000001f)
a2->draw = false;
break;
case GLITTER_CURVE_SCALE_Z:
a2->scale.z = value;
if (fabsf(value) < 0.000001f)
a2->draw = false;
break;
case GLITTER_CURVE_SCALE_ALL:
a2->scale_all = value;
if (fabsf(value) < 0.000001f)
a2->draw = false;
break;
case GLITTER_CURVE_COLOR_R:
a2->color.x = value;
break;
case GLITTER_CURVE_COLOR_G:
a2->color.y = value;
break;
case GLITTER_CURVE_COLOR_B:
a2->color.z = value;
break;
case GLITTER_CURVE_COLOR_A:
a2->color.w = value;
if (value < 0.01f)
a2->draw = false;
break;
case GLITTER_CURVE_U_SCROLL:
a2->uv_scroll.x = value;
break;
case GLITTER_CURVE_V_SCROLL:
a2->uv_scroll.y = value;
break;
}
}
if (v4->data.data.flags & GLITTER_PARTICLE_ROTATE_BY_EMITTER || has_translation) {
vec3_add(translation, a2->base_translation, translation);
if (v4->data.data.flags & GLITTER_PARTICLE_ROTATE_BY_EMITTER)
mat4_mult_vec3_trans(&a2->mat, &translation, &translation);
a2->translation = translation;
}
}
if (a2->draw) {
if (a2->color.x < 0.0f)
a2->color.x = v4->data.data.color.x;
if (a2->color.y < 0.0f)
a2->color.y = v4->data.data.color.y;
if (a2->color.z < 0.0f)
a2->color.z = v4->data.data.color.z;
if (a2->color.w < 0.0f)
a2->color.w = v4->data.data.color.w;
if (color_scale >= 0.0f)
vec3_mult_scalar(*(vec3*)&a2->color, color_scale, *(vec3*)&a2->color);
if (a2->fade_in_frames > 0.0 && (a2->life_time - a2->frame) < a2->fade_in_frames)
a2->color.w *= (a2->life_time - a2->frame) / a2->fade_in_frames;
else if (a2->fade_out_frames > 0.0 && a2->frame < a2->fade_out_frames)
a2->color.w *= a2->frame / a2->fade_out_frames;
if (a2->color.w < 0.01f)
a2->draw = false;
}
if (v4->data.data.type == GLITTER_PARTICLE_LOCUS)
glitter_locus_history_append(GPM_VAL, a2->locus_history, a2, v4);
a2->frame += delta_frame;
if (v4->data.data.flags & GLITTER_PARTICLE_LOOP && a2->frame >= a2->life_time)
a2->frame -= a2->life_time;
}
void FASTCALL glitter_render_element_rotate_to_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3) {
vec3 vec1;
vec3 vec2;
float_t angle;
vec3 axis;
if (a2->flags & GLITTER_PARTICLE_EMITTER_LOCAL)
vec2 = a3->translation;
else {
mat4_get_translation(&a2->mat, &vec2);
vec3_sub(vec2, a3->translation, vec2);
}
vec3_normalize(vec2, vec2);
if (fabsf(vec2.y) >= 0.000001f) {
*mat = mat3_identity;
vec1 = (vec3){ 0.0f, 0.0f, 1.0f };
axis_angle_from_vectors(&axis, &angle, &vec1, &vec2);
mat3_mult_axis_angle(mat, mat, &axis, angle);
}
else
mat3_rotate_z((float_t)M_PI, mat);
}
void FASTCALL glitter_render_element_rotate_to_prev_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3) {
vec3 vec1;
vec3 vec2;
float_t angle;
vec3 axis;
float_t length;
vec3_sub(a3->translation, a3->translation_prev, vec2);
vec3_length_squared(vec2, length);
if (length < 0.000001f)
vec2 = a3->translation;
vec3_normalize(vec2, vec2);
if (fabsf(vec2.y) >= 0.000001f) {
mat3_rotate_z((float_t)M_PI, mat);
vec1 = (vec3){ 0.0f, 1.0f, 0.0f };
axis_angle_from_vectors(&axis, &angle, &vec1, &vec2);
mat3_mult_axis_angle(mat, mat, &axis, angle);
}
else
mat3_rotate_z((float_t)M_PI, mat);
}
static void FASTCALL glitter_render_element_accelerate(GPM, glitter_particle_inst* a1,
glitter_render_element* a2, float_t delta_frame, glitter_random* random) {
vec3 acceleration;
vec3 direction;
float_t diff_time;
float_t delta_time;
float_t reflection_coeff;
float_t speed;
a2->translation_prev = a2->translation;
delta_time = delta_frame * (float_t)(1.0 / 60.0);
diff_time = (a2->frame - a2->rebound_frame - delta_frame) * (float_t)(1.0 / 60.0);
vec3_mult_scalar(a2->acceleration, delta_time * (delta_time * 0.5f + diff_time), acceleration);
speed = a2->deceleration * delta_time * (delta_time * 0.5f - diff_time) + a2->speed;
if (speed >= 0.01f) {
vec3_mult_scalar(a2->direction, speed * delta_time, direction);
vec3_add(acceleration, direction, acceleration);
}
vec3_add(a2->translation, acceleration, a2->translation);
vec3_add(a2->base_translation, acceleration, a2->base_translation);
if (a1->data.data.flags & GLITTER_PARTICLE_REBOUND_PLANE
&& a2->translation_prev.y > a1->data.data.rebound_plane_y
&& a2->translation.y <= a1->data.data.rebound_plane_y) {
reflection_coeff = glitter_random_get_float(GPM_VAL, random,
a1->data.data.reflection_coeff_random) + a1->data.data.reflection_coeff;
a2->rebound_frame = a2->frame;
vec3_sub(a2->translation, a2->translation_prev, direction);
vec3_mult_scalar(direction, reflection_coeff * 60.0f, direction);
vec3_xor(direction, ((vec3){ 0.0f, -0.0f, 0.0f }), a2->direction);
a2->translation.y = a2->translation_prev.y;
}
}
static void FASTCALL glitter_render_element_get_color(glitter_particle_inst* a1,
float_t* r, float_t* g, float_t* b, float_t* a) {
glitter_effect_inst* effect;
effect = a1->data.effect;
if (!effect) {
if (!a1->data.parent)
return;
effect = a1->data.parent->data.effect;
if (!effect)
return;
}
}
static void FASTCALL glitter_render_element_step_uv(GPM, glitter_particle_inst* a1,
glitter_render_element* a2, float_t delta_frame, glitter_random* random) {
if (a1->data.data.frame_step_uv <= 0.0f)
return;
int32_t max_uv = a1->data.data.split_u * a1->data.data.split_v;
if (max_uv)
max_uv--;
while (a2->frame_step_uv <= 0.0f) {
switch (a1->data.data.uv_index_type) {
case GLITTER_UV_INDEX_RANDOM:
a2->uv_index = a1->data.data.uv_index_start;
if (a1->data.data.uv_index_count > 1)
a2->uv_index += glitter_random_get_int(GPM_VAL, random, a1->data.data.uv_index_count);
break;
case GLITTER_UV_INDEX_FORWARD:
case GLITTER_UV_INDEX_INITIAL_RANDOM_FORWARD:
a2->uv_index = (uint8_t)(max_uv & (a2->uv_index + 1));
break;
case GLITTER_UV_INDEX_REVERSE:
case GLITTER_UV_INDEX_INITIAL_RANDOM_REVERSE:
a2->uv_index = (uint8_t)(max_uv & (a2->uv_index - 1));
break;
}
a2->uv.x = (float_t)(a2->uv_index % a1->data.data.split_u) * a1->data.data.split_uv.x;
a2->uv.y = (float_t)(a2->uv_index / a1->data.data.split_u) * a1->data.data.split_uv.y;
a2->frame_step_uv += a1->data.data.frame_step_uv;
}
a2->frame_step_uv -= delta_frame;
}
+23
View File
@@ -0,0 +1,23 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "glitter.h"
extern void FASTCALL glitter_render_element_emit(GPM,
glitter_particle_inst* a1, glitter_render_element* a2, glitter_emitter_inst* a3,
glitter_particle_inst_data* a4, int32_t index, uint8_t step, glitter_random* random);
extern void FASTCALL glitter_render_element_free(glitter_render_element* a1);
extern void FASTCALL glitter_render_element_get_value(GPM, glitter_render_group* a1,
glitter_render_element* a2, float_t delta_frame);
extern void FASTCALL glitter_render_element_rotate_to_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3);
extern void FASTCALL glitter_render_element_rotate_to_prev_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3);
extern void FASTCALL glitter_render_element_x_rotate_to_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3, vec3* pos, vec3* direction);
extern void FASTCALL glitter_render_element_x_rotate_to_prev_position(mat3* mat,
glitter_render_group* a2, glitter_render_element* a3, vec3* pos, vec3* direction);
File diff suppressed because it is too large Load Diff
+8 -35
View File
@@ -7,42 +7,15 @@
#include "glitter.h"
extern glitter_render_group* FASTCALL glitter_render_group_init(int32_t count, glitter_particle_inst* a2);
extern glitter_render_group_sub* FASTCALL glitter_render_group_add_control(glitter_render_group* a1,
glitter_render_group_sub* a2);
extern void FASTCALL glitter_render_group_copy(glitter_render_group* a1, glitter_render_group* a2);
extern void FASTCALL glitter_render_group_copy_from_particle(glitter_render_group* render_group,
float_t delta_frame, bool copy_mats);
extern glitter_render_group* FASTCALL glitter_render_group_init(GPM, glitter_particle_inst* a1);
extern void FASTCALL glitter_render_group_calc_draw(GPM, glitter_render_group* a1,
bool(FASTCALL* render_add_list_func)(glitter_particle_mesh*, vec4*, mat4*, mat4*));
extern bool FASTCALL glitter_render_group_cannot_draw(glitter_render_group* a1);
extern void FASTCALL glitter_render_group_delete_buffers(glitter_render_group* a1, bool a2);
extern void FASTCALL glitter_render_group_draw(glitter_scene_sub* a1, glitter_render_group* a2);
extern void FASTCALL glitter_render_group_draw_line(glitter_scene_sub* a1, glitter_render_group* a2);
extern void FASTCALL glitter_render_group_draw_locus(glitter_scene_sub* a1, glitter_render_group* a2);
extern void FASTCALL glitter_render_group_draw_quad(glitter_scene_sub* a1, glitter_render_group* a2);
extern void FASTCALL glitter_render_group_draw_quad_rotate_to_prev_position(mat4* mat,
glitter_render_group* a2, glitter_render_group_sub* a3);
extern void FASTCALL glitter_render_group_draw_quad_rotate_to_position(mat4* mat,
glitter_render_group* a2, glitter_render_group_sub* a3);
extern void FASTCALL glitter_render_group_draw_quad_sub1(glitter_scene_sub* a1,
glitter_render_group* a2, mat4* a3, mat4* a4);
extern void FASTCALL glitter_render_group_draw_quad_sub2(glitter_scene_sub* a1,
glitter_render_group* a2, mat4* a3, mat4* a4,
void(FASTCALL* a5)(mat4*, glitter_render_group*, glitter_render_group_sub*));
extern void FASTCALL glitter_render_group_draw_quads(glitter_scene_sub* a1, int32_t count);
extern void FASTCALL glitter_render_group_draw_set_pivot(glitter_pivot pivot,
float_t a2, float_t a3, float_t* v00, float_t* v01, float_t* v10, float_t* v11);
extern void FASTCALL glitter_render_group_emit(glitter_render_group* a1,
extern void FASTCALL glitter_render_group_draw(GPM, glitter_render_group* a1);
extern void FASTCALL glitter_render_group_emit(GPM, glitter_render_group* a1,
glitter_particle_inst_data* a2, glitter_emitter_inst* a3, int32_t a4, int32_t count);
extern void FASTCALL glitter_render_group_free(glitter_render_group* a1);
extern bool FASTCALL glitter_render_group_get_a3da_scale(glitter_render_group* a1, vec3* a2);
extern void FASTCALL glitter_render_group_sub_accelerate(glitter_particle_inst* a1,
glitter_render_group_sub* a2, float_t rebound_time, float_t delta_frame);
extern void FASTCALL glitter_render_group_sub_clamp_color(glitter_particle_inst* a1,
float_t* r, float_t* g, float_t* b, float_t* a);
extern void FASTCALL glitter_render_group_sub_emit(glitter_particle_inst* a1,
glitter_render_group_sub* a2, glitter_emitter_inst* a3, glitter_particle_inst_data* a4, int32_t a5);
extern void FASTCALL glitter_render_group_sub_get_color(glitter_particle_inst* a1, glitter_render_group_sub* a2);
extern void FASTCALL glitter_render_group_sub_get_value(glitter_render_group* a1,
glitter_render_group_sub* a2, float_t delta_frame);
extern void FASTCALL glitter_render_group_sub_step_uv(glitter_particle_inst* a1,
glitter_render_group_sub* a2, float_t delta_frame);
extern void FASTCALL glitter_render_group_get_value(GPM,
glitter_render_group* render_group, float_t delta_frame, bool copy_mats);
extern void FASTCALL glitter_render_group_dispose(glitter_render_group* rg);
+39 -66
View File
@@ -5,43 +5,20 @@
#include "scene.h"
#include "effect_inst.h"
#include "render_group.h"
#include "../GlitterX/effect_inst_x.h"
glitter_scene* FASTCALL glitter_scene_init(glitter_effect_group* eg) {
glitter_scene* s = force_malloc(sizeof(glitter_scene));
s->emission = 1.0f;
s->effect_group = eg;
s->hash = eg->hash;
vector_ptr_glitter_render_group_resize(&s->sub.render_groups, 0x40);
if (eg) {
vector_ptr_glitter_effect_inst_resize(&s->effects, eg->effects.end - eg->effects.begin);
vector_ptr_glitter_effect_inst_append(&s->effects, eg->effects.end - eg->effects.begin);
s->emission = eg->emission;
}
return s;
}
bool FASTCALL glitter_scene_copy(glitter_scene* a1, glitter_effect_inst* a2, glitter_scene* a3) {
glitter_effect_inst** i;
if (a1->effects.begin == a1->effects.end)
return false;
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i && (*i)->id == a2->id) {
glitter_effect_inst_copy(*i, a2, a3);
return true;
}
return false;
}
void FASTCALL glitter_scene_emit(glitter_scene* a1, float_t frame_speed) {
glitter_effect_inst** i;
for (i = a1->effects.begin; i != a1->effects.end; ++i)
if (*i)
glitter_effect_inst_emit(*i, a1, frame_speed);
}
bool FASTCALL glitter_scene_has_ended(glitter_scene* scene, bool a2) {
glitter_effect_inst** i;
@@ -51,7 +28,7 @@ bool FASTCALL glitter_scene_has_ended(glitter_scene* scene, bool a2) {
return true;
}
void FASTCALL glitter_scene_init_effect(glitter_scene* a1,
void FASTCALL glitter_scene_init_effect(GPM, glitter_scene* a1,
glitter_effect* a2, size_t id, bool appear_now) {
glitter_effect_inst** i;
glitter_effect_inst* effect;
@@ -59,55 +36,51 @@ void FASTCALL glitter_scene_init_effect(glitter_scene* a1,
if (!a2)
return;
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i && (*i)->id == id) {
glitter_effect_inst_reset(*i, a1);
return;
}
/*if (glt_type == GLITTER_X) {
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i && (*i)->id == id) {
glitter_x_effect_inst_reset(GPM_VAL, *i, a1->emission);
return;
}
effect = glitter_effect_inst_init(a2, a1, id, appear_now);
vector_ptr_glitter_effect_inst_push_back(&a1->effects, &effect);
}
effect = glitter_x_effect_inst_init(GPM_VAL, a2, id, a1->emission, appear_now);
vector_ptr_glitter_effect_inst_push_back(&a1->effects, &effect);
}
else*/ {
for (i = a1->effects.begin; i != a1->effects.end; i++)
if (*i && (*i)->id == id) {
glitter_effect_inst_reset(GPM_VAL, *i, a1->emission);
return;
}
void FASTCALL glitter_scene_update_scene(glitter_scene* a1, float_t delta_frame) {
glitter_render_group** i;
glitter_render_group* render_group;
glitter_scene_sub* sub;
sub = &a1->sub;
sub->ctrl_quad = 0;
sub->ctrl_line = 0;
sub->ctrl_locus = 0;
for (i = sub->render_groups.begin; i != sub->render_groups.end; i++) {
if (!*i)
continue;
render_group = *i;
switch (render_group->type) {
case GLITTER_PARTICLE_QUAD:
sub->ctrl_quad += render_group->ctrl;
break;
case GLITTER_PARTICLE_LINE:
sub->ctrl_line += render_group->ctrl;
break;
case GLITTER_PARTICLE_LOCUS:
sub->ctrl_locus += render_group->ctrl;
break;
}
glitter_render_group_copy_from_particle(render_group, delta_frame, true);
effect = glitter_effect_inst_init(GPM_VAL, a2, id, a1->emission, appear_now);
vector_ptr_glitter_effect_inst_push_back(&a1->effects, &effect);
}
}
void FASTCALL glitter_scene_update_value_frame(glitter_scene* a1, float_t delta_frame) {
void FASTCALL glitter_scene_update_value_frame(GPM, glitter_scene* a1, float_t delta_frame) {
glitter_effect_inst** i;
glitter_effect_inst* effect;
for (i = a1->effects.begin; i != a1->effects.end; ++i)
if (*i)
glitter_effect_inst_update_value_frame(*i, delta_frame);
/*if (glt_type == GLITTER_X)
for (i = a1->effects.begin; i != a1->effects.end; ++i) {
if (!*i)
continue;
effect = *i;
glitter_x_effect_inst_update_value_frame(GPM_VAL, effect, delta_frame, a1->emission);
}
else*/
for (i = a1->effects.begin; i != a1->effects.end; ++i) {
if (!*i)
continue;
effect = *i;
glitter_effect_inst_update_value_frame(GPM_VAL, effect, delta_frame, a1->emission);
}
}
void FASTCALL glitter_scene_dispose(glitter_scene* s) {
vector_ptr_glitter_effect_inst_free(&s->effects, (void*)glitter_effect_inst_dispose);
vector_ptr_glitter_render_group_free(&s->sub.render_groups, (void*)glitter_render_group_dispose);
vector_ptr_glitter_effect_inst_free(&s->effects, glitter_effect_inst_dispose);
free(s);
}
+2 -5
View File
@@ -8,11 +8,8 @@
#include "glitter.h"
extern glitter_scene* FASTCALL glitter_scene_init(glitter_effect_group* eg);
extern bool FASTCALL glitter_scene_copy(glitter_scene* a1, glitter_effect_inst* a2, glitter_scene* a3);
extern void FASTCALL glitter_scene_emit(glitter_scene* a1, float_t frame_speed);
extern bool FASTCALL glitter_scene_has_ended(glitter_scene* scene, bool a2);
extern void FASTCALL glitter_scene_init_effect(glitter_scene* a1,
extern void FASTCALL glitter_scene_init_effect(GPM, glitter_scene* a1,
glitter_effect* a2, size_t id, bool appear_now);
extern void FASTCALL glitter_scene_update_scene(glitter_scene* a1, float_t delta_frame);
extern void FASTCALL glitter_scene_update_value_frame(glitter_scene* a1, float_t delta_frame);
extern void FASTCALL glitter_scene_update_value_frame(GPM, glitter_scene* a1, float_t delta_frame);
extern void FASTCALL glitter_scene_dispose(glitter_scene* s);
+19 -2
View File
@@ -9,8 +9,6 @@ float_t frame_speed = 1.0f;
float_t target_fps = 60.0f;
extern double_t render_freq;
int32_t glitter_shader_flags[4];
float_t get_frame_speed() {
return (float_t)(clamp(target_fps / render_freq, 0.0, 1.0) * frame_speed);
}
@@ -40,6 +38,21 @@ void FASTCALL axis_angle_from_vectors(vec3* axis, float_t* angle, vec3* vec1, ve
*angle = (float_t)M_PI - *angle;
}
void FASTCALL mat3_mult_axis_angle(mat3* src, mat3* dst, vec3* axis, float_t angle) {
quat q1;
quat q2;
quat q3;
quat_from_mat3(src->row0.x, src->row0.y, src->row0.z, src->row1.x,
src->row1.y, src->row1.z, src->row2.x, src->row2.y, src->row2.z, &q1);
quat_from_axis_angle(axis, angle, &q2);
q3.x = q1.x * q2.w - q1.y * q2.z + q1.z * q2.y + q1.w * q2.x;
q3.y = q1.x * q2.z + q1.y * q2.w - q1.z * q2.x + q1.w * q2.y;
q3.z = -q1.x * q2.y + q1.y * q2.x + q1.z * q2.w + q1.w * q2.z;
q3.w = -q1.x * q2.x - q1.y * q2.y - q1.z * q2.z + q1.w * q2.w;
mat3_from_quat(&q3, dst);
}
void FASTCALL mat4_mult_axis_angle(mat4* src, mat4* dst, vec3* axis, float_t angle) {
quat q1;
quat q2;
@@ -57,4 +70,8 @@ void FASTCALL mat4_mult_axis_angle(mat4* src, mat4* dst, vec3* axis, float_t ang
*(vec3*)&dst->row0 = yt.row0;
*(vec3*)&dst->row1 = yt.row1;
*(vec3*)&dst->row2 = yt.row2;
dst->row0.w = src->row0.w;
dst->row1.w = src->row2.w;
dst->row2.w = src->row3.w;
dst->row3 = src->row3;
}
+2 -5
View File
@@ -10,14 +10,13 @@
#include "../../KKdLib/f2_struct.h"
#include "../../KKdLib/farc.h"
#include "../../KKdLib/hash.h"
#include "../../KKdLib/io_path.h"
#include "../../KKdLib/mat.h"
#include "../../KKdLib/quat.h"
#include "../../KKdLib/str_utils.h"
#include "../../KKdLib/txp.h"
#include "../../KKdLib/utf8.h"
#include "../../KKdLib/vec.h"
#include "../../KKdLib/vector.h"
#include "../camera.h"
#define GLEW_STATIC
#include <GLEW/glew.h>
@@ -25,9 +24,7 @@ extern float_t frame_speed;
extern float_t target_fps;
extern float_t current_fps;
extern int32_t glitter_shader_flags[4];
extern camera* cam;
extern float_t get_frame_speed();
extern void FASTCALL axis_angle_from_vectors(vec3* axis, float_t* angle, vec3* vec0, vec3* vec1);
extern void FASTCALL mat3_mult_axis_angle(mat3* src, mat3* dst, vec3* axis, float_t angle);
extern void FASTCALL mat4_mult_axis_angle(mat4* src, mat4* dst, vec3* axis, float_t angle);
+95 -153
View File
@@ -4,47 +4,46 @@
*/
#include "texture.h"
#include "../texture.h"
static void load_texture_data(txp_sub_data* data, int32_t mipmap);
bool FASTCALL glitter_texture_hashes_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
char* data;
bool FASTCALL glitter_texture_hashes_pack_file(glitter_effect_group* a1, f2_struct* st) {
size_t l;
size_t d;
size_t count;
uint64_t* resource_hashes;
size_t i;
if (!a1->effects.begin)
if (a1->effects.end - a1->effects.begin < 1 || !a1->resources_count
|| a1->resource_hashes.end - a1->resource_hashes.begin < 1)
return false;
memset(st, 0, sizeof(f2_struct));
count = a1->resources_count;
data = force_malloc(align_val(0x08 + 0x08 * count, 0x10));
st->data = data;
st->length = align_val(0x08 + 0x08 * count, 0x10);
if (use_big_endian)
*(int32_t*)data = reverse_endianess_int32_t((int32_t)count);
else
*(int32_t*)data = (int32_t)count;
data += 0x04;
*(int32_t*)data = 0;
data += 0x04;
memset(st, 0, sizeof(f2_struct));
l = 0;
if (count) {
resource_hashes = a1->resource_hashes;
if (!resource_hashes)
return false;
vector_enrs_entry e = { 0, 0, 0 };
enrs_entry ee;
if (use_big_endian)
for (i = 0; i < count; i++, data += sizeof(uint64_t))
*(uint64_t*)data = reverse_endianess_uint64_t(resource_hashes[i]);
else
memcpy(data, resource_hashes, sizeof(uint64_t) * count);
}
ee = (enrs_entry){ 0, 2, (uint32_t)(8 + count * 8), 1, { 0, 0, 0 } };
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 0, 1, ENRS_TYPE_DWORD });
vector_enrs_sub_entry_push_back(&ee.sub, &(enrs_sub_entry){ 4, (uint32_t)count, ENRS_TYPE_QWORD });
vector_enrs_entry_push_back(&e, &ee);
l += 8 + count * 8;
l = align_val(l, 0x10);
d = (size_t)force_malloc(l);
st->data = (void*)d;
st->length = l;
st->enrs = e;
*(int32_t*)d = (int32_t)count;
*(int32_t*)(d + 4) = 0;
d += 8;
memcpy((void*)d, a1->resource_hashes.begin, sizeof(uint64_t) * count);
st->header.signature = 0x53525644;
st->header.length = 0x20;
st->header.use_big_endian = use_big_endian ? true : false;
st->header.use_big_endian = false;
st->header.use_section_size = true;
return true;
}
@@ -55,7 +54,7 @@ bool FASTCALL glitter_texture_hashes_unpack_file(glitter_effect_group* a1, f2_st
uint64_t* resource_hashes;
size_t i;
if (a1->resource_hashes)
if (a1->resources_count && a1->resource_hashes.end - a1->resource_hashes.begin > 0)
return true;
if (!st || !st->header.data_size)
@@ -73,8 +72,10 @@ bool FASTCALL glitter_texture_hashes_unpack_file(glitter_effect_group* a1, f2_st
a1->resources_count = count;
if (count) {
resource_hashes = force_malloc_s(sizeof(uint64_t), count);
a1->resource_hashes = resource_hashes;
resource_hashes = force_malloc_s(uint64_t, count);
a1->resource_hashes.begin = resource_hashes;
a1->resource_hashes.end = resource_hashes + count;
a1->resource_hashes.capacity_end = resource_hashes + count;
if (!resource_hashes)
return false;
@@ -87,154 +88,95 @@ bool FASTCALL glitter_texture_hashes_unpack_file(glitter_effect_group* a1, f2_st
return true;
}
bool FASTCALL glitter_texture_resource_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian) {
if (!a1->resources_tex)
bool FASTCALL glitter_texture_resource_pack_file(glitter_effect_group* a1, f2_struct* st) {
if (a1->resources_tex.end - a1->resources_tex.begin < 1)
return false;
memset(st, 0, sizeof(f2_struct));
txp_pack_file(a1->resources_tex, &st->data, &st->length, use_big_endian);
if (!tex_set_produce_enrs(&a1->resources_tex, &st->enrs))
return false;
tex_set_pack_file(&a1->resources_tex, &st->data, &st->length, false);
st->header.signature = 0x43505854;
st->header.length = 0x20;
st->header.use_big_endian = use_big_endian ? true : false;
st->header.use_big_endian = false;
st->header.use_section_size = true;
return true;
}
bool FASTCALL glitter_texture_resource_unpack_file(glitter_effect_group* a1, f2_struct* st) {
size_t i;
size_t j;
size_t k;
txp_data* tex_data;
txp_sub_data** tex_sub_data;
txp_sub_data* tex_sub_sub_data;
glitter_effect** l;
glitter_effect* effect;
glitter_emitter** m;
glitter_emitter* emitter;
glitter_particle** n;
glitter_particle* particle;
if (!st || !st->header.data_size)
return false;
txp* t = txp_init();
if (!txp_unpack_file(t, st->data, st->header.use_big_endian) || !a1->resources_count || a1->resources_count != t->count)
goto End;
if (!a1->resources) {
a1->resources = force_malloc_s(sizeof(int32_t), a1->resources_count);
glGenTextures(a1->resources_count, a1->resources);
tex_set_unpack_file(&a1->resources_tex, st->data, st->header.use_big_endian);
return glitter_texture_load(a1);
}
tex_data = t->data;
for (i = 0; i < t->count; i++, tex_data++) {
glBindTexture(GL_TEXTURE_2D, a1->resources[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
tex_data->mipmaps_count > 1 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex_data->mipmaps_count - 1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, 16.0f);
tex_sub_data = tex_data->data;
for (j = 0; j < tex_data->array_size; j++, tex_sub_data++) {
tex_sub_sub_data = *tex_sub_data;
for (k = 0; k < tex_data->mipmaps_count; k++, tex_sub_sub_data++)
load_texture_data(tex_sub_sub_data, (int32_t)k);
break;
}
glGenerateMipmap(GL_TEXTURE_2D);
}
glBindTexture(GL_TEXTURE_2D, 0);
}
bool FASTCALL glitter_texture_load(glitter_effect_group* a1) {
if (!a1->resources_count)
return false;
for (i = 0; i < a1->resources_count; i++)
for (l = a1->effects.begin; l != a1->effects.end; l++) {
effect = *l;
if (!effect)
size_t count = a1->resources_tex.end - a1->resources_tex.begin;
if (!count || !a1->resources_count || a1->resources_count != count)
return false;
if (!texture_txp_load(&a1->resources_tex, &a1->resources))
return false;
for (glitter_effect** l = a1->effects.begin; l != a1->effects.end; l++) {
if (!*l)
continue;
glitter_effect* effect = *l;
for (glitter_emitter** m = effect->emitters.begin; m != effect->emitters.end; m++) {
if (!*m)
continue;
for (m = effect->emitters.begin; m != effect->emitters.end; m++) {
emitter = *m;
if (!emitter)
glitter_emitter* emitter = *m;
for (glitter_particle** n = emitter->particles.begin; n != emitter->particles.end; n++) {
if (!*n)
continue;
for (n = emitter->particles.begin; n != emitter->particles.end; n++) {
particle = *n;
if (!particle)
glitter_particle* particle = *n;
particle->data.texture0 = 0;
particle->data.texture1 = 0;
}
}
}
for (size_t i = 0; i < a1->resources_count; i++)
for (glitter_effect** l = a1->effects.begin; l != a1->effects.end; l++) {
if (!*l)
continue;
glitter_effect* effect = *l;
for (glitter_emitter** m = effect->emitters.begin; m != effect->emitters.end; m++) {
if (!*m)
continue;
glitter_emitter* emitter = *m;
for (glitter_particle** n = emitter->particles.begin; n != emitter->particles.end; n++) {
if (!*n)
continue;
if (particle->data.data.tex_hash0 == a1->resource_hashes[i])
particle->data.data.texture0 = a1->resources[i];
if (particle->data.data.tex_hash1 == a1->resource_hashes[i])
particle->data.data.texture1 = a1->resources[i];
glitter_particle* particle = *n;
if (particle->data.type == GLITTER_PARTICLE_LINE
|| particle->data.type == GLITTER_PARTICLE_MESH)
continue;
if (particle->data.tex_hash0 == a1->resource_hashes.begin[i])
particle->data.texture0 = a1->resources.begin[i];
if (particle->data.tex_hash1 == a1->resource_hashes.begin[i])
particle->data.texture1 = a1->resources.begin[i];
}
}
}
End:
a1->resources_tex = t;
return true;
}
static void load_texture_data(txp_sub_data* data, int32_t mipmap) {
switch (data->format) {
case TXP_A8:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_ALPHA8, data->width, data->height,
0, GL_ALPHA, GL_UNSIGNED_BYTE, data->data);
break;
case TXP_RGB8:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_RGB8, data->width, data->height,
0, GL_RGB, GL_UNSIGNED_BYTE, data->data);
break;
case TXP_RGBA8:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_RGBA8, data->width, data->height,
0, GL_RGBA, GL_UNSIGNED_BYTE, data->data);
break;
case TXP_RGB5:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_RGB5, data->width, data->height,
0, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, data->data);
break;
case TXP_RGB5A1:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_RGB5_A1, data->width, data->height,
0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, data->data);
break;
case TXP_RGBA4:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_RGBA4, data->width, data->height,
0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data->data);
break;
case TXP_DXT1:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_DXT1a:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_DXT3:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_DXT5:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_ATI1:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RED_RGTC1_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_ATI2:
glCompressedTexImage2D(GL_TEXTURE_2D, mipmap, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
data->width, data->height, 0, data->size, data->data);
break;
case TXP_L8:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_LUMINANCE8, data->width, data->height,
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data->data);
break;
case TXP_L8A8:
glTexImage2D(GL_TEXTURE_2D, mipmap, GL_LUMINANCE8_ALPHA8, data->width, data->height,
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, data->data);
break;
}
void FASTCALL glitter_texture_unload(glitter_effect_group* a1) {
texture_txp_unload(&a1->resources);
}
+4 -2
View File
@@ -7,7 +7,9 @@
#include "glitter.h"
extern bool FASTCALL glitter_texture_hashes_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_texture_hashes_pack_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_texture_hashes_unpack_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_texture_resource_pack_file(glitter_effect_group* a1, f2_struct* st, bool use_big_endian);
extern bool FASTCALL glitter_texture_resource_pack_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_texture_resource_unpack_file(glitter_effect_group* a1, f2_struct* st);
extern bool FASTCALL glitter_texture_load(glitter_effect_group* a1);
extern void FASTCALL glitter_texture_unload(glitter_effect_group* a1);
+11
View File
@@ -0,0 +1,11 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
extern bool FASTCALL glitter_x_curve_get_value(GPM, glitter_curve* c,
float_t frame, float_t* value, int32_t random_value, glitter_random* random);
+198
View File
@@ -0,0 +1,198 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "curve_x.h"
#include "../Glitter/random.h"
static void FASTCALL glitter_x_curve_get_key_indexes(vector_glitter_curve_key* keys,
float_t frame, size_t* curr, size_t* next);
static float_t FASTCALL glitter_x_curve_interpolate(GPM, glitter_curve* c, float_t frame,
glitter_curve_key* curr, glitter_curve_key* next, glitter_key_type key_type, glitter_random* random);
static float_t FASTCALL glitter_x_curve_randomize(GPM,
glitter_curve* c, float_t value, glitter_random* random);
static float_t FASTCALL glitter_x_curve_randomize_key(GPM,
glitter_curve* c, glitter_curve_key* key, glitter_random* random);
bool FASTCALL glitter_x_curve_get_value(GPM, glitter_curve* c,
float_t frame, float_t* value, int32_t random_value, glitter_random* random) {
size_t keys_count;
int32_t random_val;
bool negate;
float_t _value;
keys_count = c->keys.end - c->keys.begin;
if (!keys_count)
return false;
random_val = glitter_random_get_value(random);
glitter_random_set_value(random, random_value);
negate = c->flags & GLITTER_CURVE_NEGATE
&& glitter_random_get_int_min_max(GPM_VAL, random, 0, 0xFFFF) > 0x7FFF;
if (c->flags & GLITTER_CURVE_STEP)
glitter_random_set_value(random, random_val + 1);
if (keys_count == 1) {
glitter_curve_key* curr_key = &c->keys.begin[keys_count - 1];
_value = glitter_x_curve_randomize_key(GPM_VAL, c, curr_key, random);
goto End;
}
float_t start_time = (float_t)c->start_time;
float_t end_time = (float_t)c->end_time;
if (c->repeat && (start_time > frame || frame >= end_time)) {
float_t t = (frame - start_time) / (end_time - start_time);
t = t <= 0.0f ? (float_t)(int32_t)t - 1.0f : (float_t)(int32_t)t;
frame -= t * (end_time - start_time);
}
if (end_time <= frame) {
glitter_curve_key* key = &c->keys.begin[keys_count - 1];
_value = glitter_x_curve_randomize_key(GPM_VAL, c, key, random);
}
else if (start_time > frame) {
glitter_curve_key* key = &c->keys.begin[0];
_value = glitter_x_curve_randomize_key(GPM_VAL, c, key, random);
}
else if (c->flags & GLITTER_CURVE_BAKED) {
size_t key_index;
if (frame >= end_time)
key_index = keys_count - 1;
else if (frame > start_time) {
key_index = (size_t)frame - c->start_time;
if (~c->flags & GLITTER_CURVE_BAKED_FULL)
key_index /= 2;
if (key_index >= keys_count)
key_index = keys_count - 1;
}
else
key_index = 0;
glitter_curve_key* key = &c->keys.begin[key_index];
_value = glitter_x_curve_randomize_key(GPM_VAL, c, key, random);
}
else {
size_t curr_key_index = 0;
size_t next_key_index = 0;
if (keys_count > 3)
glitter_x_curve_get_key_indexes(&c->keys, frame, &curr_key_index, &next_key_index);
else if (keys_count == 3 && frame >= c->keys.begin[1].frame) {
curr_key_index = 1;
next_key_index = 2;
}
else {
curr_key_index = 0;
next_key_index = 1;
}
glitter_curve_key* curr_key = &c->keys.begin[curr_key_index];
glitter_curve_key* next_key = &c->keys.begin[next_key_index];
_value = glitter_x_curve_interpolate(GPM_VAL, c, frame, curr_key, next_key, curr_key->type, random);
}
End:
_value = glitter_x_curve_randomize(GPM_VAL, c, _value, random);
*value = negate ? -_value : _value;
glitter_random_set_value(random, random_val + 1);
return true;
}
static void FASTCALL glitter_x_curve_get_key_indexes(vector_glitter_curve_key* keys,
float_t frame, size_t* curr, size_t* next) {
size_t v4;
glitter_curve_key* v6;
size_t count;
size_t v9;
size_t v10;
count = keys->end - keys->begin;
if (count <= 1) {
*curr = 0;
*next = 0;
return;
}
v4 = 0;
v6 = keys->begin;
v9 = count - 1;
v10 = v9 / 2;
while (v4 <= v9) {
v10 = (v9 + v4) / 2;
if (frame <= v6[(v10 + 1) % count].frame) {
if (frame >= v6[v10].frame)
goto LABEL_12;
v9 = v10 - 1;
}
else
v4 = v10 + 1;
}
if (frame > v6[v10].frame) {
LABEL_12:
*curr = v10;
*next = v10 + 1;
}
else {
*curr = v10 - 1;
*next = v10;
}
*next %= count;
}
static float_t FASTCALL glitter_x_curve_interpolate(GPM, glitter_curve* c, float_t frame,
glitter_curve_key* curr, glitter_curve_key* next, glitter_key_type key_type, glitter_random* random) {
float_t next_val;
float_t curr_val;
float_t val;
if (key_type == GLITTER_KEY_CONSTANT)
return glitter_x_curve_randomize_key(GPM_VAL, c, curr, random);
float_t df = frame - (float_t)curr->frame;
float_t t = df / (float_t)(next->frame - curr->frame);
if (key_type == GLITTER_KEY_HERMITE) {
float_t t_1 = t - 1.0f;
next_val = glitter_x_curve_randomize_key(GPM_VAL, c, next, random);
curr_val = glitter_x_curve_randomize_key(GPM_VAL, c, curr, random);
val = glitter_x_curve_randomize_key(GPM_VAL, c, curr, random);
val += t * t * (3.0f - 2.0f * t) * (next_val - curr_val)
+ (t_1 * curr->tangent2 + t * next->tangent1) * df * t_1;
}
else {
curr_val = glitter_x_curve_randomize_key(GPM_VAL, c, curr, random);
next_val = glitter_x_curve_randomize_key(GPM_VAL, c, next, random);
val = curr_val + (next_val - curr_val) * t;
}
return val;
}
static float_t FASTCALL glitter_x_curve_randomize(GPM,
glitter_curve* c, float_t value, glitter_random* random) {
float_t rand;
if (~c->flags & GLITTER_CURVE_RANDOM_RANGE)
return value;
rand = glitter_random_get_float_min_max(GPM_VAL, random,
c->flags & GLITTER_CURVE_RANDOM_RANGE_NEGATE ? -c->random_range : 0.0f, c->random_range);
if (c->flags & GLITTER_CURVE_RANDOM_RANGE_MULT)
rand *= value * 0.01f;
return rand + value;
}
static float_t FASTCALL glitter_x_curve_randomize_key(GPM,
glitter_curve* c, glitter_curve_key* key, glitter_random* random) {
float_t rand;
if (~c->flags & GLITTER_CURVE_KEY_RANDOM_RANGE)
return key->value;
rand = glitter_random_get_float_min_max(GPM_VAL, random,
c->flags & GLITTER_CURVE_RANDOM_RANGE_NEGATE ? -key->random_range : 0.0f, key->random_range);
if (c->flags & GLITTER_CURVE_RANDOM_RANGE_MULT)
rand *= key->value * 0.01f;
return rand + key->value;
}
+56
View File
@@ -0,0 +1,56 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "effect_inst_x.h"
#include "../Glitter/counter.h"
#include "../Glitter/random.h"
#include "curve_x.h"
#include "emitter_inst_x.h"
#include "render_group_x.h"
static int32_t FASTCALL glitter_x_effect_inst_get_ext_anim_bone_index(int32_t index);
static int32_t FASTCALL glitter_x_effect_inst_get_ext_anim_bone_index(int32_t index) {
switch (index) {
case 0:
return 15;
case 1:
return 54;
case 2:
return 0;
case 3:
return 7;
case 4:
return 98;
case 5:
return 100;
case 6:
return 101;
case 7:
return 115;
case 8:
return 132;
case 9:
return 136;
case 10:
return 137;
case 11:
return 151;
case 12:
return 186;
case 13:
return 176;
case 14:
return 175;
case 15:
return 189;
case 16:
return 183;
case 17:
return 182;
default:
return 193;
}
}
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
+12
View File
@@ -0,0 +1,12 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "emitter_inst_x.h"
#include "../Glitter/random.h"
#include "curve_x.h"
#include "particle_inst_x.h"
#include "../camera.h"
extern camera* cam;
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
+64
View File
@@ -0,0 +1,64 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "locus_history_x.h"
glitter_locus_history* FASTCALL glitter_x_locus_history_init(size_t size) {
glitter_locus_history* lh = force_malloc(sizeof(glitter_locus_history));
vector_glitter_locus_history_data_append(&lh->data, size);
return lh;
}
void FASTCALL glitter_x_locus_history_append(GPM, glitter_locus_history* a1,
glitter_render_element* a2, glitter_particle_inst* a3) {
glitter_locus_history_data* data;
glitter_locus_history_data locus_history;
glitter_emitter_inst* emitter;
ssize_t size;
ssize_t i;
vec3 temp;
vec3 temp1;
data = a1->data.begin;
size = a1->data.end - a1->data.begin;
temp = a2->translation;
if (a3->data.data.flags & GLITTER_PARTICLE_EMITTER_LOCAL && (emitter = a3->data.emitter)) {
vec3 emit_trans;
mat4_get_translation(&emitter->mat, &emit_trans);
vec3_add(temp, emit_trans, temp);
if (glt_type == GLITTER_X && a3->data.emitter
&& a3->data.data.flags & GLITTER_PARTICLE_ROTATE_LOCUS)
mat4_mult_vec3(&a3->data.emitter->mat_no_scale, &temp, &temp);
}
locus_history.color = a2->color;
locus_history.translation = temp;
locus_history.scale = a2->scale_particle.x * a2->scale.x * a2->scale_all;
if (size < 1)
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
else if (size == 1) {
locus_history.translation = data->translation;
if (a1->data.capacity_end - a1->data.begin > 1)
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
data->translation = temp;
}
else {
temp1 = data[size - 1].translation;
for (i = size - 1; i > 0; i--)
data[i].translation = data[i - 1].translation;
if (size < a1->data.capacity_end - a1->data.begin) {
locus_history.translation = temp1;
vector_glitter_locus_history_data_push_back(&a1->data, &locus_history);
}
data->translation = temp;
}
}
void FASTCALL glitter_x_locus_history_dispose(glitter_locus_history* lh) {
vector_glitter_locus_history_data_free(&lh->data);
free(lh);
}
+13
View File
@@ -0,0 +1,13 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
extern glitter_locus_history* FASTCALL glitter_x_locus_history_init(size_t size);
extern void FASTCALL glitter_x_locus_history_append(GPM, glitter_locus_history* a1,
glitter_render_element* a2, glitter_particle_inst* a3);
extern void FASTCALL glitter_x_locus_history_dispose(glitter_locus_history* lh);
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "particle_inst_x.h"
#include "effect_inst_x.h"
#include "render_group_x.h"
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
+12
View File
@@ -0,0 +1,12 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "render_element_x.h"
#include "../Glitter/counter.h"
#include "../Glitter/random.h"
#include "curve_x.h"
#include "emitter_inst_x.h"
#include "locus_history_x.h"
#include "particle_inst_x.h"
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
+16
View File
@@ -0,0 +1,16 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "emitter_inst_x.h"
#include "../Glitter/random.h"
#include "render_group_x.h"
#include "render_element_x.h"
#include "../camera.h"
#include "../shader.h"
#include "../shared.h"
#include "../static_var.h"
extern camera* cam;
extern shader_fbo particle_shader;
+8
View File
@@ -0,0 +1,8 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../Glitter/glitter.h"
+179 -201
View File
@@ -10,28 +10,28 @@ camera* camera_init() {
return c;
}
void camera_update_focal_length(camera* c);
void camera_rebuild_projection(camera* c);
void camera_calculate_rotation(camera* c);
void camera_calculate(camera* 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, double_t fov) {
c->aspect = aspect;
c->fov = fov;
c->up = (vec3){ 0.0f, 1.0f, 0.0f };
c->position = vec3_null;
c->target = (vec3){ 0.0f, 0.0f, -1.0f };
c->view_point = (vec3){ 0.0, 0.0f, 0.0f };
c->interest = (vec3){ 0.0f, 0.0f, -1.0f };
c->view = mat4_identity;
c->projection = mat4_identity;
c->view_projection = mat4_identity;
c->inv_projection = mat4_identity;
c->inv_view = 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_calculate_rotation(c);
camera_rebuild_projection(c);
camera_calculate(c);
camera_update(c);
}
double_t camera_get_min_distance(camera* c) {
@@ -41,7 +41,7 @@ double_t camera_get_min_distance(camera* c) {
void camera_set_min_distance(camera* c, double_t value) {
if (value != c->min_distance) {
c->min_distance = value;
camera_rebuild_projection(c);
c->changed_proj = true;
}
}
@@ -52,63 +52,10 @@ double_t camera_get_max_distance(camera* c) {
void camera_set_max_distance(camera* c, double_t value) {
if (value != c->max_distance) {
c->max_distance = value;
camera_rebuild_projection(c);
c->changed_proj = true;
}
}
double_t camera_get_camera_aperture_w(camera* c) {
return c->camera_aperture_w;
}
void camera_set_camera_aperture_w(camera* c, double_t value) {
if (value != c->camera_aperture_w) {
c->camera_aperture_w = value;
camera_rebuild_projection(c);
}
}
double_t camera_get_camera_aperture_h(camera* c) {
return c->camera_aperture_h;
}
void camera_set_camera_aperture_h(camera* c, double_t value) {
if (value != c->camera_aperture_h) {
c->camera_aperture_h = value;
camera_rebuild_projection(c);
}
}
double_t camera_get_focal_length(camera* c) {
return c->focal_length;
}
void camera_set_focal_length(camera* c, double_t value) {
if (value != c->focal_length) {
c->focal_length = value;
camera_rebuild_projection(c);
}
}
bool camera_get_fov_horizontal(camera* c) {
return c->fov_horizontal;
}
void camera_set_fov_horizontal(camera* c, bool value) {
if (value != c->fov_horizontal) {
c->fov_horizontal = value;
camera_rebuild_projection(c);
}
}
void camera_update_focal_length(camera* c) {
camera_set_aspect(c, c->camera_aperture_w / c->camera_aperture_h);
if (c->camera_aperture_w == 0 || c->camera_aperture_h == 0 || c->focal_length == 0)
return;
c->fov = atan(c->camera_aperture_h * 12.7 / c->focal_length);
camera_set_fov(c, c->fov * 180.0 / M_PI * 2.0);
}
double_t camera_get_aspect(camera* c) {
return c->aspect;
}
@@ -116,7 +63,7 @@ double_t camera_get_aspect(camera* c) {
void camera_set_aspect(camera* c, double_t value) {
if (value != c->aspect) {
c->aspect = value;
camera_rebuild_projection(c);
c->changed_proj = true;
}
}
@@ -128,46 +75,24 @@ void camera_set_fov(camera* c, double_t value) {
value = clamp(value, 1.0, 180.0);
if (value != c->fov) {
c->fov = value;
camera_rebuild_projection(c);
c->changed_proj = true;
}
}
void camera_rebuild_projection(camera* c) {
double_t fov = c->fov;
if (c->fov_horizontal)
fov = 2.0 * atan(1.0 / c->aspect * tan(fov * 0.5));
fov = fov * M_PI / 180.0;
double_t max_y = c->min_distance * tan(fov * 0.5);
double_t min_y = -max_y;
double_t max_x = max_y * c->aspect;
double_t min_x = min_y * c->aspect;
double_t x = max_x - min_x;
double_t y = max_y - min_y;
double_t a = (max_x + min_x) / x;
double_t b = (max_y + min_y) / y;
double_t e = c->max_distance - c->min_distance;
double_t d = -(2.0f * c->max_distance * c->min_distance) / e;
x = 2.0f * c->min_distance / x;
y = 2.0f * c->min_distance / y;
e = -(c->max_distance + c->min_distance) / e;
c->projection.row0 = (vec4){ (float_t)x, 0.0f, 0.0f, 0.0f };
c->projection.row1 = (vec4){ 0.0f, (float_t)y, 0.0f, 0.0f };
c->projection.row2 = (vec4){ (float_t)a, (float_t)b, (float_t)e, -1.0f };
c->projection.row3 = (vec4){ 0.0f, 0.0f, (float_t)d, 0.0f };
mat4_mult(&c->view, &c->projection, &c->view_projection);
}
double_t camera_get_pitch(camera* c) {
return c->pitch;
}
void camera_set_pitch(camera* c, double_t value) {
c->pitch = clamp(value, -89.5, 89.5);
while (value > 180.0)
value -= 360.0;
while (value < -180.0)
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) {
@@ -179,11 +104,15 @@ void camera_set_yaw(camera* c, double_t value) {
value -= 360.0;
while (value < -180.0)
value += 360.0;
c->yaw = value - 90.0;
value -= 90.0;
if (c->yaw != value) {
c->yaw = value;
c->changed_view = true;
}
}
double_t camera_get_roll(camera* c) {
return c->roll;
return -c->roll;
}
void camera_set_roll(camera* c, double_t value) {
@@ -191,132 +120,181 @@ void camera_set_roll(camera* c, double_t value) {
value -= 360.0;
while (value < -180.0)
value += 360.0;
c->roll = value;
value = -value;
if (c->roll != value) {
c->roll = value;
c->changed_view = true;
}
}
void camera_get_view_point(camera* c, vec3* value) {
}
void camera_set_view_point(camera* c, 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_point(camera* c, vec3* value) {
*value = c->interest;
}
void camera_set_interest_point(camera* c, 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_reset(camera* c) {
camera_set_pitch(c, 0.0);
camera_set_yaw(c, 0.0);
camera_set_roll(c, 0.0);
c->position = vec3_null;
camera_calculate_rotation(c);
camera_calculate(c);
camera_calculate_forward(c);
camera_set_position(c, &(vec3){ 0.0, 0.0f, 0.0f});
camera_update(c);
}
void camera_set_point(camera* c, vec3* view_point, vec3* interest_point,
vec3* trans, vec3* rot, vec3* scale, double_t roll, double_t fov) {
if (fov > 0.0)
camera_set_fov(c, fov);
while (roll > 180.0)
roll -= 360.0;
while (roll < -180.0)
roll += 360.0;
c->position = *view_point;
c->target = *interest_point;
c->up.x = (float_t)sin(-c->roll * 180.0 / M_PI);
c->up.y = (float_t)cos(c->roll * 180.0 / M_PI);
c->up.z = 0;
mat4 trans_rot = mat4_identity;
mat4_rotate_x_mult(&trans_rot, (float_t)rot->x, &trans_rot);
mat4_rotate_y_mult(&trans_rot, (float_t)rot->y, &trans_rot);
mat4_rotate_z_mult(&trans_rot, (float_t)rot->z, &trans_rot);
trans_rot.row3 = (vec4){ trans->x, trans->y, trans->z, 1.0f };
/*
mat4* cam = mat4::CreateScale(scale) * transRot;
c->position = new vec3(new Vector4(c->position, 1) * cam);
c->target = new vec3(new Vector4(c->target, 1) * cam);
vec3 tempVar(new Vector4(c->up, 1) * cam);
c->up = (&tempVar)->NormalizeAlt();*/
camera_set(c, &c->position, &c->target, &c->up);
}
void camera_set(camera* c, vec3* eye, vec3* target, vec3* up) {
camera_look_at(c, eye, target, up, &c->view);
mat4_mult(&c->view, &c->projection, &c->view_projection);
}
void camera_rotate_vec2(camera* c, vec2* rotate) {
if (rotate->x != 0 || rotate->y != 0) {
camera_set_yaw(c, camera_get_yaw(c) + rotate->x);
camera_set_pitch(c, camera_get_pitch(c) + rotate->y);
camera_calculate_rotation(c);
camera_calculate(c);
}
}
void camera_move_vec2(camera* c, vec2* move) {
if (move->x != 0 || move->y != 0) {
void camera_move(camera* c, vec2d* move) {
if (move->x != 0.0 || move->y != 0.0) {
vec3 temp;
vec3_cross(c->forward, c->up, temp);
vec3 view_point;
vec3 interest;
vec3_cross(c->forward, ((vec3) { 0.0f, 1.0f, 0.0f}), temp);
vec3_normalize(temp, temp);
vec3_mult_scalar(temp, move->y, temp);
vec3_add(c->position, temp, c->position);
vec3_mult_scalar(c->forward, move->x, temp);
vec3_add(c->position, temp, c->position);
camera_calculate(c);
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_point(c, &interest);
}
}
void camera_move_vec3(camera* c, vec3* move) {
if (move->x != 0 || move->y != 0 || move->z != 0) {
c->position = *move;
camera_calculate(c);
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_point(c, &interest);
}
}
void camera_calculate_rotation(camera* c) {
c->right.x = 0;
c->right.y = (float_t)cos(c->pitch * M_PI / 180.0);
c->right.z = (float_t)sin(c->pitch * M_PI / 180.0);
c->forward.x = (float_t)(cos(c->pitch * M_PI / 180.0) * cos(c->yaw * M_PI / 180.0));
c->forward.y = (float_t)sin(c->pitch * M_PI / 180.0);
c->forward.z = (float_t)(cos(c->pitch * M_PI / 180.0) * sin(c->yaw * M_PI / 180.0));
//c->up.x = (float_t)sin(c->roll * M_PI / 180.0);
//c->up.y = (float_t)cos(c->roll * M_PI / 180.0);
//c->up.z = 0;
void camera_roll(camera* c, double_t roll) {
if (roll != 0.0f)
camera_set_roll(c, camera_get_roll(c) + roll);
}
void camera_calculate(camera* c) {
vec3_add(c->position, c->forward, c->target);
camera_look_at(c, &c->position, &c->target, &c->up, &c->view);
mat4_mult(&c->view, &c->projection, &c->view_projection);
void camera_set(camera* c, vec3* view_point, vec3* interest,
vec3* trans, vec3* rot, 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;
while (_roll > 180.0)
_roll -= 360.0;
while (_roll < -180.0)
_roll += 360.0;
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_point(c, &_int);
camera_set_roll(c, _roll);
camera_set_fov(c, _fov);
}
void camera_look_at(camera* c, vec3* eye, vec3* target, vec3* up, mat4* view) {
vec3 x, y, z;
float_t t;
vec3 xyz;
void camera_set_position(camera* c, vec3* pos) {
vec3 interest;
vec3_add(*pos, c->forward, interest);
camera_set_view_point(c, pos);
camera_set_interest_point(c, &interest);
}
vec3_sub(*eye, *target, z);
vec3_normalize(z, z);
void camera_update(camera* c) {
if (c->changed_proj)
camera_calculate_projection(c);
vec3_cross(*up, z, x);
vec3_normalize(x, x);
vec3_length(x, t);
if (t == 0.0f)
x = (vec3){ 1.0f, 0.0f, 0.0f };
vec3_cross(z, x, y);
vec3_normalize(y, y);
if (c->changed_view)
camera_calculate_view(c);
vec3_dot(x, *eye, xyz.x);
vec3_dot(y, *eye, xyz.y);
vec3_dot(z, *eye, xyz.z);
view->row0 = (vec4){ x.x, y.x, z.x, 0.0f };
view->row1 = (vec4){ x.y, y.y, z.y, 0.0f };
view->row2 = (vec4){ x.z, y.z, z.z, 0.0f };
*(vec3*)&view->row3 = xyz;
view->row3.w = -1.0f;
vec4_negate(view->row3, view->row3);
c->rotation.x = asinf(view->row1.z);
c->rotation.y = atan2f(-view->row0.z, view->row2.z);
c->rotation.z = atan2f(-view->row1.x, view->row1.y);
vec3_negate(c->rotation, c->rotation);
if (c->changed_proj || c->changed_view) {
mat4_mult(&c->view, &c->projection, &c->view_projection);
c->changed_proj = false;
c->changed_view = false;
c->updated = true;
}
else
c->updated = 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) * cos(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) * sin(c->yaw * DEG_TO_RAD));
}
static void camera_calculate_projection(camera* c) {
double_t tan_fov = tan(c->fov * 0.5);
double_t max_d = c->max_distance;
double_t min_d = c->min_distance;
double_t x = 1.0 / (c->aspect * tan_fov);
double_t y = 1.0 / tan_fov;
double_t d = -(2.0 * max_d * min_d) / (max_d - min_d);
double_t e = -(max_d + min_d) / (max_d - min_d);
c->projection.row0 = (vec4){ (float_t)x, 0.0f, 0.0f, 0.0f };
c->projection.row1 = (vec4){ 0.0f, (float_t)y, 0.0f, 0.0f };
c->projection.row2 = (vec4){ 0.0f, 0.0f, (float_t)e, -1.0f };
c->projection.row3 = (vec4){ 0.0f, 0.0f, (float_t)d, 0.0f };
mat4_inverse(&c->projection, &c->inv_projection);
}
static void camera_calculate_view(camera* c) {
vec3 dist;
vec3_sub(c->view_point, c->interest, dist);
c->rotation.x = atan2f(-dist.y, sqrtf(dist.x * dist.x + dist.z * dist.z));
c->rotation.y = atan2f(dist.x, dist.z);
c->rotation.z = (float_t)(c->roll * DEG_TO_RAD);
c->view = mat4_identity;
mat4_rot_z(&c->view, -c->rotation.z, &c->view);
mat4_rot_x(&c->view, -c->rotation.x, &c->view);
mat4_rot_y(&c->view, -c->rotation.y, &c->view);
mat4_translate_mult(&c->view, -c->view_point.x, -c->view_point.y, -c->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);
}
+19 -22
View File
@@ -13,23 +13,24 @@ typedef struct camera {
mat4 view;
mat4 projection;
mat4 view_projection;
vec3 position;
vec3 target;
vec3 up;
vec3 right;
mat4 inv_projection;
mat4 inv_view;
mat3 view_mat3;
mat3 inv_view_mat3;
vec3 forward;
vec3 rotation;
vec3 view_point;
vec3 interest;
double_t yaw;
double_t pitch;
double_t roll;
double_t camera_aperture_w;
double_t camera_aperture_h;
double_t aspect;
double_t focal_length;
double_t fov;
bool fov_horizontal;
double_t max_distance;
double_t min_distance;
bool changed_proj;
bool changed_view;
bool updated;
} camera;
extern camera* camera_init();
@@ -38,14 +39,6 @@ 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_camera_aperture_w(camera* c);
extern void camera_set_camera_aperture_w(camera* c, double_t value);
extern double_t camera_get_camera_aperture_h(camera* c);
extern void camera_set_camera_aperture_h(camera* c, double_t value);
extern double_t camera_get_focal_length(camera* c);
extern void camera_set_focal_length(camera* c, double_t value);
extern bool camera_get_fov_horizontal(camera* c);
extern void camera_set_fov_horizontal(camera* c, bool 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);
@@ -56,12 +49,16 @@ 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, vec3* value);
extern void camera_get_interest_point(camera* c, vec3* value);
extern void camera_set_interest_point(camera* c, vec3* value);
extern void camera_reset(camera* c);
extern void camera_set_point(camera* c, vec3* view_point, vec3* interest_point,
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, vec3* view_point, vec3* interest,
vec3* trans, vec3* rot, vec3* scale, double_t roll, double_t fov);
extern void camera_set(camera* c, vec3* eye, vec3* target, vec3* up);
extern void camera_rotate_vec2(camera* c, vec2* rotate);
extern void camera_move_vec2(camera* c, vec2* move);
extern void camera_move_vec3(camera* c, vec3* move);
extern void camera_look_at(camera* c, vec3* eye, vec3* target, vec3* up, mat4* view);
extern void camera_set_position(camera* c, vec3* pos);
extern void camera_update(camera* c);
extern void camera_dispose(camera* c);
+108
View File
@@ -0,0 +1,108 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "dof.h"
static const dof_debug dof_debug_default = {
.flags = 0,
.distance_to_focus = 10.0f,
.focal_length = 40.0f,
.f_number = 1.4f,
.f2 = {
.distance_to_focus = 10.0f,
.focus_range = 1.0f,
.fuzzing_range = 0.5f,
.ratio = 1.0f,
},
};
static const dof_pv dof_pv_default = {
.enable = false,
.f2 = {
.distance_to_focus = 10.0f,
.focus_range = 1.0f,
.fuzzing_range = 0.5f,
.ratio = 1.0f,
},
};
static void dof_calculate(dof_struct* d, size_t height, double_t min_dist, double_t max_dist, double_t fov,
float_t dist, float_t focal_length, float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio);
dof_struct* dof_init() {
dof_struct* d = force_malloc(sizeof(dof_struct));
return d;
}
void dof_initialize(dof_struct* d, dof_debug* debug, dof_pv* pv) {
if (debug)
d->debug = *debug;
else
d->debug = dof_debug_default;
if (pv)
d->pv = *pv;
else
d->pv = dof_pv_default;
}
void dof_get_dof_debug(dof_struct* d, dof_debug* debug) {
if (debug)
*debug = d->debug;
}
void dof_set_dof_debug(dof_struct* d, dof_debug* debug) {
if (debug)
d->debug = *debug;
else
d->debug = dof_debug_default;
}
void dof_get_dof_pv(dof_struct* d, dof_pv* pv) {
if (pv)
*pv = d->pv;
}
void dof_set_dof_pv(dof_struct* d, dof_pv* pv) {
if (pv)
d->pv = *pv;
else
d->pv = dof_pv_default;
}
void dof_calculate_physical(dof_struct* d, size_t height,
double_t min_dist, double_t max_dist, double_t fov, float_t dist,
float_t focal_length, float_t f_number) {
dof_calculate(d, height, min_dist, max_dist, fov, dist, focal_length, f_number, 0.0f, 1.0f, 0.0f);
}
void dof_calculate_f2(dof_struct* d, size_t height,
double_t min_dist, double_t max_dist, double_t fov, float_t dist,
float_t focus_range, float_t fuzzing_range, float_t ratio) {
dof_calculate(d, height, min_dist, max_dist, fov, dist, 0.0f, 1.0f, focus_range, fuzzing_range, ratio);
}
void dof_dispose(dof_struct* d) {
free(d);
}
static void dof_calculate(dof_struct* d, size_t height, double_t min_dist, double_t max_dist, double_t fov,
float_t dist, float_t focal_length, float_t f_number, float_t focus_range, float_t fuzzing_range, float_t ratio) {
double_t fl = (double_t)focal_length;
if (dist <= focal_length)
fl = (double_t)dist + 0.1;
fl = fl * fl * (1.0 / ((dist - fl) * f_number));
d->data[0] = (float_t)((min_dist - max_dist) / (min_dist * max_dist));
d->data[1] = (float_t)(1.0 / min_dist);
d->data[2] = -(float_t)(((fl * dist) * (min_dist - max_dist)) * (1.0 / (min_dist * max_dist)));
d->data[3] = (float_t)((1.0 - dist * (1.0 / min_dist)) * fl);
d->data[4] = (float_t)((double_t)height / (tan(fov * 0.5) * 2.0 * min_dist));
d->data[5] = d->data[4] * (float_t)(1.0 / 3.0);
d->data[6] = (float_t)(1.0 / 3.0);
d->data[7] = 3.0;
d->data[8] = dist;
d->data[9] = focus_range;
d->data[10] = -4.5f / (fuzzing_range * fuzzing_range);
d->data[11] = ratio * 8.0f;
}
+53
View File
@@ -0,0 +1,53 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/vec.h"
typedef enum dof_debug_flags {
DOF_DEBUG_USE_UI_PARAMS = 0x1,
DOF_DEBUG_ENABLE_DOF = 0x2,
DOF_DEBUG_ENABLE_PHYS_DOF = 0x4,
DOF_DEBUG_AUTO_FOCUS = 0x8,
} dof_debug_flags;
typedef struct dof_f2 {
float_t distance_to_focus;
float_t focus_range;
float_t fuzzing_range;
float_t ratio;
} dof_f2;
typedef struct dof_debug {
dof_debug_flags flags;
float_t distance_to_focus;
float_t focal_length;
float_t f_number;
dof_f2 f2;
} dof_debug;
typedef struct dof_pv {
bool enable;
dof_f2 f2;
} dof_pv;
typedef struct dof_struct {
dof_debug debug;
dof_pv pv;
float_t data[12];
} dof_struct;
extern dof_struct* dof_init();
extern void dof_initialize(dof_struct* d, dof_debug* debug, dof_pv* pv);
extern void dof_calculate_physical(dof_struct* d, size_t height,
double_t min_dist, double_t max_dist, double_t fov, float_t dist,
float_t focal_length, float_t f_number);
extern void dof_calculate_f2(dof_struct* d, size_t height,
double_t min_dist, double_t max_dist, double_t fov, float_t dist,
float_t focus_range, float_t fuzzing_range, float_t ratio);
extern void dof_dispose(dof_struct* d);
+25 -37
View File
@@ -53,19 +53,19 @@ static void fbo_dof_bind_fbo(fbo_dof* dfbo, vec2i* res) {
dfbo->res_20.x = res->x > 20 ? res->x / 20 : 1;
dfbo->res_20.y = res->y > 20 ? res->y / 20 : 1;
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[0]);
bind_framebuffer(dfbo->fbo[0]);
glDrawBuffers(1, fbo_dof_s_attachments);
fbo_helper_gen_texture_image_ms(dfbo->tcb[0], dfbo->res_20.x, dfbo->res_20.y,
1, GL_RG16F, GL_RG, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[1]);
bind_framebuffer(dfbo->fbo[1]);
glDrawBuffers(1, fbo_dof_s_attachments);
fbo_helper_gen_texture_image_ms(dfbo->tcb[1], dfbo->res_20.x, dfbo->res_20.y,
1, GL_RG16F, GL_RG, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[2]);
bind_framebuffer(dfbo->fbo[2]);
glDrawBuffers(2, fbo_dof_d_attachments);
fbo_helper_gen_texture_image_ms(dfbo->tcb[2], dfbo->res_2.x, dfbo->res_2.y,
1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
@@ -73,17 +73,18 @@ static void fbo_dof_bind_fbo(fbo_dof* dfbo, vec2i* res) {
1, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[3]);
bind_framebuffer(dfbo->fbo[3]);
glDrawBuffers(2, fbo_dof_d_attachments);
fbo_helper_gen_texture_image_ms(dfbo->tcb[4], dfbo->res_2.x, dfbo->res_2.y,
1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(dfbo->tcb[5], dfbo->res_2.x, dfbo->res_2.y,
1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
bind_framebuffer(0);
}
void fbo_dof_draw(fbo_dof* dfbo, int32_t color_tcb, int32_t depth_tcb, int32_t out_fbo, bool dof_f2) {
void fbo_dof_draw(fbo_dof* dfbo, int32_t color_tcb, int32_t depth_tcb,
int32_t out_fbo, bool dof_f2) {
if (!dfbo)
return;
@@ -93,52 +94,39 @@ void fbo_dof_draw(fbo_dof* dfbo, int32_t color_tcb, int32_t depth_tcb, int32_t o
glBindBufferBase(GL_UNIFORM_BUFFER, 2, dfbo->texcoords_ubo);
glViewport(0, 0, dfbo->res_20.x, dfbo->res_20.y);
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[0]);
bind_framebuffer(dfbo->fbo[0]);
shader_fbo_use(&dfbo->d_shader[o]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depth_tcb);
bind_index_tex2d(0, depth_tcb);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[1]);
bind_framebuffer(dfbo->fbo[1]);
shader_fbo_use(&dfbo->d_shader[o + 1]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[0]);
bind_index_tex2d(0, dfbo->tcb[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, dfbo->res_2.x, dfbo->res_2.y);
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[2]);
bind_framebuffer(dfbo->fbo[2]);
shader_fbo_use(&dfbo->d_shader[o + 2]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depth_tcb);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, color_tcb);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[1]);
bind_index_tex2d(0, depth_tcb);
bind_index_tex2d(1, color_tcb);
bind_index_tex2d(2, dfbo->tcb[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindFramebuffer(GL_FRAMEBUFFER, dfbo->fbo[3]);
bind_framebuffer(dfbo->fbo[3]);
shader_fbo_use(&dfbo->d_shader[o + 3]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[3]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[2]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[1]);
bind_index_tex2d(0, dfbo->tcb[3]);
bind_index_tex2d(1, dfbo->tcb[2]);
bind_index_tex2d(2, dfbo->tcb[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, dfbo->res.x, dfbo->res.y);
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
bind_framebuffer(out_fbo);
shader_fbo_use(&dfbo->d_shader[o + 4]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[4]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[5]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, dfbo->tcb[1]);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, color_tcb);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, depth_tcb);
bind_index_tex2d(0, dfbo->tcb[4]);
bind_index_tex2d(1, dfbo->tcb[5]);
bind_index_tex2d(2, dfbo->tcb[1]);
bind_index_tex2d(3, color_tcb);
bind_index_tex2d(4, depth_tcb);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+2 -1
View File
@@ -28,5 +28,6 @@ extern fbo_dof* fbo_dof_init();
extern void fbo_dof_initialize(fbo_dof* dfbo, vec2i* res, int32_t vao,
shader_fbo* d_shader, int32_t dof_common_ubo, int32_t texcoords_ubo);
extern void fbo_dof_resize(fbo_dof* dfbo, vec2i* res);
extern void fbo_dof_draw(fbo_dof* dfbo, int32_t color_tcb, int32_t depth_tcb, int32_t out_fbo, bool f2);
extern void fbo_dof_draw(fbo_dof* dfbo, int32_t color_tcb, int32_t depth_tcb,
int32_t out_fbo, bool dof_f2);
extern void fbo_dof_dispose(fbo_dof* dfbo);
+11 -12
View File
@@ -8,7 +8,7 @@
const GLenum fbo_hdr_c_attachments[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_DEPTH_ATTACHMENT,
};
const GLenum fbo_hdr_f_attachments[] = {
@@ -49,17 +49,18 @@ static void fbo_hdr_bind_fbo(fbo_hdr* hfbo, vec2i* res, vec2i* res_2d) {
hfbo->res_2d.x = res_2d->x > 1 ? res_2d->x : 1;
hfbo->res_2d.y = res_2d->y > 1 ? res_2d->y : 1;
glBindFramebuffer(GL_FRAMEBUFFER, hfbo->fbo[0]);
bind_framebuffer(hfbo->fbo[0]);
fbo_helper_gen_texture_image_ms(hfbo->tcb[0], hfbo->res.x, hfbo->res.y, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(hfbo->tcb[1], hfbo->res.x, hfbo->res.y, 1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_gen_texture_image_ms(hfbo->tcb[1], hfbo->res.x, hfbo->res.y, 1,
GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 16);
glDrawBuffers(2, fbo_hdr_c_attachments);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, hfbo->fbo[1]);
bind_framebuffer(hfbo->fbo[1]);
fbo_helper_gen_texture_image_ms(hfbo->tcb[2], hfbo->res_2d.x, hfbo->res_2d.y, 1, GL_RGBA8, GL_RGBA, GL_BYTE, 0);
glDrawBuffers(1, fbo_hdr_f_attachments);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
bind_framebuffer(0);
}
void fbo_hdr_draw_aa(fbo_hdr* hfbo) {
@@ -67,11 +68,10 @@ void fbo_hdr_draw_aa(fbo_hdr* hfbo) {
return;
glViewport(0, 0, hfbo->res_2d.x, hfbo->res_2d.y);
glBindFramebuffer(GL_FRAMEBUFFER, hfbo->fbo[1]);
bind_framebuffer(hfbo->fbo[1]);
shader_fbo_use(&hfbo->h_shader[hfbo->fxaa ? 1 : 0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, hfbo->tcb[0]);
glBindVertexArray(hfbo->vao);
bind_index_tex2d(0, hfbo->tcb[0]);
bind_vertex_array(hfbo->vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
@@ -80,9 +80,8 @@ void fbo_hdr_draw(fbo_hdr* hfbo) {
return;
shader_fbo_use(&hfbo->f_shader);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, hfbo->tcb[2]);
glBindVertexArray(hfbo->vao);
bind_index_tex2d(0, hfbo->tcb[2]);
bind_vertex_array(hfbo->vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+6 -13
View File
@@ -8,7 +8,7 @@
void fbo_helper_gen_texture_image_ms(int32_t tcb, int32_t width, int32_t height, int32_t samples,
GLenum internal_format, GLenum format, GLenum type, int32_t attachment) {
if (samples > 1) {
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tcb);
bind_tex2dms(tcb);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, samples, internal_format, width, height, true);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -18,7 +18,7 @@ void fbo_helper_gen_texture_image_ms(int32_t tcb, int32_t width, int32_t height,
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else {
glBindTexture(GL_TEXTURE_2D, tcb);
bind_tex2d(tcb);
glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -28,17 +28,10 @@ void fbo_helper_gen_texture_image_ms(int32_t tcb, int32_t width, int32_t height,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachment, tcb, 0);
}
void fbo_helper_gen_renderbuffer(int32_t rbo, int32_t width, int32_t height, int32_t samples, GLenum internal_format) {
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
if (samples > 1)
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, internal_format, width, height);
else
glRenderbufferStorage(GL_RENDERBUFFER, internal_format, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
if (attachment >= 0 && attachment <= 15)
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachment, tcb, 0);
else if (attachment == 16)
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, tcb, 0);
}
void fbo_helper_get_error_code() {
+1 -4
View File
@@ -6,11 +6,8 @@
#pragma once
#include "../KKdLib/default.h"
#define GLEW_STATIC
#include <GLEW/glew.h>
#include "static_var.h"
extern void fbo_helper_gen_texture_image_ms(int32_t tcb, int32_t width, int32_t height, int32_t samples,
GLenum internal_format, GLenum format, GLenum type, int32_t attachment);
extern void fbo_helper_gen_renderbuffer(int32_t rbo, int32_t width,
int32_t height, int32_t samples, GLenum internal_format);
extern void fbo_helper_get_error_code();
+69 -97
View File
@@ -107,67 +107,68 @@ void fbo_pp_initialize(fbo_pp* pfbo, vec2i* res, int32_t vao,
glGenFramebuffers(11, pfbo->fbo);
glGenTextures(16, pfbo->tcb);
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[0]);
bind_framebuffer(pfbo->fbo[0]);
fbo_helper_gen_texture_image_ms(pfbo->tcb[0], 256, 144, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(pfbo->tcb[1], 256, 144, 1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[1]);
bind_framebuffer(pfbo->fbo[1]);
fbo_helper_gen_texture_image_ms(pfbo->tcb[2], 128, 72, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(pfbo->tcb[3], 128, 72, 1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[2]);
bind_framebuffer(pfbo->fbo[2]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[4], 128, 72, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[3]);
bind_framebuffer(pfbo->fbo[3]);
fbo_helper_gen_texture_image_ms(pfbo->tcb[5], 64, 36, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(pfbo->tcb[6], 64, 36, 1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[4]);
bind_framebuffer(pfbo->fbo[4]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[7], 64, 36, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[5]);
bind_framebuffer(pfbo->fbo[5]);
fbo_helper_gen_texture_image_ms(pfbo->tcb[8], 32, 18, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_gen_texture_image_ms(pfbo->tcb[9], 32, 18, 1, GL_R16F, GL_RED, GL_HALF_FLOAT, 1);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[6]);
bind_framebuffer(pfbo->fbo[6]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[10], 32, 18, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[7]);
bind_framebuffer(pfbo->fbo[7]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[11], 8, 8, 1, GL_R32F, GL_RED, GL_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[8]);
bind_framebuffer(pfbo->fbo[8]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[12], 256, 144, 1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[9]);
bind_framebuffer(pfbo->fbo[9]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[13], 1, 1, 1, GL_R32F, GL_RED, GL_FLOAT, 0);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[10]);
bind_framebuffer(pfbo->fbo[10]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(pfbo->tcb[14], 1, 1, 1, GL_R32F, GL_RED, GL_FLOAT, 0);
fbo_helper_get_error_code();
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[15]);
bind_tex2d(pfbo->tcb[15]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, 32, 1, 0, GL_RED, GL_FLOAT, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
bind_tex2d(0);
fbo_pp_bind_fbo(pfbo, res);
}
@@ -218,27 +219,27 @@ static void fbo_pp_bind_fbo(fbo_pp* pfbo, vec2i* res) {
vec2i* res_down = pfbo->res_down;
if (!fbo_down)
fbo_down = force_malloc_s(sizeof(int32_t), i);
fbo_down = force_malloc_s(int32_t, i);
else if (pfbo->count_down < i) {
void* temp = force_malloc_s(sizeof(int32_t), i);
void* temp = force_malloc_s(int32_t, i);
memcpy(temp, fbo_down, sizeof(int32_t) * pfbo->count_down);
free(fbo_down);
fbo_down = temp;
}
if (!tcb_down)
tcb_down = force_malloc_s(sizeof(int32_t), i);
tcb_down = force_malloc_s(int32_t, i);
else if (pfbo->count_down < i) {
void* temp = force_malloc_s(sizeof(int32_t), i);
void* temp = force_malloc_s(int32_t, i);
memcpy(temp, tcb_down, sizeof(int32_t) * pfbo->count_down);
free(tcb_down);
tcb_down = temp;
}
if (!res_down)
res_down = force_malloc_s(sizeof(vec2i), i);
res_down = force_malloc_s(vec2i, i);
else if (pfbo->count_down < i) {
void* temp = force_malloc_s(sizeof(vec2i), i);
void* temp = force_malloc_s(vec2i, i);
memcpy(temp, res_down, sizeof(vec2i) * pfbo->count_down);
free(res_down);
res_down = temp;
@@ -266,14 +267,14 @@ static void fbo_pp_bind_fbo(fbo_pp* pfbo, vec2i* res) {
(float_t)r.x, (float_t)r.y, 1.0f / (float_t)r.x, 1.0f / (float_t)r.y);
for (i = 0; i < pfbo->count_down; i++) {
glBindFramebuffer(GL_FRAMEBUFFER, fbo_down[i]);
bind_framebuffer(fbo_down[i]);
glDrawBuffers(1, fbo_pp_s_attachments);
fbo_helper_gen_texture_image_ms(tcb_down[i], res_down[i].x, res_down[i].y,
1, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
fbo_helper_get_error_code();
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
bind_framebuffer(0);
pfbo->fbo_down = fbo_down;
pfbo->tcb_down = tcb_down;
@@ -286,155 +287,131 @@ void fbo_pp_draw(fbo_pp* pfbo, int32_t in_tcb, int32_t out_fbo,
if (pfbo->dst_pixel > 31)
pfbo->dst_pixel = 0;
glBindVertexArray(pfbo->vao);
bind_vertex_array(pfbo->vao);
int i = 0;
if (pfbo->count_down > 0) {
shader_fbo_use(&pfbo->b_shader[0]);
for (; i < pfbo->count_down; i++) {
glViewport(0, 0, pfbo->res_down[i].x, pfbo->res_down[i].y); // 0
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo_down[i]);
bind_framebuffer(pfbo->fbo_down[i]);
shader_fbo_set_vec4(&pfbo->b_shader[0], "res",
(float_t)pfbo->res_down[i].x, (float_t)pfbo->res_down[i].y,
1.0f / (float_t)pfbo->res_down[i].x, 1.0f / (float_t)pfbo->res_down[i].y);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, i == 0 ? in_tcb : pfbo->tcb_down[i - 1]);
bind_index_tex2d(0, i == 0 ? in_tcb : pfbo->tcb_down[i - 1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
i--;
}
glViewport(0, 0, 256, 144); // 1
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[0]);
bind_framebuffer(pfbo->fbo[0]);
glDrawBuffers(2, fbo_pp_d_attachments);
shader_fbo_use(&pfbo->b_shader[1]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->count_down > 0 ? pfbo->tcb_down[i] : in_tcb);
bind_index_tex2d(0, pfbo->count_down > 0 ? pfbo->tcb_down[i] : in_tcb);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 128, 72); // 2
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[1]);
bind_framebuffer(pfbo->fbo[1]);
glDrawBuffers(2, fbo_pp_d_attachments);
shader_fbo_use(&pfbo->b_shader[2]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[1]);
bind_index_tex2d(0, pfbo->tcb[0]);
bind_index_tex2d(1, pfbo->tcb[1]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 64, 36); // 3
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[3]);
bind_framebuffer(pfbo->fbo[3]);
glDrawBuffers(2, fbo_pp_d_attachments);
shader_fbo_use(&pfbo->b_shader[3]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[2]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[3]);
bind_index_tex2d(0, pfbo->tcb[2]);
bind_index_tex2d(1, pfbo->tcb[3]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 32, 18); // 4
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[5]);
bind_framebuffer(pfbo->fbo[5]);
glDrawBuffers(2, fbo_pp_d_attachments);
shader_fbo_use(&pfbo->b_shader[4]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[5]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[6]);
bind_index_tex2d(0, pfbo->tcb[5]);
bind_index_tex2d(1, pfbo->tcb[6]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 8, 8); // 5
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[7]);
bind_framebuffer(pfbo->fbo[7]);
shader_fbo_use(&pfbo->b_shader[5]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[9]);
bind_index_tex2d(0, pfbo->tcb[9]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 128, 72); // 6
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[2]);
bind_framebuffer(pfbo->fbo[2]);
shader_fbo_use(&pfbo->b_shader[6]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[2]);
bind_index_tex2d(0, pfbo->tcb[2]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 64, 36); // 7
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[4]);
bind_framebuffer(pfbo->fbo[4]);
shader_fbo_use(&pfbo->b_shader[7]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[5]);
bind_index_tex2d(0, pfbo->tcb[5]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 32, 18); // 8
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[6]);
bind_framebuffer(pfbo->fbo[6]);
shader_fbo_use(&pfbo->b_shader[8]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[8]);
bind_index_tex2d(0, pfbo->tcb[8]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 128, 72); // 9
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[1]);
bind_framebuffer(pfbo->fbo[1]);
glDrawBuffers(1, fbo_pp_s_attachments);
shader_fbo_use(&pfbo->b_shader[9]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[4]);
bind_index_tex2d(0, pfbo->tcb[4]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 64, 36); // 10
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[3]);
bind_framebuffer(pfbo->fbo[3]);
glDrawBuffers(1, fbo_pp_s_attachments);
shader_fbo_use(&pfbo->b_shader[10]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[7]);
bind_index_tex2d(0, pfbo->tcb[7]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 32, 18); // 11
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[5]);
bind_framebuffer(pfbo->fbo[5]);
glDrawBuffers(1, fbo_pp_s_attachments);
shader_fbo_use(&pfbo->b_shader[11]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[10]);
bind_index_tex2d(0, pfbo->tcb[10]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 256, 144); // 12
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[8]);
bind_framebuffer(pfbo->fbo[8]);
shader_fbo_use(&pfbo->b_shader[12]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[0]);
bind_index_tex2d(0, pfbo->tcb[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 256, 144); // 13
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[0]);
bind_framebuffer(pfbo->fbo[0]);
glDrawBuffers(1, fbo_pp_s_attachments);
shader_fbo_use(&pfbo->b_shader[13]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[12]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[2]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[5]);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[8]);
bind_index_tex2d(0, pfbo->tcb[12]);
bind_index_tex2d(1, pfbo->tcb[2]);
bind_index_tex2d(2, pfbo->tcb[5]);
bind_index_tex2d(3, pfbo->tcb[8]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glViewport(0, 0, 1, 1); // 14
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[9]);
bind_framebuffer(pfbo->fbo[9]);
shader_fbo_use(&pfbo->b_shader[14]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[11]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[6]);
bind_index_tex2d(0, pfbo->tcb[11]);
bind_index_tex2d(1, pfbo->tcb[6]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[9]);
bind_framebuffer(pfbo->fbo[9]);
glReadBuffer(GL_COLOR_ATTACHMENT0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[15]);
bind_index_tex2d(0, pfbo->tcb[15]);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, pfbo->dst_pixel, 0, 0, 0, 1, 1);
glViewport(0, 0, 1, 1); // 15
glBindFramebuffer(GL_FRAMEBUFFER, pfbo->fbo[10]);
bind_framebuffer(pfbo->fbo[10]);
shader_fbo_use(&pfbo->b_shader[15]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[15]);
bind_index_tex2d(0, pfbo->tcb[15]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
int32_t tone_map_shader_flags[8];
@@ -443,20 +420,15 @@ void fbo_pp_draw(fbo_pp* pfbo, int32_t in_tcb, int32_t out_fbo,
tone_map_shader_flags[3] = pfbo->scene_fade ? 1 : 0;
glBindBufferBase(GL_UNIFORM_BUFFER, 1, pfbo->tone_map_ubo);
glViewport(0, 0, pfbo->res.x, pfbo->res.y); // 16
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
bind_framebuffer(out_fbo);
glDrawBuffers(out_fbo_attachments_count, out_fbo_attachments);
shader_fbo_use(&pfbo->t_shader);
shader_fbo_set_int_array(&pfbo->t_shader, "mode", 8, tone_map_shader_flags);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, in_tcb);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[0]);
if (pfbo->tone_map_method == 0) {
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_1D, pfbo->tone_map.id);
}
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, pfbo->tcb[14]);
bind_index_tex2d(0, in_tcb);
bind_index_tex2d(1, pfbo->tcb[0]);
if (pfbo->tone_map_method == 0)
bind_index_tex1d(2, pfbo->tone_map.id);
bind_index_tex2d(3, pfbo->tcb[14]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
+32 -39
View File
@@ -5,23 +5,18 @@
#include "fbo_render.h"
#include "fbo_helper.h"
#include "shared.h"
extern int32_t sv_samples;
const GLenum fbo_render_c_attachments[] = {
GL_COLOR_ATTACHMENT4,
GL_COLOR_ATTACHMENT0,
};
const GLenum fbo_render_f_attachments[] = {
GL_COLOR_ATTACHMENT4,
GL_COLOR_ATTACHMENT3,
};
const GLenum fbo_render_g_attachments[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3,
};
static void fbo_render_bind_fbo(fbo_render* rfbo, vec2i* res);
@@ -29,7 +24,6 @@ static void fbo_render_bind_fbo(fbo_render* rfbo, vec2i* res);
fbo_render* fbo_render_init() {
fbo_render* rfbo = force_malloc(sizeof(fbo_render));
glGenFramebuffers(1, &rfbo->fbo);
glGenRenderbuffers(1, &rfbo->rbo);
glGenTextures(5, rfbo->tcb);
return rfbo;
}
@@ -57,21 +51,20 @@ static void fbo_render_bind_fbo(fbo_render* rfbo, vec2i* res) {
rfbo->res.y = res->y > 1 ? res->y : 1;
rfbo->samples = sv_samples;
glBindFramebuffer(GL_FRAMEBUFFER, rfbo->fbo);
bind_framebuffer(rfbo->fbo);
rfbo->target = rfbo->samples > 1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
fbo_helper_gen_texture_image_ms(rfbo->tcb[0], rfbo->res.x, rfbo->res.y,
rfbo->samples, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 0);
rfbo->samples, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 16);
fbo_helper_gen_texture_image_ms(rfbo->tcb[1], rfbo->res.x, rfbo->res.y,
rfbo->samples, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, 1);
rfbo->samples, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 0);
fbo_helper_gen_texture_image_ms(rfbo->tcb[2], rfbo->res.x, rfbo->res.y,
rfbo->samples, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 2);
rfbo->samples, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 1);
fbo_helper_gen_texture_image_ms(rfbo->tcb[3], rfbo->res.x, rfbo->res.y,
rfbo->samples, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, 3);
rfbo->samples, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 2);
fbo_helper_gen_texture_image_ms(rfbo->tcb[4], rfbo->res.x, rfbo->res.y,
rfbo->samples, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 4);
fbo_helper_gen_renderbuffer(rfbo->rbo, rfbo->res.x, rfbo->res.y, rfbo->samples, GL_DEPTH24_STENCIL8);
rfbo->samples, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, 3);
fbo_helper_get_error_code();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
bind_framebuffer(0);
}
void fbo_render_draw_c(fbo_render* rfbo, bool depth) {
@@ -87,49 +80,50 @@ void fbo_render_draw_c(fbo_render* rfbo, bool depth) {
shader_fbo* c_shader = rfbo->samples > 1 ? rfbo->samples > 2 ? rfbo->samples > 4 ? rfbo->samples > 8 ?
&rfbo->c_shader[9] : &rfbo->c_shader[8] : &rfbo->c_shader[7] : &rfbo->c_shader[6] : &rfbo->c_shader[5];
shader_fbo_use(c_shader);
glActiveTexture(GL_TEXTURE0);
glBindTexture(rfbo->target, rfbo->tcb[4]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(rfbo->target, rfbo->tcb[0]);
bind_index_tex2d(0, rfbo->tcb[4]);
bind_index_tex2d(1, rfbo->tcb[0]);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
glDepthMask(true);
}
else {
shader_fbo* c_shader = rfbo->samples > 1 ? rfbo->samples > 2 ? rfbo->samples > 4 ? rfbo->samples > 8 ?
&rfbo->c_shader[4] : &rfbo->c_shader[3] : &rfbo->c_shader[2] : &rfbo->c_shader[1] : &rfbo->c_shader[0];
shader_fbo_use(c_shader);
glActiveTexture(GL_TEXTURE0);
glBindTexture(rfbo->target, rfbo->tcb[4]);
bind_index_tex2d(0, rfbo->tcb[4]);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
}
glBindVertexArray(rfbo->vao);
bind_vertex_array(rfbo->vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
glDisablei(GL_BLEND, 0);
glDisable(GL_STENCIL_TEST);
}
void fbo_render_draw_g(fbo_render* rfbo, int32_t dir_lights_tcb,
int32_t dir_lights_count, int32_t point_lights_tcb, int32_t point_lights_count) {
void fbo_render_draw_g(fbo_render* rfbo,
int32_t light_dir_tcb, int32_t light_dir_count,
int32_t light_point_tcb, int32_t light_point_count) {
if (!rfbo)
return;
glBindFramebuffer(GL_FRAMEBUFFER, rfbo->fbo);
glDrawBuffers(1, fbo_render_f_attachments);
glDrawBuffers(1, fbo_render_c_attachments);
shader_fbo* g_shader = rfbo->samples > 1 ? rfbo->samples > 2 ? rfbo->samples > 4 ? rfbo->samples > 8 ?
&rfbo->g_shader[4] : &rfbo->g_shader[3] : &rfbo->g_shader[2] : &rfbo->g_shader[1] : &rfbo->g_shader[0];
shader_fbo_use(g_shader);
for (int32_t i = 0; i < 4; i++) {
glActiveTexture(GL_TEXTURE0 + i);
glBindTexture(rfbo->target, rfbo->tcb[i]);
}
shader_fbo_set_int(g_shader, "dirLightsCount", dir_lights_count);
shader_fbo_set_int(g_shader, "pointLightsCount", point_lights_count);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, dir_lights_tcb);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, point_lights_tcb);
shader_fbo_set_int(g_shader, "lightDirCount", light_dir_count);
shader_fbo_set_int(g_shader, "lightPointCount", light_point_count);
for (int32_t i = 0; i < 4; i++)
bind_index_tex2d(i, rfbo->tcb[i]);
bind_index_tex2d(4, light_dir_tcb);
bind_index_tex2d(5, light_point_tcb);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 0xFF, 0xFF);
glStencilMask(0xFF);
glBindVertexArray(rfbo->vao);
bind_vertex_array(rfbo->vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisable(GL_STENCIL_TEST);
}
@@ -139,7 +133,6 @@ void fbo_render_dispose(fbo_render* rfbo) {
return;
glDeleteFramebuffers(1, &rfbo->fbo);
glDeleteRenderbuffers(1, &rfbo->rbo);
glDeleteTextures(5, rfbo->tcb);
free(rfbo);
}
+3 -4
View File
@@ -12,7 +12,6 @@
typedef struct fbo_render {
int32_t vao;
int32_t fbo;
int32_t rbo;
int32_t tcb[5];
int32_t samples;
shader_fbo c_shader[10];
@@ -22,7 +21,6 @@ typedef struct fbo_render {
} fbo_render;
extern const GLenum fbo_render_c_attachments[];
extern const GLenum fbo_render_f_attachments[];
extern const GLenum fbo_render_g_attachments[];
extern fbo_render* fbo_render_init();
@@ -30,6 +28,7 @@ extern void fbo_render_initialize(fbo_render* rfbo, vec2i* res,
int32_t vao, shader_fbo* c_shader, shader_fbo* g_shader);
extern void fbo_render_resize(fbo_render* rfbo, vec2i* res);
extern void fbo_render_draw_c(fbo_render* rfbo, bool depth);
extern void fbo_render_draw_g(fbo_render* rfbo, int32_t dir_lights_tcb,
int32_t dir_lights_count, int32_t point_lights_tcb, int32_t point_lights_count);
extern void fbo_render_draw_g(fbo_render* rfbo,
int32_t light_dir_tcb, int32_t light_dir_count,
int32_t light_point_tcb, int32_t light_point_count);
extern void fbo_render_dispose(fbo_render* rfbo);
+198 -144
View File
@@ -4,20 +4,22 @@
*/
#include "gl_object.h"
#include "static_var.h"
extern const gl_object_cull_face gl_object_cull_face_default = {
.enable = true,
.mode = GL_BACK,
};
static void gl_object_generate_vbo(gl_object* obj);
static void gl_object_bind_vbo(gl_object* obj);
static void gl_object_generate_ivbo(gl_object* obj);
static void gl_object_bind_ivbo(gl_object* obj);
static void gl_object_generate_ebo(gl_object* obj);
static void gl_object_bind_ebo(gl_object* obj);
static void gl_object_generate_vao(gl_object* obj);
static void gl_object_draw(gl_object* obj);
gl_object* gl_object_init() {
gl_object* obj = force_malloc(sizeof(gl_object));
gl_object_generate_vbo(obj);
gl_object_generate_ivbo(obj);
gl_object_generate_ebo(obj);
gl_object_generate_vao(obj);
return obj;
@@ -26,13 +28,13 @@ gl_object* gl_object_init() {
void gl_object_update_vert(gl_object* obj, vertex* vert) {
switch (vert->type) {
case VERTEX_SIMPLE:
obj->type = obj->instances.count > 0 ? GL_OBJECT_INSTANCED_SIMPLE : GL_OBJECT_SIMPLE;
obj->type = GL_OBJECT_SIMPLE;
obj->vertex = *vert;
gl_object_bind_vbo(obj);
gl_object_bind_ebo(obj);
break;
case VERTEX_BONED:
obj->type = obj->instances.count > 0 ? GL_OBJECT_INSTANCED_BONED : GL_OBJECT_BONED;
obj->type = GL_OBJECT_BONED;
obj->vertex = *vert;
gl_object_bind_vbo(obj);
gl_object_bind_ebo(obj);
@@ -40,11 +42,11 @@ void gl_object_update_vert(gl_object* obj, vertex* vert) {
}
}
void gl_object_update_texture(gl_object* obj, texture_set* texture) {
if (texture)
obj->texture = *texture;
void gl_object_update_material(gl_object* obj, material* mat) {
if (mat)
obj->material = *mat;
else
memset(&obj->texture, 0, sizeof(texture_set));
memset(&obj->material, 0, sizeof(material));
}
void gl_object_update_shader(gl_object* obj, shader_model* shader) {
@@ -54,24 +56,15 @@ void gl_object_update_shader(gl_object* obj, shader_model* shader) {
memset(&obj->shader, 0, sizeof(shader_model));
}
void gl_object_update_instances(gl_object* obj, gl_object_instances* instances) {
if (instances->count > 0)
switch (obj->type) {
case GL_OBJECT_SIMPLE:
obj->type = GL_OBJECT_INSTANCED_SIMPLE;
break;
case GL_OBJECT_BONED:
obj->type = GL_OBJECT_INSTANCED_BONED;
break;
}
void gl_object_update_bone_mat(gl_object* obj, texture_bone_mat* bone_mat_tex) {
if (bone_mat_tex)
obj->bone_mat_tex = *bone_mat_tex;
else
memset(&obj->bone_mat_tex, 0, sizeof(texture_bone_mat));
}
switch (obj->type) {
case GL_OBJECT_INSTANCED_SIMPLE:
case GL_OBJECT_INSTANCED_BONED:
obj->instances = *instances;
gl_object_bind_ivbo(obj);
break;
}
void gl_object_update_cull_face(gl_object* obj, gl_object_cull_face cull_face) {
obj->cull_face = cull_face;
}
static void gl_object_generate_vbo(gl_object* obj) {
@@ -80,23 +73,10 @@ static void gl_object_generate_vbo(gl_object* obj) {
}
static void gl_object_bind_vbo(gl_object* obj) {
glBindBuffer(GL_ARRAY_BUFFER, obj->vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(uint32_t) * obj->vertex.vert_count, obj->vertex.vert, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
static void gl_object_generate_ivbo(gl_object* obj) {
glGenBuffers(1, &obj->instances_trans_vbo);
glGenBuffers(1, &obj->instances_data_vbo);
gl_object_bind_ivbo(obj);
}
static void gl_object_bind_ivbo(gl_object* obj) {
glBindBuffer(GL_ARRAY_BUFFER, obj->instances_trans_vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(mat4) * obj->instances.count, obj->instances.trans, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, obj->instances_data_vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(mat4) * obj->instances.count, obj->instances.data, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
bind_array_buffer(obj->vbo);
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(sizeof(vertex_data) * obj->vertex.vert_count),
(void*)obj->vertex.vert, GL_DYNAMIC_DRAW);
bind_array_buffer(0);
}
static void gl_object_generate_ebo(gl_object* obj) {
@@ -105,125 +85,203 @@ static void gl_object_generate_ebo(gl_object* obj) {
}
static void gl_object_bind_ebo(gl_object* obj) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, obj->vbo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32_t) * obj->vertex.ind_count, obj->vertex.ind, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
bind_element_array_buffer(obj->ebo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)(sizeof(uint32_t) * obj->vertex.ind_count),
obj->vertex.ind, GL_DYNAMIC_DRAW);
bind_element_array_buffer(0);
}
static void gl_object_generate_vao(gl_object* obj) {
glGenVertexArrays(1, &obj->vao);
glBindVertexArray(obj->vao);
switch (obj->type) {
case GL_OBJECT_SIMPLE:
case GL_OBJECT_INSTANCED_SIMPLE:
glBindBuffer(GL_ARRAY_BUFFER, obj->vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, obj->ebo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 40, (void*)0); // Pos
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_HALF_FLOAT, false, 40, (void*)12); // UV
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_HALF_FLOAT, false, 40, (void*)16); // UV2
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 4, GL_HALF_FLOAT, false, 40, (void*)20); // Color
glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 3, GL_HALF_FLOAT, false, 40, (void*)28); // Normal
glEnableVertexAttribArray(5);
glVertexAttribPointer(5, 3, GL_HALF_FLOAT, false, 40, (void*)34); // Tangent
break;
case GL_OBJECT_BONED:
case GL_OBJECT_INSTANCED_BONED:
glBindBuffer(GL_ARRAY_BUFFER, obj->vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, obj->ebo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, false, 56, (void*)0); // Pos
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_HALF_FLOAT, false, 56, (void*)12); // UV
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_HALF_FLOAT, false, 56, (void*)16); // UV2
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 4, GL_HALF_FLOAT, false, 56, (void*)20); // Color
glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 3, GL_HALF_FLOAT, false, 56, (void*)28); // Normal
glEnableVertexAttribArray(5);
glVertexAttribPointer(5, 3, GL_HALF_FLOAT, false, 56, (void*)34); // Tangent
glEnableVertexAttribArray(6);
glVertexAttribPointer(6, 4, GL_UNSIGNED_SHORT, false, 56, (void*)40); // Bone Index
glEnableVertexAttribArray(7);
glVertexAttribPointer(7, 4, GL_HALF_FLOAT, false, 56, (void*)48); // Bone Weight
break;
}
static const GLsizei data_size = sizeof(vertex_data);
switch (obj->type) {
case GL_OBJECT_INSTANCED_SIMPLE:
case GL_OBJECT_INSTANCED_BONED:
glBindBuffer(GL_ARRAY_BUFFER, obj->instances_trans_vbo);
glEnableVertexAttribArray(8);
glVertexAttribPointer(8, 4, GL_FLOAT, false, 64, (void*)0); // Trans[0]
glVertexAttribDivisor(8, 1);
glEnableVertexAttribArray(9);
glVertexAttribPointer(9, 4, GL_FLOAT, false, 64, (void*)16); // Trans[1]
glVertexAttribDivisor(9, 1);
glEnableVertexAttribArray(10);
glVertexAttribPointer(10, 4, GL_FLOAT, false, 64, (void*)32); // Trans[2]
glVertexAttribDivisor(10, 1);
glEnableVertexAttribArray(11);
glVertexAttribPointer(11, 4, GL_FLOAT, false, 64, (void*)48); // Trans[3]
glVertexAttribDivisor(11, 1);
glBindBuffer(GL_ARRAY_BUFFER, obj->instances_data_vbo);
glEnableVertexAttribArray(12);
glVertexAttribPointer(12, 4, GL_FLOAT, false, 64, (void*)0); // Data[0]
glVertexAttribDivisor(12, 1);
glEnableVertexAttribArray(13);
glVertexAttribPointer(13, 4, GL_FLOAT, false, 64, (void*)16); // Data[1]
glVertexAttribDivisor(13, 1);
glEnableVertexAttribArray(14);
glVertexAttribPointer(14, 4, GL_FLOAT, false, 64, (void*)32); // Data[2]
glVertexAttribDivisor(14, 1);
glEnableVertexAttribArray(15);
glVertexAttribPointer(15, 4, GL_FLOAT, false, 64, (void*)48); // Data[3]
glVertexAttribDivisor(15, 1);
break;
}
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glGenVertexArrays(1, &obj->vao);
bind_vertex_array(obj->vao);
bind_array_buffer(obj->vbo);
bind_element_array_buffer(obj->ebo);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, data_size,
(void*)offsetof(vertex_data, pos)); // Pos
glEnableVertexAttribArray(1);
glVertexAttribIPointer(1, 4, GL_UNSIGNED_INT, data_size,
(void*)offsetof(vertex_data, uv)); // UV/Color
glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 3, GL_SHORT, GL_TRUE, data_size,
(void*)offsetof(vertex_data, normal)); // Normal
glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 3, GL_SHORT, GL_TRUE, data_size,
(void*)offsetof(vertex_data, tangent)); // Tangent
glEnableVertexAttribArray(4);
glVertexAttribIPointer(4, 4, GL_UNSIGNED_SHORT, data_size,
(void*)offsetof(vertex_data, bone_index)); // Bone Index
glEnableVertexAttribArray(5);
glVertexAttribPointer(5, 4, GL_UNSIGNED_BYTE, GL_TRUE, data_size,
(void*)offsetof(vertex_data, bone_weight)); // Bone Weight
bind_vertex_array(0);
bind_array_buffer(0);
bind_element_array_buffer(0);
}
void gl_object_draw_c(gl_object* obj) {
if (obj->type == GL_OBJECT_NONE)
return;
if (obj->material.blend.enable) {
glEnablei(GL_BLEND, 0);
glBlendFuncSeparate(obj->material.blend.src_factor_rgb, obj->material.blend.dst_factor_rgb,
obj->material.blend.src_factor_alpha, obj->material.blend.dst_factor_alpha);
glBlendEquationSeparate(obj->material.blend.mode_rgb, obj->material.blend.mode_alpha);
}
else
glDisable(GL_BLEND);
if (obj->cull_face.enable) {
glEnable(GL_CULL_FACE);
glCullFace(obj->cull_face.mode);
}
else
glDisable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(true);
bool use_bones;
switch (obj->type) {
case GL_OBJECT_BONED:
use_bones = true;
break;
default:
use_bones = false;
break;
}
GLint tex_mode[8];
for (int32_t i = 0; i < 8; i++)
tex_mode[i] = obj->material.texture.tex[i].mode;
shader_model_c_use(&obj->shader);
gl_object_draw(obj);
shader_model_c_use(0);
shader_model_c_set_int_array(&obj->shader, "tex_mode", 8, tex_mode);
shader_model_c_set_bool(&obj->shader, "use_bones", use_bones);
shader_model_c_set_bool(&obj->shader, "write_only_depth", false);
texture_set_bind(&obj->material.texture);
texture_bone_mat_bind(&obj->bone_mat_tex, 8);
bind_vertex_array(obj->vao);
glDrawElements(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count, GL_UNSIGNED_INT, 0);
texture_set_reset(&obj->material.texture);
texture_bone_mat_reset(&obj->bone_mat_tex, 8);
}
void gl_object_draw_c_translucent_first_part(gl_object* obj) {
if (obj->type == GL_OBJECT_NONE)
return;
if (obj->cull_face.enable) {
glEnable(GL_CULL_FACE);
glCullFace(obj->cull_face.mode);
}
bool use_bones;
switch (obj->type) {
case GL_OBJECT_BONED:
use_bones = true;
break;
default:
use_bones = false;
break;
}
shader_model_c_use(&obj->shader);
shader_model_c_set_bool(&obj->shader, "use_bones", use_bones);
shader_model_c_set_bool(&obj->shader, "write_only_depth", true);
texture_set_reset(&obj->material.texture);
texture_bone_mat_bind(&obj->bone_mat_tex, 8);
bind_vertex_array(obj->vao);
glDrawElements(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count, GL_UNSIGNED_INT, 0);
texture_bone_mat_reset(&obj->bone_mat_tex, 8);
}
void gl_object_draw_c_translucent_second_part(gl_object* obj) {
if (obj->type == GL_OBJECT_NONE)
return;
glBlendFuncSeparate(obj->material.blend.src_factor_rgb, obj->material.blend.dst_factor_rgb,
obj->material.blend.src_factor_alpha, obj->material.blend.dst_factor_alpha);
glBlendEquationSeparate(obj->material.blend.mode_rgb, obj->material.blend.mode_alpha);
if (obj->cull_face.enable) {
glEnable(GL_CULL_FACE);
glCullFace(obj->cull_face.mode);
}
else
glDisable(GL_CULL_FACE);
bool use_bones;
switch (obj->type) {
case GL_OBJECT_BONED:
use_bones = true;
break;
default:
use_bones = false;
break;
}
GLint tex_mode[8];
for (int32_t i = 0; i < 8; i++)
tex_mode[i] = obj->material.texture.tex[i].mode;
shader_model_c_use(&obj->shader);
shader_model_c_set_int_array(&obj->shader, "tex_mode", 8, tex_mode);
shader_model_c_set_bool(&obj->shader, "use_bones", use_bones);
shader_model_c_set_bool(&obj->shader, "write_only_depth", false);
texture_set_bind(&obj->material.texture);
texture_bone_mat_bind(&obj->bone_mat_tex, 8);
bind_vertex_array(obj->vao);
glDrawElements(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count, GL_UNSIGNED_INT, 0);
texture_set_reset(&obj->material.texture);
texture_bone_mat_reset(&obj->bone_mat_tex, 8);
}
void gl_object_draw_g(gl_object* obj) {
if (obj->type == GL_OBJECT_NONE)
return;
shader_model_g_use(&obj->shader);
gl_object_draw(obj);
shader_model_c_use(0);
}
if (obj->cull_face.enable) {
glEnable(GL_CULL_FACE);
glCullFace(obj->cull_face.mode);
}
else
glDisable(GL_CULL_FACE);
static void gl_object_draw(gl_object* obj) {
texture_set_bind(&obj->texture);
glBindVertexArray(obj->vao);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthMask(true);
bool use_bones;
switch (obj->type) {
case GL_OBJECT_SIMPLE:
case GL_OBJECT_BONED:
glDrawElements(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count, GL_UNSIGNED_INT, 0);
use_bones = true;
break;
case GL_OBJECT_INSTANCED_SIMPLE:
case GL_OBJECT_INSTANCED_BONED:
glDrawElementsInstanced(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count,
GL_UNSIGNED_INT, 0, (GLsizei)obj->instances.count);
default:
use_bones = false;
break;
}
texture_set_reset(&obj->texture);
glBindVertexArray(0);
GLint tex_mode[8];
for (int32_t i = 0; i < 8; i++)
tex_mode[i] = obj->material.texture.tex[i].mode;
shader_model_g_use(&obj->shader);
shader_model_g_set_int_array(&obj->shader, "tex_mode", 8, tex_mode);
shader_model_g_set_bool(&obj->shader, "use_bones", use_bones);
texture_set_bind(&obj->material.texture);
texture_bone_mat_bind(&obj->bone_mat_tex, 8);
bind_vertex_array(obj->vao);
glDrawElements(GL_TRIANGLES, (GLsizei)obj->vertex.ind_count, GL_UNSIGNED_INT, 0);
texture_set_reset(&obj->material.texture);
texture_bone_mat_reset(&obj->bone_mat_tex, 8);
}
void gl_object_dispose(gl_object* obj) {
@@ -233,9 +291,5 @@ void gl_object_dispose(gl_object* obj) {
glDeleteBuffers(1, &obj->ebo);
if (obj->vao)
glDeleteVertexArrays(1, &obj->vao);
if (obj->instances_trans_vbo)
glDeleteBuffers(1, &obj->instances_trans_vbo);
if (obj->instances_data_vbo)
glDeleteBuffers(1, &obj->instances_data_vbo);
free(obj);
}
+23 -19
View File
@@ -7,49 +7,53 @@
#include "../KKdLib/default.h"
#include "../KKdLib/mat.h"
#include "hash.h"
#include "material.h"
#include "shader.h"
#include "texture.h"
#include "vertex.h"
typedef struct gl_object_cull_face {
bool enable;
int16_t mode;
} gl_object_cull_face;
typedef enum gl_object_type {
GL_OBJECT_NONE = 0,
GL_OBJECT_SIMPLE,
GL_OBJECT_BONED,
GL_OBJECT_INSTANCED_SIMPLE,
GL_OBJECT_INSTANCED_BONED,
} gl_object_type;
typedef struct gl_object_instances {
size_t count;
mat4* trans;
mat4* data;
} gl_object_instances;
typedef struct gl_object {
gl_object_type type;
int32_t vao;
int32_t vbo;
int32_t ebo;
texture_set texture;
shader_model shader;
vertex vertex;
int32_t instances_trans_vbo;
int32_t instances_data_vbo;
gl_object_instances instances;
material material;
shader_model shader;
texture_bone_mat bone_mat_tex;
gl_object_cull_face cull_face;
} gl_object;
typedef struct gl_object_update {
uint64_t texture;
uint64_t shader;
uint64_t vert;
gl_object_instances instances;
hash vert;
hash material;
hash shader;
hash bone_mat;
gl_object_cull_face cull_face;
} gl_object_update;
extern const gl_object_cull_face gl_object_cull_face_default;
extern gl_object* gl_object_init();
extern void gl_object_update_vert(gl_object* obj, vertex* vert);
extern void gl_object_update_texture(gl_object* obj, texture_set* texture);
extern void gl_object_update_material(gl_object* obj, material* material);
extern void gl_object_update_shader(gl_object* obj, shader_model* shader);
extern void gl_object_update_instances(gl_object* obj, gl_object_instances* instances);
extern void gl_object_update_bone_mat(gl_object* obj, texture_bone_mat* bone_mat_tex);
extern void gl_object_update_cull_face(gl_object* obj, gl_object_cull_face cull_face);
extern void gl_object_draw_c(gl_object* obj);
extern void gl_object_draw_c_translucent_first_part(gl_object* obj);
extern void gl_object_draw_c_translucent_second_part(gl_object* obj);
extern void gl_object_draw_g(gl_object* obj);
extern void gl_object_dispose(gl_object* obj);
+6 -7
View File
@@ -6,18 +6,17 @@
#include "hash.h"
#include "../KKdLib/hash.h"
uint64_t hash_char(char* data) {
inline hash hash_char(char* data) {
return hash_data(data, strlen(data));
}
uint64_t hash_wchar_t(wchar_t* data) {
inline hash hash_wchar_t(wchar_t* data) {
return hash_data(data, wcslen(data));
}
uint64_t hash_data(void* data, size_t length) {
uint64_t hash, hash1, hash2;
hash1 = hash_fnv1a64(data, length);
hash2 = hash_murmurhash(data, length, 0, false, false);
hash = hash1 | (hash2 << 32);
inline hash hash_data(void* data, size_t length) {
hash hash;
hash.f = hash_fnv1a64(data, length);
hash.m = hash_murmurhash(data, length, 0, false, false);
return hash;
}
+14 -6
View File
@@ -7,18 +7,26 @@
#include "../KKdLib/default.h"
#define hash(t) \
typedef struct hash {
uint64_t f;
uint32_t m;
} hash;
#define hash_dat(t) \
typedef struct hash_##t { \
uint64_t hash; \
hash hash; \
t data; \
} hash_##t;
#define hash_ptr(t) \
typedef struct hash_ptr_##t { \
uint64_t hash; \
hash hash; \
t* data; \
} hash_ptr_##t;
extern uint64_t hash_char(char* data);
extern uint64_t hash_wchar_t(wchar_t* data);
extern uint64_t hash_data(void* data, size_t length);
#define HASH_COMPARE(a, b) \
(((a).f == (b).f) || ((a).m == (b).m))
extern hash hash_char(char* data);
extern hash hash_wchar_t(wchar_t* data);
extern hash hash_data(void* data, size_t length);
+16
View File
@@ -0,0 +1,16 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "light.h"
inline float_t light_point_calculate_radius(vec3* color,
float_t constant, float_t linear, float_t quadratic) {
vec3 c = *color;
float_t light_max = max(max(c.x, c.y), c.z);
double_t t_sqrt = sqrt(linear * linear - 4 * quadratic * (constant - (256.0 / 1.0) * light_max));
double_t radius = (-linear + t_sqrt) / (2.0 * quadratic);
return (float_t)radius;
}
+44
View File
@@ -0,0 +1,44 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
typedef struct light_dir {
vec3 dir;
vec3 color;
} light_dir;
typedef struct light_point {
vec3 position;
vec3 color;
union {
struct {
float_t constant;
float_t linear;
float_t quadratic;
float_t radius;
};
vec4 clqr;
};
} light_point;
typedef struct light_dir_update {
vec3 dir;
vec4 color;
} light_dir_update;
typedef struct light_point_update {
vec3 position;
vec4 color;
float_t constant;
float_t linear;
float_t quadratic;
} light_point_update;
extern float_t light_point_calculate_radius(vec3* color,
float_t constant, float_t linear, float_t quadratic);
+35
View File
@@ -0,0 +1,35 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../KKdLib/default.h"
#define lock_val(name) \
CRITICAL_SECTION name; \
BOOL name##_init
#define lock_extern_val(name) \
extern CRITICAL_SECTION name; \
extern BOOL name##_init
#define lock_init(val) \
(val##_init) = InitializeCriticalSectionAndSpinCount(&(val), 0);
#define lock_check_init(val) \
(val##_init)
#define lock_lock(val) \
if (val##_init) { \
EnterCriticalSection(&(val));
#define lock_unlock(val) \
LeaveCriticalSection(&(val)); \
}
#define lock_dispose(val) \
if (val##_init) \
DeleteCriticalSection(&(val)); \
(val##_init) = FALSE
+16
View File
@@ -0,0 +1,16 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "material.h"
const material_blend material_blend_default = {
.enable = true,
.src_factor_rgb = GL_SRC_ALPHA,
.dst_factor_rgb = GL_ONE_MINUS_SRC_ALPHA,
.src_factor_alpha = GL_ONE,
.dst_factor_alpha = GL_ONE_MINUS_SRC_ALPHA,
.mode_rgb = GL_FUNC_ADD,
.mode_alpha = GL_FUNC_ADD,
};
+34
View File
@@ -0,0 +1,34 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../KKdLib/default.h"
#include "hash.h"
#include "texture.h"
typedef struct material_blend {
bool enable;
int16_t src_factor_rgb;
int16_t dst_factor_rgb;
int16_t src_factor_alpha;
int16_t dst_factor_alpha;
int16_t mode_rgb;
int16_t mode_alpha;
} material_blend;
typedef struct material {
texture_set texture;
material_blend blend;
bool translucent;
} material;
typedef struct material_update {
hash texture;
material_blend blend;
bool translucent;
} material_update;
extern const material_blend material_blend_default;
-1250
View File
File diff suppressed because it is too large Load Diff
-379
View File
@@ -1,379 +0,0 @@
/*
** Copyright (c) 2020 rxi
**
** This library is free software; you can redistribute it and/or modify it
** under the terms of the MIT license. See `microui.c` for details.
*/
#pragma once
#include "../KKdLib/default.h"
#define MU_VERSION "2.01"
#define MU_COMMANDLIST_SIZE (256 * 1024)
#define MU_ROOTLIST_SIZE 32
#define MU_CONTAINERSTACK_SIZE 32
#define MU_CLIPSTACK_SIZE 32
#define MU_IDSTACK_SIZE 32
#define MU_LAYOUTSTACK_SIZE 16
#define MU_CONTAINERPOOL_SIZE 48
#define MU_TREENODEPOOL_SIZE 48
#define MU_MAX_WIDTHS 16
#define MU_REAL float
#define MU_REAL_FMT "%g"
#define MU_SLIDER_FMT "%.2f"
#define MU_MAX_FMT 127
#define mu_stack(T, n) struct { size_t idx; T items[n]; }
#define mu_min(a, b) ((a) < (b) ? (a) : (b))
#define mu_max(a, b) ((a) > (b) ? (a) : (b))
#define mu_clamp(x, a, b) mu_min(b, mu_max(a, x))
typedef enum mu_clip_enum {
MU_CLIP_NONE = 0,
MU_CLIP_PART,
MU_CLIP_ALL
} mu_clip_enum;
typedef enum mu_command_enum {
MU_COMMAND_NONE = 0,
MU_COMMAND_JUMP,
MU_COMMAND_CLIP,
MU_COMMAND_RECT,
MU_COMMAND_TEXT,
MU_COMMAND_ICON,
MU_COMMAND_TEX,
MU_COMMAND_MAX
} mu_command_enum;
typedef enum mu_color_enum {
MU_COLOR_TEXT = 0,
MU_COLOR_BORDER,
MU_COLOR_WINDOWBG,
MU_COLOR_TITLEBG,
MU_COLOR_TITLETEXT,
MU_COLOR_PANELBG,
MU_COLOR_BUTTON,
MU_COLOR_BUTTONHOVER,
MU_COLOR_BUTTONFOCUS,
MU_COLOR_BASE,
MU_COLOR_BASEHOVER,
MU_COLOR_BASEFOCUS,
MU_COLOR_SCROLLBASE,
MU_COLOR_SCROLLTHUMB,
MU_COLOR_MAX
} mu_color_enum;
typedef enum mu_icon_enum {
MU_ICON_NONE = 0,
MU_ICON_CLOSE,
MU_ICON_CHECK,
MU_ICON_COLLAPSED,
MU_ICON_EXPANDED,
MU_ICON_MAX
} mu_icon_enum;
typedef enum mu_res_enum {
MU_RES_ACTIVE = (1 << 0),
MU_RES_SUBMIT = (1 << 1),
MU_RES_CHANGE = (1 << 2),
} mu_res_enum;
typedef enum mu_opt_enum {
MU_OPT_ALIGNCENTER = (1 << 0),
MU_OPT_ALIGNRIGHT = (1 << 1),
MU_OPT_NOINTERACT = (1 << 2),
MU_OPT_NOFRAME = (1 << 3),
MU_OPT_NOSCROLL = (1 << 4),
MU_OPT_NOCLOSE = (1 << 5),
MU_OPT_NOTITLE = (1 << 6),
MU_OPT_HOLDFOCUS = (1 << 7),
MU_OPT_AUTOSIZE = (1 << 8),
MU_OPT_POPUP = (1 << 9),
MU_OPT_CLOSED = (1 << 10),
MU_OPT_EXPANDED = (1 << 11),
MU_OPT_ALIGNTOP = (1 << 12),
MU_OPT_ALIGNBOTTOM = (1 << 13),
} mu_opt_enum;
typedef enum mu_mouse_enum {
MU_MOUSE_LEFT = (1 << 0),
MU_MOUSE_RIGHT = (1 << 1),
MU_MOUSE_MIDDLE = (1 << 2),
} mu_mouse_enum;
typedef enum mu_key_enum {
MU_KEY_SHIFT = (1 << 0),
MU_KEY_CTRL = (1 << 1),
MU_KEY_ALT = (1 << 2),
MU_KEY_BACKSPACE = (1 << 3),
MU_KEY_RETURN = (1 << 4),
} mu_key_enum;
typedef enum mu_layout_enum {
MU_LAYOUT_NONE = 0,
MU_LAYOUT_RELATIVE,
MU_LAYOUT_ABSOLUTE,
} mu_layout_enum;
typedef struct mu_Context mu_Context;
typedef unsigned mu_Id;
typedef MU_REAL mu_Real;
typedef void* mu_Font;
typedef struct mu_Vec2 {
int32_t x;
int32_t y;
} mu_Vec2;
typedef struct mu_Rect {
int32_t x;
int32_t y;
int32_t w;
int32_t h;
} mu_Rect;
typedef struct mu_Color {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} mu_Color;
typedef struct mu_PoolItem {
mu_Id id;
int last_update;
} mu_PoolItem;
typedef struct mu_BaseCommand {
mu_command_enum type;
size_t size;
} mu_BaseCommand;
typedef struct mu_JumpCommand {
mu_BaseCommand base;
void *dst;
} mu_JumpCommand;
typedef struct mu_ClipCommand {
mu_BaseCommand base;
mu_Rect rect;
} mu_ClipCommand;
typedef struct mu_RectCommand {
mu_BaseCommand base;
mu_Rect rect;
mu_Color color;
} mu_RectCommand;
typedef struct mu_TextCommand {
mu_BaseCommand base;
mu_Font font;
mu_Vec2 pos;
mu_Color color;
char str[1];
} mu_TextCommand;
typedef struct mu_IconCommand {
mu_BaseCommand base;
mu_Rect rect;
int id;
mu_Color color;
} mu_IconCommand;
typedef struct mu_TexCommand {
mu_BaseCommand base;
mu_Rect rect;
mu_Rect draw;
mu_Color color;
} mu_TexCommand;
typedef union mu_Command {
mu_command_enum type;
mu_BaseCommand base;
mu_JumpCommand jump;
mu_ClipCommand clip;
mu_RectCommand rect;
mu_TextCommand text;
mu_IconCommand icon;
mu_TexCommand tex;
} mu_Command;
typedef struct mu_Layout {
mu_Rect body;
mu_Rect next;
mu_Vec2 position;
mu_Vec2 size;
mu_Vec2 max;
int widths[MU_MAX_WIDTHS];
int items;
int item_index;
int next_row;
mu_layout_enum next_type;
int indent;
} mu_Layout;
typedef struct mu_Container {
mu_Command *head, *tail;
mu_Rect rect;
mu_Rect body;
mu_Vec2 content_size;
mu_Vec2 scroll;
int zindex;
bool open;
bool swap_scroll;
} mu_Container;
typedef struct mu_Style {
mu_Font font;
mu_Vec2 size;
int padding;
int spacing;
int indent;
int title_height;
int scrollbar_size;
int thumb_size;
mu_Color colors[MU_COLOR_MAX];
} mu_Style;
struct mu_Context {
/* callbacks */
int (*text_width)(mu_Font font, const char *str, size_t len);
int (*text_height)(mu_Font font);
void (*draw_frame)(mu_Context *ctx, mu_Rect rect, int colorid);
/* core state */
mu_Style _style;
mu_Style *style;
mu_Id hover;
mu_Id focus;
mu_Id last_id;
mu_Rect last_rect;
int last_zindex;
bool updated_focus;
int frame;
mu_Container *hover_root;
mu_Container *next_hover_root;
mu_Container *scroll_target;
char number_edit_buf[MU_MAX_FMT];
mu_Id number_edit;
/* stacks */
mu_stack(char, MU_COMMANDLIST_SIZE) command_list;
mu_stack(mu_Container*, MU_ROOTLIST_SIZE) root_list;
mu_stack(mu_Container*, MU_CONTAINERSTACK_SIZE) container_stack;
mu_stack(mu_Rect, MU_CLIPSTACK_SIZE) clip_stack;
mu_stack(mu_Id, MU_IDSTACK_SIZE) id_stack;
mu_stack(mu_Layout, MU_LAYOUTSTACK_SIZE) layout_stack;
/* retained state pools */
mu_PoolItem container_pool[MU_CONTAINERPOOL_SIZE];
mu_Container containers[MU_CONTAINERPOOL_SIZE];
mu_PoolItem treenode_pool[MU_TREENODEPOOL_SIZE];
/* input state */
mu_Vec2 mouse_pos;
mu_Vec2 last_mouse_pos;
mu_Vec2 mouse_delta;
mu_Vec2 scroll_delta;
mu_mouse_enum mouse_down;
mu_mouse_enum mouse_pressed;
mu_key_enum key_down;
mu_key_enum key_pressed;
char input_text[32];
bool text_input;
};
mu_Vec2 mu_vec2(int32_t x, int32_t y);
mu_Rect mu_rect(int32_t x, int32_t y, int32_t w, int32_t h);
mu_Color mu_color(int32_t r, int32_t g, int32_t b, int32_t a);
mu_Color mu_color_real(float_t r, float_t g, float_t b, float_t a);
void mu_init(mu_Context *ctx);
void mu_begin(mu_Context *ctx);
void mu_end(mu_Context *ctx);
void mu_set_focus(mu_Context *ctx, mu_Id id);
mu_Id mu_get_id(mu_Context *ctx, const void *data, size_t size);
void mu_push_id(mu_Context *ctx, const void *data, size_t size);
void mu_pop_id(mu_Context *ctx);
void mu_push_clip_rect(mu_Context *ctx, mu_Rect rect);
void mu_pop_clip_rect(mu_Context *ctx);
mu_Rect mu_get_clip_rect(mu_Context *ctx);
mu_clip_enum mu_check_clip(mu_Context *ctx, mu_Rect r);
mu_Container* mu_get_current_container(mu_Context *ctx);
mu_Container* mu_get_container(mu_Context *ctx, const char *name);
void mu_bring_to_front(mu_Context *ctx, mu_Container *cnt);
int mu_pool_init(mu_Context *ctx, mu_PoolItem *items, size_t len, mu_Id id);
int mu_pool_get(mu_Context *ctx, mu_PoolItem *items, size_t len, mu_Id id);
void mu_pool_update(mu_Context *ctx, mu_PoolItem *items, int idx);
void mu_input_mousemove(mu_Context *ctx, int x, int y);
void mu_input_mousedown(mu_Context *ctx, mu_mouse_enum btn);
void mu_input_mouseup(mu_Context *ctx, mu_mouse_enum btn);
void mu_input_scroll(mu_Context *ctx, int x, int y);
void mu_input_keydown(mu_Context *ctx, mu_key_enum key);
void mu_input_keyup(mu_Context *ctx, mu_key_enum key);
void mu_input_text(mu_Context *ctx, const char *text);
mu_Command* mu_push_command(mu_Context *ctx, mu_command_enum type, size_t size);
bool mu_next_command(mu_Context *ctx, mu_Command **cmd);
void mu_set_clip(mu_Context *ctx, mu_Rect rect);
void mu_draw_rect(mu_Context *ctx, mu_Rect rect, mu_Color color);
void mu_draw_box(mu_Context *ctx, mu_Rect rect, mu_Color color);
void mu_draw_text(mu_Context *ctx, mu_Font font, const char *str, size_t len, mu_Vec2 pos, mu_Color color);
void mu_draw_icon(mu_Context *ctx, int id, mu_Rect rect, mu_Color color);
void mu_layout_row(mu_Context *ctx, int items, const int *widths, int height);
void mu_layout_width(mu_Context *ctx, int width);
void mu_layout_height(mu_Context *ctx, int height);
void mu_layout_begin_column(mu_Context *ctx);
void mu_layout_end_column(mu_Context *ctx);
void mu_layout_set_next(mu_Context *ctx, mu_Rect r, int relative);
void mu_layout_get_next(mu_Context* ctx, mu_Layout* layout);
mu_Rect mu_layout_next(mu_Context *ctx);
void mu_draw_control_frame(mu_Context *ctx, mu_Id id, mu_Rect rect, int colorid, mu_opt_enum opt);
void mu_draw_control_text(mu_Context *ctx, const char *str, mu_Rect rect, int colorid, mu_opt_enum opt);
bool mu_mouse_over(mu_Context *ctx, mu_Rect rect);
void mu_update_control(mu_Context *ctx, mu_Id id, mu_Rect rect, mu_opt_enum opt);
#define mu_button(ctx, label) mu_button_ex(ctx, label, 0, MU_OPT_ALIGNCENTER)
#define mu_textbox(ctx, buf, bufsz) mu_textbox_ex(ctx, buf, bufsz, 0)
#define mu_slider(ctx, value, lo, hi) mu_slider_ex(ctx, value, lo, hi, 0, MU_SLIDER_FMT, MU_OPT_ALIGNCENTER)
#define mu_number(ctx, value, step) mu_number_ex(ctx, value, step, MU_SLIDER_FMT, MU_OPT_ALIGNCENTER)
#define mu_header(ctx, label) mu_header_ex(ctx, label, 0)
#define mu_begin_treenode(ctx, label) mu_begin_treenode_ex(ctx, label, 0)
#define mu_begin_window(ctx, title, rect) mu_begin_window_ex(ctx, title, rect, 0, false, false, false)
#define mu_begin_panel(ctx, name) mu_begin_panel_ex(ctx, name, 0, false)
#define mu_slider_step(ctx, value, low, high, step) \
mu_slider_ex(ctx, value, low, high, step, MU_SLIDER_FMT, MU_OPT_ALIGNCENTER);
#define mu_slider_fmt(ctx, value, low, high, step, fmt) \
mu_slider_ex(ctx, value, low, high, step, fmt, MU_OPT_ALIGNCENTER);
#define mu_number_fmt(ctx, value, step, fmt) \
mu_number_ex(ctx, value, step, fmt, MU_OPT_ALIGNCENTER)
void mu_text(mu_Context *ctx, const char *text);
void mu_label(mu_Context *ctx, const char *text);
mu_res_enum mu_button_ex(mu_Context *ctx, const char *label, int icon, mu_opt_enum opt);
mu_res_enum mu_checkbox(mu_Context *ctx, const char *label, bool *state);
mu_res_enum mu_textbox_raw(mu_Context *ctx, char *buf, size_t bufsz, mu_Id id, mu_Rect r, mu_opt_enum opt);
mu_res_enum mu_textbox_ex(mu_Context *ctx, char *buf, size_t bufsz, mu_opt_enum opt);
mu_res_enum mu_slider_ex(mu_Context *ctx, mu_Real *value, mu_Real low, mu_Real high, mu_Real step, const char *fmt, mu_opt_enum opt);
mu_res_enum mu_number_ex(mu_Context *ctx, mu_Real *value, mu_Real step, const char *fmt, mu_opt_enum opt);
mu_res_enum mu_header_ex(mu_Context *ctx, const char *label, mu_opt_enum opt);
mu_res_enum mu_begin_treenode_ex(mu_Context *ctx, const char *label, mu_opt_enum opt);
void mu_end_treenode(mu_Context *ctx);
mu_res_enum mu_begin_window_ex(mu_Context *ctx, const char *title,
mu_Rect rect, mu_opt_enum opt, bool reset_pos, bool reset_size, bool swap_scroll);
void mu_end_window(mu_Context *ctx);
void mu_open_popup(mu_Context *ctx, const char *name);
mu_res_enum mu_begin_popup(mu_Context *ctx, const char *name);
void mu_end_popup(mu_Context *ctx);
void mu_begin_panel_ex(mu_Context *ctx, const char *name, mu_opt_enum opt, bool swap_scroll);
void mu_end_panel(mu_Context *ctx);
void mu_tabs_get_title_size(mu_Context* muctx, int32_t min, int32_t max,
int32_t* w, int32_t* h, char** temp, int32_t* temp_w);
bool mu_tabs_set(mu_Context* muctx, int32_t min, int32_t max, char** temp,
int32_t* temp_w, int32_t temp_c, int32_t* selector, char* name, mu_Rect rect, bool focus_reset);
mu_res_enum mu_slider_uint8_t(mu_Context* ctx, uint8_t* value, int32_t low, int32_t high);
mu_res_enum mu_slider_uint8_t_label(mu_Context* ctx, uint8_t* value, int32_t low, int32_t high, const char* label);
int32_t mu_misc_get_max_text_width(mu_Context* muctx, char** temp, size_t temp_c);
-994
View File
@@ -1,994 +0,0 @@
enum { ATLAS_WHITE = MU_ICON_MAX, ATLAS_FONT };
enum { ATLAS_WIDTH = 128, ATLAS_HEIGHT = 128 };
static unsigned char atlas_texture[ATLAS_WIDTH * ATLAS_HEIGHT] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xc0, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x32, 0x0b, 0x00, 0x00, 0x00,
0x00, 0x31, 0x35, 0x01, 0x00, 0x00, 0x00, 0x15, 0x35, 0x1d, 0x30, 0x19,
0x00, 0x00, 0x0f, 0x35, 0x06, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x2d, 0x00, 0x00, 0x00,
0x14, 0x26, 0x00, 0x00, 0x31, 0x2a, 0x00, 0x00, 0x00, 0x10, 0x31, 0x00,
0x00, 0x00, 0x00, 0x06, 0x3e, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x3e, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x40, 0x0d, 0x00, 0x00, 0x00, 0x00,
0x31, 0x35, 0x2f, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x41,
0x37, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x21, 0xe0, 0xea, 0x2c, 0x00, 0x00, 0x00, 0x00,
0x36, 0xc4, 0xdb, 0xb2, 0xd9, 0xc1, 0x1a, 0x00, 0x00, 0xea, 0xff, 0x39,
0x00, 0x00, 0x00, 0x9e, 0xff, 0x88, 0xbe, 0x9c, 0x00, 0x00, 0x72, 0xff,
0x48, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1c, 0xe4, 0xce, 0x8d, 0x00, 0x00, 0xb5, 0x60, 0x00, 0x00,
0xea, 0xfa, 0x2c, 0x00, 0x00, 0x4e, 0xeb, 0x00, 0x00, 0x1c, 0x8f, 0xea,
0xea, 0xee, 0x92, 0x1f, 0x00, 0x00, 0x1c, 0x8f, 0xea, 0xea, 0xee, 0x92,
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0xf3, 0xcd, 0xf5, 0x3a, 0x00, 0x00, 0x00, 0xea, 0xf2, 0xef, 0xe5,
0x8f, 0x2f, 0x00, 0x00, 0x0f, 0xa0, 0xfe, 0xf2, 0xf1, 0xfa, 0x33, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21,
0xe0, 0xea, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x35, 0xdc, 0x33, 0x00, 0x06,
0x00, 0x5a, 0xd7, 0x13, 0x00, 0xea, 0xd8, 0x92, 0x00, 0x00, 0x09, 0xf0,
0xd9, 0x88, 0x7b, 0xda, 0x00, 0x00, 0xb9, 0xe9, 0x91, 0x00, 0x05, 0xf4,
0x03, 0x35, 0x02, 0x32, 0x1f, 0x00, 0x04, 0x37, 0x24, 0x00, 0x5b, 0xa9,
0x1b, 0xe7, 0x01, 0x44, 0xd0, 0x02, 0x00, 0x00, 0xea, 0xe4, 0xc3, 0x01,
0x00, 0x4e, 0xeb, 0x00, 0x00, 0x8f, 0xd8, 0x42, 0x01, 0x3a, 0xd0, 0x9b,
0x00, 0x00, 0x8f, 0xd8, 0x42, 0x01, 0x3a, 0xd0, 0x9b, 0x00, 0x2e, 0x1a,
0x00, 0x03, 0x36, 0x19, 0x00, 0x04, 0x36, 0x00, 0xa3, 0xa0, 0x00, 0xb5,
0x8d, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x01, 0x3d, 0xac, 0xe5, 0x03, 0x00,
0xa1, 0xeb, 0x63, 0x0c, 0x03, 0x2e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xe1, 0xeb, 0x2d, 0x00, 0x00,
0x00, 0x00, 0x00, 0xd6, 0x38, 0x37, 0xb4, 0xd6, 0xe9, 0x35, 0x9e, 0x5c,
0x00, 0xea, 0x87, 0xe8, 0x03, 0x00, 0x56, 0xcc, 0xba, 0x88, 0x38, 0xff,
0x1a, 0x09, 0xf7, 0x84, 0xd9, 0x00, 0x39, 0xfe, 0x0e, 0xff, 0xb7, 0xe1,
0xf3, 0x94, 0xbc, 0xde, 0xfb, 0x97, 0x73, 0x9b, 0x0b, 0xfb, 0x0b, 0xcf,
0x44, 0x01, 0x00, 0x00, 0xea, 0x65, 0xf7, 0x63, 0x00, 0x4e, 0xeb, 0x00,
0x01, 0xe0, 0x79, 0x00, 0x00, 0x00, 0x6b, 0xea, 0x03, 0x01, 0xe0, 0x79,
0x00, 0x00, 0x00, 0x6b, 0xea, 0x03, 0xb0, 0xa4, 0x00, 0x39, 0xfe, 0xa0,
0x00, 0x3d, 0xfd, 0x00, 0x6e, 0xe0, 0x5b, 0xef, 0x41, 0x00, 0x00, 0x00,
0xea, 0x6d, 0x00, 0x00, 0x17, 0xfd, 0x47, 0x18, 0xff, 0x8f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x21, 0xe1, 0xeb, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xe3,
0x00, 0xc5, 0x51, 0x00, 0xd4, 0x37, 0x61, 0x99, 0x00, 0xea, 0x4d, 0xe9,
0x45, 0x00, 0xb2, 0x70, 0xbf, 0x88, 0x04, 0xf0, 0x59, 0x48, 0xe9, 0x18,
0xfd, 0x23, 0x77, 0xd4, 0x0e, 0xff, 0x9f, 0x02, 0x54, 0xff, 0x86, 0x00,
0x69, 0xf0, 0x39, 0xd1, 0x61, 0xca, 0x60, 0xb6, 0x6f, 0xe3, 0x98, 0x00,
0xea, 0x4a, 0x7f, 0xec, 0x15, 0x4e, 0xeb, 0x00, 0x32, 0xff, 0x36, 0x00,
0x00, 0x00, 0x29, 0xff, 0x3e, 0x32, 0xff, 0x36, 0x00, 0x00, 0x00, 0x29,
0xff, 0x3f, 0x68, 0xe6, 0x00, 0x83, 0xaf, 0xe7, 0x01, 0x80, 0xc9, 0x00,
0x18, 0xf4, 0xff, 0x53, 0x00, 0x15, 0x3b, 0x00, 0xea, 0x6d, 0x00, 0x00,
0x00, 0xc5, 0xa2, 0x41, 0xff, 0x39, 0x00, 0x40, 0x73, 0x73, 0x35, 0x00,
0x00, 0x00, 0x3d, 0xed, 0x45, 0x00, 0x00, 0x00, 0x22, 0xe1, 0xeb, 0x2d,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0xb3, 0x12, 0xf9, 0x04, 0x03,
0xef, 0x2c, 0x6a, 0x94, 0x00, 0xea, 0x4d, 0x95, 0x9e, 0x14, 0xf6, 0x18,
0xc1, 0x88, 0x00, 0xb2, 0x96, 0x8e, 0xa4, 0x00, 0xcb, 0x6a, 0xb5, 0x92,
0x0e, 0xff, 0x59, 0x00, 0x27, 0xff, 0x3d, 0x00, 0x3a, 0xff, 0x04, 0x71,
0xae, 0x40, 0xe0, 0x2e, 0xee, 0x1e, 0xd5, 0x00, 0xea, 0x4d, 0x08, 0xd9,
0xa0, 0x4b, 0xeb, 0x00, 0x20, 0xfe, 0x45, 0x00, 0x00, 0x00, 0x37, 0xff,
0x2c, 0x20, 0xfe, 0x45, 0x00, 0x00, 0x00, 0x37, 0xff, 0x3b, 0x21, 0xff,
0x29, 0xcc, 0x4a, 0xe9, 0x30, 0xc3, 0x81, 0x14, 0xdf, 0xab, 0xbd, 0xcd,
0x14, 0x9c, 0xb5, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0xdc, 0xa6, 0x20,
0xfe, 0x42, 0x00, 0x63, 0xb2, 0xf4, 0x76, 0x00, 0x00, 0x00, 0x13, 0xd0,
0xf6, 0x45, 0x00, 0x22, 0xe1, 0xeb, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xe7, 0x03, 0xd7, 0x5e, 0x75, 0xf7, 0x8d, 0xc7, 0x4a,
0x00, 0xea, 0x4d, 0x3c, 0xf0, 0x71, 0xb7, 0x00, 0xc1, 0x88, 0x00, 0x70,
0xc9, 0xcb, 0x5d, 0x00, 0x83, 0xa2, 0xe9, 0x4f, 0x0e, 0xff, 0x43, 0x00,
0x26, 0xff, 0x2d, 0x00, 0x39, 0xff, 0x00, 0x00, 0x00, 0x7c, 0x9a, 0x1f,
0xf1, 0x00, 0xaf, 0x00, 0xea, 0x4d, 0x00, 0x44, 0xfe, 0x83, 0xeb, 0x00,
0x00, 0xcd, 0x89, 0x00, 0x00, 0x00, 0x7b, 0xd9, 0x00, 0x00, 0xcd, 0x89,
0x00, 0x00, 0x00, 0x7b, 0xf8, 0x08, 0x00, 0xd8, 0x75, 0xf8, 0x0d, 0xa7,
0x79, 0xf7, 0x39, 0x5b, 0xfc, 0x0a, 0x09, 0xba, 0xd4, 0xf6, 0x39, 0x00,
0xea, 0x6d, 0x00, 0x00, 0x31, 0xff, 0x75, 0x00, 0xcc, 0x8f, 0x00, 0x00,
0x00, 0xdb, 0x76, 0x00, 0x00, 0x00, 0x00, 0x13, 0xd0, 0xf6, 0x63, 0xe1,
0xeb, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0xf3,
0x44, 0x2c, 0x96, 0x87, 0x29, 0xa3, 0x64, 0x00, 0x00, 0xea, 0x4d, 0x01,
0xe1, 0xf3, 0x5b, 0x00, 0xc1, 0x88, 0x00, 0x2e, 0xf7, 0xf5, 0x17, 0x00,
0x3a, 0xec, 0xfc, 0x10, 0x0e, 0xff, 0x43, 0x00, 0x26, 0xff, 0x2d, 0x00,
0x39, 0xff, 0x00, 0x00, 0x17, 0xe6, 0x19, 0x02, 0xee, 0x13, 0xd0, 0x00,
0xea, 0x4d, 0x00, 0x00, 0xa5, 0xf6, 0xeb, 0x00, 0x00, 0x7d, 0xec, 0x7a,
0x24, 0x73, 0xe7, 0x87, 0x00, 0x00, 0x7d, 0xec, 0x7a, 0x24, 0x73, 0xe7,
0x9c, 0x00, 0x00, 0x91, 0xda, 0xbd, 0x00, 0x61, 0xd9, 0xed, 0x03, 0x2b,
0xfe, 0x67, 0x1d, 0x70, 0xfc, 0xf0, 0x1a, 0x00, 0xea, 0x7f, 0x31, 0x81,
0xdc, 0xdc, 0x0a, 0x00, 0x79, 0xef, 0x83, 0x23, 0x1c, 0xe1, 0x76, 0x00,
0x00, 0x00, 0x00, 0x00, 0x13, 0xd0, 0xff, 0xec, 0x2e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6b, 0xdc, 0x78, 0x20, 0x0d,
0x3c, 0x3b, 0x00, 0x00, 0x00, 0xea, 0x4d, 0x00, 0x8a, 0xf3, 0x0b, 0x00,
0xc1, 0x88, 0x00, 0x01, 0xea, 0xce, 0x00, 0x00, 0x03, 0xed, 0xc9, 0x00,
0x0e, 0xff, 0x43, 0x00, 0x26, 0xff, 0x2d, 0x00, 0x39, 0xff, 0x00, 0x00,
0x98, 0x7e, 0x00, 0x00, 0x78, 0xe7, 0xb0, 0x00, 0xea, 0x4d, 0x00, 0x00,
0x18, 0xef, 0xeb, 0x00, 0x00, 0x06, 0x54, 0xb6, 0xfb, 0xbb, 0x57, 0x07,
0x00, 0x00, 0x06, 0x54, 0xb6, 0xfc, 0xff, 0x8d, 0x01, 0x00, 0x00, 0x49,
0xff, 0x74, 0x00, 0x1b, 0xfe, 0xa8, 0x00, 0x00, 0x7f, 0xde, 0xff, 0xe7,
0x72, 0xb1, 0xdb, 0x00, 0xea, 0xff, 0xf8, 0xd6, 0x92, 0x13, 0x00, 0x00,
0x06, 0x52, 0xb4, 0xfb, 0xff, 0xe5, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x13, 0xbc, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x44, 0xb7, 0xde, 0xdb, 0xad, 0x50, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1b, 0xda, 0xbb, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0xe6,
0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x17, 0x00, 0x00, 0x00,
0x2a, 0x1e, 0x00, 0x35, 0x13, 0x00, 0x00, 0x00, 0x2c, 0x1c, 0x00, 0x00,
0x0c, 0x27, 0x00, 0x29, 0x09, 0x00, 0x00, 0x00, 0x3c, 0x24, 0x00, 0x00,
0x00, 0x31, 0x35, 0x30, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44,
0x1f, 0x00, 0x00, 0x31, 0x17, 0x00, 0x00, 0x13, 0x35, 0x00, 0x31, 0x35,
0x2b, 0x02, 0x00, 0x00, 0x00, 0x31, 0x35, 0x2a, 0x02, 0x00, 0x00, 0x33,
0x16, 0x00, 0x00, 0x00, 0x0f, 0x35, 0x27, 0x28, 0x00, 0x00, 0x00, 0x1f,
0x2e, 0x0b, 0xbc, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x13, 0xbc, 0x2a, 0x0b, 0xbc, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0xc9, 0x8e, 0x00, 0xfc,
0x5b, 0x00, 0x00, 0x00, 0xd2, 0x84, 0x00, 0x00, 0x59, 0xa9, 0x00, 0xea,
0x0f, 0x00, 0x00, 0x34, 0xfe, 0xce, 0x00, 0x00, 0x00, 0xea, 0xf2, 0xed,
0xfa, 0xce, 0x1a, 0x00, 0x09, 0xb5, 0xfd, 0xe7, 0xf5, 0xaf, 0x00, 0xea,
0x6d, 0x00, 0x0c, 0xcf, 0xa7, 0x00, 0xea, 0xf2, 0xf3, 0xea, 0x94, 0x00,
0x00, 0xea, 0xf4, 0xf6, 0xec, 0x9d, 0x00, 0xc0, 0x9e, 0x00, 0x00, 0x00,
0x7a, 0xe5, 0x58, 0xf8, 0x26, 0x00, 0x0d, 0xe4, 0x7a, 0x0e, 0xff, 0x43,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0xff, 0x39, 0x0e,
0xff, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea,
0x6d, 0x00, 0x00, 0x00, 0xc9, 0x8e, 0x00, 0xfc, 0x5b, 0x00, 0x00, 0x00,
0xd2, 0x84, 0x00, 0x00, 0x89, 0x79, 0x1c, 0xdd, 0x00, 0x00, 0x00, 0x93,
0xad, 0xf9, 0x2e, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x19, 0xe3, 0x8c, 0x00,
0xab, 0xe1, 0x4f, 0x02, 0x07, 0x1f, 0x00, 0xea, 0x6d, 0x03, 0xb2, 0xc6,
0x08, 0x00, 0xea, 0x6d, 0x03, 0x4d, 0xff, 0x33, 0x00, 0xea, 0x6d, 0x03,
0x49, 0xff, 0x3a, 0x67, 0xee, 0x06, 0x00, 0x00, 0xd0, 0x8e, 0x00, 0xb3,
0xbb, 0x00, 0x8e, 0xcf, 0x05, 0x0e, 0xff, 0x41, 0x12, 0x25, 0x00, 0x00,
0x00, 0x00, 0x18, 0x20, 0x18, 0xff, 0x39, 0x0e, 0xff, 0x41, 0x2e, 0x33,
0x01, 0x00, 0x03, 0x35, 0x01, 0x2e, 0x34, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x39, 0x05, 0x00, 0x00, 0x03, 0x36, 0x02, 0x11, 0x25,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00,
0xc9, 0x8e, 0x00, 0xfc, 0x5b, 0x00, 0x00, 0x00, 0xd2, 0x84, 0x41, 0xd3,
0xf0, 0xe3, 0xdd, 0xf4, 0xd3, 0x00, 0x06, 0xec, 0x52, 0xb4, 0x8d, 0x00,
0x00, 0xea, 0x6d, 0x00, 0x06, 0xdd, 0x86, 0x0b, 0xfc, 0x81, 0x00, 0x00,
0x00, 0x00, 0x00, 0xea, 0x6d, 0x8d, 0xdd, 0x15, 0x00, 0x00, 0xea, 0x6d,
0x00, 0x07, 0xf3, 0x64, 0x00, 0xea, 0x6d, 0x00, 0x0a, 0xf4, 0x69, 0x13,
0xfa, 0x4a, 0x00, 0x27, 0xff, 0x34, 0x00, 0x1c, 0xf1, 0x86, 0xf7, 0x33,
0x00, 0x0e, 0xff, 0xaa, 0xd3, 0xf8, 0xab, 0x01, 0x00, 0x87, 0xf6, 0xda,
0xa5, 0xff, 0x39, 0x0e, 0xff, 0xc0, 0xe5, 0xf2, 0xd5, 0x03, 0x0e, 0xff,
0xb4, 0xe5, 0xf2, 0xd6, 0x04, 0x00, 0x00, 0x00, 0x00, 0x6d, 0xe7, 0xdd,
0xe7, 0x6d, 0x00, 0x0e, 0xff, 0x98, 0xd2, 0xf8, 0xab, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0xea, 0xe9, 0xd9, 0xd9, 0xd9, 0xf7, 0x8e, 0x00, 0xfc,
0x5b, 0x00, 0x00, 0x00, 0xd2, 0x84, 0x09, 0x1d, 0xec, 0x2e, 0x93, 0x87,
0x1d, 0x00, 0x52, 0xf1, 0x09, 0x5d, 0xe8, 0x04, 0x00, 0xea, 0xe4, 0xd3,
0xf6, 0xb1, 0x0d, 0x3c, 0xff, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea,
0xc9, 0xff, 0x60, 0x00, 0x00, 0x00, 0xea, 0x8a, 0x49, 0x9e, 0xf1, 0x0d,
0x00, 0xea, 0xa6, 0x71, 0xbb, 0xe1, 0x1a, 0x00, 0xb4, 0xa0, 0x00, 0x7d,
0xda, 0x00, 0x00, 0x00, 0x74, 0xff, 0x93, 0x00, 0x00, 0x0e, 0xff, 0x9c,
0x02, 0x2a, 0xff, 0x32, 0x0e, 0xfa, 0x5a, 0x00, 0x6f, 0xff, 0x39, 0x0e,
0xff, 0xa6, 0x04, 0x1e, 0xff, 0x42, 0x0e, 0xff, 0xa5, 0x04, 0x1e, 0xff,
0x42, 0x00, 0x00, 0x00, 0x07, 0xf1, 0x59, 0x00, 0x55, 0xf2, 0x09, 0x0e,
0xff, 0x99, 0x01, 0x2d, 0xff, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea,
0x98, 0x4c, 0x4c, 0x4c, 0xd9, 0x8e, 0x00, 0xfc, 0x5b, 0x00, 0x00, 0x00,
0xd2, 0x84, 0x37, 0x58, 0xef, 0x4a, 0xc6, 0x83, 0x38, 0x00, 0xb1, 0xd5,
0x6f, 0x7d, 0xff, 0x4c, 0x00, 0xea, 0x94, 0x47, 0x70, 0xe7, 0x83, 0x22,
0xff, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0xd2, 0xaf, 0xe2, 0x10,
0x00, 0x00, 0xea, 0xf5, 0xda, 0x94, 0x3e, 0x00, 0x00, 0xea, 0xd6, 0xc4,
0xfd, 0x27, 0x00, 0x00, 0x5b, 0xef, 0x06, 0xd3, 0x81, 0x00, 0x00, 0x01,
0xbc, 0xeb, 0xd2, 0x06, 0x00, 0x0e, 0xff, 0x56, 0x00, 0x00, 0xdd, 0x77,
0x50, 0xfb, 0x0c, 0x00, 0x23, 0xff, 0x39, 0x0e, 0xff, 0x5c, 0x00, 0x00,
0xeb, 0x68, 0x0e, 0xff, 0x5c, 0x00, 0x00, 0xeb, 0x68, 0x00, 0x00, 0x00,
0x4c, 0xfb, 0x0b, 0x00, 0x08, 0xf8, 0x51, 0x0e, 0xff, 0x52, 0x00, 0x00,
0xde, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00,
0xc9, 0x8e, 0x00, 0xd3, 0x85, 0x00, 0x00, 0x09, 0xf4, 0x6b, 0x7b, 0xc7,
0xdf, 0xa7, 0xfd, 0xa9, 0x7f, 0x16, 0xfa, 0xc4, 0xb8, 0xb8, 0xe2, 0xab,
0x00, 0xea, 0x6d, 0x00, 0x00, 0x8e, 0xdf, 0x00, 0xd2, 0x89, 0x00, 0x00,
0x00, 0x00, 0x00, 0xea, 0x6d, 0x0f, 0xe0, 0xa1, 0x00, 0x00, 0xea, 0x6d,
0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x01, 0xc6, 0xa5, 0x00, 0x00,
0x0c, 0xf5, 0x69, 0xff, 0x28, 0x00, 0x00, 0x60, 0xec, 0x21, 0xe4, 0x80,
0x00, 0x0e, 0xff, 0x65, 0x00, 0x01, 0xea, 0x67, 0x43, 0xfe, 0x12, 0x00,
0x25, 0xff, 0x39, 0x0e, 0xff, 0x43, 0x00, 0x00, 0xea, 0x68, 0x0e, 0xff,
0x43, 0x00, 0x00, 0xea, 0x68, 0x00, 0x00, 0x00, 0x4c, 0xfe, 0x16, 0x00,
0x11, 0xfd, 0x40, 0x0e, 0xff, 0x65, 0x00, 0x01, 0xeb, 0x67, 0x00, 0x00,
0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0xc9, 0x8e, 0x00, 0x72,
0xdf, 0x4b, 0x23, 0x8c, 0xfa, 0x28, 0x00, 0x7c, 0x81, 0x1a, 0xe5, 0x00,
0x00, 0x70, 0xeb, 0x05, 0x00, 0x00, 0x5c, 0xf8, 0x00, 0xea, 0x7f, 0x22,
0x4a, 0xdd, 0x95, 0x00, 0x84, 0xed, 0x7c, 0x1d, 0x24, 0x32, 0x00, 0xea,
0x6d, 0x00, 0x40, 0xfd, 0x52, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00,
0x00, 0xea, 0x6d, 0x00, 0x31, 0xfc, 0x49, 0x00, 0x00, 0xa8, 0xe3, 0xcd,
0x00, 0x00, 0x17, 0xed, 0x62, 0x00, 0x54, 0xf9, 0x2d, 0x0e, 0xff, 0xbc,
0x1d, 0x5f, 0xff, 0x21, 0x07, 0xf5, 0x7e, 0x11, 0x8d, 0xff, 0x39, 0x0e,
0xff, 0x43, 0x00, 0x00, 0xea, 0x68, 0x0e, 0xff, 0x43, 0x00, 0x00, 0xea,
0x68, 0x00, 0x00, 0x00, 0x14, 0xf2, 0x88, 0x15, 0x82, 0xe8, 0x03, 0x0e,
0xff, 0xbc, 0x1e, 0x61, 0xff, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea,
0x6d, 0x00, 0x00, 0x00, 0xc9, 0x8e, 0x00, 0x10, 0x85, 0xdc, 0xfe, 0xd9,
0x4c, 0x00, 0x00, 0xaa, 0x50, 0x4b, 0xb4, 0x00, 0x00, 0xcf, 0x97, 0x00,
0x00, 0x00, 0x0c, 0xf4, 0x00, 0xea, 0xff, 0xff, 0xdd, 0x93, 0x1c, 0x00,
0x08, 0x5c, 0xc0, 0xfe, 0xed, 0x7b, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x8d,
0xea, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00,
0x00, 0x95, 0xe0, 0x00, 0x00, 0x4f, 0xff, 0x74, 0x00, 0x00, 0xa8, 0xc3,
0x01, 0x00, 0x00, 0xb7, 0xca, 0x0e, 0xfd, 0x6f, 0xd4, 0xe5, 0x72, 0x00,
0x00, 0x5c, 0xd9, 0xdb, 0x63, 0xef, 0x39, 0x0e, 0xff, 0x43, 0x00, 0x00,
0xea, 0x68, 0x0e, 0xff, 0x43, 0x00, 0x00, 0xea, 0x68, 0x00, 0x00, 0x00,
0x00, 0x43, 0xdb, 0xfc, 0xb7, 0x46, 0x00, 0x0e, 0xff, 0x8c, 0xd4, 0xe4,
0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0x00, 0x0e, 0xff, 0x43, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e,
0xff, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xc2, 0x33, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x79,
0x00, 0x00, 0x00, 0x00, 0x58, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0a, 0x2f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e,
0x14, 0x00, 0x00, 0x04, 0x32, 0x3b, 0x03, 0x00, 0x00, 0x00, 0x21, 0x38,
0x04, 0x00, 0x00, 0x00, 0x00, 0x07, 0x3b, 0x0f, 0x00, 0x2e, 0x35, 0x35,
0x35, 0x16, 0x00, 0x00, 0x03, 0x26, 0x49, 0x1f, 0x1e, 0x33, 0x33, 0x33,
0x33, 0x33, 0x00, 0x00, 0x18, 0x3a, 0x05, 0x00, 0x00, 0x00, 0x14, 0x37,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f,
0x00, 0x31, 0x35, 0x35, 0x35, 0x27, 0x00, 0x31, 0x35, 0x35, 0x35, 0x26,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0xa6, 0xea, 0x9e, 0x53, 0x0f, 0x03,
0x5f, 0xa3, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d,
0xe9, 0xea, 0xb4, 0x23, 0x00, 0x07, 0x98, 0xff, 0x61, 0x00, 0x27, 0xd4,
0xee, 0xe8, 0xe8, 0x2f, 0x32, 0xcf, 0xdd, 0xe5, 0xef, 0x33, 0x00, 0x00,
0x00, 0x89, 0xff, 0x41, 0x00, 0xea, 0xf9, 0xf6, 0xf6, 0x64, 0x00, 0x25,
0xcf, 0xfe, 0xd1, 0x6c, 0x90, 0xf6, 0xf6, 0xf6, 0xf9, 0xff, 0x00, 0xa0,
0xea, 0xca, 0xee, 0x3e, 0x00, 0x9e, 0xf3, 0xe2, 0xe3, 0x1c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0xea, 0xf4, 0xec,
0xec, 0xac, 0x00, 0xea, 0xf4, 0xec, 0xec, 0xa9, 0x00, 0x00, 0x00, 0x00,
0x17, 0x3a, 0x05, 0x30, 0x0c, 0x06, 0x36, 0x0c, 0x00, 0x00, 0x34, 0x13,
0x16, 0xf6, 0x91, 0xc3, 0x79, 0x5b, 0x80, 0xed, 0xc9, 0xd9, 0xdb, 0xcb,
0x00, 0x00, 0x31, 0xa9, 0x00, 0x00, 0x06, 0xf7, 0x57, 0x0c, 0xbd, 0x88,
0x05, 0xc6, 0xb6, 0xed, 0x61, 0x00, 0x08, 0x64, 0x05, 0x02, 0xbf, 0x9d,
0x04, 0x3a, 0x00, 0x01, 0xbe, 0xa2, 0x00, 0x00, 0x3d, 0xd1, 0xfc, 0x41,
0x02, 0xfc, 0x41, 0x00, 0x00, 0x00, 0x00, 0xc9, 0xa9, 0x1f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x90, 0xbf, 0x23, 0xfe, 0x27, 0x00, 0x9b, 0xaf,
0x2b, 0xfc, 0x21, 0x00, 0xa9, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x50, 0xce,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x98, 0x1e, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7c, 0xc1, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0xea,
0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x85, 0xf6, 0xdf, 0xbf, 0xf9,
0x39, 0x1d, 0xff, 0x38, 0x00, 0x00, 0xf6, 0x5c, 0x30, 0xff, 0x55, 0xa7,
0x00, 0x00, 0x06, 0x21, 0xdd, 0xeb, 0x45, 0x0c, 0x00, 0x00, 0x3a, 0xc8,
0x00, 0x00, 0x35, 0xfd, 0x09, 0x00, 0x77, 0xc1, 0x00, 0x44, 0x03, 0xee,
0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa6, 0xa9, 0x00, 0x00, 0x00, 0x09,
0xdb, 0x79, 0x00, 0x0d, 0xdc, 0x43, 0xff, 0x41, 0x13, 0xff, 0x38, 0x0f,
0x00, 0x00, 0x36, 0xff, 0x34, 0x26, 0x05, 0x00, 0x00, 0x00, 0x00, 0x12,
0xf3, 0x4e, 0x0a, 0xf1, 0x6b, 0x16, 0xce, 0x80, 0x6e, 0xda, 0x00, 0x00,
0x58, 0xe9, 0x00, 0x01, 0x50, 0xce, 0xbc, 0x44, 0x49, 0xab, 0xab, 0xab,
0xab, 0xa8, 0x0f, 0x78, 0xe1, 0x98, 0x1f, 0x00, 0x00, 0x01, 0xdb, 0x62,
0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0e, 0xfa, 0x58, 0x00, 0x6f, 0xff, 0x39, 0x1d, 0xff, 0x38,
0x00, 0x00, 0xf6, 0x5c, 0x00, 0x90, 0xfc, 0xdd, 0x46, 0x00, 0x00, 0x8b,
0xbb, 0x75, 0xce, 0x06, 0x41, 0x8d, 0xa7, 0xe7, 0x8d, 0x8d, 0x6b, 0xe3,
0x00, 0x00, 0x52, 0xf5, 0x00, 0x00, 0x00, 0xf0, 0x61, 0x00, 0x00, 0x00,
0x00, 0x31, 0xf8, 0x3f, 0x00, 0x33, 0xcb, 0xf8, 0x85, 0x05, 0x00, 0x9c,
0x8e, 0x08, 0xff, 0x41, 0x1f, 0xfd, 0xfe, 0xfa, 0xb8, 0x2d, 0x5b, 0xf2,
0xc9, 0xe6, 0xe7, 0x5a, 0x00, 0x00, 0x00, 0x7c, 0xd9, 0x02, 0x00, 0x37,
0xfb, 0xf8, 0xa4, 0x02, 0x2e, 0xfd, 0x49, 0x26, 0xbd, 0xfe, 0x35, 0xce,
0xac, 0x34, 0x00, 0x00, 0x24, 0x55, 0x55, 0x55, 0x55, 0x53, 0x00, 0x00,
0x08, 0x68, 0xd8, 0x98, 0x00, 0x3b, 0xf4, 0x0d, 0x00, 0xea, 0xe8, 0xd6,
0xd6, 0x6f, 0x00, 0xea, 0xb6, 0x82, 0x82, 0x42, 0x00, 0x00, 0x4f, 0xfb,
0x0c, 0x00, 0x23, 0xff, 0x39, 0x1d, 0xff, 0x38, 0x00, 0x00, 0xf6, 0x5c,
0x00, 0x00, 0x3a, 0xe4, 0xf4, 0x89, 0x00, 0x24, 0x30, 0x0c, 0x48, 0x00,
0x34, 0x72, 0x92, 0xe1, 0x72, 0x72, 0x5e, 0xea, 0x00, 0x00, 0x59, 0xee,
0x00, 0x00, 0x00, 0xf0, 0x61, 0x00, 0x00, 0x00, 0x22, 0xe6, 0x76, 0x00,
0x00, 0x15, 0x57, 0x82, 0xe7, 0x79, 0x4d, 0xd5, 0x09, 0x08, 0xff, 0x41,
0x00, 0x13, 0x03, 0x2c, 0xcd, 0xa5, 0x6f, 0xfc, 0x30, 0x01, 0x81, 0xd3,
0x00, 0x00, 0x09, 0xe9, 0x6a, 0x00, 0x0f, 0xc5, 0xb2, 0x78, 0xed, 0x63,
0x00, 0x7f, 0xe4, 0xe4, 0xa5, 0xeb, 0x34, 0xc4, 0xcd, 0x64, 0x0a, 0x00,
0x2e, 0x6c, 0x6c, 0x6c, 0x6c, 0x6a, 0x00, 0x00, 0x29, 0x92, 0xe4, 0x93,
0x00, 0x9a, 0xa3, 0x00, 0x00, 0xea, 0x96, 0x48, 0x48, 0x25, 0x00, 0xea,
0xc8, 0xa1, 0xa1, 0x52, 0x00, 0x00, 0x43, 0xfe, 0x12, 0x00, 0x23, 0xff,
0x39, 0x1c, 0xff, 0x3d, 0x00, 0x1c, 0xff, 0x5c, 0x06, 0x00, 0x17, 0xa7,
0x8a, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0xc8,
0x00, 0x00, 0x25, 0xff, 0x0f, 0x00, 0x7f, 0xb8, 0x00, 0x00, 0x00, 0xf0,
0x61, 0x00, 0x00, 0x20, 0xe0, 0x7d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x84, 0xe4, 0xc4, 0xf0, 0xe2, 0xe3, 0xff, 0xe9, 0x00, 0x00, 0x00, 0x00,
0x7b, 0xdd, 0x4b, 0xf3, 0x07, 0x00, 0x47, 0xf8, 0x00, 0x00, 0x68, 0xed,
0x0b, 0x00, 0x5f, 0xe3, 0x02, 0x00, 0x5d, 0xeb, 0x00, 0x00, 0x01, 0x00,
0xaa, 0xbd, 0x00, 0x00, 0x35, 0xa5, 0xea, 0x90, 0x3f, 0x92, 0x92, 0x92,
0x92, 0x90, 0x34, 0xbe, 0xe0, 0x74, 0x10, 0x00, 0x09, 0xf0, 0x44, 0x00,
0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xf5, 0x7b, 0x10, 0x8b, 0xff, 0x39, 0x02, 0xe4, 0x8c,
0x10, 0x86, 0xff, 0x5c, 0x60, 0xd2, 0xa9, 0xea, 0xfd, 0x77, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x91, 0x00, 0x00, 0x01, 0xea,
0x87, 0x2f, 0xd5, 0x81, 0x00, 0x00, 0x00, 0xf0, 0x61, 0x00, 0x1f, 0xdf,
0x9f, 0x29, 0x29, 0x29, 0x36, 0x28, 0x04, 0x29, 0xcd, 0x9c, 0x2a, 0x35,
0x35, 0x3b, 0xff, 0x69, 0x28, 0x37, 0x09, 0x32, 0xd3, 0x81, 0x16, 0xef,
0x7f, 0x18, 0xa7, 0xaf, 0x00, 0x03, 0xdb, 0x87, 0x00, 0x00, 0x3e, 0xf5,
0x26, 0x05, 0x88, 0xc7, 0x00, 0x06, 0x1b, 0x75, 0xf4, 0x48, 0x00, 0x00,
0x00, 0x00, 0x1b, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x56,
0x04, 0x00, 0x00, 0x00, 0x5a, 0xe2, 0x02, 0x00, 0x00, 0xea, 0x81, 0x24,
0x24, 0x1a, 0x00, 0xea, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c,
0xda, 0xda, 0x71, 0xff, 0x39, 0x00, 0x68, 0xe4, 0xfa, 0xa6, 0xd0, 0x5c,
0x09, 0x38, 0x74, 0xc9, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0xb5, 0xef, 0x82, 0x10,
0x00, 0x00, 0x00, 0xf0, 0x61, 0x00, 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff,
0x5f, 0xdc, 0xfc, 0xe9, 0xa6, 0x22, 0x00, 0x00, 0x00, 0x08, 0xff, 0x41,
0x3e, 0xd7, 0xfd, 0xe4, 0x95, 0x17, 0x00, 0x47, 0xdc, 0xfb, 0xb2, 0x30,
0x00, 0x55, 0xfa, 0x1b, 0x00, 0x00, 0x00, 0x90, 0xe3, 0xf2, 0xbf, 0x3c,
0x00, 0xec, 0xfc, 0xde, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xb9, 0x85, 0x00, 0x00, 0x00, 0xea, 0xff, 0xff, 0xff, 0xba, 0x00, 0xea,
0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x1a, 0xff,
0x39, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x70,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0f, 0x0d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0xff, 0x39, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x14, 0xc2, 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x17, 0x00,
0x00, 0x00, 0x00, 0x00, 0x15, 0x43, 0x14, 0x00, 0x2d, 0x35, 0x35, 0x35,
0x35, 0x35, 0x32, 0x1b, 0x00, 0x00, 0x00, 0x26, 0x1c, 0x35, 0x35, 0x35,
0x35, 0x35, 0x00, 0x00, 0x1d, 0x17, 0x00, 0x00, 0x00, 0x00, 0x8c, 0xa9,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xbc, 0x2f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x7a,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x35, 0x35,
0x35, 0x2b, 0x0d, 0x35, 0x04, 0x35, 0x0e, 0x00, 0x12, 0x41, 0x0e, 0x00,
0x2f, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0xa1,
0xf9, 0xe4, 0xfe, 0x7c, 0xc9, 0xf0, 0xf6, 0xfe, 0xf0, 0xf0, 0x9e, 0xd1,
0x02, 0x00, 0x14, 0xf1, 0x7c, 0xf0, 0xf0, 0xf0, 0xf8, 0xff, 0x00, 0x00,
0xbd, 0xae, 0x00, 0x00, 0x00, 0x00, 0x0b, 0xb2, 0x74, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0xff, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x60, 0x60, 0x60, 0xaa, 0x33, 0xfc,
0x02, 0xf9, 0x36, 0x9f, 0xeb, 0xd6, 0xf7, 0x5d, 0xa5, 0x99, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x2b, 0xfe, 0x2d, 0x00, 0x1a, 0x15,
0x00, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x1d, 0xf7, 0x58, 0x00, 0x8a, 0xda,
0x00, 0x00, 0x00, 0x08, 0xd5, 0x9c, 0x00, 0x35, 0xc9, 0xd2, 0x34, 0x00,
0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x00, 0x03, 0x35, 0x42, 0x09, 0x00,
0x00, 0x00, 0x07, 0x38, 0x03, 0x00, 0x00, 0x00, 0x28, 0x48, 0x36, 0x36,
0x0e, 0xff, 0x40, 0x00, 0x0e, 0x36, 0x34, 0x17, 0x00, 0x00, 0x0f, 0x36,
0x25, 0x2c, 0x00, 0x00, 0x1a, 0x35, 0x33, 0x1a, 0x00, 0x00, 0x10, 0x36,
0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x95, 0x00, 0x00, 0x00, 0x95, 0x1f, 0xea, 0x00, 0xe6, 0x22, 0x1c,
0x04, 0x00, 0x7a, 0xcf, 0x46, 0xef, 0x09, 0x00, 0x00, 0x00, 0x04, 0x3e,
0x21, 0x00, 0x04, 0x36, 0x34, 0x06, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00,
0x00, 0x00, 0x24, 0xff, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0xea,
0x00, 0x00, 0x00, 0x8b, 0xd9, 0x1d, 0xf5, 0x54, 0x00, 0x00, 0x00, 0x8b,
0xe0, 0x0e, 0x00, 0xac, 0x58, 0x54, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xa7, 0xd5, 0xc6, 0xf3, 0x42, 0x00, 0x6d, 0xe1, 0xc7,
0xe1, 0x49, 0x02, 0xca, 0xbd, 0xb6, 0xff, 0xb2, 0x0e, 0xff, 0x40, 0x0c,
0xc7, 0xae, 0xba, 0xa4, 0x00, 0x00, 0x7f, 0xdf, 0x46, 0xfb, 0x38, 0x08,
0xd8, 0x97, 0xb6, 0xb1, 0x00, 0x00, 0x81, 0xe2, 0x00, 0x00, 0x58, 0xaa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
0x00, 0x95, 0x0a, 0xa3, 0x00, 0xa1, 0x0d, 0x00, 0x00, 0x02, 0xa9, 0xb9,
0x03, 0xe3, 0x58, 0x00, 0x00, 0x70, 0xe7, 0xdd, 0xf7, 0x11, 0xe9, 0xe3,
0xd8, 0xcf, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x84,
0xfb, 0xb6, 0x33, 0x00, 0x00, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x00, 0x12,
0xef, 0xd9, 0xc8, 0x01, 0x00, 0x00, 0x3b, 0xfb, 0x42, 0x00, 0x26, 0xdf,
0x04, 0x02, 0xd1, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
0x00, 0x00, 0xa7, 0xa5, 0x07, 0xf1, 0x3f, 0x00, 0x77, 0xba, 0x45, 0xf4,
0x06, 0x01, 0xe9, 0x66, 0x0e, 0xff, 0x45, 0xbc, 0xbb, 0x07, 0x59, 0xf3,
0x0a, 0x00, 0xd8, 0x80, 0x00, 0x95, 0xd5, 0x8f, 0xdb, 0x0b, 0x50, 0xf9,
0x13, 0x00, 0xd8, 0x85, 0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x2c, 0xb1,
0xcf, 0x88, 0x4c, 0x89, 0x00, 0x95, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x9a, 0xd6, 0x1d, 0x00, 0x86, 0xb7, 0x00,
0x07, 0xf1, 0x62, 0x00, 0x06, 0x58, 0xf8, 0x20, 0x00, 0x08, 0x00, 0x00,
0x00, 0xea, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0xbe, 0xfe, 0x5a,
0x00, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x00, 0x00, 0x79, 0xff, 0x40, 0x00,
0x00, 0x0a, 0xda, 0x92, 0x00, 0x00, 0x9a, 0x75, 0x00, 0x00, 0x53, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x8b, 0xbf, 0xe6, 0xc5,
0x49, 0xfe, 0xc3, 0xc2, 0xd2, 0xfc, 0x36, 0xfe, 0x39, 0x2b, 0xf8, 0x29,
0x0e, 0xff, 0xc7, 0xf9, 0x18, 0x00, 0x09, 0xef, 0x57, 0x32, 0xfd, 0x20,
0x00, 0x0b, 0xe0, 0xff, 0x3d, 0x00, 0x04, 0xe5, 0x69, 0x31, 0xfe, 0x25,
0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x49, 0x3a, 0x47, 0x91, 0xbd, 0x67,
0x00, 0x95, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x43, 0xe6, 0x15, 0x00, 0x00, 0x28, 0xfb, 0x1a, 0x4a, 0xfb, 0x0d, 0x00,
0x00, 0x11, 0xc2, 0xf4, 0x90, 0x19, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0xbe, 0x00, 0x00, 0x6c, 0xea,
0x00, 0x00, 0x00, 0x00, 0x47, 0xff, 0x12, 0x00, 0x00, 0x91, 0xda, 0x0a,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x27, 0xfc, 0x6a, 0x1e, 0x9a, 0xc5, 0x3b, 0xfd, 0x42, 0x31,
0x31, 0x31, 0x00, 0x9f, 0xe5, 0xb3, 0x5d, 0x00, 0x0e, 0xff, 0xac, 0xd2,
0xa4, 0x00, 0x00, 0x97, 0xac, 0x88, 0xbc, 0x00, 0x00, 0x2b, 0xf7, 0xee,
0x75, 0x00, 0x00, 0x82, 0xbf, 0x86, 0xc3, 0x00, 0x00, 0x00, 0x58, 0xaa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
0x00, 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x5b, 0x00, 0x00,
0x00, 0x00, 0xc7, 0x76, 0x40, 0xfe, 0x15, 0x00, 0x00, 0x00, 0x01, 0x4f,
0xd1, 0xdf, 0x00, 0x00, 0x00, 0xea, 0x83, 0x27, 0x27, 0x23, 0x39, 0x44,
0x14, 0x2b, 0xd1, 0x7b, 0x00, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x00, 0x00,
0x47, 0xff, 0x12, 0x00, 0x40, 0xfd, 0x60, 0x27, 0x27, 0x27, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0xf6,
0x0f, 0x1f, 0xe4, 0xc5, 0x01, 0xe0, 0x89, 0x0e, 0x07, 0x31, 0x08, 0xfa,
0x4e, 0x24, 0x0a, 0x00, 0x0e, 0xff, 0x40, 0x2b, 0xf5, 0x65, 0x00, 0x36,
0xef, 0xd1, 0x5b, 0x00, 0x05, 0xcd, 0x9e, 0x4b, 0xf8, 0x2d, 0x00, 0x1e,
0xf6, 0xda, 0x63, 0x00, 0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x68, 0xd4,
0x04, 0xec, 0x8a, 0x14, 0x3f, 0x27, 0x2c, 0x01, 0x54, 0xee, 0x00, 0x00,
0x00, 0xea, 0xff, 0xff, 0xff, 0xe6, 0x51, 0xdb, 0xfd, 0xea, 0xa3, 0x11,
0x00, 0x00, 0x6c, 0xea, 0x00, 0x00, 0x00, 0x00, 0x47, 0xff, 0x12, 0x00,
0xa0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc8, 0xf7, 0xdf, 0x83, 0xc5,
0x00, 0x3f, 0xae, 0xf4, 0xfc, 0x9f, 0x0a, 0xd2, 0xfc, 0xfb, 0xf7, 0x90,
0x0e, 0xff, 0x40, 0x00, 0x65, 0xf6, 0x00, 0x00, 0xd4, 0xf0, 0x09, 0x00,
0x83, 0xe5, 0x10, 0x00, 0xa2, 0xd0, 0x00, 0x00, 0xb4, 0xf4, 0x0d, 0x00,
0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xc6, 0x95, 0x95, 0x95, 0xb6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x82, 0xe8, 0x00, 0x00, 0x00, 0x00, 0x11, 0xf7, 0x00, 0x4f, 0xbf, 0xfe,
0xf1, 0x57, 0xe9, 0xf3, 0xde, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0x0a, 0x00, 0xaa, 0x94, 0x08, 0x02, 0x4e, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x06, 0xbf, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x58, 0xaa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x0f,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xae,
0x37, 0x49, 0xae, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0xc3,
0xf1, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x58, 0xaa, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x79, 0xb0, 0x96, 0x5c, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x89, 0x9f, 0x3a, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3d, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0xff, 0x5a, 0xff, 0x8f, 0x00,
0x00, 0x00, 0xff, 0x8f, 0x00, 0x00, 0x00, 0x8f, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3c, 0xaa, 0x3c, 0x8f, 0xff, 0x8f, 0x00, 0x00, 0x8f, 0xff,
0x8f, 0x00, 0x8f, 0xff, 0x8f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x8f, 0xff, 0x8f, 0x00, 0x00, 0x8f, 0xff, 0x8f, 0xff, 0x8f,
0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x6e, 0xaa, 0x00, 0x3c, 0xaa, 0x3c, 0x00, 0x00, 0x8f,
0xff, 0x8f, 0x00, 0x00, 0x8f, 0xff, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x86, 0xbd, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x17,
0x00, 0x00, 0x00, 0x0a, 0x35, 0x13, 0x00, 0x00, 0x30, 0x20, 0x1d, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x31, 0x17, 0x00, 0x33, 0x15, 0x07, 0x35, 0x35,
0x26, 0x35, 0x31, 0x03, 0x7f, 0x18, 0x03, 0x7f, 0x18, 0x0b, 0xbc, 0x31,
0x00, 0x00, 0x0d, 0x35, 0x00, 0x00, 0x00, 0x5e, 0xff, 0x70, 0x00, 0x00,
0x00, 0x00, 0x70, 0xff, 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5,
0xff, 0x00, 0x5a, 0xff, 0x5a, 0x00, 0x8f, 0xff, 0x8f, 0x00, 0x00, 0x00,
0x00, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x81, 0xd8, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4f, 0x3b, 0x00, 0x00, 0x00, 0xb5, 0xf5, 0xb0, 0xe7, 0x28, 0x00, 0x26,
0xff, 0x55, 0x00, 0x3e, 0xe7, 0x4c, 0xdc, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xea, 0x6d, 0x00, 0xf4, 0x64, 0x22, 0xff, 0xcb, 0x8e, 0xd6, 0xeb, 0x0b,
0xc5, 0x2f, 0x0b, 0xc5, 0x2f, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x33, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x70, 0xff, 0x70, 0x00, 0x00, 0x70, 0xff, 0x70,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x8f, 0xff, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x17, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x07,
0xcd, 0xa8, 0x36, 0x03, 0x35, 0x00, 0x24, 0x0b, 0xcf, 0x85, 0x36, 0x00,
0x32, 0xfd, 0x1b, 0x01, 0xbb, 0x85, 0x00, 0x19, 0xff, 0x48, 0x01, 0xca,
0x70, 0x01, 0xca, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x2c, 0x09, 0x00, 0x2c, 0x08, 0x00, 0xea, 0x6d, 0x00, 0xf4,
0x64, 0x22, 0xff, 0x12, 0x00, 0x46, 0xeb, 0x03, 0x36, 0x0e, 0x03, 0x36,
0x0e, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x1f, 0xea, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0xff, 0x70, 0x70, 0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x55, 0x37, 0x00, 0x37, 0x55, 0x00, 0x1e, 0x55, 0x1e, 0xff, 0x8f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0xcc,
0xcc, 0xe8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x98, 0xf3, 0xe6, 0xc9, 0x0e,
0xff, 0x85, 0xfc, 0x93, 0xfb, 0xde, 0xc9, 0x00, 0x41, 0xf6, 0x00, 0x00,
0x9e, 0x99, 0x00, 0x0c, 0xff, 0x3c, 0x2c, 0xff, 0x0f, 0x00, 0x69, 0xd0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0xf8, 0x54,
0x20, 0xf8, 0x51, 0x00, 0xea, 0x6d, 0x00, 0xf4, 0x64, 0x22, 0xff, 0x12,
0x00, 0x46, 0xeb, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43,
0x00, 0x00, 0x0a, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff,
0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xa5, 0x00, 0xa5,
0xff, 0x00, 0x5a, 0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0xe6, 0x6f, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc7, 0x8b, 0x00, 0x0e, 0xff, 0xc7, 0x1f, 0x00,
0xee, 0x64, 0x00, 0x00, 0x64, 0xe7, 0x00, 0x00, 0x8f, 0xba, 0x00, 0x01,
0xfd, 0x2f, 0x54, 0xe5, 0x00, 0x00, 0x41, 0xf6, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x45, 0x09, 0x03, 0x46, 0x09, 0x00,
0xea, 0x6d, 0x00, 0xf4, 0x64, 0x22, 0xff, 0x12, 0x00, 0x46, 0xeb, 0x0e,
0xff, 0x43, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff, 0xff, 0x70, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x55, 0x37, 0x00, 0x37, 0x55, 0x00, 0x1e, 0x55,
0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xb1, 0xb6, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc7, 0x8b, 0x00, 0x0e, 0xff, 0x5d, 0x00, 0x00, 0xee, 0x64, 0x00, 0x9b,
0xe8, 0x53, 0x00, 0x00, 0x23, 0xc4, 0xd7, 0x00, 0xf1, 0x22, 0x7b, 0xbe,
0x00, 0x00, 0x1a, 0xff, 0x00, 0x00, 0x00, 0x62, 0xa4, 0xa4, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0xf4,
0x64, 0x22, 0xff, 0x12, 0x00, 0x46, 0xeb, 0x0e, 0xff, 0x43, 0x0e, 0xff,
0x43, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x70, 0xff, 0x70, 0x70, 0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69,
0xe8, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc7, 0x8b, 0x00, 0x0e,
0xff, 0x43, 0x00, 0x00, 0xee, 0x64, 0x00, 0x52, 0xcc, 0xa7, 0x00, 0x00,
0x4e, 0xea, 0x76, 0x00, 0x75, 0x0c, 0x6f, 0xca, 0x00, 0x00, 0x26, 0xff,
0x00, 0x00, 0x00, 0x49, 0x7a, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xea, 0x6d, 0x00, 0xf4, 0x64, 0x22, 0xff, 0x12,
0x00, 0x46, 0xeb, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff, 0x70, 0x00,
0x00, 0x70, 0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0xf5, 0x4c, 0x03, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0xc7, 0x8b, 0x00, 0x0e, 0xff, 0x43, 0x00, 0x00,
0xd0, 0x8f, 0x05, 0x00, 0x4a, 0xf5, 0x00, 0x00, 0x99, 0xa2, 0x00, 0x08,
0x75, 0x17, 0x47, 0xf2, 0x01, 0x00, 0x4e, 0xeb, 0x09, 0x56, 0x17, 0x00,
0x00, 0x00, 0x08, 0x75, 0x17, 0x08, 0x75, 0x17, 0x09, 0x56, 0x17, 0x00,
0xea, 0x6d, 0x00, 0xf4, 0x64, 0x22, 0xff, 0x12, 0x00, 0x46, 0xeb, 0x0e,
0xff, 0x43, 0x0e, 0xff, 0x43, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x5e, 0xff, 0x70, 0x00, 0x00, 0x00, 0x00, 0x70, 0xff,
0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x9a, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc7, 0x8b, 0x00, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x62, 0xee, 0xfc, 0x00,
0x41, 0xf7, 0x00, 0x00, 0x9f, 0x99, 0x00, 0x27, 0xfe, 0x4f, 0x1a, 0xfc,
0x27, 0x00, 0x82, 0xba, 0x3d, 0xf9, 0x14, 0x00, 0x00, 0x00, 0x27, 0xfe,
0x4f, 0x27, 0xfe, 0x4f, 0x3d, 0xf9, 0x14, 0x00, 0xea, 0x6d, 0x00, 0xf6,
0x60, 0x22, 0xff, 0x12, 0x00, 0x46, 0xeb, 0x0e, 0xff, 0x43, 0x0e, 0xff,
0x43, 0x0e, 0xff, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14,
0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5c, 0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0e, 0x00, 0x13, 0xf7, 0x74, 0x3a,
0xe1, 0x6d, 0x00, 0x00, 0x12, 0x00, 0x00, 0x97, 0x9e, 0x0d, 0xeb, 0x3d,
0x71, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x12, 0x00,
0x71, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x33, 0xff, 0x25, 0x22, 0xff, 0x3c,
0x20, 0x67, 0xeb, 0x00, 0x00, 0x00, 0x17, 0xff, 0x42, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1,
0xc1, 0xc1, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0xa8, 0x8b, 0x86, 0x0d, 0x00, 0x00,
0x00, 0x00, 0x00, 0x16, 0xc8, 0x5c, 0x97, 0x00, 0x49, 0x33, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x33, 0x00, 0x00,
0x00, 0x00, 0xf9, 0xad, 0x00, 0x1c, 0xd1, 0xd1, 0x95, 0xd1, 0xc0, 0x00,
0x00, 0x00, 0xba, 0xf7, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static mu_Rect atlas[] = {
[MU_ICON_CLOSE] = { 88, 68, 16, 16 },
[MU_ICON_CHECK] = { 0, 0, 18, 18 },
[MU_ICON_EXPANDED] = { 118, 68, 7, 5 },
[MU_ICON_COLLAPSED] = { 113, 68, 5, 7 },
[ATLAS_WHITE] = { 125, 68, 3, 3 },
[ATLAS_FONT + 32] = { 84, 68, 2, 17 },
[ATLAS_FONT + 33] = { 39, 68, 3, 17 },
[ATLAS_FONT + 34] = { 114, 51, 5, 17 },
[ATLAS_FONT + 35] = { 34, 17, 7, 17 },
[ATLAS_FONT + 36] = { 28, 34, 6, 17 },
[ATLAS_FONT + 37] = { 58, 0, 9, 17 },
[ATLAS_FONT + 38] = { 103, 0, 8, 17 },
[ATLAS_FONT + 39] = { 86, 68, 2, 17 },
[ATLAS_FONT + 40] = { 42, 68, 3, 17 },
[ATLAS_FONT + 41] = { 45, 68, 3, 17 },
[ATLAS_FONT + 42] = { 34, 34, 6, 17 },
[ATLAS_FONT + 43] = { 40, 34, 6, 17 },
[ATLAS_FONT + 44] = { 48, 68, 3, 17 },
[ATLAS_FONT + 45] = { 51, 68, 3, 17 },
[ATLAS_FONT + 46] = { 54, 68, 3, 17 },
[ATLAS_FONT + 47] = { 124, 34, 4, 17 },
[ATLAS_FONT + 48] = { 46, 34, 6, 17 },
[ATLAS_FONT + 49] = { 52, 34, 6, 17 },
[ATLAS_FONT + 50] = { 58, 34, 6, 17 },
[ATLAS_FONT + 51] = { 64, 34, 6, 17 },
[ATLAS_FONT + 52] = { 70, 34, 6, 17 },
[ATLAS_FONT + 53] = { 76, 34, 6, 17 },
[ATLAS_FONT + 54] = { 82, 34, 6, 17 },
[ATLAS_FONT + 55] = { 88, 34, 6, 17 },
[ATLAS_FONT + 56] = { 94, 34, 6, 17 },
[ATLAS_FONT + 57] = { 100, 34, 6, 17 },
[ATLAS_FONT + 58] = { 57, 68, 3, 17 },
[ATLAS_FONT + 59] = { 60, 68, 3, 17 },
[ATLAS_FONT + 60] = { 106, 34, 6, 17 },
[ATLAS_FONT + 61] = { 112, 34, 6, 17 },
[ATLAS_FONT + 62] = { 118, 34, 6, 17 },
[ATLAS_FONT + 63] = { 119, 51, 5, 17 },
[ATLAS_FONT + 64] = { 18, 0, 10, 17 },
[ATLAS_FONT + 65] = { 41, 17, 7, 17 },
[ATLAS_FONT + 66] = { 48, 17, 7, 17 },
[ATLAS_FONT + 67] = { 55, 17, 7, 17 },
[ATLAS_FONT + 68] = { 111, 0, 8, 17 },
[ATLAS_FONT + 69] = { 0, 35, 6, 17 },
[ATLAS_FONT + 70] = { 6, 35, 6, 17 },
[ATLAS_FONT + 71] = { 119, 0, 8, 17 },
[ATLAS_FONT + 72] = { 18, 17, 8, 17 },
[ATLAS_FONT + 73] = { 63, 68, 3, 17 },
[ATLAS_FONT + 74] = { 66, 68, 3, 17 },
[ATLAS_FONT + 75] = { 62, 17, 7, 17 },
[ATLAS_FONT + 76] = { 12, 51, 6, 17 },
[ATLAS_FONT + 77] = { 28, 0, 10, 17 },
[ATLAS_FONT + 78] = { 67, 0, 9, 17 },
[ATLAS_FONT + 79] = { 76, 0, 9, 17 },
[ATLAS_FONT + 80] = { 69, 17, 7, 17 },
[ATLAS_FONT + 81] = { 85, 0, 9, 17 },
[ATLAS_FONT + 82] = { 76, 17, 7, 17 },
[ATLAS_FONT + 83] = { 18, 51, 6, 17 },
[ATLAS_FONT + 84] = { 24, 51, 6, 17 },
[ATLAS_FONT + 85] = { 26, 17, 8, 17 },
[ATLAS_FONT + 86] = { 83, 17, 7, 17 },
[ATLAS_FONT + 87] = { 38, 0, 10, 17 },
[ATLAS_FONT + 88] = { 90, 17, 7, 17 },
[ATLAS_FONT + 89] = { 30, 51, 6, 17 },
[ATLAS_FONT + 90] = { 36, 51, 6, 17 },
[ATLAS_FONT + 91] = { 69, 68, 3, 17 },
[ATLAS_FONT + 92] = { 124, 51, 4, 17 },
[ATLAS_FONT + 93] = { 72, 68, 3, 17 },
[ATLAS_FONT + 94] = { 42, 51, 6, 17 },
[ATLAS_FONT + 95] = { 15, 68, 4, 17 },
[ATLAS_FONT + 96] = { 48, 51, 6, 17 },
[ATLAS_FONT + 97] = { 54, 51, 6, 17 },
[ATLAS_FONT + 98] = { 97, 17, 7, 17 },
[ATLAS_FONT + 99] = { 0, 52, 5, 17 },
[ATLAS_FONT + 100] = { 104, 17, 7, 17 },
[ATLAS_FONT + 101] = { 60, 51, 6, 17 },
[ATLAS_FONT + 102] = { 19, 68, 4, 17 },
[ATLAS_FONT + 103] = { 66, 51, 6, 17 },
[ATLAS_FONT + 104] = { 111, 17, 7, 17 },
[ATLAS_FONT + 105] = { 75, 68, 3, 17 },
[ATLAS_FONT + 106] = { 78, 68, 3, 17 },
[ATLAS_FONT + 107] = { 72, 51, 6, 17 },
[ATLAS_FONT + 108] = { 81, 68, 3, 17 },
[ATLAS_FONT + 109] = { 48, 0, 10, 17 },
[ATLAS_FONT + 110] = { 118, 17, 7, 17 },
[ATLAS_FONT + 111] = { 0, 18, 7, 17 },
[ATLAS_FONT + 112] = { 7, 18, 7, 17 },
[ATLAS_FONT + 113] = { 14, 34, 7, 17 },
[ATLAS_FONT + 114] = { 23, 68, 4, 17 },
[ATLAS_FONT + 115] = { 5, 52, 5, 17 },
[ATLAS_FONT + 116] = { 27, 68, 4, 17 },
[ATLAS_FONT + 117] = { 21, 34, 7, 17 },
[ATLAS_FONT + 118] = { 78, 51, 6, 17 },
[ATLAS_FONT + 119] = { 94, 0, 9, 17 },
[ATLAS_FONT + 120] = { 84, 51, 6, 17 },
[ATLAS_FONT + 121] = { 90, 51, 6, 17 },
[ATLAS_FONT + 122] = { 10, 68, 5, 17 },
[ATLAS_FONT + 123] = { 31, 68, 4, 17 },
[ATLAS_FONT + 124] = { 96, 51, 6, 17 },
[ATLAS_FONT + 125] = { 35, 68, 4, 17 },
[ATLAS_FONT + 126] = { 102, 51, 6, 17 },
[ATLAS_FONT + 127] = { 108, 51, 6, 17 },
};
+1 -1
View File
@@ -361,7 +361,7 @@ static void tone_map_data_calculate(tone_map_data* tmd) {
vec3 tone_trans, tone_trans_scale, tone_trans_offset;
vec3_sub(tmd->tone_trans_end, tmd->tone_trans_start, tone_trans);
vec3_div(vec3_identity, tone_trans, tone_trans_scale);
vec3_rcp(tone_trans, tone_trans_scale);
vec3_mult(tone_trans_scale, tmd->tone_trans_start, tone_trans_offset);
vec3_negate(tone_trans_offset, tone_trans_offset);
+260 -31
View File
@@ -5,7 +5,159 @@
#include "shader.h"
#include "../CRE/hash.h"
#include "../KKdLib/io_path.h"
#include "../KKdLib/str_utils.h"
static const char* process_mat_string =
"uniform bool use_bones;\n"
"\n"
"uniform sampler2D BoneMatrix;\n"
"\n"
"vec4 P = vec4(0.0);\n"
"vec3 N = vec3(0.0);\n"
"vec3 T = vec3(0.0);\n"
"\n"
"vec4 position;\n"
"vec3 normal;\n"
"vec3 tangent;\n"
"\n"
"void getBone(int bone_index, float bone_weight)\n"
"{\n"
" vec4 v0 = texelFetch(BoneMatrix, ivec2(0, bone_index), 0);\n"
" vec4 v1 = texelFetch(BoneMatrix, ivec2(1, bone_index), 0);\n"
" vec4 v2 = texelFetch(BoneMatrix, ivec2(2, bone_index), 0);\n"
" vec4 v3 = texelFetch(BoneMatrix, ivec2(3, bone_index), 0);\n"
" vec3 v4 = texelFetch(BoneMatrix, ivec2(4, bone_index), 0).xyz;\n"
" vec3 v5 = texelFetch(BoneMatrix, ivec2(5, bone_index), 0).xyz;\n"
" vec3 v6 = texelFetch(BoneMatrix, ivec2(6, bone_index), 0).xyz;\n"
" mat4 model_bone = mat4(v0, v1, v2, v3);\n"
" mat3 model_bone_normal = mat3(v4, v5, v6);\n"
" P += (model_bone * position) * bone_weight;\n"
" N += (model_bone_normal * normal) * bone_weight;\n"
" T += (model_bone_normal * tangent) * bone_weight;\n"
"}\n"
"\n"
"void PROCESSMAT()\n"
"{\n"
" if (use_bones && (aBoneWeight[0] != 0.0 || aBoneWeight[1] != 0.0 || aBoneWeight[2] != 0.0 || aBoneWeight[3] != 0.0))\n"
" {\n"
" P = vec4(0.0);\n"
" N = vec3(0.0);\n"
" T = vec3(0.0);\n"
" if (aBoneWeight[0] != 0.0)\n"
" getBone(int(aBoneIndex[0]), aBoneWeight[0]);\n"
" if (aBoneWeight[1] != 0.0)\n"
" getBone(int(aBoneIndex[1]), aBoneWeight[1]);\n"
" if (aBoneWeight[2] != 0.0)\n"
" getBone(int(aBoneIndex[2]), aBoneWeight[2]);\n"
" if (aBoneWeight[3] != 0.0)\n"
" getBone(int(aBoneIndex[3]), aBoneWeight[3]);\n"
"\n"
" N = normalize(N);\n"
" T = normalize(T);\n"
" T = normalize(T - dot(N, T) * N);\n"
" }\n"
" else\n"
" {\n"
" P = position;\n"
" N = normal;\n"
" T = tangent;\n"
" }\n"
"\n"
" P = model * P;\n"
" N = model_normal * N;\n"
" T = model_normal * T;\n"
"\n"
" N = normalize(N);\n"
" T = normalize(T);\n"
" T = normalize(T - dot(N, T) * N);\n"
"}";
static const char* tex_decode_string =
"uniform sampler2D[8] material;\n"
"uniform int[8] tex_mode;\n"
"\n"
"// Tex ID\n"
"// 0 - diffuse\n"
"// 1 - specular\n"
"// 2 - displacement\n"
"// 3 - normal\n"
"// 4 - albedo\n"
"// 5 - ao\n"
"// 6 - metallic\n"
"// 7 - roughness\n"
"\n"
"// Tex Mode\n"
"// 0 - default\n"
"// 1 - YCbCr BC4\n"
"// 2 - YCbCr BC5\n"
"// 3 - Normal Map BC5 Unsigned\n"
"// 4 - Normal Map BC5 Signed\n"
"// 5 - Normal Map Unsigned\n"
"// 6 - Normal Map Signed\n"
"\n"
"const vec3 _red_coef_709 = vec3( 1.5748, 1.0, 0.0000);\n"
"const vec3 _grn_coef_709 = vec3(-0.4681, 1.0, -0.1873);\n"
"const vec3 _blu_coef_709 = vec3( 0.0000, 1.0, 1.8556);\n"
"\n"
"const float cbcr_mult = 256.0 / 255.0;\n"
"const float cbcr_sub = 128.5 / 255.0;\n"
"\n"
"vec4 TEXDECODE(int id, vec2 uv)\n"
"{\n"
" vec4 data = vec4(0.0);\n"
" int mode = tex_mode[id];\n"
" if (mode == 1)\n"
" {\n"
" vec3 tmp;\n"
" tmp.y = textureLod(material[id], uv, 0).x;\n"
" tmp.x = textureLod(material[id], uv, 1).x;\n"
" tmp.z = textureLod(material[id], uv, 2).x;\n"
" tmp.xz = tmp.xz * cbcr_mult - cbcr_sub;\n"
"\n"
" vec4 c;\n"
" c.r = dot(tmp.xyz, _red_coef_709);\n"
" c.g = dot(tmp.xyz, _grn_coef_709);\n"
" c.b = dot(tmp.xyz, _blu_coef_709);\n"
" c.a = 1.0;\n"
" data = c;\n"
" }\n"
" else if (mode == 2)\n"
" {\n"
" vec4 tmp;\n"
" tmp.yw = textureLod(material[id], uv, 0).xy;\n"
" tmp.xz = textureLod(material[id], uv, 1).yx;\n"
" tmp.xz = tmp.xz * cbcr_mult - cbcr_sub;\n"
"\n"
" vec4 c;\n"
" c.r = dot(tmp.xyz, _red_coef_709);\n"
" c.g = dot(tmp.xyz, _grn_coef_709);\n"
" c.b = dot(tmp.xyz, _blu_coef_709);\n"
" c.a = tmp.a;\n"
" data = c;\n"
" }\n"
" else if (mode == 3)\n"
" {\n"
" vec3 normal;\n"
" normal.xy = texture(material[id], uv).xy * 2.0 - 1.0;\n"
" normal.z = sqrt(1.0 - normal.x * normal.x - normal.y * normal.y);\n"
" data = vec4(normal, 0.0);\n"
" }\n"
" else if (mode == 4)\n"
" {\n"
" vec3 normal;\n"
" normal.xy = texture(material[id], uv).xy;\n"
" normal.z = sqrt(1.0 - normal.x * normal.x - normal.y * normal.y);\n"
" data = vec4(normal, 0.0);\n"
" }\n"
" else if (mode == 5)\n"
" {\n"
" vec3 normal = texture(material[id], uv).xyz * 2.0 - 1.0;\n"
" data = vec4(normal, 0.0);\n"
" }\n"
" else\n"
" data = texture(material[id], uv);\n"
" return data;\n"
"}";
static int32_t program = 0;
@@ -21,7 +173,7 @@ static char* shader_parse_define(char* data, shader_param* param) {
for (size_t i = 0; i < s; i++)
if (param->param[i]) {
sprintf_s(temp, 0x100, "#define %s\n", param->param[i]);
sprintf_s(temp, sizeof(temp), "#define %s\n", param->param[i]);
temp_len[i] = strlen(temp);
}
else
@@ -30,28 +182,54 @@ static char* shader_parse_define(char* data, shader_param* param) {
char* def = strstr(data, "//DEF\n");
if (!def)
return data;
size_t len_b = def - data;
size_t len_a = def - data;
def += 5;
size_t len_a = strlen(def);
size_t len_b = strlen(def);
size_t len = 0;
for (size_t i = 0; i < s; i++)
len += temp_len[i];
if (!len)
def++;
len += len_b + len_a;
len += len_a + len_b;
char* temp_data = force_malloc(len + 1);
size_t pos = 0;
memcpy(temp_data + pos, data, len_b);
pos += len_b;
memcpy(temp_data + pos, data, len_a);
pos += len_a;
for (size_t i = 0; i < s; i++) {
if (param->param[i]) {
sprintf_s(temp, 0x100, "#define %s\n", param->param[i]);
memcpy(temp_data + pos, temp, len_b);
sprintf_s(temp, sizeof(temp), "#define %s\n", param->param[i]);
memcpy(temp_data + pos, temp, len_a);
}
pos += temp_len[i];
}
memcpy(temp_data + pos, def, len_a);
memcpy(temp_data + pos, def, len_b);
free(data);
return temp_data;
}
static char* shader_parse(char* data, char* parse_string, const char* replace_string) {
if (!data)
return data;
char* def = strstr(data, parse_string);
if (!def)
return data;
size_t len_a = def - data;
def += strlen(parse_string);
size_t len_b = strlen(replace_string);
size_t len_c = strlen(def);
size_t len = len_a + len_b + len_c;
char* temp_data = force_malloc(len + 1);
size_t pos = 0;
memcpy(temp_data + pos, data, len_a);
pos += len_a;
memcpy(temp_data + pos, replace_string, len_b);
pos += len_b;
memcpy(temp_data + pos, def, len_c);
free(data);
return temp_data;
}
@@ -67,16 +245,32 @@ static GLuint shader_compile(GLenum type, char* data) {
}
void shader_fbo_load(shader_fbo* s, farc* f, shader_param* param) {
wchar_t_buffer_init(&s->name, param->name);
wchar_t* temp_frag = path_wadd_extension(param->frag, L".frag");
wchar_t* temp_vert = path_wadd_extension(param->vert, L".vert");
wchar_t* temp_geom = path_wadd_extension(param->geom, L".geom");
if (!s || !f || !param)
return;
wchar_t temp[0x1000];
temp[0] = 0;
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), param->name);
for (size_t i = 0; i < SHADER_PARAM_NUM_PARAMS; i++)
if (param->param[i]) {
wchar_t* t = char_string_to_wchar_t_string(param->param[i]);
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), L"#");
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), t);
free(t);
}
else
break;
wchar_t_buffer_init(&s->name, temp);
wchar_t* temp_frag = str_utils_wadd(param->frag, L".frag");
wchar_t* temp_vert = str_utils_wadd(param->vert, L".vert");
wchar_t* temp_geom = str_utils_wadd(param->geom, L".geom");
farc_file* frag = farc_wread_file(f, temp_frag);
farc_file* vert = farc_wread_file(f, temp_vert);
farc_file* geom = farc_wread_file(f, temp_geom);
size_t frag_length = !frag ? 0 : frag->size_uncompressed;
size_t vert_length = !vert ? 0 : vert->size_uncompressed;
size_t geom_length = !geom ? 0 : geom->size_uncompressed;
size_t frag_length = !frag ? 0 : frag->size;
size_t vert_length = !vert ? 0 : vert->size;
size_t geom_length = !geom ? 0 : geom->size;
char* frag_data = !frag ? 0 : force_malloc(frag_length + 1);
char* vert_data = !vert ? 0 : force_malloc(vert_length + 1);
char* geom_data = !geom ? 0 : force_malloc(geom_length + 1);
@@ -126,8 +320,11 @@ void shader_fbo_load(shader_fbo* s, farc* f, shader_param* param) {
glGetProgramiv(s->program, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(s->program, 0x200, 0, info_log);
wprintf(L"Program Shader linking error: %ls\n", param->name);
printf("%s\n", info_log);
printf("Program FBO Shader linking error: ");
wprintf(param->name);
putchar('\n');
printf(info_log);
putchar('\n');
}
if (frag_shad)
@@ -138,7 +335,7 @@ void shader_fbo_load(shader_fbo* s, farc* f, shader_param* param) {
glDeleteShader(geom_shad);
}
void shader_fbo_use(shader_fbo* s) {
inline void shader_fbo_use(shader_fbo* s) {
if (s) {
if (program == s->program)
return;
@@ -178,7 +375,23 @@ void shader_fbo_free(shader_fbo* s) {
}
void shader_model_load(shader_model* s, shader_model_update* upd) {
wchar_t_buffer_init(&s->name, upd->param.name);
if (!s || !upd)
return;
wchar_t temp[0x1000];
temp[0] = 0;
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), upd->param.name);
for (size_t i = 0; i < SHADER_PARAM_NUM_PARAMS; i++)
if (upd->param.param[i]) {
wchar_t* t = char_string_to_wchar_t_string(upd->param.param[i]);
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), L"#");
wcscat_s(temp, sizeof(temp) / sizeof(wchar_t), t);
free(t);
}
else
break;
wchar_t_buffer_init(&s->name, temp);
size_t frag_c_length = !upd->frag_c ? 0 : strlen(upd->frag_c);
size_t frag_g_length = !upd->frag_g ? 0 : strlen(upd->frag_g);
size_t vert_length = !upd->vert ? 0 : strlen(upd->vert);
@@ -213,6 +426,13 @@ void shader_model_load(shader_model* s, shader_model_update* upd) {
vert_data = shader_parse_define(vert_data, &upd->param);
geom_data = shader_parse_define(geom_data, &upd->param);
vert_data = shader_parse(vert_data, "//PROCESSMAT", process_mat_string);
frag_c_data = shader_parse(frag_c_data, "//TEXDECODE", tex_decode_string);
frag_g_data = shader_parse(frag_g_data, "//TEXDECODE", tex_decode_string);
vert_data = shader_parse(vert_data, "//TEXDECODE", tex_decode_string);
geom_data = shader_parse(geom_data, "//TEXDECODE", tex_decode_string);
GLuint frag_c_shad = shader_compile(GL_FRAGMENT_SHADER, frag_c_data);
GLuint frag_g_shad = shader_compile(GL_FRAGMENT_SHADER, frag_g_data);
GLuint vert_shad = shader_compile(GL_VERTEX_SHADER, vert_data);
@@ -224,7 +444,6 @@ void shader_model_load(shader_model* s, shader_model_update* upd) {
free(geom_data);
GLint success;
GLchar info_log[0x200];
s->c_program = glCreateProgram();
s->g_program = glCreateProgram();
if (frag_c_shad)
@@ -237,9 +456,14 @@ void shader_model_load(shader_model* s, shader_model_update* upd) {
glGetProgramiv(s->c_program, GL_LINK_STATUS, &success);
if (!success) {
glGetProgramInfoLog(s->c_program, 0x200, 0, info_log);
wprintf(L"Program C Shader linking error: %ls\n", upd->param.name);
printf("%s\n", info_log);
GLchar* info_log = force_malloc(0x10000);
glGetProgramInfoLog(s->c_program, 0x10000, 0, info_log);
printf("Program C Shader linking error: ");
wprintf(upd->param.name);
putchar('\n');
printf(info_log);
putchar('\n');
free(info_log);
}
if (frag_g_shad)
@@ -252,9 +476,14 @@ void shader_model_load(shader_model* s, shader_model_update* upd) {
glGetProgramiv(s->g_program, GL_LINK_STATUS, &success);
if (!success) {
GLchar* info_log = force_malloc(0x10000);
glGetProgramInfoLog(s->g_program, 0x200, 0, info_log);
wprintf(L"Program G Shader linking error: %ls\n", upd->param.name);
printf("%s\n", info_log);
printf("Program G Shader linking error: ");
wprintf(upd->param.name);
putchar('\n');
printf(info_log);
putchar('\n');
free(info_log);
}
if (frag_c_shad)
@@ -267,7 +496,7 @@ void shader_model_load(shader_model* s, shader_model_update* upd) {
glDeleteShader(geom_shad);
}
void shader_model_c_use(shader_model* s) {
inline void shader_model_c_use(shader_model* s) {
if (s) {
if (program == s->c_program)
return;
@@ -281,7 +510,7 @@ void shader_model_c_use(shader_model* s) {
}
}
void shader_model_g_use(shader_model* s) {
inline void shader_model_g_use(shader_model* s) {
if (s) {
if (program == s->g_program)
return;
@@ -302,7 +531,7 @@ GLint shader_model_c_get_uniform_location(shader_model* s, GLchar* name) {
shader_model_c_use(s);
GLint location = glGetUniformLocation(s->c_program, name);
if (location == -1)
printf("Location \"%s\" in program %d isn't found", name, s->c_program);;
printf("Location \"%s\" in program %d isn't found\n", name, s->c_program);;
return location;
}
@@ -313,7 +542,7 @@ GLint shader_model_g_get_uniform_location(shader_model* s, GLchar* name) {
shader_model_g_use(s);
GLint location = glGetUniformLocation(s->g_program, name);
if (location == -1)
printf("Location \"%s\" in program %d isn't found", name, s->g_program);;
printf("Location \"%s\" in program %d isn't found\n", name, s->g_program);;
return location;
}
+84 -42
View File
@@ -118,86 +118,128 @@ glUniformMatrix3fv(shader_fbo_get_uniform_location(s, name), count, transpose, (
#define shader_fbo_set_mat4_array(s, name, count, transpose, mat) \
glUniformMatrix4fv(shader_fbo_get_uniform_location(s, name), count, transpose, (GLfloat*)mat)
#define shader_model_set_bool(s, name, value) \
glUniform1i(shader_model_c_get_uniform_location(s, name), value ? 1 : 0); \
#define shader_model_c_set_bool(s, name, value) \
glUniform1i(shader_model_c_get_uniform_location(s, name), value ? 1 : 0)
#define shader_model_c_set_int(s, name, value) \
glUniform1i(shader_model_c_get_uniform_location(s, name), value)
#define shader_model_c_set_float(s, name, value) \
glUniform1f(shader_model_c_get_uniform_location(s, name), value)
#define shader_model_c_set_vec2i(s, name, x, y) \
glUniform2i(shader_model_c_get_uniform_location(s, name), x, y)
#define shader_model_c_set_vec2(s, name, x, y) \
glUniform2f(shader_model_c_get_uniform_location(s, name), x, y)
#define shader_model_c_set_vec3i(s, name, x, y, z) \
glUniform3i(shader_model_c_get_uniform_location(s, name), x, y, z)
#define shader_model_c_set_vec3(s, name, x, y, z) \
glUniform3f(shader_model_c_get_uniform_location(s, name), x, y, z)
#define shader_model_c_set_vec4i(s, name, x, y, z, w) \
glUniform4i(shader_model_c_get_uniform_location(s, name), x, y, z, w)
#define shader_model_c_set_vec4(s, name, x, y, z, w) \
glUniform4f(shader_model_c_get_uniform_location(s, name), x, y, z, w)
#define shader_model_c_set_mat3(s, name, transpose, mat) \
glUniformMatrix3fv(shader_model_c_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat)
#define shader_model_c_set_mat4(s, name, transpose, mat) \
glUniformMatrix4fv(shader_model_c_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat)
#define shader_model_c_set_int_array(s, name, count, value) \
glUniform1iv(shader_model_c_get_uniform_location(s, name), count, value)
#define shader_model_c_set_float_array(s, name, count, value) \
glUniform1fv(shader_model_c_get_uniform_location(s, name), count, value)
#define shader_model_c_set_vec2i_array(s, name, count, value) \
glUniform2iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_c_set_vec2_array(s, name, count, value) \
glUniform2fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_c_set_vec3i_array(s, name, count, value) \
glUniform3iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_c_set_vec3_array(s, name, count, value) \
glUniform3fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_c_set_vec4i_array(s, name, count, value) \
glUniform4iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_c_set_vec4_array(s, name, count, value) \
glUniform4fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_c_set_mat3_array(s, name, count, transpose, mat) \
glUniformMatrix3fv(shader_model_c_get_uniform_location(s, name), count, transpose, (GLfloat*)mat)
#define shader_model_c_set_mat4_array(s, name, count, transpose, mat) \
glUniformMatrix4fv(shader_model_c_get_uniform_location(s, name), count, transpose, (GLfloat*)mat)
#define shader_model_g_set_bool(s, name, value) \
glUniform1i(shader_model_g_get_uniform_location(s, name), value ? 1 : 0)
#define shader_model_set_int(s, name, value) \
glUniform1i(shader_model_c_get_uniform_location(s, name), value); \
#define shader_model_g_set_int(s, name, value) \
glUniform1i(shader_model_g_get_uniform_location(s, name), value)
#define shader_model_set_float(s, name, value) \
glUniform1f(shader_model_c_get_uniform_location(s, name), value); \
#define shader_model_g_set_float(s, name, value) \
glUniform1f(shader_model_g_get_uniform_location(s, name), value)
#define shader_model_set_vec2i(s, name, x, y) \
glUniform2i(shader_model_c_get_uniform_location(s, name), x, y); \
#define shader_model_g_set_vec2i(s, name, x, y) \
glUniform2i(shader_model_g_get_uniform_location(s, name), x, y)
#define shader_model_set_vec2(s, name, x, y) \
glUniform2f(shader_model_c_get_uniform_location(s, name), x, y); \
#define shader_model_g_set_vec2(s, name, x, y) \
glUniform2f(shader_model_g_get_uniform_location(s, name), x, y)
#define shader_model_set_vec3i(s, name, x, y, z) \
glUniform3i(shader_model_c_get_uniform_location(s, name), x, y, z); \
#define shader_model_g_set_vec3i(s, name, x, y, z) \
glUniform3i(shader_model_g_get_uniform_location(s, name), x, y, z)
#define shader_model_set_vec3(s, name, x, y, z) \
glUniform3f(shader_model_c_get_uniform_location(s, name), x, y, z); \
#define shader_model_g_set_vec3(s, name, x, y, z) \
glUniform3f(shader_model_g_get_uniform_location(s, name), x, y, z)
#define shader_model_set_vec4i(s, name, x, y, z, w) \
glUniform4i(shader_model_c_get_uniform_location(s, name), x, y, z, w); \
#define shader_model_g_set_vec4i(s, name, x, y, z, w) \
glUniform4i(shader_model_g_get_uniform_location(s, name), x, y, z, w)
#define shader_model_set_vec4(s, name, x, y, z, w) \
glUniform4f(shader_model_c_get_uniform_location(s, name), x, y, z, w); \
#define shader_model_g_set_vec4(s, name, x, y, z, w) \
glUniform4f(shader_model_g_get_uniform_location(s, name), x, y, z, w)
#define shader_model_set_mat3(s, name, transpose, mat) \
glUniformMatrix3fv(shader_model_c_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat); \
#define shader_model_g_set_mat3(s, name, transpose, mat) \
glUniformMatrix3fv(shader_model_g_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat)
#define shader_model_set_mat4(s, name, transpose, mat) \
glUniformMatrix4fv(shader_model_c_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat); \
#define shader_model_g_set_mat4(s, name, transpose, mat) \
glUniformMatrix4fv(shader_model_g_get_uniform_location(s, name), 1, transpose, (GLfloat*)mat)
#define shader_model_set_int_array(s, name, count, value) \
glUniform1iv(shader_model_c_get_uniform_location(s, name), count, value); \
#define shader_model_g_set_int_array(s, name, count, value) \
glUniform1iv(shader_model_g_get_uniform_location(s, name), count, value)
#define shader_model_set_float_array(s, name, count, value) \
glUniform1fv(shader_model_c_get_uniform_location(s, name), count, value); \
#define shader_model_g_set_float_array(s, name, count, value) \
glUniform1fv(shader_model_g_get_uniform_location(s, name), count, value)
#define shader_model_set_vec2i_array(s, name, count, value) \
glUniform2iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value); \
#define shader_model_g_set_vec2i_array(s, name, count, value) \
glUniform2iv(shader_model_g_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_set_vec2_array(s, name, count, value) \
glUniform2fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value); \
#define shader_model_g_set_vec2_array(s, name, count, value) \
glUniform2fv(shader_model_g_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_set_vec3i_array(s, name, count, value) \
glUniform3iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value); \
#define shader_model_g_set_vec3i_array(s, name, count, value) \
glUniform3iv(shader_model_g_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_set_vec3_array(s, name, count, value) \
glUniform3fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value); \
#define shader_model_g_set_vec3_array(s, name, count, value) \
glUniform3fv(shader_model_g_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_set_vec4i_array(s, name, count, value) \
glUniform4iv(shader_model_c_get_uniform_location(s, name), count, (GLint*)value); \
#define shader_model_g_set_vec4i_array(s, name, count, value) \
glUniform4iv(shader_model_g_get_uniform_location(s, name), count, (GLint*)value)
#define shader_model_set_vec4_array(s, name, count, value) \
glUniform4fv(shader_model_c_get_uniform_location(s, name), count, (GLfloat*)value); \
#define shader_model_g_set_vec4_array(s, name, count, value) \
glUniform4fv(shader_model_g_get_uniform_location(s, name), count, (GLfloat*)value)
#define shader_model_set_mat3_array(s, name, count, transpose, mat) \
glUniformMatrix3fv(shader_model_c_get_uniform_location(s, name), count, transpose, (GLfloat*)mat); \
#define shader_model_g_set_mat3_array(s, name, count, transpose, mat) \
glUniformMatrix3fv(shader_model_g_get_uniform_location(s, name), count, transpose, (GLfloat*)mat)
#define shader_model_set_mat4_array(s, name, count, transpose, mat) \
glUniformMatrix4fv(shader_model_c_get_uniform_location(s, name), count, transpose, (GLfloat*)mat); \
#define shader_model_g_set_mat4_array(s, name, count, transpose, mat) \
glUniformMatrix4fv(shader_model_g_get_uniform_location(s, name), count, transpose, (GLfloat*)mat)
+16
View File
@@ -0,0 +1,16 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#include "shared.h"
vector_func(hash_ptr_gl_object)
vector_func(hash_light_dir)
vector_func(hash_light_point)
vector_func(hash_material)
vector_func(hash_shader_model)
vector_func(hash_texture)
vector_func(hash_texture_set)
vector_func(hash_texture_bone_mat)
vector_func(hash_ptr_vertex)
+38
View File
@@ -0,0 +1,38 @@
/*
by korenkonder
GitHub/GitLab: korenkonder
*/
#pragma once
#include "../KKdLib/str_utils.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
#include "gl_object.h"
#include "hash.h"
#include "light.h"
#include "lock.h"
#include "shader.h"
#include "task.h"
#include "texture.h"
#include "vertex.h"
hash_ptr(gl_object)
hash_dat(light_dir)
hash_dat(light_point)
hash_dat(material)
hash_dat(shader_model)
hash_dat(texture)
hash_dat(texture_set)
hash_dat(texture_bone_mat)
hash_ptr(vertex)
vector(hash_ptr_gl_object)
vector(hash_light_dir)
vector(hash_light_point)
vector(hash_material)
vector(hash_shader_model)
vector(hash_texture)
vector(hash_texture_set)
vector(hash_texture_bone_mat)
vector(hash_ptr_vertex)
+129
View File
@@ -22,6 +22,18 @@ bool sv_fxaa_changed = false;
bool sv_old_fxaa = false;
bool sv_fxaa = false;
static int32_t active_tex;
static int32_t current_fbo;
static int32_t current_vao;
static int32_t current_vbo;
static int32_t current_ebo;
static int32_t current_ubo;
static int32_t current_tex1d[32];
static int32_t current_tex2d[32];
static int32_t current_tex2dms[32];
static int32_t current_tex3d[32];
static int32_t current_texcube[32];
const vec3 sv_rgb_to_luma = {
0.2126f, 0.7152f, 0.0722f
};
@@ -62,3 +74,120 @@ void sv_fxaa_set(bool value) {
sv_fxaa_changed = true;
sv_old_fxaa = sv_fxaa;
}
inline void bind_index_tex1d(int32_t index, int32_t id) {
if (current_tex1d[index] != id) {
active_texture(index);
glBindTexture(GL_TEXTURE_1D, id);
current_tex1d[index] = id;
}
}
inline void bind_index_tex2d(int32_t index, int32_t id) {
if (current_tex2d[index] != id) {
active_texture(index);
glBindTexture(GL_TEXTURE_2D, id);
current_tex2d[index] = id;
}
}
inline void bind_index_tex2dms(int32_t index, int32_t id) {
if (current_tex2dms[index] != id) {
active_texture(index);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, id);
current_tex2dms[index] = id;
}
}
inline void bind_index_tex3d(int32_t index, int32_t id) {
if (current_tex3d[index] != id) {
active_texture(index);
glBindTexture(GL_TEXTURE_3D, id);
current_tex3d[index] = id;
}
}
inline void bind_index_texcube(int32_t index, int32_t id) {
if (current_texcube[index] != id) {
active_texture(index);
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
current_texcube[index] = id;
}
}
inline void active_texture(int32_t index) {
if (active_tex != index) {
glActiveTexture(GL_TEXTURE0 + index);
active_tex = index;
}
}
inline void bind_framebuffer(int32_t fbo) {
if (current_fbo != fbo) {
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
current_fbo = fbo;
}
}
inline void bind_vertex_array(int32_t vao) {
if (current_vao != vao) {
glBindVertexArray(vao);
current_vao = vao;
}
}
inline void bind_array_buffer(int32_t vbo) {
if (current_vbo != vbo) {
glBindBuffer(GL_ARRAY_BUFFER, vbo);
current_vbo = vbo;
}
}
inline void bind_element_array_buffer(int32_t ebo) {
if (current_ebo != ebo) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
current_ebo = ebo;
}
}
inline void bind_uniform_buffer(int32_t ubo) {
if (current_ubo != ubo) {
glBindBuffer(GL_UNIFORM_BUFFER, ubo);
current_ubo = ubo;
}
}
inline void bind_tex1d(int32_t id) {
if (current_tex1d[active_tex] != id) {
glBindTexture(GL_TEXTURE_1D, id);
current_tex1d[active_tex] = id;
}
}
inline void bind_tex2d(int32_t id) {
if (current_tex2d[active_tex] != id) {
glBindTexture(GL_TEXTURE_2D, id);
current_tex2d[active_tex] = id;
}
}
inline void bind_tex2dms(int32_t id) {
if (current_tex2dms[active_tex] != id) {
glBindTexture(GL_TEXTURE_2D, id);
current_tex2dms[active_tex] = id;
}
}
inline void bind_tex3d(int32_t id) {
if (current_tex3d[active_tex] != id) {
glBindTexture(GL_TEXTURE_3D, id);
current_tex3d[active_tex] = id;
}
}
inline void bind_texcube(int32_t id) {
if (current_texcube[active_tex] != id) {
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
current_texcube[active_tex] = id;
}
}
+19
View File
@@ -8,6 +8,8 @@
#include "../KKdLib/default.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/mat.h"
#define GLEW_STATIC
#include <GLEW/glew.h>
extern int32_t sv_max_samples;
extern int32_t sv_max_texture_buffer_size;
@@ -31,3 +33,20 @@ extern bool sv_can_use_msaa();
extern void sv_anisotropy_set(int32_t value);
extern void sv_samples_set(int32_t value);
extern void sv_fxaa_set(bool value);
extern void bind_index_tex1d(int32_t index, int32_t id);
extern void bind_index_tex2d(int32_t index, int32_t id);
extern void bind_index_tex2dms(int32_t index, int32_t id);
extern void bind_index_tex3d(int32_t index, int32_t id);
extern void bind_index_texcube(int32_t index, int32_t id);
extern void active_texture(int32_t index);
extern void bind_framebuffer(int32_t fbo);
extern void bind_vertex_array(int32_t vao);
extern void bind_array_buffer(int32_t vbo);
extern void bind_element_array_buffer(int32_t ebo);
extern void bind_uniform_buffer(int32_t ubo);
extern void bind_tex1d(int32_t id);
extern void bind_tex2d(int32_t id);
extern void bind_tex2dms(int32_t id);
extern void bind_tex3d(int32_t id);
extern void bind_texcube(int32_t id);
+1
View File
@@ -5,6 +5,7 @@
#include "task.h"
vector_func(task_render_uniform)
vector_func(task_render)
vector_func(task_render_draw2d)
vector_func(task_render_draw3d)
+37 -27
View File
@@ -11,14 +11,31 @@
#include "../KKdLib/vec.h"
#include "../KKdLib/vector.h"
#include "../CRE/gl_object.h"
#include "../CRE/light.h"
#include "../CRE/shader.h"
#include "../CRE/texture.h"
#include "../CRE/material.h"
#include "../CRE/vertex.h"
#include <xmmintrin.h>
typedef enum task_render_free_type {
TASK_RENDER_FREE_NONE = 0,
TASK_RENDER_FREE_GL_OBJECT,
TASK_RENDER_FREE_LIGHT_DIR,
TASK_RENDER_FREE_LIGHT_POINT,
TASK_RENDER_FREE_SHADER,
TASK_RENDER_FREE_MATERIAL,
TASK_RENDER_FREE_TEXTURE,
TASK_RENDER_FREE_TEXTURE_SET,
TASK_RENDER_FREE_VERT,
} task_render_free_type;
typedef enum task_render_update_type {
TASK_RENDER_UPDATE_NONE = 0,
TASK_RENDER_UPDATE_GL_OBJECT,
TASK_RENDER_UPDATE_LIGHT_DIR,
TASK_RENDER_UPDATE_LIGHT_POINT,
TASK_RENDER_UPDATE_SHADER,
TASK_RENDER_UPDATE_MATERIAL,
TASK_RENDER_UPDATE_TEXTURE,
TASK_RENDER_UPDATE_TEXTURE_SET,
TASK_RENDER_UPDATE_VERT,
@@ -71,11 +88,14 @@ typedef enum task_render_draw3d_type {
} task_render_draw3d_type;
typedef struct task_render_update {
hash hash;
task_render_update_type type;
uint64_t hash;
union {
gl_object_update gl_obj;
light_dir_update light_dir;
light_point_update light_point;
shader_model_update shad;
material_update mat;
texture_data tex;
texture_set_data tex_set;
vertex_update vert;
@@ -83,8 +103,8 @@ typedef struct task_render_update {
} task_render_update;
typedef struct task_render_free {
task_render_update_type type;
uint64_t hash;
hash hash;
task_render_free_type type;
} task_render_free;
typedef struct task_render_uniform_bool {
@@ -186,11 +206,11 @@ typedef struct task_render_uniform_mat4_array {
} task_render_uniform_mat4_array;
typedef struct task_render_uniform {
uint64_t shader_hash;
hash shader_hash;
char_buffer name;
task_render_uniform_type type;
union {
task_render_uniform_bool bool;
task_render_uniform_bool boolean;
task_render_uniform_int32 int32;
task_render_uniform_float32 float32;
task_render_uniform_vec2 vec2;
@@ -223,33 +243,23 @@ typedef struct task_render {
};
} task_render;
vector(task_render_uniform)
typedef struct task_render_draw2d {
hash hash;
task_render_draw2d_type type;
uint64_t hash;
bool blend;
int16_t blend_src_factor_rgb;
int16_t blend_dst_factor_rgb;
int16_t blend_src_factor_alpha;
int16_t blend_dst_factor_alpha;
int16_t blend_mode_rgb;
int16_t blend_mode_alpha;
vector_task_render_uniform uniforms;
} task_render_draw2d;
typedef struct task_render_draw3d {
hash hash;
task_render_draw3d_type type;
uint64_t hash;
bool blend;
int16_t blend_src_factor_rgb;
int16_t blend_dst_factor_rgb;
int16_t blend_src_factor_alpha;
int16_t blend_dst_factor_alpha;
int16_t blend_mode_rgb;
int16_t blend_mode_alpha;
bool depth;
int16_t depth_func;
bool depth_mask;
bool cull_face;
int16_t cull_face_mode;
bool translucent;
mat4 model;
mat3 model_normal;
mat4 uv_mat;
vec4 color;
vector_task_render_uniform uniforms;
} task_render_draw3d;
vector(task_render)
+357 -70
View File
@@ -4,13 +4,17 @@
*/
#include "texture.h"
#include "../KKdLib/mat.h"
#include "../KKdLib/txp.h"
#include "static_var.h"
void texture_1d_load(texture* tex, texture_data* data) {
if (!data->data || data->width < 1)
return;
static void load_texture_data(GLenum target, txp_format format,
uint32_t width, uint32_t height, uint32_t level, void* data);
glBindTexture(GL_TEXTURE_1D, tex->id);
static void texture_1d_load(texture* tex, texture_data* data) {
uint32_t width = max(data->width, 0);
bind_tex1d(tex->id);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, data->wrap_mode_s);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, data->min_filter);
@@ -18,24 +22,24 @@ void texture_1d_load(texture* tex, texture_data* data) {
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glTexImage1D(GL_TEXTURE_1D, 0, data->pixel_internal_format, data->width,
glTexImage1D(GL_TEXTURE_1D, 0, data->pixel_internal_format, width,
0, data->pixel_format, data->pixel_type, data->data);
if (data->generate_mipmap)
glGenerateMipmap(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, 0);
bind_tex1d(0);
}
void texture_1d_update(texture* tex) {
glBindTexture(GL_TEXTURE_1D, tex->id);
static void texture_1d_update(texture* tex) {
bind_tex1d(tex->id);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glBindTexture(GL_TEXTURE_1D, 0);
bind_tex1d(0);
}
void texture_2d_load(texture* tex, texture_data* data) {
if (!data->data || data->width < 1 || data->height < 1)
return;
static void texture_2d_load(texture* tex, texture_data* data) {
uint32_t width = max(data->width, 0);
uint32_t height = max(data->height, 0);
glBindTexture(GL_TEXTURE_2D, tex->id);
bind_tex2d(tex->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, data->wrap_mode_s);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, data->wrap_mode_t);
@@ -44,24 +48,25 @@ void texture_2d_load(texture* tex, texture_data* data) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glTexImage2D(GL_TEXTURE_2D, 0, data->pixel_internal_format, data->width, data->height,
glTexImage2D(GL_TEXTURE_2D, 0, data->pixel_internal_format, width, height,
0, data->pixel_format, data->pixel_type, data->data);
if (data->generate_mipmap)
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
bind_tex2d(0);
}
void texture_2d_update(texture* tex) {
glBindTexture(GL_TEXTURE_2D, tex->id);
static void texture_2d_update(texture* tex) {
bind_tex2d(tex->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glBindTexture(GL_TEXTURE_2D, 0);
bind_tex2d(0);
}
void texture_3d_load(texture* tex, texture_data* data) {
if (!data->data)
return;
static void texture_3d_load(texture* tex, texture_data* data) {
uint32_t width = max(data->width, 0);
uint32_t height = max(data->height, 0);
uint32_t depth = max(data->depth, 0);
glBindTexture(GL_TEXTURE_3D, tex->id);
bind_tex3d(tex->id);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, data->wrap_mode_s);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, data->wrap_mode_t);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, data->wrap_mode_r);
@@ -71,24 +76,34 @@ void texture_3d_load(texture* tex, texture_data* data) {
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glTexImage3D(GL_TEXTURE_3D, 0, data->pixel_internal_format, data->width, data->height,
data->depth, 0, data->pixel_format, data->pixel_type, data->data);
glTexImage3D(GL_TEXTURE_3D, 0, data->pixel_internal_format, width, height,
depth, 0, data->pixel_format, data->pixel_type, data->data);
if (data->generate_mipmap)
glGenerateMipmap(GL_TEXTURE_3D);
glBindTexture(GL_TEXTURE_3D, 0);
bind_tex3d(0);
}
void texture_3d_update(texture* tex) {
glBindTexture(GL_TEXTURE_3D, tex->id);
static void texture_3d_update(texture* tex) {
bind_tex3d(tex->id);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glBindTexture(GL_TEXTURE_3D, 0);
bind_tex3d(0);
}
void texture_cube_load(texture* tex, texture_cube_data* data) {
if (!data->px.data || !data->nx.data || !data->py.data || !data->ny.data || !data->pz.data || !data->nz.data)
return;
static void texture_cube_load(texture* tex, texture_cube_data* data) {
uint32_t px_width = max(data->px.width, 0);
uint32_t px_height = max(data->px.height, 0);
uint32_t nx_width = max(data->nx.width, 0);
uint32_t nx_height = max(data->nx.height, 0);
uint32_t py_width = max(data->py.width, 0);
uint32_t py_height = max(data->py.height, 0);
uint32_t ny_width = max(data->ny.width, 0);
uint32_t ny_height = max(data->ny.height, 0);
uint32_t pz_width = max(data->pz.width, 0);
uint32_t pz_height = max(data->pz.height, 0);
uint32_t nz_width = max(data->nz.width, 0);
uint32_t nz_height = max(data->nz.height, 0);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex->id);
bind_texcube(tex->id);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, data->wrap_mode_s);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, data->wrap_mode_t);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, data->wrap_mode_r);
@@ -98,33 +113,40 @@ void texture_cube_load(texture* tex, texture_cube_data* data) {
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, data->pixel_internal_format, data->px.width,
data->px.height, 0, data->px.pixel_format, data->px.pixel_type, data->px.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, data->pixel_internal_format, data->nx.width,
data->nx.height, 0, data->nx.pixel_format, data->nx.pixel_type, data->nx.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, data->pixel_internal_format, data->py.width,
data->py.height, 0, data->py.pixel_format, data->py.pixel_type, data->py.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, data->pixel_internal_format, data->ny.width,
data->ny.height, 0, data->ny.pixel_format, data->ny.pixel_type, data->ny.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, data->pixel_internal_format, data->pz.width,
data->pz.height, 0, data->pz.pixel_format, data->pz.pixel_type, data->pz.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, data->pixel_internal_format, data->nz.width,
data->nz.height, 0, data->nz.pixel_format, data->nz.pixel_type, data->nz.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, data->pixel_internal_format, px_width,
px_height, 0, data->px.pixel_format, data->px.pixel_type, data->px.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, data->pixel_internal_format, nx_width,
nx_height, 0, data->nx.pixel_format, data->nx.pixel_type, data->nx.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, data->pixel_internal_format, py_width,
py_height, 0, data->py.pixel_format, data->py.pixel_type, data->py.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, data->pixel_internal_format, ny_width,
ny_height, 0, data->ny.pixel_format, data->ny.pixel_type, data->ny.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, data->pixel_internal_format, pz_width,
pz_height, 0, data->pz.pixel_format, data->pz.pixel_type, data->pz.data);
glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, data->pixel_internal_format, nz_width,
nz_height, 0, data->nz.pixel_format, data->nz.pixel_type, data->nz.data);
if (data->generate_mipmap)
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
bind_texcube(0);
}
void texture_cube_update(texture* tex) {
glBindTexture(GL_TEXTURE_CUBE_MAP, tex->id);
static void texture_cube_update(texture* tex) {
bind_texcube(tex->id);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAX_ANISOTROPY, sv_anisotropy);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
bind_texcube(0);
}
void texture_load(texture* tex, texture_data* data) {
if (!tex)
return;
if (tex->id == 0)
glGenTextures(1, &tex->id);
if (!data)
return;
tex->mode = TEXTURE_MODE_DEFAULT;
tex->type = data->type;
switch (tex->type) {
case TEXTURE_1D:
@@ -143,52 +165,49 @@ void texture_load(texture* tex, texture_data* data) {
}
void texture_bind(texture* tex, int32_t index) {
GLenum target = 0;
if (!tex)
return;
switch (tex->type) {
case TEXTURE_1D:
target = GL_TEXTURE_1D;
bind_index_tex1d(index, tex->id);
break;
case TEXTURE_2D:
target = GL_TEXTURE_2D;
bind_index_tex2d(index, tex->id);
break;
case TEXTURE_3D:
target = GL_TEXTURE_3D;
bind_index_tex3d(index, tex->id);
break;
case TEXTURE_CUBE:
target = GL_TEXTURE_CUBE_MAP;
bind_index_texcube(index, tex->id);
break;
}
if (target) {
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(target, tex->id);
}
}
void texture_reset(texture* tex, int32_t index) {
GLenum target = 0;
if (!tex)
return;
switch (tex->type) {
case TEXTURE_1D:
target = GL_TEXTURE_1D;
bind_index_tex1d(index, 0);
break;
case TEXTURE_2D:
target = GL_TEXTURE_2D;
bind_index_tex2d(index, 0);
break;
case TEXTURE_3D:
target = GL_TEXTURE_3D;
bind_index_tex3d(index, 0);
break;
case TEXTURE_CUBE:
target = GL_TEXTURE_CUBE_MAP;
bind_index_texcube(index, 0);
break;
}
if (target) {
glActiveTexture(GL_TEXTURE0 + index);
glBindTexture(target, 0);
}
}
void texture_update(texture* tex) {
if (!tex)
return;
switch (tex->type) {
case TEXTURE_1D:
texture_1d_update(tex);
@@ -206,32 +225,300 @@ void texture_update(texture* tex) {
}
void texture_free(texture* tex) {
if (!tex)
return;
if (tex->id)
glDeleteTextures(1, &tex->id);
tex->id = 0;
}
void texture_set_load(texture_set* tex, texture_set_data* data) {
for (int32_t i = 0; i < 8; i++)
texture_load(&tex->tex[i], data->tex[i]);
if (!tex)
return;
if (data)
for (int32_t i = 0; i < 8; i++)
texture_load(&tex->tex[i], data->tex[i]);
else
for (int32_t i = 0; i < 8; i++)
texture_load(&tex->tex[i], 0);
}
void texture_set_bind(texture_set* tex) {
if (!tex)
return;
for (int32_t i = 0; i < 8; i++)
texture_bind(&tex->tex[i], i);
}
void texture_set_reset(texture_set* tex) {
if (!tex)
return;
for (int32_t i = 0; i < 8; i++)
texture_reset(&tex->tex[i], i);
}
void texture_set_update(texture_set* tex) {
if (!tex)
return;
for (int32_t i = 0; i < 8; i++)
texture_update(&tex->tex[i]);
}
void texture_set_free(texture_set* tex) {
if (!tex)
return;
for (int32_t i = 0; i < 8; i++)
texture_free(&tex->tex[i]);
}
void texture_bone_mat_load(texture_bone_mat* tex, texture_bone_mat_data* data) {
if (!tex)
return;
if (tex->id == 0)
glGenTextures(1, &tex->id);
if (!data || !data->data || data->count < 1)
return;
mat4* mat = data->data;
void* temp_data = force_malloc_s(mat4, data->count * 2LL);
mat4* d = temp_data;
for (int32_t i = 0; i < data->count; i++, mat++, d += 2) {
d[0] = *mat;
mat4_invtrans(mat, &d[1]);
}
bind_tex2d(tex->id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, sizeof(mat4) / sizeof(vec4) * 2,
data->count, 0, GL_RGBA, GL_FLOAT, temp_data);
bind_tex2d(0);
free(temp_data);
}
void texture_bone_mat_bind(texture_bone_mat* tex, int32_t index) {
if (!tex)
return;
bind_index_tex2d(index, tex->id);
}
void texture_bone_mat_reset(texture_bone_mat* tex, int32_t index) {
if (!tex)
return;
bind_index_tex2d(index, tex->id);
}
void texture_bone_mat_free(texture_bone_mat* tex) {
if (!tex)
return;
if (tex->id)
glDeleteTextures(1, &tex->id);
tex->id = 0;
}
bool texture_txp_load(vector_txp* tex, vector_int32_t* textures) {
static const GLenum target_cubemap_array[] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
};
if (!tex || !textures)
return false;
size_t count = tex->end - tex->begin;
if (count < 1)
return false;
if (textures->end - textures->begin != 0)
texture_txp_unload(textures);
vector_int32_t_append(textures, count);
for (uint32_t i = 0; i < count; i++)
vector_int32_t_push_back(textures, &i);
glGenTextures((GLsizei)count, textures->begin);
txp* tex_data = tex->begin;
for (size_t i = 0; i < count; i++, tex_data++)
if ((tex_data->has_cubemap && tex_data->array_size == 6) || tex_data->array_size == 1) {
GLenum target = tex_data->has_cubemap ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
uint32_t mipmaps_count = tex_data->mipmaps_count;
if (tex_data->has_cubemap)
bind_texcube(textures->begin[i]);
else
bind_tex2d(textures->begin[i]);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameterfv(target, GL_TEXTURE_BORDER_COLOR, (float_t*)&vec4_null);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
mipmaps_count > 1 ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, mipmaps_count - 1);
glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY, tex_data->has_cubemap ? 1.0f : 16.0f);
txp_mipmap* tex_mipmap = tex_data->data.begin;
if (tex_data->has_cubemap)
for (uint32_t j = 0; j < 6; j++, tex_data++) {
uint32_t width = tex_mipmap->width;
uint32_t height = tex_mipmap->height;
txp_format format = tex_mipmap->format;
for (uint32_t k = 0; k < mipmaps_count; k++, tex_mipmap++)
load_texture_data(target_cubemap_array[j], format,
max(width >> k, 1), max(height >> k, 1), k, tex_mipmap->data);
}
else {
uint32_t width = tex_mipmap->width;
uint32_t height = tex_mipmap->height;
txp_format format = tex_mipmap->format;
for (uint32_t k = 0; k < mipmaps_count; k++, tex_mipmap++)
load_texture_data(target, format,
max(width >> k, 1), max(height >> k, 1), k, tex_mipmap->data);
}
glBindTexture(target, 0);
}
bind_tex2d(0);
bind_texcube(0);
return true;
}
void texture_txp_unload(vector_int32_t* textures) {
if (!textures)
return;
if (textures->end - textures->begin != 0)
glDeleteTextures((GLsizei)(textures->end - textures->begin), textures->begin);
vector_int32_t_free(textures);
}
static void load_texture_data(GLenum target, txp_format format,
uint32_t width, uint32_t height, uint32_t level, void* data) {
static const GLint textureswizzles_a8 [] = { GL_ZERO, GL_ZERO , GL_ZERO, GL_RED };
static const GLint textureswizzles_ati1[] = { GL_RED , GL_RED , GL_RED , GL_ONE };
static const GLint textureswizzles_ati2[] = { GL_RED , GL_GREEN, GL_ZERO, GL_RED };
static const GLint textureswizzles_l8 [] = { GL_RED , GL_RED , GL_RED , GL_ONE };
static const GLint textureswizzles_l8a8[] = { GL_RED , GL_RED , GL_RED , GL_GREEN };
static const GLint* textureswizzles[] = {
[TXP_A8] = textureswizzles_a8,
[TXP_RGB8] = 0,
[TXP_RGBA8] = 0,
[TXP_RGB5] = 0,
[TXP_RGB5A1] = 0,
[TXP_RGBA4] = 0,
[TXP_DXT1] = 0,
[TXP_DXT1a] = 0,
[TXP_DXT3] = 0,
[TXP_DXT5] = 0,
[TXP_ATI1] = textureswizzles_ati1,
[TXP_ATI2] = textureswizzles_ati2,
[TXP_L8] = textureswizzles_l8,
[TXP_L8A8] = textureswizzles_l8a8,
};
static const GLenum types[] = {
[TXP_A8] = GL_UNSIGNED_BYTE,
[TXP_RGB8] = GL_UNSIGNED_BYTE,
[TXP_RGBA8] = GL_UNSIGNED_BYTE,
[TXP_RGB5] = GL_UNSIGNED_SHORT_5_6_5_REV,
[TXP_RGB5A1] = GL_UNSIGNED_SHORT_1_5_5_5_REV,
[TXP_RGBA4] = GL_UNSIGNED_SHORT_4_4_4_4_REV,
[TXP_DXT1] = 0,
[TXP_DXT1a] = 0,
[TXP_DXT3] = 0,
[TXP_DXT5] = 0,
[TXP_ATI1] = 0,
[TXP_ATI2] = 0,
[TXP_L8] = GL_UNSIGNED_BYTE,
[TXP_L8A8] = GL_UNSIGNED_BYTE,
};
static const GLenum formats[] = {
[TXP_A8] = GL_RED,
[TXP_RGB8] = GL_RGB,
[TXP_RGBA8] = GL_RGBA,
[TXP_RGB5] = GL_RGB,
[TXP_RGB5A1] = GL_RGBA,
[TXP_RGBA4] = GL_RGBA,
[TXP_DXT1] = 0,
[TXP_DXT1a] = 0,
[TXP_DXT3] = 0,
[TXP_DXT5] = 0,
[TXP_ATI1] = 0,
[TXP_ATI2] = 0,
[TXP_L8] = GL_RED,
[TXP_L8A8] = GL_RG,
};
static const GLenum internalformats[] = {
[TXP_A8] = GL_R8,
[TXP_RGB8] = GL_RGB8,
[TXP_RGBA8] = GL_RGBA8,
[TXP_RGB5] = GL_RGB5,
[TXP_RGB5A1] = GL_RGB5_A1,
[TXP_RGBA4] = GL_RGBA4,
[TXP_DXT1] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
[TXP_DXT1a] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
[TXP_DXT3] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
[TXP_DXT5] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
[TXP_ATI1] = GL_COMPRESSED_RED_RGTC1_EXT,
[TXP_ATI2] = GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
[TXP_L8] = GL_R8,
[TXP_L8A8] = GL_RG8,
};
switch (format) {
case TXP_A8:
case TXP_L8:
case TXP_L8A8:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, textureswizzles[format]);
glTexImage2D(target, level, internalformats[format],
width, height, 0, formats[format], types[format], data);
break;
case TXP_RGB8:
case TXP_RGBA8:
case TXP_RGB5:
case TXP_RGB5A1:
case TXP_RGBA4:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(target, level, internalformats[format],
width, height, 0, formats[format], types[format], data);
break;
case TXP_DXT1:
case TXP_DXT1a:
case TXP_DXT3:
case TXP_DXT5: {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
uint32_t size = txp_get_size(format, width, height);
glCompressedTexImage2D(target, level, internalformats[format],
width, height, 0, size, data);
} break;
case TXP_ATI1:
case TXP_ATI2: {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, textureswizzles[format]);
uint32_t size = txp_get_size(format, width, height);
glCompressedTexImage2D(target, level, internalformats[format],
width, height, 0, size, data);
} break;
}
}
+27
View File
@@ -6,6 +6,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "../KKdLib/txp.h"
#define GLEW_STATIC
#include <GLEW/glew.h>
@@ -17,6 +18,16 @@ typedef enum texture_type {
TEXTURE_CUBE,
} texture_type;
typedef enum texture_mode {
TEXTURE_MODE_DEFAULT = 0,
TEXTURE_MODE_YCBCR_BC4 = 1,
TEXTURE_MODE_YCBCR_BC5 = 2,
TEXTURE_MODE_NORMAL_BC5U = 3,
TEXTURE_MODE_NORMAL_BC5S = 4,
TEXTURE_MODE_NORMAL_U = 5,
TEXTURE_MODE_NORMAL_S = 6,
} texture_mode;
typedef struct texture_data {
texture_type type;
int32_t width;
@@ -60,6 +71,7 @@ typedef struct texture_cube_data {
typedef struct texture {
int32_t id;
texture_mode mode;
texture_type type;
} texture;
@@ -91,6 +103,15 @@ typedef union texture_set {
texture tex[8];
} texture_set;
typedef struct texture_bone_mat_data {
int32_t count;
void* data;
} texture_bone_mat_data;
typedef struct texture_bone_mat {
int32_t id;
} texture_bone_mat;
extern void texture_load(texture* tex, texture_data* data);
extern void texture_bind(texture* tex, int32_t index);
extern void texture_reset(texture* tex, int32_t index);
@@ -101,3 +122,9 @@ extern void texture_set_bind(texture_set* tex);
extern void texture_set_reset(texture_set* tex);
extern void texture_set_update(texture_set* tex);
extern void texture_set_free(texture_set* tex);
extern void texture_bone_mat_load(texture_bone_mat* tex, texture_bone_mat_data* data);
extern void texture_bone_mat_bind(texture_bone_mat* tex, int32_t index);
extern void texture_bone_mat_reset(texture_bone_mat* tex, int32_t index);
extern void texture_bone_mat_free(texture_bone_mat* tex);
extern bool texture_txp_load(vector_txp* tex, vector_int32_t* textures);
extern void texture_txp_unload(vector_int32_t* textures);
+19 -22
View File
@@ -6,6 +6,7 @@
#pragma once
#include "../KKdLib/default.h"
#include "lock.h"
extern LARGE_INTEGER performance_frequency;
@@ -16,7 +17,7 @@ double_t name##_history[HISTORY_COUNT]; \
uint8_t name##_history_counter; \
LARGE_INTEGER name##_curr_time, name##_prev_time; \
double_t name##_freq = 0.0; \
HANDLE name##_freq_lock = 0; \
lock_val(name##_freq_lock); \
HANDLE name##_timer
#define timer_init(name, mutex_name) \
@@ -25,35 +26,31 @@ name##_history_counter = 0; \
name##_curr_time.QuadPart = 0; \
name##_prev_time.QuadPart = 0; \
name##_freq = 0; \
name##_freq_lock = CreateMutexW(0, false, L##mutex_name##L" Freq"); \
lock_init(name##_freq_lock); \
name##_timer = create_timer()
#define timer_calc_pre(name) \
if (name##_freq_lock) { \
WaitForSingleObject(name##_freq_lock, INFINITE); \
double_t time = timer_get_msec(name##_prev_time); \
QueryPerformanceCounter(&name##_prev_time); \
double_t freq = 0; \
for (uint8_t i = 0; i < name##_history_counter; i++) \
freq += name##_history[i]; \
freq += name##_history[name##_history_counter] = 1000.0 / time; \
for (uint8_t i = name##_history_counter + 1; i < HISTORY_COUNT; i++) \
freq += name##_history[i]; \
name##_freq = freq / HISTORY_COUNT; \
name##_history_counter++; \
if (name##_history_counter >= HISTORY_COUNT) \
name##_history_counter = 0; \
ReleaseMutex(name##_freq_lock); \
}
lock_lock(name##_freq_lock); \
double_t time = timer_get_msec(name##_prev_time); \
QueryPerformanceCounter(&name##_prev_time); \
double_t freq = 0; \
for (uint8_t i = 0; i < name##_history_counter; i++) \
freq += name##_history[i]; \
freq += name##_history[name##_history_counter] = 1000.0 / time; \
for (uint8_t i = name##_history_counter + 1; i < HISTORY_COUNT; i++) \
freq += name##_history[i]; \
name##_freq = freq / HISTORY_COUNT; \
name##_history_counter++; \
if (name##_history_counter >= HISTORY_COUNT) \
name##_history_counter = 0; \
lock_unlock(name##_freq_lock);
#define timer_calc_post(name) \
timer_get_msec(name##_prev_time)
#define timer_dispose(name) \
if (name##_freq_lock) \
CloseHandle(name##_freq_lock); \
dispose_timer(name##_timer); \
name##_freq_lock = 0
lock_dispose(name##_freq_lock); \
dispose_timer(name##_timer)
extern double_t timer_get_msec(LARGE_INTEGER t);
extern HANDLE create_timer();
+193 -133
View File
@@ -5,20 +5,23 @@
#include "vertex.h"
#include "../KKdLib/half_t.h"
#include "../KKdLib/vec.h"
#include "../KKdLib/hash.h"
#include "../KKdLib/vector.h"
typedef struct vertex_data {
#pragma pack(push, 1)
typedef struct vertex_pre_data {
vec3 pos;
vec2 uv[2];
vec2 uv;
vec2 uv2;
vec4 color;
vec3 normal;
vec3 tangent;
uint16_t bone_index[4];
float_t bone_weight[4];
} vertex_data;
vec4i bone_index;
vec4 bone_weight;
} vertex_pre_data;
#pragma pack(pop)
vector(vertex_data)
vector(vertex_pre_data)
vertex* vertex_init() {
vertex* v = force_malloc(sizeof(vertex));
@@ -38,6 +41,8 @@ void vertex_load(vertex* v, vertex_update* upd) {
if (!upd->data || !upd->length)
return;
bool use_bone_data = false;
bool translucent = false;
float_t* data = upd->data;
size_t length = upd->length;
bool uv = upd->uv;
@@ -47,21 +52,27 @@ void vertex_load(vertex* v, vertex_update* upd) {
bool bones = upd->bones;
size_t len = 3LL + (uv ? (2LL + (uv2 ? 2 : 0)) : 0) + (color ? 4 : 0) + (normal ? 3 : 0) + (bones ? 8 : 0);
length /= len;
vertex_data* verts = force_malloc_s(sizeof(vertex_data), length);
vertex_pre_data* verts = force_malloc_s(vertex_pre_data, length);
if (bones) {
for (size_t i = 0; i < length; i++) {
vertex_data* v = &verts[i];
vertex_pre_data* v = &verts[i];
v->pos.x = *data++;
v->pos.y = *data++;
v->pos.z = *data++;
if (uv) {
v->uv[0].x = *data++;
v->uv[0].y = *data++;
v->uv.x = *data++;
v->uv.y = *data++;
if (uv2) {
v->uv[1].x = *data++;
v->uv[1].y = *data++;
v->uv2.x = *data++;
v->uv2.y = *data++;
}
else
v->uv2 = vec2_null;
}
else {
v->uv = vec2_null;
v->uv2 = vec2_null;
}
if (color) {
@@ -69,6 +80,8 @@ void vertex_load(vertex* v, vertex_update* upd) {
v->color.y = *data++;
v->color.z = *data++;
v->color.w = *data++;
if (v->color.w < 1.0f)
translucent = true;
}
else
v->color = vec4_identity;
@@ -79,28 +92,51 @@ void vertex_load(vertex* v, vertex_update* upd) {
v->normal.z = *data++;
vec3_normalize(v->normal, v->normal);
}
else
v->normal = vec3_null;
for (int32_t j = 0; j < 4; j++)
v->bone_index[j] = (uint16_t)*data++;
v->tangent = vec3_null;
for (int32_t j = 0; j < 4; j++)
v->bone_weight[j] = *data++;
v->bone_index.x = (int32_t)*data++;
v->bone_index.y = (int32_t)*data++;
v->bone_index.z = (int32_t)*data++;
v->bone_index.w = (int32_t)*data++;
vec4 bone_weight;
bone_weight.x = *data++;
bone_weight.y = *data++;
bone_weight.z = *data++;
bone_weight.w = *data++;
vec4_normalize(bone_weight, bone_weight);
float_t bone_weight_length;
vec4_length_squared(bone_weight, bone_weight_length);
if (bone_weight_length != 0.0f)
use_bone_data = true;
v->bone_weight = bone_weight;
}
}
else {
for (size_t i = 0; i < length; i++) {
vertex_data* v = &verts[i];
vertex_pre_data* v = &verts[i];
v->pos.x = *data++;
v->pos.y = *data++;
v->pos.z = *data++;
if (uv) {
v->uv[0].x = *data++;
v->uv[0].y = *data++;
v->uv.x = *data++;
v->uv.y = *data++;
if (uv2) {
v->uv[1].x = *data++;
v->uv[1].y = *data++;
v->uv2.x = *data++;
v->uv2.y = *data++;
}
else
v->uv2 = vec2_null;
}
else {
v->uv = vec2_null;
v->uv2 = vec2_null;
}
if (color) {
@@ -108,6 +144,8 @@ void vertex_load(vertex* v, vertex_update* upd) {
v->color.y = *data++;
v->color.z = *data++;
v->color.w = *data++;
if (v->color.w < 1.0f)
translucent = true;
}
else
v->color = vec4_identity;
@@ -118,138 +156,160 @@ void vertex_load(vertex* v, vertex_update* upd) {
v->normal.z = *data++;
vec3_normalize(v->normal, v->normal);
}
else
v->normal = vec3_null;
v->tangent = vec3_null;
v->bone_index = vec4i_null;
v->bone_weight = vec4_null;
}
}
v->translucent = translucent;
v->ind_count = length;
v->ind = force_malloc_s(sizeof(uint32_t), v->ind_count);
v->ind = force_malloc_s(uint32_t, v->ind_count);
vector_vertex_pre_data vert_list = { 0, 0, 0 };
vector_vertex_pre_data_append(&vert_list, length);
for (size_t i = 0; i < length; i++) {
vertex_pre_data* vert = &verts[i];
vector_vertex_data vert_list;
vert_list.begin = vert_list.end = vert_list.capacity_end = 0;
for (size_t i = 0, j = 0; i < length; i++) {
bool found = false;
size_t count = vert_list.end - vert_list.begin;
for (j = 0; j < count; i++)
if (!memcmp(&vert_list.begin[j], &verts[i], sizeof(vertex_data))) {
vertex_pre_data* j = vert_list.begin;
uint32_t k = 0;
for (; j != vert_list.end; j++, k++)
if (!memcmp(j, vert, sizeof(vertex_pre_data))) {
found = true;
break;
}
if (!found)
vector_vertex_data_push_back(&vert_list, &verts[i]);
v->ind[i] = (uint32_t)j;
vector_vertex_pre_data_push_back(&vert_list, vert);
v->ind[i] = k;
}
vector_size_t r;
vec3 edge0, edge1, t;
vec2 uv0, uv1;
r.begin = r.end = r.capacity_end = 0;
for (vertex_data* i = vert_list.begin; i != vert_list.end; i++) {
vec3 p = i->pos;
vec3 n = i->normal;
vec3 pos, normal;
for (size_t j = 0; j < length; j++) {
pos = verts[j].pos;
normal = verts[j].normal;
if (p.x == pos.x && p.y == pos.y && p.z == pos.z
&& n.x == normal.x && n.y == normal.y && n.z == normal.z)
vector_size_t_push_back(&r, &j);
}
if (r.end - r.begin < 1) {
vector_size_t_clear(&r);
continue;
}
t = vec3_null;
for (size_t* j = r.begin; j != r.end; j++) {
vec3 t0, t1;
vertex_data* v1 = &verts[*j / 3 * 3 + 0];
vertex_data* v2 = &verts[*j / 3 * 3 + 1];
vertex_data* v3 = &verts[*j / 3 * 3 + 2];
vec2_sub(v2->uv[0], v1->uv[0], uv0);
vec2_sub(v3->uv[0], v1->uv[0], uv1);
if (uv0.x * uv1.y - uv1.x * uv0.y != 0) {
vec3_sub(v2->pos, v1->pos, edge0);
vec3_sub(v3->pos, v1->pos, edge1);
vec3_mult_scalar(edge0, uv1.y, t0);
vec3_mult_scalar(edge1, uv0.y, t1);
vec3_sub(t0, t1, t1);
vec3_mult_scalar(t1, 1.0f / (uv0.x * uv1.y - uv1.x * uv0.y), t1);
vec3_normalize(t1, t1);
vec3_add(t, t1, t);
if (normal) {
vec3 edge0, edge1, t;
vec2 uv0, uv1;
vector_size_t r = { 0, 0, 0 };
vector_size_t_append(&r, length);
for (vertex_pre_data* i = vert_list.begin; i != vert_list.end; i++) {
vec3 p = i->pos;
vec3 n = i->normal;
for (size_t j = 0; j < length; j++) {
vec3 pos = verts[j].pos;
vec3 normal = verts[j].normal;
if (p.x == pos.x && p.y == pos.y && p.z == pos.z
&& n.x == normal.x && n.y == normal.y && n.z == normal.z)
vector_size_t_push_back(&r, &j);
}
if (r.end - r.begin < 1) {
vector_size_t_clear(&r);
continue;
}
t = vec3_null;
for (size_t* j = r.begin; j != r.end; j++) {
vec3 t0, t1;
vertex_pre_data* v1 = &verts[*j / 3 * 3 + 0];
vertex_pre_data* v2 = &verts[*j / 3 * 3 + 1];
vertex_pre_data* v3 = &verts[*j / 3 * 3 + 2];
vec2_sub(v2->uv, v1->uv, uv0);
vec2_sub(v3->uv, v1->uv, uv1);
if (uv0.x * uv1.y - uv1.x * uv0.y != 0) {
vec3_sub(v2->pos, v1->pos, edge0);
vec3_sub(v3->pos, v1->pos, edge1);
vec3_mult_scalar(edge0, uv1.y, t0);
vec3_mult_scalar(edge1, uv0.y, t1);
vec3_sub(t0, t1, t1);
vec3_mult_scalar(t1, 1.0f / (uv0.x * uv1.y - uv1.x * uv0.y), t1);
vec3_normalize(t1, t1);
vec3_add(t, t1, t);
}
}
vec3_mult_scalar(t, 1.0f / (float_t)(r.end - r.begin), t);
vec3_normalize(t, i->tangent);
vector_size_t_clear(&r);
}
vector_size_t_clear(&r);
vec3_mult_scalar(t, 1.0f / (float_t)(r.end - r.begin), t);
vec3_normalize(t, i->tangent);
vector_size_t_free(&r);
}
free(r.begin);
free(verts);
v->vert_count = vert_list.end - vert_list.begin;
if (bones) {
if (use_bone_data)
v->type = VERTEX_BONED;
v->vert = force_malloc_s(56, v->vert_count);
uint64_t vert_ptr = (uint64_t)v->vert;
for (size_t i = 0; i < v->vert_count; i++) {
vertex_data* vert = &vert_list.begin[i];
*(float_t*)(vert_ptr + 0) = vert->pos.x;
*(float_t*)(vert_ptr + 4) = vert->pos.y;
*(float_t*)(vert_ptr + 8) = vert->pos.z;
*(half_t*)(vert_ptr + 12) = float_to_half(vert->uv[0].x);
*(half_t*)(vert_ptr + 14) = float_to_half(vert->uv[0].y);
*(half_t*)(vert_ptr + 16) = float_to_half(vert->uv[1].x);
*(half_t*)(vert_ptr + 18) = float_to_half(vert->uv[1].y);
*(half_t*)(vert_ptr + 20) = float_to_half(vert->color.x);
*(half_t*)(vert_ptr + 22) = float_to_half(vert->color.y);
*(half_t*)(vert_ptr + 24) = float_to_half(vert->color.z);
*(half_t*)(vert_ptr + 26) = float_to_half(vert->color.w);
*(half_t*)(vert_ptr + 28) = float_to_half(vert->normal.x);
*(half_t*)(vert_ptr + 30) = float_to_half(vert->normal.y);
*(half_t*)(vert_ptr + 32) = float_to_half(vert->normal.z);
*(half_t*)(vert_ptr + 34) = float_to_half(vert->tangent.x);
*(half_t*)(vert_ptr + 36) = float_to_half(vert->tangent.y);
*(half_t*)(vert_ptr + 38) = float_to_half(vert->tangent.z);
*(uint16_t*)(vert_ptr + 40) = vert->bone_index[0];
*(uint16_t*)(vert_ptr + 42) = vert->bone_index[1];
*(uint16_t*)(vert_ptr + 44) = vert->bone_index[2];
*(uint16_t*)(vert_ptr + 46) = vert->bone_index[3];
*(half_t*)(vert_ptr + 48) = float_to_half(vert->bone_weight[0]);
*(half_t*)(vert_ptr + 50) = float_to_half(vert->bone_weight[1]);
*(half_t*)(vert_ptr + 52) = float_to_half(vert->bone_weight[2]);
*(half_t*)(vert_ptr + 54) = float_to_half(vert->bone_weight[3]);
vert_ptr += 56;
}
}
else {
else
v->type = VERTEX_SIMPLE;
v->vert = force_malloc_s(40, v->vert_count);
uint64_t vert_ptr = (uint64_t)v->vert;
for (size_t i = 0; i < v->vert_count; i++) {
vertex_data* vert = &vert_list.begin[i];
*(float_t*)(vert_ptr + 0) = vert->pos.x;
*(float_t*)(vert_ptr + 4) = vert->pos.y;
*(float_t*)(vert_ptr + 8) = vert->pos.z;
*(half_t*)(vert_ptr + 12) = float_to_half(vert->uv[0].x);
*(half_t*)(vert_ptr + 14) = float_to_half(vert->uv[0].y);
*(half_t*)(vert_ptr + 16) = float_to_half(vert->uv[1].x);
*(half_t*)(vert_ptr + 18) = float_to_half(vert->uv[1].y);
*(half_t*)(vert_ptr + 20) = float_to_half(vert->color.x);
*(half_t*)(vert_ptr + 22) = float_to_half(vert->color.y);
*(half_t*)(vert_ptr + 24) = float_to_half(vert->color.z);
*(half_t*)(vert_ptr + 26) = float_to_half(vert->color.w);
*(half_t*)(vert_ptr + 28) = float_to_half(vert->normal.x);
*(half_t*)(vert_ptr + 30) = float_to_half(vert->normal.y);
*(half_t*)(vert_ptr + 32) = float_to_half(vert->normal.z);
*(half_t*)(vert_ptr + 34) = float_to_half(vert->tangent.x);
*(half_t*)(vert_ptr + 36) = float_to_half(vert->tangent.y);
*(half_t*)(vert_ptr + 38) = float_to_half(vert->tangent.z);
vert_ptr += 40;
}
v->vert = force_malloc_s(vertex_data, v->vert_count);
if (!v->vert) {
vector_vertex_pre_data_free(&vert_list);
vertex_bounding_box bound_box;
bound_box.min = vec3_null;
bound_box.max = vec3_null;
v->bound_box = bound_box;
return;
}
free(vert_list.begin);
free(verts);
vec3 bound_box_min = (vec3){ FLT_MAX, FLT_MAX, FLT_MAX };
vec3 bound_box_max = (vec3){ -FLT_MAX, -FLT_MAX, -FLT_MAX };
vertex_data* vert_ptr = v->vert;
for (vertex_pre_data* i = vert_list.begin; i != vert_list.end; i++) {
vec3 pos;
vec2 uv;
vec2 uv2;
vec4 color;
vec3 normal;
vec3 tangent;
vec4i bone_index;
vec4 bone_weight;
pos = i->pos;
uv = i->uv;
uv2 = i->uv2;
color = i->color;
normal = i->normal;
tangent = i->tangent;
bone_index = i->bone_index;
bone_weight = i->bone_weight;
vec3_min(bound_box_min, pos, bound_box_min);
vec3_max(bound_box_max, pos, bound_box_max);
vec3_mult_min_max_scalar(normal, -32768.0f, 32767.0f, normal);
vec3_mult_min_max_scalar(tangent, -32768.0f, 32767.0f, tangent);
vec4_mult_scalar(bone_weight, 255.0f, bone_weight);
vert_ptr->pos = pos;
vert_ptr->uv.x = float_to_half(uv.x);
vert_ptr->uv.y = float_to_half(uv.y);
vert_ptr->uv2.x = float_to_half(uv2.x);
vert_ptr->uv2.y = float_to_half(uv2.y);
vert_ptr->color.r = float_to_half(color.x);
vert_ptr->color.g = float_to_half(color.y);
vert_ptr->color.b = float_to_half(color.z);
vert_ptr->color.a = float_to_half(color.w);
vert_ptr->normal.x = (int16_t)normal.x;
vert_ptr->normal.y = (int16_t)normal.y;
vert_ptr->normal.z = (int16_t)normal.z;
vert_ptr->tangent.x = (int16_t)tangent.x;
vert_ptr->tangent.y = (int16_t)tangent.y;
vert_ptr->tangent.z = (int16_t)tangent.z;
vert_ptr->bone_index.x = (uint16_t)bone_index.x;
vert_ptr->bone_index.y = (uint16_t)bone_index.y;
vert_ptr->bone_index.z = (uint16_t)bone_index.z;
vert_ptr->bone_index.w = (uint16_t)bone_index.w;
vert_ptr->bone_weight.x = (uint8_t)bone_weight.x;
vert_ptr->bone_weight.y = (uint8_t)bone_weight.y;
vert_ptr->bone_weight.z = (uint8_t)bone_weight.z;
vert_ptr->bone_weight.w = (uint8_t)bone_weight.w;
vert_ptr++;
}
vector_vertex_pre_data_free(&vert_list);
v->bound_box.min = bound_box_min;
v->bound_box.max = bound_box_max;
}
void vertex_dispose(vertex* v) {
@@ -261,4 +321,4 @@ void vertex_dispose(vertex* v) {
free(v);
}
vector_func(vertex_data)
vector_func(vertex_pre_data)

Some files were not shown because too many files have changed in this diff Show More