X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Ftrack.cpp;h=b2ee4fad8fd34e942f25ceec0549169bad6cdb70;hb=6dc18b0e518407bd2a86602bae1e9bbae05da7c8;hp=85050c97f597a50d0b9b56d185d574bf8735ea62;hpb=38fb8d56efde037a71c46a58bda314655e68ab6c;p=r2c2.git diff --git a/source/3d/track.cpp b/source/3d/track.cpp index 85050c9..b2ee4fa 100644 --- a/source/3d/track.cpp +++ b/source/3d/track.cpp @@ -64,7 +64,7 @@ void Track3D::get_bounds(float angle, Point &minp, Point &maxp) const void Track3D::render() const { - prepare_render(); + prepare_render(true); glPushName(reinterpret_cast(this)); @@ -83,7 +83,7 @@ void Track3D::render() const void Track3D::render_endpoints() const { - prepare_render(); + prepare_render(false); 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; @@ -196,7 +221,7 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build float d = sqrt(dy*dy+dz*dz); va_builder.normal(s*dz/d, -c*dz/d, dy/d); - Point v(p.x+c*profile[j].x-s*profile[j].y, p.y+c*profile[j].y+s*profile[j].x, profile[j].z+i*track.get_slope()/nsegs); + Point v(p.x+c*profile[j].x-s*profile[j].y, p.y+c*profile[j].y+s*profile[j].x, profile[j].z); va_builder.vertex(v.x, v.y, v.z); if(profile[j].z==0) border.push_back(v); @@ -219,10 +244,10 @@ void Track3D::build_part(const TrackPart &part, GL::VertexArrayBuilder &va_build rail_seq.push_back(base_index+(i+1)*psize+1+j*2); rail_seq.push_back(base_index+i*psize+1+j*2); } - route_seq[part.route].push_back(base_index+i*psize+18); - route_seq[part.route].push_back(base_index+(i+1)*psize+18); - route_seq[part.route].push_back(base_index+(i+1)*psize+19); - route_seq[part.route].push_back(base_index+i*psize+19); + path_seq[part.path].push_back(base_index+i*psize+18); + path_seq[part.path].push_back(base_index+(i+1)*psize+18); + path_seq[part.path].push_back(base_index+(i+1)*psize+19); + path_seq[part.path].push_back(base_index+i*psize+19); } base_index += (nsegs+1)*psize;