laserspace/src/trap/tracks.rs
2025-04-08 11:39:23 +02:00

92 lines
No EOL
2 KiB
Rust

use bevy::prelude::*;
use serde::{Serialize,Deserialize};
#[derive(Serialize,Deserialize)]
pub struct Frame {
pub tracks: std::collections::HashMap<String, Track>
}
#[derive(Serialize, Deserialize, Component, Debug)]
pub struct Detection{
track_id: u64,
l: f32,
t: f32,
w: f32,
h: f32,
conf: f32,
state: u8,
frame_nr: u64,
det_class: u8,
}
impl Detection {
fn to_point(&self) -> Vec2 {
let x = self.l + self.w/2.;
let y = self.t + self.h;
Vec2::new(x, y)
}
}
#[derive(Serialize, Deserialize, Component, Debug)]
pub struct Track {
pub track_id: u64,
// nr: u32,
pub history: Vec<Vec2>, // projected foot coordintes //Vec<Detection>, // history
pub predictor_history: Option<Vec<Vec2>>, // history
pub predictions: Option<Vec<Vec<Vec2>>>,
}
// check: https://www.reddit.com/r/bevy/comments/y1km8n/how_to_link_components_in_bevy_or_am_i_too_oop/
#[derive(Serialize, Deserialize, Component)]
pub struct PredictedTrajectory{
person: Entity,
points: Vec<Vec2>,
}
// #[derive(Bundle)]
// pub struct TrackBundle {
// track: Track,
// // label: TextBundle,
// }
// impl From<Track> for TrackBundle{
// fn from(track: Track) -> Self {
// let name = track.track_id.to_string();
// TrackBundle{
// track: track,
// // label: TextBundle{
// // text: Text::from_section(name, TextStyle::default()),
// // transform: Transform::from_translation(250. * Vec3::Y),
// // ..default()
// // }
// }
// }
// }
// #[derive(Bundle)]
// pub struct TrackBundle {
// pub history: TrajectoryBundle,
// pub time: Time,
// }
// #[derive(Bundle)]
// pub struct TrajectoryBundle {
// pub line: PolylineBundle
// // pub trajectory: Trajectory,
// }
#[derive(Component)]
pub struct Trajectory {
pub points: Vec<Vec3>,
}
fn spawn_track() {
}
fn draw_tracks() {
// evyr ææææááá
}