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


C++ Environment::GetAmbient方法代码示例

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


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

示例1: _SetParameters

	//--------------------------------------------------------------------------------------
	void PrePixelLightTransform::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		Environment* env = engine.GetEnvironment();
		ICamera* camera = engine.GetCamera();

		Matrix44f wvp = *m_pTransform * camera->GetViewProj();

		device->SetShaderParameter(m_hTransform, *m_pTransform);
		if( NULL == m_pColor )
		{
			device->SetShaderParameter(m_hColor, vector4f(1,1,1,1) );
		}
		else
		{
			device->SetShaderParameter(m_hColor, *m_pColor);
		}
		device->SetShaderParameter(m_hNormalTransform, Matrix33f( *m_pTransform ) );
		device->SetShaderParameter(m_hWorldViewProjMatrixLoc, wvp);
		device->SetShaderParameter(m_hLightDirectionLoc, -env->GetCurrentLight().GetWorldDirection());//phong光是像素到光源的方向,所以这里反向
		device->SetShaderParameter(m_hCameraPositionLoc, camera->GetPosition() );
		device->SetShaderParameter(m_hAmbientLoc, env->GetAmbient());
		device->SetShaderParameter(m_hLightLoc, env->GetCurrentLight().GetColor());
		//clean up
		m_pTransform = NULL;
		m_pColor = NULL;
	}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:29,代码来源:PrePixelLightShaders.cpp

示例2: _SetParameters

	//--------------------------------------------------------------------------------------
	void ModelSpotLightPerpixel::_SetParameters ()
	{
		Engine& engine = Engine::Instance();
		Device* device = engine.GetDevice();
		Environment* env = engine.GetEnvironment();
		ICamera* camera = engine.GetCamera();

		device->SetShaderParameter(m_hTransform, *(Matrix44f*)(m_pMaterial->Attribute( IAttributeNode::ATT_WORLDTRANSFORM )) );
		device->SetShaderParameter(m_hNormalTransform, *(Matrix33f*)(m_pMaterial->Attribute( IAttributeNode::ATT_NORMALTRANSFORM )) );
		device->SetShaderParameter(m_hViewProjMatrixLoc, camera->GetViewProj());
		device->SetShaderParameter(m_hLightDirectionLoc, env->GetCurrentLight().GetWorldDirection() );
		device->SetShaderParameter(m_hLightPosition, env->GetCurrentLight().GetWorldPosition() );
		device->SetShaderParameter(m_hCameraPositionLoc, camera->GetPosition() );

		device->SetShaderParameter(m_hLightRangeInv, 1.0f / env->GetCurrentLight().GetRange() );
		device->SetShaderParameter(m_hInner_DiffInv, env->GetCurrentLight().GetLightInnerDiffInv() );
		device->SetShaderParameter(m_hAttenuation, env->GetCurrentLight().GetAttenuation() );

		Matrix44f Bais( 0.5, 0.0, 0.0, 0.0,
						0.0, 0.5, 0.0, 0.0,
						0.0, 0.0, 0.5, 0.0,
						0.5, 0.5, 0.5, 1.0 );
		Matrix44f PBais = env->GetCurrentLight().GetCaster().GetFirstCamera().GetViewProj() * Bais;
		device->SetShaderParameter(m_hshadowMatrixBasi, PBais );
		device->SetShaderParameter(m_hCameraLineDepthParam, env->GetCurrentLight().GetCaster().GetFirstCamera().LineDepthParam() );

		device->SetShaderParameter( m_hTextureBase, *((Texture*)m_pMaterial->Attribute(Material::ATT_TEX_DIFFUSE)) );
		device->SetShaderParameter( m_hTextureDepth, env->GetCurrentLight().GetCaster().GetFirstDepthTexture() );

		device->SetShaderParameter(m_hAmbient_AmbientLight, env->GetAmbient() * m_pMaterial->Ambient() );
		device->SetShaderParameter(m_hSpecular_Light, env->GetCurrentLight().GetColor() * m_pMaterial->Specular() * m_pMaterial->SpeLevel() );
		device->SetShaderParameter(m_hLight, m_pMaterial->Diffuse() * env->GetCurrentLight().GetColor() );
		device->SetShaderParameter(m_hShininess, m_pMaterial->Shininess() );
	}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:35,代码来源:ModelShaders.cpp


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