Пример #1
0
void CRenderer::RenderText( CIwGxFont * font, const CIwRect & rect, const CIwColour & color, const CIwStringS & txt, IwGxFontAlignHor hAlign, IwGxFontAlignVer vAlign )
{
	iwsfixed scale = IW_SFIXED(mDeviceParams.scale);
	iwsfixed offX  = mDeviceParams.offsetX;
	iwsfixed offY  = mDeviceParams.offsetY;

	CIwRect r;
	r.x = IW_FIXED_MUL(rect.x, scale) + offX;
	r.y = IW_FIXED_MUL(rect.y, scale) + offY;
	r.w = IW_FIXED_MUL(rect.w, scale);
	r.h = IW_FIXED_MUL(rect.h, scale);

	Flush();
	
	DefaultMaterial();

	IwGxFontClearFlags(0xffffffff);
	IwGxLightingOn();	
	IwGxFontSetFont( font );
	IwGxFontSetCol( color );
	//IwGxFontSetScale( scale );

	//Set the formatting rect - this controls where the text appears and what it is formatted against
	IwGxFontSetRect(r);
	IwGxFontSetAlignmentVer(vAlign);
	IwGxFontSetAlignmentHor(hAlign);

	//Draw the text
	IwGxFontDrawText(txt.c_str());
	IwGxLightingOff();
	IwGxFontFreeBuffers();
	Flush();

}
Пример #2
0
void HexMapTest::SetModelMatrix() {
	s_ModelMatrix.SetIdentity();
	CIwVec3 vectCenter = getWorldCoords(IwGxGetScreenWidth()/2, IwGxGetScreenHeight()/2);
	s_ModelMatrix.t.x = vectCenter.x;
	s_ModelMatrix.t.y = vectCenter.y;

	//Zoom
	s_ModelMatrix.Scale(IW_FIXED_FROM_FLOAT(zoom));
	CIwVec3 vect = getWorldCoords(0, 0);
	CIwVec3 vect2 = getWorldCoords(screenTranslationX, screenTranslationY);

	int32 dx = int32((vect2.x-vect.x) * zoom);
	int32 dy = int32((vect2.y-vect.y) * zoom);

	//s_ModelMatrix.t.x = -dx;
	//s_ModelMatrix.t.y = -dy;

	iwfixed sinTheta = IwGeomSin(IW_ANGLE_FROM_DEGREES(-rotation));
	iwfixed cosTheta = IwGeomCos(IW_ANGLE_FROM_DEGREES(-rotation));

	s_ModelMatrix.t.x = -vectCenter.x-(IW_FIXED_MUL(dx, cosTheta) - IW_FIXED_MUL(dy, sinTheta));
	s_ModelMatrix.t.y = -vectCenter.y-(IW_FIXED_MUL(dx, sinTheta) + IW_FIXED_MUL(dy, cosTheta));
	//Rotate
	CIwMat rotationMat = CIwMat::g_Identity;
	rotationMat.SetRotZ(IW_ANGLE_FROM_DEGREES(rotation), true, true);
	s_ModelMatrix *= rotationMat;

}
Пример #3
0
void CRenderer::CameraTransform( CIwSVec2 * vertex, int vertexCount )
{
	iwsfixed scale = IW_SFIXED(mDeviceParams.scale);

	CIwSVec2 t( FLOAT_TO_FIXED(mCamera.GetPos().x), FLOAT_TO_FIXED(mCamera.GetPos().y) );
	iwsfixed csacale = IW_SFIXED( mCamera.GetScale() );

	for (int i = 0; i < vertexCount; i++)
	{
		vertex[i] -= t;
		vertex[i].x = IW_FIXED_MUL(vertex[i].x, csacale);
		vertex[i].y = IW_FIXED_MUL(vertex[i].y, csacale);

		vertex[i].x = IW_FIXED_MUL(vertex[i].x, scale) + ((mDeviceParams.offsetX) << 3);
		vertex[i].y = IW_FIXED_MUL(vertex[i].y, scale) + ((mDeviceParams.offsetY) << 3);
	}
}
Пример #4
0
void HexMapTest::SetTranslation()
{
	int16 sprite1_pos_x,sprite1_pos_y,sprite1_pos_x_initial,sprite1_pos_y_initial;
	if (g_Input.finger1MovedTo(sprite1_pos_x, sprite1_pos_y)) {
		g_Input.finger1Initial(sprite1_pos_x_initial, sprite1_pos_y_initial);
	}
	iwfixed sinTheta = IwGeomSin(IW_ANGLE_FROM_DEGREES(rotation));
	iwfixed cosTheta = IwGeomCos(IW_ANGLE_FROM_DEGREES(rotation));

	int odx = sprite1_pos_x_initial - sprite1_pos_x;
	int ody = sprite1_pos_y_initial - sprite1_pos_y;

	int dx = (IW_FIXED_MUL(odx, cosTheta) - IW_FIXED_MUL(ody, sinTheta));
	int dy = (IW_FIXED_MUL(odx, sinTheta) + IW_FIXED_MUL(ody, cosTheta));

	screenTranslationX = screenTranslationX_initial + dx;
	screenTranslationY = screenTranslationY_initial + dy;
	SetModelMatrix();
}
Пример #5
0
CIwVec3 HexMapTest::getWorldCoords(int x, int y) {
// Generate a ray pointing to the view plane from the camera
	CIwVec3 dir(x - IwGxGetScreenWidth()/2, 
		y - IwGxGetScreenHeight()/2, 
		IwGxGetPerspMul());
	CIwVec3 origin = s_viewMatrix.t;
    
	// Rotate into camera space
	dir = s_viewMatrix.RotateVec(dir);

//		dir.NormaliseSlow();
	CIwVec3 inter = getIntersectionNew(origin, dir);
	inter = inter - s_ModelMatrix.t;
	iwfixed z = IW_FIXED_FROM_FLOAT(1.0f/zoom);
	inter.x = IW_FIXED_MUL(inter.x, z);
	inter.y = IW_FIXED_MUL(inter.y, z);
	inter.z = IW_FIXED_MUL(inter.z, z);

	CIwMat rotationMat = CIwMat::g_Identity;
	rotationMat.SetRotZ(IW_ANGLE_FROM_DEGREES(-rotation), true, true);
	inter = rotationMat.RotateVec(inter);
	return inter;
}