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