[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36882] branches/soc-2011-oregano: Initial commit with NodeLogic code from old nodelogic branch
Benoit Bolsee
benoit.bolsee at online.be
Tue May 24 22:56:49 CEST 2011
Revision: 36882
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36882
Author: ben2610
Date: 2011-05-24 20:56:48 +0000 (Tue, 24 May 2011)
Log Message:
-----------
Initial commit with NodeLogic code from old nodelogic branch
Modified Paths:
--------------
branches/soc-2011-oregano/source/blender/windowmanager/CMakeLists.txt
branches/soc-2011-oregano/source/blender/windowmanager/SConscript
branches/soc-2011-oregano/source/blender/windowmanager/intern/wm_init_exit.c
branches/soc-2011-oregano/source/creator/CMakeLists.txt
branches/soc-2011-oregano/source/gameengine/CMakeLists.txt
branches/soc-2011-oregano/source/gameengine/SConscript
Added Paths:
-----------
branches/soc-2011-oregano/release/scripts/modules/NodeLogic/
branches/soc-2011-oregano/release/scripts/modules/NodeLogic/__init__.py
branches/soc-2011-oregano/release/scripts/modules/NodeLogic/types.py
branches/soc-2011-oregano/release/scripts/nodes/
branches/soc-2011-oregano/release/scripts/nodes/samplenode.py
branches/soc-2011-oregano/source/gameengine/NodeLogic/
branches/soc-2011-oregano/source/gameengine/NodeLogic/CMakeLists.txt
branches/soc-2011-oregano/source/gameengine/NodeLogic/Makefile
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_DList.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_ILinkData.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_INode.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_INodePin.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_IQueueItem.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Node.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_Node.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeEngine.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeEngine.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeGraph.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeGraph.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeLink.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeLink.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeLogic.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodeLogic.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodePin.cpp
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodePin.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_NodePushInputPin.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/NL_QList.h
branches/soc-2011-oregano/source/gameengine/NodeLogic/SConscript
Added: branches/soc-2011-oregano/release/scripts/modules/NodeLogic/__init__.py
===================================================================
--- branches/soc-2011-oregano/release/scripts/modules/NodeLogic/__init__.py (rev 0)
+++ branches/soc-2011-oregano/release/scripts/modules/NodeLogic/__init__.py 2011-05-24 20:56:48 UTC (rev 36882)
@@ -0,0 +1,48 @@
+# bring all the builtin functions in NodeLogic
+from _NodeLogic import *
+# type database for GUI
+from NodeLogic import types
+
+# load nodes
+from bpy import utils
+import sys
+DEBUG = ("-d" in sys.argv)
+
+def load_nodes(reload_nodes=False):
+ import os
+ import traceback
+ import time
+ t_main = time.time()
+
+ def test_import(module_name):
+ try:
+ t = time.time()
+ ret= __import__(module_name)
+ if DEBUG:
+ print("time %s %.4f" % (module_name, time.time() - t))
+ return ret
+ except:
+ traceback.print_exc()
+ return None
+
+
+ for base_path in utils.script_paths():
+ for path_subdir in ("nodes",):
+ path = os.path.join(base_path, path_subdir)
+ if os.path.isdir(path):
+ sys.path.insert(0, path)
+ for f in sorted(os.listdir(path)):
+ if f.endswith(".py"):
+ # python module
+ mod = test_import(f[0:-3])
+ elif "." not in f:
+ # python package
+ mod = test_import(f)
+ else:
+ mod = None
+
+ if reload_nodes and mod:
+ print("Reloading:", mod)
+ reload(mod)
+
+load_nodes()
Property changes on: branches/soc-2011-oregano/release/scripts/modules/NodeLogic/__init__.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/soc-2011-oregano/release/scripts/modules/NodeLogic/types.py
===================================================================
--- branches/soc-2011-oregano/release/scripts/modules/NodeLogic/types.py (rev 0)
+++ branches/soc-2011-oregano/release/scripts/modules/NodeLogic/types.py 2011-05-24 20:56:48 UTC (rev 36882)
@@ -0,0 +1,29 @@
+# define data types for pins.
+# These are just placeholders, only the name is used in the UI to match
+# The poll function is used by the UI to determine which data types are compatible
+import _NodeLogic as nl
+
+class Int(nl.datatype):
+ @staticmethod
+ def poll(other):
+ return other is Float or other is Int
+
+class Float(nl.datatype):
+ @staticmethod
+ def poll(other):
+ return other is Float or other is Int
+
+class Pulse(nl.datatype):
+ @staticmethod
+ def poll(other):
+ return other is Pulse
+
+class Any(nl.datatype):
+ @staticmethod
+ def poll(other):
+ return True
+
+class Vector(nl.datatype):
+ @staticmethod
+ def poll(other):
+ return other is Vector
Property changes on: branches/soc-2011-oregano/release/scripts/modules/NodeLogic/types.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: branches/soc-2011-oregano/release/scripts/nodes/samplenode.py
===================================================================
--- branches/soc-2011-oregano/release/scripts/nodes/samplenode.py (rev 0)
+++ branches/soc-2011-oregano/release/scripts/nodes/samplenode.py 2011-05-24 20:56:48 UTC (rev 36882)
@@ -0,0 +1,143 @@
+# example of timer node
+# A node must be defined as a class derived from NodeLogic.pushnode or NodeLogic.pullnode
+# The name of the class is the type of the node and is used in the GUI
+# This class is not intended to be instantiated, it's a placeholder for
+# pins and functions. Pins are defined as class variables:
+#
+# 1. Push Input
+# <pinname> = n.pushinput(data,option,callback)
+# data : data type that can be put on the pin
+# This is not used by the engine but only by the GUI to implement automatic checks
+# example of builtin types:
+# n.Any : any data is accepted (the default)
+# n.Pulse : pulse data (in fact a boolean True value)
+# n.Vector : any type of vector
+# n.Vector2 : 2D vector
+# n.Vector3 : 3D vector
+# option : list of bitwise options.
+# n.SIMPLE : how is the data delivered to the node functions?
+# on : bare data is passed to functions (None if pin didn't receive data). (default)
+# off: the pin object is passed to functions, data is available through object's API
+# n.QUEUE : queueing of data on pin
+# on : new data arriving is put at the end of a sequence object that the engine handles automatically
+# If combined with n.SIMPLE, the node functions receive the sequence object.
+# off: new data overwrites any data that was already on pin (default)
+# n.TRIGGER : does the pin triggers the node function?
+# on : new data triggers the node function (default). The node is put on the execution
+# list and the node function is executed when its turns comes up. If combined with
+# n.QUEUE, multiple data arrivals will trigger the node only once; it is up to the
+# node writer to make sure that all data is processed before returning from the node function.
+# off: new data does not trigger the node function. It is assumed that the node is
+# triggered by another pin or another mechanism.
+# n.CLEAR : data cleared after node execution
+# on : any data left on pin is automatically removed after the execution of the node function (default)
+# off: data is left on pin after node execution. The node writer has the option to
+# clear the data manually using the pin object API if necessary (n.SIMPLE should not be used)
+# n.FLUSH : N/A
+# n.PULSE : N/A
+# n.PULL : N/A
+# n.CACHE : N/A
+# callback : name of function that is called everytime data is put on pin. The function
+# must be one of the class function. None or empty to set no callback (default).
+# The callback function allows to do prefiltering of the data before the node
+# executes.
+#
+# 2. Push Output
+# <pinname> = n.pushoutput(data,option)
+# data : data type that can be put on pin
+# option : list of bitwise options, same values as for pushinput pin but with following limitations:
+# n.SIMPLE : always off
+# n.QUEUE : always off
+# n.TRIGGER : N/A
+# n.CLEAR : always off
+# n.FLUSH : data flushed after node execution
+# on : any data present on pin is automatically pushed after node execution (default)
+# off: data is left on pin, the node writer must do manual push in script
+# n.PULSE : automatic pulse generation
+# on : a pulse is automatically generated after node execution. Requires FLUSH option set.
+# The engine does that by putting a pulse data on the pin before node execution
+# and flushing the pulse after node execution if it is still present. The node writer
+# can decide to cancel the pulse in the node function.
+# off: no pulse is generated, the user must send pulse manually (default)
+# n.PULL : N/A
+# n.CACHE : N/A
+#
+# 3. Data Input
+# <pinname> = n.datainput(data,option)
+# data : data type that can be put on pin
+# option : list of bitwise options, same values as for pushinput pin but with following limitations:
+# n.SIMPLE : applicable, default on
+# n.QUEUE : always off
+# n.TRIGGER : N/A
+# n.CLEAR : applicable, default off
+# note about caching: if a data output depends on this input via a function, clearing
+# the input data invalidates caching of the output
+# n.FLUSH : N/A
+# n.PULSE : N/A
+# n.PULL : pull the data automatically
+# on : the data is updated automatically before the node executes (default).
+# The update is done by following the link and fetching the data from the pin at the other end.
+# off: the data is not updated, the node writer must do it manually in the node function
+# n.CACHE : N/A
+#
+# 4. Data Output
+# <pinname> = n.dataoutput(data,option,function)
+# data : data type that can be put on pin
+# option : list of bitwise options
+# n.SIMPLE : always off
+# n.QUEUE : always off
+# n.TRIGGER : N/A
+# n.CLEAR : always off
+# n.FLUSH : N/A
+# n.PULSE : N/A
+# n.PULL : N/A
+# n.CACHE : cache data, applicable only if a function is defined
+# on : the engine will check the timestamps of the function input arguments before
+# calling the function (default).
+# If the timestamps indicate that the inputs were not modified since previous
+# invocation, the data stored on the output is returned without calling the function.
+# The timestamp check is propagated towards the leafs of the graphs if the inputs
+# have PULL option set. Caching is de facto disabled if a data input has the CLEAR option
+# off: the function is called systematically.
+# function : function to be called to generate the output. The function must be one of the
+# class functions. None or empty means that the output is a simple storage (default).
+#
+
+import NodeLogic as nl
+import time
+
+class Timer(nl.pushnode):
+ # pin definition
+ start = nl.pushinput(data=nl.types.Pulse,option=nl.SIMPLE|nl.TRIGGER)
+ stop = nl.pushinput(data=nl.types.Pulse,option=nl.SIMPLE|nl.TRIGGER)
+ end = nl.pushoutput(data=nl.types.Pulse,option=0)
+ run = nl.pushoutput(data=nl.types.Pulse,option=0)
+ duration = nl.datainput(data=nl.types.Float,option=nl.SIMPLE)
+ timeleft = nl.dataoutput(data=nl.types.Float)
+
+ # function that is called when the node is triggered
+ def trigger(node,start,stop,duration,end,run,timeleft):
+ if stop:
+ # stop the timer
+ end.push()
+ # no schedule on next frame
+ return False
+ if start:
+ # start the timer, remember starting time
+ node.state = time.time()
+ timeleft.set(duration)
+ run.push()
+ # request execution next frame
+ return True
+ # otherwise: running timer
+ diff = duration - (time.time()-node.state)
+ if diff <= 0.0:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list