Skip to content

Commit

Permalink
2回目以降のキャリブレーション修正/Oculus Touch用説明文追加/同時押し後のKeyUp修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-akira committed Aug 20, 2018
1 parent e129f70 commit 029bb29
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 19 deletions.
5 changes: 4 additions & 1 deletion Assets/Scripts/Calibrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private static void CalibrateLeg(Settings settings, Transform FootTransform, IKS
leg.bendGoal = null;
leg.bendGoalWeight = 0f;
}

public static IEnumerator CalibrateScaled(Transform trackerRoot, VRIK ik, Settings settings, Transform HMDTransform, Transform PelvisTransform = null, Transform LeftHandTransform = null, Transform RightHandTransform = null, Transform LeftFootTransform = null, Transform RightFootTransform = null)
{
if (!ik.solver.initiated)
Expand All @@ -188,6 +188,9 @@ public static IEnumerator CalibrateScaled(Transform trackerRoot, VRIK ik, Settin
yield break;
}

//トラッカーのルートスケールを初期値に戻す
trackerRoot.localScale = new Vector3(1.0f, 1.0f, 1.0f);

// モデルのポジションを手と手の中心位置に移動
var centerposition = Vector3.Lerp(LeftHandTransform.position, RightHandTransform.position, 0.5f);
ik.references.root.position = new Vector3(centerposition.x, ik.references.root.position.y, centerposition.z);
Expand Down
52 changes: 51 additions & 1 deletion Assets/Scripts/ControlWPFWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,57 @@ private void CheckKey(KeyConfig config, bool isKeyDown)
}
if (enable)
{
DoKeyAction(action);
//手の操作の場合、別の手の操作キーが押されたままだったらそちらを優先して、離す処理は飛ばす
var skipKeyUp = false;

var doKeyActions = new List<KeyAction>();
foreach (var downaction in CurrentSettings.KeyActions?.OrderBy(d => d.KeyConfigs.Count()).Where(d => d.FaceAction == action.FaceAction && d.HandAction == action.HandAction && d.FunctionAction == action.FunctionAction))
{//キーの少ない順に実行して、同時押しと被ったとき同時押しを後から実行して上書きさせる
//if (action.KeyConfigs.Count == CurrentKeyConfigs.Count)
//{ //別々の機能を同時に押す場合もあるのでキーの数は見てはいけない
var downenable = true;
foreach (var key in downaction.KeyConfigs)
{
if (CurrentKeyConfigs.Where(d => d.IsEqualKeyCode(key) == true).Any() == false)
{
//キーが含まれてないとき
downenable = false;
}
}
if (downenable)
{//現在押してるキーの中にすべてのキーが含まれていた
if (downaction.IsKeyUp)
{
//キーを離す操作の時はキューに入れておく
CurrentKeyUpActions.Add(downaction);
}
else
{
doKeyActions.Add(downaction);
}
}
//}
}
if (doKeyActions.Any())
{
skipKeyUp = true; //優先処理があったので、KeyUpのActionは無効
var tmpDownActions = new List<KeyAction>(doKeyActions);
foreach (var downaction in tmpDownActions)
{
foreach (var target in tmpActions.Where(d => d != downaction))
{
if (target.KeyConfigs.ContainsArray(downaction.KeyConfigs))
{//更に複数押しのキー設定が有効な場合、少ないほうは無効(上書きされてしまうため)
doKeyActions.Remove(downaction);
}
}
}
foreach (var downaction in doKeyActions)
{//残った処理だけ実行
DoKeyAction(downaction);
}
}
if (skipKeyUp == false) DoKeyAction(action);
CurrentKeyUpActions.Remove(action);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/OVRControllerAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class OVRControllerAction : MonoBehaviour
{
public InputField inputField;
// public InputField inputField;

public EventHandler<OVRKeyEventArgs> KeyDownEvent;
public EventHandler<OVRKeyEventArgs> KeyUpEvent;
Expand Down
19 changes: 11 additions & 8 deletions ControlWindowWPF/ControlWindowWPF/ShortcutKeyWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
Title="ショートカットキー設定" SizeToContent="Height" Width="800">
<DockPanel>
<StackPanel Orientation="Vertical" DockPanel.Dock="Right">
<GroupBox Header="タッチパッドの割り当て状態">
<GroupBox Header="タッチパッド/スティックの割り当て状態">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical">
<GroupBox Header="左コントローラー">
<Grid>
<Image Width="150" Height="150" Name="LeftImage"/>
<Canvas Name="LeftCanvas" ToolTip="左タッチパッドの分割領域を設定します。四角いつまみをドラッグして大きさの変更ができます"/>
<Canvas Name="LeftCanvas" ToolTip="左タッチパッド/スティックの分割領域を設定します。四角いつまみをドラッグして大きさの変更ができます"/>
</Grid>
</GroupBox>
<CheckBox Content="センターキー" Name="LeftCenterKeyCheckBox" Checked="LeftCenterKeyCheckBox_Checked" Unchecked="LeftCenterKeyCheckBox_Unchecked" ToolTip="左タッチパッドの中心を円形のキーとして独立させます"/>
<CheckBox Content="センターキー" Name="LeftCenterKeyCheckBox" Checked="LeftCenterKeyCheckBox_Checked" Unchecked="LeftCenterKeyCheckBox_Unchecked" ToolTip="左タッチパッドの中心を円形のキーとして独立させます/Oculus Touchの無反応領域"/>
<DockPanel>
<TextBlock Text="分割数:" Margin="10,0,0,0"/>
<ScrollBar Height="30" Minimum="1" Maximum="30" Value="1" DockPanel.Dock="Right" Name="LeftTouchPadUpDown" ValueChanged="LeftTouchPadUpDown_ValueChanged" SmallChange="1" ToolTip="左コントローラーのタッチパッド分割数を指定します">
<ScrollBar Height="30" Minimum="1" Maximum="30" Value="1" DockPanel.Dock="Right" Name="LeftTouchPadUpDown" ValueChanged="LeftTouchPadUpDown_ValueChanged" SmallChange="1" ToolTip="左コントローラーのタッチパッド/スティック分割数を指定します">
<ScrollBar.LayoutTransform>
<RotateTransform Angle="180"/>
</ScrollBar.LayoutTransform>
Expand All @@ -33,13 +33,13 @@
<GroupBox Header="右コントローラー">
<Grid>
<Image Width="150" Height="150" Name="RightImage"/>
<Canvas Name="RightCanvas" ToolTip="右タッチパッドの分割領域を設定します。四角いつまみをドラッグして大きさの変更ができます"/>
<Canvas Name="RightCanvas" ToolTip="右タッチパッド/スティックの分割領域を設定します。四角いつまみをドラッグして大きさの変更ができます"/>
</Grid>
</GroupBox>
<CheckBox Content="センターキー" Name="RightCenterKeyCheckBox" Checked="RightCenterKeyCheckBox_Checked" Unchecked="RightCenterKeyCheckBox_Unchecked" ToolTip="右タッチパッドの中心を円形のキーとして独立させます"/>
<CheckBox Content="センターキー" Name="RightCenterKeyCheckBox" Checked="RightCenterKeyCheckBox_Checked" Unchecked="RightCenterKeyCheckBox_Unchecked" ToolTip="右タッチパッドの中心を円形のキーとして独立させます/Oculus Touchの無反応領域"/>
<DockPanel>
<TextBlock Text="分割数:" Margin="10,0,0,0"/>
<ScrollBar Height="30" Minimum="1" Maximum="30" Value="1" DockPanel.Dock="Right" Name="RightTouchPadUpDown" ValueChanged="RightTouchPadUpDown_ValueChanged" SmallChange="1" ToolTip="右コントローラーのタッチパッド分割数を指定します">
<ScrollBar Height="30" Minimum="1" Maximum="30" Value="1" DockPanel.Dock="Right" Name="RightTouchPadUpDown" ValueChanged="RightTouchPadUpDown_ValueChanged" SmallChange="1" ToolTip="右コントローラーのタッチパッド/スティック分割数を指定します">
<ScrollBar.LayoutTransform>
<RotateTransform Angle="180"/>
</ScrollBar.LayoutTransform>
Expand All @@ -48,7 +48,10 @@
</DockPanel>
</StackPanel>
</StackPanel>
<Button Content="適用" Name="TouchPadApplyButton" Click="TouchPadApplyButton_Click" HorizontalAlignment="Right" Width="100" IsEnabled="False" ToolTip="指定したタッチパッドの割り当てを保存します(保存しないと有効になりません)"/>
<DockPanel>
<Button DockPanel.Dock="Right" Content="適用" Name="TouchPadApplyButton" Click="TouchPadApplyButton_Click" Width="100" IsEnabled="False" ToolTip="指定したタッチパッドの割り当てを保存します(保存しないと有効になりません)"/>
<TextBlock Text="Oculus Touchはセンターキー領域がスティックの無反応領域になります" TextWrapping="Wrap" Width="170" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
</DockPanel>
</StackPanel>
</GroupBox>
<UniformGrid Rows="2" Columns="2">
Expand Down
Binary file not shown.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ VRMモデル読み込みを押して、任意のVRMモデルを読み込んで

# ダウンロード
リリースページ:[https://github.com/sh-akira/VirtualMotionCapture/releases]
ダウンロードはリリースページからVirtualMotionCapture0.07.zipをダウンロードしてください。
ダウンロードはリリースページからVirtualMotionCapture0.10.zipをダウンロードしてください。
解凍後VirtualMotionCapture.exeを実行で開始します。


Expand All @@ -52,14 +52,19 @@ VR: HTC Vive + 3 tracker
[@sh_akira](https://twitter.com/sh_akira)


●実装予定
・キャリブレーションの保存(複数起動を楽にしたい)
・足トラッカーがない場合の歩幅等の設定

●将来の実装予定
・自身の状態をVR内にオーバーレイ表示

# 更新履歴
Ver 0.10
・キャリブレーションの処理を変更しモデルのスケールをコントローラー位置にスケーリングするように
・Oculus Touchの入力とプリセットを追加
・キーの同時押しをしながら一部キーを離したときの処理を修正

Ver 0.09
・Oculus Touch確認のためにログ出力を入れた(テスト版)

Ver 0.08
・Oculus Touchの入力を暫定で入れた

Ver 0.07
・externalcamera.cfgの設定先コントローラー変更に対応
・カメラが近づいたときに顔が非表示になってしまう時がある問題修正
Expand Down Expand Up @@ -132,7 +137,10 @@ A.みゅみゅさんの記事[【HTC Vive】コントローラ2本でクロマ
実際にコントローラーを3つ繋いでいる場合は、3本目のコントローラーをカメラ代わりにすることができます。

Q.externalcamera.cfgの位置がおかしい
A.ベースステーション番号を変更して再度ファイルを開いてみてください。
A.コントローラー番号を変更して再度ファイルを開いてみてください。

Q.起動後に操作するとフリーズする
A.VirtualMotionCaputre.exeと同じフォルダにあるdefault.jsonを別のフォルダに移動し、起動後に設定の読込ボタンからdefault.jsonを開くようにすると回避できる場合があります

Q.支援先を教えてください
A.[欲しいものリスト](https://t.co/KPJRzn6sVR) ギフト送付先(akira.satoh.sh[アットマーク]gmail.com)
Expand Down

0 comments on commit 029bb29

Please sign in to comment.