add VmcExtSetEye message

This commit is contained in:
Cassandra de la Cruz-Munoz 2023-12-31 10:31:48 -05:00
parent 37298e3958
commit e9e7b75b95
Signed by: cassdlcm
GPG Key ID: BFEBACEA812DDA70

View File

@ -1227,7 +1227,7 @@ impl MessageBehavior for VmcExtSetPeriod {
OscType::from(self.blendshape),
OscType::from(self.camera),
OscType::from(self.devices),
] }
] };
}
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
if msg.args.len() != 6 {
@ -1266,3 +1266,47 @@ impl MessageBehavior for VmcExtSetPeriod {
return Ok(VmcExtSetPeriod { status, root, bone, blendshape, camera, devices})
}
}
struct VmcExtSetEye {
enable: i32,
position: Vector3,
}
impl MessageBehavior for VmcExtSetEye {
fn to_osc_message(&self) -> OscMessage {
return OscMessage{ addr: String::from("/VMC/Ext/Set/Eye"), args: vec![
OscType::from(self.enable),
OscType::from(self.position.x),
OscType::from(self.position.y),
OscType::from(self.position.z),
]
};
}
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
if msg.args.len() != 4 {
return Err(String::from("arg count invalid"));
}
let enable: i32;
let x: f32;
let y: f32;
let z: f32;
match msg.args[0] {
OscType::Int(i) => enable = i,
_ => return Err(String::from("arg type invalid")),
}
match msg.args[1] {
OscType::Float(f) => x = f,
_ => return Err(String::from("arg type invalid")),
}
match msg.args[2] {
OscType::Float(f) => y = f,
_ => return Err(String::from("arg type invalid")),
}
match msg.args[3] {
OscType::Float(f) => z = f,
_ => return Err(String::from("arg type invalid")),
}
return Ok(VmcExtSetEye { enable, position: Vector3::new(x, y, z)})
}
}