0

我有一个小工具可以用来转换一些网格文件。网格文件以 DEC3N 或 UDEC3 格式存储法线。如何将其解压缩到三个常规浮点 cpu 端?

4

1 回答 1

1

这里解释: http ://www.khronos.org/registry/gles/extensions/OES/OES_vertex_type_10_10_10_2.txt

Modifications to table 2.9 (Component conversions)

    Add the following entries:

        GLType                     Conversion of (x, y, z)  Conversion of w
        -------                    ----------------------   ===============
        INT_10_10_10_2_OES        (2c + 1)/(2^10 - 1)       (2c + 1)/(2^2 - 1)
        UNSIGNED_10_10_10_2_OES    c / (2^10 - 1)            c / (2^2 - 1)

因此,如果您在 UDEC3 格式的 32 位变量 N 中具有正常值,那么

x = (float)( (N>>22) / ((1<<10) - 1);
y = (float)( ((N>>12) & ((1<<10)-1)) / ((1<<10) - 1);
z = (float)( ((N>>2)  & ((1<<10)-1)) / ((1<<10) - 1);

很可能您还想解包 w,并将 xyz 与 w 分开。

于 2012-01-20T01:02:30.277 回答