Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

ParaWorld vertex unpacking

Featured Replies

  • Author
  • Localization

DryFun, posted Thu Apr 05, 2018 2:40 pm (33825)


I need some help with vertex unpacking

Main topic viewtopic.php?f=9&t=6998
BSM viewer https://github.com/BlasSoriano/Paraworld

Basically everything is right but it seems there is a problem with z coordinate:
(I rotate the model for more convenient viewing)
Front view https://www.dropbox.com/s/lvowyfl6jzybr ... 281).jpg
Top view https://www.dropbox.com/s/uh5hanlcid43h ... 281).jpg

Vertices unpacking script https://www.dropbox.com/s/jm51uzgze7kzpwp/Vertex.cs
Vertices.obj https://www.dropbox.com/s/2mlc74ra9a3qiva/Vertices.obj

What could be the problem?
  • Author
  • Localization

sleepyzay, posted Thu Apr 05, 2018 7:14 pm (33836)


Is it possible that your'e reading the wrong selection of bits for your x y z coordinates? I normally see packed vertices in either the 11:11:10 or 10:10:10 format, never 13:13:6.
  • Author
  • Localization

DryFun, posted Thu Apr 05, 2018 7:37 pm (33838)


BSM said: "There are still 9 remaining bits, for an unknown yet purpose: bits 0-12: x bits 13-25: y bits 26-38: z bits 39-47: unknown bits 48-55: u bits 56-63: v"
And as far as I can remember, he unpack the whole model correctly
  • Author
  • Localization

sleepyzay, posted Thu Apr 05, 2018 9:04 pm (33839)


Oh, I assumed a ulong was 32 bits, not 64. But the bit selection still feels arbitrary. Do you have a sample file I can look at?
  • Author
  • Localization

DryFun, posted Fri Apr 06, 2018 3:28 am (33842)


Yes
There are no triangles, only bits 0-12: x bits 13-25: y bits 26-38: z bits 39-47: unknown bits 48-55: u bits 56-63: v
  • Author
  • Localization

Acewell, posted Fri Apr 06, 2018 7:45 am (33844)


looks like could be a typo in Vertex.cs on line 61
https://github.com/BlasSoriano/Paraworl ... /Vertex.cs
Code:
z = ix * (boundingBox.max.Z - boundingBox.min.Z) / MAX_VALUE_13BITS   boundingBox.min.Z;

should be :?:
Code:
z = iz * (boundingBox.max.Z - boundingBox.min.Z) / MAX_VALUE_13BITS   boundingBox.min.Z;
  • Author
  • Localization

sleepyzay, posted Fri Apr 06, 2018 8:45 am (33846)


To get your desired values you need to divide your group of bits by their size. Since they're all 13, they all get divided by 8191.0.

Code:
ix = (float)(((packedBits >> 0) & 0x1FFF) / 8191.0);
iy = (float)(((packedBits >> 13) & 0x1FFF) / 8191.0);
iz = (float)(((packedBits >> 26) & 0x1FFF) / 8191.0);
  • Author
  • Localization

DryFun, posted Fri Apr 06, 2018 9:53 am (33847)


Yes, it should be the next step
Code:
        public static Vertex FromUInt64(ulong packedBits, BoundingBox boundingBox)
        {
            int ix, iy, iz;
            float x, y, z;

            ix = (int)((packedBits >> 0) & 0x1FFF);
            iy = (int)((packedBits >> 13) & 0x1FFF);
            iz = (int)((packedBits >> 26) & 0x1FFF);

            x = ix * (boundingBox.max.X - boundingBox.min.X) / MAX_VALUE_13BITS boundingBox.min.X;
            y = iy * (boundingBox.max.Y - boundingBox.min.Y) / MAX_VALUE_13BITS boundingBox.min.Y;
            z = ix * (boundingBox.max.Z - boundingBox.min.Z) / MAX_VALUE_13BITS boundingBox.min.Z;

            return new Vertex(x, y, z);
        }
  • Author
  • Localization

DryFun, posted Sat Apr 07, 2018 5:55 am (33858)


Thanks
Acewell wrote:
looks like could be a typo in Vertex.cs on line 61
https://github.com/BlasSoriano/Paraworl ... /Vertex.cs
Code:
z = ix * (boundingBox.max.Z - boundingBox.min.Z) / MAX_VALUE_13BITS   boundingBox.min.Z;

should be :?:
Code:
z = iz * (boundingBox.max.Z - boundingBox.min.Z) / MAX_VALUE_13BITS   boundingBox.min.Z;


It was so stupid...
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.