rayzor

annotate 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
rev   line source
nuclear@1 1 #include "object.h"
nuclear@1 2 #include "vmath.h"
nuclear@1 3 #include "min3d.h"
nuclear@1 4
nuclear@1 5 Object::Object()
nuclear@1 6 {
nuclear@1 7 }
nuclear@1 8
nuclear@1 9 Object::~Object()
nuclear@1 10 {
nuclear@1 11 }
nuclear@1 12
nuclear@1 13 // ---- sphere ----
nuclear@1 14 Sphere::Sphere()
nuclear@1 15 {
nuclear@1 16 }
nuclear@1 17
nuclear@1 18 Sphere::~Sphere()
nuclear@1 19 {
nuclear@1 20 }
nuclear@1 21
nuclear@6 22 #define USUB 32
nuclear@6 23 #define VSUB 16
nuclear@1 24
nuclear@1 25 void Sphere::draw() const
nuclear@1 26 {
nuclear@1 27 static Vector3 *varr;
nuclear@1 28 static int num_verts;
nuclear@1 29 if(!varr) {
nuclear@1 30 int uverts = USUB;
nuclear@1 31 int vverts = VSUB + 1;
nuclear@1 32 num_verts = uverts * vverts;
nuclear@1 33 varr = new Vector3[num_verts];
nuclear@1 34
nuclear@1 35 Vector3 *vptr = varr;
nuclear@1 36 for(int i=0; i<uverts; i++) {
nuclear@1 37 float u = (float)i / (float)USUB;
nuclear@1 38 float theta = u * M_PI * 2.0;
nuclear@1 39 for(int j=0; j<vverts; j++) {
nuclear@1 40 float v = (float)j / (float)VSUB;
nuclear@1 41 float phi = (v - 0.5) * M_PI;
nuclear@1 42
nuclear@1 43 float x = sin(theta) * cos(phi);
nuclear@1 44 float y = sin(phi);
nuclear@1 45 float z = cos(theta) * cos(phi);
nuclear@1 46
nuclear@1 47 *vptr++ = Vector3(x, y, z);
nuclear@1 48 }
nuclear@1 49 }
nuclear@1 50 }
nuclear@1 51
nuclear@5 52 m3d_vertex_array(&varr->x);
nuclear@5 53 m3d_draw(M3D_POINTS, num_verts);
nuclear@5 54 m3d_vertex_array(0);
nuclear@1 55 }