Beispiel #1
0
void tSidebarControlTrim::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    Assert(painter != 0 && option != 0);
    tSidebarControl::paint(painter, option, widget);

    tMercuryStyle* style = GetMercuryStyle();
    if( style == 0 )
    {
        return;
    }

    QRect contentRect(option->rect);
    contentRect.adjust(0, 0, 0, -1);

    float countMod = (1.8f - float(m_Count) * 0.2f);
    const int tabWidth = int(contentRect.width() * g_cTabWidth * countMod);
    const int columnHeight = int(contentRect.height() * g_cColumnHeight);
    const int columnGap = int(contentRect.width() * g_cColumnGap * countMod);
    const int indicatorHeight = int(contentRect.height() * g_cIndicatorHeight);
    const int verticalPadding = (contentRect.height() - columnHeight) / 2;

    QColor tickColorPrime = style->GetColor(tMercuryStyle::eColorRolePrimaryTickLine);
    QColor tickColor = style->GetColor(tMercuryStyle::eColorRoleSecondaryTickLine);
    QColor indicatorColor = style->GetColor(tMercuryStyle::eColorRoleLevelLine);

    int x = contentRect.left();
    if( m_TabsVisible )
    {
        DrawColumn(*painter, QRect(x, contentRect.top() + verticalPadding, tabWidth, columnHeight),
            tickColor, indicatorColor, tickColorPrime, indicatorHeight, m_ValueLeft, m_TabZeroPoint[0], m_TabValid[0]);
    }

    x += tabWidth * 2 + columnGap;
    const int valueWidth = (contentRect.width() - tabWidth * 4 - columnGap * (1 + m_Count)) / m_Count;
    for( int i = 0; i < m_Count; i++ )
    {
        if( m_TrimVisible )
        {
            DrawColumn(*painter, QRect(x, contentRect.top() + verticalPadding, valueWidth, columnHeight),
                tickColor, indicatorColor, tickColorPrime, indicatorHeight,
                qMin(1.f, 1.3333f * m_Values[i]),
                qMin(1.f, 1.3333f * m_ZeroPoints[i]),
                m_TrimValid[i]);
        }
        x += valueWidth + columnGap;
    }

    if( m_TabsVisible )
    {
        DrawColumn(*painter,
            QRect(contentRect.right() - tabWidth, contentRect.top() + verticalPadding, tabWidth, columnHeight),
            tickColor, indicatorColor, tickColorPrime, indicatorHeight, m_ValueRight, m_TabZeroPoint[1], m_TabValid[1]);
    }
}
Beispiel #2
0
	void RenderDecal::Render(RenderThread *thread, side_t *wall, DBaseDecal *decal, DrawSegment *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, const FWallCoords &savecoord, bool foggy, FDynamicColormap *basecolormap, const short *walltop, const short *wallbottom, bool drawsegPass)
	{
		DVector2 decal_left, decal_right, decal_pos;
		int x1, x2;
		double yscale;
		uint8_t flipx;
		double zpos;
		int needrepeat = 0;
		sector_t *back;
		bool calclighting;
		bool rereadcolormap;
		FDynamicColormap *usecolormap;
		float light = 0;
		const short *mfloorclip;
		const short *mceilingclip;

		if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
			return;

		// Determine actor z
		zpos = decal->Z;
		back = (curline->backsector != NULL) ? curline->backsector : curline->frontsector;

		// for 3d-floor segments use the model sector as reference
		sector_t *front;
		if ((decal->RenderFlags&RF_CLIPMASK) == RF_CLIPMID) front = decal->Sector;
		else front = curline->frontsector;

		switch (decal->RenderFlags & RF_RELMASK)
		{
		default:
			zpos = decal->Z;
			break;
		case RF_RELUPPER:
			if (curline->linedef->flags & ML_DONTPEGTOP)
			{
				zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
			}
			else
			{
				zpos = decal->Z + back->GetPlaneTexZ(sector_t::ceiling);
			}
			break;
		case RF_RELLOWER:
			if (curline->linedef->flags & ML_DONTPEGBOTTOM)
			{
				zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
			}
			else
			{
				zpos = decal->Z + back->GetPlaneTexZ(sector_t::floor);
			}
			break;
		case RF_RELMID:
			if (curline->linedef->flags & ML_DONTPEGBOTTOM)
			{
				zpos = decal->Z + front->GetPlaneTexZ(sector_t::floor);
			}
			else
			{
				zpos = decal->Z + front->GetPlaneTexZ(sector_t::ceiling);
			}
		}

		FTexture *WallSpriteTile = TexMan(decal->PicNum, true);
		flipx = (uint8_t)(decal->RenderFlags & RF_XFLIP);

		if (WallSpriteTile == NULL || WallSpriteTile->UseType == ETextureType::Null)
		{
			return;
		}

		// Determine left and right edges of sprite. Since this sprite is bound
		// to a wall, we use the wall's angle instead of the decal's. This is
		// pretty much the same as what R_AddLine() does.

		double edge_right = WallSpriteTile->GetWidth();
		double edge_left = WallSpriteTile->GetLeftOffset(0);	// decals should not use renderer-specific offsets.
		edge_right = (edge_right - edge_left) * decal->ScaleX;
		edge_left *= decal->ScaleX;

		double dcx, dcy;
		decal->GetXY(wall, dcx, dcy);
		decal_pos = { dcx, dcy };

		DVector2 angvec = (curline->v2->fPos() - curline->v1->fPos()).Unit();
		float maskedScaleY;

		decal_left = decal_pos - edge_left * angvec - thread->Viewport->viewpoint.Pos;
		decal_right = decal_pos + edge_right * angvec - thread->Viewport->viewpoint.Pos;

		CameraLight *cameraLight;
		double texturemid;

		FWallCoords WallC;
		if (WallC.Init(thread, decal_left, decal_right, TOO_CLOSE_Z))
			return;

		x1 = WallC.sx1;
		x2 = WallC.sx2;

		if (x1 >= clipper->x2 || x2 <= clipper->x1)
			return;

		FWallTmapVals WallT;
		WallT.InitFromWallCoords(thread, &WallC);

		if (drawsegPass)
		{
			uint32_t clipMode = decal->RenderFlags & RF_CLIPMASK;
			if (clipMode != RF_CLIPMID && clipMode != RF_CLIPFULL)
				return;

			// Clip decal to stay within the draw segment wall
			mceilingclip = walltop;
			mfloorclip = wallbottom;

			// Rumor has it that if RT_CLIPMASK is specified then the decal should be clipped according
			// to the full drawsegment visibility, as implemented in the remarked section below.
			//
			// This is problematic because not all 3d floors may have been drawn yet at this point. The
			// code below might work ok for cases where there is only one 3d floor.

			/*if (clipMode == RF_CLIPFULL)
			{
				mceilingclip = clipper->sprtopclip - clipper->x1;
				mfloorclip = clipper->sprbottomclip - clipper->x1;
			}*/
		}
		else
		{
			// Get the top and bottom clipping arrays
			switch (decal->RenderFlags & RF_CLIPMASK)
			{
			default:
				// keep GCC quiet.
				return;

			case RF_CLIPFULL:
				if (curline->backsector == NULL)
				{
					mceilingclip = walltop;
					mfloorclip = wallbottom;
				}
				else
				{
					mceilingclip = walltop;
					mfloorclip = thread->OpaquePass->ceilingclip;
					needrepeat = 1;
				}
				break;

			case RF_CLIPUPPER:
				mceilingclip = walltop;
				mfloorclip = thread->OpaquePass->ceilingclip;
				break;

			case RF_CLIPMID:
				return;

			case RF_CLIPLOWER:
				mceilingclip = thread->OpaquePass->floorclip;
				mfloorclip = wallbottom;
				break;
			}
		}

		yscale = decal->ScaleY;
		texturemid = WallSpriteTile->GetTopOffset(0) + (zpos - thread->Viewport->viewpoint.Pos.Z) / yscale;

		// Clip sprite to drawseg
		x1 = MAX<int>(clipper->x1, x1);
		x2 = MIN<int>(clipper->x2, x2);
		if (x1 >= x2)
		{
			return;
		}

		ProjectedWallTexcoords walltexcoords;
		walltexcoords.Project(thread->Viewport.get(), WallSpriteTile->GetWidth(), x1, x2, WallT);

		if (flipx)
		{
			int i;
			int right = (WallSpriteTile->GetWidth() << FRACBITS) - 1;

			for (i = x1; i < x2; i++)
			{
				walltexcoords.UPos[i] = right - walltexcoords.UPos[i];
			}
		}

		// Prepare lighting
		calclighting = false;
		usecolormap = basecolormap;
		rereadcolormap = true;

		// Decals that are added to the scene must fade to black.
		if (decal->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
		{
			usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate);
			rereadcolormap = false;
		}

		light = lightleft + (x1 - savecoord.sx1) * lightstep;

		cameraLight = CameraLight::Instance();

		// Draw it
		bool sprflipvert;
		if (decal->RenderFlags & RF_YFLIP)
		{
			sprflipvert = true;
			yscale = -yscale;
			texturemid -= WallSpriteTile->GetHeight();
		}
		else
		{
			sprflipvert = false;
		}

		maskedScaleY = float(1 / yscale);
		do
		{
			int x = x1;

			SpriteDrawerArgs drawerargs;

			if (cameraLight->FixedLightLevel() >= 0)
				drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, cameraLight->FixedLightLevelShade());
			else if (cameraLight->FixedColormap() != NULL)
				drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
			else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))
				drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
			else
				calclighting = true;

			bool visible = drawerargs.SetStyle(thread->Viewport.get(), decal->RenderStyle, (float)decal->Alpha, decal->Translation, decal->AlphaColor, basecolormap);

			// R_SetPatchStyle can modify basecolormap.
			if (rereadcolormap)
			{
				usecolormap = basecolormap;
			}

			if (visible)
			{
				thread->PrepareTexture(WallSpriteTile, decal->RenderStyle);
				while (x < x2)
				{
					if (calclighting)
					{ // calculate lighting
						drawerargs.SetLight(usecolormap, light, wallshade);
					}
					DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, decal->RenderStyle);
					light += lightstep;
					x++;
				}
			}

			// If this sprite is RF_CLIPFULL on a two-sided line, needrepeat will
			// be set 1 if we need to draw on the lower wall. In all other cases,
			// needrepeat will be 0, and the while will fail.
			mceilingclip = thread->OpaquePass->floorclip;
			mfloorclip = wallbottom;
		} while (needrepeat--);
	}
