How to do delta compression in real life
Hi everbody, OK, I have read the article about network in Quake3. I think I understood most of it, but there are this functions (something like this): DeltaCompress(msg,last_state,current_state); DeltaUncompress(msg,last_state,current_state); I know what they do: Delta Compress takes the changes from last_state to current_state and writes them into the message. DeltaUncompress takes the changes from msg, applies them to last_state and writes current_state. But what is a good way to write the "changes"? I mean, there must be some extra information, telling me what exactly has changed. My Idea so far: A state is an array of, let us say, 512 bytes. Then I would need a header of 512 bits=64 bytes. Every bit in the header indicates, if the byte has changed or not (1 for has changed, 0 for has not changed). The bytes are then only written if they have changed. To me, this does not sound to good: 1/8 of the message size for the header ... I think that is to much. I searched the web and gamedev.net, found many sites telling me how great delta compression can be :). But no concrete information on how to do it. I have looked into the quake3 source-code and I failed to understand it :( Is there any resource/turoial/easy to understand code explaining how to do it efficently? Or can someone of you explain it to me a little? That would be very kind! Thanks! Nathan
You can apply delta on a higher level. For example, "position," "velocity," "orientation," "current controller input," and "currently selected weapon". Give each a bit -- they fit in a byte. Then include that entire piece of data only if it's changed since the last frame.
enum Bool { True, False, FileNotFound };
mmh ... but would I not be more fortunatet, if I can delta compress the "floats" representing the position in Example? I mean, the players are going to move every frame (well, almost every frame). But they do not move far -> Only the least significant one or two bytes of the position change. And would it not be cool to only have to send those one or two bytes?
I asked sth simular in this thread,
http://www.gamedev.net/community/forums/topic.asp?topic_id=345421
It contains a link to a sourceforge site. There you can also
find a .pdf explaining some things (haven't had the time to read
through it, so dunno how helpfull it is).
Add: I quickly took a look at the q3 sources. In msg.c (MSG_WriteDelta)
you can see what he's doing. The input of the function is the old and
new values
In there he is not writing the bits of a float which changed - rather
just a bit indicating that a float has changed (with the float behind
it) or a bit which says that it didn't change.
Just my interpretation from browsing through the source for 2 minutes :)
/R
http://www.gamedev.net/community/forums/topic.asp?topic_id=345421
It contains a link to a sourceforge site. There you can also
find a .pdf explaining some things (haven't had the time to read
through it, so dunno how helpfull it is).
Add: I quickly took a look at the q3 sources. In msg.c (MSG_WriteDelta)
you can see what he's doing. The input of the function is the old and
new values
In there he is not writing the bits of a float which changed - rather
just a bit indicating that a float has changed (with the float behind
it) or a bit which says that it didn't change.
Just my interpretation from browsing through the source for 2 minutes :)
/R
visit my website at www.kalmiya.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement