예제 #1
0
/////////////////////////////////////
// Purpose:	blt given texture
//			make sure you call 
//			TextureBegin first
// Output:	texture blted on screen
// Return:	TRUE if success
/////////////////////////////////////
u32 IgfxTexture::Blt(f32 x, f32 y, const iRect *srcRect, gfxBlt *pBlt)
{
	Vec3D vect(x,y,0);

	D3DXVECTOR3 center(0,0,0);

	PGFXTEXTURE texture = (PGFXTEXTURE)GetImg();

	if(!texture) return FALSE;

	if(pBlt)
	{
		Vec3D scale(1,1,1);
		Vec3D rotCenter(pBlt->rotOfsX,pBlt->rotOfsY,0);

		f32 sW, sH;
	
		if(srcRect)
		{ sW = (f32)(srcRect->right - srcRect->left); sH = (f32)(srcRect->bottom - srcRect->top); }
		else
		{ sW = (f32)m_width; sH = (f32)m_height; }

		if(TESTFLAGS(pBlt->flags, GFXBLT_FLIPH))
		{ scale.x = -1; center.x += sW; }

		if(TESTFLAGS(pBlt->flags, GFXBLT_FLIPV))
		{ scale.y = -1; center.y += sH; }

		if(pBlt->rot != 0 && !TESTFLAGS(pBlt->flags, GFXBLT_ROTABS))
		{ rotCenter.x -= sW/2; rotCenter.y -= sH/2; }

		Matrix scaleRotOfsM(scale.x, 0,       0,       rotCenter.x,
			                0,       scale.y, 0,       rotCenter.y,
							0,       0,       scale.z, rotCenter.z,
							0,       0,       0,       1);

		Matrix rotRotOfsInvTransM; MtxRotateZ(pBlt->rot, &rotRotOfsInvTransM);
		
		rotRotOfsInvTransM._41 = -rotCenter.x;
		rotRotOfsInvTransM._42 = -rotCenter.y;
		rotRotOfsInvTransM._43 = -rotCenter.z;

		Matrix transM; MtxTranslate(&vect, &transM);

		s_pTxtSprite->SetTransform((D3DXMATRIX*)&Matrix(scaleRotOfsM*rotRotOfsInvTransM*transM));
		s_pTxtSprite->Draw(texture, (const RECT*)srcRect, &center, 0, pBlt->clr);

		//g_pTxtSprite->Draw(texture, (const RECT*)srcRect, &scale, &rotCenter, pBlt->rot, &vect, pBlt->clr);
	}
	else
	{
		Matrix mtxIden; MtxIdentity(&mtxIden);
		s_pTxtSprite->SetTransform((D3DXMATRIX*)&mtxIden);
		s_pTxtSprite->Draw(texture, (const RECT*)srcRect, &center, (D3DXVECTOR3*)&vect, 0xffffffff);
	}

	s_pTxtSprite->Flush();

	return TRUE;
}
예제 #2
0
matrix_t * fime_ship_update(const float seconds)
{
  static float ax;
  static float ay;
  matrix_t tmp;
  float x,y,z;
  vtx_t oldpos = *(vtx_t *)mtx[3];
    

  MtxIdentity(tmp);

  x = fsin(ax += 0.015f) * 1.5;
  y = (fsin(ay += 0.008f) + 1) * -0.5;
  z = 0; //mtx[3][2] + 0.00;

  angle.z = (x - oldpos.x) * 40;
  angle.x = (y - oldpos.y) * -20;
/*   angle.z = angle.z < 0 ? -3.1 : 3.1; */

  MtxIdentity(mtx);
  MtxRotateZ(mtx, angle.z);
  MtxRotateX(mtx, angle.x);
  MtxRotateY(mtx, angle.y);

  mtx[3][0] = x;
  mtx[3][1] = y;
  mtx[3][2] = z;
  
  return &mtx;
}