cyphen156

Don't Starve 모작 프로젝트 with Win32 API #1 리소스 추출 본문

프로젝트/dont'starve 모작

Don't Starve 모작 프로젝트 with Win32 API #1 리소스 추출

cyphen156 2024. 10. 8. 00:36

진짜 돈스타브 Ktools에 있는 ktech랑 krane 작동안되서 뒤지게 삽질했다. 거의 한 3일동안 이것만 본거같은데

유니티 에셋 스타일로 되잇는것도아니라서 추출도 안되가지고 시작도못하고 모작프로젝트 타이틀 바꿀뻔햇다.

추출안됬던 근본적인 원인은 imagemagick 버전이 7로 올라가면서 api 사용법이 바뀌엇기 때문이었다.

우선 ktech는 Latex파일 확장자인 .tex파일을 png로 바꿔주는 프로그램으로 텍스쳐 뽑으려면 필요했고, 이 뽑아진 텍스쳐를 가지고 krane을 통해 애니메이션 처리를 도와주는 스프라이트 애니메이션 포맷인 .scml로 변환해준다. 

아무튼 WINDOWS 11운영체제를 기준으로 설명하자면 imagemagick을 6.9.13-17-q16-x64-dll을 설치한다.

ImageMagick (legacy) – Download

 

ImageMagick

Create, Edit, Compose, or Convert Digital Images

legacy.imagemagick.org

중요한건 NonHDRI버전 써야한다.

ImageMagick-6.9.13-17-Q16-x64-dll.exe

그 다음 할것은 klei 회원가입하고 다음 링크가서 ktools 다운로드 받아라. 

괜히 윈도우 바이너리로 받아서 cmake로 빌드하는 헛고생하지말자. ← 주인장이 이거햇다가 버전다운하고, 내부 클래스 뜯어고쳐서 해야했음....클래스 헤더파일에 있는 자료형 다형성으로 명시적 특수화 해놨던데, 64비트 운영체제 stdint 헤더에 있는 INT_64, config.h에 있는 자료형 매크로 size_T 충돌나더라

무튼 돌아가게 햇으니 다행이긴한데...

How to extract animations from the game | Don't Starve Wiki | Fandom

 

How to extract animations from the game

Original post by MMueck First, you need to download and install Spriter, a free 2D animation program from BrashMonkey. It can be used to access the sprite animations and export them for example. You can find and download the newest versions here. Second, y

dontstarve.fandom.com

Download Spriter – BrashMonkey

 

Download Spriter

Download Spriter Windows Vista or higher required. Note: If after installing Spriter you get an error that vcomp120.dll is missing, please install the Visual Studio 2013 C++ runtime. If you are on 32 bit Windows you

brashmonkey.com

두개 다 다운로드 받은 다음 다운로드 받은 압축파일과 설치킷을 실행해서 설치하고 돈스타브 anim 폴더를 통째로 복사해서 가져와서 ktools-4.4.4폴더 안에 집어넣자. 

스팀 돈스타브 다운로드시 따로 경로설정 안했다면 default 경로는 다음과 같을 것이다.

아 anim폴더 안에 압축파일 한 700개쯤 있는데 이거 다 압축 풀어놔야 합니다.

C:\Programs\Steam\steamapps\common\Don't Starve\data\anim

다했으면 cmd 켜서 명령어 치자

ktools폴더가 있는곳으로 디렉토리 체인지 : 별 작업 안했다면 아마 downloads에 있을거다

cd downloads/ktools-4.4.4

krane.exe "C:\Users\cyphen\Downloads\ktools-4.4.4\anim\tentacle_pillar\anim.bin" "C:\Users\cyphen\Downloads\ktools-4.4.4\anim\tentacle_pillar\build.bin" "C:\Users\cyphen\Downloads\ktools-4.4.4\anim\tentacle_pillar\Output"

자 이제 귀찮으니까 자동화 스크립트 두개 만들자.

파이썬 파일이다. 실행하는건 파이참 깔아서 알아서 실행하시오.

scmlExtractor.py

import os
import subprocess

# ktools 폴더 경로 설정
ktools_path = r"C:\Users\cyphen\Downloads\ktools\anim"

# krane.exe 파일의 절대 경로
krane_path = r"C:\Users\cyphen\Downloads\ktools\krane.exe"
ktech_path = r"C:\Users\cyphen\Downloads\ktools\ktech.exe"

# 각 서브폴더에 대해 반복 처리
for folder_name in os.listdir(ktools_path):
    folder_path = os.path.join(ktools_path, folder_name)

    # 폴더인지 확인 (파일은 건너뜀)
    if not os.path.isdir(folder_path):
        print(f"Skipping {folder_name}, not a folder.")
        continue

    # anim.bin, build.bin, atlas-0.tex 파일 경로 설정
    anim_path = os.path.join(folder_path, "anim.bin")
    build_path = os.path.join(folder_path, "build.bin")
    atlas_path = os.path.join(folder_path, "atlas-0.tex")
    output_path = os.path.join(folder_path, "Output")

    # 출력 폴더가 없으면 생성
    if not os.path.exists(output_path):
        os.makedirs(output_path)

    # 파일이 존재하는지 확인 후 처리
    if os.path.exists(anim_path) and os.path.exists(build_path):
        # krane 실행
        print(f"Processing {folder_name} with krane...")
        subprocess.run([krane_path, anim_path, build_path, output_path])
    else:
        print(f"Skipping {folder_name}, anim.bin or build.bin not found.")

    if os.path.exists(atlas_path):
        # ktech 실행
        print(f"Processing {folder_name} with ktech...")
        subprocess.run([ktech_path, atlas_path, output_path])
    else:
        print(f"Skipping {folder_name}, atlas-0.tex not found.")

texToPng.py

import os
import subprocess

# ktools 폴더 경로 설정
ktools_path = r"C:\Users\cyphen\Downloads\ktools\anim"

# ktech.exe 파일의 절대 경로
ktech_path = r"C:\Users\cyphen\Downloads\ktools\ktech.exe"

# 각 서브폴더에 대해 반복 처리
for folder_name in os.listdir(ktools_path):
    folder_path = os.path.join(ktools_path, folder_name)

    # 폴더인지 확인 (파일은 건너뜀)
    if not os.path.isdir(folder_path):
        print(f"Skipping {folder_name}, not a folder.")
        continue

    # atlas-0.tex 파일 경로 설정
    tex_file_path = os.path.join(folder_path, "atlas-0.tex")
    ktex_output_path = os.path.join(folder_path, "ktexOutput")

    # ktexOutput 폴더가 없으면 생성
    if not os.path.exists(ktex_output_path):
        os.makedirs(ktex_output_path)

    # TEX 파일이 존재하는지 확인 후 처리
    if os.path.exists(tex_file_path):
        # ktech 실행
        print(f"Extracting TEX file in {folder_name} with ktech...")
        subprocess.run([ktech_path, tex_file_path, ktex_output_path])
    else:
        print(f"Skipping {folder_name}, TEX file not found.")

파일 추출은 대강 다 끝난거 같다. 부족한 부분이 조금 있긴 한데 이건 DST 리소스들이 anim폴더 외부에 다른 파일들이 퍼져있고, 참조해서 텍스쳐를 입히는 방식을 써서 그렇다. 

파일 추출 모두 완료하면 대강 1.3기가쯤 나오는데 이것은 구글드라이브로 제공하겠다.

https://drive.google.com/drive/folders/1QGqzlj973L0dYcrACfHqXE9IgCX2qwYp?usp=sharing

 

Google Drive: 로그인

이메일 또는 휴대전화

accounts.google.com