From 8a8076e48fa315cc9440b35ac552b0e760c3cf48 Mon Sep 17 00:00:00 2001 From: Gurkengewuerz Date: Tue, 24 Oct 2023 15:59:51 +0200 Subject: [PATCH] feat: added imager --- .env | 13 ++++- assets/usercontent/avatar/.gitkeep | 0 compose.yaml | 12 +++++ imager/Dockerfile | 21 ++++++++ imager/README.md | 80 ++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 assets/usercontent/avatar/.gitkeep create mode 100644 imager/Dockerfile create mode 100644 imager/README.md diff --git a/.env b/.env index 2978bc0..741bc91 100644 --- a/.env +++ b/.env @@ -15,4 +15,15 @@ RCON_HOST=127.0.0.1 RCON_PORT=3001 RCON_ALLOWED=127.0.0.1 -RT_THREADS=12 \ No newline at end of file +RT_THREADS=12 + +API_HOST=imager +API_PORT=3000 +AVATAR_SAVE_PATH=/app/assets/usercontent/avatar/ +# talking internally - can also be a external using FQDN +AVATAR_ACTIONS_URL=http://assets/assets/gamedata/HabboAvatarActions.json +AVATAR_FIGUREDATA_URL=http://assets/assets/gamedata/FigureData.json +AVATAR_FIGUREMAP_URL=http://assets/assets/gamedata/FigureMap.json +AVATAR_EFFECTMAP_URL=http://assets/assets/gamedata/EffectMap.json +AVATAR_ASSET_URL=http://assets/assets/bundled/figure/%libname%.nitro +AVATAR_ASSET_EFFECT_URL=http://assets/assets/bundled/effect/%libname%.nitro diff --git a/assets/usercontent/avatar/.gitkeep b/assets/usercontent/avatar/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/compose.yaml b/compose.yaml index efc2b34..00e5d90 100644 --- a/compose.yaml +++ b/compose.yaml @@ -92,5 +92,17 @@ services: - ./assets/:/usr/share/nginx/html networks: [nitro] + imager: + build: + context: imager + env_file: + - .env + volumes: + - ./assets/:/app/assets/ + ports: + - 3001:3000 + restart: unless-stopped + networks: [nitro] + networks: nitro: diff --git a/imager/Dockerfile b/imager/Dockerfile new file mode 100644 index 0000000..383e432 --- /dev/null +++ b/imager/Dockerfile @@ -0,0 +1,21 @@ +FROM node:lts as builder + +ARG BRANCH=dev +ARG COMMIT=7ff2405 + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + git \ + build-essential \ + python3 \ + && rm -rf /var/lib/apt/lists/* +RUN apt remove apt --autoremove -y --allow-remove-essential + +RUN git clone --branch ${BRANCH} --recurse-submodules https://github.com/billsonnn/nitro-imager.git . +RUN git checkout $COMMIT +RUN yarn install +RUN yarn build + +ENTRYPOINT ["node", "/app/dist/src/main.js"] +#ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/imager/README.md b/imager/README.md new file mode 100644 index 0000000..187779d --- /dev/null +++ b/imager/README.md @@ -0,0 +1,80 @@ +# Nitro Imager + +This tool serves as a server-side habbo-imager using the same avatar generator from nitro-renderer. It will download & cache in memory `.nitro` assets. Rendered figures will also save to a local folder to prevent re-renders. You will use the same process as your nitro-client to update assets for the imager. + +## URL paramaters + +Their are a few different options you may pass as URL parameters to generate figures with different actions. All parameters are optional. + +| key | default | description | +| -------------- | ------- | ------------------------------------------------------------------- | +| figure | null | The figure string to be rendered | +| action | null | The actions to render, see actions below | +| gesture | std | The gesture to render, see gestures below | +| direction | 2 | The direction to render, from 0-7 | +| head_direction | 2 | The head direction to render, from 0-7 | +| headonly | 0 | A value of `0` or `1` | +| dance | 0 | A dance id of 0-4 to render | +| effect | 0 | An effect id to render | +| size | n | The size to render, see sizes below | +| frame_num | 0 | The frame number to render | +| img_format | png | A value of `png` or `gif`. Gif will render all frames of the figure | + +## Actions + +You may render multiple actions with a comma separater + +Example: `&action=wlk,wav,drk=1` + +##### Posture + +| key | description | +| ------ | ---------------------------- | +| std | Renders the standing posture | +| wlk,mv | Renders the walking posture | +| sit | Renders the sitting posture | +| lay | Renders the laying posture | + +##### Expression + +| key | description | +| -------- | ------------------------------- | +| wav,wave | Renders the waving expression | +| blow | Renders the kissing expression | +| laugh | Renders the laughing expression | +| respect | Renders the respect expression | + +##### Carry / Drink + +To hold a certain drink, use an equal separator with the hand item id. You can only render one of these options at a time + +| key | description | +| -------- | ------------------------ | +| crr,cri | Renders the carry action | +| drk,usei | Renders the drink action | + +## Gestures + +| key | description | +| --- | ------------------------------ | +| std | Renders the standard gesture | +| agr | Renders the aggravated gesture | +| sad | Renders the sad gesture | +| sml | Renders the smile gesture | +| srp | Renders the surprised gesture | + +## Sizes + +| key | description | +| --- | ---------------------------- | +| s | Renders the small size (0.5) | +| n | Renders the normal size (1) | +| l | Renders the large size (2) | + +## Known Issues + +- GIFs are only able to render 1 bit alpha channels, therefore most effects will not correctly render due to using many different alpha values. +- The rendered canvas size may not match habbos imager exactly, we will hopefully have this addressed soon. + +## Test String: +[`figure=hd-180-1.ch-255-66.lg-280-110.sh-305-62.ha-1012-110.hr-828-61&action=std,wav&gesture=std&direction=2&head_direction=2&size=l&img_format=png`](http://labs.habox.org/generator-avatar) \ No newline at end of file