void ya2d_drawRotateTexture(ya2d_Texture *texp, int x, int y, float angle) { if(!texp->data) return; sceGuEnable(GU_TEXTURE_2D); sceGuTexMode(texp->texPSM, 0, 0, texp->isSwizzled); sceGuTexFunc(GU_TFX_REPLACE, texp->hasAlpha ? GU_TCC_RGBA : GU_TCC_RGB); ya2d_setTexture(texp); sceGumPushMatrix(); sceGumLoadIdentity(); { ScePspFVector3 pos = {x + (float)texp->centerX, y + (float)texp->centerY, 0.0f}; sceGumTranslate(&pos); sceGumRotateZ(angle); } ya2d_FloatTextureVertex *vertices = (ya2d_FloatTextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_FloatTextureVertex)); vertices[0] = (ya2d_FloatTextureVertex){0.0f, 0.0f, (float)-texp->centerX, (float)-texp->centerY, 0.0f}; vertices[1] = (ya2d_FloatTextureVertex){0.0f, 1.0f, (float)-texp->centerX, (float)texp->centerY, 0.0f}; vertices[2] = (ya2d_FloatTextureVertex){1.0f, 0.0f, (float)texp->centerX, (float)-texp->centerY, 0.0f}; vertices[3] = (ya2d_FloatTextureVertex){1.0f, 1.0f, (float)texp->centerX, (float)texp->centerY, 0.0f}; sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices); sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_FloatTextureVertex)); sceGumPopMatrix(); }
void Sprite::Draw() { sceGumPushMatrix(); ScePspFVector3 loc = {posX,posY,0.0f}; sceGumTranslate(&loc); sceGuEnable(GU_TEXTURE_2D); TextureManager::Instance()->SetTexture(imageName,GU_NEAREST,GU_NEAREST); sceGumDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices); sceGuDisable(GU_TEXTURE_2D); sceGumPopMatrix(); }
/** * Created: 01/03/2011 * Renders a cube to the demo space according to it's game location */ void FrontEnd::RenderCube(float x, float y, float z) { #ifdef PC /* Set the colour */ _pd3dDevice->SetRenderState( D3DRS_AMBIENT, IntToD3DColor( _fgColour ) ); D3DXMATRIXA16 rotation; D3DXMATRIXA16 world; D3DXMATRIXA16 temp; D3DXMatrixIdentity( &rotation ); D3DXMatrixIdentity( &world ); /* Create the rotation matrix */ D3DXMatrixIdentity( &temp ); D3DXMatrixRotationX( &temp, _rotation.y ); rotation *= temp; D3DXMatrixRotationY( &temp, _rotation.z ); rotation *= temp; D3DXMatrixRotationZ( &temp, _rotation.x ); rotation *= temp; /* Translate the cube */ D3DXMatrixIdentity( &temp ); D3DXMatrixTranslation( &temp, -x, -y, z ); world *= temp; /* Rotate the cube */ D3DXMatrixIdentity( &temp ); D3DXMatrixTranslation( &temp, _view.x, _view.y, -_view.z ); world *= temp; world *= rotation; D3DXMatrixIdentity( &temp ); D3DXMatrixTranslation( &temp, -_view.x, -_view.y, _view.z ); world *= temp; /* Set the world matrix */ _pd3dDevice->SetTransform( D3DTS_WORLD, &world ); /* Render the cube */ _pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 36 ); #else ScePspFVector3 vec; /* Create the rotation matrix */ ScePspFMatrix4 rotation; ScePspFVector3 rotator; rotator.x = _rotation.x; rotator.y = _rotation.y; rotator.z = _rotation.z; sceGumPushMatrix(); sceGumRotateXYZ( &rotator ); sceGumStoreMatrix( &rotation); sceGumPopMatrix(); /* Push a new matrix */ sceGumPushMatrix(); //printf("FrontEnd::RenderCube() started\n"); /* Rotate the cube's translation */ ScePspFVector3 view; view.x = -_view.x; view.y = -_view.y; view.z = -_view.z; sceGumTranslate( &view ); sceGumRotateXYZ( &rotator ); view.x = -view.x; view.y = -view.y; view.z = -view.z; sceGumTranslate( &view ); vec.x = (float)-x; vec.y = (float)-y; vec.z = (float)-z; sceGumTranslate( &vec ); /* Set the colour */ sceGuColor( _fgColour ); /* Render the cube */ sceGumDrawArray(SCEGU_PRIM_TRIANGLES, SCEGU_VERTEX_FLOAT, 36, 0, Cube); /* Pop the matrix */ sceGumPopMatrix(); #endif }
void Drop::Render(Vector3 playerPos, float camAngle) { if(abs(position.x-playerPos.x) < 8.0f && abs(position.y-playerPos.y) < 5.0f && abs(position.z-playerPos.z) < 8.0f) { active = true; } else { active = false; } if(toDestroy == false && getMe == false && active == true) { if(abs(position.x-playerPos.x) < 0.8f && abs(position.y-playerPos.y) < 1.8f && abs(position.z-playerPos.z) < 0.8f && existingTime >= 0.5f && myCrft->InventoryIsFull(id,amount,stackable) == false && myCrft->HP > 0.0f) { getMe = true; return; } float angle = atan2f(position.x-(playerPos.x+(cosf(camAngle+PI)*4)),position.z-(playerPos.z+(sinf(camAngle+PI)*4)))-PI*0.5f; sceGuColor(GU_COLOR(myCrft->BlockFinalLight(position.x,position.y,position.z),myCrft->BlockFinalLight(position.x,position.y,position.z),myCrft->BlockFinalLight(position.x,position.y,position.z),1.0f)); sceGuEnable(GU_DEPTH_TEST); sceGuEnable(GU_ALPHA_TEST); sceGuEnable(GU_BLEND); if(id < 250) { sceGumPushMatrix(); ScePspFVector3 loc = {position.x,position.y+sinf(levit)*0.09f,position.z}; sceGumTranslate(&loc); ScePspFVector3 sca = {0.25f,0.25f,0.25f}; sceGumScale(&sca); sceGumRotateX(0.0f); sceGumRotateY(angleBlock); sceGumRotateZ(0.0f); myCrft->drawCubes(id,myCrft->BlockFinalLight(position.x,position.y,position.z)); sceGumPopMatrix(); if(amount >= 3 && stackable == true) { sceGumPushMatrix(); ScePspFVector3 loc = {position.x+0.09f,position.y+sinf(levit)*0.09f+0.09f,position.z}; sceGumTranslate(&loc); ScePspFVector3 sca = {0.25f,0.25f,0.25f}; sceGumScale(&sca); sceGumRotateX(0.0f); sceGumRotateY(angleBlock); sceGumRotateZ(0.0f); myCrft->drawCubes(id,myCrft->BlockFinalLight(position.x,position.y,position.z)); sceGumPopMatrix(); } } else { sceGumPushMatrix(); ScePspFVector3 loc = {position.x,position.y+sinf(levit)*0.09f,position.z}; sceGumTranslate(&loc); sceGumRotateX(0.0f); sceGumRotateY(angle); sceGumRotateZ(0.0f); myCrft->drawDropItems(id); sceGumPopMatrix(); } sceGuDisable(GU_BLEND); sceGuDisable(GU_ALPHA_TEST); sceGuDisable(GU_DEPTH_TEST); } }