Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
8982b58c
Commit
8982b58c
authored
Nov 06, 2023
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding smooth interpolated motion for both camera and entity movement
parent
cdb644ea
Pipeline
#11648
passed with stage
in 22 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
ClientInit.java
src/client/java/com/owlmaddie/ClientInit.java
+12
-5
No files found.
src/client/java/com/owlmaddie/ClientInit.java
View file @
8982b58c
...
@@ -189,14 +189,21 @@ public class ClientInit implements ClientModInitializer {
...
@@ -189,14 +189,21 @@ public class ClientInit implements ClientModInitializer {
// Push a new matrix onto the stack.
// Push a new matrix onto the stack.
matrices
.
push
();
matrices
.
push
();
//
Translate to the entity's position
//
Interpolate entity position (smooth motion)
double
paddingAboveEntity
=
0.5
D
;
double
paddingAboveEntity
=
0.5
D
;
matrices
.
translate
(
entity
.
getPos
().
x
-
interpolatedCameraPos
.
x
,
Vec3d
interpolatedEntityPos
=
new
Vec3d
(
entity
.
getPos
().
y
-
interpolatedCameraPos
.
y
+
entity
.
getHeight
()
+
paddingAboveEntity
,
MathHelper
.
lerp
(
partialTicks
,
entity
.
prevX
,
entity
.
getPos
().
x
),
entity
.
getPos
().
z
-
interpolatedCameraPos
.
z
);
MathHelper
.
lerp
(
partialTicks
,
entity
.
prevY
,
entity
.
getPos
().
y
),
MathHelper
.
lerp
(
partialTicks
,
entity
.
prevZ
,
entity
.
getPos
().
z
)
);
// Translate to the entity's position
matrices
.
translate
(
interpolatedEntityPos
.
x
-
interpolatedCameraPos
.
x
,
interpolatedEntityPos
.
y
-
interpolatedCameraPos
.
y
+
entity
.
getHeight
()
+
paddingAboveEntity
,
interpolatedEntityPos
.
z
-
interpolatedCameraPos
.
z
);
// Calculate the difference vector (from entity to camera)
// Calculate the difference vector (from entity to camera)
Vec3d
difference
=
cameraEntity
.
getPos
().
subtract
(
entity
.
getPos
()
);
Vec3d
difference
=
interpolatedCameraPos
.
subtract
(
interpolatedEntityPos
);
// Calculate the yaw angle
// Calculate the yaw angle
double
yaw
=
-(
Math
.
atan2
(
difference
.
z
,
difference
.
x
)
+
Math
.
PI
/
2
D
);
double
yaw
=
-(
Math
.
atan2
(
difference
.
z
,
difference
.
x
)
+
Math
.
PI
/
2
D
);
...
...
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