Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test_vr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
florian.hassler
test_vr
Commits
4f1b7ace
Commit
4f1b7ace
authored
6 years ago
by
florian.hassler
Browse files
Options
Downloads
Patches
Plain Diff
better full circle detection and real time tracking
parent
c95e3237
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test_vr_unity/Assets/Scripts/testTouch/HandController.cs
+73
-53
73 additions, 53 deletions
test_vr_unity/Assets/Scripts/testTouch/HandController.cs
with
73 additions
and
53 deletions
test_vr_unity/Assets/Scripts/testTouch/HandController.cs
+
73
−
53
View file @
4f1b7ace
...
...
@@ -88,11 +88,8 @@ public class HandController : MonoBehaviour
LastPosition
=
currentPosition
;
displayPoint
(
false
,
rightHandPosition
);
if
(
checkFullRotation
(
currentPosition
))
{
trackHand
=
!
trackHand
;
EndTracking
();
}
}
// display position for debug purpose
...
...
@@ -118,7 +115,9 @@ public class HandController : MonoBehaviour
if
(
left
)
{
o
.
GetComponent
<
Renderer
>().
material
.
color
=
Color
.
green
;
}
else
{
}
else
{
o
.
GetComponent
<
Renderer
>().
material
.
color
=
Color
.
blue
;
}
o
.
transform
.
position
=
pos
;
...
...
@@ -189,9 +188,30 @@ public class HandController : MonoBehaviour
SpeedText
.
text
=
"Speed"
+
(
average
/
Speed
.
Count
).
ToString
();
}
bool
fullRotation
=
false
;
// Update is called once per frame
void
Update
()
{
if
(
fullRotation
)
{
if
(
CheckCircle
(
rightHandGesture
))
{
Msg
.
text
=
"Circle OK!"
;
DetermineCircleDirection
();
}
else
{
Msg
.
text
=
"Circle KO!"
;
}
RemovePoints
();
trackHand
=
!
trackHand
;
beginTracking
();
fullRotation
=
false
;
}
//left hand actions
OnButtonAPushed
();
OnButtonBPushed
();
...
...
@@ -200,23 +220,21 @@ public class HandController : MonoBehaviour
HandTracking
();
if
(
CheckCircle
(
rightHandGesture
))
if
(
trackHand
&&
checkFullRotation
(
LastPosition
))
{
Msg
.
text
=
"Circle OK!"
;
DetermineCircleDirection
();
trackHand
=
!
trackHand
;
EndTracking
();
fullRotation
=
true
;
}
}
else
{
Msg
.
text
=
"Circle KO!"
;
}
}
void
OnButtonBPushed
()
{
if
(
OVRInput
.
GetDown
(
OVRInput
.
Button
.
Two
)){
if
(
OVRInput
.
GetDown
(
OVRInput
.
Button
.
Two
))
{
OVRManager
.
display
.
RecenterPose
();
Debug
.
Log
(
"Recenter head pose"
);
}
...
...
@@ -252,7 +270,7 @@ public class HandController : MonoBehaviour
else
{
EndTracking
();
SpeedText
.
text
=
GetAngle
(
rightHandGesture
[
rightHandGesture
.
Count
-
1
]
,
rightHandGesture
[
0
]
).
ToString
();
SpeedText
.
text
=
GetAngle
(
rightHandGesture
[
0
],
rightHandGesture
[
rightHandGesture
.
Count
-
1
]).
ToString
();
//checkFullRotation(rightHandGesture[rightHandGesture.Count - 1]);
}
...
...
@@ -260,10 +278,11 @@ public class HandController : MonoBehaviour
}
public
float
GetAngle
(
Vector2
point
,
Vector2
center
)
public
float
GetAngle
(
Vector2
a
,
Vector2
b
)
{
Vector2
relPoint
=
point
-
center
;
return
(
Mathf
.
Atan2
(
relPoint
.
y
,
relPoint
.
x
)*
Mathf
.
Rad2Deg
+
450f
)
%
360f
;
return
Vector2
.
Distance
(
a
,
b
);
// return Mathf.Acos(Vector2.Dot(a.normalized, b.normalized)) * Mathf.Rad2Deg;
}
...
...
@@ -290,10 +309,7 @@ public class HandController : MonoBehaviour
Vector2
firstPoint
=
rightHandGesture
[
0
];
float
dist
=
Vector2
.
Distance
(
currentPosition
,
firstPoint
);
float
angle
=
Vector2
.
Angle
(
firstPoint
.
normalized
,
currentPosition
.
normalized
);
angle
=
Quaternion
.
FromToRotation
(
Vector2
.
up
,
currentPosition
-
firstPoint
).
eulerAngles
.
z
;
float
FullAngle
=
Mathf
.
Sign
(
Vector3
.
Cross
(
firstPoint
.
normalized
,
currentPosition
.
normalized
).
z
)
<
0
?
(
360
-
angle
)
%
360
:
angle
;
if
(
FullAngle
>=
358
)
if
(
dist
<
0.05
)
return
true
;
}
...
...
@@ -318,7 +334,8 @@ public class HandController : MonoBehaviour
if
(
res
)
{
cntClockwise
++;
}
else
}
else
{
cntAntiClockwise
++;
}
...
...
@@ -329,7 +346,8 @@ public class HandController : MonoBehaviour
if
(
cntClockwise
>
cntAntiClockwise
)
{
Msg
.
text
+=
" clockwise rotation"
;
}
else
if
(
cntAntiClockwise
>
cntClockwise
)
}
else
if
(
cntAntiClockwise
>
cntClockwise
)
{
Msg
.
text
+=
" anti Clockwise rotation"
;
}
...
...
@@ -342,17 +360,19 @@ public class HandController : MonoBehaviour
void
OnButtonXPushed
()
{
if
(
OVRInput
.
GetDown
(
OVRInput
.
Button
.
Three
))
{
RemovePoints
();
}
}
private
void
RemovePoints
()
{
Debug
.
Log
(
"Remove points"
);
foreach
(
GameObject
point
in
points
)
Destroy
(
point
);
points
.
Clear
();
}
}
void
HandTracking2
()
{
debugLeftHand
.
text
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment