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
a31d3d8b
Commit
a31d3d8b
authored
5 years ago
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'model-demo'
# Conflicts: # Assets/Scenes/Test.unity # Assets/Scripts/PlayerMovement.cs
parents
8e04a34d
2e620bee
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
152 additions
and
17 deletions
+152
-17
CameraMovement.cs
Assets/Scripts/CameraMovement.cs
+1
-1
ExtrudedMesh.cs
Assets/Scripts/ExtrudedMesh.cs
+9
-1
LevelManager.cs
Assets/Scripts/LevelManager.cs
+2
-1
Planemovement.cs
Assets/Scripts/Planemovement.cs
+75
-10
PlayerMovement.cs
Assets/Scripts/PlayerMovement.cs
+17
-3
RuntimeCSGFlatlandObject.cs
Assets/Scripts/RuntimeCSGFlatlandObject.cs
+1
-1
ScreenMovement.cs
Assets/Scripts/ScreenMovement.cs
+22
-0
ScreenMovement.cs.meta
Assets/Scripts/ScreenMovement.cs.meta
+11
-0
UIManager.cs
Assets/Scripts/UIManager.cs
+14
-0
No files found.
Assets/Scripts/CameraMovement.cs
View file @
a31d3d8b
...
...
@@ -37,7 +37,7 @@ public class CameraMovement : MonoBehaviour
transform
.
rotation
=
Quaternion
.
LookRotation
(-
vt
,
newforward
);
thecamera
.
orthographicSize
=
5
.0f
*
((
float
)
Levelmanager
.
player
.
gamma
);
thecamera
.
orthographicSize
=
10
.0f
*
((
float
)
Levelmanager
.
player
.
gamma
);
aspect
=
16.0f
/
(
9.0f
*
(
Levelmanager
.
player
.
gamma
));
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/ExtrudedMesh.cs
View file @
a31d3d8b
...
...
@@ -75,7 +75,7 @@ public class ExtrudedMesh : MonoBehaviour
DestroyImmediate
(
clone
.
transform
.
GetChild
(
1
).
gameObject
);
}
DestroyImmediate
(
clone
.
GetComponentInChildren
<
ExtrudedMesh
>());
clone
.
GetComponentInChildren
<
MeshCollider
>().
convex
=
tru
e
;
clone
.
GetComponentInChildren
<
MeshCollider
>().
convex
=
fals
e
;
clone
.
GetComponentInChildren
<
MeshCollider
>().
sharedMesh
=
clone
.
GetComponentInChildren
<
MeshFilter
>().
mesh
;
clone
.
transform
.
GetChild
(
0
).
gameObject
.
AddComponent
<
RuntimeCSGFlatlandObject
>();
clone
.
layer
=
8
;
...
...
@@ -167,4 +167,12 @@ public class ExtrudedMesh : MonoBehaviour
}
public
void
OnCollisionStay
(
Collision
collision
)
{
if
(
transform
.
parent
.
GetComponent
(
typeof
(
Planemovement
))
==
null
)
return
;
else
transform
.
parent
.
GetComponent
<
Planemovement
>().
OnCollisionStaychild
(
collision
);
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/LevelManager.cs
View file @
a31d3d8b
...
...
@@ -7,10 +7,11 @@ public class LevelManager : MonoBehaviour
public
double
gamma
;
public
PlayerMovement
player
;
public
bool
winstate
=
false
;
// Start is called before the first frame update
void
Start
()
{
winstate
=
false
;
}
// Update is called once per frame
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/Planemovement.cs
View file @
a31d3d8b
...
...
@@ -4,17 +4,24 @@ using UnityEngine;
public
class
Planemovement
:
MonoBehaviour
{
//bool toggle = true;
bool
toggle
=
false
;
bool
grabbed
=
false
;
int
cnt
=
0
;
double
beta
=
0.5f
;
// v/c
Vector3
alpha
=
new
Vector3
(
0.1f
,
0.0f
,
0.0f
);
// proper acceleration
Vector3
v
;
public
LevelManager
Levelmanager
;
public
double
playergamma
;
public
double
starttime
=
0.0f
;
public
double
gamma
=
1.0f
;
Vector3
orientation
;
double
time
=
0.0f
;
// Start is called before the first frame update
public
GameObject
theobject
;
public
Planemovement
otherclock
;
void
Start
()
{
...
...
@@ -22,7 +29,10 @@ public class Planemovement : MonoBehaviour
//Color materialColor = r.material.color;
//r.material.color = Color.clear;
v
=
new
Vector3
(
0.0f
,
0.0f
,
0.0f
);
playergamma
=
1.0f
;
//playergamma = 1.0f;
orientation
=
new
Vector3
(
0.0f
,
0.0f
,
1.0f
);
time
=
starttime
;
gamma
=
1.0f
;
}
// Update is called once per frame
...
...
@@ -32,27 +42,55 @@ 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
//cnt++;
//if (cnt % 480 == 0)
//{
// cnt = 0;
//}
cnt
++;
if
(
cnt
%
480
==
0
)
{
cnt
=
0
;
}
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.forward * Mathf.Cos(2*Mathf.PI*cnt/480) * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480) * Time.fixedDeltaTime, Space.World);
//orientation = (float)beta * Vector3.forward * Mathf.Cos(2 * Mathf.PI * cnt / 480) + (float)beta * 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, 0, 0);
if
((
Levelmanager
.
player
.
transform
.
position
-
transform
.
position
).
magnitude
<
0.5f
)
{
toggle
=
true
;
}
else
{
toggle
=
false
;
}
if
(
toggle
&&
Input
.
GetKeyDown
(
"g"
))
{
grabbed
=
!
grabbed
;
}
if
(
grabbed
)
{
v
=
Levelmanager
.
player
.
v
;
Debug
.
Log
(
"being grabbed"
);
}
else
{
v
=
new
Vector3
(
0
,
0
,
0
);
}
beta
=
v
.
magnitude
/
1.0f
;
double
gamma
=
1.0f
/
Mathf
.
Sqrt
(
1.0f
-
(
float
)(
beta
*
beta
));
gamma
=
1.0f
/
Mathf
.
Sqrt
(
1.0f
-
(
float
)(
beta
*
beta
));
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
,
Space
.
World
);
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
*
(
float
)
Levelmanager
.
player
.
gamma
,
Space
.
World
);
var
vt
=
v
+
Vector3
.
up
;
...
...
@@ -67,6 +105,7 @@ public class Planemovement : MonoBehaviour
theobject
.
transform
.
up
=
vt
;
theobject
.
transform
.
parent
=
null
;
theobject
.
transform
.
RotateAround
(
theobject
.
transform
.
position
,
vt
,
Vector3
.
Angle
(
prevorient
,
orientation
));
Vector3
newforward
=
new
Vector3
(
vt
.
y
*
(
v
.
x
/
v
.
magnitude
),
Mathf
.
Sqrt
(
vt
.
x
*
vt
.
x
+
vt
.
z
*
vt
.
z
),
vt
.
y
*
(
v
.
z
/
v
.
magnitude
));
...
...
@@ -76,5 +115,31 @@ public class Planemovement : MonoBehaviour
transform
.
localScale
=
new
Vector3
(
1.0f
,
1.0f
,
(
float
)
gamma
);
// scale x' axis
time
+=
Time
.
fixedDeltaTime
*
(
float
)(
Levelmanager
.
player
.
gamma
/
gamma
);
}
public
void
OnCollisionStaychild
(
Collision
collision
)
{
//Debug.Log("hit!");
//if(collision.transform.parent.name != "AnObject(Clone)")
// Debug.Log(collision.gameObject.name + " wow!");
if
(
collision
.
transform
.
parent
!=
null
)
{
var
x
=
collision
.
transform
.
parent
.
gameObject
.
GetComponent
(
typeof
(
Planemovement
))
as
Planemovement
;
if
(
x
!=
null
&&
x
.
Equals
(
otherclock
))
{
Debug
.
Log
(
"hit!"
);
if
(
Mathf
.
Abs
((
float
)(
otherclock
.
GetTime
()
-
time
))
<=
1.0f
)
{
Levelmanager
.
winstate
=
true
;
}
}
}
}
public
double
GetTime
()
{
return
time
;
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/PlayerMovement.cs
View file @
a31d3d8b
...
...
@@ -10,6 +10,9 @@ public class PlayerMovement : MonoBehaviour
public
Vector3
v
=
new
Vector3
(
0.0f
,
0.0f
,
0.0f
);
public
double
gamma
=
1.0f
;
public
GameObject
theobject
;
public
Vector3
orientation
=
new
Vector3
(
0.0f
,
0.0f
,
0.0f
);
public
double
time
=
0.0f
;
int
cnt
=
0
;
// Start is called before the first frame update
void
Start
()
...
...
@@ -17,6 +20,8 @@ public class PlayerMovement : MonoBehaviour
v
=
new
Vector3
(
0.0f
,
0.0f
,
0.0f
);
gamma
=
1.0f
;
cnt
=
0
;
orientation
=
new
Vector3
(
0.0f
,
0.0f
,
1.0f
);
time
=
0.0f
;
}
// Update is called once per frame
...
...
@@ -24,6 +29,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
cnt
++;
if
(
cnt
%
480
==
0
)
...
...
@@ -33,7 +39,7 @@ public class PlayerMovement : MonoBehaviour
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.forward * Mathf.Cos(2*Mathf.PI*cnt/480) * Time.fixedDeltaTime, Space.World);
//transform.Translate(0.5f*Vector3.left * Mathf.Sin(2 * Mathf.PI * cnt / 480) * Time.fixedDeltaTime, Space.World);
//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)));
...
...
@@ -41,7 +47,7 @@ public class PlayerMovement : MonoBehaviour
gamma
=
1.0f
/
Mathf
.
Sqrt
(
1.0f
-
(
float
)(
beta
*
beta
));
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
,
Space
.
World
);
transform
.
Translate
(
v
*
Time
.
fixedDeltaTime
*
(
float
)
gamma
,
Space
.
World
);
var
vt
=
v
+
Vector3
.
up
;
...
...
@@ -53,9 +59,14 @@ public class PlayerMovement : MonoBehaviour
transform
.
localScale
=
new
Vector3
(
1.0f
,
1.0f
,
1.0f
);
// release child to change x'-axis scale
theobject
.
transform
.
up
=
vt
;
//theobject.transform.up = vt;
var
neworientation
=
(
Quaternion
.
FromToRotation
(
Vector3
.
up
,
vt
))
*
orientation
;
theobject
.
transform
.
rotation
=
Quaternion
.
LookRotation
(
neworientation
,
vt
);
theobject
.
transform
.
parent
=
null
;
//theobject.transform.RotateAround(theobject.transform.position, vt, Vector3.Angle(prevorient, orientation));
Vector3
newforward
=
new
Vector3
(
vt
.
y
*
(
v
.
x
/
v
.
magnitude
),
Mathf
.
Sqrt
(
vt
.
x
*
vt
.
x
+
vt
.
z
*
vt
.
z
),
vt
.
y
*
(
v
.
z
/
v
.
magnitude
));
...
...
@@ -64,5 +75,8 @@ public class PlayerMovement : MonoBehaviour
theobject
.
transform
.
parent
=
transform
;
transform
.
localScale
=
new
Vector3
(
1.0f
,
1.0f
,
(
float
)
gamma
);
// scale x'-axis scale (distance dilation)
time
+=
Time
.
fixedDeltaTime
;
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/RuntimeCSGFlatlandObject.cs
View file @
a31d3d8b
...
...
@@ -11,7 +11,7 @@ public class RuntimeCSGFlatlandObject : MonoBehaviour
int
cnt
=
0
;
public
CSG
csg
;
//
public CSG csg;
// Start is called before the first frame update
void
Start
()
{
...
...
This diff is collapsed.
Click to expand it.
Assets/Scripts/ScreenMovement.cs
0 → 100644
View file @
a31d3d8b
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
public
class
ScreenMovement
:
MonoBehaviour
{
public
LevelManager
Levelmanager
;
// Start is called before the first frame update
void
Start
()
{
}
// Update is called once per frame
void
FixedUpdate
()
{
var
v
=
Levelmanager
.
player
.
v
;
transform
.
rotation
=
Quaternion
.
AngleAxis
(
Vector3
.
SignedAngle
(
v
,
Vector3
.
forward
,
Vector3
.
up
),
Vector3
.
forward
);
}
}
This diff is collapsed.
Click to expand it.
Assets/Scripts/ScreenMovement.cs.meta
0 → 100644
View file @
a31d3d8b
fileFormatVersion: 2
guid: 4e0af0ca58f3ba4479655495ab6e9bef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
Assets/Scripts/UIManager.cs
View file @
a31d3d8b
...
...
@@ -11,7 +11,14 @@ public class UIManager : MonoBehaviour
Square
square
;
public
GameObject
canvas
;
public
Text
mytime
;
public
Planemovement
clock1
;
public
Planemovement
clock2
;
public
Text
clock1time
;
public
Text
clock2time
;
public
Text
wintext
;
public
GameObject
_pathUI
;
public
LevelManager
Levelmanager
;
private
int
prevSelectPathNum
=
-
1
;
private
Text
pathName
;
private
Vector3
middlePoint
;
...
...
@@ -27,6 +34,13 @@ public class UIManager : MonoBehaviour
// Update is called once per frame
void
Update
()
{
mytime
.
text
=
Levelmanager
.
player
.
time
.
ToString
()
+
" s"
;
clock1time
.
text
=
clock1
.
GetTime
().
ToString
()
+
" s"
;
clock2time
.
text
=
clock2
.
GetTime
().
ToString
()
+
" s"
;
if
(
Levelmanager
.
winstate
)
{
wintext
.
gameObject
.
SetActive
(
true
);
}
if
(
Input
.
GetMouseButtonDown
(
0
))
{
RaycastHit
hit
;
...
...
This diff is collapsed.
Click to expand it.
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