Compare commits
No commits in common. "f7a429cfbc08cf979b9b921207bfd74958e90c02" and "96da001734a452505f3e8e109e3a605cee9ddb88" have entirely different histories.
f7a429cfbc
...
96da001734
2
k3ex.py
2
k3ex.py
@ -115,8 +115,6 @@ def write_some_data(context, filepath, doExportEverything):
|
|||||||
out.write(struct.pack("4f", m.col[c][0], m.col[c][1], m.col[c][2], m.col[c][3]))
|
out.write(struct.pack("4f", m.col[c][0], m.col[c][1], m.col[c][2], m.col[c][3]))
|
||||||
for b in dabones:
|
for b in dabones:
|
||||||
out.write(struct.pack("B", dabones.index(b.parent) if b.parent else 255))
|
out.write(struct.pack("B", dabones.index(b.parent) if b.parent else 255))
|
||||||
for b in dabones:
|
|
||||||
out.write(b.name.encode("UTF-8") + b'\x00')
|
|
||||||
|
|
||||||
for v in vertdict.keys():
|
for v in vertdict.keys():
|
||||||
out.write(struct.pack("3f", v[0][0], v[0][2], -v[0][1]))
|
out.write(struct.pack("3f", v[0][0], v[0][2], -v[0][1]))
|
||||||
|
11
src/game.c
11
src/game.c
@ -685,7 +685,7 @@ void game_update() {
|
|||||||
|
|
||||||
size_t boneCount = Game.entities.render[ci].cache ? k3MdlGetBoneCount(Game.entities.render[ci].cache) : 0;
|
size_t boneCount = Game.entities.render[ci].cache ? k3MdlGetBoneCount(Game.entities.render[ci].cache) : 0;
|
||||||
if(boneCount) {
|
if(boneCount) {
|
||||||
/*struct CBoned *cb = game_getcomponent(Game.entities.render[ci].entity, boned);
|
struct CBoned *cb = game_getcomponent(Game.entities.render[ci].entity, boned);
|
||||||
|
|
||||||
if(!cb) {
|
if(!cb) {
|
||||||
cb = game_ensurecomponent(Game.entities.render[ci].entity, boned);
|
cb = game_ensurecomponent(Game.entities.render[ci].entity, boned);
|
||||||
@ -741,7 +741,7 @@ void game_update() {
|
|||||||
glm_decompose(cb->anim.cache.inter[m], cb->bones[m].translation, rot, scaleignore);
|
glm_decompose(cb->anim.cache.inter[m], cb->bones[m].translation, rot, scaleignore);
|
||||||
glm_mat4_quat(cb->anim.cache.inter[m], cb->bones[m].rotation);
|
glm_mat4_quat(cb->anim.cache.inter[m], cb->bones[m].rotation);
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dGeomID gid = cp->geom;
|
dGeomID gid = cp->geom;
|
||||||
@ -776,7 +776,7 @@ void game_update() {
|
|||||||
|
|
||||||
for(size_t cm = 0; cm < Game.entities.movementCount; cm++) {
|
for(size_t cm = 0; cm < Game.entities.movementCount; cm++) {
|
||||||
struct CBoned *cb = game_getcomponent(Game.entities.movement[cm].entity, boned);
|
struct CBoned *cb = game_getcomponent(Game.entities.movement[cm].entity, boned);
|
||||||
/*if(cb && cb->anim.standard) {
|
if(cb && cb->anim.standard) {
|
||||||
struct CPhysics *cp = game_getcomponent(Game.entities.movement[cm].entity, physics);
|
struct CPhysics *cp = game_getcomponent(Game.entities.movement[cm].entity, physics);
|
||||||
if(cp && cp->geom) {
|
if(cp && cp->geom) {
|
||||||
dBodyID bid = dGeomGetBody(cp->geom);
|
dBodyID bid = dGeomGetBody(cp->geom);
|
||||||
@ -789,7 +789,7 @@ void game_update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(size_t i = 0; i < Game.conveyorCount; i++) {
|
for(size_t i = 0; i < Game.conveyorCount; i++) {
|
||||||
@ -876,6 +876,7 @@ void game_update() {
|
|||||||
vec3 dif;
|
vec3 dif;
|
||||||
glm_vec3_sub(conveyor->points[nextPoint], conveyor->points[currentPoint], dif);
|
glm_vec3_sub(conveyor->points[nextPoint], conveyor->points[currentPoint], dif);
|
||||||
glm_vec3_scale_as(dif, conveyor->speed * (conveyor->active <= 0 ? -1 : 1), dif);
|
glm_vec3_scale_as(dif, conveyor->speed * (conveyor->active <= 0 ? -1 : 1), dif);
|
||||||
|
//printf("set %f %f %f\n", dif[0], dif[1], dif[2]);
|
||||||
dBodySetLinearVel(bid, dif[0], dif[1], dif[2]); // doesn't affect movement, but necessary for proper collision response
|
dBodySetLinearVel(bid, dif[0], dif[1], dif[2]); // doesn't affect movement, but necessary for proper collision response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -949,7 +950,7 @@ void game_cleanup() {
|
|||||||
Game.entities.renderCount = 0;
|
Game.entities.renderCount = 0;
|
||||||
|
|
||||||
for(size_t i = 0; i < Game.entities.bonedCount; i++) {
|
for(size_t i = 0; i < Game.entities.bonedCount; i++) {
|
||||||
//free(Game.entities.boned[i].bones);
|
free(Game.entities.boned[i].bones);
|
||||||
}
|
}
|
||||||
Game.entities.bonedCount = 0;
|
Game.entities.bonedCount = 0;
|
||||||
|
|
||||||
|
@ -118,7 +118,14 @@ struct CPlayerCtrl {
|
|||||||
struct CBoned {
|
struct CBoned {
|
||||||
uint16_t entity;
|
uint16_t entity;
|
||||||
|
|
||||||
struct k3Animator animator;
|
size_t size;
|
||||||
|
struct k3AnimationBone *bones;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint16_t id;
|
||||||
|
struct k3Animator cache;
|
||||||
|
bool standard;
|
||||||
|
} anim;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CONVEYOR_TYPE_LOOP 0
|
#define CONVEYOR_TYPE_LOOP 0
|
||||||
|
@ -33,17 +33,6 @@ static int mdlloader(void *ud, struct ResManRes *res) {
|
|||||||
uint8_t *boneParents = malloc(header.boneCount);
|
uint8_t *boneParents = malloc(header.boneCount);
|
||||||
fread(boneParents, 1, header.boneCount, f);
|
fread(boneParents, 1, header.boneCount, f);
|
||||||
|
|
||||||
char boneNames[1500] = {};
|
|
||||||
size_t boneNamesLen = 0;
|
|
||||||
for(size_t b = 0; b < header.boneCount; b++) {
|
|
||||||
while(1) {
|
|
||||||
fread(boneNames + boneNamesLen, 1, 1, f);
|
|
||||||
if(boneNames[boneNamesLen++] == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 *pos = malloc(sizeof(*pos) * header.vertCount);
|
vec3 *pos = malloc(sizeof(*pos) * header.vertCount);
|
||||||
fread(pos, sizeof(vec3), header.vertCount, f);
|
fread(pos, sizeof(vec3), header.vertCount, f);
|
||||||
|
|
||||||
@ -70,8 +59,6 @@ static int mdlloader(void *ud, struct ResManRes *res) {
|
|||||||
|
|
||||||
struct k3Mdl *mdl = k3MdlCreate(header.vertCount, header.indCount, header.boneCount, pos, nrm, uvs, cols, boneIDs, boneWeights, inds, invBind, boneParents);
|
struct k3Mdl *mdl = k3MdlCreate(header.vertCount, header.indCount, header.boneCount, pos, nrm, uvs, cols, boneIDs, boneWeights, inds, invBind, boneParents);
|
||||||
|
|
||||||
k3MdlSetBoneNames(mdl, boneNames);
|
|
||||||
|
|
||||||
k3MdlSetDebugName(mdl, res->name);
|
k3MdlSetDebugName(mdl, res->name);
|
||||||
|
|
||||||
free(pos);
|
free(pos);
|
||||||
@ -100,19 +87,22 @@ static int mdlloader(void *ud, struct ResManRes *res) {
|
|||||||
for(size_t i = 0; i < header.animCount; i++) {
|
for(size_t i = 0; i < header.animCount; i++) {
|
||||||
struct {
|
struct {
|
||||||
uint16_t id;
|
uint16_t id;
|
||||||
uint16_t frameCount;
|
uint16_t frames;
|
||||||
uint16_t fps;
|
uint16_t fps;
|
||||||
uint16_t zero;
|
uint16_t zero;
|
||||||
} info;
|
} info;
|
||||||
fread(&info, sizeof(info), 1, f);
|
fread(&info, sizeof(info), 1, f);
|
||||||
|
|
||||||
struct k3AnimationFountain *anim = _mm_malloc(sizeof(*anim) + sizeof(*anim->frames) * info.frameCount * header.boneCount, 16);
|
struct k3Animation *anim = malloc(sizeof(*anim));
|
||||||
|
anim->frames = _mm_malloc(sizeof(*anim->frames) * info.frames * header.boneCount, 16);
|
||||||
|
anim->boneParents = boneParents;
|
||||||
|
anim->invBind = invBind;
|
||||||
anim->id = info.id;
|
anim->id = info.id;
|
||||||
anim->fps = info.fps;
|
anim->fps = info.fps;
|
||||||
anim->frameCount = info.frameCount;
|
anim->frameCount = info.frames;
|
||||||
anim->bones = header.boneCount;
|
anim->boneCount = header.boneCount;
|
||||||
|
|
||||||
fread(anim->frames, sizeof(*anim->frames), info.frameCount * header.boneCount, f);
|
fread(anim->frames, sizeof(*anim->frames), info.frames * header.boneCount, f);
|
||||||
|
|
||||||
k3MdlAddAnim(mdl, anim);
|
k3MdlAddAnim(mdl, anim);
|
||||||
}
|
}
|
||||||
@ -340,8 +330,6 @@ static int fontloader(void *ud, struct ResManRes *res) {
|
|||||||
}
|
}
|
||||||
k3FontLoad(fnt, fntbuf, fntfsz, fnttexldr);
|
k3FontLoad(fnt, fntbuf, fntfsz, fnttexldr);
|
||||||
|
|
||||||
free(fntbuf);
|
|
||||||
|
|
||||||
res->thing = fnt;
|
res->thing = fnt;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
948
src/luaapi.c
948
src/luaapi.c
File diff suppressed because it is too large
Load Diff
56
src/main.c
56
src/main.c
@ -41,8 +41,6 @@
|
|||||||
#include<ctype.h>
|
#include<ctype.h>
|
||||||
|
|
||||||
GLFWwindow *GameWnd;
|
GLFWwindow *GameWnd;
|
||||||
uint16_t GameWndW;
|
|
||||||
uint16_t GameWndH;
|
|
||||||
|
|
||||||
static int TextureResolutionReduction = 0;
|
static int TextureResolutionReduction = 0;
|
||||||
|
|
||||||
@ -72,6 +70,9 @@ static double xposold, yposold;
|
|||||||
static void buttoncallback(GLFWwindow *GameWnd, int button, int action, int mods) {
|
static void buttoncallback(GLFWwindow *GameWnd, int button, int action, int mods) {
|
||||||
if(button == GLFW_MOUSE_BUTTON_LEFT) {
|
if(button == GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
if(UiActive) {
|
if(UiActive) {
|
||||||
|
int ww, wh;
|
||||||
|
glfwGetWindowSize(GameWnd, &ww, &wh);
|
||||||
|
|
||||||
struct k3MEvent ev = {
|
struct k3MEvent ev = {
|
||||||
.original = (void*) UiActive,
|
.original = (void*) UiActive,
|
||||||
.target = (void*) UiActive,
|
.target = (void*) UiActive,
|
||||||
@ -79,8 +80,8 @@ static void buttoncallback(GLFWwindow *GameWnd, int button, int action, int mods
|
|||||||
.code = action == GLFW_PRESS ? k3M_EVENT_MOUSE_PRESS : k3M_EVENT_MOUSE_RELEASE,
|
.code = action == GLFW_PRESS ? k3M_EVENT_MOUSE_PRESS : k3M_EVENT_MOUSE_RELEASE,
|
||||||
.mouse = {
|
.mouse = {
|
||||||
.button = k3M_MOUSE_BUTTON_0,
|
.button = k3M_MOUSE_BUTTON_0,
|
||||||
.x = xposold * UiActive->w / GameWndW,
|
.x = xposold * UiActive->w / ww,
|
||||||
.y = yposold * UiActive->h / GameWndH,
|
.y = (wh - yposold - 1) * UiActive->h / wh,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -109,8 +110,11 @@ static void motioncallback(GLFWwindow *GameWnd, double xpos, double ypos) {
|
|||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
if(UiActive) {
|
if(UiActive) {
|
||||||
uint16_t uix = xposold * UiActive->w / GameWndW;
|
int ww, wh;
|
||||||
uint16_t uiy = yposold * UiActive->h / GameWndH;
|
glfwGetWindowSize(GameWnd, &ww, &wh);
|
||||||
|
|
||||||
|
uint16_t uix = xposold * UiActive->w / ww;
|
||||||
|
uint16_t uiy = (wh - yposold - 1) * UiActive->h / wh;
|
||||||
|
|
||||||
struct k3MEvent ev = {
|
struct k3MEvent ev = {
|
||||||
.original = (void*) UiActive,
|
.original = (void*) UiActive,
|
||||||
@ -168,16 +172,8 @@ static void charcallback(GLFWwindow *window, unsigned int codepoint) {
|
|||||||
|
|
||||||
static void fix_resol();
|
static void fix_resol();
|
||||||
static void resizecallback(GLFWwindow *window, int width, int height) {
|
static void resizecallback(GLFWwindow *window, int width, int height) {
|
||||||
k3Resize(GameWndW = width, GameWndH = height);
|
k3Resize(width, height);
|
||||||
fix_resol();
|
fix_resol();
|
||||||
|
|
||||||
if(UiActive) {
|
|
||||||
UiActive->w = UiActive->wDesired = GameWndW;
|
|
||||||
UiActive->h = UiActive->hDesired = GameWndH;
|
|
||||||
|
|
||||||
k3MMeasure(UiActive);
|
|
||||||
k3MArrange(UiActive);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int argc;
|
static int argc;
|
||||||
@ -221,17 +217,14 @@ static int eng_init() {
|
|||||||
#define START_WIDTH 960
|
#define START_WIDTH 960
|
||||||
#define START_HEIGHT 540
|
#define START_HEIGHT 540
|
||||||
#define START_TITLE "k4"
|
#define START_TITLE "k4"
|
||||||
|
|
||||||
GameWndW = START_WIDTH;
|
|
||||||
GameWndH = START_HEIGHT;
|
|
||||||
|
|
||||||
// Prefer core
|
// Prefer core
|
||||||
if(!k4_get_arg("core") || strcmp(k4_get_arg("core"), "0")) {
|
if(!k4_get_arg("core") || strcmp(k4_get_arg("core"), "0")) {
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
GameWnd = glfwCreateWindow(GameWndW, GameWndH, START_TITLE, NULL, NULL);
|
GameWnd = glfwCreateWindow(START_WIDTH, START_HEIGHT, START_TITLE, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt compatibility
|
// Attempt compatibility
|
||||||
@ -240,7 +233,7 @@ static int eng_init() {
|
|||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
GameWnd = glfwCreateWindow(GameWndW, GameWndH, START_TITLE, NULL, NULL);
|
GameWnd = glfwCreateWindow(START_WIDTH, START_HEIGHT, START_TITLE, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
k3MixInit(44100, 2);
|
k3MixInit(44100, 2);
|
||||||
@ -283,9 +276,7 @@ static int eng_init() {
|
|||||||
|
|
||||||
k3SetLogCallback(k4k3LogCallback);
|
k3SetLogCallback(k4k3LogCallback);
|
||||||
|
|
||||||
k3Init(
|
k3Init();
|
||||||
!k4_get_arg("tc") || strtol(k4_get_arg("tc"), NULL, 0) != 0,
|
|
||||||
!k4_get_arg("mipmap") || strtol(k4_get_arg("mipmap"), NULL, 0) != 0);
|
|
||||||
|
|
||||||
k3BatchInit();
|
k3BatchInit();
|
||||||
|
|
||||||
@ -442,9 +433,6 @@ int main(int argc_, char **argv_) {
|
|||||||
|
|
||||||
net_hi_update(CurrentTime);
|
net_hi_update(CurrentTime);
|
||||||
|
|
||||||
int windowW, windowH;
|
|
||||||
glfwGetWindowSize(GameWnd, &windowW, &windowH);
|
|
||||||
|
|
||||||
float alpha = fmodf(accumulator * GAME_TPS, 1.f);
|
float alpha = fmodf(accumulator * GAME_TPS, 1.f);
|
||||||
|
|
||||||
vec3 cameraForwardDir = {0, 0, -1};
|
vec3 cameraForwardDir = {0, 0, -1};
|
||||||
@ -602,11 +590,7 @@ int main(int argc_, char **argv_) {
|
|||||||
if(c->cache) {
|
if(c->cache) {
|
||||||
struct CBoned *b = game_getcomponent(c->entity, boned);
|
struct CBoned *b = game_getcomponent(c->entity, boned);
|
||||||
|
|
||||||
if(b && b->animator.anim) {
|
k3Batch(c->cache, transform, b ? b->bones : NULL);
|
||||||
k3AnimatorStep(&b->animator, dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
k3Batch(c->cache, transform, b ? b->animator.bones : NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,7 +640,13 @@ int main(int argc_, char **argv_) {
|
|||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
k3BatchSetResolution(windowW, windowH);
|
if(!k3IsCore) {
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrtho(0, 3600, 0, 2025, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
luaapi_render2d();
|
luaapi_render2d();
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ static void interpret_pkt(ENetPacket *pkt) {
|
|||||||
c->holding = b_ru16(&b);
|
c->holding = b_ru16(&b);
|
||||||
} if(ctype == CMD_CTYPE_BONED) {
|
} if(ctype == CMD_CTYPE_BONED) {
|
||||||
struct CBoned *c = game_ensurecomponent(ent, boned);
|
struct CBoned *c = game_ensurecomponent(ent, boned);
|
||||||
/*c->anim.standard =*/ b_ru8(&b);
|
c->anim.standard = b_ru8(&b);
|
||||||
}
|
}
|
||||||
} else if(cmd == CMD_SC_POSUPDATE) {
|
} else if(cmd == CMD_SC_POSUPDATE) {
|
||||||
uint16_t lastOurTick = b_ru16(&b);
|
uint16_t lastOurTick = b_ru16(&b);
|
||||||
|
@ -121,7 +121,7 @@ static void send_full_state(ENetPeer **peers, size_t peerCount) {
|
|||||||
|
|
||||||
b_wu16(&b, c->entity);
|
b_wu16(&b, c->entity);
|
||||||
|
|
||||||
b_wu8(&b, 0/*c->anim.standard*/);
|
b_wu8(&b, c->anim.standard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(peers) {
|
if(peers) {
|
||||||
|
Loading…
Reference in New Issue
Block a user