void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
{
type.get_bounds(angle-track.get_rotation(), minp, maxp);
void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
{
type.get_bounds(angle-track.get_rotation(), minp, maxp);
- GL::PushMatrix push_mat;
+ const Point &pos = track.get_position();
+ Point minp;
+ Point maxp;
+ type.get_bounds(0, minp, maxp);
+ float rot = track.get_rotation();
+ float c = cos(rot);
+ float s = sin(rot);
+ Point center((minp.x+maxp.x)/2, (minp.y+maxp.y)/2, 0);
+ return Point(pos.x+c*center.x-s*center.y, pos.y+s*center.x+c*center.y, pos.z+0.02);
+}
+
+void Track3D::apply_matrix() const
+{
const Point &pos = track.get_position();
float rot = track.get_rotation();
glTranslatef(pos.x, pos.y, pos.z);
glRotatef(rot*180/M_PI, 0, 0, 1);
glRotatef(track.get_slope()/track.get_type().get_total_length()*180/M_PI, 0, -1, 0);
const Point &pos = track.get_position();
float rot = track.get_rotation();
glTranslatef(pos.x, pos.y, pos.z);
glRotatef(rot*180/M_PI, 0, 0, 1);
glRotatef(track.get_slope()/track.get_type().get_total_length()*180/M_PI, 0, -1, 0);