Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View rlalance's full-sized avatar
😃
Relic Odyssey: Ruins of Xantao Coming Soon!

Richard Lalancette rlalance

😃
Relic Odyssey: Ruins of Xantao Coming Soon!
View GitHub Profile
@rlalance
rlalance / CameraAnchor.cs
Created July 12, 2018 00:38 — forked from fadookie/CameraAnchor.cs
Screen-relative anchoring component for Unity3D. Find more Unity code at http://www.eliotlash.com/2015/01/unity3d-components-and-code-snippets/
/***
* This script will anchor a GameObject to a relative screen position.
* This script is intended to be used with CameraFit.cs by Marcel Căşvan, available here: http://gamedev.stackexchange.com/a/89973/50623
*
* Note: For performance reasons it's currently assumed that the game resolution will not change after the game starts.
* You could not make this assumption by periodically calling UpdateAnchor() in the Update() function or a coroutine, but is left as an exercise to the reader.
*/
/* The MIT License (MIT)
Copyright (c) 2015, Eliot Lash
@rlalance
rlalance / CameraAnchor.cs
Created July 12, 2018 00:38 — forked from fadookie/CameraAnchor.cs
Screen-relative anchoring component for Unity3D. Find more Unity code at http://www.eliotlash.com/2015/01/unity3d-components-and-code-snippets/
/***
* This script will anchor a GameObject to a relative screen position.
* This script is intended to be used with CameraFit.cs by Marcel Căşvan, available here: http://gamedev.stackexchange.com/a/89973/50623
*
* Note: For performance reasons it's currently assumed that the game resolution will not change after the game starts.
* You could not make this assumption by periodically calling UpdateAnchor() in the Update() function or a coroutine, but is left as an exercise to the reader.
*/
/* The MIT License (MIT)
Copyright (c) 2015, Eliot Lash
@rlalance
rlalance / txt
Created January 10, 2018 13:48
Regex: Select all lines not containing a WORD
^((?!WORD).)*$\r?\n?
static void simpleDeform_bend(const float factor, const float dcut[3], float *co)
{
float x = co[0], y = co[1], z = co[2];
float theta, sint, cost;
theta = x*factor;
sint = sin(theta);
cost = cos(theta);
if(fabsf(factor) > 1e-7f)
static void simpleDeform_twist(const float factor, const float *dcut, float *co)
{
float x = co[0], y = co[1], z = co[2];
float theta, sint, cost;
theta = z*factor;
sint = sin(theta);
cost = cos(theta);
co[0] = x*cost - y*sint;
@rlalance
rlalance / gist:22d0f28566716e3b267f10057c14941c
Created June 25, 2017 10:54 — forked from Madsy/gist:6980061
Working multi-threading two-context OpenGL example with GLFW 3.0.3 and GLEW 1.8
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <cmath>
#include <cstdio>
#include <limits>
#include <chrono>
#include <thread>
#include <mutex>
@rlalance
rlalance / Photoshop-LayersToPNG.jsx
Created May 8, 2017 00:45 — forked from NathanSweet/Photoshop-LayersToPNG.jsx
Adobe Photoshop script to export to Esoteric Software's Spine: http://esotericsoftware.com/
// This script exports photoshop layers as individual PNGs. It also
// writes a JSON file that can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Setting defaults.
var writePngs = true;
var writeTemplate = false;
var writeJson = true;
var ignoreHiddenLayers = true;
var pngScale = 1;
@rlalance
rlalance / Photoshop-LayersToPNG.jsx
Created May 8, 2017 00:45 — forked from NathanSweet/Photoshop-LayersToPNG.jsx
Adobe Photoshop script to export to Esoteric Software's Spine: http://esotericsoftware.com/
// This script exports photoshop layers as individual PNGs. It also
// writes a JSON file that can be imported into Spine where the images
// will be displayed in the same positions and draw order.
// Setting defaults.
var writePngs = true;
var writeTemplate = false;
var writeJson = true;
var ignoreHiddenLayers = true;
var pngScale = 1;
@rlalance
rlalance / BezierMesh.cs
Created April 22, 2017 20:38 — forked from mikezila/BezierMesh.cs
C# for Unity3D. Creates meshes from bezier patches. The resulting meshes are ready-to-render, including texture UVs.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class BezierMesh
{
public Mesh mesh;
public List<Vector2> uvs;
// Calculate UVs for our tessellated vertices
@rlalance
rlalance / BezierMesh.cs
Created April 22, 2017 20:38 — forked from mikezila/BezierMesh.cs
C# for Unity3D. Creates meshes from bezier patches. The resulting meshes are ready-to-render, including texture UVs.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class BezierMesh
{
public Mesh mesh;
public List<Vector2> uvs;
// Calculate UVs for our tessellated vertices