def main(): [tls, tlc] = genLogTrigoTables(32 / 6) # print (codegen.buffer2pyCode("tabLog2Sin", tls)) # print (codegen.buffer2pyCode("tabLog2Cos", tlc)) print(codegen.buffer2cCode("tabLog2Sin", "signed char", tls)) print(codegen.buffer2cCode("tabLog2Cos", "signed char", tlc)) print(codegen.buffer2cCode("tab_1oversin", "unsigned char", log1oversin())) print(codegen.buffer2cCode("tab_1overcos", "unsigned char", log1overcos()))
def main(): tabAngles = list(config.rayAngles()) stRayAngles = codegen.buffer2cCode("tabRayAngles", "signed char", tabAngles) print(stRayAngles) tabCol = [] for angle in range(tabAngles[0], tabAngles[-1] - 1, -1): idxCol = rayAngle2Col(angle * config.FIX_TO_RAD) tabCol.append(idxCol) stAngles2Col = codegen.buffer2cCode("tabAngle2Col", "unsigned char", tabCol) print(stAngles2Col)
def image2TextureBuf(filepathname): base = os.path.basename(filepathname) namerad = os.path.splitext(base)[0] im = Image.open(filepathname) rgb_im = im.convert('RGB') imw, imh = im.width, im.height bufimgtranslat = [] for ii in range(imw): for jj in range(imh): ## [ref texel_codec] r, g, b = rgb_im.getpixel((ii, jj)) texel_value = (r // 85) * 16 + (g // 85) * 4 + (b // 85) bufimgtranslat.append(texel_value) cCode = codegen.buffer2cCode("texture_" + namerad, "unsigned char", bufimgtranslat) return cCode
def main(): tabIdxRdTexture = [] for u in range(1, 64): # FIXME change 64 to configurable value for v in iea(config.TEXTURE_SIZE, u): tabIdxRdTexture.append(v) strTabIdxRdTexture = codegen.buffer2cCode("tabIdxRdTexture", "unsigned char", tabIdxRdTexture) print(strTabIdxRdTexture)
def main(): coeff = config.TEXTURE_SIZE / config.WALL_HEIGHT stMulti120_high = codegen.buffer2cCode("multi120_high", "unsigned char", [((120 * ii) & 0xFF00) >> 8 for ii in range(64)]) stMulti120_low = codegen.buffer2cCode("multi120_low", "unsigned char", [(120 * ii) & 0x00FF for ii in range(64)]) stMulti32_low = codegen.buffer2cCode("multi32_high", "unsigned char", [((32 * ii) & 0xFF00) >> 8 for ii in range(32)]) stMulti32_high = codegen.buffer2cCode("multi32_low", "unsigned char", [(32 * ii) & 0x00FF for ii in range(32)]) stMultiCoeff = codegen.buffer2cCode( "multiCoeff", "unsigned char", [round(coeff * ii) for ii in range(45)]) print(stMulti120_low) print(stMulti120_high) print(stMulti32_low) print(stMulti32_high) print(stMultiCoeff)
def main(): for ii in range(64): r, g, b = (ii >> 4) & 0x03, (ii >> 2) & 0x03, (ii) & 0x03 tabRightRed.append(encodeLColor[r]) tabLeftRed.append(encodeHColor[r]) tabRightGreen.append(encodeLColor[g]) tabLeftGreen.append(encodeHColor[g]) tabRightBlue.append(encodeLColor[b]) tabLeftBlue.append(encodeHColor[b]) print(codegen.buffer2cCode("tabRightRed", "unsigned char", tabRightRed)) print(codegen.buffer2cCode("tabLeftRed", "unsigned char", tabLeftRed)) print(codegen.buffer2cCode("tabRightGreen", "unsigned char", tabRightGreen)) print(codegen.buffer2cCode("tabLeftGreen", "unsigned char", tabLeftGreen)) print(codegen.buffer2cCode("tabRightBlue", "unsigned char", tabRightBlue)) print(codegen.buffer2cCode("tabLeftBlue", "unsigned char", tabLeftBlue))
from PIL import Image import codegen im = Image.open('img.bmp') rgb_im = im.convert('RGB') imw, imh = im.width, im.height def toSimpleRgb(val): return val//85 bufimg = [] for jj in range (imh): for ii in range (imw): r, g, b = rgb_im.getpixel((ii, jj)) bufimg.append(toSimpleRgb(r)*16 + toSimpleRgb(g)*4 + toSimpleRgb(b)) print (r, g, b, toSimpleRgb(r), toSimpleRgb(g), toSimpleRgb(b), toSimpleRgb(r)*16 + toSimpleRgb(g)*4 + toSimpleRgb(b)) # print(buf_blue) cCode = f"#define TEXTURE_WIDTH {imw}\n#define TEXTURE_HEIGHT {imh}\n" cCode += codegen.buffer2cCode("bufimg", bufimg) print (cCode)
def main(): tabUnfish = unfish() stTabUnfish = codegen.buffer2cCode("unfish", "unsigned char", tabUnfish) print(stTabUnfish)
def main(): unlogd2hh = [ round(config.WALL_HEIGHT * config.FOCAL / 2**(ii / 32)) for ii in range(0, 256) ] print(codegen.buffer2cCode("unlogd2hh", "unsigned char", unlogd2hh))