Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
curvedflats
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
6
Issues
6
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Flatland
curvedflats
Commits
9159b7bc
Commit
9159b7bc
authored
Aug 09, 2019
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some shader bugs & make path info appear at mouse point
parent
5112f241
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
22 deletions
+30
-22
OnePlaneBSP.shader
Assets/Cross Section Shader/Shaders/OnePlaneBSP.shader
+2
-2
Test.unity
Assets/Scenes/Test.unity
+12
-11
Constants.cs
Assets/Scripts/Constants.cs
+1
-1
UIManager.cs
Assets/Scripts/UIManager.cs
+15
-8
No files found.
Assets/Cross Section Shader/Shaders/OnePlaneBSP.shader
View file @
9159b7bc
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
((
y1
+
0
.
0
5
)
*
(
y1
+
0
.
05
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
));
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
((
y1
+
0
.
0
8
)
*
(
y1
+
0
.
08
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
));
//float dotProd1 = tmp.y;
//float dotProd1 = tmp.y;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
...
@@ -89,7 +89,7 @@
...
@@ -89,7 +89,7 @@
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
((
y1
+
0
.
0
5
)
*
(
y1
+
0
.
05
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
));
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
((
y1
+
0
.
0
8
)
*
(
y1
+
0
.
08
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
));
//float dotProd1 = tmp.y;
//float dotProd1 = tmp.y;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
...
...
Assets/Scenes/Test.unity
View file @
9159b7bc
...
@@ -26,7 +26,7 @@ RenderSettings:
...
@@ -26,7 +26,7 @@ RenderSettings:
m_AmbientIntensity
:
1
m_AmbientIntensity
:
1
m_AmbientMode
:
0
m_AmbientMode
:
0
m_SubtractiveShadowColor
:
{
r
:
0.42
,
g
:
0.478
,
b
:
0.627
,
a
:
1
}
m_SubtractiveShadowColor
:
{
r
:
0.42
,
g
:
0.478
,
b
:
0.627
,
a
:
1
}
m_SkyboxMaterial: {fileID:
10304, guid: 0000000000000000f000000000000000, type: 0
}
m_SkyboxMaterial
:
{
fileID
:
2100000
,
guid
:
c586755a7c8d6af4bb1944882f90197c
,
type
:
2
}
m_HaloStrength
:
0.5
m_HaloStrength
:
0.5
m_FlareStrength
:
1
m_FlareStrength
:
1
m_FlareFadeSpeed
:
3
m_FlareFadeSpeed
:
3
...
@@ -652,7 +652,8 @@ MonoBehaviour:
...
@@ -652,7 +652,8 @@ MonoBehaviour:
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
square
:
{
fileID
:
934514725
}
square
:
{
fileID
:
934514725
}
canvas: {fileID: 1193230060}
playercamera
:
{
fileID
:
1661408489
}
canvas
:
{
fileID
:
1193230064
}
mytime
:
{
fileID
:
1678224219
}
mytime
:
{
fileID
:
1678224219
}
wintext
:
{
fileID
:
512200287
}
wintext
:
{
fileID
:
512200287
}
_pathUI
:
{
fileID
:
1496132462
}
_pathUI
:
{
fileID
:
1496132462
}
...
@@ -737,7 +738,7 @@ MonoBehaviour:
...
@@ -737,7 +738,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
time: 0.
1
time
:
0.
02
leaveworldline
:
1
leaveworldline
:
1
---
!u!64
&439858919
---
!u!64
&439858919
MeshCollider
:
MeshCollider
:
...
@@ -1549,7 +1550,7 @@ MonoBehaviour:
...
@@ -1549,7 +1550,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
time: 0.
1
time
:
0.
02
leaveworldline
:
1
leaveworldline
:
1
---
!u!54
&839664888
---
!u!54
&839664888
Rigidbody
:
Rigidbody
:
...
@@ -2265,7 +2266,7 @@ RectTransform:
...
@@ -2265,7 +2266,7 @@ RectTransform:
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0.5
}
m_AnchoredPosition: {x: -79.45
, y: -10.800001
}
m_AnchoredPosition
:
{
x
:
-79.45
001
,
y
:
-10.799988
}
m_SizeDelta
:
{
x
:
99.9
,
y
:
30
}
m_SizeDelta
:
{
x
:
99.9
,
y
:
30
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
---
!u!114
&1034884447
---
!u!114
&1034884447
...
@@ -2966,7 +2967,7 @@ MonoBehaviour:
...
@@ -2966,7 +2967,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
d99664edeab700d4ca972d282f99515b
,
type
:
3
}
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
time: 0.
1
time
:
0.
02
leaveworldline
:
1
leaveworldline
:
1
---
!u!64
&1320474665
---
!u!64
&1320474665
MeshCollider
:
MeshCollider
:
...
@@ -3195,10 +3196,10 @@ RectTransform:
...
@@ -3195,10 +3196,10 @@ RectTransform:
m_RootOrder
:
6
m_RootOrder
:
6
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax: {x:
1, y: 1
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition: {x:
0, y: 0
}
m_AnchoredPosition
:
{
x
:
164
,
y
:
105
}
m_SizeDelta: {x:
-487.74, y: -318.42
}
m_SizeDelta
:
{
x
:
312.26
,
y
:
132.57999
}
m_Pivot: {x: 0
.5, y: 0.5
}
m_Pivot
:
{
x
:
0
,
y
:
0
}
---
!u!1
&1661408487
---
!u!1
&1661408487
GameObject
:
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -3278,7 +3279,7 @@ Transform:
...
@@ -3278,7 +3279,7 @@ Transform:
m_PrefabAsset
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1661408487
}
m_GameObject
:
{
fileID
:
1661408487
}
m_LocalRotation
:
{
x
:
0.7071068
,
y
:
-0
,
z
:
-0
,
w
:
0.7071068
}
m_LocalRotation
:
{
x
:
0.7071068
,
y
:
-0
,
z
:
-0
,
w
:
0.7071068
}
m_LocalPosition: {x: 0, y: 5, z: 0}
m_LocalPosition
:
{
x
:
0
,
y
:
5
0
,
z
:
0
}
m_LocalScale
:
{
x
:
1
,
y
:
0.1000003
,
z
:
1
}
m_LocalScale
:
{
x
:
1
,
y
:
0.1000003
,
z
:
1
}
m_Children
:
[]
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_Father
:
{
fileID
:
0
}
...
...
Assets/Scripts/Constants.cs
View file @
9159b7bc
...
@@ -4,7 +4,7 @@ using UnityEngine;
...
@@ -4,7 +4,7 @@ using UnityEngine;
public
static
class
Constants
public
static
class
Constants
{
{
public
static
double
c
=>
3
;
// speed of light.
public
static
double
c
=>
5
;
// speed of light.
public
static
double
Gamma
(
double
v
)
public
static
double
Gamma
(
double
v
)
{
{
return
1.0f
/
Mathf
.
Sqrt
((
1
-
(
float
)((
v
/
c
)
*
(
v
/
c
))));
return
1.0f
/
Mathf
.
Sqrt
((
1
-
(
float
)((
v
/
c
)
*
(
v
/
c
))));
...
...
Assets/Scripts/UIManager.cs
View file @
9159b7bc
...
@@ -12,7 +12,7 @@ public class UIManager : MonoBehaviour
...
@@ -12,7 +12,7 @@ public class UIManager : MonoBehaviour
[
SerializeField
]
[
SerializeField
]
Camera
playercamera
;
Camera
playercamera
;
public
GameObject
canvas
;
public
Canvas
canvas
;
public
Text
mytime
;
public
Text
mytime
;
//public Planemovement clock1;
//public Planemovement clock1;
//public Planemovement clock2;
//public Planemovement clock2;
...
@@ -45,15 +45,16 @@ public class UIManager : MonoBehaviour
...
@@ -45,15 +45,16 @@ public class UIManager : MonoBehaviour
}
}
if
(
Input
.
GetMouseButtonDown
(
0
))
if
(
Input
.
GetMouseButtonDown
(
0
))
{
{
RaycastHit
hit
;
RaycastHit
hit1
;
RaycastHit
hit2
;
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
if
(
Physics
.
Raycast
(
ray
,
out
hit
1
))
{
{
ray
=
playercamera
.
ViewportPointToRay
(
hit
.
textureCoord
);
ray
=
playercamera
.
ViewportPointToRay
(
hit
1
.
textureCoord
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
if
(
Physics
.
Raycast
(
ray
,
out
hit
2
))
{
{
var
obj
=
hit
.
collider
.
gameObject
;
var
obj
=
hit
2
.
collider
.
gameObject
;
if
(
obj
.
tag
==
"path"
)
if
(
obj
.
tag
==
"path"
)
{
{
...
@@ -63,8 +64,14 @@ public class UIManager : MonoBehaviour
...
@@ -63,8 +64,14 @@ public class UIManager : MonoBehaviour
{
{
pathName
.
text
=
obj
.
name
;
pathName
.
text
=
obj
.
name
;
//_pathUI.transform.position = middlePoint;
//_pathUI.transform.position = middlePoint;
_pathUI
.
transform
.
position
=
middlePoint
+
(
square
.
GetDestPoint
(
pathNum
)
+
new
Vector3
(
0
,
300
,
0
))
*
2.5f
;
var
tmp
=
Camera
.
main
.
WorldToScreenPoint
(
hit1
.
point
);
//Debug.Log(square.GetMiddlePoint(pathNum, pathNum + 1));
float
width
=
Screen
.
width
*
_pathUI
.
GetComponent
<
RectTransform
>().
anchorMin
.
x
;
float
height
=
Screen
.
height
*
_pathUI
.
GetComponent
<
RectTransform
>().
anchorMin
.
y
;
_pathUI
.
GetComponent
<
RectTransform
>().
anchoredPosition
=
new
Vector2
(
tmp
.
x
-
width
,
tmp
.
y
-
height
);
// see for reference: https://sushanta1991.blogspot.com/2016/04/how-to-move-unity-ui-using-mouse.html
// Also try using Camera.WorldtoViewportPoint() and Camera.WorldtoScreenPoint() to convert world coordinates to
// normalized viewport (x,y) or pixel coordinates)
_pathUI
.
SetActive
(
true
);
_pathUI
.
SetActive
(
true
);
prevSelectPathNum
=
pathNum
;
prevSelectPathNum
=
pathNum
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment