CPhazonBeam::CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial, const zeus::CVector3f& scale) : CGunWeapon(characterId, type, playerId, playerMaterial, scale) , x238_aaBoxScale(zeus::CVector3f(-0.14664599f, 0.f, -0.14909725f) * scale.y(), zeus::CVector3f(0.14664599f, 0.64619601f, 0.14909725f) * scale.y()) , x250_aaBoxTranslate(zeus::CVector3f(-0.0625f, 0.f, -0.09375f) * scale.y(), zeus::CVector3f(0.0625f, -0.25f, 0.09375f) * scale.y()) { x21c_phazonVeins = g_SimplePool->GetObj("PhazonVeins"); x228_phazon2nd1 = g_SimplePool->GetObj("Phazon2nd_1"); x274_24_loaded = false; x274_25_clipWipeActive = true; x274_26_veinsAlphaActive = false; x274_27_phazonVeinsIdx = false; m_aaboxShaderScale.setAABB(x238_aaBoxScale); m_aaboxShaderTranslate.setAABB(x250_aaBoxTranslate); }
bool CMVEBounce::GetValue(int frame, zeus::CVector3f& pVel, zeus::CVector3f& pPos) const { if (!x14_planePrecomputed) { /* Compute Hesse normal form of plane (for penetration testing) */ x8_planeNormal->GetValue(frame, ((zeus::CVector3f&)x18_planeValidatedNormal)); ((zeus::CVector3f&)x18_planeValidatedNormal).normalize(); zeus::CVector3f a; x4_planePoint->GetValue(frame, a); (float&)(x24_planeD) = x18_planeValidatedNormal.dot(a); } float dot = x18_planeValidatedNormal.dot(pPos); if ((dot - x24_planeD) <= 0.0f) { if (x15_dieOnPenetrate) return true; } else return false; /* Deflection event */ if (pVel.magSquared() > 0.0f) return false; zeus::CVector3f delta = pPos - pVel; pPos += zeus::CVector3f{(-((((delta.z * ((delta.x * (delta.y * x18_planeValidatedNormal.y)) + ((pVel.x * (x18_planeValidatedNormal.y * pVel.y)) + x18_planeValidatedNormal.x))) + x18_planeValidatedNormal.z) - x24_planeD)) / ((pVel.z * ((pVel.x * (x18_planeValidatedNormal.y * pVel.y)) + x18_planeValidatedNormal.x)) + x18_planeValidatedNormal.z)) - ( (x18_planeValidatedNormal.z * ((x18_planeValidatedNormal.x * (x18_planeValidatedNormal.y * pVel.y)) + pVel.x)) + pVel.z)} * pVel; float d = 0.0f; x10_restitution->GetValue(frame, d); pVel -= d * pVel; float c = 0.0f; xc_friction->GetValue(frame, c); pVel -= zeus::CVector3f{(1.0f + c) * ((x18_planeValidatedNormal.z * (x18_planeValidatedNormal.x * (x18_planeValidatedNormal.y * pVel.y)) + pVel.x) + pVel.x)} * x18_planeValidatedNormal; return false; }
void do_sound_event(std::pair<u16, CSfxHandle>& sfxHandle, float& pitch, bool doPitchBend, u32 soundId, float weight, u32 flags, float falloff, float maxDist, float minVol, float maxVol, const zeus::CVector3f& posToCam, const zeus::CVector3f& pos, TAreaId aid, CStateManager& mgr) { if (posToCam.magSquared() >= maxDist * maxDist) return; u16 useSfxId = CSfxManager::TranslateSFXID(u16(soundId)); u32 useFlags = 0x1; // Continuous parameter update if ((flags & 0x8) != 0) useFlags |= 0x8; // Doppler effect bool useAcoustics = (flags & 0x80) == 0; CAudioSys::C3DEmitterParmData parms; parms.x0_pos = pos; parms.xc_dir = zeus::skUp; parms.x18_maxDist = maxDist; parms.x1c_distComp = falloff; parms.x20_flags = useFlags; parms.x24_sfxId = useSfxId; parms.x26_maxVol = maxVol; parms.x27_minVol = minVol; parms.x28_important = false; parms.x29_prio = 0x7f; if (mgr.GetActiveRandom()->Float() <= weight) { if ((soundId & 0x80000000) != 0) { if (!sfxHandle.second) { CSfxHandle hnd; if ((soundId & 0x40000000) != 0) hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, true, aid); else hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid); if (hnd) { sfxHandle.first = useSfxId; sfxHandle.second = hnd; if (doPitchBend) CSfxManager::PitchBend(hnd, pitch); } } else { if (sfxHandle.first == useSfxId) { CSfxManager::UpdateEmitter(sfxHandle.second, parms.x0_pos, parms.xc_dir, parms.x26_maxVol); } else if ((flags & 0x4) != 0) // Pausable { CSfxManager::RemoveEmitter(sfxHandle.second); CSfxHandle hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, true, aid); if (hnd) { sfxHandle.first = useSfxId; sfxHandle.second = hnd; if (doPitchBend) CSfxManager::PitchBend(hnd, pitch); } } } } else { CSfxHandle hnd; if ((soundId & 0x40000000) != 0) hnd = CSfxManager::SfxStart(useSfxId, 1.f, 0.f, true, 0x7f, false, aid); else hnd = CSfxManager::AddEmitter(parms, useAcoustics, 0x7f, false, aid); if (doPitchBend) CSfxManager::PitchBend(hnd, pitch); } } }
void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) { /* Indirect coords are full-texture sampling when warp is completely in viewport */ m_uniform.m_indXf[1][1] = 1.f; m_uniform.m_indXf[0][0] = 1.f; m_uniform.m_indXf[2][0] = 0.f; m_uniform.m_indXf[2][1] = 0.f; /* Warp effect is fixed at 192x192 rectangle in original (1/2.5 viewport height) */ float aspect = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_CroppedViewport.x10_height); m_uniform.m_matrix[1][1] = 1.f / 2.5f; m_uniform.m_matrix[0][0] = m_uniform.m_matrix[1][1] / aspect; SClipScreenRect clipRect = {}; clipRect.x4_left = ((pt[0] - m_uniform.m_matrix[0][0]) / 2.f + 0.5f) * CGraphics::g_CroppedViewport.xc_width; if (clipRect.x4_left >= CGraphics::g_CroppedViewport.xc_width) return; clipRect.x8_top = ((pt[1] - m_uniform.m_matrix[1][1]) / 2.f + 0.5f) * CGraphics::g_CroppedViewport.x10_height; if (clipRect.x8_top >= CGraphics::g_CroppedViewport.x10_height) return; clipRect.xc_width = CGraphics::g_CroppedViewport.xc_width * m_uniform.m_matrix[0][0]; if (clipRect.x4_left + clipRect.xc_width <= 0) return; clipRect.x10_height = CGraphics::g_CroppedViewport.x10_height * m_uniform.m_matrix[1][1]; if (clipRect.x8_top + clipRect.x10_height <= 0) return; float oldW = clipRect.xc_width; if (clipRect.x4_left < 0) { clipRect.xc_width += clipRect.x4_left; m_uniform.m_indXf[0][0] = clipRect.xc_width / oldW; m_uniform.m_indXf[2][0] = -clipRect.x4_left / oldW; clipRect.x4_left = 0; } float oldH = clipRect.x10_height; if (clipRect.x8_top < 0) { clipRect.x10_height += clipRect.x8_top; m_uniform.m_indXf[1][1] = clipRect.x10_height / oldH; m_uniform.m_indXf[2][1] = -clipRect.x8_top / oldH; clipRect.x8_top = 0; } float tmp = clipRect.x4_left + clipRect.xc_width; if (tmp >= CGraphics::g_CroppedViewport.xc_width) { clipRect.xc_width = CGraphics::g_CroppedViewport.xc_width - clipRect.x4_left; m_uniform.m_indXf[0][0] = clipRect.xc_width / oldW; } tmp = clipRect.x8_top + clipRect.x10_height; if (tmp >= CGraphics::g_CroppedViewport.x10_height) { clipRect.x10_height = CGraphics::g_CroppedViewport.x10_height - clipRect.x8_top; m_uniform.m_indXf[1][1] = clipRect.x10_height / oldH; } /* Transform UV coordinates of rectangle within viewport and sampled scene texels (clamped to viewport bounds) */ zeus::CVector2f vp{float(CGraphics::g_CroppedViewport.xc_width), float(CGraphics::g_CroppedViewport.x10_height)}; m_uniform.m_matrix[0][0] = clipRect.xc_width / vp.x(); m_uniform.m_matrix[1][1] = clipRect.x10_height / vp.y(); m_uniform.m_matrix[3][0] = pt.x() + (1.f / vp.x()); m_uniform.m_matrix[3][1] = pt.y() + (1.f / vp.y()); if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) { m_uniform.m_matrix[3][2] = pt.z() * 2.f - 1.f; } else { m_uniform.m_matrix[1][1] *= -1.f; m_uniform.m_matrix[3][1] *= -1.f; m_uniform.m_matrix[3][2] = pt.z(); } if (clipRect.x4_left) { clipRect.x4_left -= 1; clipRect.xc_width += 1; } if (clipRect.x8_top) { clipRect.x8_top -= 1; clipRect.x10_height += 1; } if (clipRect.x4_left + clipRect.xc_width < CGraphics::g_CroppedViewport.xc_width) clipRect.xc_width += 1; if (clipRect.x8_top + clipRect.x10_height < CGraphics::g_CroppedViewport.x10_height) clipRect.x10_height += 1; clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left; clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top; clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top; CGraphics::ResolveSpareTexture(clipRect); m_uniform.m_strength.x() = m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width)); m_uniform.m_strength.y() = m_uniform.m_matrix[1][1] * m_strength * 0.5f; m_uniBuf->load(&m_uniform, sizeof(m_uniform)); CGraphics::SetShaderDataBinding(m_dataBind); CGraphics::DrawArray(0, 4); }