intravenous

diff src/ship.cc @ 2:472c28b8b875

I think I pretty much nailed the camera
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 21 Apr 2012 23:03:36 +0300
parents 3ea290d35984
children 94d4c60af435
line diff
     1.1 --- a/src/ship.cc	Sat Apr 21 22:42:43 2012 +0300
     1.2 +++ b/src/ship.cc	Sat Apr 21 23:03:36 2012 +0300
     1.3 @@ -4,7 +4,6 @@
     1.4  Ship::Ship()
     1.5  {
     1.6  	friction = 0.2;
     1.7 -	//theta = phi = 0.0;
     1.8  }
     1.9  
    1.10  void Ship::accelerate(double a)
    1.11 @@ -19,8 +18,6 @@
    1.12  
    1.13  	rot *= qpitch;
    1.14  	rot *= qyaw;
    1.15 -	/*theta += yaw;
    1.16 -	phi += pitch;*/
    1.17  }
    1.18  
    1.19  void Ship::update(time_sec_t dt)
    1.20 @@ -36,18 +33,17 @@
    1.21  
    1.22  Vector3 Ship::get_direction() const
    1.23  {
    1.24 -	static const Vector3 dir{0, 0, 1};
    1.25 +	static const Vector3 dir{0, 0, -1};
    1.26  	return dir.transformed(rot);
    1.27 -	/*Vector3 dir;
    1.28 -	dir.x = sin(theta) * sin(phi);
    1.29 -	dir.z = cos(phi);
    1.30 -	dir.y = cos(theta) * sin(phi);
    1.31 -	return dir;*/
    1.32  }
    1.33  
    1.34  Matrix4x4 Ship::get_matrix() const
    1.35  {
    1.36 -	return Matrix4x4::identity;
    1.37 +	Matrix3x3 rmat = rot.get_rotation_matrix().transposed();
    1.38 +	Matrix4x4 tmat;
    1.39 +	tmat.set_translation(pos);
    1.40 +
    1.41 +	return tmat * Matrix4x4(rmat);
    1.42  }
    1.43  
    1.44  void Ship::dbg_draw() const
    1.45 @@ -70,5 +66,15 @@
    1.46  	glVertex3f(pos.x, pos.y, pos.z);
    1.47  	glEnd();
    1.48  
    1.49 +	glMatrixMode(GL_MODELVIEW);
    1.50 +	glPushMatrix();
    1.51 +	mult_gl_matrix(get_matrix());
    1.52 +
    1.53 +	glScalef(1, 1, -1);
    1.54 +	glColor3f(1, 1, 0);
    1.55 +	glutWireCone(0.1, 0.6, 12, 2);
    1.56 +
    1.57 +	glPopMatrix();
    1.58 +
    1.59  	glPopAttrib();
    1.60  }