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


C++ MaterialInfo::setGradientLayer方法代码示例

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


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

示例1: fillInstanceData

void MeshRenderSystem::fillInstanceData(InstanceData* p_data, Entity* p_entity, 
										RenderInfo* p_renderInfo, int p_boneCount){
	MaterialInfo matInfo;

	p_data->setNumberOfActiveBones(p_boneCount);

	// Try and get the gradient component
	auto gradient = static_cast<GradientComponent*>(p_entity->getComponent(
		ComponentType::Gradient));
	if(gradient != NULL){ 

		// Set all the values needed
		matInfo = m_gfxBackend->getGfxWrapper()->getMaterialInfoFromMeshID(
			p_renderInfo->m_meshId);
		matInfo.setGradientLayer(1,gradient->m_color.layerOne);
		matInfo.setGradientLayer(2,gradient->m_color.layerTwo);
		p_data->setNumberOfActiveGradientLayers( matInfo.numberOfLayers );
	}
	// If none was found check why
	else{
		// Assume its a valid Ship Module
		ShipModule* shipModule = static_cast<ShipModule*>(m_world->
			getComponentManager()->getComponent(p_entity,ComponentType::ShipModule));

		if(shipModule != NULL && shipModule->m_parentEntity > -1){
			
			Entity* parentShip = m_world->getEntity(shipModule->m_parentEntity);
			ModuleHelper::FindParentShip(m_world,&parentShip, shipModule);

			if(parentShip != NULL){
				RenderInfo* parentShipRenderInfo = getRenderInfo(parentShip);
				matInfo = m_gfxBackend->getGfxWrapper()->getMaterialInfoFromMeshID(
					parentShipRenderInfo->m_meshId);

				auto gradient = static_cast<GradientComponent*>(parentShip->getComponent(
					ComponentType::Gradient));

				matInfo.setGradientLayer(1,gradient->m_color.layerOne);
				matInfo.setGradientLayer(2,gradient->m_color.layerTwo);
				p_data->setNumberOfActiveGradientLayers( matInfo.numberOfLayers );
			}
		}
		// If not a Ship Module set values to default
		else{
			matInfo.setGradientLayer(1, AglVector4(1,1,1,1));
			matInfo.setGradientLayer(2, AglVector4(1,1,1,1));
			p_data->setNumberOfActiveGradientLayers( 1 );
		}
	}	

	auto colorTone = static_cast<ColorTone*>(p_entity->getComponent(ComponentType::ColorTone));
	if (colorTone && colorTone->toneEnabled)
		p_data->setColorTone(colorTone->color);

	auto glowAnimation = static_cast<GlowAnimation*>(p_entity->getComponent(
		ComponentType::GlowAnimation));
	if(glowAnimation && glowAnimation->enabled)
	{
		p_data->setColorTone(glowAnimation->color);
	}

	//neg-x creates additive blending
	//neg-y replaces color entirely

	if (p_entity->getComponent(ComponentType::SelectionMarker))
		p_data->setColorTone(AglVector4(-0.6f, 0.8f, 0.2f, 1)); ///< neg-sign on y for total color replacement
	else if (p_entity->getComponent(ComponentType::TAG_Highlight))
		p_data->setColorTone(AglVector4(0.5f, 1, 1, 1));


	ShipHighlight* highlight = static_cast<ShipHighlight*>(p_entity->getComponent(ComponentType::ShipHighlight));
	if (highlight && highlight->active)
		p_data->setColorTone(highlight->color);

	ShineSpawn* shineSpawn = static_cast<ShineSpawn*>(p_entity->getComponent(ComponentType::ShineSpawn));
	if (shineSpawn)
	{
		float age = m_world->getElapsedTime()-shineSpawn->m_createdAt;
		if (age < shineSpawn->m_lifetime)
			p_data->setColorTone(AglVector4(-1, 1, 1, 1) * ((shineSpawn->m_lifetime-age) / shineSpawn->m_lifetime));
	}

	p_data->setGradientColor( matInfo.getGradientColors() );
}
开发者ID:MattiasLiljeson,项目名称:Amalgamation,代码行数:84,代码来源:MeshRenderSystem.cpp


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