- 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(true);
-
- 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
-{
- prepare_render(false);
-
- const vector<Endpoint> &endpoints = track.get_type().get_endpoints();
- for(unsigned i=0; i<endpoints.size(); ++i)
- {
- const Endpoint &ep = endpoints[i];
- GL::set(GL_CULL_FACE, track.get_link(i));
- if(track.get_link(i))
- glColor4f(0.5, 0, 1, 0.5);
- else
- glColor4f(1, 0, 0.5, 0.5);
-
- float c = cos(ep.dir);
- float s = sin(ep.dir);
- float z = (i==1 ? track.get_slope() : 0);
-
- glBegin(GL_QUADS);
- glVertex3f(ep.pos.x-s*0.025, ep.pos.y+c*0.025, z);
- glVertex3f(ep.pos.x+s*0.025, ep.pos.y-c*0.025, z);
- glVertex3f(ep.pos.x+s*0.025, ep.pos.y-c*0.025, z+0.02);
- glVertex3f(ep.pos.x-s*0.025, ep.pos.y+c*0.025, z+0.02);
- glEnd();
- }
-
- if(abs(track.get_slope())>1e-4)
- {
- Point p;
- if(track.get_slope()>0)
- {
- p = endpoints[1].pos;
- p.z += track.get_slope();
- }
- else
- p = endpoints[0].pos;
- glBegin(GL_TRIANGLE_STRIP);
- for(unsigned i=0; i<=16; ++i)
- {
- float c = cos(i*M_PI/8);
- float s = sin(i*M_PI/8);
- glNormal3f(c, s, 0);
- glVertex3f(p.x+c*0.01, p.y+s*0.01, p.z);
- glVertex3f(p.x+c*0.01, p.y+s*0.01, -track.get_position().z);
- }
- glEnd();
- }
-
- glPopMatrix();
-}
-
-void Track3D::render_path(int path) const
-{
- prepare_render(true);
-
- varray.apply();
- if(path>=0 && static_cast<unsigned>(path)<path_seq.size())
- glDrawElements(GL_QUADS, path_seq[path].size(), GL_UNSIGNED_INT, &path_seq[path][0]);