bool ETHRenderEntity::DrawLightPass(const Vector2 &zAxisDirection, const bool drawToTarget) { if (!m_pSprite || IsHidden()) return false; ValidateSpriteCut(m_pSprite); m_pSprite->SetRect(m_spriteFrame); SetOrigin(); m_pSprite->DrawOptimal(ETHGlobal::ToScreenPos(GetPosition(), zAxisDirection), ConvertToDW(GetColorF()), (!IsRotatable() || drawToTarget) ? 0.0f : GetAngle(), m_properties.scale * m_pSprite->GetFrameSize()); return true; }
bool ETHRenderEntity::DrawAmbientPass(const float maxHeight, const float minHeight, const bool enableLightmaps, const ETHSceneProperties& sceneProps, const float parallaxIntensity) { if (!m_pSprite || IsHidden()) return false; Vector4 v4FinalAmbient = Vector4(sceneProps.ambient, 1.0f); v4FinalAmbient.x = Min(1.0f, v4FinalAmbient.x + m_properties.emissiveColor.x); v4FinalAmbient.y = Min(1.0f, v4FinalAmbient.y + m_properties.emissiveColor.y); v4FinalAmbient.z = Min(1.0f, v4FinalAmbient.z + m_properties.emissiveColor.z); v4FinalAmbient = v4FinalAmbient * m_v4Color; SetDepth(maxHeight, minHeight); const VideoPtr& video = m_provider->GetVideo(); const bool applyLightmap = (m_pLightmap && enableLightmaps && IsStatic()); if (applyLightmap) { m_pLightmap->SetAsTexture(1); } // sets the alpha mode according to the entity's property const Video::ALPHA_MODE& am = GetBlendMode(); if (am != video->GetAlphaMode()) video->SetAlphaMode(am); ValidateSpriteCut(m_pSprite); m_pSprite->SetRect(m_spriteFrame); SetOrigin(); const bool shouldUseFourTriangles = ShouldUseFourTriangles(parallaxIntensity); const float angle = (m_properties.type == ETHEntityProperties::ET_VERTICAL) ? 0.0f : GetAngle(); const Vector2 pos = ETHGlobal::ToScreenPos(GetPosition(), sceneProps.zAxisDirection); if (shouldUseFourTriangles) m_pSprite->SetRectMode(Sprite::RM_FOUR_TRIANGLES); m_pSprite->DrawOptimal(pos, ConvertToDW(v4FinalAmbient), angle, GetCurrentSize()); if (shouldUseFourTriangles) m_pSprite->SetRectMode(Sprite::RM_TWO_TRIANGLES); if (applyLightmap) { video->UnsetTexture(1); } return true; }
bool ETHRenderEntity::DrawHalo(const float maxHeight, const float minHeight, const bool rotateHalo, const Vector2 &zAxisDirection) { GS2D_UNUSED_ARGUMENT(minHeight); GS2D_UNUSED_ARGUMENT(maxHeight); if (!GetHalo() || !HasLightSource() || IsHidden()) return false; m_pHalo->SetOrigin(Sprite::EO_CENTER); const ETHLight* light = m_properties.light.get(); const Vector3 v3EntityPos = GetPosition(); // will remain as 1.0 for a while m_provider->GetVideo()->SetSpriteDepth(1.0f/*ETHGlobal::ComputeDepth(m_data.entity.light.pos.z+v3EntityPos.z+ETH_HALO_DEPTH_SHIFT, maxHeight, minHeight)*/); // if it has a particle system in the first slot, adjust the light // brightness according to the number of active particles float brightness = 1.0f; const ETHParticleManagerPtr paticleManager = GetParticleManager(0); if (paticleManager) { brightness = static_cast<float>(paticleManager->GetNumActiveParticles())/static_cast<float>(paticleManager->GetNumParticles()); } Vector3 v3HaloPos = light->pos + v3EntityPos; Color dwColor = ConvertToDW(light->color * light->haloBrightness * brightness); Vector2 v2Size(light->haloSize, light->haloSize); m_pHalo->DrawShaped( ETHGlobal::ToScreenPos(v3HaloPos, zAxisDirection) + ComputeParallaxOffset(), v2Size * m_properties.scale, dwColor, dwColor, dwColor, dwColor, (rotateHalo) ? ComputeHaloAngle() : 0.0f); return true; }