示例#1
0
void CTreeManager::Render() const
{
	if (SPGame()->GetSPRenderer()->GetRenderingScale() != SCALE_RENDER)
		return;

	if (GameServer()->GetRenderer()->IsRenderingTransparent())
		return;

	double flScale = CScalableFloat::ConvertUnits(1, m_pPlanet->GetScale(), SCALE_METER);

	DoubleVector vecCharacterOrigin;
	if (SPGame()->GetLocalPlayerCharacter()->GetMoveParent() == m_pPlanet)
		vecCharacterOrigin = m_pPlanet->GetCharacterLocalOrigin()*flScale;
	else
		vecCharacterOrigin = (m_pPlanet->GetGlobalToLocalTransform() * SPGame()->GetLocalPlayerCharacter()->GetGlobalOrigin()).GetUnits(SCALE_METER);

	for (auto it = m_aChunkTrees.begin(); it != m_aChunkTrees.end(); it++)
	{
		const CChunkTrees* pTrees = &it->second;

		if (!SPGame()->GetSPRenderer()->IsInFrustumAtScale(SCALE_METER, Vector(pTrees->m_vecLocalCenter*flScale-vecCharacterOrigin), (float)(pTrees->m_flRadius*flScale)))
			continue;

		pTrees->Render();
	}
}
示例#2
0
CScalableMatrix CSPCharacter::GetScalableRenderTransform() const
{
	CSPCharacter* pCharacter = SPGame()->GetLocalPlayerCharacter();
	CScalableVector vecCharacterOrigin = pCharacter->GetGlobalOrigin();

	CScalableMatrix mTransform = GetGlobalTransform();
	mTransform.SetTranslation(mTransform.GetTranslation() - vecCharacterOrigin);

	return mTransform;
}
示例#3
0
void CStar::PostRender() const
{
	BaseClass::PostRender();

	if (GameServer()->GetRenderer()->IsRenderingTransparent())
		return;

	CSPCharacter* pCharacter = SPGame()->GetLocalPlayerCharacter();
	CPlanet* pNearestPlanet = pCharacter->GetNearestPlanet();

	float flRadius = (float)(GetRadius()*2.0f).GetUnits(SPGame()->GetSPRenderer()->GetRenderingScale());

	CScalableFloat flDistance;
	float flAtmosphere = 0;

	if (pNearestPlanet)
	{
		flDistance = (pNearestPlanet->GetGlobalOrigin() - pCharacter->GetGlobalOrigin()).Length() - pNearestPlanet->GetRadius();
		flAtmosphere = (float)RemapValClamped(flDistance, CScalableFloat(1.0f, SCALE_KILOMETER), pNearestPlanet->GetAtmosphereThickness(), 1.0, 0.0);
	}

	CGameRenderingContext c(GameServer()->GetRenderer(), true);

	c.SetDepthMask(false);

	c.ResetTransformations();
	c.Transform(BaseGetRenderTransform());

	// Set material and uniform now so RenderBillboard doesn't overwrite the alpha value.
	c.UseMaterial("textures/star-yellow-atmosphere.mat");
	c.SetUniform("flAlpha", flAtmosphere);

	c.RenderBillboard("textures/star-yellow-atmosphere.mat", flRadius);

	c.UseMaterial("textures/star-yellow-space.mat");
	c.SetUniform("flAlpha", 1-flAtmosphere);

	c.RenderBillboard("textures/star-yellow-space.mat", flRadius);
}
示例#4
0
bool CStructure::ShouldRenderTransparent() const
{
	if (SPGame()->GetSPRenderer()->GetRenderingScale() != SCALE_RENDER)
		return false;

	if (IsUnderConstruction())
		return true;

	if (GameData().GetCommandMenu())
		return true;

	return BaseClass::ShouldRenderTransparent();
}
示例#5
0
void CStar::PostRender(bool bTransparent) const
{
	BaseClass::PostRender(bTransparent);

	if (!bTransparent)
		return;

	CRenderingContext c(GameServer()->GetRenderer());
	c.Transform(GetRenderTransform());
	c.SetBlend(BLEND_ADDITIVE);
	c.SetColor(Color(255, 255, 255, 255));
	c.SetLighting(false);

	c.UseProgram("model");
	c.RenderBillboard("textures/star-yellow.png", (float)(GetRadius()*2.0f).GetUnits(SPGame()->GetSPRenderer()->GetRenderingScale()));
}
示例#6
0
Vector CSPCharacter::GetRenderOrigin() const
{
	scale_t eScale = SPGame()->GetSPRenderer()->GetRenderingScale();
	TAssert(eScale != SCALE_NONE);
	return GetScalableRenderTransform().GetTranslation().GetUnits(eScale);
}