Skip to content

Instantly share code, notes, and snippets.

View Talon1024's full-sized avatar

Kevin Caccamo Talon1024

View GitHub Profile
@Talon1024
Talon1024 / io_buffers.py
Created May 28, 2023 07:34
Blender script - export mesh to vertex/index buffers (for Rust)
from collections import namedtuple
from itertools import zip_longest
import bpy
# Copied from https://docs.python.org/3/library/itertools.html#itertools-recipes
# Used for grouping triangle vertex indices
def grouper(iterable, n, *, incomplete='fill', fillvalue=None):
"Collect data into non-overlapping fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx
# grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError
@Talon1024
Talon1024 / util_fso_ufvec.py
Last active April 9, 2022 01:22
Get uvec/fvec from a Blender Euler or Blender object
from mathutils import Matrix
def obori_to_vecs(ob):
return euler_to_vecs(ob.rotation_euler)
def euler_to_vecs(eu, fix=Matrix([[-1,0,0],[0,0,1],[0,1,0]])):
mtx_euler = eu.to_matrix()
mtx_fixed = mtx_euler * fix
# mtx_fixed = mtx_euler @ fix # Blender 2.8 and newer
# print("mtx_euler", mtx_euler, "mtx_fixed", mtx_fixed, sep="\n\n")
@Talon1024
Talon1024 / unSkullfuck.lua
Created December 9, 2017 00:48
SLADE script - replace textures
-- SLADE: https://github.com/sirjuddington/SLADE
-- License: WTFPL
local editor = App.mapEditor()
local sideTexParts = { "textureBottom", "textureMiddle", "textureTop" }
local texsToReplace = {
["FNEW1"] = "METAL",
["N_MTSP3I"] = "AQSUPP01",
["N_MTSP3J"] = "AQRUST10",
["N_MTSP3F"] = "-",
@Talon1024
Talon1024 / celtopng.py
Last active November 28, 2017 02:00
Convert CEL files to PNG (Python version)
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import struct
from sys import argv
try:
import bpy
from bpy.types import Operator
@Talon1024
Talon1024 / celtopng.cpp
Created September 27, 2017 23:08
Convert CEL files to PNG
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdint>
extern "C" {
#include "png.h"
}
struct Colour {
std::uint8_t red;