shithub: 3dee

Download patch

ref: 02597db21d25fedde53513967cd979d38acbceec
parent: 978b44f127e2eeda9ec73849ab9041ead5519ca6
author: rodri <rgl@antares-labs.eu>
date: Wed Aug 7 07:49:20 EDT 2024

use the new readobjmodel function.

--- a/mkfile
+++ b/mkfile
@@ -14,8 +14,8 @@
 HFILES=dat.h fns.h
 
 LIB=\
-	libobj/libobj.a$O\
 	libgraphics/libgraphics.a$O\
+	libobj/libobj.a$O\
 
 </sys/src/cmd/mkmany
 
--- a/solar.c
+++ b/solar.c
@@ -733,7 +733,6 @@
 	Channel *keyc;
 	Entity *subject;
 	Model *model;
-	OBJ *obj;
 	Point lblsiz;
 	int i, j;
 
@@ -750,11 +749,7 @@
 
 	confproc();
 
-	if((obj = objparse("mdl/planet.obj")) == nil)
-		sysfatal("objparse: %r");
-	model = newmodel();
-	loadobjmodel(model, obj);
-	objfree(obj);
+	model = readobjmodel("mdl/planet.obj");
 	/*
 	 * normalize the vertices so that we can scale
 	 * each planet based on its radius
--- a/vis.c
+++ b/vis.c
@@ -872,7 +872,6 @@
 	Renderer *rctl;
 	Channel *keyc;
 	Entity *subject;
-	OBJ *obj;
 	char *texpath, *mdlpath, *s;
 	int i, fd, fbw, fbh, scale;
 
@@ -909,16 +908,11 @@
 	scene = newscene(nil);
 	while(argc--){
 		mdlpath = argv[argc];
-		model = newmodel();
+		model = readobjmodel(mdlpath);
 		subject = newentity(mdlpath, model);
 //		subject->p.x = argc*4;
 		scene->addent(scene, subject);
 
-		if((obj = objparse(mdlpath)) == nil)
-			sysfatal("objparse: %r");
-		loadobjmodel(model, obj);
-		objfree(obj);
-
 		if(argc == 0 && texpath != nil){
 			fd = open(texpath, OREAD);
 			if(fd < 0)
@@ -957,7 +951,9 @@
 			cams[i]->view->setscalefilter(cams[i]->view, UFScale2x);
 		else if(scale == 3)
 			cams[i]->view->setscalefilter(cams[i]->view, UFScale3x);
-fprint(2, "scalex %g scaley %g\n", cams[i]->view->bx.x, cams[i]->view->by.y);
+		cams[i]->view->p.x = (Dx(screenb->r) - cams[i]->view->getwidth(cams[i]->view))/2;
+		cams[i]->view->p.y = (Dy(screenb->r) - cams[i]->view->getheight(cams[i]->view))/2;
+fprint(2, "off %v scalex %g scaley %g\n", cams[i]->view->p, cams[i]->view->bx.x, cams[i]->view->by.y);
 	}
 	maincam = cams[3];
 	light.p = Pt3(0,100,100,1);