Skip to content

Instantly share code, notes, and snippets.

View maxattack's full-sized avatar

Max Kaufmann maxattack

View GitHub Profile
@maxattack
maxattack / AbsoluteScale.cs
Created November 22, 2018 07:38
ExecuteInEditMode Sample
using UnityEngine;
[ExecuteInEditMode]
public class AbsoluteScale : MonoBehaviour {
public Vector3 scale = new Vector3(1f, 1f, 1f);
#if UNITY_EDITOR
void Update () {
if (Application.isPlaying)
@maxattack
maxattack / DualQuaternion.cs
Created November 18, 2018 22:44
Dual Quaternion Sample Implementation for Unity3D
using UnityEngine;
/*
Dual-Quaternions are an alternate encoding for rigid transforms (translation + rotation),
with the special property that linear combinations will "arc" the translation in response
to rotation, producing a skinning interpolation that prevents the kind of collapsing you
get from simple linear interpolation of translations in their native coordinates.
Copyright (c) 2018 Max Kaufmann
@maxattack
maxattack / trinket.cpp
Last active May 5, 2018 20:36
Unstructured Embeddable Scripting VM for a toy game engine, 15 minutes in...
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include "glm/glm.hpp"
#include "glm/gtx/type_aligned.hpp"
namespace Trinket {
enum class OP : uint8_t {
NOOP,
@maxattack
maxattack / OrbitExt.cs
Created January 9, 2018 17:41
Orbit Camera Degrees-of-Freedom
/*
Copyright (c) 2018 Max Kaufmann
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:
@maxattack
maxattack / sketch.pde
Created March 8, 2017 23:54
RB remap
PImage img;
img = loadImage("https://espnfivethirtyeight.files.wordpress.com/2017/03/wasserman-landslides1.png", "png");
img.loadPixels();
int w = img.width;
int h = img.height;
int len = w * h;
for(int i=0; i<len; ++i) {
color c = img.pixels[i];
float r = red(c);
float b = blue(c);
@maxattack
maxattack / RobotPants.cs
Created April 18, 2016 05:16
Scrapped LD35 Compo Idea // Robot Pants
using InControl;
using System.Collections;
using UnityEngine;
[RequireComponent(typeof(CharacterController))]
public class RobotPants : MonoBehaviour {
public Transform hips;
public TwoBoneIK legLeft;
public TwoBoneIK legRight;
@maxattack
maxattack / QuaternionUtil.cs
Last active April 5, 2024 01:50
Some Helper Methods for Quaternions in Unity3D
using UnityEngine;
/*
Copyright 2016 Max Kaufmann (max.kaufmann@gmail.com)
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@maxattack
maxattack / svg.coffee
Created November 6, 2015 19:44
I had some SVG data to unpack, which I used as an excuse to flex my functional muscles...
checkStateChange = (token) -> switch(token)
when 'm' then state_moveTo
when 'c' then state_curveTo0
when 'l' then state_lineTo
when 'z' then null
else null
checkPoint = (token) ->
numbers = token.split ','
@maxattack
maxattack / Misc.cs
Created November 1, 2014 23:23
Unity: Prepare Files for Version Control
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
public static class Misc {
@maxattack
maxattack / example.cx
Last active August 29, 2015 14:06
Cx - Syntax Proposal for an "easier" C Syntax
// Runs on C runtime, exports C-ABI.
// No Headers
import cstdlib;
import cstdio;
struct vec2 {
float x, y;
// struct methods