Skip to content

Instantly share code, notes, and snippets.

View mstevenson's full-sized avatar

Michael Stevenson mstevenson

View GitHub Profile
@aras-p
aras-p / rgbm.c
Created September 7, 2011 04:50
Encoding to RGBM
// in our case,
const float kRGBMMaxRange = 8.0f;
const float kOneOverRGBMMaxRange = 1.0f / kRGBMMaxRange;
// encode to RGBM, c = ARGB colors in 0..1 floats
float r = c[1] * kOneOverRGBMMaxRange;
float g = c[2] * kOneOverRGBMMaxRange;
float b = c[3] * kOneOverRGBMMaxRange;
@janderit
janderit / ZmqPollPool.cs
Created September 10, 2012 15:48
ZeroMQ 3.2 Single threaded container
/// <summary>
/// Encapsulates a zeroMQ context and a worker thread.
/// Use the ZmqPollPool to server multiple 0mq sockets with single-threaded semantics.
///
/// Use MarshalAndWait or MarshalAsync to marshal 0mq context access to the working thread.
/// Call Dispose to close all registered sockets and terminate the context and thread.
/// </summary>
public class ZmqPollPool : IDisposable
{
private TimeSpan _pollTimeout;
@aras-p
aras-p / gist:3952285
Created October 25, 2012 12:22
keywords
multi_compile A B C
multi_compile D E
A B C D E
+ . . + .
. + . + .
. . + + .
+ . . . +
. + . . +
. . + . +
@mstevenson
mstevenson / ShuffleBag.cs
Last active May 25, 2020 12:16
Shuffle bag algorithm implemented in C#
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ShuffleBag<T> : ICollection<T>, IList<T>
{
private List<T> data = new List<T> ();
private int cursor = 0;
private T last;
@AngryLoki
AngryLoki / ies2cycles.py
Last active January 30, 2024 16:47
IES to Cycles addon for new nodetree system! It only works for trunk builds of blender 2.66 and later versions!!! Thread on blenderartists.org: http://blenderartists.org/forum/showthread.php?276063 Old outdated version (no rig) for official 2.66 release (old nodetrees): https://gist.github.com/Lockal/5313485
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@mstevenson
mstevenson / CameraPlane.cs
Created January 17, 2013 00:47
A simple solution for grabbing and dragging physics objects in Unity. Attach a DragRigidbody component to an object that has a both collider and a rigidbody. Add the object to a layer named "Interactive".
using UnityEngine;
using System.Collections;
/// <summary>
/// Utility class for working with planes relative to a camera.
/// </summary>
public static class CameraPlane
{
/// <summary>
/// Returns world space position at a given viewport coordinate for a given depth.
@mildmojo
mildmojo / GoogleAnalytics.cs
Last active December 11, 2015 22:09
Reporting Unity game events to Google Analytics from the Unity Webplayer. Calls out to the Google javascript library loaded on the page, so the class is configuration-free.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
/* Google Analytics integration. Web page must be configured for GA with Google's javascript snippet.
*
* Based on a comment from 2010 found here:
* http://blog.mostlytigerproof.com/2009/10/06/gathering-statistics-using-google-analytics-and-unity-3d/
*
* Analytics category/action/label/value descriptions:
@janderit
janderit / zmqexample.cs
Created April 11, 2013 15:56
ZeroMQ 3.1 Router/Dealer example
public sealed class Host
{
private readonly string _zmqEndpoint;
private readonly Action<Action> _dispatcher;
private static ZmqSocket _server;
private static readonly ConcurrentQueue<Action> WaitToSend = new ConcurrentQueue<Action>();
public Host(string zmqEndpoint, Action<Action> dispatcher)
{
_zmqEndpoint = zmqEndpoint;
@michaelbartnett
michaelbartnett / LICENSE.txt
Last active October 17, 2022 10:29
Tuple implementation for use with Unity3d
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@clayton
clayton / ffmpeg-install.sh
Created August 9, 2013 18:55
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg --with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc --with-libvorbis --with-libvpx --with-libx264 --with-libxvid
# Easy Peasy
ffmpeg -i video.mp4 video.webm