How to package network data?

Blitz3D Forums/Blitz3D Programming/How to package network data?

Is there a best way to package up (mostly floating point) data for packet transmission? Currently I'm using a modified version of the example code that came with Blitzplay Lite, shown below.

Ideally I'd like to transmit more than just the simple things shown below, including more trivial things like the position and orientation of each individual wheel, the driver's head and arms positions, exhaust flames etc..., but not if it means transmitting huge packets.

Is there a better way?


Type TYPE_netdata
	Field x#,y#,z#
	Field yaw# , pitch# , roll#
	Field velx# , vely# , velz#
	
	Field name$
	Field net_id%
	
	Field mesh
End Type


			pnet.TYPE_netdata = First TYPE_netdata

			pnet\x# = EntityX#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\y# = EntityY#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\z# = EntityZ#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\pitch# = EntityPitch#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\yaw# = EntityYaw#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\roll# = EntityRoll#(GAMEDATA\vehicle1\chassis_mesh , True)
			pnet\velx# = TOKRB_GetVelocityX#(GAMEDATA\vehicle1\chassis_RB)
			pnet\vely# = TOKRB_GetVelocityY#(GAMEDATA\vehicle1\chassis_RB)
			pnet\velz# = TOKRB_GetVelocityZ#(GAMEDATA\vehicle1\chassis_RB)

			msgtosend$ = BP_FloatToStr(pnet\x#) + BP_FloatToStr(pnet\y#) + BP_FloatToStr(pnet\z#) 
			msgtosend$ = msgtosend$ + BP_FloatToStr(pnet\pitch#)  + BP_FloatToStr(pnet\yaw#)  + BP_FloatToStr(pnet\roll#)
			msgtosend$ = msgtosend$ + BP_FloatToStr(pnet\velx#)  + BP_FloatToStr(pnet\vely#)  + BP_FloatToStr(pnet\velz#)

			If UI\NETWORK_sendupdates 
				BP_UDPMessage (0,1,msgtosend)
			EndIf