Skip to content

Instantly share code, notes, and snippets.

View tntmeijs's full-sized avatar
💻
Software engineer

Tahar Meijs tntmeijs

💻
Software engineer
View GitHub Profile
@tntmeijs
tntmeijs / BezierCurve.cs
Last active September 6, 2023 15:38
Bezier curves in Unity3D using Casteljau's algorithm
using System.Collections.Generic;
using UnityEngine;
public class BezierCurve : MonoBehaviour
{
// Casteljau's algorithm based on the implementation in: "3D Math Primer for Graphics and Game Development"
public static Vector3 Curve(List<Vector3> points, float t)
{
Vector3[] allPoints = points.ToArray();
int n = allPoints.Length;
@tntmeijs
tntmeijs / editorscreenshot.cs
Created February 13, 2018 09:48
An Unity editor extension which enables you to take screenshots of the scene view window.
using System.IO;
using UnityEditor;
using UnityEngine;
/*
* This creative work (which includes code) is under exclusive copyright by default.
* Unless specified otherwise by Tahar Meijs, nobody else may use, copy, distribute,
* or modify this work without being at risk of take-downs, shake-downs, or litigation.
*
* Testing code does not mean you will are allowed to keep on using this codebase for
@tntmeijs
tntmeijs / layer2d.cs
Created February 13, 2018 09:47
A simple tool for the Unity2D editor which allows you to hide sorting layers.
using UnityEditor;
using UnityEngine;
/*
* This creative work (which includes code) is under exclusive copyright by default.
* Unless specified otherwise by Tahar Meijs, nobody else may use, copy, distribute,
* or modify this work without being at risk of take-downs, shake-downs, or litigation.
*
* Testing code does not mean you will are allowed to keep on using this codebase for
* your own personal / commercial gain. However, it is always encouraged to use this
@tntmeijs
tntmeijs / unitythreedimensionalperlinnoise.cs
Last active October 4, 2024 20:23
A 3D implementation using the 2D Perlin noise function of Unity3D.
public static float Noise3D(float x, float y, float z, float frequency, float amplitude, float persistence, int octave, int seed)
{
float noise = 0.0f;
for (int i = 0; i < octave; ++i)
{
// Get all permutations of noise for each individual axis
float noiseXY = Mathf.PerlinNoise(x * frequency + seed, y * frequency + seed) * amplitude;
float noiseXZ = Mathf.PerlinNoise(x * frequency + seed, z * frequency + seed) * amplitude;
float noiseYZ = Mathf.PerlinNoise(y * frequency + seed, z * frequency + seed) * amplitude;