Skip to content
This repository has been archived by the owner on Aug 16, 2018. It is now read-only.

Commit

Permalink
Ported viewer window to windows OS.
Browse files Browse the repository at this point in the history
Improved the viewer window.
Played a bit with coordinate normalization.
  • Loading branch information
Tony Gonçalves committed Feb 1, 2011
1 parent cc9c3e9 commit bc4db43
Show file tree
Hide file tree
Showing 7 changed files with 785 additions and 60 deletions.
28 changes: 20 additions & 8 deletions src/OSCeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
#include <cstdio>
#include <csignal>

#include <GL/glut.h>

#include <XnCppWrapper.h>

#include <ip/UdpSocket.h>
#include <osc/OscOutboundPacketStream.h>

#include "viewer.h"
#include "common.h"



Expand Down Expand Up @@ -63,6 +61,7 @@ bool play = false;
bool record = false;
bool sendRot = false;
bool filter = false;
bool preview = false;
int nDimensions = 3;

void (*oscFunc)(osc::OutboundPacketStream*, char*) = NULL;
Expand Down Expand Up @@ -159,7 +158,7 @@ int jointPos(XnUserID player, XnSkeletonJoint eJoint) {

userID = player;
jointCoords[0] = off_x + (mult_x * (1280 - joint.position.X) / 2560); //Normalize coords to 0..1 interval
jointCoords[1] = off_y + (mult_y * (1280 - joint.position.Y) / 2560); //Normalize coords to 0..1 interval
jointCoords[1] = off_y + (mult_y * (960 - joint.position.Y) / 1920); //Normalize coords to 0..1 interval
jointCoords[2] = off_z + (mult_z * joint.position.Z * 7.8125 / 10000); //Normalize coords to 0..7.8125 interval

//for (int i=0; i<9; i++)
Expand Down Expand Up @@ -316,13 +315,14 @@ Example: %s -a 127.0.0.1 -p 7110 -d 3 -n 1 -mx 1 -my 1 -mz 1 -ox 0 -oy 0 -oz 0\n
Options:\n\
-a <addr>\t Address to send OSC packets to (default: localhost).\n\
-p <port>\t Port to send OSC packets to (default: 7110).\n\
-r\t\t Reverse image (disable mirror mode).\n\
-w\t\t Activate depth view window.\n\
-mx <n>\t Multiplier for X coordinates.\n\
-my <n>\t Multiplier for Y coordinates.\n\
-mz <n>\t Multiplier for Z coordinates.\n\
-ox <n>\t Offset to add to X coordinates.\n\
-oy <n>\t Offset to add to Y coordinates.\n\
-oz <n>\t Offset to add to Z coordinates.\n\
-r\t\t Reverse image (disable mirror mode).\n\
-f\t\t Activate noise filter to reduce jerkyness.\n\
-k\t\t Enable \"Kitchen\" mode (Animata compatibility mode).\n\
-q\t\t Enable Quartz Composer OSC format.\n\
Expand Down Expand Up @@ -350,6 +350,8 @@ are correctly installed.\n\n");
void terminate(int ignored) {
context.Shutdown();
delete transmitSocket;
if (preview)
glutDestroyWindow(window);
exit(0);
}

Expand All @@ -361,7 +363,8 @@ void main_loop() {
// Process the data
depth.GetMetaData(depthMD);
sendOSC();
draw();
if (preview)
draw();
}


Expand Down Expand Up @@ -407,6 +410,9 @@ int main(int argc, char **argv) {
usage(argv[0]);
}
break;
case 'w':
preview = true;
break;
case 's':
checkRetVal(recorder.Create(context));
checkRetVal(recorder.SetDestination(XN_RECORD_MEDIUM_FILE, argv[arg+1]));
Expand Down Expand Up @@ -542,8 +548,14 @@ int main(int argc, char **argv) {
if (record)
recorder.AddNodeToRecording(depth, XN_CODEC_16Z_EMB_TABLES);

init_window(argc, argv, 640, 480, main_loop);
glutMainLoop();
if (preview) {
init_window(argc, argv, 640, 480, main_loop);
glutMainLoop();
}
else {
while(true)
main_loop();
}

terminate(0);
}
Expand Down
13 changes: 12 additions & 1 deletion src/OSCeleton.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(InputDir)\lib\glut32.dll $(OutDir)\"
/>
</Configuration>
<Configuration
Expand Down Expand Up @@ -124,6 +125,7 @@
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
ForcedIncludeFiles=""
/>
<Tool
Name="VCManagedResourceCompilerTool"
Expand All @@ -136,7 +138,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="OpenNI.lib WS2_32.Lib winmm.lib"
AdditionalDependencies="OpenNI.lib WS2_32.Lib winmm.lib glut32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="lib;&quot;$(OPEN_NI_LIB)&quot;"
GenerateDebugInformation="true"
Expand Down Expand Up @@ -165,6 +167,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(InputDir)\lib\glut32.dll $(OutDir)\"
/>
</Configuration>
</Configurations>
Expand Down Expand Up @@ -208,12 +211,20 @@
RelativePath="..\oscpack\ip\win32\UdpSocket.cpp"
>
</File>
<File
RelativePath=".\viewer.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\viewer.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Expand Down
10 changes: 10 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifdef WIN32
#include <windows.h>
#include "gl\glut.h"
#else
#include <GL/glut.h>
#endif

extern int window;

#include "viewer.h"
Loading

0 comments on commit bc4db43

Please sign in to comment.