void Ship::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { if (IsDead()) return; m_shipFlavour.ApplyTo(GetModel()); //angthrust negated, for some reason GetModel()->SetThrust(vector3f(m_thrusters), -vector3f(m_angThrusters)); if (m_landingGearAnimation) m_landingGearAnimation->SetProgress(m_wheelState); //strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText)); RenderModel(renderer, viewCoords, viewTransform); // draw shield recharge bubble if (m_stats.shield_mass_left < m_stats.shield_mass) { const float shield = 0.01f*GetPercentShields(); renderer->SetBlendMode(Graphics::BLEND_ADDITIVE); glPushMatrix(); matrix4x4f trans = matrix4x4f::Identity(); trans.Translate(viewCoords.x, viewCoords.y, viewCoords.z); trans.Scale(GetPhysRadius()); renderer->SetTransform(trans); //fade based on strength Sfx::shieldEffect->GetMaterial()->diffuse = Color((1.0f-shield),shield,0.0,0.33f*(1.0f-shield)); Sfx::shieldEffect->Draw(renderer); glPopMatrix(); renderer->SetBlendMode(Graphics::BLEND_SOLID); } if (m_ecmRecharge > 0.0f) { // ECM effect: a cloud of particles for a sparkly effect vector3f v[100]; for (int i=0; i<100; i++) { const double r1 = Pi::rng.Double()-0.5; const double r2 = Pi::rng.Double()-0.5; const double r3 = Pi::rng.Double()-0.5; v[i] = vector3f(viewTransform * ( GetPosition() + GetPhysRadius() * vector3d(r1, r2, r3).Normalized() )); } Color c(0.5,0.5,1.0,1.0); float totalRechargeTime = GetECMRechargeTime(); if (totalRechargeTime >= 0.0f) { c.a = m_ecmRecharge / totalRechargeTime; } Sfx::ecmParticle->diffuse = c; renderer->SetBlendMode(Graphics::BLEND_ALPHA_ONE); renderer->DrawPointSprites(100, v, Sfx::ecmParticle, 50.f); } }
void Ship::Render(Graphics::Renderer *renderer, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform) { if (IsDead()) return; //angthrust negated, for some reason GetModel()->SetThrust(vector3f(m_thrusters), -vector3f(m_angThrusters)); matrix3x3f mt; matrix3x3dtof(viewTransform.Inverse().GetOrient(), mt); s_heatGradientParams.heatingMatrix = mt; s_heatGradientParams.heatingNormal = vector3f(GetVelocity().Normalized()); s_heatGradientParams.heatingAmount = Clamp(GetHullTemperature(),0.0,1.0); // This has to be done per-model with a shield and just before it's rendered const bool shieldsVisible = m_shieldCooldown > 0.01f && m_stats.shield_mass_left > (m_stats.shield_mass / 100.0f); GetShields()->SetEnabled(shieldsVisible); GetShields()->Update(m_shieldCooldown, 0.01f*GetPercentShields()); //strncpy(params.pText[0], GetLabel().c_str(), sizeof(params.pText)); RenderModel(renderer, camera, viewCoords, viewTransform); m_navLights->Render(renderer); renderer->GetStats().AddToStatCount(Graphics::Stats::STAT_SHIPS, 1); if (m_ecmRecharge > 0.0f) { // ECM effect: a cloud of particles for a sparkly effect vector3f v[100]; for (int i=0; i<100; i++) { const double r1 = Pi::rng.Double()-0.5; const double r2 = Pi::rng.Double()-0.5; const double r3 = Pi::rng.Double()-0.5; v[i] = vector3f(GetPhysRadius()*vector3d(r1, r2, r3).NormalizedSafe()); } Color c(128,128,255,255); float totalRechargeTime = GetECMRechargeTime(); if (totalRechargeTime >= 0.0f) { c.a = (m_ecmRecharge / totalRechargeTime) * 255; } SfxManager::ecmParticle->diffuse = c; matrix4x4f t; for (int i=0; i<12; i++) t[i] = float(viewTransform[i]); t[12] = viewCoords.x; t[13] = viewCoords.y; t[14] = viewCoords.z; t[15] = 1.0f; renderer->SetTransform(t); renderer->DrawPointSprites(100, v, SfxManager::additiveAlphaState, SfxManager::ecmParticle.get(), 50.f); } }