Beispiel #1
0
void SliceRenderer::drawOnScreen(int animationId, int animationFrame, int screenX, int screenY, float facing, float scale, Graphics::Surface &surface) {
	if (scale == 0.0f) {
		return;
	}
	_position.x = 0;
	_position.y = 0;
	_position.z = 0;
	_facing = facing;

	loadFrame(animationId, animationFrame);

	float frameHeight = _frameSliceHeight * _frameSliceCount;
	float frameSize = sqrt(_frameScale.x * 255.0f * _frameScale.x * 255.0f + _frameScale.y * 255.0f * _frameScale.y * 255.0f);
	float size = scale / MAX(frameSize, frameHeight);

	float s = sin(_facing);
	float c = cos(_facing);

	Matrix3x2 m_rotation(c, -s, 0.0f,
	                     s,  c, 0.0f);

	Matrix3x2 m_frame(_frameScale.x, 0.0f, _framePos.x,
	                  0.0f, _frameScale.y, _framePos.y);

	Matrix3x2 m_scale_size_25_5(size,  0.0f, 0.0f,
	                            0.0f, 25.5f, 0.0f);

	Matrix3x2 m_translate_x_32k(1.0f, 0.0f, screenX,
	                            0.0f, 1.0f, 32768.0f);

	Matrix3x2 m_scale_64k_64(65536.0f,  0.0f, 0.0f,
	                             0.0f, 64.0f, 0.0f);

	Matrix3x2 m = m_scale_64k_64 * (m_translate_x_32k * (m_scale_size_25_5 * (m_rotation * m_frame)));

	setupLookupTable(_m11lookup, m(0, 0));
	setupLookupTable(_m12lookup, m(0, 1));
	_m13 = m(0, 2);
	setupLookupTable(_m21lookup, m(1, 0));
	setupLookupTable(_m22lookup, m(1, 1));
	_m23 = m(1, 2);

	int frameY = screenY + (size / 2.0f * frameHeight);
	int currentY = frameY;

	float currentSlice = 0;
	float sliceStep = 1.0f / size / _frameSliceHeight;

	uint16 *frameLinePtr = (uint16 *)surface.getPixels() + 640 * frameY;
	uint16 lineZbuffer[640];

	while (currentSlice < _frameSliceCount) {
		if (currentY >= 0 && currentY < 480) {
			memset(lineZbuffer, 0xFF, 640 * 2);
			drawSlice(currentSlice, false, frameLinePtr, lineZbuffer, currentY);
			currentSlice += sliceStep;
			currentY--;
			frameLinePtr -= 640;
		}
	}
}
Beispiel #2
0
	void Framework::Run()
	{
		if (m_init)
			while (m_frame());
	}