Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ARtest
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
Memory Box
ARtest
Commits
edb0739d
Commit
edb0739d
authored
Dec 17, 2017
by
stendler
Browse files
Options
Downloads
Patches
Plain Diff
advanced debug method
parent
4b82ed96
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/MemoryBox/arScene/Scripts/webCamScript.cs
+26
-9
26 additions, 9 deletions
Assets/MemoryBox/arScene/Scripts/webCamScript.cs
with
26 additions
and
9 deletions
Assets/MemoryBox/arScene/Scripts/webCamScript.cs
+
26
−
9
View file @
edb0739d
...
...
@@ -17,14 +17,20 @@ public class webCamScript : MonoBehaviour
// may need to situational based on rotation ?
GameObject
cameraParent
=
new
GameObject
(
"camParent"
);
cameraParent
.
transform
.
position
=
this
.
transform
.
position
;
this
.
transform
.
parent
=
cameraParent
.
transform
;
_debug
(
"camParent"
);
cameraParent
.
transform
.
position
=
transform
.
position
;
transform
.
parent
=
cameraParent
.
transform
;
if
(
Application
.
isMobilePlatform
)
{
cameraParent
.
transform
.
Rotate
(
Vector3
.
right
,
90
);
}
_debug
(
"camParent transformed"
);
Input
.
gyro
.
enabled
=
true
;
_debug
(
"gyro enabled"
);
_webCameraTexture
=
new
WebCamTexture
();
WebCameraPlane
.
GetComponent
<
Renderer
>().
material
.
mainTexture
=
_webCameraTexture
;
_webCameraTexture
.
filterMode
=
FilterMode
.
Trilinear
;
// quality >? performance
...
...
@@ -35,12 +41,16 @@ public class webCamScript : MonoBehaviour
// set webCamPanel screen size
PlaneResize
();
_debug
(
"Plane resized"
);
_webCameraTexture
.
Play
();
_debug
(
"camera plays"
);
}
public
void
PlaneResize
()
{
float
distance
=
Vector3
.
Distance
(
this
.
WebCameraPlane
.
transform
.
position
,
this
.
transform
.
position
);
float
distance
=
Vector3
.
Distance
(
WebCameraPlane
.
transform
.
position
,
transform
.
position
);
_debug
(
distance
);
Vector3
v3ViewPort
=
new
Vector3
(
0
,
0
,
distance
);
Vector3
v3BottomLeft
=
Camera
.
main
.
ViewportToWorldPoint
(
v3ViewPort
);
...
...
@@ -48,7 +58,7 @@ public class webCamScript : MonoBehaviour
Vector3
v3TopRight
=
Camera
.
main
.
ViewportToWorldPoint
(
v3ViewPort
);
_debug
(
v3BottomLeft
);
_debug
(
v3TopRight
);
this
.
WebCameraPlane
.
transform
.
localScale
=
new
Vector3
(-
v3BottomLeft
.
x
/
4
,
1
,
-
v3BottomLeft
.
y
/
4
);
WebCameraPlane
.
transform
.
localScale
=
new
Vector3
(-
v3BottomLeft
.
x
/
4
,
1
,
-
v3BottomLeft
.
y
/
4
);
if
(
_webCameraTexture
!=
null
&&
_camInitialized
)
RecalculateCameraResolution
();
...
...
@@ -78,7 +88,7 @@ public class webCamScript : MonoBehaviour
// update rotation per gyro
Quaternion
cameraRotation
=
new
Quaternion
(
Input
.
gyro
.
attitude
.
x
,
Input
.
gyro
.
attitude
.
y
,
-
Input
.
gyro
.
attitude
.
z
,
-
Input
.
gyro
.
attitude
.
w
);
this
.
transform
.
localRotation
=
cameraRotation
;
transform
.
localRotation
=
cameraRotation
;
}
else
{
...
...
@@ -91,10 +101,17 @@ public class webCamScript : MonoBehaviour
}
}
private
void
_debug
(
object
message
)
private
void
_debug
(
object
message
=
null
)
{
string
msg
=
message
.
ToString
();
Debug
.
Log
(
msg
);
this
.
DebugInfo
.
GetComponent
<
Text
>().
text
+=
msg
+
"\n"
;
if
(
message
==
null
)
message
=
" - "
;
_debug
(
message
.
ToString
());
}
private
void
_debug
(
string
message
)
{
message
=
"-- "
+
message
;
Debug
.
Log
(
message
);
DebugInfo
.
GetComponent
<
Text
>().
text
+=
message
+
"\n"
;
}
}
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