Need help with smoothing poses for the RemoteAvatar — Oculus
New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

Need help with smoothing poses for the RemoteAvatar

MTGTech3MTGTech3 Posts: 1
NerveGear
I have set up a multiplayer scene in unity using Photon. I have the LocalAvatar (imported directly from OvrAvatar > Content > Prefabs)set to record packets which then sends packet poses over the photon network by using oculus RemoteLoobackManager (modified to work with Photon). The poses are sent to the other players RemoteAvatar (also imported from OvrAvatar > Content > Prefabs). Everything works fine except that the RemoteAvatar does not do any Interpolation between pose frames. The fingers does however work smoothly but the rest of the avatar jitters and lags. Is there anyone who have a solution to this issue?. 

the issue is demonstrated in this youtube clip:

it is hard to see that the fingers are smooth but if you look at the video frame by frame you can see this.

Here is the code for the modified RemoteLoopbackManager:

    public OvrAvatar LocalAvatar;
    public OvrAvatar LoopbackAvatar;
    byte[] data;

    int packetSequence = 0;

     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);
            writer.Write(packetSequence++);
            args.Packet.Write(outputStream);
//          SendPacketData(outputStream.ToArray());
	    data = outputStream.ToArray();

        }
    }

//    void SendPacketData(byte[] data)
//    {
//        // Loopback by just "receiving" the data
//        ReceivePacketData(data);
//    }
//
    void ReceivePacketData(byte[] data)
    {
        using (MemoryStream inputStream = new MemoryStream(data))
        {
            BinaryReader reader = new BinaryReader(inputStream);
            int sequence = reader.ReadInt32();
            OvrAvatarPacket packet = OvrAvatarPacket.Read(inputStream);
            LoopbackAvatar.GetComponent<OvrAvatarRemoteDriver>().QueuePacket(sequence, packet);
        }
    }
	void Update(){

	}
	void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		if (stream.isWriting)
		{
			stream.SendNext (data);
		}
		else
		{
			data = (byte[])stream.ReceiveNext ();
			ReceivePacketData (data);
		}
	}

Answers

  • chrisnoletchrisnolet Posts: 15
    NerveGear
    I looks like your `data` global is being continually overwritten with every call to `OnLocalAvatarPacketRecorded`. If `OnPhotonSerializeView` isn't being called as often as `OnLocalAvatarPacketRecorded`, then you will be dropping packets. I suspect this is what's happening.

    You may like to keep a list of byte arrays and send them all on `OnPhotonSerializeView`.
Sign In or Register to comment.