Colour Cube: Difference between revisions
no edit summary
mNo edit summary |
Smilingfrog (talk | contribs) No edit summary |
||
Line 35:
The following algorithm assumes that the data is stored and accessed as m_size cubes of size 32, each m_size*m_size pixels, oriented left to right with an m_size*m_size*3 bytes stride, rather than as m_size cubes oriented top to bottom with a m_size*3 bytes stride (i.e. only one cube's data per line). Regardless of which is true, it seems that the following algorithm works to produce exact conversions from Xbox 360 colourcubes to PC colourcubes. Smaller cubes, like those from NFS:HP will likely need a different algorithm for calculating the offsets.
With the above in mind, to find the 3-byte (R, G and B) pixel data for position (x,y,z) in the PC m_pixels data, 3 bytes (R, G and B) can be read from the Xbox 360 m_pixels data at the offset calculated as follows where x, y and
{| class="wikitable"
|-
! x !! y !! z !! offset
|- style="vertical-align:top;"
| <syntaxhighlight>
43210</syntaxhighlight> || <syntaxhighlight>zzzzz
43210</syntaxhighlight> || <syntaxhighlight>o0=x0
o1=x1
o2=
o3=x2
o4=x3
o5=x4^
o6=
o7=
o8=
o9=
o10=
o11=
o12=
o13=
o14=
|}
Line 69 ⟶ 70:
end
# calculate offset, in pixels, of where to find the (x,y,z) pixel in the Xbox 360 data
# pixel offset in PC file is m_size * m_size * z + m_size * y + x
def calc_offset(x, y, z)
x0 = (x >> 0) & 0b1
x1 = (x >> 1) & 0b1
Line 76 ⟶ 78:
x3 = (x >> 3) & 0b1
x4 = (x >> 4) & 0b1
x5 = (x >> 5) & 0b1▼
x6 = (x >> 6) & 0b1▼
x7 = (x >> 7) & 0b1▼
x8 = (x >> 8) & 0b1▼
x9 = (x >> 9) & 0b1▼
y0 = (y >> 0) & 0b1
y1 = (y >> 1) & 0b1
Line 86 ⟶ 83:
y3 = (y >> 3) & 0b1
y4 = (y >> 4) & 0b1
o=(
(
(
(
(
((
(
(
(
((
(x3<<4)|
(x2<<3)|
(
(x1<<1)|
(x0<<0)
Line 109 ⟶ 111:
# now, convert the m_pixels data
data="".b
m_size.times do |
m_size.times do |x|
data << pixel_data
end
end
end
|