Skip to content

Commit

Permalink
Support pos track on/off (mainly for debug purposes currently)
Browse files Browse the repository at this point in the history
  • Loading branch information
StellaArtois committed Aug 20, 2014
1 parent 61511f0 commit 545e58d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/com/mtbs3d/minecrift/MCOculus.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ public void update(float ipd,
@Override
public Vec3 getCenterEyePosition()
{
Vec3 eyePosition = Vec3.createVectorHelper(-ts.HeadPose.ThePose.Position.x, -ts.HeadPose.ThePose.Position.y, -ts.HeadPose.ThePose.Position.z);
Vec3 eyePosition = Vec3.createVectorHelper(0, 0, 0);
if (Minecraft.getMinecraft().vrSettings.usePositionTracking) {
eyePosition = Vec3.createVectorHelper(-ts.HeadPose.ThePose.Position.x, -ts.HeadPose.ThePose.Position.y, -ts.HeadPose.ThePose.Position.z);
}
eyePosition.zCoord += Minecraft.getMinecraft().vrSettings.eyeProtrusion;
eyePosition.rotateAroundY(-yawOffsetRad);
// TODO: Rotate around pitch offset
Expand All @@ -175,8 +178,11 @@ public Vec3 getCenterEyePosition()
public Vec3 getEyePosition(EyeType eye, float ipd)
{
//Minecraft.getMinecraft().printChatMessage("Eye: " + eye.toString() + ", IPD: " + -ipd);
Vector3f eyePos = super.getEyePos(eye);
Vec3 eyePosition = Vec3.createVectorHelper(-eyePos.x, -eyePos.y, -eyePos.z);
Vec3 eyePosition = Vec3.createVectorHelper(0, 0, 0);
if (Minecraft.getMinecraft().vrSettings.usePositionTracking) {
Vector3f eyePos = super.getEyePos(eye);
eyePosition = Vec3.createVectorHelper(-eyePos.x, -eyePos.y, -eyePos.z);
}
Vec3 ipdAdjust = Vec3.createVectorHelper(-ipd, 0, 0);
ipdAdjust.rotateAroundZ(rollHeadRad);
ipdAdjust.rotateAroundX(pitchHeadRad);
Expand Down
7 changes: 7 additions & 0 deletions src/com/mtbs3d/minecrift/gui/GuiHeadPositionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class GuiHeadPositionSettings extends BaseGuiSettings implements GuiEvent
};

static VRSettings.VrOptions[] oculusOptions = new VRSettings.VrOptions[] {
VRSettings.VrOptions.POSITION_TRACKING,
VRSettings.VrOptions.POS_TRACK_HIDE_COLLISION,
};

Expand Down Expand Up @@ -455,6 +456,12 @@ protected String[] getTooltipLines(String displayString, int buttonId)
" \\ Y /",
" |Y|"
};
case POSITION_TRACKING:
return new String[] {
"If position tracking should be enabled or not",
" OFF: No position tracking",
" ON: Position tracking enabled",
" Recommended: ON"} ;
// case POS_TRACK_Y_AXIS_DISTANCE_SKEW:
// return new String[] {
// "Explain this! Good luck!"
Expand Down
13 changes: 13 additions & 0 deletions src/com/mtbs3d/minecrift/settings/VRSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class VRSettings
public boolean useDistortion = true;
public boolean loadMumbleLib = true;
public boolean useHeadTracking = true;
public boolean usePositionTracking = true;
public boolean useHeadTrackPrediction = true;
public float headTrackPredictionTimeSecs = 0f;
protected float ipd = 0.0635F; // Use getIPD()
Expand Down Expand Up @@ -321,6 +322,11 @@ public void loadOptions(Reader reader)
this.useHeadTracking = optionTokens[1].equals("true");
}

if (optionTokens[0].equals("usePositionTracking"))
{
this.usePositionTracking = optionTokens[1].equals("true");
}

if (optionTokens[0].equals("useDistortion"))
{
this.useDistortion = optionTokens[1].equals("true");
Expand Down Expand Up @@ -818,6 +824,8 @@ public String getKeyBinding( VRSettings.VrOptions par1EnumOptions )
return this.loadMumbleLib ? var4 + "YES" : var4 + "NO";
case HEAD_TRACKING:
return this.useHeadTracking ? var4 + "ON" : var4 + "OFF";
case POSITION_TRACKING:
return this.usePositionTracking ? var4 + "ON" : var4 + "OFF";
case HEAD_TRACK_PREDICTION:
return this.useHeadTrackPrediction ? var4 + "ON" : var4 + "OFF";
case DELAYED_RENDER:
Expand Down Expand Up @@ -1198,6 +1206,9 @@ public void setOptionValue(VRSettings.VrOptions par1EnumOptions, int par2)
case HEAD_TRACKING:
this.useHeadTracking = !this.useHeadTracking;
break;
case POSITION_TRACKING:
this.usePositionTracking = !this.usePositionTracking;
break;
case DELAYED_RENDER:
this.frameTimingEnableVsyncSleep = !this.frameTimingEnableVsyncSleep;
break;
Expand Down Expand Up @@ -1627,6 +1638,7 @@ private void saveOptions(Writer writer)
var5.println("headTrackPredictionTimeSecs:" + this.headTrackPredictionTimeSecs);
var5.println("hudOpacity:" + this.hudOpacity);
var5.println("useHeadTracking:" + this.useHeadTracking);
var5.println("usePositionTracking:" + this.usePositionTracking);
var5.println("useDistortion:" + this.useDistortion);
var5.println("loadMumbleLib:" + this.loadMumbleLib);
var5.println("useHeadTrackPrediction:" + this.useHeadTrackPrediction);
Expand Down Expand Up @@ -1827,6 +1839,7 @@ public static enum VrOptions
HUD_OCCLUSION("HUD Occlusion", false, true),
SOUND_ORIENT("Sound Source", false, true),
HEAD_TRACKING("Head Tracking", false, true),
POSITION_TRACKING("Position Tracking", false, true),
DUMMY("Dummy", false, true),
VR_RENDERER("Stereo Renderer", false, true),
VR_HEAD_ORIENTATION("Head Orientation", false, true),
Expand Down

0 comments on commit 545e58d

Please sign in to comment.