~rabbits/moogle

74055b9a6a589bfc67cd3910e7d0bde8230b36e2 — neauoire 1 year, 11 months ago a422d40
Added sphere primitive
1 files changed, 14 insertions(+), 0 deletions(-)

M src/moogle.c
M src/moogle.c => src/moogle.c +14 -0
@@ 703,6 703,20 @@ createprism(Scene *s, double radius, int segs, double depth, int color)
}

Mesh *
createsphere(Scene *s, double radius, double segs, double ssegs, int color)
{
	double i;
	Mesh *m = addmesh(s);
	for(i = 0; i < segs; i++) {
		double j = i - segs / 2;
		addshape(m, sqrt(radius * radius - j * j), ssegs, color);
		moveto(s, 0, 0, i + 1 - segs / 2);
	}
	reset(s);
	return m;
}

Mesh *
createplane(Scene *s, double width, double height, double xsegs, double ysegs, int color)
{
	int ix, iy;