void DrawPathLineMask() { DrawRadarMask(); unsigned int color; CVector2D points[2]; if(gCurrentGpsMode != GPS_MODE_DISABLED) { color = 0; points[0].x = 1; points[0].y = 1; points[1].x = -1; points[1].y = -1; RwRenderStateSet(rwRENDERSTATETEXTURERASTER, NULL); TransformRadarPointToScreenSpace(points[0], points[0]); TransformRadarPointToScreenSpace(points[1], points[1]); SetSpriteVertices(points[1].x, (float)*gScreenHeight, points[1].x, 0.0, 0.0, (float)*gScreenHeight, 0.0, 0.0, &color, &color, &color, &color); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, gSpriteVertices, 4); SetSpriteVertices(points[0].x, points[0].y, points[0].x, 0.0, points[1].x, points[0].y, points[1].x, 0.0, &color, &color, &color, &color); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, gSpriteVertices, 4); SetSpriteVertices(points[0].x, (float)*gScreenHeight, points[0].x, points[1].y, points[1].x, (float)*gScreenHeight, points[1].x, points[1].y, &color, &color, &color, &color); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, gSpriteVertices, 4); SetSpriteVertices((float)*gScreenWidth, (float)*gScreenHeight, (float)*gScreenWidth, 0.0, points[0].x, (float)*gScreenHeight, points[0].x, 0.0, &color, &color, &color, &color); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, gSpriteVertices, 4); } RwD3D9SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); }
void DrawLine(CVector2D const&a, CVector2D const&b, float width, unsigned int color) { CVector2D point[4], shift[2], dir; width /= 2.0; dir.x = b.x - a.x; dir.y = b.y - a.y; float angle = atan2(dir.y, dir.x); shift[0].x = cos(angle - 1.5707963f) * width; shift[0].y = sin(angle - 1.5707963f) * width; shift[1].x = cos(angle + 1.5707963f) * width; shift[1].y = sin(angle + 1.5707963f) * width; point[0].x = a.x + shift[1].x; point[0].y = a.y + shift[1].y; point[1].x = b.x + shift[1].x; point[1].y = b.y + shift[1].y; point[2].x = a.x + shift[0].x; point[2].y = a.y + shift[0].y; point[3].x = b.x + shift[0].x; point[3].y = b.y + shift[0].y; float oldZ = RwIm2DGetNearScreenZ(); RwIm2DSetNearScreenZ(oldZ + *gRadarMapZShift); SetSpriteVertices(point[0].x, point[0].y, point[1].x, point[1].y, point[2].x, point[2].y, point[3].x, point[3].y, &color, &color, &color, &color); RwIm2DSetNearScreenZ(oldZ); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, gSpriteVertices, 4); }
void ShapeHelper::DrawCircleSectorTextured(float tex_width, float tex_height, float tex_u_offset, float tex_v_offset, float tex_u_size, float tex_v_size, float center_x, float center_y, float width, float height, float start, float end) { static RwIm2DVertex verts[MAX_CIRCLE_SIDES * 2 + 3]; unsigned int vertsCounter = 0; AddOneVertToBuffer(verts, vertsCounter++, center_x, center_y, 0.0f, 1.0f, 0.5f * tex_u_size / tex_width + tex_u_offset / tex_width, 0.5f * tex_v_size / tex_height + tex_v_offset / tex_height, RWRGBALONG(255, 255, 255, 255)); float a = start; for (int i = 0; i < 60; i++) { float cos_x = mCosTable[static_cast<unsigned int>(a) % 360]; float cos_y = mSinTable[static_cast<unsigned int>(a) % 360]; float u = cos_x / 2.0f + 0.5f; float v = cos_y / 2.0f + 0.5f; AddOneVertToBuffer(verts, vertsCounter++, cos_x * width + center_x, cos_y * height + center_y, 0.0f, 1.0f, u * tex_u_size / tex_width + tex_u_offset / tex_width, v * tex_v_size / tex_height + tex_v_offset / tex_height, RWRGBALONG(255, 255, 255, 255)); AddOneVertToBuffer(verts, vertsCounter++, center_x, center_y, 0.0f, 1.0f, 0.5f * tex_u_size / tex_width + tex_u_offset / tex_width, 0.5f * tex_v_size / tex_height + tex_v_offset / tex_height, RWRGBALONG(255, 255, 255, 255)); a += CIRCLE_STEP; if (a > end) { cos_x = mCosTable[static_cast<unsigned int>(end) % 360]; cos_y = mSinTable[static_cast<unsigned int>(end) % 360]; u = cos_x / 2.0f + 0.5f; v = cos_y / 2.0f + 0.5f; AddOneVertToBuffer(verts, vertsCounter++, cos_x * width + center_x, cos_y * height + center_y, 0.0f, 1.0f, u * tex_u_size / tex_width + tex_u_offset / tex_width, v * tex_v_size / tex_height + tex_v_offset / tex_height, RWRGBALONG(255, 255, 255, 255)); AddOneVertToBuffer(verts, vertsCounter++, center_x, center_y, 0.0f, 1.0f, 0.5f * tex_u_size / tex_width + tex_u_offset / tex_width, 0.5f * tex_v_size / tex_height + tex_v_offset / tex_height, RWRGBALONG(255, 255, 255, 255)); break; } else if (a == end) break; } RwIm2DRenderPrimitive(rwPRIMTYPETRISTRIP, verts, vertsCounter); }
void ShapeHelper::DrawRotatedTexturedRectangle(CRect const& rect, float center_x, float center_y, float angle, CRGBA const& color, float u1, float v1, float u2, float v2, float u3, float v3, float u4, float v4) { CSprite2d::SetVertices(rect, color, color, color, color, u1, v1, u2, v2, u3, v3, u4, v4); RotateVertices(CSprite2d::maVertices, 4, center_x, center_y, angle); RwIm2DRenderPrimitive(rwPRIMTYPETRIFAN, CSprite2d::maVertices, 4); }