Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Able to record Rigid Body data.

  • Loading branch information...
commit fa35fe487aeee4af88b6837b15a69b6d3445dcf5 1 parent ae3cd29
@mdfeist authored
View
13 BlinkAnalysis/AppData.cpp
@@ -91,6 +91,19 @@ bool AppData::openFile(char* filePath) {
return true;
}
+pugi::xml_node AppData::getNewRecording() {
+ // Get Project
+ pugi::xml_node project = doc.child("Project");
+
+ // If no Project create new Project node
+ if (!project) {
+ project = doc.append_child();
+ project.set_name("Project");
+ }
+
+ return project.append_child();
+}
+
bool AppData::saveFile() {
MainFormController::getInstance()->getInfo();
View
4 BlinkAnalysis/AppData.h
@@ -13,8 +13,6 @@
#include "NatNetTypes.h"
#include "pugixml.hpp"
-
-
public class AppData
{
public:
@@ -34,6 +32,8 @@ public class AppData
char* getLastError() { return this->error; }
+ pugi::xml_node getNewRecording();
+
bool openFile(char* filePath);
bool saveFile();
bool isSaveNeeded() { return this->needSaveFlag; }
View
8 BlinkAnalysis/BlinkAnalysis.vcxproj
@@ -85,6 +85,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<AdditionalIncludeDirectories>NatNetSDK\include;</AdditionalIncludeDirectories>
<CompileAsManaged>true</CompileAsManaged>
+ <Optimization>Full</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -113,7 +114,6 @@
<Content Include="DikablisHelpDocs\DikablisHelp.htm">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <None Include="ClassDiagram1.cd" />
<None Include="DikablisHelpDocs\DikablisHelp.rtf" />
<Content Include="NatNetLib.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -141,7 +141,8 @@
</ClCompile>
<ClCompile Include="Objects.cpp" />
<ClCompile Include="pugixml.cpp" />
- <ClCompile Include="RecorderManager.cpp" />
+ <ClCompile Include="RecordingManager.cpp" />
+ <ClCompile Include="Recording.cpp" />
<ClCompile Include="RigidBody.cpp" />
<ClCompile Include="AppData.cpp" />
<ClCompile Include="SetObjectRigidBodyForm.cpp" />
@@ -191,7 +192,8 @@
<ClInclude Include="Objects.h" />
<ClInclude Include="pugiconfig.hpp" />
<ClInclude Include="pugixml.hpp" />
- <ClInclude Include="RecorderManager.h" />
+ <ClInclude Include="RecordingManager.h" />
+ <ClInclude Include="Recording.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="RigidBody.h" />
<ClInclude Include="AppData.h" />
View
11 BlinkAnalysis/BlinkAnalysis.vcxproj.filters
@@ -22,7 +22,6 @@
<None Include="DikablisHelpDocs\DikablisHelp.rtf">
<Filter>Resource Files</Filter>
</None>
- <None Include="ClassDiagram1.cd" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BlinkAnalysis.cpp">
@@ -91,7 +90,10 @@
<ClCompile Include="WorldManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="RecorderManager.cpp">
+ <ClCompile Include="Recording.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="RecordingManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -201,7 +203,10 @@
<ClInclude Include="WorldManager.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="RecorderManager.h">
+ <ClInclude Include="Recording.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="RecordingManager.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
View
2  BlinkAnalysis/ClientHandler.cpp
@@ -76,7 +76,7 @@ osg::Vec3 ClientHandler::getRay(int x, int y) {
int loc = 3*((j*(DikablisViewingWidth+2*DikablisViewingMargin)) + i);
- if (loc >= 0 && loc < DikablisViewingSize) {
+ if (loc >= 0 && loc < (int)DikablisViewingSize) {
ray.x() = this->dikablisEyeVectorArray[loc + 0];
ray.y() = this->dikablisEyeVectorArray[loc + 1];
ray.z() = this->dikablisEyeVectorArray[loc + 2];
View
83 BlinkAnalysis/MainForm.h
@@ -26,6 +26,7 @@
#include "AppData.h"
#include "AppViewer.h"
#include "WorldManager.h"
+#include "RecordingManager.h"
#include "NatNetClientSetup.h"
@@ -389,6 +390,9 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->visualViewerScaleLabel = (gcnew System::Windows::Forms::ToolStripLabel());
this->visualViewerScaleTextBox = (gcnew System::Windows::Forms::ToolStripTextBox());
this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
+ this->visualRecorderPanel = (gcnew System::Windows::Forms::Panel());
+ this->stopRecordingBtn = (gcnew System::Windows::Forms::Button());
+ this->startRecordingBtn = (gcnew System::Windows::Forms::Button());
this->visualRecorderLabel = (gcnew System::Windows::Forms::Label());
this->visualPropertiesTabControl = (gcnew System::Windows::Forms::TabControl());
this->rigidBodyTabPage = (gcnew System::Windows::Forms::TabPage());
@@ -423,9 +427,6 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->addObjectToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
this->rigidBodyToolContextMenu = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
this->setAsRigidBodyToolToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
- this->visualRecorderPanel = (gcnew System::Windows::Forms::Panel());
- this->startRecordingBtn = (gcnew System::Windows::Forms::Button());
- this->stopRecordingBtn = (gcnew System::Windows::Forms::Button());
this->mainTabControl->SuspendLayout();
this->OptiTrackPage->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->optiTrackMainSplitContainer))->BeginInit();
@@ -455,6 +456,7 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->visualSplitContainer->Panel2->SuspendLayout();
this->visualSplitContainer->SuspendLayout();
this->visualToolStrip->SuspendLayout();
+ this->visualRecorderPanel->SuspendLayout();
this->visualPropertiesTabControl->SuspendLayout();
this->rigidBodyTabPage->SuspendLayout();
this->worldTabPage->SuspendLayout();
@@ -463,7 +465,6 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->objectGridView))->BeginInit();
this->menuStrip->SuspendLayout();
this->rigidBodyToolContextMenu->SuspendLayout();
- this->visualRecorderPanel->SuspendLayout();
this->SuspendLayout();
//
// mainTabControl
@@ -1438,6 +1439,39 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->toolStripSeparator1->Name = L"toolStripSeparator1";
this->toolStripSeparator1->Size = System::Drawing::Size(6, 25);
//
+ // visualRecorderPanel
+ //
+ this->visualRecorderPanel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
+ | System::Windows::Forms::AnchorStyles::Left)
+ | System::Windows::Forms::AnchorStyles::Right));
+ this->visualRecorderPanel->BackColor = System::Drawing::Color::WhiteSmoke;
+ this->visualRecorderPanel->Controls->Add(this->stopRecordingBtn);
+ this->visualRecorderPanel->Controls->Add(this->startRecordingBtn);
+ this->visualRecorderPanel->Location = System::Drawing::Point(3, 16);
+ this->visualRecorderPanel->Name = L"visualRecorderPanel";
+ this->visualRecorderPanel->Size = System::Drawing::Size(487, 101);
+ this->visualRecorderPanel->TabIndex = 1;
+ //
+ // stopRecordingBtn
+ //
+ this->stopRecordingBtn->Location = System::Drawing::Point(131, 3);
+ this->stopRecordingBtn->Name = L"stopRecordingBtn";
+ this->stopRecordingBtn->Size = System::Drawing::Size(122, 23);
+ this->stopRecordingBtn->TabIndex = 1;
+ this->stopRecordingBtn->Text = L"Stop Recording";
+ this->stopRecordingBtn->UseVisualStyleBackColor = true;
+ this->stopRecordingBtn->Click += gcnew System::EventHandler(this, &MainForm::stopRecordingBtn_Click);
+ //
+ // startRecordingBtn
+ //
+ this->startRecordingBtn->Location = System::Drawing::Point(3, 3);
+ this->startRecordingBtn->Name = L"startRecordingBtn";
+ this->startRecordingBtn->Size = System::Drawing::Size(122, 23);
+ this->startRecordingBtn->TabIndex = 0;
+ this->startRecordingBtn->Text = L"Start Recording";
+ this->startRecordingBtn->UseVisualStyleBackColor = true;
+ this->startRecordingBtn->Click += gcnew System::EventHandler(this, &MainForm::startRecordingBtn_Click);
+ //
// visualRecorderLabel
//
this->visualRecorderLabel->AutoSize = true;
@@ -1786,37 +1820,6 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->setAsRigidBodyToolToolStripMenuItem->Text = L"Set as Rigid Body Tool";
this->setAsRigidBodyToolToolStripMenuItem->Click += gcnew System::EventHandler(this, &MainForm::setAsRigidBodyToolToolStripMenuItem_Click);
//
- // visualRecorderPanel
- //
- this->visualRecorderPanel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom)
- | System::Windows::Forms::AnchorStyles::Left)
- | System::Windows::Forms::AnchorStyles::Right));
- this->visualRecorderPanel->BackColor = System::Drawing::Color::WhiteSmoke;
- this->visualRecorderPanel->Controls->Add(this->stopRecordingBtn);
- this->visualRecorderPanel->Controls->Add(this->startRecordingBtn);
- this->visualRecorderPanel->Location = System::Drawing::Point(3, 16);
- this->visualRecorderPanel->Name = L"visualRecorderPanel";
- this->visualRecorderPanel->Size = System::Drawing::Size(487, 101);
- this->visualRecorderPanel->TabIndex = 1;
- //
- // startRecordingBtn
- //
- this->startRecordingBtn->Location = System::Drawing::Point(3, 3);
- this->startRecordingBtn->Name = L"startRecordingBtn";
- this->startRecordingBtn->Size = System::Drawing::Size(122, 23);
- this->startRecordingBtn->TabIndex = 0;
- this->startRecordingBtn->Text = L"Start Recording";
- this->startRecordingBtn->UseVisualStyleBackColor = true;
- //
- // stopRecordingBtn
- //
- this->stopRecordingBtn->Location = System::Drawing::Point(131, 3);
- this->stopRecordingBtn->Name = L"stopRecordingBtn";
- this->stopRecordingBtn->Size = System::Drawing::Size(122, 23);
- this->stopRecordingBtn->TabIndex = 1;
- this->stopRecordingBtn->Text = L"Stop Recording";
- this->stopRecordingBtn->UseVisualStyleBackColor = true;
- //
// MainForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
@@ -1872,6 +1875,7 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->visualSplitContainer->ResumeLayout(false);
this->visualToolStrip->ResumeLayout(false);
this->visualToolStrip->PerformLayout();
+ this->visualRecorderPanel->ResumeLayout(false);
this->visualPropertiesTabControl->ResumeLayout(false);
this->rigidBodyTabPage->ResumeLayout(false);
this->worldTabPage->ResumeLayout(false);
@@ -1883,7 +1887,6 @@ private: System::Windows::Forms::Button^ startRecordingBtn;
this->menuStrip->ResumeLayout(false);
this->menuStrip->PerformLayout();
this->rigidBodyToolContextMenu->ResumeLayout(false);
- this->visualRecorderPanel->ResumeLayout(false);
this->ResumeLayout(false);
this->PerformLayout();
@@ -2640,7 +2643,7 @@ private: System::Void addObjectToolStripMenuItem_Click(System::Object^ sender,
{
optiTrackLabeledMarkerVector->at(safe_cast<int>(num->Current))->select();
}
- }*/
+}*/
private: System::Void visualRigidBodyListView_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
if (e->Button == ::MouseButtons::Right)
{
@@ -3088,6 +3091,12 @@ private: System::Void visualViewerScaleTextBox_TextChanged(System::Object^ send
float scale = Convert::ToSingle(this->visualViewerScaleTextBox->Text);
AppViewer::setScale(scale);
}
+private: System::Void startRecordingBtn_Click(System::Object^ sender, System::EventArgs^ e) {
+ RecordingManager::getInstance()->startRecording();
+ }
+private: System::Void stopRecordingBtn_Click(System::Object^ sender, System::EventArgs^ e) {
+ RecordingManager::getInstance()->stopRecording();
+ }
};
}
View
43 BlinkAnalysis/MainForm.resX
@@ -117,9 +117,6 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
- <metadata name="visualToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>327, 13</value>
- </metadata>
<metadata name="optiTrackRigidBodyIDColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@@ -147,38 +144,8 @@
<metadata name="optiTrackRigidBodyRotationWColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
- <metadata name="optiTrackRigidBodyIDColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyNameColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyPositionXColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyPositionYColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyPositionZColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyRotationXColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyRotationYColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyRotationZColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="optiTrackRigidBodyRotationWColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="worldPropertyColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="worldValueColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
+ <metadata name="visualToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>327, 13</value>
</metadata>
<metadata name="worldPropertyColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
@@ -192,12 +159,6 @@
<metadata name="objectValueColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
- <metadata name="objectPropertyColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
- <metadata name="objectValueColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
View
111 BlinkAnalysis/Recording.cpp
@@ -0,0 +1,111 @@
+#include "StdAfx.h"
+#include "Recording.h"
+
+#include "AppData.h"
+#include "RecordingManager.h"
+
+typedef std::map<int, RigidBody*>::iterator RigidBody_iterator;
+
+Recording::Recording(void)
+{
+ this->readyForRecording = false;
+ this->id = RecordingManager::getInstance()->getNewID();
+
+ this->recording = AppData::getInstance()->getNewRecording();
+}
+
+
+Recording::~Recording(void)
+{
+ this->rigidBodies.clear();
+}
+
+bool Recording::loadRecording(pugi::xml_node recording) {
+ // Clear previous frames
+ frames.clear();
+
+ // Get the name of the recording
+ pugi::xml_attribute recording_name = recording.attribute("name");
+
+ if (recording_name) {
+ this->name = recording_name.value();
+ }
+
+ // Get Static Objects
+ pugi::xml_node static_objects = recording.child("Static");
+
+ for (pugi::xml_node rigidBody = static_objects.child("RigidBody"); rigidBody; rigidBody = static_objects.next_sibling("RigidBody")) {
+ pugi::xml_attribute id = rigidBody.attribute("id");
+ pugi::xml_attribute name = rigidBody.attribute("name");
+
+ RigidBody* rb = new RigidBody();
+ rb->setID(id.as_int());
+ rb->setName((char*)name.value());
+
+ // Add the Rigid Body
+ this->rigidBodies.insert ( std::pair<int, RigidBody*>(id.as_int(), rb) );
+ }
+
+ return true;
+}
+
+void Recording::initializeRecording() {
+
+ ClientHandler* client = AppData::getInstance()->getClient();
+
+ if (client) {
+ recording.set_name("Recording");
+
+ pugi::xml_node static_objects = recording.child("Static");
+
+ if (!static_objects) {
+ static_objects = recording.append_child();
+ static_objects.set_name("Static");
+ }
+
+ for (pugi::xml_node rigidBody = static_objects.child("RigidBody"); rigidBody; rigidBody = static_objects.next_sibling("RigidBody")) {
+ static_objects.remove_child(rigidBody);
+ }
+
+ std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
+
+ for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {
+ pugi::xml_node rigidBody = static_objects.append_child();
+ rigidBody.set_name("RigidBody");
+ rigidBody.append_attribute("id") = it->second->getID();
+ rigidBody.append_attribute("name") = it->second->getName();
+ }
+ }
+
+ this->readyForRecording = true;
+}
+
+void Recording:: addFrame() {
+ if (!this->readyForRecording)
+ initializeRecording();
+
+ ClientHandler* client = AppData::getInstance()->getClient();
+
+ if (client) {
+ pugi::xml_node frame = recording.append_child();
+ frame.set_name("Frame");
+
+ std::map<int, RigidBody*>* rigidBodies = client->getRigidBodyMap();
+
+ for (RigidBody_iterator it = rigidBodies->begin(); it != rigidBodies->end(); ++it) {
+ pugi::xml_node rigidBody = frame.append_child();
+ rigidBody.set_name("RigidBody");
+
+ rigidBody.append_attribute("id") = it->second->getID();
+
+ rigidBody.append_attribute("x") = it->second->getPosition().x();
+ rigidBody.append_attribute("y") = it->second->getPosition().y();
+ rigidBody.append_attribute("z") = it->second->getPosition().z();
+
+ rigidBody.append_attribute("qx") = it->second->getRotation().x();
+ rigidBody.append_attribute("qy") = it->second->getRotation().y();
+ rigidBody.append_attribute("qz") = it->second->getRotation().z();
+ rigidBody.append_attribute("qw") = it->second->getRotation().w();
+ }
+ }
+}
View
130 BlinkAnalysis/Recording.h
@@ -0,0 +1,130 @@
+#pragma once
+#include <string.h>
+#include <map>
+#include <vector>
+
+#include "RigidBody.h"
+#include "Marker.h"
+
+#include "pugixml.hpp"
+
+class Recording
+{
+private:
+ class Marker_Frame {
+ private:
+ int _id;
+ float _x, _y, _z;
+ public:
+ Marker_Frame(int id) {
+ _id = id;
+
+ _x = 0.f;
+ _y = 0.f;
+ _z = 0.f;
+ }
+
+ Marker_Frame(int id,
+ float x, float y, float z) {
+ _id = id;
+
+ _x = x;
+ _y = y;
+ _z = z;
+ }
+
+ int getID() { return _id; }
+
+ float& x() { return _x; }
+ float& y() { return _y; }
+ float& z() { return _z; }
+ };
+
+ class RB_Frame {
+ private:
+ int _id;
+ float _x, _y, _z;
+ float _qx, _qy, _qz, _qw;
+
+ std::vector<Marker_Frame> markers;
+ public:
+ RB_Frame(int id) {
+ _id = id;
+
+ _x = 0.f;
+ _y = 0.f;
+ _z = 0.f;
+
+ _qx = 0.f;
+ _qy = 0.f;
+ _qz = 0.f;
+ _qw = 0.f;
+ }
+
+ RB_Frame(int id,
+ float x, float y, float z,
+ float qx, float qy, float qz, float qw) {
+ _id = id;
+
+ _x = x;
+ _y = y;
+ _z = z;
+
+ _qx = qx;
+ _qy = qy;
+ _qz = qz;
+ _qw = qw;
+ }
+
+ int getID() { return _id; }
+
+ float& x() { return _x; }
+ float& y() { return _y; }
+ float& z() { return _z; }
+
+ float& qx() { return _qx; }
+ float& qy() { return _qy; }
+ float& qz() { return _qz; }
+ float& qw() { return _qw; }
+
+ void addMarker(Marker_Frame marker) {
+ this->markers.push_back(marker);
+ }
+
+ std::vector<Marker_Frame> getMarkers() { return this->markers; }
+ int getNumberOfMarkers() { return this->markers.size(); }
+ };
+
+ class Frame {
+ private:
+ int _id;
+
+ std::vector<RB_Frame> rigidBodies;
+ std::vector<Marker_Frame> markers;
+ };
+
+ int id;
+ std::string name;
+
+ std::map<int, RigidBody*> rigidBodies;
+
+ bool readyForRecording;
+ std::vector<Frame> frames;
+ pugi::xml_node recording;
+
+ void initializeRecording();
+public:
+ Recording(void);
+ ~Recording(void);
+
+ void setName(std::string name) { this->name = name; }
+ std::string getName() { return this->name; }
+
+ void addFrame();
+ int numberOfFrames() { return this->frames.size(); }
+
+ bool loadRecording(pugi::xml_node recording);
+
+ pugi::xml_node& getXML() { return this->recording; }
+};
+
View
65 BlinkAnalysis/RecordingManager.cpp
@@ -0,0 +1,65 @@
+#include "StdAfx.h"
+#include "RecordingManager.h"
+
+#include <Windows.h>
+#include <process.h>
+#include <stdlib.h>
+
+RecordingManager* RecordingManager::m_pInstance = NULL;
+
+RecordingManager::RecordingManager(void)
+{
+ this->recording = false;
+ this->recordingIDCount = 0;
+
+ this->currentRecording = NULL;
+}
+
+
+RecordingManager::~RecordingManager(void)
+{
+ this->recordings.clear();
+}
+
+void recordingThread(void *) {
+ while (RecordingManager::getInstance()->isRecording()) {
+ RecordingManager::getInstance()->addFrame();
+ Sleep(1000/60);
+ }
+
+ // Terminate thread
+ _endthread();
+}
+
+void RecordingManager::addRecording() {
+ if (this->currentRecording != NULL) {
+ this->recordings.push_back(this->currentRecording);
+ this->currentRecording = 0;
+ }
+}
+
+void RecordingManager::startRecording() {
+ if (!this->recording) {
+ addRecording();
+
+ this->currentRecording = new Recording();
+
+ this->recording = true;
+
+ // Begin rendering on new thread
+ _beginthread( recordingThread, 0, NULL );
+ }
+}
+
+void RecordingManager::stopRecording() {
+ if (this->recording) {
+ addRecording();
+ this->recording = false;
+ }
+}
+
+void RecordingManager::addFrame() {
+ if (this->recording) {
+ this->currentRecording->addFrame();
+ }
+}
View
44 BlinkAnalysis/RecordingManager.h
@@ -0,0 +1,44 @@
+#pragma once
+#include <vector>
+
+#include "Recording.h"
+
+class RecordingManager
+{
+public:
+ static RecordingManager* getInstance() {
+ if(!m_pInstance) m_pInstance = new RecordingManager();
+ return m_pInstance;
+ }
+
+ bool isRecording() { return this->recording; }
+ void startRecording();
+ void stopRecording();
+ void addFrame();
+
+ std::vector<Recording*> getRecordings() { return this->recordings; }
+
+ int getNewID() {
+ this->recordingIDCount++;
+ return this->recordingIDCount;
+ }
+
+protected:
+ RecordingManager(void);
+ ~RecordingManager(void);
+private:
+ RecordingManager(RecordingManager const&);
+ RecordingManager& operator=(RecordingManager const&);
+
+ static RecordingManager* m_pInstance;
+
+ int recordingIDCount;
+ bool recording;
+
+ Recording* currentRecording;
+
+ std::vector<Recording*> recordings;
+
+ void addRecording();
+};
+
Please sign in to comment.
Something went wrong with that request. Please try again.