Beispiel #3
0
	void RenderWallSprite::Render(RenderThread *thread, short *mfloorclip, short *mceilingclip, int, int, Fake3DTranslucent)
	{
		auto spr = this;

		int x1, x2;
		double iyscale;
		bool sprflipvert;

		x1 = MAX<int>(spr->x1, spr->wallc.sx1);
		x2 = MIN<int>(spr->x2, spr->wallc.sx2);
		if (x1 >= x2)
			return;

		FWallTmapVals WallT;
		WallT.InitFromWallCoords(thread, &spr->wallc);

		ProjectedWallTexcoords walltexcoords;
		walltexcoords.Project(thread->Viewport.get(), spr->pic->GetWidth() << FRACBITS, x1, x2, WallT);

		iyscale = 1 / spr->yscale;
		double texturemid = (spr->gzt - thread->Viewport->viewpoint.Pos.Z) * iyscale;
		if (spr->renderflags & RF_XFLIP)
		{
			int right = (spr->pic->GetWidth() << FRACBITS) - 1;

			for (int i = x1; i < x2; i++)
			{
				walltexcoords.UPos[i] = right - walltexcoords.UPos[i];
			}
		}
		// Prepare lighting
		bool calclighting = false;
		FSWColormap *usecolormap = spr->Light.BaseColormap;
		bool rereadcolormap = true;

		// Decals that are added to the scene must fade to black.
		if (spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && usecolormap->Fade != 0)
		{
			usecolormap = GetSpecialLights(usecolormap->Color, 0, usecolormap->Desaturate);
			rereadcolormap = false;
		}

		SpriteDrawerArgs drawerargs;

		int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy);
		double GlobVis = thread->Light->WallGlobVis(foggy);
		float lightleft = float(GlobVis / spr->wallc.sz1);
		float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
		float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
		CameraLight *cameraLight = CameraLight::Instance();
		if (cameraLight->FixedLightLevel() >= 0)
			drawerargs.SetLight(usecolormap, 0, cameraLight->FixedLightLevelShade());
		else if (cameraLight->FixedColormap() != NULL)
			drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
		else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT))
			drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, 0);
		else
			calclighting = true;

		// Draw it
		FTexture *WallSpriteTile = spr->pic;
		if (spr->renderflags & RF_YFLIP)
		{
			sprflipvert = true;
			iyscale = -iyscale;
			texturemid -= spr->pic->GetHeight();
		}
		else
		{
			sprflipvert = false;
		}

		float maskedScaleY = (float)iyscale;

		int x = x1;

		FDynamicColormap *basecolormap = static_cast<FDynamicColormap*>(spr->Light.BaseColormap);

		bool visible = drawerargs.SetStyle(thread->Viewport.get(), spr->RenderStyle, spr->Alpha, spr->Translation, spr->FillColor, basecolormap);

		// R_SetPatchStyle can modify basecolormap.
		if (rereadcolormap)
		{
			usecolormap = spr->Light.BaseColormap;
		}

		if (!visible)
		{
			return;
		}
		else
		{
			RenderTranslucentPass *translucentPass = thread->TranslucentPass.get();

			thread->PrepareTexture(WallSpriteTile, spr->RenderStyle);
			while (x < x2)
			{
				if (calclighting)
				{ // calculate lighting
					drawerargs.SetLight(usecolormap, light, shade);
				}
				if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
					DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);
				light += lightstep;
				x++;
			}
		}
	}
