@ aluigi
It wouldn't be any fun otherwise.
@semory
Reading the delta compressed index data isn't a problem.
There's about 100 lines of commenting in edgegeom_decompress.h explaining it.
(nevermind that chrrox showed me how to read it to begin with

)
The vertex "compression" isn't really compression from what I see.
Well, as far as position data is concerned anyway. The 24-bit unit vectors you could call compressed.
And maybe the X11Y11Z10N format. I guess it depends on how you look at it.
Reading those formats isn't an issue either way.
That's the trouble - near as I can tell, I'm reading all the data correctly (apart from the unit vecs), but the skin gives screwy results.
Also, maybe someone could help with the unit vectors?
This is mah code:
Code: Select all
def rUnitVecs(data):
spec = ['V0',10, 'V1',10, 'M',2, 'MS',1, 'W',1]
reader = BitReader(spec, BitReader.BIG_ENDIAN)
vBits = reader.read(data)
vBits.MS
V0 = vBits.V0 /2047.0
V1 = vBits.V1 /2047.0
mS = math.sqrt(1-(V0**2 + V1**2))
if vBits.MS == 1:
mS *= -1
if vBits.M == 0:
vx = mS
vy = V0
vz = V1
if vBits.W == 1:
vy *= -1
vz *= -1
elif vBits.M == 1:
vx = V0
vy = mS
vz = V1
if vBits.W == 1:
vx *= -1
vz *= -1
elif vBits.M == 2:
vx = V0
vy = V1
vz = mS
if vBits.W == 1:
vx *= -1
vy *= -1
return (vx,vy,vz)
With 10-bit values the divisor should be 1023.0, but V0**2 + V1**2 ends up being greater than 1 a lot which is very bad.
Not to mention a sure sign I'm going about it wrong.
And with the sign stored for the missing value, I figured it would be redundant for the W value to just flip it again hence the nested "if"s.
......did I mention fun???

EDIT: Whoops, I forgot. 20 bits for the values stored, 2 bits for the missing value, 1 bit for that value's sign, and 1 bit for W.