Vuzix VR920 API Integration

Hey everyone. I’ve just started trying to port the beginnings of my little VR environment to OF and am having a nightmare of a time getting it to compile with the Vuzix iWear.framework being used.

Here’s the vid of what I have working in Processing:

http://vimeo.com/4044436

The SDK is downloadable from http://vrdeveloper.vr920.com/

I think the code is pretty much sound, and that the problem is in compiler flags and the like, but I honestly don’t know where to begin looking.

So this is an attempted fusion built on the ofx3DUtils example and the iWearSimple apps. The iWearSimple app is included with the VR920 Mac SDK.

During the linking phase when I try to compile, it is giving me “Symbols not found” for ALL of the IWEAR_… functions. I’ve tried everything I know to try, and then some :-/

I haven’t written in any functions to use info from the VR920 tracker yet. I’m just trying to output stereoscopy to start with.

I’m attaching the Xcode project.

Here’s my testApp.cpp:

  
  
#include "testApp.h"  
#include "iWear/iweardrv.h"	/* for the IWEAR interface */  
  
IWEAR_HANDLE ** hnd;	/* the array of device handles - allows for multiple VR920 units */  
  
//--------------------------------------------------------------  
void testApp::setup(){	   
	ofBackground(250,250,250);  
	ofSetVerticalSync(true);  
	glEnable(GL_DEPTH_TEST); //lights look weird if depth test is not enabled  
	  
	//iWear Start  
		  
	/* start up the system */  
	ret = IWEAR_Start();  
//	ERRCHK( ret );  
	  
	/* count the number of available devices */  
	ret = IWEAR_Count();  
//	ERRCHK( ret );  
	nDevices = ret;  
	fprintf( stderr, "%d IWEAR devices found.\n", nDevices );  
	if( nDevices == 0 )  
	{  
		fprintf( stderr, "Exiting.\n" );  
		IWEAR_End();  
//		return( 0 );  
	}  
	  
	/* open all of the devices we've found */  
	hnd = (IWEAR_HANDLE **)malloc( nDevices * sizeof( IWEAR_HANDLE * ) );  
	for( c=0 ; c<nDevices ; c ++ )  
	{  
		hnd[c] = IWEAR_OpenIndexed( c );  
//		ERRCHKHND( hnd[c] );  
	}  
	  
#ifdef RECENTER_EYEWEAR  
	/* center it */  
	fprintf( stderr, "Center the iWear\n" );  
	sleep( 1 );  
	ret = IWEAR_ZeroSet( hnd[0] );  
#endif  
	  
	//iWear End  
	  
	  
	centerX = 0;  
	centerY = 0;  
	centerZ = 0;  
	  
	rotX = 0;  
	rotY = 0;  
	bSmoothLight = true;  
	  
	leftEye = true;  
	  
	//reflexions!!  
	ofxMaterialSpecular(120, 120, 120); //how much specular light will be reflect by the surface  
	ofxMaterialShininess(50); //how concentrated the reflexion will be (between 0 and 128  
	  
	//each light will emit white reflexions  
	light1.specular(255, 255, 255);  
	light2.specular(255, 255, 255);  
	light3.specular(255, 255, 255);  
  
	camera.position(50, 500, 1000); //initialize the camera at a far position from the sphere  
	camera.eye(0.0f,500.0f,0.0f);  
	rotationAxisY.set(0.0f,1.0f,0.0f);  
	rotationAxisX.set(1.0f,0.0f,0.0f);  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
//	rotX += 1;  
//	rotY += 2;  
  
	//light1  
	float L1DirectionX = 1;  
	float L1DirectionY = 0;  
	float L1DirectionZ = 0;  
	  
	light1.directionalLight(255, 0, 0, L1DirectionX, L1DirectionY, L1DirectionZ);  
	  
	//light2  
	float L2ConeAngle = 50;  
	float L2Concentration = 60;  
	float L2PosX = mouseX;  
	float L2PosY = mouseY;  
	float L2PosZ = 500;  
	float L2DirectionX = 0;  
	float L2DirectionY = 0;  
	float L2DirectionZ = -1;  
	  
	light2.spotLight(0, 255, 0,   
					 L2PosX, L2PosY, L2PosZ,   
					 L2DirectionX, L2DirectionY, L2DirectionZ,  
					 L2ConeAngle,  
					 L2Concentration);  
	  
	//light3  
	float L3PosX = ofGetWidth();  
	float L3PosY = mouseY;  
	float L3PosZ = 500;  
	light3.pointLight(0, 0, 255, L3PosX, L3PosY, L3PosZ);  
	  
	ret = IWEAR_SUCCESS;  
	if( ret == IWEAR_SUCCESS )  
	{  
		for( c=0 ; c<nDevices ; c++ ) /* for each device... */  
		{  
			ret = IWEAR_GetTracking( hnd[c], &y, &p, &r );					/* get the integer-based tracking */  
			ret = IWEAR_GetTrackingNormalized( hnd[c], &yd, &pd, &rd );		/* get the normalized tracking */  
			  
//			fprintf( stderr, "%ld  Y:%-6d %-5.4f   P:%-6d %-5.4f   R:%-6d %-5.4f \n",  
//					c, y, yd, p, pd, r, rd );			  
		}  
//		sleep( 1 ); /* update only once a second for fun */  
	}  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	if(leftEye){  
		ret = IWEAR_Stereo( hnd[c], 1 );  
		camera.lerpPosition(camera.getPosition().x-100, camera.getPosition().y, camera.getPosition().z, 0.1); //interpolate the camera into a closer position  
		leftEye = false;  
	}  
	else{  
		ret = IWEAR_Stereo( hnd[c], 2 );  
		camera.lerpPosition(camera.getPosition().x+100, camera.getPosition().y, camera.getPosition().z, 0.1); //interpolate the camera into a closer position  
		leftEye = true;  
	}  
	camera.place();//this MUST be inside the draw function, and actually places the camera in position  
//	printf(ret);  
	ofSetColor(0,0,0);  
//	glPushMatrix();  
//	grid.draw(2000,100,300);  
//	glPopMatrix();  
	  
	ofxLightsOn(); //turn lights on  
	ofSetColor(255, 255, 255);  
	  
	ofxSphere(centerX - 150, centerY - 150, 0, 50, 100, 100, rotX, rotY, 0);  
	  
	ofxBox(-50, -50, -100, 100, 100, 200, rotX, rotY, 0);  
	  
	ofxCone(centerX - 150, centerY + 150, 0, 50, 100, 50, rotX, rotY, 0);  
	  
	ofxCapsule(centerX + 150, centerY + 150, 0, 100, 100, 50, rotX, rotY, 0);  
	  
//	ofxLightsOff(); //turn lights off to draw text  
//	string info = "PRESSING MOUSE WILL TURN SMOOTH LIGHTS OFF";  
//	ofSetColor(0, 0, 0);  
//	ofDrawBitmapString(info, 20, 20);  
  
}  
  
