Compare commits

...

9 Commits

@ -209,52 +209,204 @@ pub fn convert<'a>(
color:glam::Vec4::W,
});
// THE CUBE OF DESTINY
let destination_mesh_id=model::MeshId::new(world_meshes.len() as u32);
world_meshes.push(crate::brush::unit_cube());
const WHITE:vbsp::Color=vbsp::Color{r:255,g:255,b:255};
const ENTITY_ATTRIBUTE:attr::CollisionAttributesId=ATTRIBUTE_DECORATION;
const ENTITY_TRIGGER_ATTRIBUTE:attr::CollisionAttributesId=ATTRIBUTE_INTERSECT_DEFAULT;
for raw_ent in &bsp.entities{
macro_rules! ent_brush_default{
($entity:ident)=>{
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,$entity.rendercolor,ENTITY_ATTRIBUTE)
};
} macro_rules! ent_brush_prop{
($entity:ident)=>{
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,WHITE,ENTITY_ATTRIBUTE)
};
}
macro_rules! ent_brush_trigger{
($entity:ident)=>{
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE)
};
}
match raw_ent.parse(){
Ok(Entity::Cycler(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::EnvSprite(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncBreakable(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncBrush(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncButton(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncDoor(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncDoorRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::AmbientGeneric(_ambient_generic))=>(),
Ok(Entity::Cycler(brush))=>ent_brush_default!(brush),
Ok(Entity::EnvBeam(_env_beam))=>(),
Ok(Entity::EnvBubbles(_env_bubbles))=>(),
Ok(Entity::EnvDetailController(_env_detail_controller))=>(),
Ok(Entity::EnvEmbers(_env_embers))=>(),
Ok(Entity::EnvEntityMaker(_env_entity_maker))=>(),
Ok(Entity::EnvExplosion(_env_explosion))=>(),
Ok(Entity::EnvFade(_env_fade))=>(),
Ok(Entity::EnvFire(_env_fire))=>(),
Ok(Entity::EnvFireTrail(_env_fire_trail))=>(),
Ok(Entity::EnvFiresource(_env_firesource))=>(),
Ok(Entity::EnvFogController(_env_fog_controller))=>(),
Ok(Entity::EnvHudhint(_env_hudhint))=>(),
Ok(Entity::EnvLaser(_env_laser))=>(),
Ok(Entity::EnvLightglow(_env_lightglow))=>(),
Ok(Entity::EnvPhysexplosion(_env_physexplosion))=>(),
Ok(Entity::EnvProjectedtexture(_env_projectedtexture))=>(),
Ok(Entity::EnvScreenoverlay(_env_screenoverlay))=>(),
Ok(Entity::EnvShake(_env_shake))=>(),
Ok(Entity::EnvShooter(_env_shooter))=>(),
Ok(Entity::EnvSmokestack(_env_smokestack))=>(),
Ok(Entity::EnvSoundscape(_env_soundscape))=>(),
Ok(Entity::EnvSoundscapeProxy(_env_soundscape_proxy))=>(),
Ok(Entity::EnvSoundscapeTriggerable(_env_soundscape_triggerable))=>(),
Ok(Entity::EnvSpark(_env_spark))=>(),
Ok(Entity::EnvSprite(brush))=>ent_brush_default!(brush),
Ok(Entity::EnvSpritetrail(_env_spritetrail))=>(),
Ok(Entity::EnvSteam(_env_steam))=>(),
Ok(Entity::EnvSun(_env_sun))=>(),
Ok(Entity::EnvTonemapController(_env_tonemap_controller))=>(),
Ok(Entity::EnvWind(_env_wind))=>(),
// trigger_teleport.filtername probably has to do with one of these
Ok(Entity::FilterActivatorClass(_filter_activator_class))=>(),
Ok(Entity::FilterActivatorName(_filter_activator_name))=>(),
Ok(Entity::FilterDamageType(_filter_damage_type))=>(),
Ok(Entity::FilterMulti(_filter_multi))=>(),
Ok(Entity::FuncAreaportal(_func_areaportal))=>(),
Ok(Entity::FuncAreaportalwindow(_func_areaportalwindow))=>(),
Ok(Entity::FuncBombTarget(_func_bomb_target))=>(),
Ok(Entity::FuncBreakable(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncBreakableSurf(_func_breakable_surf))=>(),
Ok(Entity::FuncBrush(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncButton(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncBuyzone(_func_buyzone))=>(),
Ok(Entity::FuncClipVphysics(_func_clip_vphysics))=>(),
Ok(Entity::FuncConveyor(_func_conveyor))=>(),
// FuncDoor is Platform
Ok(Entity::FuncDoor(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncDoorRotating(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncDustcloud(_func_dustcloud))=>(),
Ok(Entity::FuncDustmotes(_func_dustmotes))=>(),
Ok(Entity::FuncFishPool(_func_fish_pool))=>(),
Ok(Entity::FuncFootstepControl(_func_footstep_control))=>(),
Ok(Entity::FuncHostageRescue(_func_hostage_rescue))=>(),
Ok(Entity::FuncIllusionary(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncMonitor(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncMovelinear(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncPhysbox(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncPhysboxMultiplayer(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncRotButton(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::FuncRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncTracktrain(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncTrain(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncWall(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncWallToggle(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ATTRIBUTE_DECORATION),
Ok(Entity::FuncWaterAnalog(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor.unwrap_or(WHITE),ATTRIBUTE_DECORATION),
Ok(Entity::PropDoorRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropDynamic(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropDynamicOverride(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropPhysics(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropPhysicsMultiplayer(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropPhysicsOverride(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::PropRagdoll(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerGravity(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerHurt(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerLook(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerMultiple(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerOnce(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerProximity(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerPush(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerSoundscape(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerTeleport(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerVphysicsMotion(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::TriggerWind(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
Ok(Entity::InfoPlayerCounterterrorist(spawn))=>{
found_spawn=Some(valve_transform(spawn.origin.into()));
},
Ok(Entity::InfoPlayerTerrorist(spawn))=>{
found_spawn=Some(valve_transform(spawn.origin.into()));
},
Ok(Entity::FuncLod(_func_lod))=>(),
Ok(Entity::FuncMonitor(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncMovelinear(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncOccluder(_func_occluder))=>(),
Ok(Entity::FuncPhysbox(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncPhysboxMultiplayer(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncPrecipitation(_func_precipitation))=>(),
Ok(Entity::FuncRotButton(brush))=>ent_brush_prop!(brush),
Ok(Entity::FuncRotating(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncSmokevolume(_func_smokevolume))=>(),
Ok(Entity::FuncTracktrain(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncTrain(brush))=>ent_brush_default!(brush),
Ok(Entity::FuncWall(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ENTITY_ATTRIBUTE),
Ok(Entity::FuncWallToggle(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ENTITY_ATTRIBUTE),
Ok(Entity::FuncWaterAnalog(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor.unwrap_or(WHITE),ENTITY_ATTRIBUTE),
Ok(Entity::GamePlayerEquip(_game_player_equip))=>(),
Ok(Entity::GameText(_game_text))=>(),
Ok(Entity::GameUi(_game_ui))=>(),
Ok(Entity::GameWeaponManager(_game_weapon_manager))=>(),
Ok(Entity::HostageEntity(_hostage_entity))=>(),
Ok(Entity::InfoCameraLink(_info_camera_link))=>(),
Ok(Entity::InfoLadder(_info_ladder))=>(),
Ok(Entity::InfoLightingRelative(_info_lighting_relative))=>(),
Ok(Entity::InfoMapParameters(_info_map_parameters))=>(),
Ok(Entity::InfoNode(_info_node))=>(),
Ok(Entity::InfoNodeHint(_info_node_hint))=>(),
Ok(Entity::InfoParticleSystem(_info_particle_system))=>(),
Ok(Entity::InfoPlayerCounterterrorist(spawn))=>found_spawn=Some(spawn.origin),
Ok(Entity::InfoPlayerLogo(_info_player_logo))=>(),
Ok(Entity::InfoPlayerStart(_info_player_start))=>(),
Ok(Entity::InfoPlayerTerrorist(spawn))=>found_spawn=Some(spawn.origin),
Ok(Entity::InfoTarget(_info_target))=>(),
// InfoTeleportDestination is Spawn#
Ok(Entity::InfoTeleportDestination(_info_teleport_destination))=>(),
Ok(Entity::Infodecal(_infodecal))=>(),
Ok(Entity::KeyframeRope(_keyframe_rope))=>(),
Ok(Entity::Light(_light))=>(),
Ok(Entity::LightEnvironment(_light_environment))=>(),
Ok(Entity::LightSpot(_light_spot))=>(),
Ok(Entity::LogicAuto(_logic_auto))=>(),
Ok(Entity::LogicBranch(_logic_branch))=>(),
Ok(Entity::LogicCase(_logic_case))=>(),
Ok(Entity::LogicCompare(_logic_compare))=>(),
Ok(Entity::LogicMeasureMovement(_logic_measure_movement))=>(),
Ok(Entity::LogicRelay(_logic_relay))=>(),
Ok(Entity::LogicTimer(_logic_timer))=>(),
Ok(Entity::MathCounter(_math_counter))=>(),
Ok(Entity::MoveRope(_move_rope))=>(),
Ok(Entity::PathTrack(_path_track))=>(),
Ok(Entity::PhysBallsocket(_phys_ballsocket))=>(),
Ok(Entity::PhysConstraint(_phys_constraint))=>(),
Ok(Entity::PhysConstraintsystem(_phys_constraintsystem))=>(),
Ok(Entity::PhysHinge(_phys_hinge))=>(),
Ok(Entity::PhysKeepupright(_phys_keepupright))=>(),
Ok(Entity::PhysLengthconstraint(_phys_lengthconstraint))=>(),
Ok(Entity::PhysPulleyconstraint(_phys_pulleyconstraint))=>(),
Ok(Entity::PhysRagdollconstraint(_phys_ragdollconstraint))=>(),
Ok(Entity::PhysRagdollmagnet(_phys_ragdollmagnet))=>(),
Ok(Entity::PhysThruster(_phys_thruster))=>(),
Ok(Entity::PhysTorque(_phys_torque))=>(),
Ok(Entity::PlayerSpeedmod(_player_speedmod))=>(),
Ok(Entity::PlayerWeaponstrip(_player_weaponstrip))=>(),
Ok(Entity::PointCamera(_point_camera))=>(),
Ok(Entity::PointClientcommand(_point_clientcommand))=>(),
Ok(Entity::PointDevshotCamera(_point_devshot_camera))=>(),
Ok(Entity::PointServercommand(_point_servercommand))=>(),
Ok(Entity::PointSpotlight(_point_spotlight))=>(),
Ok(Entity::PointSurroundtest(_point_surroundtest))=>(),
Ok(Entity::PointTemplate(_point_template))=>(),
Ok(Entity::PointTesla(_point_tesla))=>(),
Ok(Entity::PointViewcontrol(_point_viewcontrol))=>(),
Ok(Entity::PropDoorRotating(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropDynamic(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropDynamicOverride(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropPhysics(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropPhysicsMultiplayer(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropPhysicsOverride(brush))=>ent_brush_prop!(brush),
Ok(Entity::PropRagdoll(brush))=>ent_brush_prop!(brush),
Ok(Entity::ShadowControl(_shadow_control))=>(),
Ok(Entity::SkyCamera(_sky_camera))=>(),
Ok(Entity::TriggerGravity(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerHurt(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerLook(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerMultiple(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE),
Ok(Entity::TriggerOnce(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerProximity(brush))=>ent_brush_trigger!(brush),
// TriggerPush is booster
Ok(Entity::TriggerPush(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerSoundscape(brush))=>ent_brush_trigger!(brush),
// TriggerTeleport is Trigger#
Ok(Entity::TriggerTeleport(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE),
Ok(Entity::TriggerVphysicsMotion(brush))=>ent_brush_trigger!(brush),
Ok(Entity::TriggerWind(brush))=>ent_brush_trigger!(brush),
Ok(Entity::WaterLodControl(_water_lod_control))=>(),
Ok(Entity::WeaponAk47(_weapon_ak47))=>(),
Ok(Entity::WeaponAwp(_weapon_awp))=>(),
Ok(Entity::WeaponDeagle(_weapon_deagle))=>(),
Ok(Entity::WeaponElite(_weapon_elite))=>(),
Ok(Entity::WeaponFamas(_weapon_famas))=>(),
Ok(Entity::WeaponFiveseven(_weapon_fiveseven))=>(),
Ok(Entity::WeaponFlashbang(_weapon_flashbang))=>(),
Ok(Entity::WeaponG3sg1(_weapon_g3sg1))=>(),
Ok(Entity::WeaponGlock(_weapon_glock))=>(),
Ok(Entity::WeaponHegrenade(_weapon_hegrenade))=>(),
Ok(Entity::WeaponKnife(_weapon_knife))=>(),
Ok(Entity::WeaponM249(_weapon_m249))=>(),
Ok(Entity::WeaponM3(_weapon_m3))=>(),
Ok(Entity::WeaponM4a1(_weapon_m4a1))=>(),
Ok(Entity::WeaponMac10(_weapon_mac10))=>(),
Ok(Entity::WeaponP228(_weapon_p228))=>(),
Ok(Entity::WeaponP90(_weapon_p90))=>(),
Ok(Entity::WeaponScout(_weapon_scout))=>(),
Ok(Entity::WeaponSg550(_weapon_sg550))=>(),
Ok(Entity::WeaponSmokegrenade(_weapon_smokegrenade))=>(),
Ok(Entity::WeaponTmp(_weapon_tmp))=>(),
Ok(Entity::WeaponUmp45(_weapon_ump45))=>(),
Ok(Entity::WeaponUsp(_weapon_usp))=>(),
Ok(Entity::WeaponXm1014(_weapon_xm1014))=>(),
Ok(Entity::Worldspawn(_worldspawn))=>(),
Err(e)=>{
println!("Bsp Entity parse error: {e}");
},
@ -306,15 +458,12 @@ pub fn convert<'a>(
let mut modes_list=Vec::new();
if let Some(spawn_point)=found_spawn{
// create a new mesh
let mesh_id=model::MeshId::new(world_meshes.len() as u32);
world_meshes.push(crate::brush::unit_cube());
// create a new model
let model_id=model::ModelId::new(world_models.len() as u32);
world_models.push(model::Model{
mesh:mesh_id,
mesh:destination_mesh_id,
attributes:ATTRIBUTE_INTERSECT_DEFAULT,
transform:integer::Planar64Affine3::from_translation(spawn_point),
transform:integer::Planar64Affine3::from_translation(valve_transform(spawn_point.into())),
color:glam::Vec4::W,
});