use glam::Vec3; use crate::world::WeaponKind; /// Gameplay, sight-alignment, and animation metadata for each detailed weapon model. /// All weapon meshes use canonical weapon-local coordinates: /// - `+Z`: forward toward muzzle /// - `+Y`: up /// - `(0, 0, 0)`: receiver / pistol-grip pivot /// - Iron sights & PSO-1 optic line sit cleanly on `x = 0.0, y = sight_height_y`. #[derive(Clone, Copy, Debug)] pub struct WeaponModelMeta { pub sight_height_y: f32, pub hip_offset: Vec3, pub ads_offset: Vec3, pub sprint_offset: Vec3, pub sprint_rot: Vec3, pub muzzle_local: Vec3, pub ads_fov_deg: f32, pub has_pso1_scope: bool, pub mag_capacity: u32, pub reserve_default: u32, pub reload_secs: f32, pub auto_capable: bool, pub recoil_pitch: f32, pub recoil_yaw: f32, pub recoil_kick_z: f32, } pub const fn weapon_model_meta(kind: WeaponKind) -> WeaponModelMeta { match kind { WeaponKind::Ak74m => WeaponModelMeta { sight_height_y: 0.088, hip_offset: Vec3::new(0.20, -0.19, -0.35), ads_offset: Vec3::new(0.0, -0.088, -0.25), sprint_offset: Vec3::new(0.14, -0.24, -0.30), sprint_rot: Vec3::new(-0.32, 0.58, -0.18), muzzle_local: Vec3::new(0.0, 0.018, 0.72), ads_fov_deg: 44.0, has_pso1_scope: false, mag_capacity: 30, reserve_default: 150, reload_secs: 2.2, auto_capable: true, recoil_pitch: 0.022, recoil_yaw: 0.008, recoil_kick_z: 0.042, }, WeaponKind::Akm => WeaponModelMeta { sight_height_y: 0.088, hip_offset: Vec3::new(0.21, -0.19, -0.35), ads_offset: Vec3::new(0.0, -0.088, -0.25), sprint_offset: Vec3::new(0.14, -0.25, -0.30), sprint_rot: Vec3::new(-0.34, 0.60, -0.18), muzzle_local: Vec3::new(0.0, 0.018, 0.71), ads_fov_deg: 44.0, has_pso1_scope: false, mag_capacity: 30, reserve_default: 150, reload_secs: 2.3, auto_capable: true, recoil_pitch: 0.032, recoil_yaw: 0.012, recoil_kick_z: 0.055, }, WeaponKind::Aks74u => WeaponModelMeta { sight_height_y: 0.085, hip_offset: Vec3::new(0.19, -0.175, -0.32), ads_offset: Vec3::new(0.0, -0.085, -0.23), sprint_offset: Vec3::new(0.12, -0.22, -0.27), sprint_rot: Vec3::new(-0.28, 0.52, -0.15), muzzle_local: Vec3::new(0.0, 0.016, 0.50), ads_fov_deg: 47.0, has_pso1_scope: false, mag_capacity: 30, reserve_default: 150, reload_secs: 2.0, auto_capable: true, recoil_pitch: 0.024, recoil_yaw: 0.011, recoil_kick_z: 0.040, }, WeaponKind::Pkm => WeaponModelMeta { sight_height_y: 0.106, hip_offset: Vec3::new(0.23, -0.22, -0.38), ads_offset: Vec3::new(0.0, -0.106, -0.27), sprint_offset: Vec3::new(0.16, -0.28, -0.32), sprint_rot: Vec3::new(-0.36, 0.64, -0.20), muzzle_local: Vec3::new(0.0, 0.020, 0.89), ads_fov_deg: 44.0, has_pso1_scope: false, mag_capacity: 100, reserve_default: 300, reload_secs: 3.6, auto_capable: true, recoil_pitch: 0.028, recoil_yaw: 0.015, recoil_kick_z: 0.048, }, WeaponKind::Svd => WeaponModelMeta { sight_height_y: 0.122, hip_offset: Vec3::new(0.21, -0.20, -0.36), ads_offset: Vec3::new(0.0, -0.122, -0.24), sprint_offset: Vec3::new(0.15, -0.25, -0.31), sprint_rot: Vec3::new(-0.30, 0.60, -0.18), muzzle_local: Vec3::new(0.0, 0.018, 0.96), ads_fov_deg: 21.0, has_pso1_scope: true, mag_capacity: 10, reserve_default: 40, reload_secs: 2.4, auto_capable: false, recoil_pitch: 0.046, recoil_yaw: 0.008, recoil_kick_z: 0.068, }, WeaponKind::Rpg7v => WeaponModelMeta { sight_height_y: 0.112, hip_offset: Vec3::new(0.23, -0.17, -0.30), ads_offset: Vec3::new(0.0, -0.112, -0.22), sprint_offset: Vec3::new(0.18, -0.24, -0.26), sprint_rot: Vec3::new(-0.26, 0.56, -0.15), muzzle_local: Vec3::new(0.0, 0.0, 0.80), ads_fov_deg: 48.0, has_pso1_scope: false, mag_capacity: 1, reserve_default: 4, reload_secs: 3.1, auto_capable: false, recoil_pitch: 0.055, recoil_yaw: 0.012, recoil_kick_z: 0.080, }, } } #[cfg(feature = "cold_water_assets")] mod cold_water_weapon_meshes { use glam::{Mat4, Vec2, Vec3}; use crate::core::materials::MaterialId; use crate::world::actors_mesh::MeshSlice; use crate::world::ActorVertex; /// Axis-aligned helper box. #[inline] fn push_aabb( v: &mut Vec, idx: &mut Vec, min: Vec3, max: Vec3, mat: MaterialId, ) { let center = (min + max) * 0.5; let half = (max - min) * 0.5; push_xform_box(v, idx, half, Mat4::from_translation(center), mat); } /// Oriented box with arbitrary rigid transform (`det > 0` preserves CCW outward winding). fn push_xform_box( vertices: &mut Vec, indices: &mut Vec, half: Vec3, xform: Mat4, mat: MaterialId, ) { let c = [ Vec3::new(-half.x, -half.y, half.z), Vec3::new(half.x, -half.y, half.z), Vec3::new(half.x, half.y, half.z), Vec3::new(-half.x, half.y, half.z), Vec3::new(-half.x, -half.y, -half.z), Vec3::new(half.x, -half.y, -half.z), Vec3::new(half.x, half.y, -half.z), Vec3::new(-half.x, half.y, -half.z), ]; let faces = [ ([0, 1, 2, 3], Vec3::Z), ([5, 4, 7, 6], -Vec3::Z), ([1, 5, 6, 2], Vec3::X), ([4, 0, 3, 7], -Vec3::X), ([3, 2, 6, 7], Vec3::Y), ([4, 5, 1, 0], -Vec3::Y), ]; let uvs = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]; let mat_id = mat.gpu_layer(); for (f, n_local) in faces { let base = vertices.len() as u32; let wn = xform.transform_vector3(n_local).normalize_or_zero().to_array(); for k in 0..4 { let wp = xform.transform_point3(c[f[k]]); vertices.push(ActorVertex { position: wp.to_array(), normal: wn, uv: uvs[k], mat_id, }); } indices.extend_from_slice(&[base, base + 1, base + 2, base, base + 2, base + 3]); } } /// Tapered low-poly cylinder oriented along local `+Z` from `z0` to `z1` (`z0 < z1`), CCW outward. #[allow(clippy::too_many_arguments)] fn push_z_cylinder( verts: &mut Vec, indices: &mut Vec, center_xy: Vec2, z0: f32, z1: f32, r0: f32, r1: f32, sides: usize, mat: MaterialId, cap0: bool, cap1: bool, ) { let mat_id = mat.gpu_layer(); let dz = (z1 - z0).max(0.0001); let dr = r0 - r1; let ring0 = verts.len() as u32; for s in 0..sides { let ang = (s as f32 / sides as f32) * std::f32::consts::TAU; let (sa, ca) = ang.sin_cos(); let n = Vec3::new(ca * dz, sa * dz, dr).normalize_or_zero(); verts.push(ActorVertex { position: [center_xy.x + ca * r0, center_xy.y + sa * r0, z0], normal: n.to_array(), uv: [s as f32 / sides as f32, 0.0], mat_id, }); } let ring1 = verts.len() as u32; for s in 0..sides { let ang = (s as f32 / sides as f32) * std::f32::consts::TAU; let (sa, ca) = ang.sin_cos(); let n = Vec3::new(ca * dz, sa * dz, dr).normalize_or_zero(); verts.push(ActorVertex { position: [center_xy.x + ca * r1, center_xy.y + sa * r1, z1], normal: n.to_array(), uv: [s as f32 / sides as f32, 1.0], mat_id, }); } for s in 0..sides { let sn = (s + 1) % sides; let a = ring0 + s as u32; let b = ring0 + sn as u32; let c = ring1 + sn as u32; let d = ring1 + s as u32; // (b-a) ≈ +Y, (d-a) = +Z -> (b-a) x (d-a) = +X outward indices.extend_from_slice(&[a, b, c, a, c, d]); } if cap0 && r0 > 0.0005 { let c_idx = verts.len() as u32; verts.push(ActorVertex { position: [center_xy.x, center_xy.y, z0], normal: [0.0, 0.0, -1.0], uv: [0.5, 0.5], mat_id, }); for s in 0..sides { let sn = (s + 1) % sides; indices.extend_from_slice(&[c_idx, ring0 + sn as u32, ring0 + s as u32]); } } if cap1 && r1 > 0.0005 { let c_idx = verts.len() as u32; verts.push(ActorVertex { position: [center_xy.x, center_xy.y, z1], normal: [0.0, 0.0, 1.0], uv: [0.5, 0.5], mat_id, }); for s in 0..sides { let sn = (s + 1) % sides; indices.extend_from_slice(&[c_idx, ring1 + s as u32, ring1 + sn as u32]); } } } fn push_curved_mag( v: &mut Vec, idx: &mut Vec, origin: Vec3, seg_count: usize, seg_len: f32, curve_step: f32, half_xz: (f32, f32), mat: MaterialId, ) { let mut cur = origin; let mut tilt = 0.14_f32; for s in 0..seg_count { let step_dir = Vec3::new(0.0, -tilt.cos(), tilt.sin()); let center = cur + step_dir * (seg_len * 0.5); let rot = Mat4::from_rotation_x(-tilt); push_xform_box( v, idx, Vec3::new(half_xz.0, seg_len * 0.54, half_xz.1), Mat4::from_translation(center) * rot, mat, ); cur += step_dir * seg_len; tilt += curve_step + (s as f32) * 0.03; } } fn push_ak_iron_sights( v: &mut Vec, idx: &mut Vec, rear_z: f32, front_z: f32, sight_y: f32, mat: MaterialId, ) { // Rear sight base + beveled open-notch cheeks (9mm aperture so front post stands crisp) push_aabb(v, idx, Vec3::new(-0.011, 0.044, rear_z - 0.020), Vec3::new(0.011, sight_y - 0.009, rear_z + 0.022), mat); push_aabb(v, idx, Vec3::new(-0.012, sight_y - 0.009, rear_z - 0.006), Vec3::new(-0.0045, sight_y + 0.003, rear_z + 0.006), mat); push_aabb(v, idx, Vec3::new(0.0045, sight_y - 0.009, rear_z - 0.006), Vec3::new(0.012, sight_y + 0.003, rear_z + 0.006), mat); // Front sight tower + slim protective ears + centered post at x=0, y=sight_y push_aabb(v, idx, Vec3::new(-0.007, 0.018, front_z - 0.009), Vec3::new(0.007, sight_y - 0.013, front_z + 0.009), mat); push_aabb(v, idx, Vec3::new(-0.009, sight_y - 0.013, front_z - 0.006), Vec3::new(-0.006, sight_y + 0.006, front_z + 0.006), mat); push_aabb(v, idx, Vec3::new(0.006, sight_y - 0.013, front_z - 0.006), Vec3::new(0.009, sight_y + 0.006, front_z + 0.006), mat); push_aabb(v, idx, Vec3::new(-0.0013, sight_y - 0.013, front_z - 0.002), Vec3::new(0.0013, sight_y + 0.002, front_z + 0.002), mat); } // ============================================================================ // 1. AK-74M (5.45x39) — Black polymer folding stock, plum/bakelite furniture // ============================================================================ pub fn push_weapon_ak74m(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let plum = MaterialId::BakelitePlum; // Polymer folding stock with sling cutout push_xform_box(v, idx, Vec3::new(0.014, 0.018, 0.115), Mat4::from_translation(Vec3::new(0.0, 0.018, -0.17)) * Mat4::from_rotation_x(0.05), metal); push_xform_box(v, idx, Vec3::new(0.014, 0.014, 0.11), Mat4::from_translation(Vec3::new(0.0, -0.036, -0.175)) * Mat4::from_rotation_x(-0.18), metal); push_aabb(v, idx, Vec3::new(-0.017, -0.068, -0.295), Vec3::new(0.017, 0.032, -0.268), metal); // Stamped receiver + ribbed dust cover + trigger guard push_aabb(v, idx, Vec3::new(-0.020, -0.018, -0.055), Vec3::new(0.020, 0.032, 0.185), metal); push_aabb(v, idx, Vec3::new(-0.017, 0.032, -0.052), Vec3::new(0.017, 0.054, 0.155), metal); push_aabb(v, idx, Vec3::new(-0.006, -0.042, 0.02), Vec3::new(0.006, -0.018, 0.075), metal); // Pistol grip (angled Bakelite/plum) push_xform_box(v, idx, Vec3::new(0.013, 0.050, 0.017), Mat4::from_translation(Vec3::new(0.0, -0.056, -0.022)) * Mat4::from_rotation_x(0.32), plum); // Curved 5.45 Bakelite 30-rd magazine push_curved_mag(v, idx, Vec3::new(0.0, -0.018, 0.112), 3, 0.062, 0.11, (0.013, 0.031), plum); // Polymer lower & upper handguard push_aabb(v, idx, Vec3::new(-0.018, -0.014, 0.185), Vec3::new(0.018, 0.019, 0.365), metal); push_aabb(v, idx, Vec3::new(-0.014, 0.020, 0.195), Vec3::new(0.014, 0.044, 0.355), plum); // Gas tube + 90 deg gas block + barrel + two-chamber AK-74 muzzle brake push_z_cylinder(v, idx, Vec2::new(0.0, 0.034), 0.16, 0.455, 0.010, 0.010, 6, metal, true, true); push_aabb(v, idx, Vec3::new(-0.010, 0.010, 0.438), Vec3::new(0.010, 0.044, 0.464), metal); push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.18, 0.635, 0.0105, 0.009, 8, metal, false, false); push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.635, 0.715, 0.0135, 0.0135, 8, metal, true, true); push_ak_iron_sights(v, idx, 0.168, 0.612, 0.088, metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // 2. AKM (7.62x39) — Laminated Wood Stock & Handguard, Steeper Mag, Slant Brake // ============================================================================ pub fn push_weapon_akm(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let wood = MaterialId::WoodFurniture; let bake = MaterialId::BakelitePlum; // Classic angled laminated wood stock + steel buttplate push_xform_box(v, idx, Vec3::new(0.015, 0.040, 0.115), Mat4::from_translation(Vec3::new(0.0, -0.012, -0.168)) * Mat4::from_rotation_x(-0.14), wood); push_aabb(v, idx, Vec3::new(-0.016, -0.068, -0.288), Vec3::new(0.016, 0.028, -0.276), metal); // Receiver + ribbed dust cover + trigger guard push_aabb(v, idx, Vec3::new(-0.020, -0.018, -0.055), Vec3::new(0.020, 0.032, 0.185), metal); push_aabb(v, idx, Vec3::new(-0.017, 0.032, -0.052), Vec3::new(0.017, 0.055, 0.155), metal); push_aabb(v, idx, Vec3::new(-0.006, -0.042, 0.02), Vec3::new(0.006, -0.018, 0.075), metal); // Bakelite grip push_xform_box(v, idx, Vec3::new(0.013, 0.050, 0.017), Mat4::from_translation(Vec3::new(0.0, -0.056, -0.022)) * Mat4::from_rotation_x(0.32), bake); // Ribbed steel 7.62x39 banana magazine (deeper curve) push_curved_mag(v, idx, Vec3::new(0.0, -0.018, 0.112), 3, 0.066, 0.17, (0.014, 0.033), metal); // Grooved wood handguard + gas tube + 45 deg gas block + slant muzzle brake push_aabb(v, idx, Vec3::new(-0.019, -0.015, 0.185), Vec3::new(0.019, 0.020, 0.365), wood); push_aabb(v, idx, Vec3::new(-0.015, 0.021, 0.195), Vec3::new(0.015, 0.045, 0.355), wood); push_z_cylinder(v, idx, Vec2::new(0.0, 0.034), 0.16, 0.455, 0.010, 0.010, 6, metal, true, true); push_xform_box(v, idx, Vec3::new(0.010, 0.018, 0.013), Mat4::from_translation(Vec3::new(0.0, 0.026, 0.445)) * Mat4::from_rotation_x(-0.35), metal); push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.18, 0.675, 0.0105, 0.0095, 8, metal, false, false); push_xform_box(v, idx, Vec3::new(0.011, 0.011, 0.018), Mat4::from_translation(Vec3::new(0.0, 0.017, 0.69)) * Mat4::from_rotation_x(0.25), metal); push_ak_iron_sights(v, idx, 0.168, 0.620, 0.088, metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // 3. AKS-74U ("Krinkov") — Triangle Folder, Short Wood Handguard, Conical Booster // ============================================================================ pub fn push_weapon_aks74u(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let wood = MaterialId::WoodFurniture; let bake = MaterialId::BakelitePlum; // Open triangular folding steel skeleton stock push_xform_box(v, idx, Vec3::new(0.007, 0.009, 0.112), Mat4::from_translation(Vec3::new(-0.010, 0.020, -0.16)) * Mat4::from_rotation_x(0.06), metal); push_xform_box(v, idx, Vec3::new(0.007, 0.009, 0.112), Mat4::from_translation(Vec3::new(0.010, 0.020, -0.16)) * Mat4::from_rotation_x(0.06), metal); push_xform_box(v, idx, Vec3::new(0.009, 0.009, 0.116), Mat4::from_translation(Vec3::new(0.0, -0.026, -0.162)) * Mat4::from_rotation_x(-0.24), metal); push_aabb(v, idx, Vec3::new(-0.015, -0.062, -0.278), Vec3::new(0.015, 0.030, -0.258), metal); // Compact receiver + top cover + rear flip sight push_aabb(v, idx, Vec3::new(-0.020, -0.018, -0.052), Vec3::new(0.020, 0.032, 0.165), metal); push_aabb(v, idx, Vec3::new(-0.017, 0.032, -0.050), Vec3::new(0.017, 0.054, 0.155), metal); // Bakelite grip & curved mag push_xform_box(v, idx, Vec3::new(0.013, 0.048, 0.016), Mat4::from_translation(Vec3::new(0.0, -0.054, -0.020)) * Mat4::from_rotation_x(0.32), bake); push_curved_mag(v, idx, Vec3::new(0.0, -0.018, 0.102), 3, 0.060, 0.11, (0.013, 0.030), bake); // Stubby wooden handguard + short gas tube + conical Krinkov flash booster push_aabb(v, idx, Vec3::new(-0.018, -0.014, 0.165), Vec3::new(0.018, 0.019, 0.295), wood); push_aabb(v, idx, Vec3::new(-0.014, 0.020, 0.172), Vec3::new(0.014, 0.043, 0.290), wood); push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.165, 0.405, 0.010, 0.0095, 8, metal, false, false); // Iconic cylindrical expansion chamber + flared cone muzzle booster push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.405, 0.455, 0.014, 0.014, 8, metal, true, false); push_z_cylinder(v, idx, Vec2::new(0.0, 0.016), 0.455, 0.495, 0.013, 0.019, 8, metal, false, true); push_ak_iron_sights(v, idx, 0.040, 0.390, 0.085, metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // 4. PKM (7.62x54mmR) — Heavy Feed Cover, Skeleton Wood Stock, 100-rd Belt Box & Bipod // ============================================================================ pub fn push_weapon_pkm(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let steel = MaterialId::SteelHulk; let wood = MaterialId::WoodFurniture; let brass = MaterialId::Sandbag; // Skeletonized wood buttstock push_aabb(v, idx, Vec3::new(-0.017, 0.004, -0.29), Vec3::new(0.017, 0.032, -0.06), wood); push_xform_box(v, idx, Vec3::new(0.016, 0.014, 0.11), Mat4::from_translation(Vec3::new(0.0, -0.045, -0.175)) * Mat4::from_rotation_x(-0.18), wood); push_aabb(v, idx, Vec3::new(-0.018, -0.072, -0.305), Vec3::new(0.018, 0.034, -0.265), wood); // Heavy rectangular receiver + hinged ribbed feed tray cover push_aabb(v, idx, Vec3::new(-0.028, -0.028, -0.06), Vec3::new(0.028, 0.040, 0.275), metal); push_aabb(v, idx, Vec3::new(-0.024, 0.040, -0.045), Vec3::new(0.024, 0.068, 0.245), metal); // Pistol grip + angled carry handle push_xform_box(v, idx, Vec3::new(0.014, 0.052, 0.018), Mat4::from_translation(Vec3::new(0.0, -0.062, -0.025)) * Mat4::from_rotation_x(0.28), metal); push_xform_box(v, idx, Vec3::new(0.008, 0.008, 0.055), Mat4::from_translation(Vec3::new(0.028, 0.060, 0.30)) * Mat4::from_rotation_z(-0.5), wood); // Suspended 100-rd olive steel ammo box + visible brass belt strip push_aabb(v, idx, Vec3::new(-0.056, -0.165, 0.045), Vec3::new(0.046, -0.030, 0.205), steel); push_aabb(v, idx, Vec3::new(0.026, -0.035, 0.11), Vec3::new(0.044, 0.032, 0.175), brass); // Heavy fluted barrel + under-barrel gas cylinder + slotted flash hider push_z_cylinder(v, idx, Vec2::new(0.0, 0.020), 0.27, 0.79, 0.014, 0.012, 8, metal, false, false); push_z_cylinder(v, idx, Vec2::new(0.0, -0.008), 0.24, 0.56, 0.011, 0.011, 6, metal, true, true); push_z_cylinder(v, idx, Vec2::new(0.0, 0.020), 0.79, 0.885, 0.0155, 0.0155, 8, metal, true, true); // Folded twin bipod legs tucked along gas block push_aabb(v, idx, Vec3::new(-0.026, -0.032, 0.32), Vec3::new(-0.014, -0.014, 0.56), metal); push_aabb(v, idx, Vec3::new(0.014, -0.032, 0.32), Vec3::new(0.026, -0.014, 0.56), metal); push_ak_iron_sights(v, idx, -0.015, 0.755, 0.106, metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // 5. SVD Dragunov (7.62x54mmR) — Thumbhole Stock, Slender Barrel & PSO-1 4x Scope // ============================================================================ pub fn push_weapon_svd(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let scope = MaterialId::SteelHulk; let wood = MaterialId::WoodFurniture; // Iconic skeletonized SVD thumbhole wood stock + padded cheekpiece push_aabb(v, idx, Vec3::new(-0.015, 0.010, -0.325), Vec3::new(0.015, 0.036, -0.045), wood); push_aabb(v, idx, Vec3::new(-0.016, 0.036, -0.25), Vec3::new(0.016, 0.056, -0.115), metal); push_xform_box(v, idx, Vec3::new(0.015, 0.014, 0.115), Mat4::from_translation(Vec3::new(0.0, -0.046, -0.205)) * Mat4::from_rotation_x(-0.18), wood); push_xform_box(v, idx, Vec3::new(0.014, 0.046, 0.018), Mat4::from_translation(Vec3::new(0.0, -0.034, -0.068)) * Mat4::from_rotation_x(0.26), wood); push_aabb(v, idx, Vec3::new(-0.017, -0.072, -0.338), Vec3::new(0.017, 0.038, -0.312), wood); // Long milled receiver + top cover + straight 10-rd magazine push_aabb(v, idx, Vec3::new(-0.018, -0.018, -0.055), Vec3::new(0.018, 0.032, 0.225), metal); push_aabb(v, idx, Vec3::new(-0.015, 0.032, -0.045), Vec3::new(0.015, 0.052, 0.195), metal); push_xform_box(v, idx, Vec3::new(0.012, 0.056, 0.036), Mat4::from_translation(Vec3::new(0.0, -0.068, 0.125)) * Mat4::from_rotation_x(-0.10), metal); // Long ventilated wooden handguard + slender barrel + long slotted flash hider push_aabb(v, idx, Vec3::new(-0.017, -0.010, 0.225), Vec3::new(0.017, 0.034, 0.505), wood); push_z_cylinder(v, idx, Vec2::new(0.0, 0.018), 0.22, 0.87, 0.010, 0.009, 8, metal, false, false); push_z_cylinder(v, idx, Vec2::new(0.0, 0.018), 0.87, 0.955, 0.013, 0.013, 8, metal, true, true); push_ak_iron_sights(v, idx, 0.215, 0.855, 0.082, metal); // Side-mounted PSO-1 4x24 Telescopic Optic (centered on optical axis y=0.122, rigidly clamped to receiver) // Solid L-shaped dovetail side bracket & dual scope rings push_aabb(v, idx, Vec3::new(0.015, 0.012, 0.040), Vec3::new(0.025, 0.118, 0.125), metal); push_aabb(v, idx, Vec3::new(-0.016, 0.098, 0.044), Vec3::new(0.025, 0.124, 0.068), metal); push_aabb(v, idx, Vec3::new(-0.016, 0.098, 0.102), Vec3::new(0.025, 0.124, 0.124), metal); // Main PSO-1 tube + objective bell + dark rubber eyecup + elevation/windage turrets push_z_cylinder(v, idx, Vec2::new(0.0, 0.122), -0.025, 0.175, 0.015, 0.015, 8, scope, true, false); push_z_cylinder(v, idx, Vec2::new(0.0, 0.122), 0.175, 0.255, 0.015, 0.022, 8, scope, false, true); push_z_cylinder(v, idx, Vec2::new(0.0, 0.122), -0.075, -0.025, 0.019, 0.015, 8, metal, true, false); push_aabb(v, idx, Vec3::new(-0.007, 0.136, 0.068), Vec3::new(0.007, 0.149, 0.088), metal); push_aabb(v, idx, Vec3::new(-0.024, 0.114, 0.068), Vec3::new(-0.014, 0.130, 0.088), metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // 6. RPG-7V — Flared Venturi Tube, Wood Heat Shields & Separable PG-7V Warhead // ============================================================================ pub fn push_weapon_rpg_tube(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let metal = MaterialId::Gunmetal; let steel = MaterialId::SteelHulk; let wood = MaterialId::WoodFurniture; // Rear Venturi cone -> narrow waist -> main steel tube -> flared front collar push_z_cylinder(v, idx, Vec2::ZERO, -0.58, -0.44, 0.044, 0.026, 8, metal, true, false); push_z_cylinder(v, idx, Vec2::ZERO, -0.44, -0.28, 0.026, 0.028, 8, steel, false, false); push_z_cylinder(v, idx, Vec2::ZERO, -0.28, 0.42, 0.028, 0.028, 8, steel, false, false); push_z_cylinder(v, idx, Vec2::ZERO, 0.42, 0.47, 0.032, 0.035, 8, metal, true, true); // Mid-tube laminated wood heat-shield staves push_z_cylinder(v, idx, Vec2::ZERO, -0.20, 0.08, 0.033, 0.033, 8, wood, true, true); // Front pistol grip/trigger housing + rear steadying grip push_xform_box(v, idx, Vec3::new(0.014, 0.056, 0.018), Mat4::from_translation(Vec3::new(0.0, -0.072, 0.175)) * Mat4::from_rotation_x(0.18), wood); push_xform_box(v, idx, Vec3::new(0.013, 0.048, 0.016), Mat4::from_translation(Vec3::new(0.0, -0.064, -0.06)) * Mat4::from_rotation_x(0.12), metal); push_aabb(v, idx, Vec3::new(-0.008, -0.056, 0.115), Vec3::new(0.008, -0.026, 0.205), metal); // Open-frame folding iron ladder sight (rear notch + open front protective frame & post) push_aabb(v, idx, Vec3::new(-0.009, 0.026, 0.138), Vec3::new(-0.004, 0.114, 0.148), metal); push_aabb(v, idx, Vec3::new(0.004, 0.026, 0.138), Vec3::new(0.009, 0.114, 0.148), metal); push_aabb(v, idx, Vec3::new(-0.009, 0.026, 0.138), Vec3::new(0.009, 0.098, 0.148), metal); push_aabb(v, idx, Vec3::new(-0.009, 0.026, 0.428), Vec3::new(-0.006, 0.115, 0.438), metal); push_aabb(v, idx, Vec3::new(0.006, 0.026, 0.428), Vec3::new(0.009, 0.115, 0.438), metal); push_aabb(v, idx, Vec3::new(-0.009, 0.026, 0.428), Vec3::new(0.009, 0.058, 0.438), metal); push_aabb(v, idx, Vec3::new(-0.0015, 0.058, 0.430), Vec3::new(0.0015, 0.112, 0.436), metal); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } pub fn push_weapon_rpg_warhead(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let warhead = MaterialId::SteelHulk; let fuze = MaterialId::Gunmetal; // Rocket motor stem protruding from muzzle -> expanding cone -> main HEAT warhead -> tapered nose + piezo probe push_z_cylinder(v, idx, Vec2::ZERO, 0.44, 0.54, 0.021, 0.022, 8, fuze, true, false); push_z_cylinder(v, idx, Vec2::ZERO, 0.54, 0.62, 0.022, 0.048, 8, warhead, false, false); push_z_cylinder(v, idx, Vec2::ZERO, 0.62, 0.68, 0.048, 0.048, 8, warhead, false, false); push_z_cylinder(v, idx, Vec2::ZERO, 0.68, 0.77, 0.048, 0.015, 8, warhead, false, false); push_z_cylinder(v, idx, Vec2::ZERO, 0.77, 0.85, 0.015, 0.008, 6, fuze, false, true); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } // ============================================================================ // First-Person Viewmodel Helper Meshes (Camo Sleeves, Gloved Hands, Flash Star) // ============================================================================ /// Builds two camo-sleeved forearms reaching toward pistol grip & handguard in weapon-local space. pub fn push_vm_sleeve_arms(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let m = MaterialId::FloraCamo; // Right forearm: rear-right hip up to pistol grip push_xform_box( v, idx, Vec3::new(0.036, 0.034, 0.145), Mat4::from_translation(Vec3::new(-0.075, -0.115, -0.135)) * Mat4::from_rotation_y(0.42) * Mat4::from_rotation_x(0.36), m, ); // Left support forearm: tucked smoothly under the front handguard push_xform_box( v, idx, Vec3::new(0.036, 0.034, 0.165), Mat4::from_translation(Vec3::new(0.105, -0.115, 0.085)) * Mat4::from_rotation_y(-0.58) * Mat4::from_rotation_x(0.30), m, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } /// Builds dark leather/wool gloved hands cradling the pistol grip & lower handguard. pub fn push_vm_gloves(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let g = MaterialId::Gunmetal; push_xform_box( v, idx, Vec3::new(0.018, 0.026, 0.026), Mat4::from_translation(Vec3::new(0.0, -0.052, -0.020)) * Mat4::from_rotation_x(0.28), g, ); push_xform_box( v, idx, Vec3::new(0.021, 0.018, 0.036), Mat4::from_translation(Vec3::new(0.004, -0.026, 0.250)) * Mat4::from_rotation_y(-0.12), g, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } /// Builds a compact 3D starburst flash mesh centered at origin (rendered near weapon muzzle). pub fn push_vm_muzzle_flash(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; let m = MaterialId::Sandbag; push_xform_box(v, idx, Vec3::new(0.095, 0.014, 0.045), Mat4::IDENTITY, m); push_xform_box(v, idx, Vec3::new(0.014, 0.095, 0.045), Mat4::IDENTITY, m); push_xform_box(v, idx, Vec3::new(0.065, 0.014, 0.055), Mat4::from_rotation_z(0.785), m); push_xform_box(v, idx, Vec3::new(0.014, 0.065, 0.055), Mat4::from_rotation_z(0.785), m); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off } } } #[cfg(feature = "cold_water_assets")] pub use cold_water_weapon_meshes::*; #[cfg(not(feature = "cold_water_assets"))] mod engine_weapon_fallbacks { use glam::Vec3; use crate::core::materials::MaterialId; use crate::world::actors_mesh::MeshSlice; use crate::world::ActorVertex; fn push_neutral_box( vertices: &mut Vec, indices: &mut Vec, min: Vec3, max: Vec3, mat: MaterialId, ) { let c = [ Vec3::new(min.x, min.y, max.z), Vec3::new(max.x, min.y, max.z), Vec3::new(max.x, max.y, max.z), Vec3::new(min.x, max.y, max.z), Vec3::new(min.x, min.y, min.z), Vec3::new(max.x, min.y, min.z), Vec3::new(max.x, max.y, min.z), Vec3::new(min.x, max.y, min.z), ]; let faces = [ ([0, 1, 2, 3], Vec3::Z), ([5, 4, 7, 6], -Vec3::Z), ([1, 5, 6, 2], Vec3::X), ([4, 0, 3, 7], -Vec3::X), ([3, 2, 6, 7], Vec3::Y), ([4, 5, 1, 0], -Vec3::Y), ]; let uvs = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]]; let mat_id = mat.gpu_layer(); for (f, n) in faces { let base = vertices.len() as u32; let wn = n.to_array(); for k in 0..4 { vertices.push(ActorVertex { position: c[f[k]].to_array(), normal: wn, uv: uvs[k], mat_id, }); } indices.extend_from_slice(&[base, base + 1, base + 2, base, base + 2, base + 3]); } } fn push_generic_rifle( v: &mut Vec, idx: &mut Vec, barrel_len: f32, heavy: bool, ) -> MeshSlice { let off = idx.len() as u32; let steel = MaterialId::SteelHulk; let body = MaterialId::Concrete; // Neutral receiver block push_neutral_box( v, idx, Vec3::new(-0.022, -0.020, -0.08), Vec3::new(0.022, 0.042, 0.20), steel, ); // Neutral stock push_neutral_box( v, idx, Vec3::new(-0.016, -0.045, -0.28), Vec3::new(0.016, 0.032, -0.08), body, ); // Neutral grip + magazine prism push_neutral_box( v, idx, Vec3::new(-0.014, -0.095, -0.03), Vec3::new(0.014, -0.018, 0.02), body, ); push_neutral_box( v, idx, Vec3::new(-0.015, -0.145, 0.05), Vec3::new(0.015, -0.015, 0.12), steel, ); // Neutral barrel + simple iron post let br = if heavy { 0.016 } else { 0.011 }; push_neutral_box( v, idx, Vec3::new(-br, 0.008, 0.20), Vec3::new(br, 0.008 + br * 2.0, 0.20 + barrel_len), steel, ); push_neutral_box( v, idx, Vec3::new(-0.002, 0.042, 0.18 + barrel_len), Vec3::new(0.002, 0.088, 0.19 + barrel_len), steel, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } pub fn push_weapon_ak74m(v: &mut Vec, idx: &mut Vec) -> MeshSlice { push_generic_rifle(v, idx, 0.48, false) } pub fn push_weapon_akm(v: &mut Vec, idx: &mut Vec) -> MeshSlice { push_generic_rifle(v, idx, 0.46, false) } pub fn push_weapon_aks74u(v: &mut Vec, idx: &mut Vec) -> MeshSlice { push_generic_rifle(v, idx, 0.30, false) } pub fn push_weapon_pkm(v: &mut Vec, idx: &mut Vec) -> MeshSlice { push_generic_rifle(v, idx, 0.62, true) } pub fn push_weapon_svd(v: &mut Vec, idx: &mut Vec) -> MeshSlice { push_generic_rifle(v, idx, 0.68, false) } pub fn push_weapon_rpg_tube(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; push_neutral_box( v, idx, Vec3::new(-0.032, -0.032, -0.45), Vec3::new(0.032, 0.032, 0.48), MaterialId::SteelHulk, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } pub fn push_weapon_rpg_warhead(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; push_neutral_box( v, idx, Vec3::new(-0.042, -0.042, 0.48), Vec3::new(0.042, 0.042, 0.80), MaterialId::Concrete, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } pub fn push_vm_sleeve_arms(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; push_neutral_box( v, idx, Vec3::new(-0.11, -0.15, -0.26), Vec3::new(-0.04, -0.07, 0.0), MaterialId::Concrete, ); push_neutral_box( v, idx, Vec3::new(0.06, -0.15, -0.06), Vec3::new(0.13, -0.07, 0.24), MaterialId::Concrete, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } pub fn push_vm_gloves(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; push_neutral_box( v, idx, Vec3::new(-0.02, -0.08, -0.04), Vec3::new(0.02, -0.02, 0.01), MaterialId::SteelHulk, ); push_neutral_box( v, idx, Vec3::new(-0.02, -0.05, 0.20), Vec3::new(0.02, -0.01, 0.28), MaterialId::SteelHulk, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } pub fn push_vm_muzzle_flash(v: &mut Vec, idx: &mut Vec) -> MeshSlice { let off = idx.len() as u32; push_neutral_box( v, idx, Vec3::new(-0.07, -0.07, -0.03), Vec3::new(0.07, 0.07, 0.03), MaterialId::Sandbag, ); MeshSlice { index_offset: off, index_count: idx.len() as u32 - off, } } } #[cfg(not(feature = "cold_water_assets"))] pub use engine_weapon_fallbacks::*;