//--------------------------------------------------------------  
void testApp::keyPressed  (int key){   
	if(key == 'j'){  
		camera.rotate(rotationAxisY, 1.0f);  
	}  
	if(key == 'l'){  
		camera.rotate(rotationAxisY, -1.0f);  
	}  
	if(key == 'i'){  
		camera.moveLocal(0.0f,0.0f,10.0f);  
	}  
	if(key == 'k'){  
		camera.moveLocal(0.0f,0.0f,-10.0f);  
	}  
	if(key == 'a'){  
		camera.orbitAround(camera.getEye(),rotationAxisY, 1.0f);  
	}  
	if(key == 'd'){  
		camera.orbitAround(camera.getEye(),rotationAxisY, -1.0f);  
	}  
	if(key == 'w'){  
		camera.orbitAround(camera.getEye(),rotationAxisX, 1.0f);  
	}  
	if(key == 's'){  
		camera.orbitAround(camera.getEye(),rotationAxisX, -1.0f);  
	}  
	  
}  
  
//--------------------------------------------------------------  
void testApp::keyReleased  (int key){   
	  
}  
  
//--------------------------------------------------------------  
void testApp::mouseMoved(int x, int y ){  
  
}  
  
//--------------------------------------------------------------  
void testApp::mouseDragged(int x, int y, int button){  
}  
  
