[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39783] branches/soc-2008-mxcurioni: Added an 'angle' parameter to the Perlin Noise 1D and 2D geometry modifiers
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Tue Aug 30 02:29:13 CEST 2011
Revision: 39783
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39783
Author: kjym3
Date: 2011-08-30 00:29:12 +0000 (Tue, 30 Aug 2011)
Log Message:
-----------
Added an 'angle' parameter to the Perlin Noise 1D and 2D geometry modifiers
to specify a displacement direction in degrees.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
Modified: branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py 2011-08-30 00:23:11 UTC (rev 39782)
+++ branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/parameter_editor.py 2011-08-30 00:29:12 UTC (rev 39783)
@@ -419,6 +419,46 @@
n = n * self._amplitude * math.cos(distance / self._wavelength * 2 * math.pi + self._phase)
v.setPoint(p + n)
+class PerlinNoise1DShader(StrokeShader):
+ def __init__(self, freq = 10, amp = 10, oct = 4, angle = 45, seed = -1):
+ StrokeShader.__init__(self)
+ self.__noise = Noise(seed)
+ self.__freq = freq
+ self.__amp = amp
+ self.__oct = oct
+ theta = pi * angle / 180.0
+ self.__dir = Vector([cos(theta), sin(theta)])
+ def getName(self):
+ return "PerlinNoise1DShader"
+ def shade(self, stroke):
+ it = stroke.strokeVerticesBegin()
+ while not it.isEnd():
+ v = it.getObject()
+ i = v.getProjectedX() + v.getProjectedY()
+ nres = self.__noise.turbulence1(i, self.__freq, self.__amp, self.__oct)
+ v.setPoint(v.getPoint() + nres * self.__dir)
+ it.increment()
+
+class PerlinNoise2DShader(StrokeShader):
+ def __init__(self, freq = 10, amp = 10, oct = 4, angle = 45, seed = -1):
+ StrokeShader.__init__(self)
+ self.__noise = Noise(seed)
+ self.__freq = freq
+ self.__amp = amp
+ self.__oct = oct
+ theta = pi * angle / 180.0
+ self.__dir = Vector([cos(theta), sin(theta)])
+ def getName(self):
+ return "PerlinNoise2DShader"
+ def shade(self, stroke):
+ it = stroke.strokeVerticesBegin()
+ while not it.isEnd():
+ v = it.getObject()
+ vec = Vector([v.getProjectedX(), v.getProjectedY()])
+ nres = self.__noise.turbulence2(vec, self.__freq, self.__amp, self.__oct)
+ v.setPoint(v.getPoint() + nres * self.__dir)
+ it.increment()
+
# Predicates and helper functions
class QuantitativeInvisibilityRangeUP1D(UnaryPredicate1D):
@@ -836,11 +876,11 @@
shaders_list.append(SpatialNoiseShader(
m.amplitude, m.scale, m.octaves, m.smooth, m.pure_random))
elif m.type == "PERLIN_NOISE_1D":
- shaders_list.append(pyPerlinNoise1DShader(
- m.frequency, m.amplitude, m.octaves, _seed.get(m.seed)))
+ shaders_list.append(PerlinNoise1DShader(
+ m.frequency, m.amplitude, m.octaves, m.angle, _seed.get(m.seed)))
elif m.type == "PERLIN_NOISE_2D":
- shaders_list.append(pyPerlinNoise2DShader(
- m.frequency, m.amplitude, m.octaves, _seed.get(m.seed)))
+ shaders_list.append(PerlinNoise2DShader(
+ m.frequency, m.amplitude, m.octaves, m.angle, _seed.get(m.seed)))
elif m.type == "BACKBONE_STRETCHER":
shaders_list.append(BackboneStretcherShader(
m.amount))
Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-08-30 00:23:11 UTC (rev 39782)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-08-30 00:29:12 UTC (rev 39783)
@@ -477,12 +477,14 @@
box.prop(modifier, "frequency")
box.prop(modifier, "amplitude")
box.prop(modifier, "octaves")
+ box.prop(modifier, "angle")
box.prop(modifier, "seed")
elif modifier.type == "PERLIN_NOISE_2D":
box.prop(modifier, "frequency")
box.prop(modifier, "amplitude")
box.prop(modifier, "octaves")
+ box.prop(modifier, "angle")
box.prop(modifier, "seed")
elif modifier.type == "BACKBONE_STRETCHER":
Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2011-08-30 00:23:11 UTC (rev 39782)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c 2011-08-30 00:29:12 UTC (rev 39783)
@@ -403,11 +403,13 @@
((LineStyleGeometryModifier_PerlinNoise1D *)m)->frequency = 10.0;
((LineStyleGeometryModifier_PerlinNoise1D *)m)->amplitude = 10.0;
((LineStyleGeometryModifier_PerlinNoise1D *)m)->octaves = 4;
+ ((LineStyleGeometryModifier_PerlinNoise1D *)m)->angle = 45.0;
break;
case LS_MODIFIER_PERLIN_NOISE_2D:
((LineStyleGeometryModifier_PerlinNoise2D *)m)->frequency = 10.0;
((LineStyleGeometryModifier_PerlinNoise2D *)m)->amplitude = 10.0;
((LineStyleGeometryModifier_PerlinNoise2D *)m)->octaves = 4;
+ ((LineStyleGeometryModifier_PerlinNoise2D *)m)->angle = 45.0;
break;
case LS_MODIFIER_BACKBONE_STRETCHER:
((LineStyleGeometryModifier_BackboneStretcher *)m)->amount = 10.0;
Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2011-08-30 00:23:11 UTC (rev 39782)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h 2011-08-30 00:29:12 UTC (rev 39783)
@@ -261,18 +261,20 @@
typedef struct LineStyleGeometryModifier_PerlinNoise1D {
struct LineStyleModifier modifier;
- float frequency, amplitude;
+ float frequency, amplitude, angle;
unsigned int octaves;
int seed;
+ int pad1;
} LineStyleGeometryModifier_PerlinNoise1D;
typedef struct LineStyleGeometryModifier_PerlinNoise2D {
struct LineStyleModifier modifier;
- float frequency, amplitude;
+ float frequency, amplitude, angle;
unsigned int octaves;
int seed;
+ int pad1;
} LineStyleGeometryModifier_PerlinNoise2D;
Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2011-08-30 00:23:11 UTC (rev 39782)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c 2011-08-30 00:29:12 UTC (rev 39783)
@@ -578,6 +578,11 @@
RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise).");
RNA_def_property_update(prop, NC_SCENE, NULL);
+ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "angle");
+ RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "seed");
RNA_def_property_ui_text(prop, "Seed", "Seed for random number generation. If negative, time is used as a seed instead.");
@@ -602,6 +607,11 @@
RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise).");
RNA_def_property_update(prop, NC_SCENE, NULL);
+ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "angle");
+ RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees.");
+ RNA_def_property_update(prop, NC_SCENE, NULL);
+
prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "seed");
RNA_def_property_ui_text(prop, "Seed", "Seed for random number generation. If negative, time is used as a seed instead.");
More information about the Bf-blender-cvs
mailing list