Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Failframeit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FrameIT
Failframeit
Commits
174f8fa6
Commit
174f8fa6
authored
3 years ago
by
John Schihada
Browse files
Options
Downloads
Patches
Plain Diff
Adjusted spawning of angles: Made rotation more accurate
parent
f55169e8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Assets/Scripts/InteractionEngine/FactSpawner.cs
+10
-16
10 additions, 16 deletions
Assets/Scripts/InteractionEngine/FactSpawner.cs
with
10 additions
and
16 deletions
Assets/Scripts/InteractionEngine/FactSpawner.cs
+
10
−
16
View file @
174f8fa6
...
...
@@ -164,29 +164,22 @@ public Fact SpawnAngle(Fact fact)
this
.
FactRepresentation
=
(
GameObject
)
Resources
.
Load
(
"Prefabs/Angle"
,
typeof
(
GameObject
));
GameObject
angle
=
GameObject
.
Instantiate
(
FactRepresentation
);
//Place the Angle at position of point2
angle
.
transform
.
position
=
point2
;
//Calculate Angle:
Vector3
from
=
(
point3
-
point2
).
normalized
;
Vector3
to
=
(
point1
-
point2
).
normalized
;
float
angleValue
=
Vector3
.
Angle
(
from
,
to
);
//We always get an angle between 0 and 180° here
//Change scale and rotation, so that the angle is in between the two lines
var
v3T
=
angle
.
transform
.
localScale
;
v3T
=
new
Vector3
(
length
,
v3T
.
y
,
length
);
//Calculate Angle:
Vector3
from
=
(
point1
-
point2
).
normalized
;
Vector3
to
=
(
point3
-
point2
).
normalized
;
float
angleValue
=
Vector3
.
Angle
(
from
,
to
);
//We always get an angle between 0 and 180° here
//Vector3 direction = point2 - camera.transform.position;
//float angleSign = Mathf.Sign( Vector3.Dot( direction, Vector3.Cross( from, to ) ) );
Vector3
up
=
Vector3
.
Cross
(
to
,
from
);
angle
.
transform
.
rotation
=
Quaternion
.
LookRotation
(
Vector3
.
Cross
((
from
+
to
).
normalized
,
up
),
up
);
angle
.
transform
.
rotation
=
Quaternion
.
FromToRotation
(
Vector3
.
right
,
(
Vector3
.
Lerp
((
point1
-
point2
).
normalized
,
(
point3
-
point2
).
normalized
,
0.5f
)));
float
signedAngle
=
Mathf
.
Atan2
(
Vector3
.
Dot
((
Vector3
.
Lerp
((
point1
-
point2
).
normalized
,
(
point3
-
point2
).
normalized
,
0.5f
)),
Vector3
.
Cross
(
angle
.
transform
.
GetChild
(
0
).
forward
.
normalized
,
(
point1
-
point3
).
normalized
)),
Vector3
.
Dot
(
angle
.
transform
.
GetChild
(
0
).
forward
.
normalized
,
(
point1
-
point3
).
normalized
))
*
Mathf
.
Rad2Deg
;
if
(
signedAngle
<
0
)
{
angle
.
transform
.
RotateAround
(
point2
,
(
Vector3
.
Lerp
((
point1
-
point2
).
normalized
,
(
point3
-
point2
).
normalized
,
0.5f
)),
Vector3
.
Angle
(
angle
.
transform
.
GetChild
(
0
).
forward
.
normalized
,
(
point3
-
point1
).
normalized
));
}
else
angle
.
transform
.
RotateAround
(
point2
,
(
Vector3
.
Lerp
((
point1
-
point2
).
normalized
,
(
point3
-
point2
).
normalized
,
0.5f
)),
Vector3
.
Angle
(
angle
.
transform
.
GetChild
(
0
).
forward
.
normalized
,
(
point1
-
point3
).
normalized
));
//Place the Angle at position of point2
angle
.
transform
.
position
=
point2
;
//Set text of angle
TextMeshPro
[]
texts
=
angle
.
GetComponentsInChildren
<
TextMeshPro
>();
foreach
(
TextMeshPro
t
in
texts
)
{
//Change Text not to the id, but to the angle-value (from both sides) AND change font-size relative to length of the angle (from both sides)
...
...
@@ -194,6 +187,7 @@ public Fact SpawnAngle(Fact fact)
t
.
fontSize
=
angle
.
GetComponentInChildren
<
TextMeshPro
>().
fontSize
*
angle
.
transform
.
GetChild
(
0
).
transform
.
GetChild
(
0
).
localScale
.
x
;
}
//Generate angle mesh
CircleSegmentGenerator
[]
segments
=
angle
.
GetComponentsInChildren
<
CircleSegmentGenerator
>();
foreach
(
CircleSegmentGenerator
c
in
segments
)
c
.
setAngle
(
angleValue
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment