Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

画面左右でスケルトンのボーン表示がColor画像からずれる問題を修正 #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,11 @@ private Vector3 GetVector3FromJoint(Kinect.Joint joint)
// KinectのCamera座標系(3次元)をColor座標系(2次元)に変換する
var point =_CoordinateMapper.MapCameraPointToColorSpace( joint.Position );
var point2 = new Vector3( point.X, point.Y, 0 );
if ( (0<= point2.x) && (point2.x < SensorWidth) && (0 <= point2.y) && (point2.y < SensorHeight) ) {
// スクリーンサイズで調整(Kinect->Unity)
point2.x = point2.x * Screen.width / SensorWidth;
point2.y = point2.y * Screen.height / SensorHeight;
if ((0 <= point2.x) && (point2.x < SensorWidth) && (0 <= point2.y) && (point2.y < SensorHeight)){

//Quadの大きさに合わせてスケーリング
var colorPoint3 = new Vector3(point2.x * 16 / 1920, point2.y * 9 / 1080, 0);

// Unityのワールド座標系(3次元)に変換
var colorPoint3 = _Camera.ScreenToWorldPoint( point2 );

// 座標の調整
// Y座標は逆、Z座標は0にする(Xもミラー状態によって逆にする必要あり)
Expand Down
6 changes: 3 additions & 3 deletions CoodinateMapKinectToUnity/Assets/Scenes/CoodinateSample.unity
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ NavMeshSettings:
minRegionArea: 2
widthInaccuracy: 16.666666
heightInaccuracy: 10
tileSizeHint: 0
m_NavMesh: {fileID: 0}
--- !u!1 &236295980
GameObject:
Expand Down Expand Up @@ -227,7 +228,6 @@ MonoBehaviour:
BoneMaterial: {fileID: 2100000, guid: f2ea145c63353784985576f08398a815, type: 2}
BodySourceManager: {fileID: 236295980}
Camera: {fileID: 1045325165}
IsCoodinateColor: 1
--- !u!4 &729636175
Transform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -389,7 +389,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 985433717}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 8, y: -4.5, z: 0}
m_LocalScale: {x: 16, y: 9, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down Expand Up @@ -646,7 +646,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1874380095}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -7.5}
m_LocalPosition: {x: 8, y: -4.5, z: -7.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
--- !u!30 &1
GraphicsSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_AlwaysIncludedShaders:
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}