Skip to content

Commit

Permalink
0.07 externalcameraの設定先コントローラ選択追加
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-akira committed Aug 13, 2018
1 parent 8603790 commit c9ab42e
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 13 deletions.
9 changes: 9 additions & 0 deletions Assets/ExternalPlugins/OVRTracking/Scripts/TrackerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class TrackerHandler : MonoBehaviour
public GameObject HMDObject;
public GameObject LeftControllerObject;
public GameObject RightControllerObject;
public GameObject CameraControllerObject;
[System.NonSerialized]
public int CameraControllerIndex = -1;
[System.NonSerialized]
public List<GameObject> Trackers = new List<GameObject>();
public List<GameObject> TrackersObject = new List<GameObject>();
Expand Down Expand Up @@ -48,6 +51,12 @@ void Update()
var controllerPositions = positions[ETrackedDeviceClass.Controller];
if (controllerPositions.Any())
{
//externalcamera.cfg用のコントローラー設定
if (CameraControllerIndex >= 0 && CameraControllerIndex < controllerPositions.Count)
{
CameraControllerObject.transform.SetPositionAndRotation(controllerPositions[CameraControllerIndex]);
controllerPositions.RemoveAt(CameraControllerIndex);
}
LeftControllerObject.transform.SetPositionAndRotation(controllerPositions.FirstOrDefault());
if (controllerPositions.Count > 1)
{
Expand Down
116 changes: 116 additions & 0 deletions Assets/Scenes/VirtualMotionCapture.unity
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,91 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &24719457
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 24719458}
- component: {fileID: 24719461}
- component: {fileID: 24719460}
- component: {fileID: 24719459}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &24719458
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 24719457}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.08, y: 0.08, z: 0.2}
m_Children: []
m_Father: {fileID: 696852443}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &24719459
BoxCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 24719457}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &24719460
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 24719457}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &24719461
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 24719457}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &54464774
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -967,6 +1052,35 @@ Transform:
m_Father: {fileID: 1128534204}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &696852442
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 696852443}
m_Layer: 0
m_Name: CameraController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &696852443
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 696852442}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1, y: 1.3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 24719458}
m_Father: {fileID: 1128534204}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &716008275
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1293,6 +1407,7 @@ MonoBehaviour:
HMDObject: {fileID: 131724274}
LeftControllerObject: {fileID: 617002694}
RightControllerObject: {fileID: 1766301012}
CameraControllerObject: {fileID: 696852442}
TrackersObject:
- {fileID: 1682114101}
- {fileID: 1466831150}
Expand All @@ -1319,6 +1434,7 @@ Transform:
- {fileID: 801812189}
- {fileID: 1255601379}
- {fileID: 1653217472}
- {fileID: 696852443}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down
20 changes: 13 additions & 7 deletions Assets/Scripts/ControlWPFWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,16 @@ await mainThreadInvoker.InvokeAsync(async () =>
var d = (PipeCommands.SetExternalCameraConfig)e.Data;
//フリーカメラに変更
ChangeCamera(CameraTypes.Free);
//externalcamera.cfgはベースステーション基準のポジション
//いったんベースステーションの子にして座標指定したら、
currentCamera.transform.SetParent(handler.BaseStations[d.BaseStationIndex].transform);
//externalcamera.cfgは3つ目のコントローラー基準のポジション
handler.CameraControllerIndex = d.ControllerIndex;
//指定のコントローラーの子にして座標指定
currentCamera.transform.SetParent(handler.CameraControllerObject.transform);
currentCamera.transform.localPosition = new Vector3(d.x, d.y, d.z);
currentCamera.transform.localRotation = Quaternion.Euler(d.rx, d.ry, d.rz);
currentCamera.fieldOfView = d.fov;
//座標を維持したままルートに配置しなおす
currentCamera.transform.SetParent(null, true);
if (CurrentSettings.FreeCameraTransform == null) CurrentSettings.FreeCameraTransform = new StoreTransform(currentCamera.transform);
CurrentSettings.FreeCameraTransform.SetPosition(currentCamera.transform);
//コントローラーは動くのでカメラ位置の保存はできない
//if (CurrentSettings.FreeCameraTransform == null) CurrentSettings.FreeCameraTransform = new StoreTransform(currentCamera.transform);
//CurrentSettings.FreeCameraTransform.SetPosition(currentCamera.transform);
}
else if (e.CommandType == typeof(PipeCommands.LoadCurrentSettings))
{
Expand Down Expand Up @@ -455,6 +455,12 @@ private async void ImportVRM(string path, bool ImportForCalibration)
// ParseしたJSONをシーンオブジェクトに変換していく
CurrentModel = await VRMImporter.LoadVrmAsync(context);

//モデルのSkinnedMeshRendererがカリングされないように、すべてのオプション変更
foreach(var renderer in CurrentModel.GetComponentsInChildren<SkinnedMeshRenderer>(true))
{
renderer.updateWhenOffscreen = true;
}

//LipSync
LipSync.ImportVRMmodel(CurrentModel);
//まばたき
Expand Down
6 changes: 4 additions & 2 deletions ControlWindowWPF/ControlWindowWPF/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
<GroupBox Header="externalcamera.cfg(フリーカメラ座標を設定)">
<DockPanel>
<Button DockPanel.Dock="Bottom" Content="externalcamera.cfgを開く" Name="ExternalCameraConigButton" Click="ExternalCameraConigButton_Click" ToolTip="VRゲームにモデルを合成するためのexternalcamera.cfgを読み込んでフリーカメラに設定します"/>
<TextBlock Text="基準ベースステーション"/>
<ComboBox Name="BaseStationComboBox" SelectedIndex="0" ToolTip="externalcameraの基準になるベースステーションを選択(カメラがずれているときに変更してcfgファイルを開きなおしてください)">
<TextBlock Text="コントローラー番号"/>
<ComboBox Name="ControllerComboBox" SelectedIndex="0" ToolTip="externalcameraの基準になるコントローラーを選択(変更する際はcfgファイルを開きなおしてください)">
<ComboBoxItem>1</ComboBoxItem>
<ComboBoxItem>2</ComboBoxItem>
<ComboBoxItem>3</ComboBoxItem>
<ComboBoxItem>4</ComboBoxItem>
</ComboBox>
</DockPanel>
</GroupBox>
Expand Down
2 changes: 1 addition & 1 deletion ControlWindowWPF/ControlWindowWPF/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private async void ExternalCameraConigButton_Click(object sender, RoutedEventArg
var rz = GetFloat("rz");
var fov = GetFloat("fov");

await Globals.Client?.SendCommandAsync(new PipeCommands.SetExternalCameraConfig { x = x, y = y, z = z, rx = rx, ry = ry, rz = rz, fov = fov, BaseStationIndex = BaseStationComboBox.SelectedIndex });
await Globals.Client?.SendCommandAsync(new PipeCommands.SetExternalCameraConfig { x = x, y = y, z = z, rx = rx, ry = ry, rz = rz, fov = fov, ControllerIndex = ControllerComboBox.SelectedIndex });
}
}
}
Expand Down
Binary file not shown.
8 changes: 6 additions & 2 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.06.zipをダウンロードしてください。
ダウンロードはリリースページからVirtualMotionCapture0.07.zipをダウンロードしてください。
解凍後VirtualMotionCapture.exeを実行で開始します。


