rayzor

view src/object.cc @ 8:fcd06a15dfdd

added missing set_mouse_limits to dosemu.c
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 07 Apr 2014 08:46:06 +0300
parents 5fcf72837b69
children 70e332156d02
line source
1 #include "object.h"
2 #include "vmath.h"
3 #include "min3d.h"
5 Object::Object()
6 {
7 }
9 Object::~Object()
10 {
11 }
13 // ---- sphere ----
14 Sphere::Sphere()
15 {
16 }
18 Sphere::~Sphere()
19 {
20 }
22 #define USUB 32
23 #define VSUB 16
25 void Sphere::draw() const
26 {
27 static Vector3 *varr;
28 static int num_verts;
29 if(!varr) {
30 int uverts = USUB;
31 int vverts = VSUB + 1;
32 num_verts = uverts * vverts;
33 varr = new Vector3[num_verts];
35 Vector3 *vptr = varr;
36 for(int i=0; i<uverts; i++) {
37 float u = (float)i / (float)USUB;
38 float theta = u * M_PI * 2.0;
39 for(int j=0; j<vverts; j++) {
40 float v = (float)j / (float)VSUB;
41 float phi = (v - 0.5) * M_PI;
43 float x = sin(theta) * cos(phi);
44 float y = sin(phi);
45 float z = cos(theta) * cos(phi);
47 *vptr++ = Vector3(x, y, z);
48 }
49 }
50 }
52 m3d_vertex_array(&varr->x);
53 m3d_draw(M3D_POINTS, num_verts);
54 m3d_vertex_array(0);
55 }