Page 1 of 1

Need Help to Output Delta Displacements

Posted: Fri Feb 19, 2016 4:11 pm
by shahil

I'm hoping someone can help me out with a simple coding task. I want to stream the displacement data from the Motive software from a couple of rigid bodies, but I want to display the delta displacments from their initial positions. I basically want to zero out the initial positions so that I only see the deltas when the targets move.

I'm trying to use the NatNetSDK WinFormsSample application code to do this, but am having some trouble (pardon me, I'm a beginner when it comes to coding). I'm trying to capture the initial value of the rigid body position at rb.x, rb.y, and rb,z, and then simply minus this value from the outputed number in the display. Does anyone know how to capture those initial position values? It doesn't seem to be working when I simply equate a temp variable to the rb.x/y/z floats.

Any quick help would be much appreciated.

Re: Need Help to Output Delta Displacements

Posted: Wed Apr 27, 2016 11:49 am
by morgan
The initial values need to be stored in persistent variables (either static, or global, or class members). If you are just storing them in local variables on the stack in the data handler they would reinitialzed every frame.

I'd probably create a list of initposes, 1 for each rigidbody.

Here's some C# pseudocode for the Winforms sample:

Code: Select all

// Init Pose type
public class InitPose
      int RigidBodyID;
      double x;
      double y;
      double z;

// Add List of these to the winforms form class
    public partial class Form1 : Form
        List<InitPose> mListInitPoses = new List<InitPose>();

// Initialize each init pose on first frame of data
void ProcessFrameOfData(ref NatNetML.FrameOfMocapData data)
            // First frame of data?  Store off the init poses 
            for (int i = 0; i < m_FrameOfData.nRigidBodies; i++)
                NatNetML.RigidBodyData rb = m_FrameOfData.RigidBodies[i];
                InitPose pose;
                pose.ID = rb.ID;
                pose.x = rb.x;
                pose.y = rb.y;
                pose.z = rb.z;


Hope this helps,