Skip to content

Commit

Permalink
Oculus updates
Browse files Browse the repository at this point in the history
  • Loading branch information
m1keall1son committed Jul 3, 2016
1 parent bbd713a commit 22bc67f
Show file tree
Hide file tree
Showing 13 changed files with 178 additions and 45 deletions.
2 changes: 1 addition & 1 deletion CloudsLibrary/src/Core/CloudsCalibrationNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void CalibrationNode::updateWorldPosition(){
void CalibrationNode::updateScreenPosition(){

#ifdef OCULUS_RIFT
ofRectangle viewport = CloudsVisualSystem::getOculusRift().getOculusViewport();
ofRectangle viewport = CloudsVisualSystem::getOculusRift().getViewport();
ofVec3f screenPos = CloudsVisualSystem::getOculusRift().worldToScreen(worldPosition);
screenPosition = ofVec2f(screenPos.x,screenPos.y);
cursorDirection = screenPosition - viewport.getCenter();
Expand Down
15 changes: 14 additions & 1 deletion CloudsLibrary/src/Core/CloudsPlaybackController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,17 @@ void CloudsPlaybackController::update(ofEventArgs & args){

updateTransition();

//OCULUS CONTROLS
#ifdef OCULUS_RIFT
if(CloudsVisualSystem::getOculusRift().getButtonClicked(ovrButton_Enter) && bShowingAct && currentVisualSystem != clusterMap){
hud.togglePause();
}
if(CloudsVisualSystem::getOculusRift().getButtonClicked(ovrButton_Right) && currentVisualSystem != clusterMap){
keyedToNext = true;
}
//TODO: make more complete by adding back button & volume controls
#endif

}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -1824,7 +1835,8 @@ void CloudsPlaybackController::clearRenderTarget(){

//--------------------------------------------------------------------
bool CloudsPlaybackController::updateInterludeInterface(){


/*
#ifdef OCULUS_RIFT
interludeContinueSelected = interludeHoveringContinue;
interludeResetSelected = interludeHoveringReset;
Expand All @@ -1842,6 +1854,7 @@ bool CloudsPlaybackController::updateInterludeInterface(){
return true;
}
#endif
*/
return false;

}
Expand Down
7 changes: 5 additions & 2 deletions CloudsLibrary/src/Input/CloudsInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ void CloudsInput::selfDrawCursorDefault(CloudsCursorMode mode, ofVec3f& pos, boo
ofLine(pos.x + size, pos.y, pos.x + size - lineLength, pos.y);
ofLine(pos.x, pos.y - size, pos.x, pos.y - size + lineLength);
ofLine(pos.x, pos.y + size, pos.x, pos.y + size - lineLength);
ofFill();
ofCircle(pos, 1);
#else
ofFill();
ofCircle(pos, .22);
#endif

ofFill();
ofCircle(pos, 1);
}


Expand Down
2 changes: 2 additions & 0 deletions CloudsLibrary/src/Input/CloudsInputOculus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ void CloudsInputOculus::disable(){
void CloudsInputOculus::update(ofEventArgs& data){
lastPosition = currentPosition;
currentPosition = (CloudsVisualSystem::getOculusRift().gazePosition2D());
//HACK to remove camera drift
//currentPosition = ofVec3f(0,0,0);
if (currentPosition.distance(lastPosition) > 0) {
interactionMoved(currentPosition, true, false, 0);
}
Expand Down
38 changes: 30 additions & 8 deletions CloudsLibrary/src/RGBD/CloudsVisualSystemRGBD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void CloudsVisualSystemRGBD::selfSetup(){
portals.push_back(&resetPortal);
resetPortal.setup();
resetPortal.cam = &cloudsCamera;
//resetPortal.cam = &getOculusRift().getTransformedCamera();
resetPortal.bLookAtCamera = true;
resetPortal.question = "QUIT";
#endif
Expand Down Expand Up @@ -1175,20 +1176,41 @@ void CloudsVisualSystemRGBD::updateQuestions(){
for(int i = 0; i < portals.size(); i++){

portals[i]->update();

if(!portals[i]->onScreen || portals[i]->question == ""){
#ifndef OCULUS_RIFT

if( !portals[i]->onScreen || portals[i]->question == ""){
continue;
}

ofVec2f mouseNode(GetCloudsInputX(),GetCloudsInputY());
float distanceToQuestion = portals[i]->screenPosition.distance(mouseNode);

#else

if( portals[i]->question == ""){
continue;
}

#ifdef OCULUS_RIFT

ofNode n;
n.setOrientation(getOculusRift().getOrientationQuat());
n.setPosition(getOculusRift().getTranslation());
float dotproduct = n.getLookAtDir().dot(n.getPosition() - portals[i]->hoverPosition);
//not on screen
if(dotproduct < 0){
continue;
}
//if(portals[i]->question == "QUIT"){
// cout << "dot " << dotproduct << endl;
//}

ofVec3f screenPos = getOculusRift().worldToScreen(portals[i]->hoverPosition);
ofRectangle viewport = getOculusRift().getOculusViewport();

ofRectangle viewport = getOculusRift().getViewport();
float distanceToQuestion = ofDist(screenPos.x, screenPos.y,
viewport.getCenter().x, viewport.getCenter().y);

#else
ofVec2f mouseNode(GetCloudsInputX(),GetCloudsInputY());
float distanceToQuestion = portals[i]->screenPosition.distance(mouseNode);
//cout << "DISTANCE IS " << distanceToQuestion << endl;

#endif

////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ void CloudsVisualSystemClusterMap::updateQuestions(){

#ifdef OCULUS_RIFT
ofVec3f screenPos = getOculusRift().worldToScreen(curQuestion.hoverPosition);
ofRectangle viewport = getOculusRift().getOculusViewport();
ofRectangle viewport = getOculusRift().getViewport();
float distanceToQuestion = ofDist(screenPos.x, screenPos.y,viewport.getCenter().x, viewport.getCenter().y);
#else
ofVec2f mouseNode = cursor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ void CloudsIntroSequence::updateQuestions(){
#ifdef OCULUS_RIFT
if(curQuestion.hoverPosition.z - warpCamera.getPosition().z < questionMinZGrabDistance || &curQuestion == caughtQuestion){
ofVec3f screenPos = getOculusRift().worldToScreen(curQuestion.hoverPosition);
ofRectangle viewport = getOculusRift().getOculusViewport();
ofRectangle viewport = getOculusRift().getViewport();
float distanceToQuestion = ofDist(screenPos.x, screenPos.y,viewport.getCenter().x, viewport.getCenter().y);
#else
if(curQuestion.hoverPosition.z - warpCamera.getPosition().z < questionZStopRange.max || &curQuestion == caughtQuestion){
Expand Down
13 changes: 10 additions & 3 deletions CloudsLibrary/src/VisualSystemsLibrary/CloudsRGBDCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,14 @@ void CloudsRGBDCamera::setCanvasWidthHeight(float width, float height ){

void CloudsRGBDCamera::setPositionFromMouse(){

#ifdef OCULUS_RIFT
float percentOnCurve = .5;
float liftDrift = 0;
#else
float percentOnCurve = ofMap(GetCloudsInputX(), canvasWidth*.2, canvasWidth*.8, 0, 1, true);
float liftDrift = ofMap(GetCloudsInputY(), canvasHeight*.2, canvasHeight*.8, -liftRange,liftRange, true);

#endif
ofVec3f sidePositionLeft = lookTarget + ofVec3f(-sideDistance,0,sidePullback);
ofVec3f sidePositionRight = lookTarget + ofVec3f( sideDistance,0,sidePullback);
ofVec3f frontPosition = lookTarget + ofVec3f(0,0,-frontDistance);
Expand All @@ -124,8 +131,7 @@ void CloudsRGBDCamera::setPositionFromMouse(){
else{
position = sidePositionLeft.getInterpolated(frontPosition, ofMap(percentOnCurve, 0, .5, 0, 1.0) );
}

float liftDrift = ofMap(GetCloudsInputY(), canvasHeight*.2, canvasHeight*.8, -liftRange,liftRange, true);

position.y += ofMap(abs(.5 - percentOnCurve), 0, .5, (liftDrift + liftAmount), (liftDrift-liftAmount)*.5);
position.z -= MAX(liftDrift,0) * .5; // zoom in on mouse up

Expand All @@ -139,6 +145,7 @@ void CloudsRGBDCamera::setPositionFromMouse(){
ofVec3f driftPosition = currentPosition;
float channelA = 1000;
float channelB = 1500;
#ifndef OCULUS_RIFT
if(maxDriftAngle > 0){
ofVec3f toCamera = currentPosition - currentLookTarget;
ofQuaternion driftQuatX,driftQuatY;
Expand All @@ -154,7 +161,7 @@ void CloudsRGBDCamera::setPositionFromMouse(){
// driftQuatY.makeRotate(maxDriftAngle*driftY, 1, 0, 0);
// driftOffset = driftQuatX * driftQuatY * (ofVec3f(0,0,1) * toCamera.length());
}

#endif
mouseBasedNode.setPosition(driftPosition);
mouseBasedNode.lookAt(currentLookTarget, ofVec3f(0,1,0));

Expand Down
20 changes: 14 additions & 6 deletions CloudsLibrary/src/VisualSystemsLibrary/CloudsVisualSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static ofVideoPlayer* selectLow = NULL;

static ofxFTGLFont subtitleNameFont;
static int subtitleNameFontSize = 24;
static float playerScale = 30.0;
float CloudsVisualSystem::subtitleHudZ = -300;
float CloudsVisualSystem::subtitleHudScale = 1.0;

Expand Down Expand Up @@ -308,8 +309,8 @@ ofFbo& CloudsVisualSystem::getSharedRenderTarget(){
#ifdef OCULUS_RIFT
// int targetWidth = 1920/2;
// int targetHeight = 1080;
int targetWidth = getOculusRift().getOculusViewport().getWidth();
int targetHeight = getOculusRift().getOculusViewport().getHeight();
int targetWidth = getOculusRift().getViewport().getWidth();
int targetHeight = getOculusRift().getViewport().getHeight();
// cout << "OCULUS VIEWPORT " << targetWidth << " " << targetHeight << endl;

#else
Expand Down Expand Up @@ -563,6 +564,11 @@ void CloudsVisualSystem::update(ofEventArgs & args)

#ifdef OCULUS_RIFT
getOculusRift().baseCamera = &getCameraRef();
#ifdef OCULUS_RIFT
//TODO: Make dynamic
getOculusRift().setPlayerScale(playerScale);
#endif

#endif

for(vector<ofx1DExtruder *>::iterator it = extruders.begin(); it != extruders.end(); ++it){
Expand All @@ -582,7 +588,7 @@ void CloudsVisualSystem::update(ofEventArgs & args)
selfUpdate();
#ifdef OCULUS_RIFT
if(isInterlude){
updateInterludeInterface();
//updateInterludeInterface();
}
#endif
if(bMatchBackgrounds) {
Expand Down Expand Up @@ -862,7 +868,7 @@ void CloudsVisualSystem::drawScene(){

#ifdef OCULUS_RIFT
if(isInterlude){
drawInterludeInterface();
//drawInterludeInterface();
}
draw3DCursor();
#endif
Expand Down Expand Up @@ -968,7 +974,7 @@ void CloudsVisualSystem::draw3DCursor(){

ofEnableAlphaBlending();

ofVec3f cursorPt = ofVec3f(0, 0, -150);
ofVec3f cursorPt = ofVec3f(0, 0, subtitle3DBasePosZ);
selfDrawCursor(cursorPt, false, primaryCursorMode);

glPopAttrib();
Expand Down Expand Up @@ -1340,7 +1346,7 @@ void CloudsVisualSystem::mouseMoved(ofMouseEventArgs& data)
{
#ifdef OCULUS_RIFT
// Remap the mouse coords.
ofRectangle viewport = getOculusRift().getOculusViewport();
ofRectangle viewport = getOculusRift().getViewport();
// cout << "MOUSE IN: " << data.x << ", " << data.y << " // VIEWPORT: " << viewport.x << ", " << viewport.y << ", " << viewport.width << ", " << viewport.height;
data.x = ofMap(data.x, 0, ofGetWidth(), viewport.x, viewport.width);
data.y = ofMap(data.y, 0, ofGetHeight(), viewport.y, viewport.height);
Expand Down Expand Up @@ -1918,6 +1924,7 @@ void CloudsVisualSystem::setupCameraGui()
camGui->addToggle("Invert Spin Axis", &bInvertCameraSpinAxis);


camGui->addMinimalSlider("Oculus Player Scale", 1.0, 300, &playerScale);
camGui->addSpacer();

vector<string> transitions;
Expand All @@ -1943,6 +1950,7 @@ void CloudsVisualSystem::setupCameraGui()
ddl->setShowCurrentSelected(true);
ddl->activateToggle("DISABLE");


selfSetupCameraGui();

camGui->autoSizeToFitWidgets();
Expand Down
9 changes: 1 addition & 8 deletions CloudsLibrary/src/VisualSystemsLibrary/CloudsVisualSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,7 @@ class CloudsVisualSystem {

#ifdef OCULUS_RIFT
void setupOculusGui();
void guiOculusEvent(ofxUIEventArgs &e);

//#ifdef CLOUDS_HUD
// CloudsHUDController* hud;
// void setupHUDGui();
// void guiHUDEvent(ofxUIEventArgs &e);
//#endif

void guiOculusEvent(ofxUIEventArgs &e);
#endif

//Lighting Helpers
Expand Down
12 changes: 4 additions & 8 deletions OculusDirectTest/OculusDirectTest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@ Global
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug_Oculus|Win32.ActiveCfg = Debug|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug_Oculus|Win32.Build.0 = Debug|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug_Oculus|Win32.ActiveCfg = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug_Oculus|x64.ActiveCfg = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug_Oculus|x64.Build.0 = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release_Oculus|Win32.ActiveCfg = Release|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release_Oculus|Win32.Build.0 = Release|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release_Oculus|Win32.ActiveCfg = Release|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release_Oculus|x64.ActiveCfg = Release|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release_Oculus|x64.Build.0 = Release|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64
{5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64
{7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug_Oculus|Win32.ActiveCfg = Debug_Oculus|x64
Expand Down
Loading

0 comments on commit 22bc67f

Please sign in to comment.