Skip to content

Instantly share code, notes, and snippets.

// Untested Tilt Brush script
// Try running this in a tool script.
// Gleaned from ParametricStrokeCreator.cs and PointerManager.cs
var xfPointer_CS = App.Scene.ActiveCanvas.AsCanvas[rAttachPoint];
ParametricStrokeCreator currentCreator = new CircleCreator(xfPointer_CS);
PointerScript script = PointerManager.m_Instance.MainPointer;
script.CreateNewLine(
App.Scene.ActiveCanvas,
xfPointer_CS,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using TiltBrush;
using UnityEditor;
using UnityEngine;
using Valve.Newtonsoft.Json.Utilities;
using Object = UnityEngine.Object;
using UnityEngine;
using UnityEngine.Events;
//
//Custom grabbable script wich checks if the grabber "is mine" to actually grab
//
namespace Networking.Pun2
{
[RequireComponent(typeof(Photon.Pun.PhotonView))]
def gltf(request, lat, lng, distance):
scale = 100000
pnt = GEOSGeometry(f"POINT({lng} {lat})", srid=4326)
buildings = Building.objects.filter(outline__dwithin=(pnt, km2deg(distance)))
scene = Scene()
centroid_total = (0, 0)
count = 0.0
// Generate the ground grid and extrude random buildings
var grid = Grids.Grids.MakeGrid(GridType, GridShape, width, depth);
grid = grid.VertexRotate(new OpParams(Jitter, randomValues: true));
var floors = grid.FaceKeep(new OpParams(.1f, pickRandomly));
var houses = floors.Loft(new OpParams(0, x=>Random.Range(.5f, 1.5f)));
var (walls, roofs) = houses.Split(new OpParams(FaceSelections.Existing));
// Make window holes
walls = walls.Loft(new OpParams(0.75f, FaceSelections.AllNew));
walls = walls.FaceSlide(new OpParams(0.15f, FaceSelections.Existing));
@andybak
andybak / town.cs
Last active September 17, 2020 10:37
var grid = Grids.Grids.MakeGrid(GridType, GridShape, width, depth);
grid = grid.VertexRotate(new OpParams(Jitter, randomize = true));
var houses = grid.FaceKeep(new OpParams(randomPerFace, .1f));
houses = houses.Loft(new OpParams(funcB=x=>Random.Range(.5f, 1.5f)));
var (walls, domes) = houses.Split(new OpParams(FaceSelections.Existing));
walls = walls.Loft(new OpParams (FaceSelections.AllNew, 0.75f));
walls = walls.FaceSlide(new OpParams (0.15f, FaceSelections.Existing));
walls = walls.FaceRemove(new OpParams (FaceSelections.Existing));
walls = walls.Shell(0.025f);
domes = domes.Dome(FaceSelections.All, DomeHeight, DomeSegments, DomeCurve1, DomeCurve2);
// https://www.shadertoy.com/view/lldyRB
#define samples 8.0
#define PI 10.159265359
#define offset 3.0
#define strength -6.5
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
using System;
using Conway;
using Johnson;
using UnityEngine;
using Random = UnityEngine.Random;
[ExecuteInEditMode]
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class RandomSpaceshipGenerator : MonoBehaviour
public ConwayPoly Subdivide(float offset)
{
var faceIndices = new List<int[]>();
var vertexPoints = new List<Vector3>();
// Add existing vertices
for (int vertexIndex = 0; vertexIndex < Vertices.Count; vertexIndex++)
{
var x = Vertices[vertexIndex];
//Moebius transformations in 3d, by reverse stereographic projection to the 3-sphere,
//rotation in 4d space, and projection back.
//by Daniel Piker 09/08/20
//Feel free to use, adapt and reshare. I'd appreciate a mention if you post something using this.
//You can also now find this transformation as a component in Grasshopper/Rhino
//I first wrote about these transformations here:
//https://spacesymmetrystructure.wordpress.com/2008/12/11/4-dimensional-rotations/
Shader "Custom/Moebius"
{