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
8e39be2f
Commit
8e39be2f
authored
Aug 22, 2019
by
Chae Ho Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collision WIP
parent
8865b3dc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
59 deletions
+106
-59
DoubleClick.cs
Assets/Scripts/DoubleClick.cs
+0
-0
DoubleClick.cs.meta
Assets/Scripts/DoubleClick.cs.meta
+0
-0
FlatlandMovement.cs
Assets/Scripts/FlatlandMovement.cs
+56
-9
SelectArea.cs
Assets/Scripts/SelectArea.cs
+39
-39
SelectArea.cs.meta
Assets/Scripts/SelectArea.cs.meta
+11
-11
No files found.
Assets/DoubleClick.cs
→
Assets/
Scripts/
DoubleClick.cs
View file @
8e39be2f
File moved
Assets/DoubleClick.cs.meta
→
Assets/
Scripts/
DoubleClick.cs.meta
View file @
8e39be2f
File moved
Assets/Scripts/FlatlandMovement.cs
View file @
8e39be2f
...
...
@@ -251,7 +251,29 @@ public class FlatlandMovement : MonoBehaviour
}
public
bool
SetVelecityToAbPosition
(
Vector3
dest
,
float
v
)
public
IEnumerator
_AcceleratetoConstantVelocityWithoutCorrection
(
Vector3
dest
,
float
v
)
{
Vector3
acceleration
=
new
Vector3
(
dest
.
x
,
0f
,
dest
.
y
);
var
tinterval
=
Constants
.
alphatinterval
;
acceleration
=
acceleration
.
normalized
;
var
deltat
=
Time
.
fixedDeltaTime
*
tinterval
;
acceleration
=
(
float
)((
Constants
.
c
/
deltat
)
*
MathNet
.
Numerics
.
Trig
.
Asinh
(
v
*
Constants
.
Gamma
(
v
*
Constants
.
c
)))
*
acceleration
;
// acceleration required to accelerate to v in deltat seconds: see https://en.wikiversity.org/wiki/Theory_of_relativity/Rindler_coordinates
this
.
alpha
+=
acceleration
;
for
(
var
j
=
0
;
j
<
tinterval
;
++
j
)
{
yield
return
new
WaitForFixedUpdate
();
}
this
.
alpha
-=
acceleration
;
}
public
bool
SetVelecityToAbPosition
(
Vector3
dest
,
float
v
)
{
dest
.
y
=
0
;
//속도와 목적지 설정.
...
...
@@ -340,21 +362,46 @@ public class FlatlandMovement : MonoBehaviour
Vector3
col
=
(
other
.
v
-
this
.
v
);
var
totalThreeMomentum
=
this
.
GetThreeMomentum
()
+
other
.
GetThreeMomentum
();
var
totalThreeMomentum
=
Constants
.
BoostMatrix
(
v
)
*
other
.
GetThreeMomentum
();
var
tmp
=
collision
.
GetContact
(
0
).
normal
;
tmp
=
new
Vector3
(
tmp
.
x
,
0
,
tmp
.
z
);
tmp
=
tmp
.
normalized
;
float
inner
=
SpaceInnerPorduct
(
tmp
,
col
.
normalized
);
double
[]
tmpx
=
{
0
,
tmp
.
x
,
tmp
.
z
};
double
[]
tmpv
=
{
Constants
.
Gamma
(
other
.
v
.
magnitude
)
*
Constants
.
c
,
Constants
.
Gamma
(
other
.
v
.
magnitude
)
*
other
.
v
.
x
,
Constants
.
Gamma
(
other
.
v
.
magnitude
)
*
other
.
v
.
z
};
var
direction
=
V
.
DenseOfArray
(
tmpx
);
var
collisionvelocity
=
V
.
DenseOfArray
(
tmpv
);
if
(
v
.
magnitude
>
0
)
{
direction
=
Constants
.
BoostMatrix
(
v
)
*
direction
;
collisionvelocity
=
Constants
.
BoostMatrix
(
v
)
*
collisionvelocity
;
}
Vector3
finalcollisionforcedirection
=
new
Vector3
((
float
)
direction
[
1
],
0
,
(
float
)
direction
[
2
]);
var
finalcollisionvelocitygamma
=
collisionvelocity
[
0
]
/
Constants
.
c
;
Vector3
finalcollisionvelocity
=
new
Vector3
((
float
)(
collisionvelocity
[
1
]
/
finalcollisionvelocitygamma
),
0
,
(
float
)(
collisionvelocity
[
2
]
/
finalcollisionvelocitygamma
));
finalcollisionforcedirection
=
finalcollisionforcedirection
.
normalized
;
var
a
=
mass
+
other
.
mass
*
finalcollisionvelocitygamma
;
var
b
=
other
.
mass
*
finalcollisionvelocitygamma
*
SpaceInnerPorduct
(
finalcollisionvelocity
,
finalcollisionforcedirection
)
/
Constants
.
c
;
var
c
=
other
.
mass
*
finalcollisionvelocitygamma
;
inner
=
Mathf
.
Abs
(
inner
);
var
resultvgamma
=
((
2.0
*
a
*
c
)
+
Math
.
Sqrt
((
4
*
a
*
a
*
c
*
c
)
-
4.0
*
(
a
*
a
-
b
*
b
)
*
(
b
*
b
+
c
*
c
)))
/
(
2.0
*
(
a
*
a
-
b
*
b
));
if
(
resultvgamma
<
1.0
)
{
resultvgamma
=
-
resultvgamma
;
}
tmp
*=
col
.
magnitude
*
inner
*
other
.
mass
;
var
resultvbetamagnitude
=
Math
.
Sqrt
(
1.0
-
(
1.0
/
resultvgamma
))
;
collisionforce
=
tmp
;
alpha
+=
collisionforce
;
StartCoroutine
(
_AcceleratetoConstantVelocityWithoutCorrection
(
finalcollisionforcedirection
,(
float
)
resultvbetamagnitude
));
Debug
.
Log
(
collisions
.
Count
);
}
...
...
@@ -376,8 +423,8 @@ public class FlatlandMovement : MonoBehaviour
collisions
.
Remove
(
collision
.
gameObject
.
GetComponent
<
ExtrudedMesh
>().
hash
);
alpha
-=
collisionforce
;
collisionforce
=
new
Vector3
(
0
,
0
,
0
);
//
alpha -= collisionforce;
//
collisionforce = new Vector3(0, 0, 0);
}
public
double
GetEnergy
()
...
...
Assets/SelectArea.cs
→
Assets/S
cripts/S
electArea.cs
View file @
8e39be2f
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine.UI
;
using
UnityEngine
;
public
class
SelectArea
:
MonoBehaviour
{
public
GameObject
sd
;
public
Canvas
canvas
;
Vector3
startPos
,
endPos
;
GameObject
tempDrag
;
void
Start
()
{
}
void
Update
()
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
startPos
=
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
0
);
tempDrag
=
Instantiate
(
sd
,
startPos
,
Quaternion
.
identity
)
as
GameObject
;
tempDrag
.
transform
.
parent
=
canvas
.
transform
;
}
if
(
Input
.
GetMouseButton
(
0
))
{
endPos
=
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
0
);
tempDrag
.
transform
.
localScale
=
new
Vector3
(
endPos
.
x
-
startPos
.
x
,
endPos
.
y
-
startPos
.
y
,
0
);
}
if
(
Input
.
GetMouseButtonUp
(
0
))
{
Destroy
(
tempDrag
);
}
}
}
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine.UI
;
using
UnityEngine
;
public
class
SelectArea
:
MonoBehaviour
{
public
GameObject
sd
;
public
Canvas
canvas
;
Vector3
startPos
,
endPos
;
GameObject
tempDrag
;
void
Start
()
{
}
void
Update
()
{
if
(
Input
.
GetMouseButtonDown
(
0
))
{
startPos
=
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
0
);
tempDrag
=
Instantiate
(
sd
,
startPos
,
Quaternion
.
identity
)
as
GameObject
;
tempDrag
.
transform
.
parent
=
canvas
.
transform
;
}
if
(
Input
.
GetMouseButton
(
0
))
{
endPos
=
new
Vector3
(
Input
.
mousePosition
.
x
,
Input
.
mousePosition
.
y
,
0
);
tempDrag
.
transform
.
localScale
=
new
Vector3
(
endPos
.
x
-
startPos
.
x
,
endPos
.
y
-
startPos
.
y
,
0
);
}
if
(
Input
.
GetMouseButtonUp
(
0
))
{
Destroy
(
tempDrag
);
}
}
}
Assets/SelectArea.cs.meta
→
Assets/S
cripts/S
electArea.cs.meta
View file @
8e39be2f
fileFormatVersion: 2
guid: 4cac6e9f5a929c3459ede6049a34ff3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 4cac6e9f5a929c3459ede6049a34ff3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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