//--------------------------------------------------------------  
void testApp::mousePressed(int x, int y, int button){  
	ofxSetSmoothLight(false);  
}  
  
//--------------------------------------------------------------  
void testApp::mouseReleased(){  
	ofxSetSmoothLight(true);  
}  
  

And here is the testApp.h:

  
#ifndef _TEST_APP  
#define _TEST_APP  
  
#include "ofMain.h"  
#include "ofx3DUtils.h"  
//#include "worldBox.h"  
#include <stdio.h>		/* for printf, etc */  
#include <stdlib.h>		/* for malloc/free */  
#include <unistd.h>		/* for usleep */  
//#include "iWear/iweardrv.h"	/* for the IWEAR interface */  
  
class testApp : public ofSimpleApp{  
	  
public:  
	  
	void setup();  
	void update();  
	void draw();  
	  
	void keyPressed(int key);  
	void keyReleased(int key);  
	void mouseMoved(int x, int y );  
	void mouseDragged(int x, int y, int button);  
	void mousePressed(int x, int y, int button);  
	void mouseReleased();  
	  
	worldBox grid;  
	  
	//  
	ofxCamera camera;  
	  
	ofxLight light1; //this will be a directional light  
	ofxLight light2; //this one a spot light  
	ofxLight light3; //and this one a point light  
	  
	ofxVec3f rotationAxisY;  
	ofxVec3f rotationAxisX;  
	  
	float centerX, centerY, centerZ;  
	float rotX, rotY;  
	  
	bool bSmoothLight;  
	float camX, camY, camZ;  
	  
	bool leftEye;  
	  
//	IWEAR_HANDLE ** hnd;	/* the array of device handles - allows for multiple VR920 units */  
	long ret;				/* return value we use for most calls */  
	long nDevices;			/* number of VR920 devices found on the system */  
	long c;					/* generic counting variable */  
	long y, p, r;			/* the yaw, pitch, roll retrieved */  
	double yd, pd, rd;		/* the normalized yaw, pitch, roll received */  
	  
};  
  
#endif  
	  
  

Anyone have any suggestions? Need more info to help? Any suggestions would be much appreciated.

vrBox.zip

Hi - I just tried and have the same issue as you.

I linked the framework and I get the same errors.
The example project that comes with the sdk runs fine - the only thing I could think of is that either it is a c vs cpp thing (as their project is a c project) or that there is some project setting which is different that allows it to compile.

I tried disabling prebinding on the OF project and also adding /Library/Frameworks/ to the framework search paths in project settings. I don’t know what else I can try.

Also one thing I noticed in your project is that when you have added files you have added them absolutely (or just chosen Default). It is quite important that when you add files within your OF folder (including addons) you add them as Relative to Project except for all files at the System/Developer level which you should add as Absolute Path. This doesn’t affect you immediately but if you share a project it breaks a lot of things because instead of looking for a file like src/someFile.cpp it is looking for /Disk/Users/You/OF/apps/myApp/src/SomeFile.cpp

Theo

Thanks, Theo.

I’ll fix all of the search paths to make them relative. I tried adding /Library/Frameworks to the framework search paths too. :-/ I recall seeing some fixes in other threads that involved

  
extern "C" {extern... }  

directives. Is it possible to apply that to the inclusion of header files, rather than going and editing the header file itself? And do I need to use that when declaring the handle in my code? I’ll keep messing with it.

Thanks again, Theo.

I got it working just by using the following for the #include

  
extern "C" {  
#include "iWear/iweardrv.h"	/* for the IWEAR interface */  
}  

When things are cleaner and I’ve ported more of the app, I’ll make sure to post it.

Thanks again, Theo.