Example #1
0
void Mesh::normalize() {
    float dia = this->diameter();
    float scaling = 1.0 / dia;

    smlt::Mat4 scale_matrix;
    kmMat4Scaling(&scale_matrix, scaling, scaling, scaling);

    transform_vertices(scale_matrix);
}
Example #2
0
void ExtObject::Draw()
{
	// Enable the Z stencil
	cr::renderstate_value old_zbuffer_state = renderer->GetRenderState(cr::rs_zbuffer_enabled);
	renderer->SetRenderState(cr::rs_zbuffer_enabled, (zbuffer ? cr::rsv_enabled : cr::rsv_disabled));

	cr::point3d objpos(info.x, info.y, z + (depth / 2.0));

	vector<cr::point3d> verts;
	for( int i = 0; i < 8; i++)
	{
		verts.push_back( makepoint3d(cube_vertices_xyz[i]) );
	}
	transform_vertices(verts, false);





	// Draw each face separately
	for (int i = 0; i < 6; i++) {

		renderer->SetTexture(textures[i]);

		float u = textures[i]->xf;
		float v = textures[i]->yf;

		//pRuntime->EndBatch();
		renderer->BeginBatchQuads(24, 36);

		renderer->AddIndex(0);
		renderer->AddIndex(1);
		renderer->AddIndex(2);
		renderer->AddIndex(2);
		renderer->AddIndex(3);
		renderer->AddIndex(0);


		for(int b = i*4; b < i*4 + 4; b++){

			renderer->AddVertex(verts[cube_indexes[b]], 
				cr::point(cube_vertices[b]._uv.u * u, cube_vertices[b]._uv.v * v),
				cr::opaque_white);
		}
	}

	renderer->SetRenderState(cr::rs_zbuffer_enabled, old_zbuffer_state);
}
Example #3
0
void cmd_timerefresh(){
    // Checks how fast the engine is rendering the current scene.
    int i,timer_now,timer_count;
    float frames,secs;

    // Only do the TIMEREFRESH if we're actaully looking at a level.
    if(player_connected==1){

        // Initiate.
        timer_now=clock();
        frames=0;

        // Turn the player around full circle (128 frames in total, like Quake).
        for(i=0;i<full_circle/10;i++){
            player_angle+=10;
            if(player_angle>=full_circle){player_angle-=full_circle;}
            transform_vertices();
            window_size_init();
            clear_to_color(vgabuf,0);
            //test_render();
            render();
            if(player_vsync==1){vsync();}
            blit(vgabuf,screen,0,0,0,0,screen_width,screen_height);
            frames++;
        }

        // Work out how long it took.
        timer_count=clock();
        secs=(float)(timer_count-timer_now)/(float)CLOCKS_PER_SEC;
        sprintf(saybuf,"%f seconds (%f fps)",secs,frames/secs);
        con_printf(saybuf);
    }
    else{
        con_printf("can't timerefresh when disconnected");
    }
}