From 7ca15d3d92fbe86ba688758f3ef07db3c787d504 Mon Sep 17 00:00:00 2001 From: rodri Date: Mon, 1 Apr 2024 16:22:58 +0000 Subject: fix typo and get it working. --- fs.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/fs.c b/fs.c index 8faeaa9..5bca49d 100644 --- a/fs.c +++ b/fs.c @@ -128,8 +128,11 @@ newclient(void) c->slot = c-clients; c->inuse = 1; c->cam = emalloc9p(sizeof *c->cam); - c->cam->rctl = renderer; + c->cam->fov = 40*DEG; + c->cam->clip.n = 0.01; + c->cam->clip.f = 1000; placecamera(c->cam, Pt3(0,0,100,1), Pt3(0,0,0,1), Vec3(0,1,0)); + c->cam->rctl = renderer; c->cam->s = newscene(nil); return c->slot; } @@ -419,6 +422,7 @@ fswrite(Req *r) char *msg, *f[10]; uvlong path; ulong cnt, nf; + int w, h; path = r->fid->qid.path; cnt = r->ifcall.count; @@ -438,7 +442,10 @@ fswrite(Req *r) /* viewport $width $height */ if(c->cam->vp != nil) rmviewport(c->cam->vp); - c->cam->vp = mkviewport(Rect(0,0,strtoul(f[1], nil, 10),strtoul(f[2], nil, 10))); + + w = strtoul(f[1], nil, 10); + h = strtoul(f[2], nil, 10); + c->cam->vp = mkviewport(Rect(0,0,w,h)); }else if(nf == 5 && strcmp(f[0], "move") == 0 && strcmp(f[1], "camera") == 0){ /* move camera $x $y $z */ c->cam->p.x = strtod(f[2], nil); @@ -456,13 +463,15 @@ fswrite(Req *r) c->cam->fov = strtod(f[1], nil); if(utfrune(f[1], L'°') != nil) c->cam->fov *= DEG; + reloadcamera(c->cam); }else if(nf == 3 && strcmp(f[0], "clip") == 0){ /* clip [near|far] $dz */ if(strcmp(f[1], "near") == 0) c->cam->clip.n = strtod(f[2], nil); else if(strcmp(f[1], "far") == 0) c->cam->clip.f = strtod(f[2], nil); - }else if(nf == 1 && strcmp(f[0], "shoot")) + reloadcamera(c->cam); + }else if(nf == 1 && strcmp(f[0], "shoot") == 0) /* shoot */ shootcamera(c->cam, &auxshaders); @@ -478,7 +487,7 @@ fswrite(Req *r) nf = tokenize(msg, f, nelem(f)); if(nf != 1) goto noscene; - fprint(2, "loading obj from %s", msg); + fprint(2, "loading obj from %s\n", msg); /* TODO load an actual scene (format tbd) */ model = newmodel(); if((model->obj = objparse(f[0])) == nil){ -- cgit v1.2.3