shithub: renderfs

Download patch

ref: 7ca15d3d92fbe86ba688758f3ef07db3c787d504
parent: 0469e025814868bdf409a28b92550aea18c27661
author: rodri <[email protected]>
date: Mon Apr 1 12:22:58 EDT 2024

fix typo and get it working.

--- a/fs.c
+++ b/fs.c
@@ -128,8 +128,11 @@
 	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 @@
 	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 @@
 		/* 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,6 +463,7 @@
 			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)
@@ -462,7 +470,8 @@
 				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 @@
 		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){