create VmcExtBlendVal
This commit is contained in:
parent
3054bcc8fe
commit
61cc7bcb81
36
src/lib.rs
36
src/lib.rs
|
@ -238,10 +238,9 @@ struct VmcExtBonePos {
|
|||
|
||||
impl MessageBehavior for VmcExtBonePos {
|
||||
fn to_sendable_osc_message(&self) -> OscMessage {
|
||||
let addr = String::from("/VMC/Ext/Bone/Pos");
|
||||
let quat = self.transform.basis.to_quat();
|
||||
return OscMessage {
|
||||
addr,
|
||||
addr: String::from("/VMC/Ext/Bone/Pos"),
|
||||
args: vec![
|
||||
OscType::from(self.name.to_owned()),
|
||||
OscType::from(self.transform.origin.x),
|
||||
|
@ -304,3 +303,36 @@ impl MessageBehavior for VmcExtBonePos {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
struct VmcExtBlendVal {
|
||||
name: String,
|
||||
value: f32,
|
||||
}
|
||||
|
||||
impl MessageBehavior for VmcExtBlendVal {
|
||||
fn to_sendable_osc_message(&self) -> OscMessage {
|
||||
return OscMessage {
|
||||
addr: String::from("/VMC/Ext/Blend/Val"),
|
||||
args: vec![
|
||||
OscType::from(self.name.to_owned()),
|
||||
OscType::from(self.value),
|
||||
],
|
||||
};
|
||||
}
|
||||
fn parse_from_osc_message(msg: OscMessage) -> Result<Self, String> {
|
||||
let name: String;
|
||||
let value: f32;
|
||||
if msg.args.len() != 2 {
|
||||
return Err(String::from("arg count invalid"));
|
||||
}
|
||||
match &msg.args[0] {
|
||||
OscType::String(s) => name = s.to_owned(),
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
match msg.args[1] {
|
||||
OscType::Float(f) => value = f,
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
return Ok(VmcExtBlendVal { name, value });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user