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
b4184cd7
Commit
b4184cd7
authored
Aug 02, 2019
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working demo of model(proto level)
parent
d689c27e
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
436 additions
and
37 deletions
+436
-37
Test.unity
Assets/Scenes/Test.unity
+273
-22
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
+69
-8
PlayerMovement.cs
Assets/Scripts/PlayerMovement.cs
+34
-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/Scenes/Test.unity
View file @
b4184cd7
This diff is collapsed.
Click to expand it.
Assets/Scripts/CameraMovement.cs
View file @
b4184cd7
...
...
@@ -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
));
...
...
Assets/Scripts/ExtrudedMesh.cs
View file @
b4184cd7
...
...
@@ -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
);
}
}
Assets/Scripts/LevelManager.cs
View file @
b4184cd7
...
...
@@ -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
...
...
Assets/Scripts/Planemovement.cs
View file @
b4184cd7
...
...
@@ -4,17 +4,23 @@ 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
;
Vector3
orientation
;
double
time
=
0.0f
;
// Start is called before the first frame update
public
GameObject
theobject
;
public
Planemovement
otherclock
;
void
Start
()
{
...
...
@@ -22,7 +28,9 @@ 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
;
}
// Update is called once per frame
...
...
@@ -32,22 +40,50 @@ 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
));
...
...
@@ -67,6 +103,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 +113,29 @@ public class Planemovement : MonoBehaviour
transform
.
localScale
=
new
Vector3
(
1.0f
,
1.0f
,
(
float
)
gamma
);
// scale x' axis
time
+=
Time
.
fixedDeltaTime
*
(
float
)
Levelmanager
.
player
.
gamma
/
(
float
)
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
)
{
if
(
collision
.
transform
.
parent
.
gameObject
.
Equals
(
otherclock
))
{
Debug
.
Log
(
"hit!"
);
if
(
Mathf
.
Abs
((
float
)(
otherclock
.
GetTime
()
-
time
))
<
1.0f
)
{
Levelmanager
.
winstate
=
true
;
}
}
}
}
public
double
GetTime
()
{
return
time
;
}
}
Assets/Scripts/PlayerMovement.cs
View file @
b4184cd7
...
...
@@ -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,9 +39,26 @@ 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
)));
//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
(
Input
.
GetKey
(
"w"
))
{
v
+=
Vector3
.
forward
*
0.8f
;
}
else
if
(
Input
.
GetKey
(
"a"
))
{
v
+=
Vector3
.
left
*
0.8f
;
}
else
if
(
Input
.
GetKey
(
"s"
))
{
v
-=
Vector3
.
forward
*
0.8f
;
}
else
if
(
Input
.
GetKey
(
"d"
))
{
v
+=
Vector3
.
right
*
0.8f
;
}
beta
=
v
.
magnitude
/
1.0f
;
...
...
@@ -53,9 +76,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 +92,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
;
}
}
Assets/Scripts/RuntimeCSGFlatlandObject.cs
View file @
b4184cd7
...
...
@@ -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
()
{
...
...
Assets/Scripts/ScreenMovement.cs
0 → 100644
View file @
b4184cd7
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
);
}
}
Assets/Scripts/ScreenMovement.cs.meta
0 → 100644
View file @
b4184cd7
fileFormatVersion: 2
guid: 4e0af0ca58f3ba4479655495ab6e9bef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/UIManager.cs
View file @
b4184cd7
...
...
@@ -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
;
// Start is called before the first frame update
...
...
@@ -23,6 +30,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
.
enabled
=
true
;
}
if
(
Input
.
GetMouseButtonDown
(
0
))
{
RaycastHit
hit
;
...
...
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