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() ); }