-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathVRRenderingAPI.java
More file actions
123 lines (110 loc) · 4.45 KB
/
Copy pathVRRenderingAPI.java
File metadata and controls
123 lines (110 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package org.vivecraft.api.client;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix4f;
import org.vivecraft.api.client.data.RenderPass;
import org.vivecraft.api.data.VRPose;
import org.vivecraft.client.api_impl.VRRenderingAPIImpl;
import javax.annotation.Nullable;
/**
* The main interface for interacting with Vivecraft from rendering code. For other client-side code, one should use
* {@link VRClientAPI}.
*
* @since 1.3.0
*/
public interface VRRenderingAPI {
/**
* Gets the API instance for interacting with Vivecraft for rendering.
*
* @return The Vivecraft API instance for interacting with Vivecraft's rendering API.
* @since 1.3.0
*/
static VRRenderingAPI instance() {
return VRRenderingAPIImpl.INSTANCE;
}
/**
* Gets whether the current render pass is a vanilla render pass. This method's return value is only valid if this
* method was called while rendering.
*
* @return Whether the current render pass is a vanilla render pass.
* @since 1.3.0
*/
boolean isVanillaRenderPass();
/**
* Gets the current render pass. This method's return value is only valid if this method was called while rendering.
*
* @return The current render pass Vivecraft is performing.
* @since 1.3.0
*/
RenderPass getCurrentRenderPass();
/**
* Returns if the current render pass is the first render pass for this render cycle. This method's return value is
* only valid if this method was called while rendering.
*
* @return Whether the current render pass is the first one performed for this render cycle.
* @since 1.3.0
*/
boolean isFirstRenderPass();
/**
* Returns the camera rotation for the given {@link RenderPass}
* For Gui, Mirror or Vanilla passes this returns the regular camera rotation
*
* @param pass RenderPass to get the camera rotation for
* @return The camera rotation for the given RenderPass
* @since 1.3.0
*/
Matrix4f getRenderPassMatrix(RenderPass pass);
/**
* Gets the position that the provided {@link InteractionHand} renders at. Unlike
* {@link VRPose#getHand(InteractionHand)} from {@link VRClientAPI#getWorldRenderPose()},
* this returns a reasonable, default value for seated mode.
*
* @param hand The hand to get the rendering position of.
* @return The rendering position for the provided hand.
* @since 1.3.0
*/
Vec3 getHandRenderPos(InteractionHand hand);
/**
* Gets the position of the camera entity during rendering. Vivecraft sets the cameras entities position during a
* renderpass to the camera position for compatibility, so this can be used to get back the actual
* entities position.
* <br>
* Calling this outside a level, or when the camera has no entity will return garbage
*
* @param partialTick partial tick of the current frame
* @return The actual world position of the camera entity
* @since 1.3.8
*/
Vec3 getCameraEntityPos(float partialTick);
/**
* Sets the provided {@link PoseStack} to render at the position of and with the rotation of the provided
* {@link InteractionHand}, this assumes the given {@code stack} to be set to an identity.
*
* @param hand The hand to set the PoseStack to.
* @param stack The PoseStack to be set.
* @since 1.3.0
*/
void setupRenderingAtHand(InteractionHand hand, PoseStack stack);
/**
* Sets the provided {@link Matrix4f} to render at the position of and with the rotation of the provided
* {@link InteractionHand}, this assumes the given {@code matrix} to be an identity.
*
* @param hand The hand to set the Matrix4f to.
* @param matrix The Matrix4f to be set.
* @since 1.3.0
* @since Minecraft 1.20.5
*/
void setupRenderingAtHand(InteractionHand hand, Matrix4f matrix);
/**
* Gets the VR pose representing the player in Minecraft world coordinates interpolated for rendering.
*
* @param player Player to get the VR pose interpolated for rendering of.
* @return The VR pose representing the provided player in Minecraft space post-tick interpolated for rendering, or
* {@code null} if the player isn't in VR.
* @since 1.3.5
*/
@Nullable
VRPose getWorldRenderPose(Player player);
}