diff options
Diffstat (limited to 'source/blender/compositor/nodes')
154 files changed, 7540 insertions, 0 deletions
diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.cpp b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp new file mode 100644 index 00000000000..7cd26bc79b7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_AlphaOverNode.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_AlphaOverNode.h" + +#include "COM_MixBaseOperation.h" +#include "COM_AlphaOverKeyOperation.h" +#include "COM_AlphaOverMixedOperation.h" +#include "COM_AlphaOverPremultiplyOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" // the ramp types + +void AlphaOverNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *valueSocket = this->getInputSocket(0); + InputSocket *color1Socket = this->getInputSocket(1); + InputSocket *color2Socket = this->getInputSocket(2); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* editorNode = this->getbNode(); + + MixBaseOperation *convertProg; + NodeTwoFloats *ntf= (NodeTwoFloats*)editorNode->storage; + if (ntf->x!= 0.0f) { + AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation(); + mixOperation->setX(ntf->x); + convertProg = mixOperation; + + } else if (editorNode->custom1) { + convertProg = new AlphaOverKeyOperation(); + } else { + convertProg = new AlphaOverPremultiplyOperation(); + } + + convertProg->setUseValueAlphaMultiply(false); + if (color1Socket->isConnected()) { + convertProg->setResolutionInputSocketIndex(1); + } else if (color2Socket->isConnected()) { + convertProg->setResolutionInputSocketIndex(2); + } else { + convertProg->setResolutionInputSocketIndex(0); + } + valueSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph); + color1Socket->relinkConnections(convertProg->getInputSocket(1), true, 1, graph); + color2Socket->relinkConnections(convertProg->getInputSocket(2), true, 2, graph); + outputSocket->relinkConnections(convertProg->getOutputSocket(0)); + graph->addOperation(convertProg); +} diff --git a/source/blender/compositor/nodes/COM_AlphaOverNode.h b/source/blender/compositor/nodes/COM_AlphaOverNode.h new file mode 100644 index 00000000000..b9840f89d3a --- /dev/null +++ b/source/blender/compositor/nodes/COM_AlphaOverNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_AlphaOverNode_h +#define _COM_AlphaOverNode_h + +#include "COM_Node.h" + +/** + * @brief AlphaOverNode + * @ingroup Node + */ +class AlphaOverNode: public Node { +public: + AlphaOverNode(bNode* editorNode) :Node(editorNode) {} + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp new file mode 100644 index 00000000000..5302fb01f1c --- /dev/null +++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BilateralBlurNode.h" +#include "DNA_scene_types.h" +#include "DNA_node_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_BilateralBlurOperation.h" + +BilateralBlurNode::BilateralBlurNode(bNode *editorNode): Node(editorNode) { +} + +void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + NodeBilateralBlurData *data = (NodeBilateralBlurData*)this->getbNode()->storage; + BilateralBlurOperation *operation = new BilateralBlurOperation(); + operation->setQuality(context->getQuality()); + operation->setData(data); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.h b/source/blender/compositor/nodes/COM_BilateralBlurNode.h new file mode 100644 index 00000000000..d5d9b7367a4 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BilateralBlurNode_h_ +#define _COM_BilateralBlurNode_h_ + +#include "COM_Node.h" + +/** + * @brief BilateralBlurNode + * @ingroup Node + */ +class BilateralBlurNode: public Node { +public: + BilateralBlurNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp new file mode 100644 index 00000000000..c278ea877ba --- /dev/null +++ b/source/blender/compositor/nodes/COM_BlurNode.cpp @@ -0,0 +1,79 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BlurNode.h" +#include "DNA_scene_types.h" +#include "DNA_node_types.h" +#include "COM_GaussianXBlurOperation.h" +#include "COM_GaussianYBlurOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_GaussianBokehBlurOperation.h" +#include "COM_FastGaussianBlurOperation.h" + +BlurNode::BlurNode(bNode *editorNode): Node(editorNode) { +} + +void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + bNode* editorNode = this->getbNode(); + NodeBlurData * data = (NodeBlurData*)editorNode->storage; + const bNodeSocket *sock = this->getInputSocket(1)->getbNodeSocket(); + //const float size = ((const bNodeSocketValueFloat*)sock->default_value)->value; + + CompositorQuality quality = context->getQuality(); + + if (data->filtertype == R_FILTER_MITCH || data->filtertype == R_FILTER_CATROM) { + quality = COM_QUALITY_HIGH; + } + if (data->filtertype == R_FILTER_FAST_GAUSS) { + FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation(); + operationfgb->setData(data); + this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0)); + graph->addOperation(operationfgb); + addPreviewOperation(graph, operationfgb->getOutputSocket(), 5); + }else if (!data->bokeh) { + GaussianXBlurOperation *operationx = new GaussianXBlurOperation(); + operationx->setData(data); + operationx->setQuality(quality); + this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), true, 1, graph); + graph->addOperation(operationx); + GaussianYBlurOperation *operationy = new GaussianYBlurOperation(); + operationy->setData(data); + operationy->setQuality(quality); + this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket()); + graph->addOperation(operationy); + addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0)); + addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1)); + addPreviewOperation(graph, operationy->getOutputSocket(), 5); + } else { + GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation(); + operation->setData(data); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + operation->setQuality(quality); + graph->addOperation(operation); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + addPreviewOperation(graph, operation->getOutputSocket(), 5); + } +} diff --git a/source/blender/compositor/nodes/COM_BlurNode.h b/source/blender/compositor/nodes/COM_BlurNode.h new file mode 100644 index 00000000000..087e2be208f --- /dev/null +++ b/source/blender/compositor/nodes/COM_BlurNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BlurNode_h_ +#define _COM_BlurNode_h_ + +#include "COM_Node.h" + +/** + * @brief BlurNode + * @ingroup Node + */ + +class BlurNode: public Node { +public: + BlurNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp new file mode 100644 index 00000000000..c40bcab3ffb --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp @@ -0,0 +1,63 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BokehBlurNode.h" +#include "DNA_scene_types.h" +#include "DNA_camera_types.h" +#include "DNA_object_types.h" +#include "DNA_node_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_BokehBlurOperation.h" +#include "COM_VariableSizeBokehBlurOperation.h" +#include "COM_ConvertDepthToRadiusOperation.h" + +BokehBlurNode::BokehBlurNode(bNode *editorNode): Node(editorNode) { +} + +void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + Object* camob = context->getScene()->camera; + + if (this->getInputSocket(2)->isConnected()) { + VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); + ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); + converter->setfStop(4.0f); + converter->setCameraObject(camob); + operation->setMaxBlur(16); + operation->setQuality(context->getQuality()); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getInputSocket(2)->relinkConnections(converter->getInputSocket(0), true, 2, graph); + addLink(graph, converter->getOutputSocket(), operation->getInputSocket(2)); + graph->addOperation(operation); + graph->addOperation(converter); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + } else { + BokehBlurOperation *operation = new BokehBlurOperation(); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), true, 3, graph); + operation->setSize(((bNodeSocketValueFloat*)this->getInputSocket(2)->getbNodeSocket()->default_value)->value); + operation->setQuality(context->getQuality()); + graph->addOperation(operation); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.h b/source/blender/compositor/nodes/COM_BokehBlurNode.h new file mode 100644 index 00000000000..cb9d117c8ae --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehBlurNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BokehBlurNode_h_ +#define _COM_BokehBlurNode_h_ + +#include "COM_Node.h" + +/** + * @brief BokehBlurNode + * @ingroup Node + */ + +class BokehBlurNode: public Node { +public: + BokehBlurNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.cpp b/source/blender/compositor/nodes/COM_BokehImageNode.cpp new file mode 100644 index 00000000000..511727636b5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehImageNode.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BokehImageNode.h" +#include "DNA_scene_types.h" +#include "COM_BokehImageOperation.h" +#include "COM_ExecutionSystem.h" + +BokehImageNode::BokehImageNode(bNode *editorNode): Node(editorNode) { +} + +void BokehImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + BokehImageOperation *operation = new BokehImageOperation(); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + operation->setData((NodeBokehImage*)this->getbNode()->storage); + addPreviewOperation(graph, operation->getOutputSocket(0), 9); +} diff --git a/source/blender/compositor/nodes/COM_BokehImageNode.h b/source/blender/compositor/nodes/COM_BokehImageNode.h new file mode 100644 index 00000000000..f3322077c47 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BokehImageNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BokehImageNode_h_ +#define _COM_BokehImageNode_h_ + +#include "COM_Node.h" + +/** + * @brief BokehImageNode + * @ingroup Node + */ +class BokehImageNode: public Node { +public: + BokehImageNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.cpp b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp new file mode 100644 index 00000000000..7f904f1acc0 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BoxMaskNode.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BoxMaskNode.h" +#include "DNA_scene_types.h" +#include "COM_BoxMaskOperation.h" +#include "COM_ExecutionSystem.h" + +BoxMaskNode::BoxMaskNode(bNode *editorNode): Node(editorNode) { +} + +void BoxMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + BoxMaskOperation *operation; + operation = new BoxMaskOperation(); + operation->setData((NodeBoxMask*)this->getbNode()->storage); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + operation->setMaskType(this->getbNode()->custom1); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_BoxMaskNode.h b/source/blender/compositor/nodes/COM_BoxMaskNode.h new file mode 100644 index 00000000000..c91730fdbb8 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BoxMaskNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BoxMaskNode_h_ +#define _COM_BoxMaskNode_h_ + +#include "COM_Node.h" + +/** + * @brief BoxMaskNode + * @ingroup Node + */ +class BoxMaskNode: public Node { +public: + BoxMaskNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.cpp b/source/blender/compositor/nodes/COM_BrightnessNode.cpp new file mode 100644 index 00000000000..3ff5538f13e --- /dev/null +++ b/source/blender/compositor/nodes/COM_BrightnessNode.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_BrightnessNode.h" +#include "DNA_scene_types.h" +#include "COM_BrightnessOperation.h" +#include "COM_ExecutionSystem.h" + +BrightnessNode::BrightnessNode(bNode *editorNode): Node(editorNode) { +} +/// @todo: add anti alias when not FSA +void BrightnessNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + BrightnessOperation *operation = new BrightnessOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0)); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2),true, 2, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_BrightnessNode.h b/source/blender/compositor/nodes/COM_BrightnessNode.h new file mode 100644 index 00000000000..8f1c9ccda86 --- /dev/null +++ b/source/blender/compositor/nodes/COM_BrightnessNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_BrightnessNode_h_ +#define _COM_BrightnessNode_h_ + +#include "COM_Node.h" + +/** + * @brief BrightnessNode + * @ingroup Node + */ +class BrightnessNode: public Node { +public: + BrightnessNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp new file mode 100644 index 00000000000..bf3def05643 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ChannelMatteNode.h" +#include "BKE_node.h" +#include "COM_ChannelMatteOperation.h" +#include "COM_ConvertRGBToHSVOperation.h" +#include "COM_ConvertRGBToYCCOperation.h" +#include "COM_ConvertRGBToYUVOperation.h" +#include "COM_SetAlphaOperation.h" + +ChannelMatteNode::ChannelMatteNode(bNode *editorNode): Node(editorNode) +{} + +void ChannelMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocketImage = this->getInputSocket(0); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + + NodeOperation *convert=NULL; + bNode* node = this->getbNode(); + + /* colorspace */ + switch(node->custom1) { + case CMP_NODE_CHANNEL_MATTE_CS_RGB: + break; + case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/ + convert = new ConvertRGBToHSVOperation(); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/ + convert = new ConvertRGBToYUVOperation(); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/ + convert = new ConvertRGBToYCCOperation(); + ((ConvertRGBToYCCOperation *)convert)->setMode(0); /* BLI_YCC_ITU_BT601 */ + break; + default: + break; + } + + ChannelMatteOperation *operation = new ChannelMatteOperation(); + /* pass the ui properties to the operation */ + operation->setSettings((NodeChroma*)node->storage, node->custom2); + + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + + if (convert) { + inputSocketImage->relinkConnections(convert->getInputSocket(0), true, 0, graph); + addLink(graph, convert->getOutputSocket(), operation->getInputSocket(0)); + addLink(graph, convert->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); + graph->addOperation(convert); + } + else { + inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph); + addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); + } + + if (outputSocketMatte->isConnected()) { + outputSocketMatte->relinkConnections(operation->getOutputSocket(0)); + } + + graph->addOperation(operation); + graph->addOperation(operationAlpha); + + addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9); + + if (outputSocketImage->isConnected()) { + outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.h b/source/blender/compositor/nodes/COM_ChannelMatteNode.h new file mode 100644 index 00000000000..cb67ac604b2 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef COM_ChannelMatteNODE_H +#define COM_ChannelMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief ChannelMatteNode + * @ingroup Node + */ +class ChannelMatteNode : public Node +{ +public: + ChannelMatteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_ChannelMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp new file mode 100644 index 00000000000..36d315c3a4b --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ChromaMatteNode.h" +#include "BKE_node.h" +#include "COM_ChromaMatteOperation.h" +#include "COM_ConvertRGBToYCCOperation.h" +#include "COM_SetAlphaOperation.h" + +ChromaMatteNode::ChromaMatteNode(bNode *editorNode): Node(editorNode) +{} + +void ChromaMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocketImage = this->getInputSocket(0); + InputSocket *inputSocketKey = this->getInputSocket(1); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + + ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation(); + ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation(); + operationRGBToYCC_Image->setMode(0); /* BLI_YCC_ITU_BT601 */ + operationRGBToYCC_Key->setMode(0); /* BLI_YCC_ITU_BT601 */ + + ChromaMatteOperation *operation = new ChromaMatteOperation(); + bNode* editorsnode = getbNode(); + operation->setSettings((NodeChroma*)editorsnode->storage); + + inputSocketImage->relinkConnections(operationRGBToYCC_Image->getInputSocket(0), true, 0, graph); + inputSocketKey->relinkConnections(operationRGBToYCC_Key->getInputSocket(0), true, 0, graph); + + addLink(graph, operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0)); + addLink(graph, operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1)); + + graph->addOperation(operationRGBToYCC_Image); + graph->addOperation(operationRGBToYCC_Key); + graph->addOperation(operation); + + if (outputSocketMatte->isConnected()) { + outputSocketMatte->relinkConnections(operation->getOutputSocket()); + } + + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + addLink(graph, operationRGBToYCC_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + + graph->addOperation(operationAlpha); + addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9); + + if (outputSocketImage->isConnected()) { + outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.h b/source/blender/compositor/nodes/COM_ChromaMatteNode.h new file mode 100644 index 00000000000..6008137b4a7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef COM_ChromaMatteNODE_H +#define COM_ChromaMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief ChromaMatteNode + * @ingroup Node + */ +class ChromaMatteNode : public Node +{ +public: + ChromaMatteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_ChromaMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp new file mode 100644 index 00000000000..73d10d4b1ca --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp @@ -0,0 +1,68 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorBalanceNode.h" +#include "COM_ColorBalanceLGGOperation.h" +#include "COM_ColorBalanceASCCDLOperation.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" +#include "COM_MixBlendOperation.h" + +ColorBalanceNode::ColorBalanceNode(bNode* editorNode): Node(editorNode) +{ +} +void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputImageSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + + bNode* node = this->getbNode(); + NodeColorBalance *n= (NodeColorBalance *)node->storage; + NodeOperation*operation; + if (node->custom1 == 0) { + ColorBalanceLGGOperation* operationLGG = new ColorBalanceLGGOperation(); + { + int c; + + for (c = 0; c < 3; c++) { + n->lift_lgg[c] = 2.0f - n->lift[c]; + n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f/n->gamma[c] : 1000000.0f; + } + } + + operationLGG->setGain(n->gain); + operationLGG->setLift(n->lift_lgg); + operationLGG->setGammaInv(n->gamma_inv); + operation = operationLGG; + } else { + ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); + operationCDL->setGain(n->gain); + operationCDL->setLift(n->lift); + operationCDL->setGamma(n->gamma); + operation = operationCDL; + } + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputImageSocket->relinkConnections(operation->getInputSocket(1), true, 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.h b/source/blender/compositor/nodes/COM_ColorBalanceNode.h new file mode 100644 index 00000000000..6de431a764f --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_ColorBalanceNODE_H +#define COM_ColorBalanceNODE_H + +#include "COM_Node.h" + +/** + * @brief ColorBalanceNode + * @ingroup Node + */ +class ColorBalanceNode : public Node +{ +public: + ColorBalanceNode(bNode* editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif // COM_ColorBalanceNODE_H diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp new file mode 100644 index 00000000000..ac3e1285e75 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorCorrectionNode.h" +#include "DNA_scene_types.h" +#include "COM_ColorCorrectionOperation.h" +#include "COM_ExecutionSystem.h" + +ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode): Node(editorNode) { +} + +void ColorCorrectionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + ColorCorrectionOperation *operation = new ColorCorrectionOperation(); + bNode* editorNode = getbNode(); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0),true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + operation->setData((NodeColorCorrection*)editorNode->storage); + operation->setRedChannelEnabled((editorNode->custom1&1)>0); + operation->setGreenChannelEnabled((editorNode->custom1&2)>0); + operation->setBlueChannelEnabled((editorNode->custom1&4)>0); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorCorrectionNode.h b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h new file mode 100644 index 00000000000..e5c35476931 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCorrectionNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ColorCorrectionNode_h_ +#define _COM_ColorCorrectionNode_h_ + +#include "COM_Node.h" + +/** + * @brief ColorCorrectionNode + * @ingroup Node + */ +class ColorCorrectionNode: public Node { +public: + ColorCorrectionNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.cpp b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp new file mode 100644 index 00000000000..55837a35b59 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCurveNode.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorCurveNode.h" +#include "DNA_scene_types.h" +#include "COM_ColorCurveOperation.h" +#include "COM_ExecutionSystem.h" + +ColorCurveNode::ColorCurveNode(bNode *editorNode): Node(editorNode) { +} + +void ColorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + ColorCurveOperation *operation = new ColorCurveOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, graph); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, graph); + + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + operation->setCurveMapping((CurveMapping*)this->getbNode()->storage); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorCurveNode.h b/source/blender/compositor/nodes/COM_ColorCurveNode.h new file mode 100644 index 00000000000..aade20860c2 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorCurveNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ColorCurveNode_h_ +#define _COM_ColorCurveNode_h_ + +#include "COM_Node.h" + +/** + * @brief ColorCurveNode + * @ingroup Node + */ +class ColorCurveNode: public Node { +public: + ColorCurveNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp new file mode 100644 index 00000000000..fa00c95f50b --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp @@ -0,0 +1,67 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ColorMatteNode.h" +#include "BKE_node.h" +#include "COM_ColorMatteOperation.h" +#include "COM_ConvertRGBToHSVOperation.h" +#include "COM_SetAlphaOperation.h" + +ColorMatteNode::ColorMatteNode(bNode *editorNode): Node(editorNode) +{} + +void ColorMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocketImage = this->getInputSocket(0); + InputSocket *inputSocketKey = this->getInputSocket(1); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + + ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation(); + ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation(); + + ColorMatteOperation *operation = new ColorMatteOperation(); + bNode* editorsnode = getbNode(); + operation->setSettings((NodeChroma*)editorsnode->storage); + + inputSocketImage->relinkConnections(operationRGBToHSV_Image->getInputSocket(0), true, 0, graph); + inputSocketKey->relinkConnections(operationRGBToHSV_Key->getInputSocket(0), true, 1, graph); + + addLink(graph, operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0)); + addLink(graph, operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1)); + + if (outputSocketMatte->isConnected()) { + outputSocketMatte->relinkConnections(operation->getOutputSocket(0)); + } + + graph->addOperation(operationRGBToHSV_Image); + graph->addOperation(operationRGBToHSV_Key); + graph->addOperation(operation); + + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + addLink(graph, operationRGBToHSV_Image->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + graph->addOperation(operationAlpha); + addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9); + + if (outputSocketImage->isConnected()) { + outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.h b/source/blender/compositor/nodes/COM_ColorMatteNode.h new file mode 100644 index 00000000000..af64616d054 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef COM_ColorMatteNODE_H +#define COM_ColorMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief ColorMatteNode + * @ingroup Node + */ +class ColorMatteNode : public Node +{ +public: + ColorMatteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_ColorMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_ColorNode.cpp b/source/blender/compositor/nodes/COM_ColorNode.cpp new file mode 100644 index 00000000000..0eee305a7e6 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorNode.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorNode.h" +#include "DNA_scene_types.h" +#include "COM_SetColorOperation.h" +#include "COM_ExecutionSystem.h" + +ColorNode::ColorNode(bNode *editorNode): Node(editorNode) { +} + +void ColorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + SetColorOperation *operation = new SetColorOperation(); + bNodeSocket* socket = this->getEditorOutputSocket(0); + bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)socket->default_value; + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + operation->setChannels(dval->value); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorNode.h b/source/blender/compositor/nodes/COM_ColorNode.h new file mode 100644 index 00000000000..6a9f3062676 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ColorNode_h_ +#define _COM_ColorNode_h_ + +#include "COM_Node.h" + +/** + * @brief ColorNode + * @ingroup Node + */ +class ColorNode: public Node { +public: + ColorNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.cpp b/source/blender/compositor/nodes/COM_ColorRampNode.cpp new file mode 100644 index 00000000000..bd1b3b5a35e --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorRampNode.cpp @@ -0,0 +1,51 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorRampNode.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" +#include "COM_ColorRampOperation.h" +#include "COM_SeparateChannelOperation.h" +#include "DNA_texture_types.h" + +ColorRampNode::ColorRampNode(bNode* editorNode): Node(editorNode) +{} + +void ColorRampNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocket = this->getOutputSocket(0); + OutputSocket *outputSocketAlpha = this->getOutputSocket(1); + bNode* editorNode = this->getbNode(); + + ColorRampOperation * operation = new ColorRampOperation(); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + if (outputSocketAlpha->isConnected()) { + SeparateChannelOperation *operation2 = new SeparateChannelOperation(); + outputSocketAlpha->relinkConnections(operation2->getOutputSocket()); + addLink(graph, operation->getOutputSocket(), operation2->getInputSocket(0)); + operation2->setChannel(3); + graph->addOperation(operation2); + } + operation->setColorBand((ColorBand*)editorNode->storage); + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorRampNode.h b/source/blender/compositor/nodes/COM_ColorRampNode.h new file mode 100644 index 00000000000..de0f2a5395e --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorRampNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_ColorRampNODE_H +#define COM_ColorRampNODE_H + +#include "COM_Node.h" + +/** + * @brief ColorRampNode + * @ingroup Node + */ +class ColorRampNode : public Node +{ +public: + ColorRampNode(bNode* editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif // COM_ColorRampNODE_H diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.cpp b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp new file mode 100644 index 00000000000..011a2cb12cc --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorSpillNode.h" +#include "BKE_node.h" +#include "COM_ColorSpillOperation.h" + +ColorSpillNode::ColorSpillNode(bNode *editorNode): Node(editorNode) +{} + +void ColorSpillNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocketImage = this->getInputSocket(0); + InputSocket *inputSocketFac = this->getInputSocket(1); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + + bNode* editorsnode = getbNode(); + + + ColorSpillOperation *operation; + if (editorsnode->custom2 == 0) { + // Simple color spill + operation = new ColorSpillOperation(); + } else { + // Average color spill + operation = new ColorSpillAverageOperation(); + } + operation->setSettings((NodeColorspill*)editorsnode->storage); + operation->setSpillChannel(editorsnode->custom1-1); // Channel for spilling + + + inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputSocketFac->relinkConnections(operation->getInputSocket(1), true, 1, graph); + + outputSocketImage->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ColorSpillNode.h b/source/blender/compositor/nodes/COM_ColorSpillNode.h new file mode 100644 index 00000000000..ed0e33b0742 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorSpillNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_ColorSpillNODE_H +#define COM_ColorSpillNODE_H + +#include "COM_Node.h" + +/** + * @brief ColorSpillNode + * @ingroup Node + */ +class ColorSpillNode : public Node +{ +public: + ColorSpillNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_ColorSpillNODE_H diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.cpp b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp new file mode 100644 index 00000000000..a58c2e9fd19 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ColorToBWNode.h" + +#include "COM_ConvertColorToBWOperation.h" +#include "COM_ExecutionSystem.h" + +ColourToBWNode::ColourToBWNode(bNode *editorNode): Node(editorNode) { +} + +void ColourToBWNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *colourSocket = this->getInputSocket(0); + OutputSocket *valueSocket = this->getOutputSocket(0); + + ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation(); + colourSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph); + valueSocket->relinkConnections(convertProg->getOutputSocket(0)); + graph->addOperation(convertProg); +} diff --git a/source/blender/compositor/nodes/COM_ColorToBWNode.h b/source/blender/compositor/nodes/COM_ColorToBWNode.h new file mode 100644 index 00000000000..e2badd1b104 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ColorToBWNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ColourToBWNode_h +#define _COM_ColourToBWNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief ColourToBWNode + * @ingroup Node + */ +class ColourToBWNode : public Node { +public: + ColourToBWNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.cpp b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp new file mode 100644 index 00000000000..bd43f207fc7 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineHSVANode.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_CombineHSVANode.h" + +#include "COM_CombineChannelsOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_ConvertHSVToRGBOperation.h" + +CombineHSVANode::CombineHSVANode(bNode *editorNode): CombineRGBANode(editorNode) { +} + +void CombineHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + ConvertHSVToRGBOperation *operation = new ConvertHSVToRGBOperation(); + OutputSocket *outputSocket = this->getOutputSocket(0); + if (outputSocket->isConnected()) { + outputSocket->relinkConnections(operation->getOutputSocket()); + addLink(graph, outputSocket, operation->getInputSocket(0)); + } + graph->addOperation(operation); + CombineRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_CombineHSVANode.h b/source/blender/compositor/nodes/COM_CombineHSVANode.h new file mode 100644 index 00000000000..fabd6f91f7e --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineHSVANode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_CombineHSVANode_h +#define _COM_CombineHSVANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_CombineRGBANode.h" +/** + * @brief CombineHSVANode + * @ingroup Node + */ +class CombineHSVANode : public CombineRGBANode { +public: + CombineHSVANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.cpp b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp new file mode 100644 index 00000000000..8a1a34589a5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineRGBANode.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_CombineRGBANode.h" + +#include "COM_CombineChannelsOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" // the ramp types + + +CombineRGBANode::CombineRGBANode(bNode *editorNode): Node(editorNode) { +} + + +void CombineRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputRSocket = this->getInputSocket(0); + InputSocket *inputGSocket = this->getInputSocket(1); + InputSocket *inputBSocket = this->getInputSocket(2); + InputSocket *inputASocket = this->getInputSocket(3); + OutputSocket *outputSocket = this->getOutputSocket(0); + + CombineChannelsOperation *operation = new CombineChannelsOperation(); + if (inputRSocket->isConnected()) { + operation->setResolutionInputSocketIndex(0); + } else if (inputGSocket->isConnected()) { + operation->setResolutionInputSocketIndex(1); + } else if (inputBSocket->isConnected()) { + operation->setResolutionInputSocketIndex(2); + } else { + operation->setResolutionInputSocketIndex(3); + } + inputRSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputGSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph); + inputBSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph); + inputASocket->relinkConnections(operation->getInputSocket(3), true, 3, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_CombineRGBANode.h b/source/blender/compositor/nodes/COM_CombineRGBANode.h new file mode 100644 index 00000000000..182bfece6d3 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineRGBANode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_CombineRGBANode_h +#define _COM_CombineRGBANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief CombineRGBANode + * @ingroup Node + */ +class CombineRGBANode : public Node { +public: + CombineRGBANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.cpp b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp new file mode 100644 index 00000000000..bf31daf5852 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineYCCANode.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_CombineYCCANode.h" +#include "COM_ConvertYCCToRGBOperation.h" + +CombineYCCANode::CombineYCCANode(bNode *editorNode): CombineRGBANode(editorNode) { +} + +void CombineYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation(); + OutputSocket *outputSocket = this->getOutputSocket(0); + + bNode *node = this->getbNode(); + operation->setMode(node->custom1); + + if (outputSocket->isConnected()) { + outputSocket->relinkConnections(operation->getOutputSocket()); + addLink(graph, outputSocket, operation->getInputSocket(0)); + } + + graph->addOperation(operation); + CombineRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_CombineYCCANode.h b/source/blender/compositor/nodes/COM_CombineYCCANode.h new file mode 100644 index 00000000000..86e2d50e950 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineYCCANode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_CombineYCCANode_h +#define _COM_CombineYCCANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_CombineRGBANode.h" +/** + * @brief CombineYCCANode + * @ingroup Node + */ +class CombineYCCANode : public CombineRGBANode { +public: + CombineYCCANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.cpp b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp new file mode 100644 index 00000000000..3348eacc86f --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineYUVANode.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_CombineYUVANode.h" +#include "COM_ConvertYUVToRGBOperation.h" + +CombineYUVANode::CombineYUVANode(bNode *editorNode): CombineRGBANode(editorNode) { +} + +void CombineYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + ConvertYUVToRGBOperation *operation = new ConvertYUVToRGBOperation(); + OutputSocket *outputSocket = this->getOutputSocket(0); + if (outputSocket->isConnected()) { + outputSocket->relinkConnections(operation->getOutputSocket()); + addLink(graph, outputSocket, operation->getInputSocket(0)); + } + graph->addOperation(operation); + CombineRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_CombineYUVANode.h b/source/blender/compositor/nodes/COM_CombineYUVANode.h new file mode 100644 index 00000000000..7d2f9cddf7e --- /dev/null +++ b/source/blender/compositor/nodes/COM_CombineYUVANode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_CombineYUVANode_h +#define _COM_CombineYUVANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_CombineRGBANode.h" +/** + * @brief CombineYUVANode + * @ingroup Node + */ +class CombineYUVANode : public CombineRGBANode { +public: + CombineYUVANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_CompositorNode.cpp b/source/blender/compositor/nodes/COM_CompositorNode.cpp new file mode 100644 index 00000000000..95db41b322c --- /dev/null +++ b/source/blender/compositor/nodes/COM_CompositorNode.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_CompositorNode.h" +#include "COM_CompositorOperation.h" +#include "COM_ExecutionSystem.h" + +CompositorNode::CompositorNode(bNode *editorNode): Node(editorNode) { +} + +void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *imageSocket = this->getInputSocket(0); + InputSocket *alphaSocket = this->getInputSocket(1); + if (imageSocket->isConnected()) { + CompositorOperation *colourAlphaProg = new CompositorOperation(); + colourAlphaProg->setScene(context->getScene()); + colourAlphaProg->setbNodeTree(context->getbNodeTree()); + imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0)); + alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1)); + graph->addOperation(colourAlphaProg); + addPreviewOperation(graph, colourAlphaProg->getInputSocket(0), 5); + } +} diff --git a/source/blender/compositor/nodes/COM_CompositorNode.h b/source/blender/compositor/nodes/COM_CompositorNode.h new file mode 100644 index 00000000000..e77d1d2f225 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CompositorNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_CompositorNode_h +#define _COM_CompositorNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief CompositorNode + * @ingroup Node + */ +class CompositorNode : public Node { +public: + CompositorNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp new file mode 100644 index 00000000000..4e20b3a5d3a --- /dev/null +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_ConvertAlphaNode.h" +#include "COM_ConvertPremulToKeyOperation.h" +#include "COM_ConvertKeyToPremulOperation.h" +#include "COM_ExecutionSystem.h" + +void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + NodeOperation* operation = NULL; + bNode* node = this->getbNode(); + + /* value hardcoded in rna_nodetree.c */ + if (node->custom1 == 1){ + operation = new ConvertPremulToKeyOperation(); + } + else { + operation = new ConvertKeyToPremulOperation(); + } + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.h b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h new file mode 100644 index 00000000000..04834a45c45 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_ConvertAlphaNode_h +#define _COM_ConvertAlphaNode_h + +#include "COM_Node.h" + +/** + * @brief ConvertAlphaNode + * @ingroup Node + */ +class ConvertAlphaNode: public Node { +public: + ConvertAlphaNode(bNode* editorNode) :Node(editorNode) {} + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp new file mode 100644 index 00000000000..fdbb1529c60 --- /dev/null +++ b/source/blender/compositor/nodes/COM_CropNode.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_CropNode.h" +#include "COM_CropOperation.h" + + +CropNode::CropNode(bNode *editorNode) : Node(editorNode) { +} + +void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context){ + bNode* node = getbNode(); + NodeTwoXYs *cropSettings = (NodeTwoXYs*)node->storage; + bool relative = (bool)node->custom2; + bool cropImage = (bool)node->custom1; + CropBaseOperation *operation; + if (cropImage){ + operation = new CropImageOperation(); + } else { + operation = new CropOperation(); + } + operation->setCropSettings(cropSettings); + operation->setRelative(relative); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getOutputSocket()->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_CropNode.h b/source/blender/compositor/nodes/COM_CropNode.h new file mode 100644 index 00000000000..a39bd47f22a --- /dev/null +++ b/source/blender/compositor/nodes/COM_CropNode.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_CropNode_h_ +#define _COM_CropNode_h_ + +#include "COM_Node.h" + +class CropNode: public Node { +public: + CropNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif + + diff --git a/source/blender/compositor/nodes/COM_DefocusNode.cpp b/source/blender/compositor/nodes/COM_DefocusNode.cpp new file mode 100644 index 00000000000..7f5c9896bbe --- /dev/null +++ b/source/blender/compositor/nodes/COM_DefocusNode.cpp @@ -0,0 +1,110 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_DefocusNode.h" +#include "DNA_scene_types.h" +#include "DNA_camera_types.h" +#include "DNA_object_types.h" +#include "DNA_node_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_ConvertDepthToRadiusOperation.h" +#include "COM_VariableSizeBokehBlurOperation.h" +#include "COM_BokehImageOperation.h" +#include "COM_MathBaseOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_GammaCorrectOperation.h" + +DefocusNode::DefocusNode(bNode *editorNode): Node(editorNode) { +} + +void DefocusNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + bNode *node = this->getbNode(); + Scene *scene= (Scene*)node->id; + Object* camob = (scene)? scene->camera: NULL; + NodeDefocus *data = (NodeDefocus*)node->storage; + + NodeOperation* radiusOperation; + if (data->no_zbuf) { + MathMultiplyOperation *multiply = new MathMultiplyOperation(); + SetValueOperation *multiplier = new SetValueOperation(); + multiplier->setValue(data->scale); + SetValueOperation *maxRadius = new SetValueOperation(); + maxRadius->setValue(data->maxblur); + MathMinimumOperation *minimize = new MathMinimumOperation(); + this->getInputSocket(1)->relinkConnections(multiply->getInputSocket(0), true, 1, graph); + addLink(graph, multiplier->getOutputSocket(), multiply->getInputSocket(1)); + addLink(graph, maxRadius->getOutputSocket(), minimize->getInputSocket(1)); + addLink(graph, multiply->getOutputSocket(), minimize->getInputSocket(0)); + + graph->addOperation(multiply); + graph->addOperation(multiplier); + graph->addOperation(maxRadius); + graph->addOperation(minimize); + radiusOperation = minimize; + } else { + ConvertDepthToRadiusOperation *converter = new ConvertDepthToRadiusOperation(); + converter->setCameraObject(camob); + converter->setfStop(data->fstop); + converter->setMaxRadius(data->maxblur); + this->getInputSocket(1)->relinkConnections(converter->getInputSocket(0), true, 1, graph); + graph->addOperation(converter); + radiusOperation = converter; + } + + BokehImageOperation *bokeh = new BokehImageOperation(); + NodeBokehImage * bokehdata = new NodeBokehImage(); + bokehdata->angle = data->rotation; + bokehdata->rounding = 0.0f; + bokehdata->flaps = data->bktype; + if (data->bktype<3) { + bokehdata->flaps = 5; + bokehdata->rounding = 1.0f; + } + bokehdata->catadioptric = 0.0f; + bokehdata->lensshift = 0.0f; + + bokeh->setData(bokehdata); + bokeh->deleteDataOnFinish(); + graph->addOperation(bokeh); + + VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); + operation->setQuality(context->getQuality()); + operation->setMaxBlur(data->maxblur); + operation->setThreshold(data->bthresh); + addLink(graph, bokeh->getOutputSocket(), operation->getInputSocket(1)); + addLink(graph, radiusOperation->getOutputSocket(), operation->getInputSocket(2)); + if (data->gamco) { + GammaCorrectOperation * correct = new GammaCorrectOperation(); + GammaUncorrectOperation * inverse = new GammaUncorrectOperation(); + this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, true, graph); + addLink(graph, correct->getOutputSocket(), operation->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), inverse->getInputSocket(0)); + this->getOutputSocket()->relinkConnections(inverse->getOutputSocket()); + graph->addOperation(correct); + graph->addOperation(inverse); + } else { + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, true, graph); + this->getOutputSocket()->relinkConnections(operation->getOutputSocket()); + } + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_DefocusNode.h b/source/blender/compositor/nodes/COM_DefocusNode.h new file mode 100644 index 00000000000..3d2ff7eb4de --- /dev/null +++ b/source/blender/compositor/nodes/COM_DefocusNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_DefocusNode_h_ +#define _COM_DefocusNode_h_ + +#include "COM_Node.h" + +/** + * @brief DefocusNode + * @ingroup Node + */ + +class DefocusNode: public Node { +public: + DefocusNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp new file mode 100644 index 00000000000..8327813cf05 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp @@ -0,0 +1,52 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_DifferenceMatteNode.h" +#include "BKE_node.h" +#include "COM_DifferenceMatteOperation.h" +#include "COM_SetAlphaOperation.h" + +DifferenceMatteNode::DifferenceMatteNode(bNode* editorNode): Node(editorNode) +{} + +void DifferenceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputSocket2 = this->getInputSocket(1); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + bNode* editorNode = this->getbNode(); + + DifferenceMatteOperation * operationSet = new DifferenceMatteOperation(); + operationSet->setSettings((NodeChroma*)editorNode->storage); + inputSocket->relinkConnections(operationSet->getInputSocket(0), true, 0, graph); + inputSocket2->relinkConnections(operationSet->getInputSocket(1), true, 1, graph); + + outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0)); + graph->addOperation(operationSet); + + SetAlphaOperation * operation = new SetAlphaOperation(); + addLink(graph, operationSet->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0)); + addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1)); + outputSocketImage->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); + addPreviewOperation(graph, operation->getOutputSocket(), 5); +} diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.h b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h new file mode 100644 index 00000000000..2adce752f49 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_DifferenceMatteNODE_H +#define COM_DifferenceMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief DifferenceMatteNode + * @ingroup Node + */ +class DifferenceMatteNode : public Node +{ +public: + DifferenceMatteNode(bNode* editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif // COM_DifferenceMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.cpp b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp new file mode 100644 index 00000000000..185eb6475bf --- /dev/null +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.cpp @@ -0,0 +1,46 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_DilateErodeNode.h" +#include "DNA_scene_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_DilateErodeOperation.h" +#include "COM_AntiAliasOperation.h" +#include "BLI_math.h" + +DilateErodeNode::DilateErodeNode(bNode *editorNode): Node(editorNode) { +} + +void DilateErodeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + bNode* editorNode = this->getbNode(); + DilateErodeOperation *operation = new DilateErodeOperation(); + operation->setDistance(editorNode->custom2); + operation->setInset(2.0f); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0)); + + AntiAliasOperation * antiAlias = new AntiAliasOperation(); + addLink(graph, operation->getOutputSocket(), antiAlias->getInputSocket(0)); + this->getOutputSocket(0)->relinkConnections(antiAlias->getOutputSocket(0)); + graph->addOperation(operation); + graph->addOperation(antiAlias); +} diff --git a/source/blender/compositor/nodes/COM_DilateErodeNode.h b/source/blender/compositor/nodes/COM_DilateErodeNode.h new file mode 100644 index 00000000000..1ebf7e0b4c8 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DilateErodeNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_DilateErodeNode_h_ +#define _COM_DilateErodeNode_h_ + +#include "COM_Node.h" + +/** + * @brief DilateErodeNode + * @ingroup Node + */ +class DilateErodeNode: public Node { +public: + DilateErodeNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp new file mode 100644 index 00000000000..ef3e4918048 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_DirectionalBlurNode.h" +#include "DNA_scene_types.h" +#include "DNA_node_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_DirectionalBlurOperation.h" + +DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode): Node(editorNode) { +} + +void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + NodeDBlurData *data = (NodeDBlurData*)this->getbNode()->storage; + DirectionalBlurOperation *operation = new DirectionalBlurOperation(); + operation->setQuality(context->getQuality()); + operation->setData(data); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.h b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h new file mode 100644 index 00000000000..842e330d6d0 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_DirectionalBlurNode_h_ +#define _COM_DirectionalBlurNode_h_ + +#include "COM_Node.h" + +/** + * @brief DirectionalBlurNode + * @ingroup Node + */ +class DirectionalBlurNode: public Node { +public: + DirectionalBlurNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.cpp b/source/blender/compositor/nodes/COM_DisplaceNode.cpp new file mode 100644 index 00000000000..ff5dd413468 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DisplaceNode.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_DisplaceNode.h" +#include "COM_DisplaceOperation.h" +#include "COM_DisplaceSimpleOperation.h" +#include "COM_ExecutionSystem.h" + +DisplaceNode::DisplaceNode(bNode *editorNode): Node(editorNode) { +} + +void DisplaceNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) +{ + NodeOperation *operation; + if (context->getQuality() == COM_QUALITY_LOW) + operation = new DisplaceSimpleOperation(); + else + operation = new DisplaceOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, graph); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_DisplaceNode.h b/source/blender/compositor/nodes/COM_DisplaceNode.h new file mode 100644 index 00000000000..3451f05dd1f --- /dev/null +++ b/source/blender/compositor/nodes/COM_DisplaceNode.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_DisplaceNode_h +#define _COM_DisplaceNode_h + +#include "COM_Node.h" + +/** + * @brief DisplaceNode + * @ingroup Node + */ +class DisplaceNode : public Node { +public: + DisplaceNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp new file mode 100644 index 00000000000..c55ce803f97 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_DistanceMatteNode.h" +#include "BKE_node.h" +#include "COM_DistanceMatteOperation.h" +#include "COM_SetAlphaOperation.h" + +DistanceMatteNode::DistanceMatteNode(bNode *editorNode): Node(editorNode) +{} + +void DistanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocketImage = this->getInputSocket(0); + InputSocket *inputSocketKey = this->getInputSocket(1); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + + DistanceMatteOperation *operation = new DistanceMatteOperation(); + bNode* editorsnode = getbNode(); + operation->setSettings((NodeChroma*)editorsnode->storage); + + inputSocketImage->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputSocketKey->relinkConnections(operation->getInputSocket(1), true, 1, graph); + + if (outputSocketMatte->isConnected()) { + outputSocketMatte->relinkConnections(operation->getOutputSocket()); + } + + graph->addOperation(operation); + + SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + addLink(graph, operation->getInputSocket(0)->getConnection()->getFromSocket(), operationAlpha->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), operationAlpha->getInputSocket(1)); + + graph->addOperation(operationAlpha); + addPreviewOperation(graph, operationAlpha->getOutputSocket(), 9); + + if (outputSocketImage->isConnected()) { + outputSocketImage->relinkConnections(operationAlpha->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.h b/source/blender/compositor/nodes/COM_DistanceMatteNode.h new file mode 100644 index 00000000000..740eb767a71 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef COM_DistanceMatteNODE_H +#define COM_DistanceMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief DistanceMatteNode + * @ingroup Node + */ +class DistanceMatteNode : public Node +{ +public: + DistanceMatteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_DistanceMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp new file mode 100644 index 00000000000..f1ec4ab9b23 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_DoubleEdgeMaskNode.h" +#include "COM_DoubleEdgeMaskOperation.h" +#include "DNA_scene_types.h" +#include "COM_ExecutionSystem.h" + +DoubleEdgeMaskNode::DoubleEdgeMaskNode(bNode *editorNode): Node(editorNode) { +} + +void DoubleEdgeMaskNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + DoubleEdgeMaskOperation *operation; + bNode* bnode = this->getbNode(); + + operation = new DoubleEdgeMaskOperation(); + operation->setAdjecentOnly(bnode->custom1); + operation->setKeepInside(bnode->custom2); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + system->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h new file mode 100644 index 00000000000..26d553a1422 --- /dev/null +++ b/source/blender/compositor/nodes/COM_DoubleEdgeMaskNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_DoubleEdgeMaskNode_h_ +#define _COM_DoubleEdgeMaskNode_h_ + +#include "COM_Node.h" + +/** + * @brief DoubleEdgeMaskNode + * @ingroup Node + */ +class DoubleEdgeMaskNode: public Node { +public: + DoubleEdgeMaskNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp new file mode 100644 index 00000000000..89996f0e590 --- /dev/null +++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_EllipseMaskNode.h" +#include "DNA_scene_types.h" +#include "COM_EllipseMaskOperation.h" +#include "COM_ExecutionSystem.h" + +EllipseMaskNode::EllipseMaskNode(bNode *editorNode): Node(editorNode) { +} + +void EllipseMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + EllipseMaskOperation *operation; + operation = new EllipseMaskOperation(); + operation->setData((NodeEllipseMask*)this->getbNode()->storage); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + operation->setMaskType(this->getbNode()->custom1); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_EllipseMaskNode.h b/source/blender/compositor/nodes/COM_EllipseMaskNode.h new file mode 100644 index 00000000000..4fecf6946cc --- /dev/null +++ b/source/blender/compositor/nodes/COM_EllipseMaskNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_EllipseMaskNode_h_ +#define _COM_EllipseMaskNode_h_ + +#include "COM_Node.h" + +/** + * @brief EllipseMaskNode + * @ingroup Node + */ +class EllipseMaskNode: public Node { +public: + EllipseMaskNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_FilterNode.cpp b/source/blender/compositor/nodes/COM_FilterNode.cpp new file mode 100644 index 00000000000..ce78e451f30 --- /dev/null +++ b/source/blender/compositor/nodes/COM_FilterNode.cpp @@ -0,0 +1,81 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_FilterNode.h" +#include "COM_ConvolutionFilterOperation.h" +#include "COM_ConvolutionEdgeFilterOperation.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" +#include "COM_MixBlendOperation.h" + +FilterNode::FilterNode(bNode* editorNode): Node(editorNode) +{ +} + +void FilterNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputImageSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + ConvolutionFilterOperation *operation = NULL; + + switch(this->getbNode()->custom1) { + case CMP_FILT_SOFT: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f); + break; + case CMP_FILT_SHARP: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(-1,-1,-1,-1,9,-1,-1,-1,-1); + break; + case CMP_FILT_LAPLACE: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f); + break; + case CMP_FILT_SOBEL: + operation = new ConvolutionEdgeFilterOperation(); + operation->set3x3Filter(1,2,1,0,0,0,-1,-2,-1); + break; + case CMP_FILT_PREWITT: + operation = new ConvolutionEdgeFilterOperation(); + operation->set3x3Filter(1,1,1,0,0,0,-1,-1,-1); + break; + case CMP_FILT_KIRSCH: + operation = new ConvolutionEdgeFilterOperation(); + operation->set3x3Filter(5,5,5,-3,-3,-3,-2,-2,-2); + break; + case CMP_FILT_SHADOW: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(1,2,1,0,1,0,-1,-2,-1); + break; + default: + operation = new ConvolutionFilterOperation(); + operation->set3x3Filter(0,0,0,0,1,0,0,0,0); + break; + } + + inputImageSocket->relinkConnections(operation->getInputSocket(0), true, 1, graph); + inputSocket->relinkConnections(operation->getInputSocket(1), true, 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket()); + addPreviewOperation(graph, operation->getOutputSocket(0), 5); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_FilterNode.h b/source/blender/compositor/nodes/COM_FilterNode.h new file mode 100644 index 00000000000..c77846ef2fe --- /dev/null +++ b/source/blender/compositor/nodes/COM_FilterNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_FILTERNODE_H +#define COM_FILTERNODE_H + +#include "COM_Node.h" + +/** + * @brief FilterNode + * @ingroup Node + */ +class FilterNode : public Node +{ +public: + FilterNode(bNode* editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif // COM_FILTERNODE_H diff --git a/source/blender/compositor/nodes/COM_FlipNode.cpp b/source/blender/compositor/nodes/COM_FlipNode.cpp new file mode 100644 index 00000000000..7fbb21478ec --- /dev/null +++ b/source/blender/compositor/nodes/COM_FlipNode.cpp @@ -0,0 +1,53 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_FlipNode.h" + +#include "COM_FlipOperation.h" +#include "COM_ExecutionSystem.h" + +FlipNode::FlipNode(bNode *editorNode) : Node(editorNode) { +} + +void FlipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocket = this->getOutputSocket(0); + FlipOperation *operation = new FlipOperation(); + switch (this->getbNode()->custom1) { + case 0: /// @TODO: I didn't find any constants in the old implementation, should I introduce them. + operation->setFlipX(true); + operation->setFlipY(false); + break; + case 1: + operation->setFlipX(false); + operation->setFlipY(true); + break; + case 2: + operation->setFlipX(true); + operation->setFlipY(true); + break; + } + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_FlipNode.h b/source/blender/compositor/nodes/COM_FlipNode.h new file mode 100644 index 00000000000..593fed452af --- /dev/null +++ b/source/blender/compositor/nodes/COM_FlipNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_FlipNode_h_ +#define _COM_FlipNode_h_ + +#include "COM_Node.h" + +/** + * @brief FlipNode + * @ingroup Node + */ +class FlipNode: public Node { +public: + FlipNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_GammaNode.cpp b/source/blender/compositor/nodes/COM_GammaNode.cpp new file mode 100644 index 00000000000..e61f9245f40 --- /dev/null +++ b/source/blender/compositor/nodes/COM_GammaNode.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_GammaNode.h" +#include "DNA_scene_types.h" +#include "COM_GammaOperation.h" +#include "COM_ExecutionSystem.h" + +GammaNode::GammaNode(bNode *editorNode): Node(editorNode) { +} + +void GammaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + GammaOperation *operation = new GammaOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_GammaNode.h b/source/blender/compositor/nodes/COM_GammaNode.h new file mode 100644 index 00000000000..56f2374467d --- /dev/null +++ b/source/blender/compositor/nodes/COM_GammaNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_GammaNode_h_ +#define _COM_GammaNode_h_ + +#include "COM_Node.h" + +/** + * @brief GammaNode + * @ingroup Node + */ +class GammaNode: public Node { +public: + GammaNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_GlareNode.cpp b/source/blender/compositor/nodes/COM_GlareNode.cpp new file mode 100644 index 00000000000..c0fcad1a5b3 --- /dev/null +++ b/source/blender/compositor/nodes/COM_GlareNode.cpp @@ -0,0 +1,128 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_GlareNode.h" +#include "DNA_node_types.h" +#include "COM_FogGlowImageOperation.h" +#include "COM_BokehBlurOperation.h" +#include "COM_GlareThresholdOperation.h" +#include "COM_GlareSimpleStarOperation.h" +#include "COM_GlareStreaksOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_MixBlendOperation.h" + +GlareNode::GlareNode(bNode *editorNode): Node(editorNode) { +} + +void GlareNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + bNode* node = this->getbNode(); + NodeGlare* glare = (NodeGlare*)node->storage; + + switch (glare->type) { + + default: + case 2: // streaks + { + GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); + GlareStreaksOperation * glareoperation = new GlareStreaksOperation(); + SetValueOperation * mixvalueoperation = new SetValueOperation(); + MixBlendOperation * mixoperation = new MixBlendOperation(); + + this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system); + addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); + addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); + addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2)); + addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1)); + this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket()); + + thresholdOperation->setThreshold(glare->threshold); + glareoperation->setGlareSettings(glare); + mixvalueoperation->setValue(0.5f+glare->mix*0.5f); + mixoperation->setResolutionInputSocketIndex(1); + + system->addOperation(glareoperation); + system->addOperation(thresholdOperation); + system->addOperation(mixvalueoperation); + system->addOperation(mixoperation); + } + break; + case 1: // fog glow + { + GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); + FogGlowImageOperation * kerneloperation = new FogGlowImageOperation(); + BokehBlurOperation * bluroperation = new BokehBlurOperation(); + SetValueOperation * valueoperation = new SetValueOperation(); + SetValueOperation * mixvalueoperation = new SetValueOperation(); + MixBlendOperation * mixoperation = new MixBlendOperation(); + mixoperation->setResolutionInputSocketIndex(1); + this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system); + addLink(system, thresholdOperation->getOutputSocket(), bluroperation->getInputSocket(0)); + addLink(system, kerneloperation->getOutputSocket(), bluroperation->getInputSocket(1)); + addLink(system, valueoperation->getOutputSocket(), bluroperation->getInputSocket(2)); + addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); + addLink(system, bluroperation->getOutputSocket(), mixoperation->getInputSocket(2)); + addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1)); + + thresholdOperation->setThreshold(glare->threshold); + bluroperation->setSize(0.003f*glare->size); + bluroperation->setQuality(context->getQuality()); + valueoperation->setValue(1.0f); + mixvalueoperation->setValue(0.5f+glare->mix*0.5f); + this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket()); + + system->addOperation(bluroperation); + system->addOperation(kerneloperation); + system->addOperation(thresholdOperation); + system->addOperation(mixvalueoperation); + system->addOperation(valueoperation); + system->addOperation(mixoperation); + } + break; + + case 0: // simple star + { + GlareThresholdOperation *thresholdOperation = new GlareThresholdOperation(); + GlareSimpleStarOperation * glareoperation = new GlareSimpleStarOperation(); + SetValueOperation * mixvalueoperation = new SetValueOperation(); + MixBlendOperation * mixoperation = new MixBlendOperation(); + + this->getInputSocket(0)->relinkConnections(thresholdOperation->getInputSocket(0), true, 0, system); + addLink(system, thresholdOperation->getOutputSocket(), glareoperation->getInputSocket(0)); + addLink(system, mixvalueoperation->getOutputSocket(), mixoperation->getInputSocket(0)); + addLink(system, glareoperation->getOutputSocket(), mixoperation->getInputSocket(2)); + addLink(system, thresholdOperation->getInputSocket(0)->getConnection()->getFromSocket(), mixoperation->getInputSocket(1)); + this->getOutputSocket()->relinkConnections(mixoperation->getOutputSocket()); + + thresholdOperation->setThreshold(glare->threshold); + glareoperation->setGlareSettings(glare); + mixvalueoperation->setValue(0.5f+glare->mix*0.5f); + mixoperation->setResolutionInputSocketIndex(1); + + + system->addOperation(glareoperation); + system->addOperation(thresholdOperation); + system->addOperation(mixvalueoperation); + system->addOperation(mixoperation); + } + break; + } +} diff --git a/source/blender/compositor/nodes/COM_GlareNode.h b/source/blender/compositor/nodes/COM_GlareNode.h new file mode 100644 index 00000000000..b3e965fa72d --- /dev/null +++ b/source/blender/compositor/nodes/COM_GlareNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_GlareNode_h_ +#define _COM_GlareNode_h_ + +#include "COM_Node.h" + +/** + * @brief GlareNode + * @ingroup Node + */ +class GlareNode: public Node { +public: + GlareNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp new file mode 100644 index 00000000000..dcb8691524a --- /dev/null +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_GroupNode.h" +#include "COM_SocketProxyNode.h" +#include "COM_ExecutionSystemHelper.h" + +GroupNode::GroupNode(bNode *editorNode): Node(editorNode) { +} + +void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { +} + +void GroupNode::ungroup(ExecutionSystem &system) { + vector<InputSocket*> &inputsockets = this->getInputSockets(); + vector<OutputSocket*> &outputsockets = this->getOutputSockets(); + unsigned int index; + + /* get the node list size _before_ adding proxy nodes, so they are available for linking */ + int nodes_start = system.getNodes().size(); + + for (index = 0 ; index < inputsockets.size();index ++) { + InputSocket * inputSocket = inputsockets[index]; + bNodeSocket *editorInput = inputSocket->getbNodeSocket(); + if (editorInput->groupsock) { + if (inputSocket->isConnected()) { + SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock); + inputSocket->relinkConnections(proxy->getInputSocket(0), true, index, &system); + ExecutionSystemHelper::addNode(system.getNodes(), proxy); + } else { + OutputSocketProxyNode * proxy = new OutputSocketProxyNode(this->getbNode(), editorInput, editorInput->groupsock); + inputSocket->relinkConnections(proxy->getInputSocket(0), true, index, &system); + ExecutionSystemHelper::addNode(system.getNodes(), proxy); + } + } + } + + for (index = 0 ; index < outputsockets.size();index ++) { + OutputSocket * outputSocket = outputsockets[index]; + bNodeSocket *editorOutput = outputSocket->getbNodeSocket(); + if (outputSocket->isConnected() && editorOutput->groupsock) { + SocketProxyNode * proxy = new SocketProxyNode(this->getbNode(), editorOutput->groupsock, editorOutput); + outputSocket->relinkConnections(proxy->getOutputSocket(0)); + ExecutionSystemHelper::addNode(system.getNodes(), proxy); + } + } + + bNodeTree* subtree = (bNodeTree*)this->getbNode()->id; + ExecutionSystemHelper::addbNodeTree(system, nodes_start, subtree); +} diff --git a/source/blender/compositor/nodes/COM_GroupNode.h b/source/blender/compositor/nodes/COM_GroupNode.h new file mode 100644 index 00000000000..a3a46ad2c33 --- /dev/null +++ b/source/blender/compositor/nodes/COM_GroupNode.h @@ -0,0 +1,57 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_GroupNode_h_ +#define _COM_GroupNode_h_ + +#include "COM_Node.h" +#include "COM_ExecutionSystem.h" + +/** + * @brief Represents a group node + * @ingroup Node + */ +class GroupNode: public Node { +public: + GroupNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); + + /** + * @brief check if this node a group node. + * @returns true + */ + bool isGroupNode() const { return true; } + + /** + * @brief ungroup this group node. + * during ungroup the subtree (internal nodes and links) of the group node + * are added to the ExecutionSystem. + * + * Between the main tree and the subtree proxy nodes will be added + * to translate between InputSocket and OutputSocket + * + * @param system the ExecutionSystem where to add the subtree + */ + void ungroup(ExecutionSystem &system); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp new file mode 100644 index 00000000000..88ba24498bb --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.cpp @@ -0,0 +1,69 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_HueSaturationValueCorrectNode.h" + +#include "COM_ConvertColourToValueProg.h" +#include "COM_ExecutionSystem.h" +#include "COM_ConvertRGBToHSVOperation.h" +#include "COM_ConvertHSVToRGBOperation.h" +#include "COM_MixBlendOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_ChangeHSVOperation.h" +#include "DNA_node_types.h" +#include "COM_HueSaturationValueCorrectOperation.h" + +HueSaturationValueCorrectNode::HueSaturationValueCorrectNode(bNode *editorNode): Node(editorNode) { +} + +void HueSaturationValueCorrectNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *valueSocket = this->getInputSocket(0); + InputSocket *colourSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* editorsnode = getbNode(); + CurveMapping *storage = (CurveMapping*)editorsnode->storage; + + if (colourSocket->isConnected() && outputSocket->isConnected()) { + ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation(); + ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation(); + HueSaturationValueCorrectOperation *changeHSV = new HueSaturationValueCorrectOperation(); + MixBlendOperation * blend = new MixBlendOperation(); + + colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), true, 0, graph); + addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); + valueSocket->relinkConnections(blend->getInputSocket(0), true, 0, graph); + outputSocket->relinkConnections(blend->getOutputSocket()); + + changeHSV->setCurveMapping(storage); + + blend->setResolutionInputSocketIndex(1); + + graph->addOperation(rgbToHSV); + graph->addOperation(hsvToRGB); + graph->addOperation(changeHSV); + graph->addOperation(blend); + } +} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h new file mode 100644 index 00000000000..d69990f712c --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueCorrectNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_HueSaturationValueCorrectNode_h +#define _COM_HueSaturationValueCorrectNode_h + +#include "COM_Node.h" + +/** + * @brief HueSaturationValueCorrectNode + * @ingroup Node + */ +class HueSaturationValueCorrectNode : public Node { +public: + HueSaturationValueCorrectNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp new file mode 100644 index 00000000000..b4b9b55cf8b --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.cpp @@ -0,0 +1,68 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_HueSaturationValueNode.h" + +#include "COM_ConvertColourToValueProg.h" +#include "COM_ExecutionSystem.h" +#include "COM_ConvertRGBToHSVOperation.h" +#include "COM_ConvertHSVToRGBOperation.h" +#include "COM_MixBlendOperation.h" +#include "COM_SetColorOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_ChangeHSVOperation.h" +#include "DNA_node_types.h" + +HueSaturationValueNode::HueSaturationValueNode(bNode *editorNode): Node(editorNode) { +} + +void HueSaturationValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *valueSocket = this->getInputSocket(0); + InputSocket *colourSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* editorsnode = getbNode(); + NodeHueSat *storage = (NodeHueSat*)editorsnode->storage; + + ConvertRGBToHSVOperation * rgbToHSV = new ConvertRGBToHSVOperation(); + ConvertHSVToRGBOperation * hsvToRGB = new ConvertHSVToRGBOperation(); + ChangeHSVOperation *changeHSV = new ChangeHSVOperation(); + MixBlendOperation * blend = new MixBlendOperation(); + + colourSocket->relinkConnections(rgbToHSV->getInputSocket(0), true, 0, graph); + addLink(graph, rgbToHSV->getOutputSocket(), changeHSV->getInputSocket(0)); + addLink(graph, changeHSV->getOutputSocket(), hsvToRGB->getInputSocket(0)); + addLink(graph, hsvToRGB->getOutputSocket(), blend->getInputSocket(2)); + addLink(graph, rgbToHSV->getInputSocket(0)->getConnection()->getFromSocket(), blend->getInputSocket(1)); + valueSocket->relinkConnections(blend->getInputSocket(0), true, 0, graph); + outputSocket->relinkConnections(blend->getOutputSocket()); + + changeHSV->setHue(storage->hue); + changeHSV->setSaturation(storage->sat); + changeHSV->setValue(storage->val); + + blend->setResolutionInputSocketIndex(1); + + graph->addOperation(rgbToHSV); + graph->addOperation(hsvToRGB); + graph->addOperation(changeHSV); + graph->addOperation(blend); +} diff --git a/source/blender/compositor/nodes/COM_HueSaturationValueNode.h b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h new file mode 100644 index 00000000000..4fa1a4f547c --- /dev/null +++ b/source/blender/compositor/nodes/COM_HueSaturationValueNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_HueSaturationValueNode_h +#define _COM_HueSaturationValueNode_h + +#include "COM_Node.h" + +/** + * @brief HueSaturationValueNode + * @ingroup Node + */ +class HueSaturationValueNode : public Node { +public: + HueSaturationValueNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.cpp b/source/blender/compositor/nodes/COM_IDMaskNode.cpp new file mode 100644 index 00000000000..440468afd46 --- /dev/null +++ b/source/blender/compositor/nodes/COM_IDMaskNode.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_IDMaskNode.h" +#include "DNA_scene_types.h" +#include "COM_IDMaskOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_AntiAliasOperation.h" + +IDMaskNode::IDMaskNode(bNode *editorNode): Node(editorNode) { +} +void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + bNode* bnode = this->getbNode(); + IDMaskOperation *operation; + operation = new IDMaskOperation(); + operation->setObjectIndex(bnode->custom1); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0)); + if (bnode->custom2==0 || context->getScene()->r.scemode & R_FULL_SAMPLE) { + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + } else { + AntiAliasOperation * antiAliasOperation = new AntiAliasOperation(); + addLink(graph, operation->getOutputSocket(), antiAliasOperation->getInputSocket(0)); + this->getOutputSocket(0)->relinkConnections(antiAliasOperation->getOutputSocket(0)); + graph->addOperation(antiAliasOperation); + } + graph->addOperation(operation); + +} diff --git a/source/blender/compositor/nodes/COM_IDMaskNode.h b/source/blender/compositor/nodes/COM_IDMaskNode.h new file mode 100644 index 00000000000..5559044df4e --- /dev/null +++ b/source/blender/compositor/nodes/COM_IDMaskNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_IDMaskNode_h_ +#define _COM_IDMaskNode_h_ + +#include "COM_Node.h" + +/** + * @brief IDMaskNode + * @ingroup Node + */ +class IDMaskNode: public Node { +public: + IDMaskNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp new file mode 100644 index 00000000000..20e6069b60a --- /dev/null +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -0,0 +1,150 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Lukas Tönne + */ + +#include "COM_ImageNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_ImageOperation.h" +#include "COM_MultilayerImageOperation.h" +#include "BKE_node.h" +#include "BLI_utildefines.h" + +ImageNode::ImageNode(bNode *editorNode): Node(editorNode) { +} +NodeOperation* ImageNode::doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype) { + OutputSocket *outputSocket = this->getOutputSocket(outputsocketIndex); + MultilayerBaseOperation * operation = NULL; + switch (datatype) { + case COM_DT_VALUE: + operation = new MultilayerValueOperation(pass); + break; + case COM_DT_VECTOR: + operation = new MultilayerVectorOperation(pass); + break; + case COM_DT_COLOR: + operation = new MultilayerColorOperation(pass); + break; + default: + break; + } + operation->setImage(image); + operation->setRenderLayer(rl); + operation->setImageUser(user); + operation->setFramenumber(framenumber); + outputSocket->relinkConnections(operation->getOutputSocket()); + system->addOperation(operation); + return operation; +} + +void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + /// Image output + OutputSocket *outputImage = this->getOutputSocket(0); + bNode *editorNode = this->getbNode(); + Image *image = (Image*)editorNode->id; + ImageUser *imageuser = (ImageUser*)editorNode->storage; + int framenumber = context->getFramenumber(); + int numberOfOutputs = this->getNumberOfOutputSockets(); + + /* force a load, we assume iuser index will be set OK anyway */ + if(image && image->type==IMA_TYPE_MULTILAYER) { + BKE_image_get_ibuf(image, imageuser); + if(image->rr) { + OutputSocket * socket; + int index; + for (index = 0 ; index < numberOfOutputs ; index ++) { + socket = this->getOutputSocket(index); + if (socket->isConnected() || index == 0) { + bNodeSocket *bnodeSocket = socket->getbNodeSocket(); + NodeImageLayer *storage = (NodeImageLayer*)bnodeSocket->storage; + int passindex = storage->pass_index; + int layerindex = storage->layer_index; + RenderLayer *rl= (RenderLayer*)BLI_findlink(&image->rr->layers, layerindex); + if (rl) { + + RenderPass *rpass = (RenderPass *)BLI_findlink(&rl->passes, passindex); + if (rpass) { + NodeOperation * operation = NULL; + imageuser->pass = passindex; + imageuser->layer = layerindex; + switch (rpass->channels) { + case 1: + operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VALUE); + break; + /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */ + /* XXX any way to detect actual vector images? */ + case 3: + operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_VECTOR); + break; + case 4: + operation = doMultilayerCheck(graph, rl, image, imageuser, framenumber, index, passindex, COM_DT_COLOR); + break; + + default: + /* XXX add a dummy operation? */ + break; + } + if (index == 0 && operation) { + addPreviewOperation(graph, operation->getOutputSocket(), 9); + } + } + } + } + } + } + } else { + if (numberOfOutputs > 0) { + ImageOperation *operation = new ImageOperation(); + if (outputImage->isConnected()) { + outputImage->relinkConnections(operation->getOutputSocket()); + } + operation->setImage(image); + operation->setImageUser(imageuser); + operation->setFramenumber(framenumber); + graph->addOperation(operation); + addPreviewOperation(graph, operation->getOutputSocket(), 9); + } + + if (numberOfOutputs > 1) { + OutputSocket *alphaImage = this->getOutputSocket(1); + if (alphaImage->isConnected()) { + ImageAlphaOperation *alphaOperation = new ImageAlphaOperation(); + alphaOperation->setImage(image); + alphaOperation->setImageUser(imageuser); + alphaOperation->setFramenumber(framenumber); + alphaImage->relinkConnections(alphaOperation->getOutputSocket()); + graph->addOperation(alphaOperation); + } + } + if (numberOfOutputs > 2) { + OutputSocket *depthImage = this->getOutputSocket(2); + if (depthImage->isConnected()) { + ImageDepthOperation *depthOperation = new ImageDepthOperation(); + depthOperation->setImage(image); + depthOperation->setImageUser(imageuser); + depthOperation->setFramenumber(framenumber); + depthImage->relinkConnections(depthOperation->getOutputSocket()); + graph->addOperation(depthOperation); + } + } + } +} + diff --git a/source/blender/compositor/nodes/COM_ImageNode.h b/source/blender/compositor/nodes/COM_ImageNode.h new file mode 100644 index 00000000000..cfbfbd119f9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ImageNode.h @@ -0,0 +1,44 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Lukas Tönne + */ + +#include "COM_defines.h" +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "DNA_image_types.h" +extern "C" { + #include "RE_engine.h" +} + +/** + * @brief ImageNode + * @ingroup Node + */ +class ImageNode : public Node { + +private: + NodeOperation* doMultilayerCheck(ExecutionSystem *system, RenderLayer* rl, Image* image, ImageUser* user, int framenumber, int outputsocketIndex, int pass, DataType datatype); +public: + ImageNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); + +}; diff --git a/source/blender/compositor/nodes/COM_InvertNode.cpp b/source/blender/compositor/nodes/COM_InvertNode.cpp new file mode 100644 index 00000000000..2c47b467537 --- /dev/null +++ b/source/blender/compositor/nodes/COM_InvertNode.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_InvertNode.h" +#include "DNA_scene_types.h" +#include "COM_InvertOperation.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" + +InvertNode::InvertNode(bNode *editorNode): Node(editorNode) { +} + +void InvertNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InvertOperation *operation = new InvertOperation(); + bNode* node = this->getbNode(); + operation->setColor(node->custom1 & CMP_CHAN_RGB); + operation->setAlpha(node->custom1 & CMP_CHAN_A); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0),true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1),true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_InvertNode.h b/source/blender/compositor/nodes/COM_InvertNode.h new file mode 100644 index 00000000000..ec70be3ba31 --- /dev/null +++ b/source/blender/compositor/nodes/COM_InvertNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_InvertNode_h_ +#define _COM_InvertNode_h_ + +#include "COM_Node.h" + +/** + * @brief InvertNode + * @ingroup Node + */ +class InvertNode: public Node { +public: + InvertNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp new file mode 100644 index 00000000000..edaa0a9009e --- /dev/null +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_LensDistortionNode.h" +#include "DNA_scene_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_ProjectorLensDistortionOperation.h" +#include "COM_ScreenLensDistortionOperation.h" + +LensDistortionNode::LensDistortionNode(bNode *editorNode): Node(editorNode) { +} + +void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + bNode* editorNode = this->getbNode(); + NodeLensDist * data = (NodeLensDist*)editorNode->storage; + if (data->proj) { + ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + + operation->setData(data); + graph->addOperation(operation); + + } else { + ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]); + operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + + operation->setData(data); + graph->addOperation(operation); + } + +} diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.h b/source/blender/compositor/nodes/COM_LensDistortionNode.h new file mode 100644 index 00000000000..41b84d4baff --- /dev/null +++ b/source/blender/compositor/nodes/COM_LensDistortionNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_LensDistortionNode_h_ +#define _COM_LensDistortionNode_h_ + +#include "COM_Node.h" + +/** + * @brief LensDistortionNode + * @ingroup Node + */ +class LensDistortionNode: public Node { +public: + LensDistortionNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp new file mode 100644 index 00000000000..010688b6c2a --- /dev/null +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_LuminanceMatteNode.h" +#include "BKE_node.h" +#include "COM_LuminanceMatteOperation.h" +#include "COM_ConvertRGBToYUVOperation.h" +#include "COM_SetAlphaOperation.h" + +LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode): Node(editorNode) +{} + +void LuminanceMatteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocketImage = this->getOutputSocket(0); + OutputSocket *outputSocketMatte = this->getOutputSocket(1); + + ConvertRGBToYUVOperation *rgbToYUV = new ConvertRGBToYUVOperation(); + LuminanceMatteOperation *operationSet = new LuminanceMatteOperation(); + bNode* editorsnode = getbNode(); + operationSet->setSettings((NodeChroma*)editorsnode->storage); + + inputSocket->relinkConnections(rgbToYUV->getInputSocket(0), true, 0, graph); + addLink(graph, rgbToYUV->getOutputSocket(), operationSet->getInputSocket(0)); + + if (outputSocketMatte->isConnected()) { + outputSocketMatte->relinkConnections(operationSet->getOutputSocket(0)); + } + + graph->addOperation(rgbToYUV); + graph->addOperation(operationSet); + + SetAlphaOperation *operation = new SetAlphaOperation(); + addLink(graph, rgbToYUV->getInputSocket(0)->getConnection()->getFromSocket(), operation->getInputSocket(0)); + addLink(graph, operationSet->getOutputSocket(), operation->getInputSocket(1)); + graph->addOperation(operation); + addPreviewOperation(graph, operation->getOutputSocket(), 9); + + if (outputSocketImage->isConnected()) { + outputSocketImage->relinkConnections(operation->getOutputSocket()); + } +} diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.h b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h new file mode 100644 index 00000000000..e2dd8b47833 --- /dev/null +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef COM_LuminanceMatteNODE_H +#define COM_LuminanceMatteNODE_H + +#include "COM_Node.h" + +/** + * @brief LuminanceMatteNode + * @ingroup Node + */ +class LuminanceMatteNode : public Node +{ +public: + LuminanceMatteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif // COM_LuminanceMatteNODE_H diff --git a/source/blender/compositor/nodes/COM_MapUVNode.cpp b/source/blender/compositor/nodes/COM_MapUVNode.cpp new file mode 100644 index 00000000000..14129eb7064 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapUVNode.cpp @@ -0,0 +1,41 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_MapUVNode.h" +#include "COM_MapUVOperation.h" +#include "COM_ExecutionSystem.h" + +MapUVNode::MapUVNode(bNode *editorNode): Node(editorNode) { +} + +void MapUVNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + MapUVOperation *operation = new MapUVOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + bNode* node = this->getbNode(); + operation->setAlpha((float)node->custom1); + operation->setResolutionInputSocketIndex(1); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_MapUVNode.h b/source/blender/compositor/nodes/COM_MapUVNode.h new file mode 100644 index 00000000000..3092e84990f --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapUVNode.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_MapUVNode_h +#define _COM_MapUVNode_h + +#include "COM_Node.h" + +/** + * @brief MapUVNode + * @ingroup Node + */ +class MapUVNode : public Node { +public: + MapUVNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_MapValueNode.cpp b/source/blender/compositor/nodes/COM_MapValueNode.cpp new file mode 100644 index 00000000000..834b74a552d --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapValueNode.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MapValueNode.h" + +#include "COM_MapValueOperation.h" +#include "COM_ExecutionSystem.h" + +MapValueNode::MapValueNode(bNode *editorNode): Node(editorNode) { +} + +void MapValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *colourSocket = this->getInputSocket(0); + OutputSocket *valueSocket = this->getOutputSocket(0); + TexMapping* storage = (TexMapping*)this->getbNode()->storage; + MapValueOperation *convertProg = new MapValueOperation(); + convertProg->setSettings(storage); + colourSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph); + valueSocket->relinkConnections(convertProg->getOutputSocket(0)); + graph->addOperation(convertProg); +} diff --git a/source/blender/compositor/nodes/COM_MapValueNode.h b/source/blender/compositor/nodes/COM_MapValueNode.h new file mode 100644 index 00000000000..47a6ea6adce --- /dev/null +++ b/source/blender/compositor/nodes/COM_MapValueNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_MapValueNode_h +#define _COM_MapValueNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief MapValueNode + * @ingroup Node + */ +class MapValueNode : public Node { +public: + MapValueNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_MathNode.cpp b/source/blender/compositor/nodes/COM_MathNode.cpp new file mode 100644 index 00000000000..075b90c0f2b --- /dev/null +++ b/source/blender/compositor/nodes/COM_MathNode.cpp @@ -0,0 +1,92 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MathNode.h" +#include "COM_MathBaseOperation.h" +#include "COM_ExecutionSystem.h" + +void MathNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + MathBaseOperation* operation=NULL; + + switch(this->getbNode()->custom1) + { + case 0: /* Add */ + operation = new MathAddOperation(); + break; + case 1: /* Subtract */ + operation = new MathSubtractOperation(); + break; + case 2: /* Multiply */ + operation = new MathMultiplyOperation(); + break; + case 3: /* Divide */ + operation = new MathDivideOperation(); + break; + case 4: /* Sine */ + operation = new MathSineOperation(); + break; + case 5: /* Cosine */ + operation = new MathCosineOperation(); + break; + case 6: /* Tangent */ + operation = new MathTangentOperation(); + break; + case 7: /* Arc-Sine */ + operation = new MathArcSineOperation(); + break; + case 8: /* Arc-Cosine */ + operation = new MathArcCosineOperation(); + break; + case 9: /* Arc-Tangent */ + operation = new MathArcTangentOperation(); + break; + case 10: /* Power */ + operation = new MathPowerOperation(); + break; + case 11: /* Logarithm */ + operation = new MathLogarithmOperation(); + break; + case 12: /* Minimum */ + operation = new MathMinimumOperation(); + break; + case 13: /* Maximum */ + operation = new MathMaximumOperation(); + break; + case 14: /* Round */ + operation = new MathRoundOperation(); + break; + case 15: /* Less Than */ + operation = new MathLessThanOperation(); + break; + case 16: /* Greater Than */ + operation = new MathGreaterThanOperation(); + break; + } + + if (operation != NULL) { + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + graph->addOperation(operation); + } +} diff --git a/source/blender/compositor/nodes/COM_MathNode.h b/source/blender/compositor/nodes/COM_MathNode.h new file mode 100644 index 00000000000..f5e6b5daebe --- /dev/null +++ b/source/blender/compositor/nodes/COM_MathNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_MathNode_h +#define _COM_MathNode_h + +#include "COM_Node.h" + +/** + * @brief MathNode + * @ingroup Node + */ +class MathNode: public Node { +public: + MathNode(bNode* editorNode) :Node(editorNode) {} + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_MixNode.cpp b/source/blender/compositor/nodes/COM_MixNode.cpp new file mode 100644 index 00000000000..1477163d1fc --- /dev/null +++ b/source/blender/compositor/nodes/COM_MixNode.cpp @@ -0,0 +1,131 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MixNode.h" + +#include "COM_MixBlendOperation.h" +#include "COM_MixAddOperation.h" +#include "COM_MixMultiplyOperation.h" +#include "COM_MixBurnOperation.h" +#include "COM_MixColorOperation.h" +#include "COM_MixDarkenOperation.h" +#include "COM_MixDifferenceOperation.h" +#include "COM_MixDivideOperation.h" +#include "COM_MixHueOperation.h" +#include "COM_MixLightenOperation.h" +#include "COM_MixLinearLightOperation.h" +#include "COM_MixOverlayOperation.h" +#include "COM_MixSaturationOperation.h" +#include "COM_MixScreenOperation.h" +#include "COM_MixSoftLightOperation.h" +#include "COM_MixSubtractOperation.h" +#include "COM_MixValueOperation.h" +#include "COM_MixDodgeOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" // the ramp types + + +MixNode::MixNode(bNode *editorNode): Node(editorNode) { +} + + +void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *valueSocket = this->getInputSocket(0); + InputSocket *color1Socket = this->getInputSocket(1); + InputSocket *color2Socket = this->getInputSocket(2); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* editorNode = this->getbNode(); + + MixBaseOperation *convertProg; + + switch (editorNode->custom1) { + case MA_RAMP_ADD: + convertProg = new MixAddOperation(); + break; + case MA_RAMP_MULT: + convertProg = new MixMultiplyOperation(); + break; + case MA_RAMP_LIGHT: + convertProg = new MixLightenOperation(); + break; + case MA_RAMP_BURN: + convertProg = new MixBurnOperation(); + break; + case MA_RAMP_HUE: + convertProg = new MixHueOperation(); + break; + case MA_RAMP_COLOR: + convertProg = new MixColorOperation(); + break; + case MA_RAMP_SOFT: + convertProg = new MixSoftLightOperation(); + break; + case MA_RAMP_SCREEN: + convertProg = new MixScreenOperation(); + break; + case MA_RAMP_LINEAR: + convertProg = new MixLinearLightOperation(); + break; + case MA_RAMP_DIFF: + convertProg = new MixDifferenceOperation(); + break; + case MA_RAMP_SAT: + convertProg = new MixSaturationOperation(); + break; + case MA_RAMP_DIV: + convertProg = new MixDivideOperation(); + break; + case MA_RAMP_SUB: + convertProg = new MixSubtractOperation(); + break; + case MA_RAMP_DARK: + convertProg = new MixDarkenOperation(); + break; + case MA_RAMP_OVERLAY: + convertProg = new MixOverlayOperation(); + break; + case MA_RAMP_VAL: + convertProg = new MixValueOperation(); + break; + case MA_RAMP_DODGE: + convertProg = new MixDodgeOperation(); + break; + + case MA_RAMP_BLEND: + default: + convertProg = new MixBlendOperation(); + break; + } + convertProg->setUseValueAlphaMultiply(this->getbNode()->custom2); + + valueSocket->relinkConnections(convertProg->getInputSocket(0), true, 0, graph); + color1Socket->relinkConnections(convertProg->getInputSocket(1), true, 1, graph); + color2Socket->relinkConnections(convertProg->getInputSocket(2), true, 2, graph); + outputSocket->relinkConnections(convertProg->getOutputSocket(0)); + addPreviewOperation(graph, convertProg->getOutputSocket(0), 5); + + convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode()); + + graph->addOperation(convertProg); +} diff --git a/source/blender/compositor/nodes/COM_MixNode.h b/source/blender/compositor/nodes/COM_MixNode.h new file mode 100644 index 00000000000..4b57bdbc02a --- /dev/null +++ b/source/blender/compositor/nodes/COM_MixNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_MixNode_h +#define _COM_MixNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief MixNode + * @ingroup Node + */ +class MixNode : public Node { +public: + MixNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.cpp b/source/blender/compositor/nodes/COM_MovieClipNode.cpp new file mode 100644 index 00000000000..7d11a06a24d --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieClipNode.cpp @@ -0,0 +1,118 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MovieClipNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_MovieClipOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_ConvertColorProfileOperation.h" + +extern "C" { + #include "DNA_movieclip_types.h" + #include "BKE_movieclip.h" + #include "BKE_tracking.h" +} + +MovieClipNode::MovieClipNode(bNode *editorNode): Node(editorNode) { +} + +void MovieClipNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + OutputSocket *outputMovieClip = this->getOutputSocket(0); + OutputSocket *offsetXMovieClip = this->getOutputSocket(1); + OutputSocket *offsetYMovieClip = this->getOutputSocket(2); + OutputSocket *scaleMovieClip = this->getOutputSocket(3); + OutputSocket *angleMovieClip = this->getOutputSocket(4); + + bNode *editorNode = this->getbNode(); + MovieClip *movieClip = (MovieClip*)editorNode->id; + MovieClipUser *movieClipUser = (MovieClipUser*)editorNode->storage; + + ImBuf * ibuf= NULL; + if (movieClip) { + ibuf = BKE_movieclip_get_ibuf(movieClip, movieClipUser); + } + + // always connect the output image + MovieClipOperation *operation = new MovieClipOperation(); + + if (ibuf && context->isColorManaged() && ibuf->profile == IB_PROFILE_NONE) { + ConvertColorProfileOperation *converter = new ConvertColorProfileOperation(); + converter->setFromColorProfile(IB_PROFILE_LINEAR_RGB); + converter->setToColorProfile(IB_PROFILE_SRGB); + addLink(graph, operation->getOutputSocket(), converter->getInputSocket(0)); + addPreviewOperation(graph, converter->getOutputSocket(), 9); + if (outputMovieClip->isConnected()) { + outputMovieClip->relinkConnections(converter->getOutputSocket()); + } + graph->addOperation(converter); + if (ibuf) { + converter->setPredivided(ibuf->flags & IB_cm_predivide); + } + } else { + addPreviewOperation(graph, operation->getOutputSocket(), 9); + if (outputMovieClip->isConnected()) { + outputMovieClip->relinkConnections(operation->getOutputSocket()); + } + } + operation->setMovieClip(movieClip); + operation->setMovieClipUser(movieClipUser); + operation->setFramenumber(context->getFramenumber()); + graph->addOperation(operation); + + MovieTrackingStabilization *stab= &movieClip->tracking.stabilization; + float loc[2], scale, angle; + loc[0] = 0.0f; + loc[1] = 0.0f; + scale = 1.0f; + angle = 0.0f; + + if (ibuf) { + if(stab->flag&TRACKING_2D_STABILIZATION) { + BKE_tracking_stabilization_data(&movieClip->tracking, context->getFramenumber(), ibuf->x, ibuf->y, loc, &scale, &angle); + } + } + + if (offsetXMovieClip->isConnected()) { + SetValueOperation * operationSetValue = new SetValueOperation(); + operationSetValue->setValue(loc[0]); + offsetXMovieClip->relinkConnections(operationSetValue->getOutputSocket()); + graph->addOperation(operationSetValue); + } + if (offsetYMovieClip->isConnected()) { + SetValueOperation * operationSetValue = new SetValueOperation(); + operationSetValue->setValue(loc[1]); + offsetYMovieClip->relinkConnections(operationSetValue->getOutputSocket()); + graph->addOperation(operationSetValue); + } + if (scaleMovieClip->isConnected()) { + SetValueOperation * operationSetValue = new SetValueOperation(); + operationSetValue->setValue(scale); + scaleMovieClip->relinkConnections(operationSetValue->getOutputSocket()); + graph->addOperation(operationSetValue); + } + if (angleMovieClip->isConnected()) { + SetValueOperation * operationSetValue = new SetValueOperation(); + operationSetValue->setValue(angle); + angleMovieClip->relinkConnections(operationSetValue->getOutputSocket()); + graph->addOperation(operationSetValue); + } +} diff --git a/source/blender/compositor/nodes/COM_MovieClipNode.h b/source/blender/compositor/nodes/COM_MovieClipNode.h new file mode 100644 index 00000000000..883ebe486f8 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieClipNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief MovieClipNode + * @ingroup Node + */ +class MovieClipNode : public Node { + + +public: + MovieClipNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); + +}; diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp new file mode 100644 index 00000000000..4233f313a87 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MovieDistortionNode.h" + +#include "COM_MovieDistortionOperation.h" +#include "COM_ExecutionSystem.h" +#include "DNA_movieclip_types.h" + +MovieDistortionNode::MovieDistortionNode(bNode *editorNode) : Node(editorNode) { +} + +void MovieDistortionNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* bnode = this->getbNode(); + MovieClip * clip = (MovieClip*)bnode->id; + + MovieDistortionOperation * operation = new MovieDistortionOperation(bnode->custom1 == 1); + operation->setMovieClip(clip); + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, system); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + system->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_MovieDistortionNode.h b/source/blender/compositor/nodes/COM_MovieDistortionNode.h new file mode 100644 index 00000000000..28eec5011a2 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MovieDistortionNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_MovieDistortionNode_h_ +#define _COM_MovieDistortionNode_h_ + +#include "COM_Node.h" + +/** + * @brief MovieDistortionNode + * @ingroup Node + */ +class MovieDistortionNode: public Node { +public: + MovieDistortionNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp new file mode 100644 index 00000000000..44accf42f6a --- /dev/null +++ b/source/blender/compositor/nodes/COM_MuteNode.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_MuteNode.h" +#include "COM_SocketConnection.h" +#include "stdio.h" +#include "COM_SetValueOperation.h" +#include "COM_SetVectorOperation.h" +#include "COM_SetColorOperation.h" + +MuteNode::MuteNode(bNode *editorNode): Node(editorNode) { +} + +void MuteNode::reconnect(ExecutionSystem * graph, OutputSocket * output) { + vector<InputSocket*> &inputsockets = this->getInputSockets(); + for (unsigned int index = 0; index < inputsockets.size() ; index ++) { + InputSocket *input = inputsockets[index]; + if (input->getDataType() == output->getDataType()) { + if (input->isConnected()) { + output->relinkConnections(input->getConnection()->getFromSocket(), false); + return; + } + } + } + + NodeOperation * operation; + switch (output->getDataType()) { + case COM_DT_VALUE: + { + SetValueOperation *valueoperation = new SetValueOperation(); + valueoperation->setValue(0.0f); + operation = valueoperation; + break; + } + case COM_DT_VECTOR: + { + SetVectorOperation *vectoroperation = new SetVectorOperation(); + vectoroperation->setX(0.0f); + vectoroperation->setY(0.0f); + vectoroperation->setW(0.0f); + operation = vectoroperation; + break; + } + case COM_DT_COLOR: + { + SetColorOperation *coloroperation = new SetColorOperation(); + coloroperation->setChannel1(0.0f); + coloroperation->setChannel2(0.0f); + coloroperation->setChannel3(0.0f); + coloroperation->setChannel4(0.0f); + operation = coloroperation; + break; + } + } + if (operation) { + output->relinkConnections(operation->getOutputSocket(), false); + graph->addOperation(operation); + } + + output->clearConnections(); +} + +void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + vector<OutputSocket*> &outputsockets = this->getOutputSockets(); + + for (unsigned int index = 0 ; index < outputsockets.size() ; index ++) { + OutputSocket * output = outputsockets[index]; + if (output->isConnected()) { + reconnect(graph, output); + } + } +} diff --git a/source/blender/compositor/nodes/COM_MuteNode.h b/source/blender/compositor/nodes/COM_MuteNode.h new file mode 100644 index 00000000000..c2d1f283c62 --- /dev/null +++ b/source/blender/compositor/nodes/COM_MuteNode.h @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_MuteNode_h_ +#define _COM_MuteNode_h_ + +#include "COM_Node.h" + +/** + * @brief MuteNode + * @ingroup Node + */ +class MuteNode: public Node { +public: + MuteNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +private: + void reconnect(ExecutionSystem* graph, OutputSocket * output); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_NormalNode.cpp b/source/blender/compositor/nodes/COM_NormalNode.cpp new file mode 100644 index 00000000000..b54d8b8aab6 --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalNode.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_NormalNode.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" +#include "COM_DotproductOperation.h" +#include "COM_SetVectorOperation.h" + +NormalNode::NormalNode(bNode* editorNode): Node(editorNode) +{} + +void NormalNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocket = this->getOutputSocket(0); + OutputSocket *outputSocketDotproduct = this->getOutputSocket(1); + bNode* editorNode = this->getbNode(); + + SetVectorOperation * operationSet = new SetVectorOperation(); + bNodeSocket * insock = (bNodeSocket*)editorNode->outputs.first; + bNodeSocketValueVector *dval = (bNodeSocketValueVector*)insock->default_value; + operationSet->setX(dval->value[0]); + operationSet->setY(dval->value[1]); + operationSet->setZ(dval->value[2]); + operationSet->setW(0.0f); + + outputSocket->relinkConnections(operationSet->getOutputSocket(0)); + graph->addOperation(operationSet); + + if (outputSocketDotproduct->isConnected()) { + DotproductOperation *operation = new DotproductOperation(); + outputSocketDotproduct->relinkConnections(operation->getOutputSocket(0)); + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + addLink(graph, operationSet->getOutputSocket(0), operation->getInputSocket(1)); + graph->addOperation(operation); + } +} diff --git a/source/blender/compositor/nodes/COM_NormalNode.h b/source/blender/compositor/nodes/COM_NormalNode.h new file mode 100644 index 00000000000..97a2f4bdd06 --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalNode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef COM_NORMALNODE_H +#define COM_NORMALNODE_H + +#include "COM_Node.h" + +/** + * @brief NormalNode + * @ingroup Node + */ +class NormalNode : public Node +{ +public: + NormalNode(bNode* editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif // COM_NormalNODE_H diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.cpp b/source/blender/compositor/nodes/COM_NormalizeNode.cpp new file mode 100644 index 00000000000..dbe8278af0f --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalizeNode.cpp @@ -0,0 +1,36 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_NormalizeNode.h" +#include "COM_NormalizeOperation.h" +#include "COM_ExecutionSystem.h" + +NormalizeNode::NormalizeNode(bNode *editorNode): Node(editorNode) { +} + +void NormalizeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + NormalizeOperation *operation = new NormalizeOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_NormalizeNode.h b/source/blender/compositor/nodes/COM_NormalizeNode.h new file mode 100644 index 00000000000..b955b52391e --- /dev/null +++ b/source/blender/compositor/nodes/COM_NormalizeNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_NormalizeNode_h_ +#define _COM_NormalizeNode_h_ + +#include "COM_Node.h" + +/** + * @brief NormalizeNode + * @ingroup Node + */ +class NormalizeNode: public Node { +public: + NormalizeNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cpp b/source/blender/compositor/nodes/COM_OutputFileNode.cpp new file mode 100644 index 00000000000..d844861cdd5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Lukas Tönne + */ + +#include "COM_OutputFileNode.h" +#include "COM_OutputFileOperation.h" +#include "COM_ExecutionSystem.h" +#include "BLI_path_util.h" +#include "BKE_utildefines.h" + +OutputFileNode::OutputFileNode(bNode *editorNode): Node(editorNode) { +} + +void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + NodeImageMultiFile* storage = (NodeImageMultiFile*)this->getbNode()->storage; + + if (!context->isRendering()) { + /* XXX TODO as in previous implementation? + * add dummy operations and exit, to prevent file writing on each compo update. + */ + } + + if (storage->format.imtype==R_IMF_IMTYPE_MULTILAYER) { + /* single output operation for the multilayer file */ + OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation( + context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec); + + int num_inputs = getNumberOfInputSockets(); + bool hasConnections = false; + for (int i=0; i < num_inputs; ++i) { + InputSocket *input = getInputSocket(i); + if (input->isConnected()) { + hasConnections = true; + NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage; + + outputOperation->add_layer(sockdata->path, input->getDataType()); + + input->relinkConnections(outputOperation->getInputSocket(i)); + } + } + if (hasConnections) addPreviewOperation(graph, outputOperation->getInputSocket(0), 5); + + graph->addOperation(outputOperation); + } + else { /* single layer format */ + int num_inputs = getNumberOfInputSockets(); + bool previewAdded = false; + for (int i=0; i < num_inputs; ++i) { + InputSocket *input = getInputSocket(i); + if (input->isConnected()) { + NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)input->getbNodeSocket()->storage; + ImageFormatData *format = (sockdata->use_node_format ? &storage->format : &sockdata->format); + char path[FILE_MAX]; + + /* combine file path for the input */ + BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path); + + OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation( + context->getScene(), context->getbNodeTree(), input->getActualDataType(), format, path); + input->relinkConnections(outputOperation->getInputSocket(0)); + graph->addOperation(outputOperation); + if (!previewAdded) { + addPreviewOperation(graph, outputOperation->getInputSocket(0), 5); + previewAdded = true; + } + } + } + } +} + diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.h b/source/blender/compositor/nodes/COM_OutputFileNode.h new file mode 100644 index 00000000000..10cbba7d50f --- /dev/null +++ b/source/blender/compositor/nodes/COM_OutputFileNode.h @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + * Lukas Tönne + */ + +#ifndef _COM_OutputFileNode_h +#define _COM_OutputFileNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief OutputFileNode + * @ingroup Node + */ +class OutputFileNode : public Node { +public: + OutputFileNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp new file mode 100644 index 00000000000..e22c2fd5910 --- /dev/null +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_RenderLayersNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_RenderLayersImageProg.h" +#include "COM_RenderLayersAlphaProg.h" +#include "COM_RenderLayersDepthProg.h" +#include "COM_RenderLayersNormalOperation.h" +#include "COM_RenderLayersSpeedOperation.h" +#include "COM_RenderLayersColorOperation.h" +#include "COM_RenderLayersUVOperation.h" +#include "COM_RenderLayersMistOperation.h" +#include "COM_RenderLayersObjectIndexOperation.h" +#include "COM_RenderLayersDiffuseOperation.h" +#include "COM_RenderLayersSpecularOperation.h" +#include "COM_RenderLayersShadowOperation.h" +#include "COM_RenderLayersAOOperation.h" +#include "COM_RenderLayersEmitOperation.h" +#include "COM_RenderLayersReflectionOperation.h" +#include "COM_RenderLayersRefractionOperation.h" +#include "COM_RenderLayersEnvironmentOperation.h" +#include "COM_RenderLayersIndirectOperation.h" +#include "COM_RenderLayersMaterialIndexOperation.h" +#include "COM_RenderLayersCyclesOperation.h" +#include "COM_TranslateOperation.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_SetValueOperation.h" + +RenderLayersNode::RenderLayersNode(bNode *editorNode): Node(editorNode) { +} + +void RenderLayersNode::testSocketConnection(ExecutionSystem* system, int outputSocketNumber, RenderLayersBaseProg * operation) { + OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber); + Scene* scene = (Scene*)this->getbNode()->id; + short layerId = this->getbNode()->custom1; + + if (outputSocket->isConnected()) { + operation->setScene(scene); + operation->setLayerId(layerId); + outputSocket->relinkConnections(operation->getOutputSocket()); + system->addOperation(operation); + if (outputSocketNumber == 0) { // only do for image socket if connected + addPreviewOperation(system, operation->getOutputSocket(), 9); + } + } else { + if (outputSocketNumber == 0) { + system->addOperation(operation); + operation->setScene(scene); + operation->setLayerId(layerId); + addPreviewOperation(system, operation->getOutputSocket(), 9); + } else { + delete operation; + } + } +} + +void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + testSocketConnection(graph, 0, new RenderLayersColourProg()); + testSocketConnection(graph, 1, new RenderLayersAlphaProg()); + testSocketConnection(graph, 2, new RenderLayersDepthProg()); + testSocketConnection(graph, 3, new RenderLayersNormalOperation()); + testSocketConnection(graph, 4, new RenderLayersUVOperation()); + testSocketConnection(graph, 5, new RenderLayersSpeedOperation()); + testSocketConnection(graph, 6, new RenderLayersColorOperation()); + testSocketConnection(graph, 7, new RenderLayersDiffuseOperation()); + testSocketConnection(graph, 8, new RenderLayersSpecularOperation()); + testSocketConnection(graph, 9, new RenderLayersShadowOperation()); + testSocketConnection(graph, 10, new RenderLayersAOOperation()); + testSocketConnection(graph, 11, new RenderLayersReflectionOperation()); + testSocketConnection(graph, 12, new RenderLayersRefractionOperation()); + testSocketConnection(graph, 13, new RenderLayersIndirectOperation()); + testSocketConnection(graph, 14, new RenderLayersObjectIndexOperation()); + testSocketConnection(graph, 15, new RenderLayersMaterialIndexOperation()); + testSocketConnection(graph, 16, new RenderLayersMistOperation()); + testSocketConnection(graph, 17, new RenderLayersEmitOperation()); + testSocketConnection(graph, 18, new RenderLayersEnvironmentOperation()); + + // cycles passes + testSocketConnection(graph, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT)); + testSocketConnection(graph, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT)); + testSocketConnection(graph, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR)); + testSocketConnection(graph, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT)); + testSocketConnection(graph, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT)); + testSocketConnection(graph, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR)); + testSocketConnection(graph, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT)); + testSocketConnection(graph, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT)); + testSocketConnection(graph, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR)); +} diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.h b/source/blender/compositor/nodes/COM_RenderLayersNode.h new file mode 100644 index 00000000000..285b6f6d007 --- /dev/null +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_RenderLayersBaseProg.h" + +/** + * @brief RenderLayersNode + * @ingroup Node + */ +class RenderLayersNode : public Node { +public: + RenderLayersNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +private: + void testSocketConnection(ExecutionSystem* graph, int outputSocketNumber, RenderLayersBaseProg * operation); +}; diff --git a/source/blender/compositor/nodes/COM_RotateNode.cpp b/source/blender/compositor/nodes/COM_RotateNode.cpp new file mode 100644 index 00000000000..059a62874bb --- /dev/null +++ b/source/blender/compositor/nodes/COM_RotateNode.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_RotateNode.h" + +#include "COM_RotateOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetSamplerOperation.h" + +RotateNode::RotateNode(bNode *editorNode) : Node(editorNode) { +} + +void RotateNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputDegreeSocket = this->getInputSocket(1); + OutputSocket *outputSocket = this->getOutputSocket(0); + RotateOperation *operation = new RotateOperation(); + SetSamplerOperation *sampler = new SetSamplerOperation(); + + switch (this->getbNode()->custom1) { + case 0: + sampler->setSampler(COM_PS_NEAREST); + break ; + case 1: + sampler->setSampler(COM_PS_BILINEAR); + break; + case 2: + sampler->setSampler(COM_PS_BICUBIC); + break; + + } + + addLink(system, sampler->getOutputSocket(), operation->getInputSocket(0)); + + inputSocket->relinkConnections(sampler->getInputSocket(0), true, 0, system); + inputDegreeSocket->relinkConnections(operation->getInputSocket(1), true, 1, system); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + system->addOperation(sampler); + system->addOperation(operation); + +} diff --git a/source/blender/compositor/nodes/COM_RotateNode.h b/source/blender/compositor/nodes/COM_RotateNode.h new file mode 100644 index 00000000000..7e4f7a1a546 --- /dev/null +++ b/source/blender/compositor/nodes/COM_RotateNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_RotateNode_h_ +#define _COM_RotateNode_h_ + +#include "COM_Node.h" + +/** + * @brief RotateNode + * @ingroup Node + */ +class RotateNode: public Node { +public: + RotateNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ScaleNode.cpp b/source/blender/compositor/nodes/COM_ScaleNode.cpp new file mode 100644 index 00000000000..b281ed64d79 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ScaleNode.cpp @@ -0,0 +1,86 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ScaleNode.h" + +#include "COM_ScaleOperation.h" +#include "COM_ExecutionSystem.h" +#include "BKE_node.h" +#include "COM_SetValueOperation.h" + +ScaleNode::ScaleNode(bNode *editorNode) : Node(editorNode) { +} + +void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputXSocket = this->getInputSocket(1); + InputSocket *inputYSocket = this->getInputSocket(2); + OutputSocket *outputSocket = this->getOutputSocket(0); + bNode* bnode = this->getbNode(); + switch (bnode->custom1) { + case CMP_SCALE_RELATIVE: { + ScaleOperation *operation = new ScaleOperation(); + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph); + inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } + break; + case CMP_SCALE_SCENEPERCENT: { + SetValueOperation * scaleFactorOperation = new SetValueOperation(); + scaleFactorOperation->setValue(context->getScene()->r.size/100.0f); + ScaleOperation * operation = new ScaleOperation(); + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1)); + addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(2)); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(scaleFactorOperation); + graph->addOperation(operation); + } + break; + + case CMP_SCALE_RENDERPERCENT: { + const RenderData* data = &context->getScene()->r; + ScaleFixedSizeOperation * operation = new ScaleFixedSizeOperation(); + operation->setNewWidth(data->xsch*data->size/100.0f); + operation->setNewHeight(data->ysch*data->size/100.0f); + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + operation->getInputSocket(0)->getConnection()->setIgnoreResizeCheck(true); + graph->addOperation(operation); + } + break; + + case CMP_SCALE_ABSOLUTE: { + ScaleAbsoluteOperation *operation = new ScaleAbsoluteOperation(); // TODO: what is the use of this one.... perhaps some issues when the ui was updated.... + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph); + inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } + break; + } +} diff --git a/source/blender/compositor/nodes/COM_ScaleNode.h b/source/blender/compositor/nodes/COM_ScaleNode.h new file mode 100644 index 00000000000..b6a1a56d8c9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ScaleNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ScaleNode_h_ +#define _COM_ScaleNode_h_ + +#include "COM_Node.h" + +/** + * @brief ScaleNode + * @ingroup Node + */ +class ScaleNode: public Node { +public: + ScaleNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp new file mode 100644 index 00000000000..922b9c051d5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SeparateHSVANode.h" + +#include "COM_SeparateChannelOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_ConvertRGBToHSVOperation.h" + +SeparateHSVANode::SeparateHSVANode(bNode *editorNode): SeparateRGBANode(editorNode) { +} + +void SeparateHSVANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + ConvertRGBToHSVOperation *operation = new ConvertRGBToHSVOperation(); + InputSocket *inputSocket = this->getInputSocket(0); + if (inputSocket->isConnected()) { + inputSocket->relinkConnections(operation->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), inputSocket); + } + graph->addOperation(operation); + SeparateRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_SeparateHSVANode.h b/source/blender/compositor/nodes/COM_SeparateHSVANode.h new file mode 100644 index 00000000000..9fbd0212509 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateHSVANode.h @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SeparateHSVANode_h +#define _COM_SeparateHSVANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_SeparateRGBANode.h" + +/** + * @brief SeparateHSVANode + * @ingroup Node + */ +class SeparateHSVANode : public SeparateRGBANode { +public: + SeparateHSVANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp new file mode 100644 index 00000000000..08b3c87cbf9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SeparateRGBANode.h" + +#include "COM_SeparateChannelOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "DNA_material_types.h" // the ramp types + + +SeparateRGBANode::SeparateRGBANode(bNode *editorNode): Node(editorNode) { +} + + +void SeparateRGBANode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *imageSocket = this->getInputSocket(0); + OutputSocket *outputRSocket = this->getOutputSocket(0); + OutputSocket *outputGSocket = this->getOutputSocket(1); + OutputSocket *outputBSocket = this->getOutputSocket(2); + OutputSocket *outputASocket = this->getOutputSocket(3); + + if (outputRSocket->isConnected()) { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(0); + imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph); + outputRSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } + if (outputGSocket->isConnected()) { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(1); + imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph); + outputGSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } + if (outputBSocket->isConnected()) { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(2); + imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph); + outputBSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } + if (outputASocket->isConnected()) { + SeparateChannelOperation *operation = new SeparateChannelOperation(); + operation->setChannel(3); + imageSocket->relinkConnections(operation->getInputSocket(0), true, 0, true, graph); + outputASocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } +} diff --git a/source/blender/compositor/nodes/COM_SeparateRGBANode.h b/source/blender/compositor/nodes/COM_SeparateRGBANode.h new file mode 100644 index 00000000000..5fb00600790 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateRGBANode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SeparateRGBANode_h +#define _COM_SeparateRGBANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief SeparateRGBANode + * @ingroup Node + */ +class SeparateRGBANode : public Node { +public: + SeparateRGBANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp new file mode 100644 index 00000000000..854f74cda4c --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.cpp @@ -0,0 +1,44 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_SeparateYCCANode.h" +#include "COM_SeparateChannelOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_ConvertRGBToYCCOperation.h" + +SeparateYCCANode::SeparateYCCANode(bNode *editorNode): SeparateRGBANode(editorNode) { +} + +void SeparateYCCANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + ConvertRGBToYCCOperation *operation = new ConvertRGBToYCCOperation(); + InputSocket *inputSocket = this->getInputSocket(0); + + bNode *node = this->getbNode(); + operation->setMode(node->custom1); + + if (inputSocket->isConnected()) { + inputSocket->relinkConnections(operation->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), inputSocket); + } + graph->addOperation(operation); + SeparateRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_SeparateYCCANode.h b/source/blender/compositor/nodes/COM_SeparateYCCANode.h new file mode 100644 index 00000000000..441eba9bc93 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateYCCANode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_SeparateYCCANode_h +#define _COM_SeparateYCCANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_SeparateRGBANode.h" + +/** + * @brief SeparateYCCANode + * @ingroup Node + */ +class SeparateYCCANode : public SeparateRGBANode { +public: + SeparateYCCANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp new file mode 100644 index 00000000000..db8a8bd2697 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#include "COM_SeparateYUVANode.h" +#include "COM_SeparateChannelOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_ConvertRGBToYUVOperation.h" + +SeparateYUVANode::SeparateYUVANode(bNode *editorNode): SeparateRGBANode(editorNode) { +} + +void SeparateYUVANode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { + ConvertRGBToYUVOperation *operation = new ConvertRGBToYUVOperation(); + InputSocket *inputSocket = this->getInputSocket(0); + if (inputSocket->isConnected()) { + inputSocket->relinkConnections(operation->getInputSocket(0)); + addLink(graph, operation->getOutputSocket(), inputSocket); + } + graph->addOperation(operation); + SeparateRGBANode::convertToOperations(graph, context); +} diff --git a/source/blender/compositor/nodes/COM_SeparateYUVANode.h b/source/blender/compositor/nodes/COM_SeparateYUVANode.h new file mode 100644 index 00000000000..136ce1b4f20 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SeparateYUVANode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Dalai Felinto + */ + +#ifndef _COM_SeparateYUVANode_h +#define _COM_SeparateYUVANode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +#include "COM_SeparateRGBANode.h" + +/** + * @brief SeparateYUVANode + * @ingroup Node + */ +class SeparateYUVANode : public SeparateRGBANode { +public: + SeparateYUVANode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp new file mode 100644 index 00000000000..5dd7dea1fa8 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp @@ -0,0 +1,35 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SetAlphaNode.h" +#include "COM_SetAlphaOperation.h" +#include "COM_ExecutionSystem.h" + +void SetAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + SetAlphaOperation* operation = new SetAlphaOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 0, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.h b/source/blender/compositor/nodes/COM_SetAlphaNode.h new file mode 100644 index 00000000000..c9d819d172e --- /dev/null +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SetAlphaNode_h +#define _COM_SetAlphaNode_h + +#include "COM_Node.h" + +/** + * @brief SetAlphaNode + * @ingroup Node + */ +class SetAlphaNode: public Node { +public: + SetAlphaNode(bNode* editorNode) :Node(editorNode) {} + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp new file mode 100644 index 00000000000..0622ed0ea84 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SocketProxyNode.h" +#include "COM_SocketConnection.h" +#include "COM_SocketProxyOperation.h" +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_SetVectorOperation.h" +#include "COM_SetColorOperation.h" + +SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): Node(editorNode, false) { + DataType dt; + + dt = COM_DT_VALUE; + if (editorInput->type == SOCK_RGBA) dt = COM_DT_COLOR; + if (editorInput->type == SOCK_VECTOR) dt = COM_DT_VECTOR; + this->addInputSocket(dt, (InputSocketResizeMode)editorInput->resizemode, editorInput); + + dt = COM_DT_VALUE; + if (editorOutput->type == SOCK_RGBA) dt = COM_DT_COLOR; + if (editorOutput->type == SOCK_VECTOR) dt = COM_DT_VECTOR; + this->addOutputSocket(dt, editorOutput); +} + +void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + OutputSocket * outputsocket = this->getOutputSocket(0); + if (outputsocket->isConnected()) { + SocketProxyOperation *operation = new SocketProxyOperation(); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0)); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + } +} + +void OutputSocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + OutputSocket * outputsocket = this->getOutputSocket(0); + InputSocket * inputsocket = this->getInputSocket(0); + if (outputsocket->isConnected()) { + switch (outputsocket->getActualDataType()) { + case COM_DT_VALUE: + { + SetValueOperation *operation = new SetValueOperation(); + bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)inputsocket->getbNodeSocket()->default_value; + operation->setValue(dval->value); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + break; + } + case COM_DT_COLOR: + { + SetColorOperation *operation = new SetColorOperation(); + bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA*)inputsocket->getbNodeSocket()->default_value; + operation->setChannels(dval->value); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + break; + } + case COM_DT_VECTOR: + { + SetVectorOperation *operation = new SetVectorOperation(); + bNodeSocketValueVector *dval = (bNodeSocketValueVector*)inputsocket->getbNodeSocket()->default_value; + operation->setVector(dval->value); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); + break; + } + } + } +} diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h new file mode 100644 index 00000000000..eb14f84c46a --- /dev/null +++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h @@ -0,0 +1,46 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SocketProxyNode_h_ +#define _COM_SocketProxyNode_h_ + +#include "COM_Node.h" + +/** + * @brief SocketProxyNode + * @ingroup Node + */ +class SocketProxyNode: public Node { +public: + SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); + + virtual bool isProxyNode() const { return true; } +}; + +class OutputSocketProxyNode: public SocketProxyNode { +public: + OutputSocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput): SocketProxyNode(editorNode, editorInput, editorOutput) {} + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.cpp b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp new file mode 100644 index 00000000000..12204c65112 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.cpp @@ -0,0 +1,49 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SplitViewerNode.h" +#include "BKE_global.h" + +#include "COM_SplitViewerOperation.h" +#include "COM_ExecutionSystem.h" + +SplitViewerNode::SplitViewerNode(bNode *editorNode): Node(editorNode) { +} + +void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *image1Socket = this->getInputSocket(0); + InputSocket *image2Socket = this->getInputSocket(1); + Image* image = (Image*)this->getbNode()->id; + ImageUser * imageUser = (ImageUser*) this->getbNode()->storage; + if (image1Socket->isConnected() && image2Socket->isConnected()) { + SplitViewerOperation *splitViewerOperation = new SplitViewerOperation(); + splitViewerOperation->setImage(image); + splitViewerOperation->setImageUser(imageUser); + splitViewerOperation->setActive(this->getbNode()->flag & NODE_DO_OUTPUT); + splitViewerOperation->setSplitPercentage(this->getbNode()->custom1); + splitViewerOperation->setXSplit(!this->getbNode()->custom2); + image1Socket->relinkConnections(splitViewerOperation->getInputSocket(0), true, 1, graph); + image2Socket->relinkConnections(splitViewerOperation->getInputSocket(1), true, 1, graph); + addPreviewOperation(graph, splitViewerOperation->getInputSocket(0), 0); + graph->addOperation(splitViewerOperation); + } +} diff --git a/source/blender/compositor/nodes/COM_SplitViewerNode.h b/source/blender/compositor/nodes/COM_SplitViewerNode.h new file mode 100644 index 00000000000..e2d7a8c0dc9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SplitViewerNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SplitViewerNode_h +#define _COM_SplitViewerNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief SplitViewerNode + * @ingroup Node + */ +class SplitViewerNode : public Node { +public: + SplitViewerNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp new file mode 100644 index 00000000000..74fde974784 --- /dev/null +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.cpp @@ -0,0 +1,87 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Stabilize2dNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TranslateOperation.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_MovieClipAttributeOperation.h" + +extern "C" { + #include "DNA_movieclip_types.h" + #include "BKE_tracking.h" +} + +Stabilize2dNode::Stabilize2dNode(bNode *editorNode): Node(editorNode) { +} + +void Stabilize2dNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *imageInput = this->getInputSocket(0); + MovieClip *clip= (MovieClip *)getbNode()->id; + + ScaleOperation * scaleOperation = new ScaleOperation(); + RotateOperation * rotateOperation = new RotateOperation(); + TranslateOperation * translateOperation = new TranslateOperation(); + MovieClipAttributeOperation *scaleAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *angleAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *xAttribute = new MovieClipAttributeOperation(); + MovieClipAttributeOperation *yAttribute = new MovieClipAttributeOperation(); + + scaleAttribute->setAttribute(MCA_SCALE); + scaleAttribute->setFramenumber(context->getFramenumber()); + scaleAttribute->setMovieClip(clip); + + angleAttribute->setAttribute(MCA_ANGLE); + angleAttribute->setFramenumber(context->getFramenumber()); + angleAttribute->setMovieClip(clip); + + xAttribute->setAttribute(MCA_X); + xAttribute->setFramenumber(context->getFramenumber()); + xAttribute->setMovieClip(clip); + + yAttribute->setAttribute(MCA_Y); + yAttribute->setFramenumber(context->getFramenumber()); + yAttribute->setMovieClip(clip); + + imageInput->relinkConnections(scaleOperation->getInputSocket(0), true, 0, graph); + addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(1)); + addLink(graph, scaleAttribute->getOutputSocket(), scaleOperation->getInputSocket(2)); + + addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); + addLink(graph, angleAttribute->getOutputSocket(), rotateOperation->getInputSocket(1)); + rotateOperation->setDoDegree2RadConversion(false); + + addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); + addLink(graph, xAttribute->getOutputSocket(), translateOperation->getInputSocket(1)); + addLink(graph, yAttribute->getOutputSocket(), translateOperation->getInputSocket(2)); + + this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket()); + + graph->addOperation(scaleAttribute); + graph->addOperation(angleAttribute); + graph->addOperation(xAttribute); + graph->addOperation(yAttribute); + graph->addOperation(scaleOperation); + graph->addOperation(translateOperation); + graph->addOperation(rotateOperation); +} diff --git a/source/blender/compositor/nodes/COM_Stabilize2dNode.h b/source/blender/compositor/nodes/COM_Stabilize2dNode.h new file mode 100644 index 00000000000..613bb97b994 --- /dev/null +++ b/source/blender/compositor/nodes/COM_Stabilize2dNode.h @@ -0,0 +1,34 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief Stabilize2dNode + * @ingroup Node + */ +class Stabilize2dNode : public Node { +public: + Stabilize2dNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp new file mode 100644 index 00000000000..1b15ae0e890 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_SwitchNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_SocketProxyOperation.h" + +SwitchNode::SwitchNode(bNode *editorNode): Node(editorNode) { +} + + +void SwitchNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + SocketProxyOperation * operation = new SocketProxyOperation(); + int switchFrame = this->getbNode()->custom1; + + if (!switchFrame) { + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + } else { + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(0), true, 1, graph); + } + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_SwitchNode.h b/source/blender/compositor/nodes/COM_SwitchNode.h new file mode 100644 index 00000000000..da93af42489 --- /dev/null +++ b/source/blender/compositor/nodes/COM_SwitchNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_SwitchNode_h +#define _COM_SwitchNode_h + +#include "COM_Node.h" +#include "COM_NodeOperation.h" +#include "DNA_node_types.h" +/** + * @brief SwitchNode + * @ingroup Node + */ +class SwitchNode : public Node { +public: + SwitchNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_TextureNode.cpp b/source/blender/compositor/nodes/COM_TextureNode.cpp new file mode 100644 index 00000000000..ac78c1afd7d --- /dev/null +++ b/source/blender/compositor/nodes/COM_TextureNode.cpp @@ -0,0 +1,49 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_TextureNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TextureOperation.h" + +TextureNode::TextureNode(bNode *editorNode): Node(editorNode) { +} + +void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + bNode* editorNode = this->getbNode(); + Tex* texture = (Tex*)editorNode->id; + TextureOperation* operation = new TextureOperation(); + this->getOutputSocket(1)->relinkConnections(operation->getOutputSocket()); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system); + operation->setTexture(texture); + system->addOperation(operation); + addPreviewOperation(system, operation->getOutputSocket(), 9); + + if (this->getOutputSocket(0)->isConnected()) { + TextureAlphaOperation* alphaOperation = new TextureAlphaOperation(); + this->getOutputSocket(0)->relinkConnections(alphaOperation->getOutputSocket()); + addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0)); + addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1)); + alphaOperation->setTexture(texture); + system->addOperation(alphaOperation); + } +} diff --git a/source/blender/compositor/nodes/COM_TextureNode.h b/source/blender/compositor/nodes/COM_TextureNode.h new file mode 100644 index 00000000000..493c94ddb19 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TextureNode.h @@ -0,0 +1,34 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief TextureNode + * @ingroup Node + */ +class TextureNode : public Node { +public: + TextureNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; diff --git a/source/blender/compositor/nodes/COM_TimeNode.cpp b/source/blender/compositor/nodes/COM_TimeNode.cpp new file mode 100644 index 00000000000..3e2c750d3aa --- /dev/null +++ b/source/blender/compositor/nodes/COM_TimeNode.cpp @@ -0,0 +1,55 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_TimeNode.h" +#include "DNA_scene_types.h" +#include "COM_SetValueOperation.h" +#include "COM_ExecutionSystem.h" +extern "C" { + #include "BKE_colortools.h" +} +#include "BLI_utildefines.h" + +TimeNode::TimeNode(bNode *editorNode): Node(editorNode) { +} + +void TimeNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + SetValueOperation *operation = new SetValueOperation(); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + bNode* node = this->getbNode(); + + /* stack order output: fac */ + float fac= 0.0f; + const int framenumber = context->getFramenumber(); + + if (framenumber < node->custom1) { + fac = 0.0f; + } else if (framenumber > node->custom2) { + fac = 1.0f; + } else if(node->custom1 < node->custom2) { + fac= (context->getFramenumber() - node->custom1)/(float)(node->custom2-node->custom1); + } + + fac= curvemapping_evaluateF((CurveMapping*)node->storage, 0, fac); + operation->setValue(CLAMPIS(fac, 0.0f, 1.0f)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_TimeNode.h b/source/blender/compositor/nodes/COM_TimeNode.h new file mode 100644 index 00000000000..25134db8528 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TimeNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_TimeNode_h_ +#define _COM_TimeNode_h_ + +#include "COM_Node.h" + +/** + * @brief TimeNode + * @ingroup Node + */ +class TimeNode: public Node { +public: + TimeNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_TonemapNode.cpp b/source/blender/compositor/nodes/COM_TonemapNode.cpp new file mode 100644 index 00000000000..a610146a495 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TonemapNode.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_TonemapNode.h" +#include "DNA_scene_types.h" +#include "COM_TonemapOperation.h" +#include "COM_ExecutionSystem.h" + +TonemapNode::TonemapNode(bNode *editorNode): Node(editorNode) { +} + +void TonemapNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + NodeTonemap* data = (NodeTonemap*)this->getbNode()->storage; + TonemapOperation *operation = data->type==1?new PhotoreceptorTonemapOperation():new TonemapOperation(); + + operation->setData(data); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0)); + system->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_TonemapNode.h b/source/blender/compositor/nodes/COM_TonemapNode.h new file mode 100644 index 00000000000..2140d7deb6a --- /dev/null +++ b/source/blender/compositor/nodes/COM_TonemapNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_TonemapNode_h_ +#define _COM_TonemapNode_h_ + +#include "COM_Node.h" + +/** + * @brief TonemapNode + * @ingroup Node + */ +class TonemapNode: public Node { +public: + TonemapNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_TransformNode.cpp b/source/blender/compositor/nodes/COM_TransformNode.cpp new file mode 100644 index 00000000000..9b6d5ec35c5 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TransformNode.cpp @@ -0,0 +1,77 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_TransformNode.h" +#include "COM_ExecutionSystem.h" +#include "COM_TranslateOperation.h" +#include "COM_RotateOperation.h" +#include "COM_ScaleOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_SetSamplerOperation.h" + +TransformNode::TransformNode(bNode *editorNode): Node(editorNode) { +} + +void TransformNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *imageInput = this->getInputSocket(0); + InputSocket *xInput = this->getInputSocket(1); + InputSocket *yInput = this->getInputSocket(2); + InputSocket *angleInput = this->getInputSocket(3); + InputSocket *scaleInput = this->getInputSocket(4); + + ScaleOperation * scaleOperation = new ScaleOperation(); + RotateOperation * rotateOperation = new RotateOperation(); + TranslateOperation * translateOperation = new TranslateOperation(); + SetSamplerOperation *sampler = new SetSamplerOperation(); + + switch (this->getbNode()->custom1) { + case 0: + sampler->setSampler(COM_PS_NEAREST); + break ; + case 1: + sampler->setSampler(COM_PS_BILINEAR); + break; + case 2: + sampler->setSampler(COM_PS_BICUBIC); + break; + } + + imageInput->relinkConnections(sampler->getInputSocket(0), true, 0, graph); + addLink(graph, sampler->getOutputSocket(), scaleOperation->getInputSocket(0)); + scaleInput->relinkConnections(scaleOperation->getInputSocket(1), true, 4, graph); + addLink(graph, scaleOperation->getInputSocket(1)->getConnection()->getFromSocket(), scaleOperation->getInputSocket(2)); // xscale = yscale + + addLink(graph, scaleOperation->getOutputSocket(), rotateOperation->getInputSocket(0)); + rotateOperation->setDoDegree2RadConversion(false); + angleInput->relinkConnections(rotateOperation->getInputSocket(1), true, 3, graph); + + addLink(graph, rotateOperation->getOutputSocket(), translateOperation->getInputSocket(0)); + xInput->relinkConnections(translateOperation->getInputSocket(1), true, 1, graph); + yInput->relinkConnections(translateOperation->getInputSocket(2), true, 2, graph); + + this->getOutputSocket()->relinkConnections(translateOperation->getOutputSocket()); + + graph->addOperation(sampler); + graph->addOperation(scaleOperation); + graph->addOperation(rotateOperation); + graph->addOperation(translateOperation); +} diff --git a/source/blender/compositor/nodes/COM_TransformNode.h b/source/blender/compositor/nodes/COM_TransformNode.h new file mode 100644 index 00000000000..bcb71ba8e5d --- /dev/null +++ b/source/blender/compositor/nodes/COM_TransformNode.h @@ -0,0 +1,34 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_Node.h" +#include "DNA_node_types.h" + +/** + * @brief TransformNode + * @ingroup Node + */ +class TransformNode : public Node { +public: + TransformNode(bNode* editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; diff --git a/source/blender/compositor/nodes/COM_TranslateNode.cpp b/source/blender/compositor/nodes/COM_TranslateNode.cpp new file mode 100644 index 00000000000..4dfa901610c --- /dev/null +++ b/source/blender/compositor/nodes/COM_TranslateNode.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_TranslateNode.h" + +#include "COM_TranslateOperation.h" +#include "COM_ExecutionSystem.h" + +TranslateNode::TranslateNode(bNode *editorNode) : Node(editorNode) { +} + +void TranslateNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *inputSocket = this->getInputSocket(0); + InputSocket *inputXSocket = this->getInputSocket(1); + InputSocket *inputYSocket = this->getInputSocket(2); + OutputSocket *outputSocket = this->getOutputSocket(0); + TranslateOperation *operation = new TranslateOperation(); + + inputSocket->relinkConnections(operation->getInputSocket(0), true, 0, graph); + inputXSocket->relinkConnections(operation->getInputSocket(1), true, 1, graph); + inputYSocket->relinkConnections(operation->getInputSocket(2), true, 2, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_TranslateNode.h b/source/blender/compositor/nodes/COM_TranslateNode.h new file mode 100644 index 00000000000..8f7558ea468 --- /dev/null +++ b/source/blender/compositor/nodes/COM_TranslateNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_TranslateNode_h_ +#define _COM_TranslateNode_h_ + +#include "COM_Node.h" + +/** + * @brief TranslateNode + * @ingroup Node + */ +class TranslateNode: public Node { +public: + TranslateNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ValueNode.cpp b/source/blender/compositor/nodes/COM_ValueNode.cpp new file mode 100644 index 00000000000..0b40872bed4 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ValueNode.cpp @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ValueNode.h" +#include "DNA_scene_types.h" +#include "COM_SetValueOperation.h" +#include "COM_ExecutionSystem.h" + +ValueNode::ValueNode(bNode *editorNode): Node(editorNode) { +} + +void ValueNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + SetValueOperation *operation = new SetValueOperation(); + bNodeSocket* socket = this->getEditorOutputSocket(0); + bNodeSocketValueFloat *dval = (bNodeSocketValueFloat*)socket->default_value; + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + operation->setValue(dval->value); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_ValueNode.h b/source/blender/compositor/nodes/COM_ValueNode.h new file mode 100644 index 00000000000..f0322a9704c --- /dev/null +++ b/source/blender/compositor/nodes/COM_ValueNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ValueNode_h_ +#define _COM_ValueNode_h_ + +#include "COM_Node.h" + +/** + * @brief ValueNode + * @ingroup Node + */ +class ValueNode: public Node { +public: + ValueNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp new file mode 100644 index 00000000000..2063f21c785 --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_VectorBlurNode.h" +#include "DNA_node_types.h" +#include "COM_FogGlowImageOperation.h" +#include "COM_BokehBlurOperation.h" +#include "COM_VectorBlurOperation.h" +#include "COM_SetValueOperation.h" +#include "COM_MixBlendOperation.h" + +VectorBlurNode::VectorBlurNode(bNode *editorNode): Node(editorNode) { +} + +void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext * context) { + bNode* node = this->getbNode(); + NodeBlurData* vectorBlurSettings = (NodeBlurData*)node->storage; + VectorBlurOperation *operation = new VectorBlurOperation(); + operation->setVectorBlurSettings(vectorBlurSettings); + operation->setQuality(context->getQuality()); + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system); + this->getOutputSocket()->relinkConnections(operation->getOutputSocket()); + system->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.h b/source/blender/compositor/nodes/COM_VectorBlurNode.h new file mode 100644 index 00000000000..54449bde1d3 --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorBlurNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_VectorBlurNode_h_ +#define _COM_VectorBlurNode_h_ + +#include "COM_Node.h" + +/** + * @brief VectorBlurNode + * @ingroup Node + */ +class VectorBlurNode: public Node { +public: + VectorBlurNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.cpp b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp new file mode 100644 index 00000000000..c62906a82a6 --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorCurveNode.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_VectorCurveNode.h" +#include "DNA_scene_types.h" +#include "COM_VectorCurveOperation.h" +#include "COM_ExecutionSystem.h" + +VectorCurveNode::VectorCurveNode(bNode *editorNode): Node(editorNode) { +} + +void VectorCurveNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + VectorCurveOperation *operation = new VectorCurveOperation(); + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, graph); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + + operation->setCurveMapping((CurveMapping*)this->getbNode()->storage); + + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_VectorCurveNode.h b/source/blender/compositor/nodes/COM_VectorCurveNode.h new file mode 100644 index 00000000000..e18dac54c2c --- /dev/null +++ b/source/blender/compositor/nodes/COM_VectorCurveNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_VectorCurveNode_h_ +#define _COM_VectorCurveNode_h_ + +#include "COM_Node.h" + +/** + * @brief VectorCurveNode + * @ingroup Node + */ +class VectorCurveNode: public Node { +public: + VectorCurveNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp new file mode 100644 index 00000000000..b5b15b2ba70 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ViewLevelsNode.h" +#include "DNA_scene_types.h" +#include "COM_ExecutionSystem.h" +#include "COM_CalculateMeanOperation.h" +#include "COM_CalculateStandardDeviationOperation.h" + +ViewLevelsNode::ViewLevelsNode(bNode *editorNode): Node(editorNode) { +} +void ViewLevelsNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket * input = this->getInputSocket(0); + bool firstOperationConnected = false; + if (input->isConnected()) { + OutputSocket* inputSocket= input->getConnection()->getFromSocket(); + // add preview to inputSocket; + + OutputSocket * socket = this->getOutputSocket(0); + if (socket->isConnected()) { + // calculate mean operation + CalculateMeanOperation * operation = new CalculateMeanOperation(); + input->relinkConnections(operation->getInputSocket(0), true, 0, graph); + firstOperationConnected = true; + operation->setSetting(this->getbNode()->custom1); + socket->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); + } + + socket = this->getOutputSocket(1); + if (socket->isConnected()) { + // calculate standard deviation operation + CalculateStandardDeviationOperation * operation = new CalculateStandardDeviationOperation(); + if (firstOperationConnected) { + addLink(graph, inputSocket, operation->getInputSocket(0)); + }else{ + input->relinkConnections(operation->getInputSocket(0), true, 0, graph); + } + operation->setSetting(this->getbNode()->custom1); + socket->relinkConnections(operation->getOutputSocket()); + graph->addOperation(operation); + } + } +} + diff --git a/source/blender/compositor/nodes/COM_ViewLevelsNode.h b/source/blender/compositor/nodes/COM_ViewLevelsNode.h new file mode 100644 index 00000000000..9d6b764a2a9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewLevelsNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ViewLevelsNode_h_ +#define _COM_ViewLevelsNode_h_ + +#include "COM_Node.h" + +/** + * @brief ViewLevelsNode + * @ingroup Node + */ +class ViewLevelsNode: public Node { +public: + ViewLevelsNode(bNode *editorNode); + void convertToOperations(ExecutionSystem* graph, CompositorContext * context); +}; + +#endif diff --git a/source/blender/compositor/nodes/COM_ViewerNode.cpp b/source/blender/compositor/nodes/COM_ViewerNode.cpp new file mode 100644 index 00000000000..0148fac47f9 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewerNode.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ViewerNode.h" +#include "BKE_global.h" + +#include "COM_ViewerOperation.h" +#include "COM_ExecutionSystem.h" + +ViewerNode::ViewerNode(bNode *editorNode): Node(editorNode) { +} + +void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) { + InputSocket *imageSocket = this->getInputSocket(0); + InputSocket *alphaSocket = this->getInputSocket(1); + Image* image = (Image*)this->getbNode()->id; + ImageUser * imageUser = (ImageUser*) this->getbNode()->storage; + if (imageSocket->isConnected()) { + bNode* editorNode = this->getbNode(); + ViewerOperation *viewerOperation = new ViewerOperation(); + viewerOperation->setColorManagement( context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT); + viewerOperation->setColorPredivide( context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); + viewerOperation->setbNodeTree(context->getbNodeTree()); + viewerOperation->setImage(image); + viewerOperation->setImageUser(imageUser); + viewerOperation->setActive(editorNode->flag & NODE_DO_OUTPUT); + viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1); + viewerOperation->setCenterX(editorNode->custom3); + viewerOperation->setCenterY(editorNode->custom4); + imageSocket->relinkConnections(viewerOperation->getInputSocket(0), true, 0, graph); + alphaSocket->relinkConnections(viewerOperation->getInputSocket(1)); + graph->addOperation(viewerOperation); + addPreviewOperation(graph, viewerOperation->getInputSocket(0), 0); + } +} diff --git a/source/blender/compositor/nodes/COM_ViewerNode.h b/source/blender/compositor/nodes/COM_ViewerNode.h new file mode 100644 index 00000000000..59371f04e87 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ViewerNode.h @@ -0,0 +1,37 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ViewerNode_h +#define _COM_ViewerNode_h + +#include "COM_Node.h" +#include "DNA_node_types.h" +/** + * @brief ViewerNode + * @ingroup Node + */ +class ViewerNode : public Node { +public: + ViewerNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; +#endif diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.cpp b/source/blender/compositor/nodes/COM_ZCombineNode.cpp new file mode 100644 index 00000000000..be7b6ebdc45 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ZCombineNode.cpp @@ -0,0 +1,64 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_ZCombineNode.h" + +#include "COM_ZCombineOperation.h" + +#include "COM_ExecutionSystem.h" +#include "COM_SetValueOperation.h" +#include "COM_MathBaseOperation.h" + +#include "DNA_material_types.h" // the ramp types + +void ZCombineNode::convertToOperations(ExecutionSystem* system, CompositorContext * context) { + if (this->getOutputSocket(0)->isConnected()) { + ZCombineOperation * operation = NULL; + if (this->getbNode()->custom1) { + operation = new ZCombineAlphaOperation(); + } else { + operation = new ZCombineOperation(); + } + + this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), true, 0, system); + this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), true, 1, system); + this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), true, 2, system); + this->getInputSocket(3)->relinkConnections(operation->getInputSocket(3), true, 3, system); + this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); + system->addOperation(operation); + if (this->getOutputSocket(1)->isConnected()) { + MathMinimumOperation * zoperation = new MathMinimumOperation(); + addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), zoperation->getInputSocket(0)); + addLink(system, operation->getInputSocket(3)->getConnection()->getFromSocket(), zoperation->getInputSocket(1)); + this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); + system->addOperation(zoperation); + } + } else { + if (this->getOutputSocket(1)->isConnected()) { + MathMinimumOperation * zoperation = new MathMinimumOperation(); + this->getInputSocket(1)->relinkConnections(zoperation->getInputSocket(0), true, 1, system); + this->getInputSocket(3)->relinkConnections(zoperation->getInputSocket(1), true, 3, system); + this->getOutputSocket(1)->relinkConnections(zoperation->getOutputSocket()); + system->addOperation(zoperation); + } + } +} diff --git a/source/blender/compositor/nodes/COM_ZCombineNode.h b/source/blender/compositor/nodes/COM_ZCombineNode.h new file mode 100644 index 00000000000..0faf7df8725 --- /dev/null +++ b/source/blender/compositor/nodes/COM_ZCombineNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_ZCombineNode_h +#define _COM_ZCombineNode_h + +#include "COM_Node.h" + +/** + * @brief ZCombineNode + * @ingroup Node + */ +class ZCombineNode: public Node { +public: + ZCombineNode(bNode* editorNode) :Node(editorNode) {} + void convertToOperations(ExecutionSystem *graph, CompositorContext * context); +}; + +#endif |