Compare commits
5 Commits
832ba66295
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b513956e70 | |||
| 2ab94a1cb8 | |||
| a18368acd2 | |||
| c56cbd741b | |||
| ef80b0faba |
@@ -2,7 +2,7 @@
|
|||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||||
|
|
||||||
#define MyAppName "KAvEAT"
|
#define MyAppName "KAvEAT"
|
||||||
#define MyAppVersion "1.0.0"
|
#define MyAppVersion "1.1.0"
|
||||||
#define MyAppPublisher "bonkmaykr"
|
#define MyAppPublisher "bonkmaykr"
|
||||||
#define MyAppURL "https://kangworlds.net/"
|
#define MyAppURL "https://kangworlds.net/"
|
||||||
#define MyAppUpdateURL "https://git.worlio.com/bonkmaykr/KAvEAT/releases"
|
#define MyAppUpdateURL "https://git.worlio.com/bonkmaykr/KAvEAT/releases"
|
||||||
@@ -65,6 +65,7 @@ Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_webp_.dll"; De
|
|||||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_xml_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_xml_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zip_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zip_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zlib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\CORE_RL_zlib_.dll"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
|
Source: "C:\Users\kangang\source\repos\KAvEAT\x64\Release\mogrify.exe"; DestDir: "{app}"; Flags: ignoreversion
|
||||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
|
|||||||
76
main.c
76
main.c
@@ -3,6 +3,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <MagickWand/MagickWand.h>
|
#include <MagickWand/MagickWand.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int isPowerOfTwo(int x) {return x && (!(x & (x - 1)));}
|
int isPowerOfTwo(int x) {return x && (!(x & (x - 1)));}
|
||||||
|
|
||||||
@@ -34,11 +37,12 @@ unsigned int nearest_power_of_2(unsigned int n) {
|
|||||||
struct options {
|
struct options {
|
||||||
uint32_t r;
|
uint32_t r;
|
||||||
int s;
|
int s;
|
||||||
uint8_t c;
|
uint16_t c;
|
||||||
int o;
|
int o;
|
||||||
int l;
|
int l;
|
||||||
int w;
|
int w;
|
||||||
int h;
|
int h;
|
||||||
|
int d;
|
||||||
};
|
};
|
||||||
|
|
||||||
void printHelp() {
|
void printHelp() {
|
||||||
@@ -48,6 +52,11 @@ void printHelp() {
|
|||||||
"A maximum of 360 different frames can be used for a single avatar.\n"
|
"A maximum of 360 different frames can be used for a single avatar.\n"
|
||||||
"If the size of any frame does not match, it will be resized to match the first frame.\n"
|
"If the size of any frame does not match, it will be resized to match the first frame.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"When using KAvEAT to create environment textures, please keep in mind that Worlds has\n"
|
||||||
|
"a limit of 9x9 tiles per CMP/MOV file due to the URL parser only reading single digits.\n"
|
||||||
|
"This makes the practical maximum resolution of avatars 2048x2048. World textures can not\n"
|
||||||
|
"have more than 9 frames but can bypass both limits by splitting walls into more pieces.\n"
|
||||||
|
"\n"
|
||||||
"Available options:\n"
|
"Available options:\n"
|
||||||
" -r # Maximum resolution, where # is a power of 2. For example, 256 pixels would be \"-r 8\"\n"
|
" -r # Maximum resolution, where # is a power of 2. For example, 256 pixels would be \"-r 8\"\n"
|
||||||
" -s Stretch the image when non-pot or mismatched size, as opposed to fitting it within.\n"
|
" -s Stretch the image when non-pot or mismatched size, as opposed to fitting it within.\n"
|
||||||
@@ -57,6 +66,8 @@ void printHelp() {
|
|||||||
" so using this setting with different image sizes will cause visible bars to appear\n"
|
" so using this setting with different image sizes will cause visible bars to appear\n"
|
||||||
" unless you combine it with the -s option, which will always fill the canvas for each\n"
|
" unless you combine it with the -s option, which will always fill the canvas for each\n"
|
||||||
" frame. The same is true for all imported frames which contain an alpha channel.\n"
|
" frame. The same is true for all imported frames which contain an alpha channel.\n"
|
||||||
|
" -d Don't run COMPIMG, don't delete temporary files. Useful if COMPIMG is broken for some\n"
|
||||||
|
" reason, or if you want to customize the command line options given to it.\n"
|
||||||
// " -l Enable Lanczos filtering when scaling the image.\n" //point filter unimplemented
|
// " -l Enable Lanczos filtering when scaling the image.\n" //point filter unimplemented
|
||||||
//" -w Specify the number of subdivisions to make horizontally per frame.\n"
|
//" -w Specify the number of subdivisions to make horizontally per frame.\n"
|
||||||
//" Use this if you are importing a spritesheet. Each cut is perfectly even.\n"
|
//" Use this if you are importing a spritesheet. Each cut is perfectly even.\n"
|
||||||
@@ -66,13 +77,24 @@ void printHelp() {
|
|||||||
//" -h Same as -w, but vertical. If used with -w, KAvEAT will create each chunk\n"
|
//" -h Same as -w, but vertical. If used with -w, KAvEAT will create each chunk\n"
|
||||||
//" from each row left-to-right first, not each column top-to-bottom.\n"
|
//" from each row left-to-right first, not each column top-to-bottom.\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
DWORD procIDs[2];
|
||||||
|
DWORD maxCount = 2;
|
||||||
|
if (GetConsoleProcessList((LPDWORD)procIDs, maxCount) == 1) {
|
||||||
|
printf("\n\nTHIS PROGRAM IS DESIGNED FOR USE WITH A TERMINAL.\n"
|
||||||
|
"Please run cmd.exe first! Then you can use the tool.\n");
|
||||||
|
system("pause");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printNoFrames() { printf("You need to specify at least one frame to use, goober.\n"); }
|
void printNoFrames() { printf("You need to specify at least one frame to use, goober.\n"); }
|
||||||
|
|
||||||
int main(const int argc, char *argv[]) {
|
int main(const int argc, char *argv[]) {
|
||||||
printf(
|
printf(
|
||||||
"Knowledge Adventure Worlds Easy Avatar Tool, version 1\n"
|
"Knowledge Adventure Worlds Easy Avatar Tool, version 1.1.1\n"
|
||||||
"Copyright (c) 2025 Brett \"bonkmaykr\" Bergstrom\n"
|
"Copyright (c) 2025 Brett \"bonkmaykr\" Bergstrom\n"
|
||||||
"This program is free software under the MIT license.\n"
|
"This program is free software under the MIT license.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@@ -91,22 +113,25 @@ int main(const int argc, char *argv[]) {
|
|||||||
struct options opt;
|
struct options opt;
|
||||||
opt.r = 0;
|
opt.r = 0;
|
||||||
opt.s = 0;
|
opt.s = 0;
|
||||||
opt.c = 255;
|
opt.c = 0xDEAD;
|
||||||
opt.o = 0;
|
opt.o = 0;
|
||||||
opt.l = 0;
|
opt.l = 0;
|
||||||
opt.w = 0;
|
opt.w = 0;
|
||||||
opt.h = 0;
|
opt.h = 0;
|
||||||
|
opt.d = 0;
|
||||||
uint16_t numFrames = 0;
|
uint16_t numFrames = 0;
|
||||||
char* frames[360];
|
char* frames[360];
|
||||||
|
|
||||||
int i = 2;
|
int i = 2;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
if (argv[i][0] == '+') {
|
if (argv[i][0] == '+') {
|
||||||
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
if (numFrames < 360) {
|
||||||
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
frames[numFrames] = (char*)malloc(strlen(argv[i]) + 1);
|
||||||
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
memcpy(frames[numFrames], &argv[i][1], strlen(argv[i]) + 1);
|
||||||
|
printf("Adding frame to search index: %s\n", frames[numFrames]);
|
||||||
|
|
||||||
numFrames++;
|
numFrames++;
|
||||||
|
} else printf("REJECTING new frame as it exceeds the frame limit.\n");
|
||||||
} else if (strcmp(argv[i], "-r") == 0) {
|
} else if (strcmp(argv[i], "-r") == 0) {
|
||||||
if (i == argc-1) { printf("No parameter for option: -r\n"); return 0; }
|
if (i == argc-1) { printf("No parameter for option: -r\n"); return 0; }
|
||||||
int r = pow(2, trunc(atof(argv[i+1])));
|
int r = pow(2, trunc(atof(argv[i+1])));
|
||||||
@@ -122,9 +147,11 @@ int main(const int argc, char *argv[]) {
|
|||||||
} else if (strcmp(argv[i], "-c") == 0) {
|
} else if (strcmp(argv[i], "-c") == 0) {
|
||||||
if (i == argc-1) { printf("No parameter for option: -c\n"); return 0; }
|
if (i == argc-1) { printf("No parameter for option: -c\n"); return 0; }
|
||||||
const int c = trunc(atof(argv[i+1]));
|
const int c = trunc(atof(argv[i+1]));
|
||||||
if (c < 1 || c > 256) { printf("Invalid number of colors: %s\n", argv[i+1]); return 0; }
|
if (c < 1 || c > 256 - (!opt.o)) { printf("Invalid number of colors: %s\nThe maximum palette size is 255 for transparent MOVs and 256 for opaque ones.\n", argv[i+1]); return 0; }
|
||||||
opt.c = c - 1;
|
opt.c = c - 1;
|
||||||
i++;
|
i++;
|
||||||
|
} else if (strcmp(argv[i], "-d") == 0) {
|
||||||
|
opt.d = !opt.d;
|
||||||
} else {
|
} else {
|
||||||
printf("I don't know what \"%s\" means!\n", argv[i]);
|
printf("I don't know what \"%s\" means!\n", argv[i]);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -132,6 +159,7 @@ int main(const int argc, char *argv[]) {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (numFrames == 0) { printNoFrames(); return 0; }
|
if (numFrames == 0) { printNoFrames(); return 0; }
|
||||||
|
if (opt.c == 0xDEAD) { if (opt.o) opt.c = 254; else opt.c = 255; }
|
||||||
|
|
||||||
if (MagickReadImage(mw, frames[0]) == MagickFalse) { printf("ERROR trying to read %s\n", frames[0]); return 0;}
|
if (MagickReadImage(mw, frames[0]) == MagickFalse) { printf("ERROR trying to read %s\n", frames[0]); return 0;}
|
||||||
MagickSetImageFormat(mw, "BMP3");
|
MagickSetImageFormat(mw, "BMP3");
|
||||||
@@ -293,6 +321,11 @@ int main(const int argc, char *argv[]) {
|
|||||||
|
|
||||||
MagickWriteImage(chunk, framename);
|
MagickWriteImage(chunk, framename);
|
||||||
|
|
||||||
|
char* command = (char*)malloc(512); // lazy hack until magickwand is fixed
|
||||||
|
sprintf(command, "mogrify -depth 8 -define bmp:format=bmp3 -type palette -compress none %s", framename);
|
||||||
|
system(command);
|
||||||
|
free(command);
|
||||||
|
|
||||||
iw++;
|
iw++;
|
||||||
}
|
}
|
||||||
ih++;
|
ih++;
|
||||||
@@ -301,6 +334,7 @@ int main(const int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
fclose(partlist);
|
fclose(partlist);
|
||||||
|
|
||||||
|
if (!opt.d) {
|
||||||
// Pass on images to COMPIMG
|
// Pass on images to COMPIMG
|
||||||
printf("Encoding texture file...\n");
|
printf("Encoding texture file...\n");
|
||||||
char* command = (char*)malloc((54 + 3 * abs(1-opt.o) + strlen(filename))*sizeof(char)); // MSVC
|
char* command = (char*)malloc((54 + 3 * abs(1-opt.o) + strlen(filename))*sizeof(char)); // MSVC
|
||||||
@@ -312,9 +346,31 @@ int main(const int argc, char *argv[]) {
|
|||||||
sprintf(command, "./compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c+1, argTransparent, filename);
|
sprintf(command, "./compimg.exe -ace -c%d -r0 -pt%s -emov -M%s +segments.txt", opt.c+1, argTransparent, filename);
|
||||||
#endif
|
#endif
|
||||||
printf("%s\n", command);
|
printf("%s\n", command);
|
||||||
if (system(command)) { printf("ERROR trying to run COMPIMG!\n"); return 0; }
|
if (system(command)) { printf("ERROR trying to run COMPIMG!\nMake sure that COMPIMG.EXE is inside of the folder you are working in.\n"); }
|
||||||
|
|
||||||
printf("\n\n!!! DONE !!!\nYour avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
printf("Cleaning up temporary files...\n");
|
||||||
|
while (i < numFrames) {
|
||||||
|
int ih = 0;
|
||||||
|
while (ih < piecesY) {
|
||||||
|
int iw = 0;
|
||||||
|
while (iw < piecesX) {
|
||||||
|
char* framename = (char*)malloc(12 * piecesX * piecesY * sizeof(char)); // MSVC
|
||||||
|
sprintf(framename, "f%d%d%d.bmp", i, iw, ih);
|
||||||
|
remove(framename);
|
||||||
|
free(framename);
|
||||||
|
|
||||||
|
iw++;
|
||||||
|
}
|
||||||
|
ih++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remove("segments.txt");
|
||||||
|
|
||||||
|
printf("\n\n!!! DONE !!!\n");
|
||||||
|
if (opt.d)
|
||||||
|
printf("Your avatar name is: %s%ds*%dh*%dv*.mov\n", filename, numFrames, piecesX, piecesY);
|
||||||
|
|
||||||
if(mw) mw = DestroyMagickWand(mw);
|
if(mw) mw = DestroyMagickWand(mw);
|
||||||
MagickWandTerminus();
|
MagickWandTerminus();
|
||||||
|
|||||||
Reference in New Issue
Block a user