X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Ftrack.cpp;h=b2ee4fad8fd34e942f25ceec0549169bad6cdb70;hb=6dc18b0e518407bd2a86602bae1e9bbae05da7c8;hp=5857e52d8813b8c29053e7dd107d882d7bf0f35c;hpb=319f90fd59587efc1242c34f307abc29f323642b;p=r2c2.git diff --git a/source/3d/track.cpp b/source/3d/track.cpp index 5857e52..b2ee4fa 100644 --- a/source/3d/track.cpp +++ b/source/3d/track.cpp @@ -25,41 +25,46 @@ Track3D::Track3D(Track &t, unsigned q): build_object(); } +void Track3D::set_color(const Msp::GL::Color &c) +{ + color = c; +} + void Track3D::set_quality(unsigned q) { - quality=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(); + const Point &pos = track.get_position(); + float rot = track.get_rotation(); - float c=cos(-angle); - float s=sin(-angle); + 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; + 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); + float c2 = cos(rot-angle); + float s2 = sin(rot-angle); for(vector::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; + 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); + 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(); + prepare_render(true); glPushName(reinterpret_cast(this)); @@ -78,56 +83,81 @@ void Track3D::render() const void Track3D::render_endpoints() const { - prepare_render(); + prepare_render(false); - const vector &endpoints=track.get_type().get_endpoints(); + const vector &endpoints = track.get_type().get_endpoints(); for(unsigned i=0; i1e-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_route(int route) const +void Track3D::render_path(int path) const { - prepare_render(); + prepare_render(true); varray.apply(); - if(route>=0 && static_cast(route)=0 && static_cast(path) &parts=track.get_type().get_parts(); - unsigned index=0; + const vector &parts = track.get_type().get_parts(); + unsigned index = 0; for(vector::const_iterator i=parts.begin(); i!=parts.end(); ++i) build_part(*i, builder, index); } @@ -169,29 +199,29 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build profile.push_back(Point(0, -0.002, 0.012)); profile.push_back(Point(0, 0.002, 0.012)); } - static unsigned psize=profile.size(); + static unsigned psize = profile.size(); - unsigned nsegs=(part.radius ? static_cast(part.length*(1<(part.length*(1<