Skip to content

Instantly share code, notes, and snippets.

@LordNed
LordNed / Unlit-Alpha-Color.shader
Created October 9, 2015 20:00
A #unity3d shader which is unlit, and supports a texture (with transparency) as well as a overall color for the texture sample to be multiplied by.
// Unlit alpha-blended shader.
// - no lighting
// - no lightmap support
Shader "Unlit/Transparent Color" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
}
@LordNed
LordNed / GearRotator.cs
Last active October 21, 2022 23:49
A quick example of creating a gear or object that can spin with mouse cursor. Expects object to rotate around its Forward vector.
using UnityEngine;
public class GearRotator : MonoBehaviour
{
[SerializeField] private float m_radiusThreshold = 4f;
private float m_startingAngle;
private bool m_isBeingRotated;
private void OnDrawGizmos()
@LordNed
LordNed / ActorUsages.csv
Last active August 29, 2015 14:26
A complete list of all actors for each map in The Legend of Zelda: The Wind Waker and their unique name (if they have one).
We can't make this file beautiful and searchable because it's too large.
Abesso, Room0, SCLS, sea
Abesso, Room0, SCLS, TF_04
Abesso, Room0, FILI,
Abesso, Room0, LBNK,
Abesso, Room0, PLYR,
Abesso, Room0, ACTR, Kui
Abesso, Room0, ACTR, Fire
Abesso, Room0, ACTR, Apzl
Abesso, Room0, ACTR, Apzl
Abesso, Room0, ACTR, swood
@LordNed
LordNed / Vector3Single.xaml.cs
Created July 26, 2015 23:27
A WPF control to bind against a Vector3 struct.
using OpenTK;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace WindEditor.UI
{
/// <summary>
/// Interaction logic for Vector3Single.xaml
/// </summary>
public class SimpleMeshHeader
{
public:
char[4] Magic;
public int SubMeshOffset;
public int NumSubMeshes;
public SimpleSubMesh* GetMesh(int index)
{
return (SimpleSubMesh *)(this + SubMeshOffset) + (index * sizeof(SimpleSubMesh));
#version 330 core
in vec3 Position;
in vec4 Color0;
in vec3 Tex0;
// Final Output
out vec4 PixelColor;
uniform sampler2D Texture0;
void main()
using GameFormatReader.Common;
using System.Diagnostics;
namespace WEditor.WindWaker.Loaders
{
public partial class J3DLoader
{
private DrawInfo LoadDRW1FromStream(EndianBinaryReader reader, long chunkStart)
{
DrawInfo drawInfo = new DrawInfo();
/// <summary>
/// Represents a file or subdirectory within a RARC archive.
/// </summary>
private class FileEntry
{
/// <summary>File ID. If 0xFFFF, then this entry is a subdirectory link.</summary>
public ushort ID { get; internal set; }
/// <summary>String hash of the <see cref="Name"/> field.</summary>
public ushort NameHashcode { get; internal set; }
/// <summary>Unknown value</summary>
private static void BuildSkeletonRecursive(SceneNode node, List<SkeletonBone> skeleton, List<SkeletonBone> rawJoints, int parentJointIndex)
{
switch(node.Type)
{
case J3DFileResource.HierarchyDataTypes.NewNode:
parentJointIndex = skeleton.Count - 1;
break;
case J3DFileResource.HierarchyDataTypes.Joint:
var joint = rawJoints[node.Value];
/// <summary> Delegate defines a function that decodes one instance of type T.</summary>
/// <param name="stream">The stream to decode the instance from</param>
private delegate T LoadFromStream<T>(EndianBinaryReader stream);
private static List<T> Collect<T>(EndianBinaryReader stream, LoadFromStream<T> function, int count)
{
List<T> values = new List<T>();
for(int i = 0; i < count; i++)
{
values.Add(function(stream));