Exemplo n.º 1
0
void DrawSpritesRot2D(float x, float y, float layer, float dx, float dy, u32 rgba, float angle)
{
    dx /= 2.0f; dy /= 2.0f;

    MATRIX matrix;
    
    // rotate and translate the sprite
    matrix = MatrixRotationZ(angle);
    matrix = MatrixMultiply(matrix, MatrixTranslation(x + dx, y + dy, 0.0f));
    
    // fix ModelView Matrix
    tiny3d_SetMatrixModelView(&matrix);
   
    tiny3d_SetPolygon(TINY3D_QUADS);

    tiny3d_VertexPos(-dx, -dy, layer);
    tiny3d_VertexColor(rgba);
    tiny3d_VertexTexture(0.0f , 0.0f);

    tiny3d_VertexPos(dx , -dy, layer);
    tiny3d_VertexTexture(0.99f, 0.0f);

    tiny3d_VertexPos(dx , dy , layer);
    tiny3d_VertexTexture(0.99f, 0.99f);

    tiny3d_VertexPos(-dx, dy , layer);
    tiny3d_VertexTexture(0.0f , 0.99f);

    tiny3d_End();

    tiny3d_SetMatrixModelView(NULL); // set matrix identity

}
Exemplo n.º 2
0
void draw_twat(float x, float y, float angle)
{
    int n;

    float ang, angs = 6.2831853071796 / 8, angs2 = 6.2831853071796 / 32;

    MATRIX matrix;

    // rotate and translate the sprite
    matrix = MatrixRotationZ(angle);
    matrix = MatrixMultiply(matrix, MatrixTranslation(x , y , 65535.0f));

    // fix ModelView Matrix
    tiny3d_SetMatrixModelView(&matrix);

    tiny3d_SetPolygon(TINY3D_TRIANGLES);

    ang = 0.0f;

    for(n = 0; n <8; n++) {

        tiny3d_VertexPos(4.0f *sinf(ang), 4.0f *cosf(ang), 0);
        tiny3d_VertexColor(0xffffff30);
        tiny3d_VertexPos(7.0f *sinf(ang+angs/2), 7.0f *cosf(ang+angs/2), 0);
        tiny3d_VertexColor(0xff00ff40);
        tiny3d_VertexPos(4.0f *sinf(ang+angs), 4.0f *cosf(ang+angs), 0);
        tiny3d_VertexColor(0xffffff30);

        ang += angs;
    }

    tiny3d_End();

    tiny3d_SetPolygon(TINY3D_POLYGON);

    ang = 0.0f;

    for(n = 0; n <32; n++) {
        tiny3d_VertexPos(3.0f * sinf(ang), 3.0f * cosf(ang), 0);
        if(n & 1) tiny3d_VertexColor(0x80ffff40);
        else tiny3d_VertexColor(0xffffff40);
        ang += angs2;
    }

    tiny3d_End();

    tiny3d_SetMatrixModelView(NULL); // set matrix identity

}
Exemplo n.º 3
0
void tiny3d_ClearSurface(u32 color, clear_flags flags, u32 rsx_offset, u32 width, u32 height, u32 stride, u32 format)
{

    flag_vertex |= VERTEX_LOCK;

    render_target.target = 1;
    render_target.w = width;
    render_target.p = stride;
    render_target.h = height;


    if(flags & TINY3D_CLEAR_COLOR) {

        tiny3d_Project2D();

        tiny3d_SetProjectionMatrix(&matrix_ident);
        tiny3d_SetMatrixModelView(&matrix_ident);
        
        internal_reality_ZControl(context, 0, 1, 1); // disable viewport culling
 
        internal_reality_DepthTestFunc(context, REALITY_ZFUNC_LESSOREQUAL);
        internal_reality_DepthWriteEnable(context, 1);
        internal_reality_DepthTestEnable(context, 1);

        internal_reality_AlphaEnable(context, 0);

        internal_reality_BlendEnable(context, 0);

        internal_reality_Viewport(context, width, height);
        
        int n;

        for(n = 0; n < 8; n++)
            internal_reality_ViewportClip(context, n, width, height);

        setupRenderTarget2(rsx_offset, stride, width, height, format);

        rsxSetClearColor(context, color);

    }

    if(flags & TINY3D_CLEAR_ZBUFFER) {

        rsxSetClearDepthValue(context, 0xffffffff);
    }

    internal_reality_ClearBuffers(context, flags);
}
Exemplo n.º 4
0
void BoxBrowser::SetZoomMatrix()
{
	MATRIX mtxScale = MatrixScale( zScale, zScale, zScale );
	MATRIX matrixX = MatrixRotationX( FROM_ANGLE( zRotX ) );
	MATRIX matrixZ = MatrixRotationZ( FROM_ANGLE( zRotZ ) );

	// rotate and translate
	MATRIX mx = MatrixRotationY( FROM_ANGLE( zRotY ) );					//rotate
	mx = MatrixMultiply( mx, matrixX );
	mx = MatrixMultiply( mx, matrixZ );
	mx = MatrixMultiply( mx, mtxScale );								//scale this thing up

	mx = MatrixMultiply( mx, MatrixTranslation( zPosX, zPosY, zPosZ ) ); //translate into place

	//apply matrix
	tiny3d_SetMatrixModelView( &mx );
}
Exemplo n.º 5
0
void BoxBrowser::Draw()
{
	if( !visible )
		return;
	if( needToUpdateBoxes )
	{
		needToUpdateBoxes = false;
		viewMode = viewFlow;
		Shift( 0 );
	}
	if( viewMode == viewFlow )
	{
		//draw text and any other 2D elements ( and leave it in 2D for the rest of the gui )
		gameText->Draw();
		//change to 3D context to draw boxes
		tiny3d_Project3D();

		//draw the surface
		DrawSurface();

		//update camera motion
		UpdateCamera();

		for( int i = 0; i < NUM_BOXES; i++ )
		{
			int mtxIdx = ( ( i * ANIMATION_FRAMES ) + animFrame );
			if( mtxIdx >= (int)mtxBox.size() || mtxIdx < 0 )
			{
				continue;
			}
			tiny3d_SetMatrixModelView( &mtxBox[ mtxIdx ] );
			box[ i ]->DrawNoMtx();
		}
		UpdateAnimation();
	}
	else if( viewMode == viewZoom )
	{
		//draw text and any other 2D elements ( and leave it in 2D for the rest of the gui )
		if( bgImg2 )
		{
			bgImg2->Draw();
		}
		if( bgImg1 )
		{
			//make sure this image is positioned correctly
			if( !bgLoaded && bgImg1->IsLoaded() )
			{
				bgLoaded = true;
				//this image should either be 1000px wide or 1920
				if( bgImg1->GetWidth() <= 1000 )
					bgImg1->SetPosition( 124, 69, 0xfff0 );//these values seem to work for all my guitar hero & rockband games
				else
					bgImg1->SetPosition( 0, 0, 0xfff0 );//i dont have any games that fit this category, but i assume this is right
			}
			bgImg1->Draw();
		}

		//change to 3D
		tiny3d_Project3D();

		//update camera motion
		UpdateCamera();

		//set matrix for zoomed box
		SetZoomMatrix();

		//the center box hopefully is the selected one
		box[ NUM_BOXES / 2 ]->DrawNoMtx();
	}


	//done in 3D mode, switch to 2D
	tiny3d_SetMatrixModelView( NULL ); // set matrix identity
	tiny3d_Project2D();

	busy = false;
	inputIdx = 0;
}
Exemplo n.º 6
0
void tiny3d_Clear(u32 color, clear_flags flags)
{

    flag_vertex |= VERTEX_LOCK;

    render_target.target = 0;

    if(flags & TINY3D_CLEAR_COLOR) {
       
        tiny3d_Project2D();

        tiny3d_SetProjectionMatrix(&matrix_ident);
        tiny3d_SetMatrixModelView(&matrix_ident);
        
        internal_reality_ZControl(context, 0, 1, 1); // disable viewport culling
 
        internal_reality_DepthTestFunc(context, REALITY_ZFUNC_LESSOREQUAL);
        internal_reality_DepthWriteEnable(context, 1);
        internal_reality_DepthTestEnable(context, 1);

        internal_reality_AlphaEnable(context, 0);

        internal_reality_BlendEnable(context, 0);

        internal_reality_Viewport(context, Video_Resolution.width, Video_Resolution.height);
        
        
      
        int n;
       
        for(n = 0; n < 8; n++)
            {
            
            internal_reality_ViewportClip(context, n, Video_Resolution.width, Video_Resolution.height);
            }

        setupRenderTarget(Video_currentBuffer);

        rsxSetClearColor(context, color);

    }

    if(flags & TINY3D_CLEAR_ZBUFFER) {

        rsxSetClearDepthValue(context, 0xffffffff);
    }

    internal_reality_ClearBuffers(context, flags);

    if((flags & TINY3D_CLEAR_COLOR) && tiny_3d_alarm) {
        
        tiny3d_SetPolygon(TINY3D_QUADS);

        tiny3d_VertexPos(848/2  , 0  ,  65535);
        tiny3d_VertexColor(0xff0000ff);

        tiny3d_VertexPos(847, 0  , 65535);

        tiny3d_VertexPos(847, 511, 65535);

        tiny3d_VertexPos(848/2 , 511, 65535);
        tiny3d_End();

        internal_reality_Viewport(context, Video_Resolution.width*15/16, Video_Resolution.height);
        int n;
        for(n = 0; n < 8; n++)
            internal_reality_ViewportClip(context, n, Video_Resolution.width*15/16, Video_Resolution.height);
        internal_reality_ClearBuffers(context, flags);
    }
}