Commit a31d3d8b authored by Chae Ho Shin's avatar Chae Ho Shin

Merge branch 'model-demo'

# Conflicts:
#	Assets/Scenes/Test.unity
#	Assets/Scripts/PlayerMovement.cs
parents 8e04a34d 2e620bee
...@@ -37,7 +37,7 @@ public class CameraMovement : MonoBehaviour ...@@ -37,7 +37,7 @@ public class CameraMovement : MonoBehaviour
transform.rotation = Quaternion.LookRotation(-vt, newforward); 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)); aspect = 16.0f / (9.0f * (Levelmanager.player.gamma));
......
...@@ -75,7 +75,7 @@ public class ExtrudedMesh : MonoBehaviour ...@@ -75,7 +75,7 @@ public class ExtrudedMesh : MonoBehaviour
DestroyImmediate(clone.transform.GetChild(1).gameObject); DestroyImmediate(clone.transform.GetChild(1).gameObject);
} }
DestroyImmediate(clone.GetComponentInChildren<ExtrudedMesh>()); DestroyImmediate(clone.GetComponentInChildren<ExtrudedMesh>());
clone.GetComponentInChildren<MeshCollider>().convex = true; clone.GetComponentInChildren<MeshCollider>().convex = false;
clone.GetComponentInChildren<MeshCollider>().sharedMesh = clone.GetComponentInChildren<MeshFilter>().mesh; clone.GetComponentInChildren<MeshCollider>().sharedMesh = clone.GetComponentInChildren<MeshFilter>().mesh;
clone.transform.GetChild(0).gameObject.AddComponent<RuntimeCSGFlatlandObject>(); clone.transform.GetChild(0).gameObject.AddComponent<RuntimeCSGFlatlandObject>();
clone.layer = 8; clone.layer = 8;
...@@ -167,4 +167,12 @@ public class ExtrudedMesh : MonoBehaviour ...@@ -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);
}
} }
...@@ -7,10 +7,11 @@ public class LevelManager : MonoBehaviour ...@@ -7,10 +7,11 @@ public class LevelManager : MonoBehaviour
public double gamma; public double gamma;
public PlayerMovement player; public PlayerMovement player;
public bool winstate = false;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
winstate = false;
} }
// Update is called once per frame // Update is called once per frame
......
...@@ -4,17 +4,24 @@ using UnityEngine; ...@@ -4,17 +4,24 @@ using UnityEngine;
public class Planemovement : MonoBehaviour public class Planemovement : MonoBehaviour
{ {
//bool toggle = true; bool toggle = false;
bool grabbed = false;
int cnt = 0; int cnt = 0;
double beta = 0.5f; // v/c double beta = 0.5f; // v/c
Vector3 alpha = new Vector3(0.1f, 0.0f, 0.0f); // proper acceleration Vector3 alpha = new Vector3(0.1f, 0.0f, 0.0f); // proper acceleration
Vector3 v; Vector3 v;
public LevelManager Levelmanager; 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 // Start is called before the first frame update
public GameObject theobject; public GameObject theobject;
public Planemovement otherclock;
void Start() void Start()
{ {
...@@ -22,7 +29,10 @@ public class Planemovement : MonoBehaviour ...@@ -22,7 +29,10 @@ public class Planemovement : MonoBehaviour
//Color materialColor = r.material.color; //Color materialColor = r.material.color;
//r.material.color = Color.clear; //r.material.color = Color.clear;
v = new Vector3(0.0f, 0.0f, 0.0f); 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 // Update is called once per frame
...@@ -32,27 +42,55 @@ public class Planemovement : MonoBehaviour ...@@ -32,27 +42,55 @@ public class Planemovement : MonoBehaviour
{ {
var prevup = transform.up; var prevup = transform.up;
var prevfor = transform.forward; 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(Vector3.up * Time.fixedDeltaTime * (float)Levelmanager.player.gamma, Space.World); // move up by 1 second
//cnt++;
//if (cnt % 480 == 0) cnt++;
//{ if (cnt % 480 == 0)
// cnt = 0; {
//} cnt = 0;
}
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World); //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.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); //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 = (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); //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; 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; var vt = v + Vector3.up;
...@@ -67,6 +105,7 @@ public class Planemovement : MonoBehaviour ...@@ -67,6 +105,7 @@ public class Planemovement : MonoBehaviour
theobject.transform.up = vt; theobject.transform.up = vt;
theobject.transform.parent = null; 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)); 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 ...@@ -76,5 +115,31 @@ public class Planemovement : MonoBehaviour
transform.localScale = new Vector3(1.0f, 1.0f, (float)gamma); // scale x' axis 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;
} }
} }
...@@ -10,6 +10,9 @@ public class PlayerMovement : MonoBehaviour ...@@ -10,6 +10,9 @@ public class PlayerMovement : MonoBehaviour
public Vector3 v = new Vector3(0.0f, 0.0f, 0.0f); public Vector3 v = new Vector3(0.0f, 0.0f, 0.0f);
public double gamma = 1.0f; public double gamma = 1.0f;
public GameObject theobject; public GameObject theobject;
public Vector3 orientation = new Vector3(0.0f, 0.0f, 0.0f);
public double time = 0.0f;
int cnt = 0; int cnt = 0;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
...@@ -17,6 +20,8 @@ public class PlayerMovement : MonoBehaviour ...@@ -17,6 +20,8 @@ public class PlayerMovement : MonoBehaviour
v = new Vector3(0.0f, 0.0f, 0.0f); v = new Vector3(0.0f, 0.0f, 0.0f);
gamma = 1.0f; gamma = 1.0f;
cnt = 0; cnt = 0;
orientation = new Vector3(0.0f, 0.0f, 1.0f);
time = 0.0f;
} }
// Update is called once per frame // Update is called once per frame
...@@ -24,6 +29,7 @@ public class PlayerMovement : MonoBehaviour ...@@ -24,6 +29,7 @@ public class PlayerMovement : MonoBehaviour
{ {
var prevup = transform.up; var prevup = transform.up;
var prevfor = transform.forward; var prevfor = transform.forward;
var prevorient = orientation;
transform.Translate(Vector3.up * Time.fixedDeltaTime * (float)gamma, Space.World); // move up by 1 second transform.Translate(Vector3.up * Time.fixedDeltaTime * (float)gamma, Space.World); // move up by 1 second
cnt++; cnt++;
if (cnt % 480 == 0) if (cnt % 480 == 0)
...@@ -33,7 +39,7 @@ public class PlayerMovement : MonoBehaviour ...@@ -33,7 +39,7 @@ public class PlayerMovement : MonoBehaviour
//transform.Translate(Vector3.forward * Time.fixedDeltaTime, Space.World); //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.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); //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 = (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)));
...@@ -41,7 +47,7 @@ public class PlayerMovement : MonoBehaviour ...@@ -41,7 +47,7 @@ public class PlayerMovement : MonoBehaviour
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)gamma, Space.World);
var vt = v + Vector3.up; var vt = v + Vector3.up;
...@@ -53,9 +59,14 @@ public class PlayerMovement : MonoBehaviour ...@@ -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 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.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)); 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 ...@@ -64,5 +75,8 @@ public class PlayerMovement : MonoBehaviour
theobject.transform.parent = transform; theobject.transform.parent = transform;
transform.localScale = new Vector3(1.0f, 1.0f, (float)gamma); // scale x'-axis scale (distance dilation) transform.localScale = new Vector3(1.0f, 1.0f, (float)gamma); // scale x'-axis scale (distance dilation)
time += Time.fixedDeltaTime;
} }
} }
...@@ -11,7 +11,7 @@ public class RuntimeCSGFlatlandObject : MonoBehaviour ...@@ -11,7 +11,7 @@ public class RuntimeCSGFlatlandObject : MonoBehaviour
int cnt = 0; int cnt = 0;
public CSG csg; //public CSG csg;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
......
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);
}
}
fileFormatVersion: 2
guid: 4e0af0ca58f3ba4479655495ab6e9bef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -11,7 +11,14 @@ public class UIManager : MonoBehaviour ...@@ -11,7 +11,14 @@ public class UIManager : MonoBehaviour
Square square; Square square;
public GameObject canvas; 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 GameObject _pathUI;
public LevelManager Levelmanager;
private int prevSelectPathNum = -1; private int prevSelectPathNum = -1;
private Text pathName; private Text pathName;
private Vector3 middlePoint; private Vector3 middlePoint;
...@@ -27,6 +34,13 @@ public class UIManager : MonoBehaviour ...@@ -27,6 +34,13 @@ public class UIManager : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() 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)) if (Input.GetMouseButtonDown(0))
{ {
RaycastHit hit; RaycastHit hit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment