- color(1, 1, 1),
- varray((GL::NORMAL3, GL::VERTEX3)),
- quality(q)
-{
- build_object();
-}
-
-void Track3D::set_color(const Msp::GL::Color &c)
-{
- color = c;
-}
-
-void Track3D::set_quality(unsigned q)
-{
- quality = q;
- build_object();
-}
-
-void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const
-{
- const Point &pos = track.get_position();
- float rot = track.get_rotation();
-
- float c = cos(-angle);
- float s = sin(-angle);
-
- minp.x = maxp.x = c*pos.x-s*pos.y;
- minp.y = maxp.y = s*pos.x+c*pos.y;
-
- float c2 = cos(rot-angle);
- float s2 = sin(rot-angle);
-
- for(vector<Point>::const_iterator i=border.begin(); i!=border.end(); ++i)
- {
- float x = c*pos.x-s*pos.y + c2*i->x-s2*i->y;
- float y = s*pos.x+c*pos.y + s2*i->x+c2*i->y;
-
- minp.x = min(minp.x, x);
- minp.y = min(minp.y, y);
- maxp.x = max(maxp.x, x);
- maxp.y = max(maxp.y, y);
- }
-}
-
-void Track3D::render() const
-{
- prepare_render();
-
- glPushName(reinterpret_cast<unsigned>(this));
-
- varray.apply();
- glColor4f(0.25*color.r, 0.25*color.g, 0.25*color.b, 1);
- glDrawElements(GL_QUADS, base_seq.size(), GL_UNSIGNED_INT, &base_seq[0]);
- if(quality>1)
- {
- glColor4f(0.85*color.r, 0.85*color.g, 0.85*color.b, 1);
- glDrawElements(GL_QUADS, rail_seq.size(), GL_UNSIGNED_INT, &rail_seq[0]);
- }
-
- glPopName();
- glPopMatrix();
-}
-
-void Track3D::render_endpoints() const