#osc #virtual #motion #capture #protocols #tracking

vmc

Implementation of Virtual Motion Capture protocol for virtual avatar tracking

4 releases (breaking)

0.4.0 Oct 28, 2024
0.3.0 Aug 17, 2023
0.2.0 Aug 11, 2023
0.1.0 Aug 11, 2023

#502 in Network programming

Download history 9/week @ 2024-07-29 28/week @ 2024-09-23 134/week @ 2024-10-28 16/week @ 2024-11-04

150 downloads per month

MIT/Apache

90KB
2K SLoC

vmc

An asynchronous implementation of the Virtual Motion Capture Protocol in Rust.

While this crate is intended specifically for Virtual Motion Capture, it can also be used as an implementation of the Open Sound Control protocol which VMC is based on.

Examples

See examples/ for more detailed examples.

Performer

use vmc::{
	VMCApplyBlendShapes, VMCBlendShape, VMCModelState, VMCResult, VMCStandardVRMBlendShape, VMCState, VMCTime
};

#[tokio::main]
async fn main() -> VMCResult<()> {
	let socket = vmc::performer!("127.0.0.1:39539").await?;
	loop {
		socket
			.send(VMCBlendShape::new(VMCStandardVRMBlendShape::Joy, 1.0))
			.await?;
		socket.send(VMCApplyBlendShapes).await?;
		socket.send(VMCState::new(VMCModelState::Loaded)).await?;
		socket.send(VMCTime::elapsed()).await?;
	}
}

Marionette

use tokio_stream::StreamExt;
use vmc::{VMCMessage, VMCResult};

#[tokio::main]
async fn main() -> VMCResult<()> {
	let mut socket = vmc::marionette!("127.0.0.1:39539").await?;
	while let Some(packet) = socket.next().await {
		let (packet, _) = packet?;
		for message in vmc::parse(packet)? {
			match message {
				VMCMessage::BoneTransform(transform) => {
					println!("\tTransform bone: {} (pos {:?}; rot {:?})", transform.bone, transform.position, transform.rotation)
				}
				_ => {}
			}
		}
	}

	Ok(())
}

License

❤️ This package is based on rosc by Andreas Linz and async-osc by Franz Heinzmann. Licensed under MIT License or Apache-2.0.

Dependencies

~7–15MB
~246K SLoC