polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit 3a3aab38cacdfc2b4c098c5bf85a7dd83526884e
parent 81db5b59d2893dc264c68343db9aceb414295084
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 25 Oct 2018 14:18:52 -0700

update ply a bit

Diffstat:
Msrc/game.c | 2+-
Msrc/ply.c | 15++++++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -65,7 +65,7 @@ void game_init(struct game *game) { node_init(&terrain->entity.node); // player init - ok = load_model(&player->model, "lambo"); + ok = load_model(&player->model, "palm-tree"); assert(ok); player->model.program = res->program.handle; player->node.label = "player"; diff --git a/src/ply.c b/src/ply.c @@ -51,13 +51,16 @@ static int parse_element(const char **cursor, const char *element, int *nverts) static inline int parse_vertex(const char **cursor, float *v, float *n, u8 *c) { + static float st[2]; + int matched = - sscanf(*cursor, "%f %f %f %f %f %f %hhu %hhu %hhu", + sscanf(*cursor, "%f %f %f %f %f %f %f %f %hhu %hhu %hhu", &v[0], &v[1], &v[2], &n[0], &n[1], &n[2], + &st[0], &st[1], &c[0], &c[1], &c[2]); - return matched == 9; + return matched == 11; } @@ -72,12 +75,14 @@ static int parse_indices(const char **cursor, int *inds) { static int parse_header(const char **cursor, int *nverts, int *ninds) { int ok = 0; ok = parse_element(cursor, "vertex", nverts); + if (ok) return 1; - // only parse one thing at a time - if (ok) - return 1; + ok = parse_element(cursor, "face", ninds); + if (ok) return 1; ok = parse_element(cursor, "face", ninds); + if (ok) return 1; + return ok; }