Posts

Showing posts from May, 2021

A Simple Button Macro

If your animations include a lot of science fiction work, or other instances where a push button is part of the scene, this short macro will do a bit of the work for you. #macro RoundButton(pB, pT, rB, rE, dD, fM) #local hB = vlength(pT - pB); #local vY = vnormalize(pT - pB); #local vX = vnormalize(vcross(vY, <vY.y,vY.z,-vY.x>)); #local vZ = vnormalize(vcross(vX, vY)); #if (fM) merge #else union #end { #if (dD < 0) #local rD = (2 * rB * rE - rB * rB - rE * rE - dD * dD) / 2 / dD - rE; difference { lathe { 5, <0,0>, <rB,0>, <rB, hB - rE>, <rB - rE, hB - rE>, <0, hB + rD + dD> } sphere { y * (hB + rD + dD), rD } bounded_by { cylinder { 0, y * hB, rB } } } #elseif (dD > 0) #local hB = hB - dD; #local rD = (rB * rB + rE * rE + dD * dD - 2 * rB * rE) / 2 / dD + rE; intersection { lathe { 6, <0,0>, <rB,0>, <rB, hB - rE>, <rB - rE, hB - rE>, <

Motion Paths

A lot of animation involves moving either a character or the camera along a path through the scene, and so I'll provide a set of macros for defining a path. Some Helper Macros To make the code that follows a lot neater, I'll be using the following helper macros: #macro LinePoly(sVariable, sConstant, sLinear) (sLinear * sVariable + sConstant) #end #macro QuadPoly(sVariable, sConstant, sLinear, sQuadratic) ((sQuadratic * sVariable + sLinear) * sVariable + sConstant) #end #macro CubePoly(sVariable, sConstant, sLinear, sQuadratic, sCubic) (((sCubic * sVariable + sQuadratic) * sVariable + sLinear) * sVariable + sConstant) #end Continuity As with the macros that I provided in the last article, a motion path can have multiple levels of continuity, some of which are only necessary for specific applications. C 0 Continuity The minimal level of continuity is C 0 , which means that there are no open gaps in the path, but otherwise the motion is as simple as possible. The