Skip to content

Instantly share code, notes, and snippets.

View jhorikawa's full-sized avatar

Junichiro Horikawa jhorikawa

View GitHub Profile
@jhorikawa
jhorikawa / ripple.c
Created February 21, 2020 05:58
Ripple pattern on surface using VEX.
float val = noise(@P * chf("smoothness") + chf("seed"));
float ang = val * $PI * chf("num_wave");
float tval = fit(sin(ang), -1.0, 1.0, 0, 1.0);
@Cd = set(tval, tval, tval);
@P += @N * fit(tval, 0, 1.0, 0, chf("offset"));
@jhorikawa
jhorikawa / gaussianblur3d.c
Last active February 20, 2020 02:58
3D gaussian blur snippet for VEX.
float sigma = chf("sigma");
int res = chi("res");
int resn = floor(res / 2.0);
float weightTotal = 0;
float valTotal = 0;
for(int i=-resn; i<=resn; i++){
for(int n=-resn; n<=resn; n++){
for(int t=-resn; t<=resn; t++){
@jhorikawa
jhorikawa / gaussianblur2d.c
Created February 19, 2020 19:45
2D Gaussian Blur for Houdini using VEX
float sigma = chf("sigma");
int res = chi("res");
int resx = chi("resx");
int resy = chi("resy");
int resn = floor(res / 2.0);
float weightTotal = 0;
float valTotal = 0;
for(int i=-resn; i<=resn; i++){
for(int n=-resn; n<=resn; n++){
float ix = @ptnum % resx + i;
import hou
import time
import os
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
dir = os.path.dirname(hou.hipFile.path())
items = hou.selectedItems()
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
for item in items:
import hou
import os
items = hou.selectedItems()
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
dir = os.path.dirname(hou.hipFile.path())
file = open(dir + '/params.txt', 'a')
for item in items:
seps = item.comment().split('-')
if len(seps) == 2 and seps[1] == "1":
file.write('== '+seps[0]+'\n\n')
@jhorikawa
jhorikawa / nodeLabeling
Last active September 9, 2019 14:24
VEX script for node labeling with numbering image.
import hou
items = hou.selectedItems()
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
images = list(editor.backgroundImages())
for item in items:
if isinstance(item, hou.NetworkBox):
nodes = item.nodes()
nodes = hou.sortedNodes(nodes)
for i in range(len(nodes)):
node = nodes[i]
@jhorikawa
jhorikawa / autolayout.json
Created August 18, 2019 04:06
JSON file for auto-layout.
{
"room_requisites" :
[
{
"id" : 0,
"name" : "dining",
"type" : "social",
"min_width" : 3.0,
"max_width" : 30.0,
"min_length" : 3.0,
@jhorikawa
jhorikawa / netflix_brightness.js
Created May 7, 2019 13:14
Increase brightness of the video of Netflix by typing code on web browser's console.
$("video").setAttribute("style", $("video").getAttribute("style") + "filter: brightness(200%);");
@jhorikawa
jhorikawa / packobjectsbydistance.cs
Last active March 22, 2019 08:45
Pack objects by objects' distance in Grasshopper. (C#)
private void RunScript(List<Point3d> pts, List<object> objs, double thresh, ref object A, ref object B)
{
DataTree<object> tree = new DataTree<object>();
List<int> usedList = new List<int>();
List<Point3d> centers = new List<Point3d>();
for(int i = 0; i < pts.Count; i++){
var pt1 = pts[i];
if(!usedList.Contains(i)){
GH_Path path = new GH_Path(i);
tree.Add(objs[i], path);
@jhorikawa
jhorikawa / batchexport.py
Created March 22, 2019 08:38
Batch export objects from layer to FBX using Rhino Python.
import rhinoscriptsyntax as rs
for i in range(3):
for n in range(8):
for t in range(2):
name = 'model'+str(i)+'_'+str(n)+'_'+str(t)
ids = rs.ObjectsByLayer(name)
rs.UnselectAllObjects()
rs.SelectObjects(ids)