This file contains hidden or 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
MStatus Node::shouldSave(const MPlug& plug, bool& result) | |
{ | |
if (plug.attribute() == arrayAttribute) | |
{ | |
result = true; | |
return MS::kSuccess; | |
} | |
return MPxNode::shouldSave(plug, result); | |
} |
This file contains hidden or 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
// ... | |
const int prev_sample = int(std::floor(controlParams[j] * (sampleCount - 1))); | |
const int next_sample = int(std::ceil(controlParams[j] * (sampleCount - 1))); | |
const float alpha = controlParams[j] - sampleParams[prev_sample]; | |
const MVector tangent = curveFn.tangent(param); | |
const MVector up1(sampleFrames[prev_sample][1][0], | |
sampleFrames[prev_sample][1][1], | |
sampleFrames[prev_sample][1][2]); | |
const MVector up2(sampleFrames[next_sample][1][0], |
This file contains hidden or 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
// ... | |
MMatrix xform = sampleFrames[i]; | |
const MVector aim(xform[0][0], xform[0][1], xform[0][2]); | |
const MVector p1(xform[3][0], xform[3][1], xform[3][2]); | |
const MVector p2(sampleFrames[next][3][0], | |
sampleFrames[next][3][1], | |
sampleFrames[next][3][2]); | |
const MVector newAim = (p2 - p1).normal(); |
This file contains hidden or 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
// ... | |
const float t = float(i) / float(sampleCount - 1); | |
for (auto j = 0; j < controlCount; ++j) | |
{ | |
const float& param = controlParams[j]; | |
const float& falloff = controlFalloffs[j]; | |
const MVector& scale = controlScales[j]; | |
float weight = 1.0f - std::abs(t - param) / falloff; |
This file contains hidden or 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
MMatrix localXform; | |
localXform[3][0] = length / double(sampleCount); | |
MMatrix parentXform; | |
for (auto i = 0; i < sampleCount; ++i) | |
{ | |
MMatrix xform = i != 0 ? localXform : MMatrix::identity; | |
xform *= parentXform; | |
for (auto j = 0; j < controlCount; ++j) |
This file contains hidden or 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
# operator precedence table | |
PRECEDENCE = { | |
'<': 10, '>': 10, '<=': 10, '>=': 10, '==': 10, '!=': 10, | |
'+': 20, '-': 20, | |
'*': 30, '/': 30, '%': 30, | |
} | |
# parse 1 + 2 * 3 | |
def parse_binary_right(self, prec, left): | |
# prec starts with default 0 |
This file contains hidden or 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
def read_while(self, predicate): | |
str = '' | |
while not self._data.end() and predicate(self._data.peek()): | |
str += self._data.next() | |
return str | |
@staticmethod | |
def is_string(char, strict=True): | |
if strict: |
This file contains hidden or 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
# get plane normal | |
normal = eval_expression('axis(plane.matrix, 1)', 'proj') | |
# project vector to plane | |
proj = eval_expression('src.translate - ({normal} * dot(src.translate, {normal}))'.format(normal=normal), 'proj') |
This file contains hidden or 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
# get plane normal | |
axis = cmds.createNode('math_AxisFromMatrix', name='proj_AXI') | |
cmds.connectAttr('plane.matrix', axis + '.input') | |
cmds.setAttr(axis + '.axis', 1) | |
# get dot product between vector and normal | |
dot = cmds.createNode('math_DotProduct', name='proj_DOT') | |
cmds.connectAttr('src.translate', dot + '.input1') | |
cmds.connectAttr(axis + '.output', dot + '.input2') |
This file contains hidden or 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
float $rate = 3.14 / 2.0; | |
float $theta = offset.translateX * $rate + control.translateX * $rate; | |
float $phi = offset.translateY * $rate - control.translateY * $rate; | |
float $x = sin($theta) * sin($phi); | |
float $y = cos($phi); | |
float $z = cos($theta) * sin($phi); | |
float $px = $x / (1 - $z); | |
float $py = $y / (1 - $z); |
NewerOlder