nukeDLL插件开发
1.新建项目


2.配置管理器




3.配置项目属性





4.代码示例
//Tec_maskcorrect.cpp
static const char* const HELP = "Tec_maskcorrect: make red + blue + green = alpha or 1";
#include <DDImage/NukeWrapper.h>
#include <DDImage/PixelIop.h>
#include <DDImage/Row.h>
#include <DDImage/Knobs.h>
using namespace DD::Image;
static const char* const dnames[] = {
"1", "alpha", 0
};
class Tec_maskcorrect : public PixelIop {
int combineType;
public:
void in_channels(int input, ChannelSet& mask) const;
Tec_maskcorrect(Node *node) : PixelIop(node) {
}
void pixel_engine(const Row& in, int y, int x, int r, ChannelMask, Row& out);
virtual void knobs(Knob_Callback);
static const Iop::Description d;
const char* Class() const {return d.name;}
const char* node_help() const {return HELP;}
void _validate(bool);
};
void Tec_maskcorrect::_validate(bool for_real) {
combineType = 0;
copy_info();
set_out_channels(Mask_All);
}
void Tec_maskcorrect::in_channels(int input, ChannelSet& mask) const {
//mask is unchanged
}
void Tec_maskcorrect::knobs(Knob_Callback f)
{
Enumeration_knob(f, &combineType, dnames, "combineType");
}
void Tec_maskcorrect::pixel_engine(const Row& in, int y, int x, int r, ChannelMask channels, Row& out){
foreach (z, channels) {
const float* inptr = in[z]+x;
const float* END = inptr+(r-x);
float* outptr = out.writable(z)+x;
while (inptr < END)
*outptr++ = *inptr++;
}
const float* inredptr = in[Channel::Chan_Red] + x;
const float* inblueptr = in[Channel::Chan_Blue] + x;
const float* ingreenptr = in[Channel::Chan_Green] + x;
const float* inalphaptr = in[Channel::Chan_Alpha] + x;
float* outredptr = out.writable(Channel::Chan_Red)+x;
float* outblueptr = out.writable(Channel::Chan_Blue)+x;
float* outgreenptr = out.writable(Channel::Chan_Green)+x;
int index = 0;
while(index < r)
{
float combine = 0;
if(combineType == 0)
combine = 1;
else if(combineType == 1)
combine = *inalphaptr;
if((*inredptr + *inblueptr + *ingreenptr) != combine)
{
float scale = combine/(*inredptr + *inblueptr + *ingreenptr);
*outredptr = scale*(*inredptr);
*outblueptr = scale*(*inblueptr);
*outgreenptr = scale*(*ingreenptr);
}
inredptr++;
inblueptr++;
ingreenptr++;
inalphaptr++;
outredptr++;
outblueptr++;
outgreenptr++;
index++;
}
}
static Iop* build(Node *node) {return new NukeWrapper(new Tec_maskcorrect(node));}
const Iop::Description Tec_maskcorrect::d("Tec_maskcorrect", "Tec_maskcorrect", build);