Permalink
Browse files

Added support for recording the eye vector. (Untested with Dikablis)

  • Loading branch information...
1 parent 439d378 commit 3a46a01b9bb1fa07719be7f15695b0ec8fb3b7c8 @mdfeist committed Jun 21, 2013
Showing with 42 additions and 0 deletions.
  1. +42 −0 BlinkAnalysis/Recording.cpp
@@ -164,6 +164,48 @@ void Recording:: addFrame() {
if (!client->lock())
return;
+ // Get current position of head
+ RigidBody* head = client->getHead();
+
+ if (head != NULL) {
+ fileStream << "<EyeVector>\n";
+
+ osg::Vec3 pos = head->getPosition();
+
+ // Add to the head point
+ fileStream << "<Start ";
+ fileStream << "x=\"" << pos.x() << "\" ";
+ fileStream << "y=\"" << pos.y() << "\" ";
+ fileStream << "z=\"" << pos.z() << "\" ";
+ fileStream << "/>";
+
+ osg::Matrixf headMatrix;
+ headMatrix.makeIdentity();
+ float qx = -head->getRotation().x();
+ float qy = -head->getRotation().y();
+ float qz = -head->getRotation().z();
+ float qw = head->getRotation().w();
+ headMatrix.makeRotate(osg::Quat(qx, qy, qz, qw));
+
+ Dikablis::journal_struct journal = Dikablis::getJournal();
+
+ int x = journal.field_x;
+ int y = journal.field_y;
+
+ osg::Vec3 ray = client->getRay(x, y);
+
+ ray = headMatrix * ray;
+ ray = (ray + pos);
+
+ fileStream << "<End ";
+ fileStream << "x=\"" << ray.x() << "\" ";
+ fileStream << "y=\"" << ray.y() << "\" ";
+ fileStream << "z=\"" << ray.z() << "\" ";
+ fileStream << "/>";
+
+ fileStream << "</EyeVector>\n";
+ }
+
std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {

0 comments on commit 3a46a01

Please sign in to comment.