I did see references to little endian, and those are the exact numbers I was expecting for those bytes, thank you! I think I’m starting to understand it now that I see all of the parts working together.
Here is the final code, but I will also start a new thread with this code in case anyone wants to do something similar (here).
import hypermedia.net.*;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
UDP udp;
int PORT_RX= 7000; //port : set in opentrack
String HOST_IP="192.168.86.28"; // must be computer IP address, use ipconfig to find
String receivedFromUDP = "";
int x,y,z;
void setup() {
size(200, 100);
udp= new UDP(this, PORT_RX, HOST_IP);
//udp.log(true);
udp.listen(true);
super.start();
}
void draw() {
background(0);
textSize(20);
text(x, 20, 30);
text(y, 20, 50);
text(z, 20, 70);
}
void receive(byte[] data) {
ByteBuffer bb = ByteBuffer.allocate(data.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.put(data);
bb.rewind();
x = (int) bb.getDouble();
y = (int) bb.getDouble();
z = (int) bb.getDouble();
//println("x,y,z: " + xx + ", " + yy + ", " + zz);
}
float byteArrayToFloat(byte[] data) {
int intBits =
data[3] << 24 | (data[2] & 0xFF) << 16 | (data[1] & 0xFF) << 8 | (data[0] & 0xFF) |
data[4] << 32 | (data[5] & 0xFF) << 40 | (data[6] & 0xFF) << 48 | (data[7] & 0xFF) << 56;
return Float.intBitsToFloat(intBits);
}