Hello, I recently figured out about CustomOp and Cplusplus Chop/TOP/DAT etc. while I tried to implement the repo below. Also understood that it needs a .plugin file. I was able to make the samples file work on my M1 Pro.
Being totally new to programming, I tried my best to create a .plugin file from the repo in xcode. But no luck as the build keeps failing. Also did not find much help online on how I can make this run on the Mac. Anyone knows if I am wasting my time or if there is a better way to be able to achieve something like a Matrix Chop.
Would be grateful for any kind of help. Thanks!
Hi! It turns out you can do it all via numpy. I updated the toe file in the repo to show this. Here’s the gist of the script CHOP. The wired input should be a CHOP containing only 3 channels: tx, ty, tz, with any number of samples. You should also use the parameters to configure the camera and render resolution.
def onSetupParameters(scriptOp):
scriptOp.destroyCustomPars()
page = scriptOp.appendCustomPage('Custom')
page.appendOBJ('Camera')
page.appendXY('Resolution')
return
# called whenever custom pulse parameter is pushed
def onPulse(par):
return
import numpy as np
def onCook(scriptOp):
for i in range(16):
scriptOp.appendChan('chan1')
cam = op(scriptOp.par.Camera)
resx = scriptOp.par.Resolutionx
resy = scriptOp.par.Resolutiony
world = cam.worldTransform
world.invert()
mat = cam.projection(resx,resy) * world
mat = mat.numpyArray()
x = scriptOp.inputs[0].numpyArray()
x = np.concatenate([x, np.ones((1, x.shape[1]), dtype=np.float32)], axis=0)
x = mat.T @ x
x = 0.5 + 0.5 * x[:3,:] / x[3,:]
scriptOp.copyNumpyArray(x)
return
1 Like
Hi David,
Thanks a ton for your prompt and perfect reply. This works perfectly now.