This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Utility to map points inside a unit square (0,0)-(1,1) to a quad defined by 4 points. | |
/// Uses math from: | |
/// https://github.com/hecomi/uHomography/blob/master/Assets/uHomography/Runtime/Scripts/Homography.cs | |
/// Instructions to use for projection mapping: | |
/// * Gather screen coordinates of four corner points, and call UpdateMatrix with them. | |
/// * The Transform method now will map a point inside a unit square to an appropriate point on the screen quad. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CalculateCorners() | |
{ | |
float aspectRatio = Screen.width / (float)Screen.height; | |
if (this.Camera == null) | |
{ | |
this.Camera = Camera.main; | |
} | |
// IMPORTANT: Do not use Screen.width here, use Camera.pixelWidth!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using UnityEngine; | |
namespace Lumic.Utils | |
{ | |
/// <summary> | |
/// Assumes string keys. | |
/// Kind of works, use the +/- buttons on the "Keys". +/- Buttons on values list does't work. | |
/// Example usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example: | |
* let param1 = 5; | |
* createSlider(0, 10, param1, 0.01, "Param 1", (val) => { param1 = val; }); | |
*/ | |
export function createSlider (min, max, value, step, text, valueChangeHandler) { | |
const container = document.createElement('div'); | |
const label = document.createElement('div'); | |
const elt = document.createElement('input'); | |
label.setAttribute('style', "background: #214288; color: white; font-family: monospace; font-size: large"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using UnityEngine; | |
namespace Lumic.Structure.Procedural | |
{ | |
public class MeshPool : ObjectPool<Mesh> | |
{ | |
protected override Mesh CreateNew() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Unity ## | |
*.cs diff=csharp text | |
*.cginc text | |
*.shader text | |
*.mat merge=unityyamlmerge eol=lf | |
*.anim merge=unityyamlmerge eol=lf | |
*.unity merge=unityyamlmerge eol=lf | |
*.prefab merge=unityyamlmerge eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using EasyButtons; | |
using UnityEngine.Rendering; | |
namespace Lumic.Utils | |
{ | |
/// <summary> | |
/// TODO support orthographic cameras | |
/// </summary> | |
[RequireComponent(typeof(Camera))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git init | |
curl -o .gitignore https://github.com/github/gitignore/raw/main/Unity.gitignore | |
curl -o .gitattributes https://gist.github.com/nemotoo/b8a1c3a0f1225bb9231979f389fd4f3f/raw/dc3e8cab80fc62d1c60db70c761b1ffa636aa796/.gitattributes | |
git add .gitignore | |
git add .gitattributes | |
git commit -m "Initialize with gitignore/git LFS attributes" | |
# Optional: add useful packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using EasyButtons; | |
namespace Lumic.Compute | |
{ | |
using System; | |
using System.Linq; | |
using System.Reflection; | |
using System.Collections.Generic; | |
using UnityEngine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming triangle side, x = 1 unit | |
# Height of triangle, H = sqrt(x) * x / 2 = 0.866025403784438 | |
# Height of centroid h = x / (2 * sqrt(3)) = 0.288675134594812; 2h = 0.577350269189624 | |
# Lower Right Vertex: (x/2, -h) | |
v 0.5 -0.288675134594812 0 | |
# Top Vertex: (0, 2h) | |
v 0 0.577350269189624 0 | |
# Lower Left Vertex (-x/2, -h) | |
v -0.5 -0.288675134594812 0 | |
# Note: OBJ format uses 1-based indexing, not 0-based |
NewerOlder