示例#1
0
void LaneLineTile::writeLine(std::ostream &out, double from, double to, double offset, double width, std::string color) const
{
	if (from >= to)
		return;

	Vector2 orthogonal = getStartDirection().getPerpendicularVectorRight();
	Vector2 p = getStartPoint() + getStartDirection() * from + orthogonal * offset;
	Vector2 q = getStartPoint() + getStartDirection() * to + orthogonal * offset;

	out << "<line x1=\"" << p[0] << "\" y1=\"" << p[1] << "\" x2=\"" << q[0] << "\" y2=\"" << q[1] << "\" style=\"stroke:" << color << "; stroke-width:" << width << ";\" />\n";
}
void GlassLayer::updateSegments(void)
{
    //Calculate a Cubic Hermite spline
    _Segments.clear();

    Vec2f Pos;
    Real32 t,
           t_sqr,
           t_cub;
    for(UInt32 i(1) ; i<getSegments() ; ++i)
    {
        t = static_cast<Real32>(i)/static_cast<Real32>(getSegments());
        t_sqr = t*t;
        t_cub = t_sqr*t;

        Pos = ( 2.0f * t_cub - 3.0f*t_sqr + 1.0f) * getStartPosition().subZero() +
              (        t_cub - 2.0f*t_sqr +    t) * getStartDirection() +
              (-2.0f * t_cub + 3.0f*t_sqr       ) * getEndPosition().subZero() +
              (        t_cub -      t_sqr       ) * getEndDirection();

        _Segments.push_back(Pos);
    }
}