Skip to content

Instantly share code, notes, and snippets.

View apokellypse's full-sized avatar

Kelly Yu apokellypse

View GitHub Profile
@apokellypse
apokellypse / kyu_bunny6.html
Created July 17, 2019 02:16
three.js bunny cross-sectioning web app
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - loaders - OBJ loader</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #000;
@apokellypse
apokellypse / stagger_keys.m
Last active April 9, 2019 03:05
Stagger Keyframes Given Existing Animation
// stagger_keys.mel (using .m to get gist syntax highlighting)
// author: Kelly Yu
// I have 124 keys that look like bunny_slice_$i_translateY where $i ranges from 001 to 123
for ($i = 1; $i < 124; $i++) {
string $formatted;
// format number so that it is at least 3 digits long
if ($i < 10) {
$formatted = "00" + $i;
} else if ($i < 100) {
@apokellypse
apokellypse / assign_to_layers.py
Created April 8, 2019 06:06
Assign Each Object To Separate Layer
### assign_to_layers.py
### Kelly Yu
import maya.cmds as cmds
cmds.select(clear=1)
# get slices
bunny_slices = cmds.ls('polySurface*')
# remove surface shapes
bunny_slices = [s for s in bunny_slices if 'Shape' not in s]
@apokellypse
apokellypse / combine_slices.py
Created April 8, 2019 06:02
Combine Objects Along Same Y-Plane Slice
### combine_slices.py
### author: Kelly Yu
import maya.cmds as cmds
cmds.select(clear=1)
# get slices
bunny_slices = cmds.ls('polySurface*', o=True)
# remove surface shapes
bunny_slices = [s for s in bunny_slices if 'Shape' not in s]
@apokellypse
apokellypse / iterative_polycloseborder.py
Last active April 8, 2019 05:50
Add Faces To Objects Such That Objects Are Now Closed Shells
### iterative_polycloseborder.py
### author: Kelly Yu
import maya.cmds as cmds
cmds.select(clear=1)
# select all objects that start with polySurface
bunny_slices = cmds.ls('polySurface*')
for slice in bunny_slices:
@apokellypse
apokellypse / iterative_polyseparate.py
Last active April 8, 2019 05:47
Separate Faces Into Objects Along Mesh Height
### iterative_polyseparate.py
### author: Kelly Yu
import maya.cmds as cmds
cmds.select(clear=True)
# select a list of objects starting with 'bunny' and get the first element
bunny = cmds.ls('bunny')[0]
# retrieve face count
bunny_face_count = cmds.polyEvaluate(bunny, face=True)
@apokellypse
apokellypse / iterative_polycut.m
Last active April 8, 2019 05:40
Iterative Polycut Along Height of Mesh
// iterative_polycut.mel (using .m only to get gist syntax highlighting)
// author: Kelly Yu
// Get bounding box info on the mesh
float $boundingBox[] = `polyEvaluate -boundingBox bunnyMesh`;
float $ymax = $boundingBox[3];
// We want to cut every 0.125 units
int $numDivisions = $ymax / 0.125;
// Assuming the bottom of the mesh is at 0, this will cut along the mesh's height