Extensions:2.4/Py/Nodes/Cookbook/Value

提供: wiki
< Extensions:2.4‎ | Py‎ | Nodes‎ | Cookbook
移動先: 案内検索

Back to index

Ideas

  • Add your idea here.

Recipes

Quantize Value

This script quantizes the given value by the Quantize value.

from Blender import Node

class QuantizeValue(Node.Scripted):
	def __init__(self, sockets):
		val = Node.Socket('Value', val=-10e6, min=0.001, max=10e6)
		qval = Node.Socket('Quantize', val=1.0, min=0.001, max=100.0)
		sockets.input = [val, qval]
		sockets.output = [val]
		
	def __call__(self):
		oval = self.input.Value
		oqval = self.input.Quantize
		self.output.Value = ((oval/oqval)-(oval%oqval))*oqval
		
__node__ = QuantizeValue