[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44336] branches/tile/source/blender/ compositor: TileBranch

Jeroen Bakker j.bakker at atmind.nl
Wed Feb 22 19:57:03 CET 2012


Revision: 44336
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44336
Author:   jbakker
Date:     2012-02-22 18:56:57 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
TileBranch
 * Added the MapValue node

 - At Mind -

Modified Paths:
--------------
    branches/tile/source/blender/compositor/CMakeLists.txt
    branches/tile/source/blender/compositor/intern/COM_Converter.cpp

Added Paths:
-----------
    branches/tile/source/blender/compositor/nodes/COM_MapValueNode.cpp
    branches/tile/source/blender/compositor/nodes/COM_MapValueNode.h
    branches/tile/source/blender/compositor/operations/COM_MapValueOperation.cpp
    branches/tile/source/blender/compositor/operations/COM_MapValueOperation.h

Modified: branches/tile/source/blender/compositor/CMakeLists.txt
===================================================================
--- branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-22 16:52:06 UTC (rev 44335)
+++ branches/tile/source/blender/compositor/CMakeLists.txt	2012-02-22 18:56:57 UTC (rev 44336)
@@ -251,6 +251,8 @@
 	nodes/COM_NormalizeNode.h
 	nodes/COM_MathNode.cpp
 	nodes/COM_MathNode.h
+	nodes/COM_MapValueNode.cpp
+	nodes/COM_MapValueNode.h
 
 	operations/COM_NormalizeOperation.cpp
 	operations/COM_NormalizeOperation.h
@@ -489,6 +491,8 @@
 		operations/COM_InvertOperation.h
 	operations/COM_SetAlphaOperation.cpp
 	operations/COM_SetAlphaOperation.h
+	operations/COM_MapValueOperation.cpp
+	operations/COM_MapValueOperation.h
 
 # Distort operation
 		operations/COM_TranslateOperation.h

Modified: branches/tile/source/blender/compositor/intern/COM_Converter.cpp
===================================================================
--- branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-22 16:52:06 UTC (rev 44335)
+++ branches/tile/source/blender/compositor/intern/COM_Converter.cpp	2012-02-22 18:56:57 UTC (rev 44336)
@@ -104,6 +104,7 @@
 #include "COM_MovieClipNode.h"
 #include "COM_ColorSpillNode.h"
 #include "COM_OutputFileNode.h"
+#include "COM_MapValueNode.h"
 
 Node* Converter::convert(bNode *bNode) {
 	Node * node;
@@ -316,8 +317,10 @@
 	case CMP_NODE_OUTPUT_FILE:
 		node = new OutputFileNode(bNode);
 		break;
+	case CMP_NODE_MAP_VALUE:
+		node = new MapValueNode(bNode);
+		break;
 	/* not inplemented yet */
-	case CMP_NODE_MAP_VALUE:
 	case CMP_NODE_VECBLUR:
 	case CMP_NODE_DOUBLEEDGEMASK:
 	case CMP_NODE_DEFOCUS:

Added: branches/tile/source/blender/compositor/nodes/COM_MapValueNode.cpp
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_MapValueNode.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_MapValueNode.cpp	2012-02-22 18:56:57 UTC (rev 44336)
@@ -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_MapValueNode.h"
+
+#include "COM_MapValueOperation.h"
+#include "COM_ExecutionSystem.h"
+
+MapValueNode::MapValueNode(bNode *editorNode): Node(editorNode) {
+//    this->addInputSocket(COM_DT_COLOR);
+//    this->addOutputSocket(COM_DT_VALUE);
+}
+
+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);
+}

Added: branches/tile/source/blender/compositor/nodes/COM_MapValueNode.h
===================================================================
--- branches/tile/source/blender/compositor/nodes/COM_MapValueNode.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/nodes/COM_MapValueNode.h	2012-02-22 18:56:57 UTC (rev 44336)
@@ -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

Added: branches/tile/source/blender/compositor/operations/COM_MapValueOperation.cpp
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_MapValueOperation.cpp	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_MapValueOperation.cpp	2012-02-22 18:56:57 UTC (rev 44336)
@@ -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_MapValueOperation.h"
+
+MapValueOperation::MapValueOperation(): NodeOperation() {
+    this->addInputSocket(COM_DT_VALUE);
+    this->addOutputSocket(COM_DT_VALUE);
+    this->inputOperation = NULL;
+}
+
+void MapValueOperation::initExecution() {
+	this->inputOperation = this->getInputSocketReader(0);
+}
+
+void MapValueOperation::executePixel(float* outputValue, float x, float y, MemoryBuffer *inputBuffers[]) {
+	float src[4];
+	inputOperation->read(src, x, y, inputBuffers);
+	TexMapping *texmap= this->settings;
+	float value = (src[0] + texmap->loc[0])*texmap->size[0];
+	if(texmap->flag & TEXMAP_CLIP_MIN)
+		if(value<texmap->min[0])
+			value= texmap->min[0];
+	if(texmap->flag & TEXMAP_CLIP_MAX)
+		if(value>texmap->max[0])
+			value= texmap->max[0];
+	
+	outputValue[0] = value;
+}
+
+void MapValueOperation::deinitExecution() {
+	this->inputOperation = NULL;
+}

Added: branches/tile/source/blender/compositor/operations/COM_MapValueOperation.h
===================================================================
--- branches/tile/source/blender/compositor/operations/COM_MapValueOperation.h	                        (rev 0)
+++ branches/tile/source/blender/compositor/operations/COM_MapValueOperation.h	2012-02-22 18:56:57 UTC (rev 44336)
@@ -0,0 +1,66 @@
+/*
+ * 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_MapValueOperation_h
+#define _COM_MapValueOperation_h
+#include "COM_NodeOperation.h"
+#include "DNA_texture_types.h"
+
+/**
+  * this program converts an input colour to an output value.
+  * it assumes we are in sRGB colour space.
+  */
+class MapValueOperation : public NodeOperation {
+private:
+    /**
+      * Cached reference to the inputProgram
+      */
+	SocketReader * inputOperation;
+	TexMapping * settings;
+public:
+    /**
+      * Default constructor
+      */
+    MapValueOperation();
+
+    /**
+      * the inner loop of this program
+      */
+	void executePixel(float* color, float x, float y, MemoryBuffer *inputBuffers[]);
+
+    /**
+      * Initialize the execution
+      */
+    void initExecution();
+
+    /**
+      * Deinitialize the execution
+      */
+    void deinitExecution();
+	
+	/**
+	  * @brief set the TexMapping settings
+	  */
+	void setSettings(TexMapping* settings) {this->settings = settings;}
+
+};
+#endif




More information about the Bf-blender-cvs mailing list