intravenous
diff src/vein.cc @ 6:2723dc026c4f
collision detection
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 23 Apr 2012 21:43:10 +0300 |
parents | aab0d8ea21cd |
children | 90af225f469a |
line diff
1.1 --- a/src/vein.cc Sun Apr 22 06:26:08 2012 +0300 1.2 +++ b/src/vein.cc Mon Apr 23 21:43:10 2012 +0300 1.3 @@ -29,20 +29,6 @@ 1.4 free_program(sdr); 1.5 } 1.6 1.7 -Vector3 Vein::calc_center(const Vector3 &ppos) const 1.8 -{ 1.9 - Vector3 pt{0, 0, ppos.z}; 1.10 - pt.x = sin(ppos.z * 0.75); 1.11 - pt.y = cos(ppos.z * 0.2) * 0.6; 1.12 - return pt; 1.13 -} 1.14 - 1.15 -Vector3 Vein::calc_dir(const Vector3 &ppos) const 1.16 -{ 1.17 - Vector3 dir = calc_center(ppos + Vector3(0, 0, 0.01)) - calc_center(ppos - Vector3(0, 0, 0.01)); 1.18 - return dir.normalized(); 1.19 -} 1.20 - 1.21 void Vein::build_idxbuf() 1.22 { 1.23 delete [] idxbuf; 1.24 @@ -80,6 +66,16 @@ 1.25 return true; 1.26 } 1.27 1.28 +void Vein::set_radius(float rad) 1.29 +{ 1.30 + this->rad = rad; 1.31 +} 1.32 + 1.33 +float Vein::get_radius() const 1.34 +{ 1.35 + return rad; 1.36 +} 1.37 + 1.38 void Vein::set_fog_color(const Vector3 &col) 1.39 { 1.40 fog_color = col; 1.41 @@ -110,12 +106,12 @@ 1.42 Vector3 right = cross_product(up, dir); 1.43 up = cross_product(dir, right); 1.44 1.45 - Matrix3x3 vrot{right, up, dir}; 1.46 + Matrix3x3 vrot(right, up, dir); 1.47 vrot.transpose(); 1.48 1.49 float theta = 0.0, dtheta = 2.0 * M_PI / (ring_subdiv - 1); 1.50 for(int j=0; j<ring_subdiv; j++) { 1.51 - Vector3 vec = Vector3{-cos(theta) * rad, sin(theta) * rad, 0.0}; 1.52 + Vector3 vec = Vector3(-cos(theta) * rad, sin(theta) * rad, 0.0); 1.53 vec.transform(vrot); 1.54 vec += cent; 1.55 1.56 @@ -149,3 +145,17 @@ 1.57 1.58 glPopMatrix(); 1.59 } 1.60 + 1.61 +Vector3 Vein::calc_center(const Vector3 &ppos) const 1.62 +{ 1.63 + Vector3 pt(0, 0, ppos.z); 1.64 + pt.x = sin(ppos.z * 0.75); 1.65 + pt.y = cos(ppos.z * 0.2) * 0.6; 1.66 + return pt; 1.67 +} 1.68 + 1.69 +Vector3 Vein::calc_dir(const Vector3 &ppos) const 1.70 +{ 1.71 + Vector3 dir = calc_center(ppos + Vector3(0, 0, 0.01)) - calc_center(ppos - Vector3(0, 0, 0.01)); 1.72 + return dir.normalized(); 1.73 +}