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
5112f241
Commit
5112f241
authored
Aug 08, 2019
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pathrenderer bug fix - now works even when moving, as long as it's inertial
parent
bfffc737
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
56 additions
and
48 deletions
+56
-48
Object1Mat.mat
...ts/Cross Section Shader/Examples/Materials/Object1Mat.mat
+2
-2
OnePlaneCrossSection.mat
...ection Shader/Examples/Materials/OnePlaneCrossSection.mat
+1
-1
PlayerMaterial.mat
...ross Section Shader/Examples/Materials/PlayerMaterial.mat
+1
-1
OnePlaneBSP.shader
Assets/Cross Section Shader/Shaders/OnePlaneBSP.shader
+3
-3
Test.unity
Assets/Scenes/Test.unity
+2
-2
CameraMovement.cs
Assets/Scripts/CameraMovement.cs
+2
-2
Constants.cs
Assets/Scripts/Constants.cs
+2
-2
PathRenderer.cs
Assets/Scripts/PathRenderer.cs
+8
-6
Planemovement.cs
Assets/Scripts/Planemovement.cs
+4
-4
PlayerMovement.cs
Assets/Scripts/PlayerMovement.cs
+5
-5
ScreenMovement.cs
Assets/Scripts/ScreenMovement.cs
+1
-1
Square.cs
Assets/Scripts/Square.cs
+1
-1
UIManager.cs
Assets/Scripts/UIManager.cs
+24
-18
No files found.
Assets/Cross Section Shader/Examples/Materials/Object1Mat.mat
View file @
5112f241
...
...
@@ -61,7 +61,7 @@ Material:
-
_DetailNormalMapScale
:
1
-
_DstBlend
:
0
-
_GlossMapScale
:
1
-
_Glossiness
:
0
.5
-
_Glossiness
:
0
-
_GlossyReflections
:
1
-
_Metallic
:
0
-
_Mode
:
0
...
...
@@ -74,7 +74,7 @@ Material:
-
_UVSec
:
0
-
_ZWrite
:
1
m_Colors
:
-
_Color
:
{
r
:
1
,
g
:
1
,
b
:
1
,
a
:
1
}
-
_Color
:
{
r
:
0
,
g
:
0
,
b
:
1
,
a
:
1
}
-
_CrossColor
:
{
r
:
0
,
g
:
0
,
b
:
1
,
a
:
1
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
-
_PlaneNormal
:
{
r
:
0
,
g
:
1
,
b
:
0
,
a
:
0
}
...
...
Assets/Cross Section Shader/Examples/Materials/OnePlaneCrossSection.mat
View file @
5112f241
...
...
@@ -60,7 +60,7 @@ Material:
-
_Cutoff
:
0.5
-
_DetailNormalMapScale
:
1
-
_DstBlend
:
0
-
_Glossiness
:
0
.5
-
_Glossiness
:
0
-
_Metallic
:
0
-
_Mode
:
0
-
_OcclusionStrength
:
1
...
...
Assets/Cross Section Shader/Examples/Materials/PlayerMaterial.mat
View file @
5112f241
...
...
@@ -61,7 +61,7 @@ Material:
-
_DetailNormalMapScale
:
1
-
_DstBlend
:
0
-
_GlossMapScale
:
1
-
_Glossiness
:
0
.5
-
_Glossiness
:
0
-
_GlossyReflections
:
1
-
_Metallic
:
0
-
_Mode
:
0
...
...
Assets/Cross Section Shader/Shaders/OnePlaneBSP.shader
View file @
5112f241
...
...
@@ -50,7 +50,7 @@
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
(
y1
*
y1
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
(
(
y1
+
0
.
05
)
*
(
y1
+
0
.
05
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
)
);
//float dotProd1 = tmp.y;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
...
...
@@ -88,8 +88,8 @@
//float3 tmp2 = { 0.0, worldPos.y - 0.05, 0.0 };
float
x1
=
abs
(
worldPos
.
x
-
_PlanePosition
.
x
);
float
z1
=
abs
(
worldPos
.
z
-
_PlanePosition
.
z
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
+
0
.
05
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
(
y1
*
y1
);
float
y1
=
abs
(
_PlanePosition
.
y
-
worldPos
.
y
);
bool
wow
=
((
x1
*
x1
)
+
(
z1
*
z1
))
<
(
(
y1
+
0
.
05
)
*
(
y1
+
0
.
05
))
&&
((
x1
*
x1
)
+
(
z1
*
z1
))
>
((
y1
)
*
(
y1
)
);
//float dotProd1 = tmp.y;
return
(
worldPos
.
y
>
_PlanePosition
.
y
)
||
!
wow
;
//float dotProd1 = dot(worldPos - _PlanePosition, _PlaneNormal);
...
...
Assets/Scenes/Test.unity
View file @
5112f241
...
...
@@ -1390,7 +1390,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
1980459831
,
guid
:
f70555f144d8491a825f0804e09c671c
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
m_UiScaleMode
:
2
m_UiScaleMode
:
1
m_ReferencePixelsPerUnit
:
100
m_ScaleFactor
:
1
m_ReferenceResolution
:
{
x
:
800
,
y
:
600
}
...
...
@@ -3705,7 +3705,7 @@ MeshRenderer:
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
1756789504
}
m_Enabled
:
1
m_Enabled
:
0
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
...
...
Assets/Scripts/CameraMovement.cs
View file @
5112f241
...
...
@@ -37,13 +37,13 @@ public class CameraMovement : MonoBehaviour
transform
.
rotation
=
Quaternion
.
LookRotation
(-
vt
,
newforward
);
thecamera
.
orthographicSize
=
10.0f
*
((
float
)
Levelmanager
.
player
.
gamma
);
thecamera
.
orthographicSize
=
10.0f
*
((
float
)
Levelmanager
.
player
.
gamma
);
// number is size of camera
aspect
=
16.0f
/
(
9.0f
*
(
Levelmanager
.
player
.
gamma
));
thecamera
.
aspect
=
(
float
)
aspect
;
transform
.
Translate
(-
Vector3
.
forward
*
5
);
transform
.
Translate
(-
Vector3
.
forward
*
5
0
);
// number is distance of camera from player
}
}
Assets/Scripts/Constants.cs
View file @
5112f241
...
...
@@ -4,10 +4,10 @@ using UnityEngine;
public
static
class
Constants
{
public
static
double
c
=>
40
;
// speed of light.
public
static
double
c
=>
3
;
// speed of light.
public
static
double
Gamma
(
double
v
)
{
return
1
/
Mathf
.
Sqrt
((
1
-
(
float
)((
v
/
c
)
*
(
v
/
c
))));
return
1
.0f
/
Mathf
.
Sqrt
((
1
-
(
float
)((
v
/
c
)
*
(
v
/
c
))));
}
public
static
double
RadianToDegree
(
double
r
)
...
...
Assets/Scripts/PathRenderer.cs
View file @
5112f241
...
...
@@ -69,8 +69,9 @@ public class PathRenderer : MonoBehaviour
private
void
_DrawOnePath
(
Vector3
point
)
{
_ResetPaths
();
square
.
pathList
[
0
]
=
transform
.
position
;
square
.
pathList
[
1
]
=
point
;
square
.
pathList
[
0
]
=
transform
.
localPosition
;
var
tmp
=
transform
.
InverseTransformPoint
(
point
);
square
.
pathList
[
1
]
=
new
Vector3
(
tmp
.
x
,
tmp
.
y
,
0.0f
);
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
0
);
}
...
...
@@ -96,7 +97,8 @@ public class PathRenderer : MonoBehaviour
}
else
{
square
.
pathList
.
Add
(
point
);
var
tmp
=
transform
.
InverseTransformPoint
(
point
);
square
.
pathList
.
Add
(
new
Vector3
(
tmp
.
x
,
tmp
.
y
,
0.0f
));
_pathRenderer
.
positionCount
=
square
.
pathList
.
Count
();
_pathRenderer
.
SetPositions
(
square
.
pathList
.
ToArray
());
_InstantiatePathCollider
(
square
.
pathList
.
Count
()
-
2
);
...
...
@@ -109,15 +111,15 @@ public class PathRenderer : MonoBehaviour
_pathCollider
.
name
=
"PathCollider-"
+
n
;
_pathCollider
.
tag
=
"path"
;
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
0.1f
,
_originalPathColliderY
,
0
);
_pathCollider
.
transform
.
eulerAngles
=
new
Vector3
(
9
0
,
_pathCollider
.
transform
.
localEulerAngles
=
new
Vector3
(
0
,
0
,
(
float
)
Constants
.
RadianToDegree
(
Mathf
.
PI
/
2
+
Mathf
.
Atan
(
square
.
GetTangent
(
square
.
GetNthPath
(
n
))))
+
90
,
0
);
square
.
GetNthPath
(
n
)))));
float
_newY
=
square
.
GetNthPath
(
n
).
magnitude
;
_pathCollider
.
transform
.
localScale
=
new
Vector3
(
0.1f
,
_newY
*
_originalPathColliderY
,
0
);
_pathCollider
.
transform
.
p
osition
=
(
square
.
pathList
[
n
]
+
square
.
pathList
[
n
+
1
])
/
2
;
_pathCollider
.
transform
.
localP
osition
=
(
square
.
pathList
[
n
]
+
square
.
pathList
[
n
+
1
])
/
2
;
}
}
Assets/Scripts/Planemovement.cs
View file @
5112f241
...
...
@@ -43,7 +43,7 @@ public class Planemovement : MonoBehaviour
var
prevup
=
transform
.
up
;
var
prevfor
=
transform
.
forward
;
var
prevorient
=
orientation
;
transform
.
Translate
(
Vector3
.
up
*
Time
.
fixedDeltaTime
*
(
float
)
Levelmanager
.
player
.
gamma
,
Space
.
World
);
// move up by 1 second
transform
.
Translate
(
(
float
)
Constants
.
c
*
Vector3
.
up
*
Time
.
fixedDeltaTime
*
(
float
)
Levelmanager
.
player
.
gamma
,
Space
.
World
);
// move up by 1 second
cnt
++;
if
(
cnt
%
480
==
0
)
...
...
@@ -86,13 +86,13 @@ public class Planemovement : MonoBehaviour
v
=
new
Vector3
(
0
,
0
,
0
);
}
beta
=
v
.
magnitude
/
1.0f
;
beta
=
v
.
magnitude
/
(
float
)
Constants
.
c
;
gamma
=
1.0f
/
Mathf
.
Sqrt
(
1.0f
-
(
float
)(
beta
*
beta
)
);
gamma
=
Constants
.
Gamma
(
v
.
magnitude
);
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
*
(
float
)
Levelmanager
.
player
.
gamma
,
Space
.
World
);
var
vt
=
v
+
Vector3
.
up
;
var
vt
=
v
+
(
float
)
Constants
.
c
*
Vector3
.
up
;
vt
.
x
=
-
vt
.
x
;
...
...
Assets/Scripts/PlayerMovement.cs
View file @
5112f241
...
...
@@ -33,7 +33,7 @@ public class PlayerMovement : MonoBehaviour
var
prevup
=
transform
.
up
;
var
prevfor
=
transform
.
forward
;
var
prevorient
=
orientation
;
transform
.
Translate
(
Vector3
.
up
*
Time
.
fixedDeltaTime
*
(
float
)
gamma
,
Space
.
World
);
// move up by 1 second
transform
.
Translate
(
(
float
)
Constants
.
c
*
Vector3
.
up
*
Time
.
fixedDeltaTime
*
(
float
)
gamma
,
Space
.
World
);
// move up by 1 second
cnt
++;
if
(
cnt
%
480
==
0
)
{
...
...
@@ -45,14 +45,14 @@ public class PlayerMovement : MonoBehaviour
//orientation = Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
//v = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480);
//v = alpha.normalized * (alpha.magnitude * Time.time / Mathf.Sqrt(1.0f + (alpha.magnitude * Time.time) * (alpha.magnitude * Time.time)));
//v = new Vector3(0.7f, 0.0f, 0.0f);
beta
=
v
.
magnitude
/
(
float
)
Constants
.
c
;
beta
=
v
.
magnitude
/
1.0f
;
gamma
=
1.0f
/
Mathf
.
Sqrt
(
1.0f
-
(
float
)(
beta
*
beta
));
gamma
=
Constants
.
Gamma
(
v
.
magnitude
);
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
*
(
float
)
gamma
,
Space
.
World
);
var
vt
=
v
+
Vector3
.
up
;
var
vt
=
v
+
(
float
)
Constants
.
c
*
Vector3
.
up
;
vt
.
x
=
-
vt
.
x
;
...
...
Assets/Scripts/ScreenMovement.cs
View file @
5112f241
...
...
@@ -17,6 +17,6 @@ public class ScreenMovement : MonoBehaviour
var
v
=
Levelmanager
.
player
.
v
;
transform
.
rotation
=
Quaternion
.
AngleAxis
(
Vector3
.
SignedAngle
(
v
,
Vector3
.
forward
,
Vector3
.
up
),
Vector3
.
forward
);
transform
.
rotation
=
Quaternion
.
AngleAxis
(
Vector3
.
SignedAngle
(
v
,
Levelmanager
.
player
.
orientation
,
Vector3
.
up
),
Vector3
.
forward
);
}
}
Assets/Scripts/Square.cs
View file @
5112f241
...
...
@@ -18,7 +18,7 @@ public class Square : FlatLandObject
public
float
GetTangent
(
Vector3
v
)
{
return
v
.
x
/
v
.
z
;
return
v
.
y
/
v
.
x
;
}
public
Vector3
GetDestPoint
(
int
n
)
...
...
Assets/Scripts/UIManager.cs
View file @
5112f241
...
...
@@ -9,6 +9,8 @@ public class UIManager : MonoBehaviour
{
[
SerializeField
]
Square
square
;
[
SerializeField
]
Camera
playercamera
;
public
GameObject
canvas
;
public
Text
mytime
;
...
...
@@ -45,23 +47,32 @@ public class UIManager : MonoBehaviour
{
RaycastHit
hit
;
var
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
var
obj
=
hit
.
collider
.
gameObject
;
if
(
obj
.
tag
==
"path"
)
ray
=
playercamera
.
ViewportPointToRay
(
hit
.
textureCoord
);
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
int
pathNum
=
int
.
Parse
(
obj
.
name
.
Substring
(
13
))
;
if
(
pathNum
!=
prevSelectPathNum
)
var
obj
=
hit
.
collider
.
gameObject
;
if
(
obj
.
tag
==
"path"
)
{
pathName
.
text
=
obj
.
name
;
//_pathUI.transform.position = middlePoint;
_pathUI
.
transform
.
position
=
middlePoint
+
(
square
.
GetDestPoint
(
pathNum
)
+
new
Vector3
(
0
,
300
,
0
))
*
2.5f
;
//Debug.Log(square.GetMiddlePoint(pathNum, pathNum + 1));
_pathUI
.
SetActive
(
true
);
prevSelectPathNum
=
pathNum
;
int
pathNum
=
int
.
Parse
(
obj
.
name
.
Substring
(
13
));
if
(
pathNum
!=
prevSelectPathNum
)
{
pathName
.
text
=
obj
.
name
;
//_pathUI.transform.position = middlePoint;
_pathUI
.
transform
.
position
=
middlePoint
+
(
square
.
GetDestPoint
(
pathNum
)
+
new
Vector3
(
0
,
300
,
0
))
*
2.5f
;
//Debug.Log(square.GetMiddlePoint(pathNum, pathNum + 1));
_pathUI
.
SetActive
(
true
);
prevSelectPathNum
=
pathNum
;
}
else
{
_pathUI
.
SetActive
(
false
);
prevSelectPathNum
=
-
1
;
}
}
else
{
...
...
@@ -69,11 +80,6 @@ public class UIManager : MonoBehaviour
prevSelectPathNum
=
-
1
;
}
}
else
{
_pathUI
.
SetActive
(
false
);
prevSelectPathNum
=
-
1
;
}
}
}
else
if
(
Input
.
GetMouseButtonDown
(
1
))
...
...
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