void DrawParthenon(glutil::MatrixStack &modelMatrix)
{
    //Draw base.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Scale(glm::vec3(parthenonWidth, parthenonBaseHeight, parthenonLength));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(UniformColorTint.theProgram);
        glUniformMatrix4fv(UniformColorTint.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        glUniform4f(UniformColorTint.baseColorUnif, 0.9f, 0.9f, 0.9f, 0.9f);
        cubeTintMesh->Render();
        glUseProgram(0);
    }

    //Draw top.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, parthenonColumnHeight + parthenonBaseHeight, 0.0f));
        modelMatrix.Scale(glm::vec3(parthenonWidth, parthenonTopHeight, parthenonLength));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(UniformColorTint.theProgram);
        glUniformMatrix4fv(UniformColorTint.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        glUniform4f(UniformColorTint.baseColorUnif, 0.9f, 0.9f, 0.9f, 0.9f);
        cubeTintMesh->Render();
        glUseProgram(0);
    }

    //Draw columns.
    const float frontZVal = (parthenonLength / 2.0f) - 1.0f;
    const float rightXVal = (parthenonWidth / 2.0f) - 1.0f;

    for(int columnNum = 0; columnNum < int(parthenonWidth / 2.0f); columnNum++)
    {
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3((2.0f * columnNum) - (parthenonWidth / 2.0f) + 1.0f,
                                            parthenonBaseHeight,
                                            frontZVal));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3((2.0f * columnNum) - (parthenonWidth / 2.0f) + 1.0f,
                                            parthenonBaseHeight,
                                            -frontZVal));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
    }

    //Don't draw the first or last columns, since they've been drawn already.
    for(int columnNum = 1; columnNum < int((parthenonLength - 2.0f) / 2.0f); columnNum++)
    {
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3(rightXVal,
                                            parthenonBaseHeight,
                                            (2.0f * columnNum) - (parthenonLength / 2.0f) + 1.0f));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
        {
            glutil::PushStack push(modelMatrix);
            modelMatrix.Translate(glm::vec3(-rightXVal,
                                            parthenonBaseHeight,
                                            (2.0f * columnNum) - (parthenonLength / 2.0f) + 1.0f));

            DrawColumn(modelMatrix, parthenonColumnHeight);
        }
    }

    //Draw interior.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f, 1.0f, 0.0f));
        modelMatrix.Scale(glm::vec3(parthenonWidth - 6.0f, parthenonColumnHeight, parthenonLength - 6.0f));
        modelMatrix.Translate(glm::vec3(0.0f, 0.5f, 0.0f));

        glUseProgram(ObjectColor.theProgram);
        glUniformMatrix4fv(ObjectColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        cubeColorMesh->Render();
        glUseProgram(0);
    }

    //Draw headpiece.
    {
        glutil::PushStack push(modelMatrix);

        modelMatrix.Translate(glm::vec3(0.0f,
                                        parthenonColumnHeight + parthenonBaseHeight + (parthenonTopHeight / 2.0f),
                                        parthenonLength / 2.0f));
        modelMatrix.RotateX(-135.0f);
        modelMatrix.RotateY(45.0f);

        glUseProgram(ObjectColor.theProgram);
        glUniformMatrix4fv(ObjectColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top()));
        cubeColorMesh->Render();
        glUseProgram(0);
    }
}
Beispiel #5
0
//--------------------------------------------------------------------------//
//--------------------------------------------------------------------------//
void CAGSymText::Draw(CAGDC& dc)
{
	dc.PushModelingMatrix(m_Matrix);
	DrawColumn(dc);
	dc.PopModelingMatrix();
}