void Helper::renderJoint(const Matrix44* m, float length){
	glPushMatrix();
		glMultMatrixf(*m);
		glColor3f(1.0f, 1.0f, 1.0);
		renderCircle(0, 0, length*0.5f);
		glPushMatrix();
			glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
			renderCircle(0, 0, length*0.5f);
		glPopMatrix();
		glPushMatrix();
			glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
			renderCircle(0, 0, length*0.5f);
		glPopMatrix();
		glBegin(GL_LINES);
			glColor3f(1.0f, 1.0f, 1.0);
			glVertex3f(0.0f, 0.0f, 0.0f);
			glColor3f(1.0f, 0.0f, 0.0);
			glVertex3f(length, 0.0f, 0.0f);
			glColor3f(1.0f, 1.0f, 1.0);
			glVertex3f(0.0f, 0.0f, 0.0f);
			glColor3f(0.0f, 1.0f, 0.0);
			glVertex3f(0.0f, length, 0.0f);
			glColor3f(1.0f, 1.0f, 1.0);
			glVertex3f(0.0f, 0.0f, 0.0f);
			glColor3f(0.0f, 0.0f, 1.0);
			glVertex3f(0.0f, 0.0f, length);
		glEnd();
	glPopMatrix();
}
void HudGaugeReticle::render(float frametime)
{
	setGaugeColor(HUD_C_BRIGHT);

	renderBitmap(crosshair.first_frame, position[0], position[1]);

	if (firepoint_display) {
		fp.clear();
		getFirepointStatus();
		
		if (!fp.empty()) {
			int ax, ay;
			bm_get_info(crosshair.first_frame, &ax, &ay);
			int centerX = position[0] + (ax / 2);
			int centerY = position[1] + (ay / 2);

			for (SCP_vector<firepoint>::iterator fpi = fp.begin(); fpi != fp.end(); ++fpi) {
				if (fpi->active == 2)
					setGaugeColor(HUD_C_BRIGHT);
				else if (fpi->active == 1)
					setGaugeColor(HUD_C_NORMAL);
				else
					setGaugeColor(HUD_C_DIM);
			
				renderCircle((int) (centerX + (fpi->xy.x * firepoint_scale_x)), (int) (centerY + (fpi->xy.y * firepoint_scale_y)), firepoint_size);
			}
		}
	}
}
Example #3
0
static void display()
{
	glClear(GL_COLOR_BUFFER_BIT);
    glLineWidth(2);
	glColor3f(1.0f, 1.0f, 1.0f);
    glBegin(GL_LINES);
	{
		glVertex2f(0, maxRadPadding);
		glVertex2f(0, -maxRadPadding);

		glVertex2f(maxRadPadding, 0);
		glVertex2f(-maxRadPadding, 0);
	}
    glEnd();
	
    glLineWidth(1);
	glColor3f(0, 0, 1.0f);
	for(int i = 0; i < partIndex - 1; i++)
		renderCircle(displaying.pos[i]);
	glColor3f(0, 1.0f, 0);
	renderCircle(displaying.pos[partIndex - 1]);

	glutSwapBuffers();
}
Example #4
0
void renderUniverse(struct renderstate *render, struct simulation *sim,
		    struct universe *univ)
{
	// SDL_Rect rect;
	int i;

	int rb, g;

	double maxCharge = 0;

	for (i = 0; i < univ->nextParticle; i++) {
		if (univ->particles[i].isActive
		    && fabs(univ->particles[i].charge) > maxCharge) {
			maxCharge = fabs(univ->particles[i].charge);
		}
	}

	SDL_SetRenderDrawColor(render->renderer, 0, 0, 0, 255);
	SDL_RenderClear(render->renderer);

	// FPS
	render->frames++;
	if ((SDL_GetTicks() - render->last_frame) > 1000) {
		render->fps = render->frames;
		render->frames = 0;
		render->last_frame += 1000;
	}
	// render->point_count = 0;
	for (i = 0; i < univ->nextParticle; i++) {

		if (!univ->particles[i].isActive) {
			continue;
		}

		double x =
		    (((univ->particles[i].xPos * univ->scale) +
		      render->xPos) * render->scale) + (render->width / 2);
		double y =
		    (((univ->particles[i].yPos * univ->scale) +
		      render->yPos) * render->scale) + (render->height / 2);

		double size =
		    (int)(univ->particles[i].size * render->scale *
			  univ->scale);

		if (size < 1) {
			size = 1;
		}

		if (univ->particles[i].charge == 0) {
			g = 255;
			rb = 0;
		} else if (fabs(univ->particles[i].charge) < maxCharge / 2.0) {
			g = 255;
			rb = (int)(255.0 *
				   (fabs(univ->particles[i].charge) /
				    (maxCharge / 2.0)));
		} else {
			rb = 255;
			g = (int)(255.0 *
				  ((maxCharge -
				    fabs(univ->particles[i].charge)) /
				   (maxCharge / 2.0)));
		}

		if (univ->particles[i].charge < 0) {
			SDL_SetRenderDrawColor(render->renderer, 0, g, rb, 255);
			renderCircle(render, x, y, size);
		} else {
			SDL_SetRenderDrawColor(render->renderer, rb, g, 0, 255);
			renderCircle(render, x, y, size);
		}

		// SDL_RenderFillRect(render->renderer, &rect);
	}

