void CParticleEffect::PaintLRS (CG16bitImage &Dest, int x, int y, const ViewportTransform &Trans)

//	PaintLRS
//
//	Paints the object on an LRS

	{
	SParticleArray *pGroup = m_pFirstGroup;
	while (pGroup)
		{
		COLORREF wColor = CGImage::RGBColor(128, 128, 128);

		for (int i = 0; i < pGroup->iCount; i++)
			if ((i % 10) == 0
					&& pGroup->pParticles[i].IsValid())
			{
			int x, y;

			Trans.Transform(GetPos() + pGroup->pParticles[i].vPos, &x, &y);
			Dest.DrawPixel(x, y, wColor);
			}

		pGroup = pGroup->pNext;
		}
	}
Example #2
0
void COrbit::Paint (CG16bitImage &Dest, const ViewportTransform &Trans, COLORREF rgbColor)

//	Paint
//
//	Paint the orbit

	{
	DWORD redValue = GetRValue(rgbColor);
	DWORD greenValue = GetGValue(rgbColor);
	DWORD blueValue = GetBValue(rgbColor);

	//	Paint circular orbits in a single color; eccentric orbits change color
	//	since they are not equidistant from the sun

	if (m_rEccentricity == 0.0)
		{
		Metric rAngle;
		const Metric rIncrement = g_Pi / 90.0;
		int xPrev, yPrev;
		WORD wColor;

		//	The orbit color fades depending on the distance from the sun

		Metric rFade = 0.25 + (LIGHT_SECOND * 180.0 / m_rSemiMajorAxis);
		if (rFade < 1.0)
			wColor = CG16bitImage::RGBValue((int)(redValue * rFade), (int)(greenValue * rFade), (int)(blueValue * rFade));
		else
			wColor = CG16bitImage::RGBValue((WORD)redValue, (WORD)greenValue, (WORD)blueValue);

		//	Compute the position of the starting point

		Trans.Transform(GetPointCircular(0.0), &xPrev, &yPrev);

		//	Paint the orbit in multiple segments

		for (rAngle = rIncrement; rAngle < g_Pi * 2.0; rAngle += rIncrement)
			{
			//	Compute the end point

			int x, y;
			Trans.Transform(GetPointCircular(rAngle), &x, &y);

			//	Draw a line segment

			Dest.DrawLine(xPrev, yPrev, x, y, 1, wColor);

			//	Next point

			xPrev = x;
			yPrev = y;
			}
		}
	else
		{
		Metric rAngle;
		const Metric rIncrement = g_Pi / 90.0;
		int xPrev, yPrev;

		//	Compute the position of the starting point

		Trans.Transform(GetPoint(0.0), &xPrev, &yPrev);

		//	Paint the orbit in multiple segments

		for (rAngle = rIncrement; rAngle < g_Pi * 2.0; rAngle += rIncrement)
			{
			Metric rRadius;
			CVector vPos = GetPointAndRadius(rAngle, &rRadius);
			WORD wColor;

			//	Compute the end point

			int x, y;
			Trans.Transform(vPos, &x, &y);

			//	The orbit color fades depending on the distance from the sun

			Metric rFade = 0.25 + (LIGHT_SECOND * 180.0 / rRadius);
			if (rFade < 1.0)
				wColor = CG16bitImage::RGBValue((int)(redValue * rFade), (int)(greenValue * rFade), (int)(blueValue * rFade));
			else
				wColor = CG16bitImage::RGBValue((WORD)redValue, (WORD)greenValue, (WORD)blueValue);

			//	Draw a line segment

			Dest.DrawLine(xPrev, yPrev, x, y, 1, wColor);

			//	Next point

			xPrev = x;
			yPrev = y;
			}
		}
	}