Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PhotonでOculusAvatarを動かす方法

 PhotonでOculusAvatarを動かす方法

Keizo Nagamine

July 17, 2019
Tweet

More Decks by Keizo Nagamine

Other Decks in Technology

Transcript

  1. LocalAvatar → アバターデータ 19 void Start() { LocalAvatar.RecordPackets = true;

    LocalAvatar.PacketRecorded += OnLocalAvatarPacketRecorded; } void OnLocalAvatarPacketRecorded(object sender, OvrAvatar.PacketEventArgs args) { using (MemoryStream outputStream = new MemoryStream()) { BinaryWriter writer = new BinaryWriter(outputStream); ... byte[] avatarData = outputStream.ToArray(); SendPacketData(avatarData); } }
  2. アバターデータ → RemoteAvatar 20 void ReceivePacketData(byte[] data) { using (MemoryStream

    inputStream = new MemoryStream(data)) { BinaryReader reader = new BinaryReader(inputStream); int sequence = reader.ReadInt32(); OvrAvatarPacket avatarPacket; ... LoopbackAvatar.GetComponent<OvrAvatarRemoteDriver>().QueuePacket(sequence, avatarPacket); } }
  3. マルチプレイの構成 21 アバター データ アバター データ アバター データ アバター データ

    PlayerA PlayerB LocalAvatar LocalAvatar RemoteAvatar RemoteAvatar ネットワーク経由のデータの 送受信をどうするか
  4. IPunObserbable 29 PhotonViewの監視対象となるインターフェイス public class PhotonAvatarView : MonoBehaviour, IPunObservable {

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if(stream.IsWriting) { byte[] data = null; stream.SendNext(data); } if(stream.IsReading) { byte[] data = (byte[])stream.ReceiveNext(); } } } ここでLocalAvatarのアバターデータを送信 受信したアバターデータを RemoteAvatarに流し 込む
  5. CREDITS Special thanks to all the people who made and

    released these awesome resources for free: ▪ Presentation template by SlidesCarnival ▪ Photographs by Unsplash 38