55import com .calicraft .vrjester .config .Constants ;
66import com .calicraft .vrjester .utils .vrdata .VRDataAggregator ;
77import com .calicraft .vrjester .utils .vrdata .VRDataState ;
8+ import com .calicraft .vrjester .utils .vrdata .VRDataType ;
89import com .calicraft .vrjester .utils .vrdata .VRDataWriter ;
9- import com .calicraft .vrjester .vox .Vattice ;
10+ import com .calicraft .vrjester .vox .Vox ;
1011import net .minecraft .client .entity .player .ClientPlayerEntity ;
1112import net .minecraft .particles .BasicParticleType ;
1213import net .minecraft .particles .ParticleTypes ;
2223import static com .calicraft .vrjester .VrJesterApi .VIVECRAFTLOADED ;
2324import static com .calicraft .vrjester .VrJesterApi .getMCI ;
2425import static com .calicraft .vrjester .utils .tools .SpawnParticles .createParticles ;
26+ import static com .calicraft .vrjester .utils .vrdata .VRDataType .VRDATA_ROOM_PRE ;
2527
2628public class TriggerEventHandler {
27- private static final VRDataAggregator data_aggregator = new VRDataAggregator ();
29+ private static final VRDataAggregator preRoomDataAggregator = new VRDataAggregator (VRDataType .VRDATA_ROOM_PRE , false );
30+ private static final VRDataAggregator preWorldDataAggregator = new VRDataAggregator (VRDataType .VRDATA_WORLD_PRE , false );
2831 private static Config config = new Config (Constants .DEV_CONFIG_PATH );
2932// private static final VRDataWriter vrDataWriter = new VRDataWriter("VRJester_Data", new String[]{"rc"}, 0);
3033// private static VRDataWriter voxDataWriter;
@@ -34,7 +37,7 @@ public class TriggerEventHandler {
3437 private long elapsed_time = 0 ;
3538
3639 private static Vector3d origin ;
37- private static Vattice activeVattice ;
40+ private static Vox activeVox ;
3841 private static int [] previousId ;
3942 private static int particle = 0 ;
4043 private static final BasicParticleType [] particleTypes = new BasicParticleType []{ParticleTypes .FLAME ,
@@ -64,19 +67,19 @@ public void onJesterTrigger(InputEvent.KeyInputEvent event) {
6467// for (Vox vox: voxList) {
6568// // VOX ID: {3, 8 , 26}
6669// System.out.println("VOX ID: " + Arrays.toString(vox.getId()));
67- // for (VRDataState vrDataState : data_aggregator .getData()) {
70+ // for (VRDataState vrDataState : preRoomDataAggregator .getData()) {
6871// System.out.println("VOX: " + vox.centroid);
6972// System.out.println("RC: " + vrDataState.getRc()[0]);
7073// if (vox.hasPoint(vrDataState.getRc()[0]))
7174// createParticles(ParticleTypes.FLAME, vrDataState.getRc());
7275// }
7376// }
7477// }
75- origin = null ; activeVattice = null ; voxIds .clear ();
78+ origin = null ; activeVox = null ; voxIds .clear ();
7679 elapsed_time = System .nanoTime () - elapsed_time ;
77- // JesterRecognition recognizer = new JesterRecognition(data_aggregator .getData(), elapsed_time);
80+ // JesterRecognition recognizer = new JesterRecognition(preRoomDataAggregator .getData(), elapsed_time);
7881// recognizer.isLinearGesture(VRDevice.RC);
79- data_aggregator .clear (); elapsed_time = 0 ;
82+ preRoomDataAggregator .clear (); elapsed_time = 0 ;
8083 // Fire event or trigger something based on recognized gesture
8184 }
8285 }
@@ -90,24 +93,24 @@ public void onClientTick(TickEvent.ClientTickEvent event) throws IOException {
9093
9194 if (VrJesterApi .MOD_KEY .isDown () && !VIVECRAFTLOADED )
9295 createParticles (ParticleTypes .FLAME , null );
93- // Listen for VR data after trigger
94- if (listener ) { // Capture data in real time
95- VRDataState vrDataState = data_aggregator .listen ();
96- // * Single Vox Recognition Working
97- if (origin == null && activeVattice == null ) {
98- origin = vrDataState .getRc ()[0 ];
99- activeVattice = new Vattice (origin );
100- previousId = activeVattice .getId ();
96+
97+ if (listener ) { // Capture VR data in real time after trigger
98+ VRDataState vrDataRoomPre = preRoomDataAggregator .listen ();
99+ VRDataState vrDataWorldPre = preWorldDataAggregator . listen ();
100+ if (origin == null && activeVox == null ) {
101+ origin = vrDataRoomPre .getRc ()[0 ];
102+ activeVox = new Vox (origin , false );
103+ previousId = activeVox .getId ();
101104 particle = 0 ; trace = "[0, 0, 0]" ;
102105 voxIds .add (previousId );
103106// voxDataWriter = new VRDataWriter();
104107// voxDataWriter.write("[0, 0, 0]");
105108 } else {
106- // vrDataWriter.write(vrDataState );
109+ // vrDataWriter.write(vrDataRoomPre );
107110
108111 // Note: The getDeltaMovement() initially returns player position before returning the actual delta movement like a sussy baka
109- activeVattice .updateVoxPosition (player .getDeltaMovement ()); // Try hardcoding a set # of vox#.updateVox()
110- int [] currentId = activeVattice .updateVox (vrDataState .getRc ()[0 ]);
112+ // activeVox .updateVoxPosition(player.getDeltaMovement());
113+ int [] currentId = activeVox .updateVox (vrDataRoomPre .getRc ()[0 ]);
111114 if (!Arrays .equals (previousId , currentId )) { // Update Vox Trace
112115// voxDataWriter.write(Arrays.toString(currentId));
113116 voxIds .add (currentId );
@@ -119,8 +122,10 @@ public void onClientTick(TickEvent.ClientTickEvent event) throws IOException {
119122 particle = 0 ;
120123 System .out .println ("TRACE: " + trace );
121124 } else {
122- createParticles (particleTypes [particle ], vrDataState .getRc ());
125+ createParticles (particleTypes [particle ], vrDataWorldPre .getRc ());
123126 }
127+
128+
124129// for (int i = 0; i < gestures.length; i++) { // CHECK SINGLE GESTURE (UPPERCUT PUNCH)
125130// if (trace.equals(gestures[i])) {
126131// particle = particleTypes.length - 1; trace = "[0, 0, 0]";
@@ -139,8 +144,7 @@ public void onClientTick(TickEvent.ClientTickEvent event) throws IOException {
139144 }
140145
141146
142- // * Write data to file(s) to debug/analyze
143- // vrDataWriter.write(vrDataState);
147+
144148// if (sleep % 20 == 0) // Print every 1 second
145149// System.out.println("JESTER LISTENING");
146150// if (sleep == 0) { // Reset trigger when done
0 commit comments