Skip to content

Instantly share code, notes, and snippets.

View hotcakesdeluxe's full-sized avatar

Steph P hotcakesdeluxe

View GitHub Profile
def shapeReplacer(obj, crv):
selection=[]
shape=[]
if(obj == ""):
selection = cmds.ls(sl=True)
else:
selection = obj
shape = cmds.listRelatives(selection, f=True,s=True)
#this split to make sure that we don't delete shapes we are using for common controls added from the 'shapeParent' function
#those shapes return as separate strings in the same list index for some maya reason
@hotcakesdeluxe
hotcakesdeluxe / HalfLambert.shader
Last active July 16, 2021 23:26
half lambert for stylized skin shading for unity
Shader "Custom/HalfLambert"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_RampTex ("Ramp (RGB)", 2D) = "white" {}
_BumpMap ("Bumpmap", 2D) = "bump" {}
_ShadowTint ("Shadow Color", Color) = (0, 0, 0, 1)
_RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
@hotcakesdeluxe
hotcakesdeluxe / poleVectorFinder.py
Created January 23, 2019 20:15
for Maya, makes a control object for your pole vector on an IK limb
import maya.cmds as cmds
import maya.api.OpenMaya as OpenMaya
pv = cmds.circle(n='poleVector_ctrl')
pvGrp = cmds.group(pv, n = 'poleVector_o')
start = cmds.xform(IKJoints[0], q = 1, ws =1, t =1)
mid = cmds.xform(IKJoints[1], q = 1, ws =1, t =1)
end = cmds.xform(IKJoints[2], q = 1, ws =1, t =1)
#create 3 vectors. this uses openmaya api's MVector, could also use a python math module?
startV = OpenMaya.MVector(start[0], start[1], start[2])
midV = OpenMaya.MVector(mid[0], mid[1], mid[2])
@hotcakesdeluxe
hotcakesdeluxe / GetUsableCVPos
Created January 16, 2019 20:52
Gets the positions of points of a curve in Maya and gives you a string to replicate that shape using the curve command
import maya.cmds as cmds
sel = cmds.ls(sl=True)
curve = cmds.ls(sel[0]+'.cv[0:]', fl = True)
cmds.select(curve)
pos = []
for i, cv in enumerate(curve):
cvpos = (cmds.pointPosition(cv, l = True))
pos.append(cvpos)
pointString = str(pos)
pointString = pointString.replace('[','(')
import maya.cmds as mc
import maya.OpenMaya as OpenMaya
def getVertices(mesh):
mc.select(mesh)
selList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(selList)
meshObj = OpenMaya.MObject()
selList.getDependNode(0,meshObj)
meshFn = OpenMaya.MFnMesh( meshObj )
@hotcakesdeluxe
hotcakesdeluxe / InsertJoints.py
Created October 3, 2018 13:19
Autodesk Maya script to insert a number of joints at equal spacing on existing bone
import maya.cmds as cmds
from maya import cmds, OpenMaya
def AddBones():
cmds.select()
sel = cmds.ls(sl=True)
if len(sel) == 0:
cmds.error("No Joints Selected")
cuts = input("Number of joints: ")
relSel = cmds.listRelatives(sel, children = True)
sel.extend(relSel)
@hotcakesdeluxe
hotcakesdeluxe / SpriteSwap.cs
Created August 31, 2018 14:30
swapping sprites in unity. unity doesn't support SVG sprite sheets yet so this is a decent work around for animating
//useful for multiple sprites that cannot be put into a sheet
//unity current does not support slicing sheets for SVG import so this allows you to take multiple SVGs and animate them in editor
//based on an script from Anima2D
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class SpriteSwap : MonoBehaviour
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class IntroCinematicCharacters : MonoBehaviour
{
public PlayableDirector characterDirector;
public List<CharacterData> MeatTeam;
@hotcakesdeluxe
hotcakesdeluxe / pinLocsToVerts
Created January 30, 2017 22:48
Maya python for point to poly constraining locators to a mesh. Not super useful on its own, but good first step to automatic face rig.
# maya Python Script
# based on https://gist.github.com/protofALk/4564420
import maya.cmds as cmds
import pymel.core as pm
class NumericString:
def __init__(self, rawValue):
self.rawValue = rawValue