当前位置: 首页>>代码示例>>C++>>正文


C++ VideoPtr::GetVertexShader方法代码示例

本文整理汇总了C++中VideoPtr::GetVertexShader方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoPtr::GetVertexShader方法的具体用法?C++ VideoPtr::GetVertexShader怎么用?C++ VideoPtr::GetVertexShader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VideoPtr的用法示例。


在下文中一共展示了VideoPtr::GetVertexShader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawCollisionBox

void ETHRenderEntity::DrawCollisionBox(SpritePtr pOutline, const Color& dwColor, const Vector2 &zAxisDirection) const
{
	VideoPtr video = m_provider->GetVideo();
	const bool collidable = (m_properties.collision);
	const Vector3 v3Size = (collidable) ? m_properties.collision->size : Vector3(32,32,32);
	const Vector3 v3Pos = (collidable) ? (m_properties.collision->pos + GetPosition()) : GetPosition();

	const Vector2 v2Pos = ETHGlobal::ToScreenPos(v3Pos, zAxisDirection)/* + Vector2(0, v3Size.y/2)*/;
	pOutline->SetOrigin(Sprite::EO_CENTER);

	const Video::ALPHA_MODE alphaMode = video->GetAlphaMode();
	video->SetAlphaMode(Video::AM_PIXEL);

	const bool zBuffer = video->GetZBuffer();
	video->SetZBuffer(false);
	const bool zWrite = video->GetZWrite();
	video->SetZWrite(false);

	ShaderPtr pVS = video->GetVertexShader();
	video->SetVertexShader(ShaderPtr());

	const Color dwH = ARGB(150,dwColor.r,dwColor.g,dwColor.b);
	const float depth = video->GetSpriteDepth();

	// base
	video->SetSpriteDepth(1.0f);
	pOutline->DrawShaped(v2Pos, Vector2(v3Size.x, v3Size.y), dwH, dwH, dwH, dwH, GetAngle());

	video->SetZBuffer(zBuffer);
	video->SetZBuffer(zWrite);
	video->SetAlphaMode(alphaMode);
	video->SetVertexShader(pVS);
	video->SetSpriteDepth(depth);
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: DrawCollisionBox

void ETHRenderEntity::DrawCollisionBox(const bool drawBase, SpritePtr pOutline, const GS_COLOR dwColor, const Vector2 &zAxisDirection) const
{
	VideoPtr video = m_provider->GetVideo();
	const bool collidable = (m_properties.collision);
	const Vector3 v3Size = (collidable) ? m_properties.collision->size : Vector3(32,32,32);
	const Vector3 v3Pos = (collidable) ? (m_properties.collision->pos + GetPosition()) : GetPosition();

	const Vector2 v2Pos = ETHGlobal::ToScreenPos(v3Pos, zAxisDirection) + Vector2(0, v3Size.y/2);
	pOutline->SetOrigin(GSEO_CENTER_BOTTOM);

	const GS_ALPHA_MODE alphaMode = video->GetAlphaMode();
	video->SetAlphaMode(GSAM_PIXEL);

	const bool zBuffer = video->GetZBuffer();
	video->SetZBuffer(false);
	const bool zWrite = video->GetZWrite();
	video->SetZWrite(false);

	ShaderPtr pVS = video->GetVertexShader();
	video->SetVertexShader(ShaderPtr());

	const GS_COLOR dwH = ARGB(150,dwColor.r,dwColor.g,dwColor.b);
	const float depth = video->GetSpriteDepth();
	if (drawBase)
	{
		// base
		video->SetSpriteDepth(1.0f);
		pOutline->DrawShaped(v2Pos, Vector2(v3Size.x, v3Size.y), dwH, dwH, dwH, dwH);
	}
	else
	{
		video->SetSpriteDepth(0.0f);
		const GS_COLOR dwV = ARGB(50,dwColor.r,dwColor.g,dwColor.b);
		// front face
		pOutline->DrawShaped(v2Pos, Vector2(v3Size.x, v3Size.z), dwV, dwV, dwV, dwV);

		// upper face
		pOutline->DrawShaped(v2Pos-Vector2(0,v3Size.z), Vector2(v3Size.x, v3Size.y), dwH, dwH, dwH, dwH);
	}

	video->SetZBuffer(zBuffer);
	video->SetZBuffer(zWrite);
	video->SetAlphaMode(alphaMode);
	video->SetVertexShader(pVS);
	video->SetSpriteDepth(depth);
}
开发者ID:LucasZeta,项目名称:ethanon,代码行数:46,代码来源:ETHRenderEntity.cpp

示例3: DrawProjShadow

bool ETHRenderEntity::DrawProjShadow(const float maxHeight, const float minHeight, const ETHSceneProperties& sceneProps, const ETHLight& light, ETHSpriteEntity *pParent,
									 const bool maxOpacity, const bool drawToTarget, const float targetAngle, const Vector3& v3TargetPos)
{
	if (!m_pSprite || IsHidden())
		return false;

	VideoPtr video = m_provider->GetVideo();
	ETHShaderManagerPtr shaderManager = m_provider->GetShaderManager();
	SpritePtr pShadow = shaderManager->GetProjShadow();

	Vector3 v3LightPos;
	Vector3 v3ParentPos(0,0,0);

	const Vector3 v3EntityPos = GetPosition();

	if (pParent)
	{
		v3ParentPos = pParent->GetPosition();
		v3LightPos = Vector3(v3ParentPos.x, v3ParentPos.y, 0) + light.pos;
	}
	else
	{
		v3LightPos = light.pos;
	}

	// if the object is higher than the light, then the shadow shouldn't be cast on the floor
	if (v3LightPos.z < v3EntityPos.z)
	{
		return true;
	}

	const float scale = (m_properties.shadowScale <= 0.0f) ? 1.0f : m_properties.shadowScale;
	const float opacity = (m_properties.shadowOpacity <= 0.0f) ? 1.0f : m_properties.shadowOpacity;
	const Vector2 v2Size = GetCurrentSize();
	Vector2 v2ShadowSize(v2Size.x, v2Size.y);
	Vector2 v2ShadowPos(v3EntityPos.x, v3EntityPos.y);

	// if we are drawing to a target of a rotated entity
	if (drawToTarget && targetAngle != 0)
	{
		// rotate the shadow position according to entity angle
		Matrix4x4 matRot = RotateZ(-DegreeToRadian(targetAngle));
		Vector3 newShadowPos(v2ShadowPos, 0);
		newShadowPos = newShadowPos - v3TargetPos;
		newShadowPos = Multiply(newShadowPos, matRot);
		newShadowPos = newShadowPos + v3TargetPos;
		v2ShadowPos.x = newShadowPos.x;
		v2ShadowPos.y = newShadowPos.y;

		// rotate the light source to cast it correctly
		Vector3 newPos = v3LightPos - v3TargetPos;
		newPos = Multiply(newPos, matRot);
		v3LightPos = newPos + v3TargetPos;
	}

	Vector3 diff = v3EntityPos - v3LightPos;
	const float squaredDist = DP3(diff, diff);
	float squaredRange = light.range * light.range;

	if (squaredDist > squaredRange)
	{
		return true;
	}

	v2ShadowSize.x *= _ETH_SHADOW_SCALEX * scale;

	// calculate the correct shadow length according to the light height
	if ((GetPosition().z+v2Size.y) < light.pos.z) // if the light is over the entity
	{
		const float planarDist = Distance(GetPositionXY(), ETHGlobal::ToVector2(v3LightPos));
		const float verticalDist = Abs((v3EntityPos.z+v2Size.y)-v3LightPos.z);
		const float totalDist = (planarDist/verticalDist)*Abs(v3LightPos.z);
		v2ShadowSize.y = totalDist-planarDist;

		// clamp shadow length to the object's height. This is not realistic
		// but it looks better for the real-time shadows.
		v2ShadowSize.y = Min(v2Size.y*_ETH_SHADOW_FAKE_STRETCH, v2ShadowSize.y);
	}
	else
	{
		v2ShadowSize.y *= ((drawToTarget) ? _ETH_SHADOW_SCALEY : _ETH_SHADOW_SCALEY/4);
	}

	// specify a minimum length for the shadow
	v2ShadowSize.y = Max(v2ShadowSize.y, v2Size.y);

	ShaderPtr pVS = video->GetVertexShader();
	pVS->SetConstant(GS_L("shadowLength"), v2ShadowSize.y * m_properties.shadowLengthScale);
	pVS->SetConstant(GS_L("entityZ"), Max(m_shadowZ, v3EntityPos.z));
	pVS->SetConstant(GS_L("shadowZ"), m_shadowZ);
	pVS->SetConstant(GS_L("lightPos"), v3LightPos);
	video->SetSpriteDepth(
		(GetType() == ETHEntityProperties::ET_VERTICAL) ?
		ETHEntity::ComputeDepth(m_shadowZ, maxHeight, minHeight)
		: Max(0.0f, ComputeDepth(maxHeight, minHeight) - m_layrableMinimumDepth));

	v2ShadowSize.y = 1.0f;

	Vector2 lightPos2(v3LightPos.x, v3LightPos.y);
	const float shadowAngle = ::GetAngle((lightPos2 - Vector2(v3EntityPos.x, v3EntityPos.y))) + DegreeToRadian(targetAngle);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的VideoPtr::GetVertexShader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。