Skip to content

Instantly share code, notes, and snippets.

@Uradamus
Uradamus / specular.py
Created July 21, 2019 00:05
A simple script for determining an approriate specular value to use with Blender's Principled BSDF shader for a given IOR value.
#!/usr/bin/env python3
from sys import argv
ior = float(argv[1])
specular = ((ior-1)/(ior+1))**2/0.08
print(round(specular, 3))
@Uradamus
Uradamus / ptf2pam.py
Created May 4, 2019 22:17
This is a pretty simple conversion script to get .ptf texture files into a format that ImageMagick could further process into any desired output formats.
"""Copyright 2019 Uradamus
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@Uradamus
Uradamus / Building Size Standards
Created February 25, 2018 19:49
These are my notes on some rough sizes I started to collect from some testing to help with planning 3D game level designs.
avg char height 1.6
avg eye level 1.5
avg char diameter 0.4
floor thickness 0.4
wall thickness 0.2
wall height 3.2 residential
wall height 3.6 commercial
door width 1.2
door height 2.2
stair rise 0.2
@Uradamus
Uradamus / dwf2swf.py
Last active February 5, 2018 02:31
Decrypt dwf files to swf.
from sys import argv
magic = 28 # Defined here in case it needs to be changed.
with open(argv[1], 'rb') as dwf:
data = bytearray(dwf.read())
count = 0
for byte in data:
@Uradamus
Uradamus / compress_blend.sh
Last active April 28, 2016 21:50
Batch convert .blend files to gzip compressed .blend files.
for blend in *.blend; do
if [[ $(file -ib "$blend") == application/octet-stream* ]]; then
gzip -n1 "$blend"
mv "$blend.gz" "$blend"
fi
done
@Uradamus
Uradamus / NWN Linux Install Notes.md
Last active April 12, 2022 01:55
Some notes on getting the native version of NWN installed on Linux.

This uses the version available through GOG.com. Thanks go to TheCycoONE from the Arch Linux and GOG communities who's AUR package and forums posts were instrumental in my discovering how to finally install the GOG version of Neverwinter Nights on Linux.

First step is to ensure you have the necessary dependencies and utilities installed:

  • elfutils
  • glu
  • ia-32-libs (only if you are on a 64bit distro)
  • innoextract
  • libgl
  • libstdc++5
@Uradamus
Uradamus / TML_0.1.md
Last active February 5, 2018 02:38
Terse Markup Language 0.1 Specification

TML

TML is an acronym for Terse Markup Language. It is intended as a light weight syntax alternative to XML and other similar markup languages. Development of TML was begun by Ian S on April 8, 2013. TML is an open specification that is free to use by all for any purpose.

Example TML document

[!TML, version="0.1", encoding="UTF-8"]

[example element hierarchy:

[element1: "An element with a name attribute and a value."]

@Uradamus
Uradamus / Regex
Last active August 29, 2015 14:13
Regular Expression for parsing InWorldz and Second Life teleport links.
((?:(?:inworldz|iz|secondlife)://)|(?:hop://[\w_!',@%\$\-\.\+\*\(\)]+(?:\.(?:com|net|org))(?::\d{1,5})?))/?(?:inworldz/)?(?:app/(?:teleport/)?)?(?:(?:(agent|group|parcel)/(?:((?i)[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/about))|(?:([\w\-_%]+)/))(\-?\d{1,3})?/?(\-?\d{1,3})?/?(\-?\d{1,3})?
@Uradamus
Uradamus / ground_obj.lua
Last active August 29, 2015 14:01
Lua script that takes a file of elevation values and uses them to recreate an InWorldz / Second Life style ground mesh as an OBJ file.
--[[
Call this file with the height input file and the desired output file as arguments.
example: lua ground_obj.lua height.txt ground.obj
]]--
-- Read the input height values.
input = io.open(arg[1], "r")
heights = {}
for line in input:lines() do
table.insert(heights, tonumber(line))
@Uradamus
Uradamus / combo.lua
Created April 12, 2014 13:47
Combination key press detection function in LOVE.
function combo (key1, key2)
if love.keyboard.isDown(key1) and love.keyboard.isDown(key2) then
return true
else
return false
end
end