11package dev .felnull .otyacraftengine .client .gui .screen .debug ;
22
33import com .mojang .blaze3d .vertex .PoseStack ;
4+ import com .mojang .math .Vector3f ;
45import dev .felnull .otyacraftengine .OtyacraftEngine ;
56import dev .felnull .otyacraftengine .client .gui .screen .OEBaseScreen ;
67import dev .felnull .otyacraftengine .client .gui .screen .debug .rendertest .BakedModelRenderTest ;
78import dev .felnull .otyacraftengine .client .gui .screen .debug .rendertest .IRenderTest ;
89import dev .felnull .otyacraftengine .client .gui .screen .debug .rendertest .ItemRenderTest ;
10+ import dev .felnull .otyacraftengine .client .util .OEClientUtil ;
911import dev .felnull .otyacraftengine .client .util .OERenderUtil ;
1012import net .minecraft .client .gui .components .Button ;
1113import net .minecraft .client .gui .components .EditBox ;
@@ -30,6 +32,8 @@ public class RenderTestScreen extends OEBaseScreen {
3032 private int sampleCount ;
3133 private int testCount = 1 ;
3234 private Motion motion = Motion .FIX ;
35+ private Vector3f cameraPos = new Vector3f (0 , 0 , 1 );
36+ private Vector3f cameraRot = new Vector3f ();
3337
3438 private EditBox countBox ;
3539
@@ -128,6 +132,46 @@ public void render(@NotNull PoseStack poseStack, int mx, int my, float f) {
128132 lastTime = System .nanoTime ();
129133 }
130134
135+ @ Override
136+ public void tick () {
137+ super .tick ();
138+ if (motion == Motion .FREE_LOOK ) {
139+ float speed = 1 ;
140+ if (OEClientUtil .isKeyInput (mc .options .keyUp )) {
141+ cameraPos .add (0 , -speed , 0 );
142+ }
143+ if (OEClientUtil .isKeyInput (mc .options .keyDown )) {
144+ cameraPos .add (0 , speed , 0 );
145+ }
146+ if (OEClientUtil .isKeyInput (mc .options .keyRight )) {
147+ cameraPos .add (speed , 0 , 0 );
148+ }
149+ if (OEClientUtil .isKeyInput (mc .options .keyLeft )) {
150+ cameraPos .add (-speed , 0 , 0 );
151+ }
152+ if (OEClientUtil .isKeyInput (mc .options .keySprint )) {
153+ cameraPos = new Vector3f (0 , 0 , 1 );
154+ cameraRot = new Vector3f ();
155+ }
156+ }
157+ }
158+
159+ @ Override
160+ public boolean mouseDragged (double d , double e , int i , double f , double g ) {
161+ if (motion == Motion .FREE_LOOK )
162+ cameraRot .add (-(float ) g , (float ) f , 0 );
163+ return super .mouseDragged (d , e , i , f , g );
164+ }
165+
166+ @ Override
167+ public boolean mouseScrolled (double d , double e , double f ) {
168+ if (motion == Motion .FREE_LOOK ) {
169+ cameraPos .add (0 , 0 , (float ) f * (OEClientUtil .isKeyInput (mc .options .keyShift ) ? 0.5f : 1f ));
170+ cameraPos .set (cameraPos .x (), cameraPos .y (), Math .max (cameraPos .z (), 1 ));
171+ }
172+ return super .mouseScrolled (d , e , f );
173+ }
174+
131175 private void reset () {
132176 eqAll = 0 ;
133177 sampleCount = 0 ;
@@ -140,14 +184,27 @@ private void renderTest(@NotNull PoseStack poseStack, @NotNull MultiBufferSource
140184
141185 poseStack .pushPose ();
142186
143-
144187 if (motion != Motion .TRANSLATED && motion != Motion .ROTED && motion != Motion .BOTH ) {
145188 double x = width / 2f ;
146189 double y = sy / 2f ;
190+
191+ if (motion == Motion .FREE_LOOK ) {
192+ x += cameraPos .x () * cameraPos .z ();
193+ y += cameraPos .y () * cameraPos .z ();
194+
195+
196+ poseStack .translate (x , y , 30 );
197+ OERenderUtil .poseRotateAll (poseStack , cameraRot .x (), cameraRot .y (), cameraRot .z ());
198+ poseStack .translate (-x , -y , -30 );
199+ }
200+
147201 poseStack .translate (x , y , 1050.0D );
148202 poseStack .scale (1 , 1 , -1 );
149203 poseStack .translate (0.0D , 0.0D , 1000 );
150204 poseStack .scale ((float ) 30 , (float ) -30 , (float ) 30 );
205+
206+ if (motion == Motion .FREE_LOOK )
207+ OERenderUtil .poseScaleAll (poseStack , cameraPos .z ());
151208 }
152209
153210 for (int i = 0 ; i < count ; i ++) {
@@ -209,6 +266,6 @@ public static void fInit() {
209266 }
210267
211268 private static enum Motion {
212- FIX , TRANSLATED , ROTED , BOTH ;
269+ FIX , TRANSLATED , ROTED , BOTH , FREE_LOOK ;
213270 }
214271}
0 commit comments