Ejemplo n.º 1
0
/*
==================
Blits a bounding line
==================
*/
inline void IND_Render::BlitCollisionLine (int pPosX1, int pPosY1, int pPosX2, int pPosY2,  byte pR, byte pG, byte pB, byte pA, IND_Matrix pIndWorldMatrix)
{
	SetTransform2d (0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0);

	D3DXMATRIX mWorldMatrix;
	GetD3DMatrix (pIndWorldMatrix, &mWorldMatrix);

	// Untransformed points
	D3DXVECTOR2 mP1Untransformed ((float) pPosX1, (float) pPosY1);			
	D3DXVECTOR2 mP2Untransformed ((float) pPosX2, (float) pPosY2);	

	D3DXVECTOR4 mP1, mP2;
	D3DXVec2Transform (&mP1, &mP1Untransformed, &mWorldMatrix);
	D3DXVec2Transform (&mP2, &mP2Untransformed, &mWorldMatrix);
	
	// Color
	SetRainbow2d (IND_OPAQUE, 1, 0, 0, IND_FILTER_POINT, pR, pG, pB, pA, 0, 0, 0, 255, 0, 0);

	// Color
	mInfo.mDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);

	// Pixel format
	mInfo.mDevice->SetFVF (D3DFVF_PIXEL);

	// Filling pixels
	FillPixel (&mPixels [0], (int) mP1.x, (int) mP1.y, pR, pG, pB);
	FillPixel (&mPixels [1], (int) mP2.x, (int) mP2.y, pR, pG, pB);

	// Blitting line
	mInfo.mDevice->DrawPrimitiveUP (D3DPT_LINESTRIP, 1, &mPixels, sizeof (PIXEL));
}
/*
==================
Blits a bounding line
==================
*/
void DirectXRender::BlitGridLine(int pPosX1, int pPosY1, int pPosX2, int pPosY2,  BYTE pR, BYTE pG, BYTE pB, BYTE pA, D3DXMATRIX pWorldMatrix) {
	setTransform2d(0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0);

	// Untransformed Points
	D3DXVECTOR2 mP1Untransformed((float) pPosX1, (float) pPosY1);
	D3DXVECTOR2 mP2Untransformed((float) pPosX2, (float) pPosY2);

	D3DXVECTOR4 mP1, mP2;
	D3DXVec2Transform(&mP1, &mP1Untransformed, &pWorldMatrix);
	D3DXVec2Transform(&mP2, &mP2Untransformed, &pWorldMatrix);

	// Color
	setRainbow2d(IND_OPAQUE, 1, 0, 0, IND_FILTER_POINT, pR, pG, pB, pA, 0, 0, 0, 255, 0, 0);

	// Color
	_info._device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);

	// Pixel format
	_info._device->SetFVF(D3DFVF_PIXEL);

	// Filling pixels
	fillPixel(&_pixels [0], (int) mP1.x, (int) mP1.y, pR, pG, pB);
	fillPixel(&_pixels [1], (int) mP2.x, (int) mP2.y, pR, pG, pB);

	// Blitting line
	_info._device->DrawPrimitiveUP(D3DPT_LINESTRIP, 1, &_pixels, sizeof(PIXEL));
}
Ejemplo n.º 3
0
/*
==================
Blits a bounding circle area
==================
*/
inline void IND_Render::BlitCollisionCircle (int pPosX, int pPosY, int pRadius, float pScale,  byte pR, byte pG, byte pB, byte pA, IND_Matrix pIndWorldMatrix)
{
	if (pScale != 1.0f) pRadius = (int) (pRadius * pScale);

	SetTransform2d (0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0);

	D3DXMATRIX mWorldMatrix;
	GetD3DMatrix (pIndWorldMatrix, &mWorldMatrix);

	// Untransformed points
	D3DXVECTOR2 mP1Untransformed ((float) pPosX, (float) pPosY);			

	D3DXVECTOR4 mP1;
	D3DXVec2Transform (&mP1, &mP1Untransformed, &mWorldMatrix);

	// Color
	SetRainbow2d (IND_OPAQUE, 1, 0, 0, IND_FILTER_POINT, pR, pG, pB, pA, 0, 0, 0, 255, 0, 0);
	
	// Color
	mInfo.mDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);

	// Pixel format
	mInfo.mDevice->SetFVF (D3DFVF_PIXEL);

	// Blitting
	int x, y, i;

	for (i = 0; i < 30; i++)
	{
		float c = i * 2 * (float) (PI / 30);
		x = (int) ( mP1.x + (pRadius * cos (c + D3DXToRadian (0))) );
		y = (int) ( mP1.y + (pRadius * sin (c + D3DXToRadian (0))) );

		FillPixel (&mPixels [i], x, y, pR, pG, pB);
	}

	FillPixel (&mPixels [i], (int) mP1.x + (int) (pRadius * cos (D3DXToRadian (0))), (int) mP1.y + (int) (pRadius * sin (D3DXToRadian (0))), pR, pG, pB);

	// Blitting circle
	mInfo.mDevice->DrawPrimitiveUP (D3DPT_LINESTRIP, i, &mPixels, sizeof (PIXEL));	
}