Page 1 of 1

INPVector Centering

Posted: Fri Jun 06, 2008 9:16 am
by RLovelett
Here is my goal, to replicate the TrackIR applications press F12 and have the coordinates of the vector reset to 0 as though the camera and vector had just started calculating for the first time. I thought that

Code: Select all

vector->Reset()
would do the trick. However, I am not seeing any changes in the values after making this call.

My question is two fold: does the

Code: Select all

vector->Reset()
function do what I think it does (reset the values back to zero), or is there something I am supposed to do when calling it, or a specific location I should be calling it in?

Attached I have a code snippet to illustrate what I'm doing (you can assume that when the variable camera comes into play it already has the camera pointer because the values for the position vector are displayed).

Any help would be greatly appreciated,
Ryan Lovelett

Code: Select all

CComPtr<INPSmoothing> smoothingYaw;
CComPtr<INPSmoothing> smoothingPitch;
CComPtr<INPSmoothing> smoothingRoll;
CComPtr<INPSmoothing> smoothingX;
CComPtr<INPSmoothing> smoothingY;
CComPtr<INPSmoothing> smoothingZ;

CComPtr<INPCameraFrame> frame;
CComPtr<INPVector> vector;

smoothingYaw.CoCreateInstance(CLSID_NPSmoothing);
smoothingPitch.CoCreateInstance(CLSID_NPSmoothing);
smoothingRoll.CoCreateInstance(CLSID_NPSmoothing);
smoothingX.CoCreateInstance(CLSID_NPSmoothing);
smoothingY.CoCreateInstance(CLSID_NPSmoothing);
smoothingZ.CoCreateInstance(CLSID_NPSmoothing);
vector.CoCreateInstance(CLSID_NPVector);

camera->Open();
camera->Start();

while(!_kbhit()) {
     camera->GetFrame(0, &frame);
     if(frame != NULL) {
          vector->Update(camera, frame);

          vector->get_Yaw(&varYaw);
	  vector->get_Pitch(&varPitch);
          vector->get_Roll(&varRoll);
	  vector->get_X(&varX);
	  vector->get_Y(&varY);
	  vector->get_Z(&varZ);

          smoothingYaw->Update(varYaw, varEmpty);
	  smoothingPitch->Update(varPitch, varEmpty);
	  smoothingRoll->Update(varRoll, varEmpty);
	  smoothingX->Update(varX, varEmpty);
	  smoothingY->Update(varY, varEmpty);
	  smoothingZ->Update(varZ, varEmpty);

          smoothingYaw->get_X(&varYaw);
	  smoothingPitch->get_X(&varPitch);
	  smoothingRoll->get_X(&varRoll);
	  smoothingX->get_X(&varX);
	  smoothingY->get_X(&varY);
	  smoothingZ->get_X(&varZ);

          frame->Free();
	  frame.Release();
     }

     vector->Reset();  //  Reset the vector to 0

}
camera->Stop();
camera->Close();
smoothingX.Release();
smoothingY.Release();
smoothingZ.Release();
smoothingYaw.Release();
smoothingPitch.Release();
smoothingRoll.Release();

Re: INPVector Centering

Posted: Fri Jun 06, 2008 2:42 pm
by Birch
Please see the existing topic which covers this :
http://forum.naturalpoint.com/forum/ubb ... mber=29982