	// SDL_RenderDrawPoints(render->renderer, render->points,
	// render->point_count);

	renderHotParticle(render, sim, univ);
	renderHUD(render, sim, univ);

	SDL_RenderPresent(render->renderer);
}
Example #5
0
void TwoDSceneSVGRenderer::renderComparisonScene( const std::string& filename, const TwoDScene& otherscene, const std::vector<CollisionInfo> *impulses, const std::vector<CollisionInfo> *otherimpulses, const scalar &eps) const
{
    const VectorXs& x = m_scene.getX();
    const VectorXs& v = m_scene.getV();
    assert( x.size()%2 == 0 );
    assert( 2*m_scene.getNumParticles() == x.size() );
    int numparticles = x.size()/2;
    const std::vector<scalar>& radii = m_scene.getRadii();
    assert( numparticles == (int) radii.size() );

    std::fstream file(filename.c_str(), std::fstream::out);
    if(!file)
    {
        std::cerr << "Failure writing SVG file!" << std::endl;
        exit(1);
    }

    scalar scale, xmin, ymin, xshift, yshift;
    computeSimToImageMap(scale, xmin, ymin, xshift, yshift );

    file << "<?xml version=\"1.0\" encoding=\"utf-8\"?> <!-- Generator: Adobe Illustrator 13.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 14948)  --> <svg version=\"1.2\" baseProfile=\"tiny\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" width=\"";
    file << m_w;
    file << "px\" height=\"";
    file << m_h;
    file << "px\" viewBox=\"0 0 ";
    file << m_w << " " << m_h;
    file << "\" xml:space=\"preserve\">" << std::endl;

    // Simulate a background color by rendering a large colored quad
    file << "<polygon points=\"" << 0 << "," << 0 << " " << m_w << "," << 0 << " " << m_w << "," << m_h << " " << 0 << "," << m_h;
    file << "\" style=\"fill:#" << intToHexString(floor(255.0*m_bgcolor.r+0.5)) << intToHexString(floor(255.0*m_bgcolor.g+0.5)) << intToHexString(floor(255.0*m_bgcolor.b+0.5));
    file << "; stroke:#000000;stroke-width:0\"/>" << std::endl;

    const std::vector<std::pair<int,int> >& edges = m_scene.getEdges();
    const std::vector<scalar>& edgeradii = m_scene.getEdgeRadii();
    renderShared( file, x, edges, radii, edgeradii, scale, xmin, ymin, xshift, yshift );



    const VectorXs& otherx = otherscene.getX();
    const VectorXs& otherv = otherscene.getV();

    for( int i = 0; i < numparticles; ++i )
    {
        scalar x_resid = (otherx.segment<2>(2*i)-x.segment<2>(2*i)).norm();
        scalar v_resid = (otherv.segment<2>(2*i)-v.segment<2>(2*i)).norm();
        if( x_resid > eps || v_resid > eps )
        {
            Vector2s center;
            center << scale*(x(2*i)-xmin) + xshift, ((scalar)m_h) - scale*(x(2*i+1)-ymin) - yshift;
            renderCircle( file, center, 1.5*scale*radii[i], renderingutils::Color(1.0,0.0,0.0) );
        }
    }

    if(impulses)
    {
        int i=0, j=0;

        // loop over the real impulses
        while(i < (int)impulses->size())
        {
            int curvert = (*impulses)[i].m_idx1;
            CollisionInfo::collisiontype curtype = (*impulses)[i].m_type;
            int curidx2 = (*impulses)[i].m_idx2;

            // all student impulses less than this correct impulse are buggy
            while(j < (int)otherimpulses->size()
                    && (*otherimpulses)[j].m_idx1 < curvert
                    && (*otherimpulses)[j].m_type < curtype
                    && (*otherimpulses)[j].m_idx2 < curidx2)
            {
                renderImpulse( file, otherscene, (*otherimpulses)[j], true);
                j++;
            }

            // check for missed collision
            if( ! (j < (int)otherimpulses->size()
                    && (*otherimpulses)[j].m_idx1 == curvert
                    && (*otherimpulses)[j].m_type == curtype
                    && (*otherimpulses)[j].m_idx2 == curidx2))
            {
                renderImpulse( file, otherscene, (*impulses)[i], false);
            }
            else
            {
                // check for buggy normal
                if( ((*otherimpulses)[j].m_n - (*impulses)[i].m_n).norm() > eps)
                {
                    renderImpulse( file, otherscene, (*impulses)[i], false);
                    renderImpulse( file, otherscene, (*otherimpulses)[j], true);
                }
                j++;
            }

            i++;
        }
        // Any remaining student impulses are buggy
        while(j < (int)otherimpulses->size())
        {
            renderImpulse( file, otherscene, (*otherimpulses)[j], true);
            j++;
        }
    }


    file << "</svg>" << std::endl;

    file.close();

}
Example #6
0
void Game_renderShipMenu(const Game *g) {
    View_apply(&g->menu_view);
    const float top = View_getOrthoTop(&g->menu_view), height = 2.f*top;
    const float right = g->menu_view.ortho_right, width = 2.f*right;
    Game_renderBg(g, top);
    Sprite_bindAlpha(g->fade_transition.alpha);
    glPushMatrix(); {
        glTranslatef(.0f, top-height*70.f/1200.f, .0f);
        Sprite_render(&g->ship_menu.titles[g->ship_menu.player_index]);
    } glPopMatrix();

    const Vec2 ship_cell_pos[MAX_SHIPS] = {
        { -right+width*210.f/1600.f, top-height*340.f/1200.f },
        { -right+width*466.f/1600.f, top-height*340.f/1200.f },
        { -right+width*210.f/1600.f, top-height*570.f/1200.f },
        { -right+width*466.f/1600.f, top-height*570.f/1200.f }
    };
    const Vec2 pal_cell_pos[MAX_PALETTES] = {
        { width*-530.f/1600.f, top-height*1080.f/1200.f },
        { width*-320.f/1600.f, top-height*1080.f/1200.f },
        { width*-110.f/1600.f, top-height*1080.f/1200.f },
        { width* 110.f/1600.f, top-height*1080.f/1200.f },
        { width* 320.f/1600.f, top-height*1080.f/1200.f },
        { width* 530.f/1600.f, top-height*1080.f/1200.f }
    };
    Vec2 cursor_pos;
    if(g->update == Game_updatePaletteSelection)
        cursor_pos = pal_cell_pos[g->ship_menu.selected_pal_index[g->ship_menu.player_index]];
    else
        cursor_pos = ship_cell_pos[g->ship_menu.selected_ship_index[g->ship_menu.player_index]];

    if(g->ship_menu.player_index)
        glColor3f(0.f, 0.f, 1.f);
    else
        glColor3f(1.f, 0.f, 0.f);

    glPushMatrix();
    {
        glTranslatef(cursor_pos.x, cursor_pos.y, 0.f);
        glScalef(top*198.f/1200.f, top*198.f/1200.f, 1.f);
        renderCircle(32, false);
        size_t thickness;
        for(thickness=0 ; thickness<10 ; ++thickness) {
            glScalef(1.01f, 1.01f, 1.f);
            renderCircle(32, false);
        }
    }
    glPopMatrix();

    size_t i;
    for(i=0 ; i<MAX_SHIPS ; ++i) {
        glPushMatrix();
        glTranslatef(ship_cell_pos[i].x, ship_cell_pos[i].y, 0.f);
        Sprite_render(&g->ship_menu.ship_cell);
        Sprite_render(&g->ship_data[i].icon[0]);
        glPopMatrix();
    }
    for(i=0 ; i<MAX_PALETTES ; ++i) {
        glPushMatrix();
        glTranslatef(pal_cell_pos[i].x, pal_cell_pos[i].y, 0.f);
        Sprite_render(&g->ship_menu.ship_cell);
        Sprite_render(&g->ship_data[g->ship_menu.selected_ship_index[g->ship_menu.player_index]].icon[i]);
        glPopMatrix();
    }

#define RENDER_SHIP_ELEMENT(elt, px, py) \
    glPushMatrix(); \
    { \
        glTranslatef(px, py, 0.f); \
        Sprite_render(&g->ship_data[g->ship_menu.selected_ship_index[g->ship_menu.player_index]].elt[g->ship_menu.selected_pal_index[g->ship_menu.player_index]]); \
    } \
    glPopMatrix();
    RENDER_SHIP_ELEMENT(artwork, -right+width*1155/1600.f, top-height*550.f/1200.f)
    RENDER_SHIP_ELEMENT(banner, -right+width*355/1600.f, top-height*840.f/1200.f)
#undef RENDER_SHIP_ELEMENT

    Sprite_bindAlpha(1.f);
}
void Direct3DCircleBatcher::renderCircle(Circle &circle, Color &c)
{
	renderCircle(circle, c, *D3DManager->m_colorProgram);
}
void OpenGLESCircleBatcher::renderCircle(Circle &circle, Color &c)
{
    renderCircle(circle, c, *OGLESManager->m_colorProgram);
}