void MatrixRefresher::visit(Group &g )
{
    if(g.dirty) {
        dirtyCount++;
    }
    refreshMatrix(g);
    stack.push(g.getMatrix());
}
void MatrixRefresher::visit(Model &m )
{
    if(m.dirty) {
        dirtyCount++;
    }
    refreshMatrix(m);
    stack.push(m.getMatrix());

}
Exemple #3
0
void SpacePage::draw()
{
    refreshMatrix();
	Gosu::Graphics& g = PageManager::Instance()->graphics();
	double wdt = g.width();
	double hgt = g.height();
    m_Closest.draw(m_matGlobalToLocal, wdt, hgt);
    m_Closest.reset();
	double xn = wdt*.25;
	double xp = wdt*.75;
	double yn = hgt*.25;
	double yp = hgt*.75;
	g.drawLine(xn, yn, Gosu::Colors::white, xp, yn, Gosu::Colors::white, 20);
	g.drawLine(xp, yn, Gosu::Colors::white, xp, yp, Gosu::Colors::white, 20);
	g.drawLine(xp, yp, Gosu::Colors::white, xn, yp, Gosu::Colors::white, 20);
	g.drawLine(xn, yp, Gosu::Colors::white, xn, yn, Gosu::Colors::white, 20);
	g.drawLine(wdt/2-20, hgt/2, Gosu::Colors::green, wdt/2+20, hgt/2, Gosu::Colors::green, 20);
	g.drawLine(wdt/2, hgt/2-20, Gosu::Colors::green, wdt/2, hgt/2+20, Gosu::Colors::green, 20);
    std::wstringstream ss;
    ss << Gosu::fps();
    m_Font.drawRel(ss.str(), wdt-20, 20, 20, 1.0, 0.0);

    for (const Bullet& b:m_Bullets) {
        double len = b.dir.magnitude()*b.lifetime;
        Vector dir = b.dir.normalized();
        double step = 5.0;
        for (double d = std::max(0.0, len - b.dir.magnitude()*50.0); d < len; d += step) {
            Vector pos1 = m_matGlobalToLocal * (b.pos+Vector(0, 0, 0.1)+(dir*d));
            Vector pos2 = m_matGlobalToLocal * (b.pos+Vector(0, 0, 0.1)+(dir*(d+step)));
            SphericalCoordinate sc = pos1.toSphericalCoordinate();
            SphericalCoordinate sc_prev = pos2.toSphericalCoordinate();
            // prevent odd lines going through you from your own fire
            if (sc.distance < 10.0) continue;
            if (sc_prev.distance <= 10.0) continue;
            double x1 = Renderable::screenX(sc, wdt);
            double x2 = Renderable::screenX(sc_prev, wdt);
            // prevent stuff from spanning the screen
            if (std::abs(x1-x2) > 10) continue;
            double y1 = Renderable::screenY(sc, hgt);
            double y2 = Renderable::screenY(sc_prev, hgt);
            g.drawLine(x1, y1, Gosu::Colors::red, x2, y2, Gosu::Colors::green, 0);
        }
    }
}