Expand Down Expand Up @@ -60,9 +60,12 @@ VR: HTC Vive + 3 tracker
・自身の状態をVR内にオーバーレイ表示

# 更新履歴
Ver 0.06
・externalcamera.cfgの設定先コントローラー変更に対応

Ver 0.06
・externalcamera.cfgファイルの読み込みに対応

Ver 0.05
・ショートカットキー機能
・ハンドジェスチャー設定
Expand Down Expand Up @@ -125,6 +128,7 @@ A.Homeは使用せずにゲームのインストールフォルダから直接ex
Q.externalcamera.cfgはどうやって設定するの?
A.みゅみゅさんの記事[【HTC Vive】コントローラ2本でクロマキー合成をする方法](https://qiita.com/miyumiyu/items/25deb3542e913750f519)を参照してください。
バーチャルモーションキャプチャーのカメラ標準はfov=60です。
実際にコントローラーを3つ繋いでいる場合は、3本目のコントローラーをカメラ代わりにすることができます。

Q.externalcamera.cfgの位置がおかしい
A.ベースステーション番号を変更して再度ファイルを開いてみてください。
Expand Down
2 changes: 1 addition & 1 deletion UnityNamedPipeCommand/PipeCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class SetExternalCameraConfig
public float ry { get; set; }
public float rz { get; set; }
public float fov { get; set; }
public int BaseStationIndex { get; set; }
public int ControllerIndex { get; set; }
}

public class ExitControlPanel { }
Expand Down

0 comments on commit c9ab42e

Please sign in to comment.