March 28, 2024, 23:39
bigger smaller reset     1020px Wide width Full width Reset   * *

Gildor's Forums

  Homepage Facebook Read news on Twitter Youtube channel Github page
Welcome, Guest. Please login or register.
Did you miss your activation email?

« previous next »
Print
Author Topic: UnHavok.cpp  (Read 292 times)
John76
Newbie
*
Posts: 3


View Profile
« on: May 04, 2020, 22:15 »


Hi,

Can someone help me and explain about Havok model
See... UnHavok.cpp... Sub FixupHavokPackfile...

It may sound funny to you, but I'm trying to translate it into Vb.Net

for example I loaded all localfixup, globalfixup from model and now i need to do fixups

can anyone explain me this part of function
how to do the same in vb code to work,

Tnx


//////////////////////////////////////////////////////////////////////////////////////////////////////

for (LocalFixup *LF = (LocalFixup*)(SectionStart + Sec->m_localFixupsOffset);
          LF < (LocalFixup*)(SectionStart + Sec->m_globalFixupsOffset);
          LF++)
      {
         if (LF->fromOffset == 0xFFFFFFFF) continue;      // padding
//         appPrintf("Lfix: %X -> %X\n", LF->fromOffset, LF->toOffset);
         // fixup
         *(byte**)(SectionStart + LF->fromOffset) = SectionStart + LF->toOffset;
      }
      // process global fixups
      for (GlobalFixup *GF = (GlobalFixup*)(SectionStart + Sec->m_globalFixupsOffset);
          GF < (GlobalFixup*)(SectionStart + Sec->m_virtualFixupsOffset);
          GF++)
      {
         if (GF->fromOffset == 0xFFFFFFFF) continue;      // padding
//         appPrintf("Gfix: %X -> %X / %X\n", GF->fromOffset, GF->toSec, GF->toOffset);
         // fixup
         byte *SectionStart2 = PackStart + Sections[GF->toSec].m_absoluteDataStart;
         *(byte**)(SectionStart + GF->fromOffset) = SectionStart2 + GF->toOffset;
      }

//////////////////////////////////////////////////////////////////////////////////////////////////////

Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #1 on: May 04, 2020, 22:30 »

Hi,
That code was used only for Bioshock 1 and 2, for reading skeleton information from Havok. I doubt it's suitable for anything else.
Havok stored data in a single block, which was serialized with a single read operation. However data contains pointers, which can't be stored in the file directly. So, there's "fixup" table which tells where these pointers are located. The code you referenced in your message performs conversion of in-file pointer placeholder to "real" pointers. It's similar to what Win32 PE file format does.
Logged
John76
Newbie
*
Posts: 3


View Profile
« Reply #2 on: May 04, 2020, 22:49 »

Tnx Gildor!

I loaded all sections from model... _class_, _type_, _data_
each separately, though they are all together in your code...

In principle it would mean something like this... I think...for example

DataSection is array of bytes... {1, 2, 33, 4, 55, 6, 7, 8, 9, 10, 10, 114, .....}

For example 33 is (at fromOffset 3) and 114 is (at toOffset 12)
I know this is not Datasection(fromoffset) = DataSection(tooffset)

When i reach 33 i jump to essentially 144?

Or my BinarReader starts from offset 12???

Tnx again!



Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #3 on: May 04, 2020, 22:53 »

Man, I wrote thin is 2009. It's too old, I don't remember details. However things should be simple if you understand the concept.
Logged
John76
Newbie
*
Posts: 3


View Profile
« Reply #4 on: May 04, 2020, 23:02 »

I agree! Tnx  Smiley
Logged
Print 
« previous next »
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS