[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18354] branches/blender2.5/blender/source /blender/makesrna: Added RNA for color ramps, as well as color-ramp properties for material

Nicholas Bishop nicholasbishop at gmail.com
Tue Jan 6 01:56:20 CET 2009


Revision: 18354
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18354
Author:   nicholasbishop
Date:     2009-01-06 01:56:20 +0100 (Tue, 06 Jan 2009)

Log Message:
-----------
Added RNA for color ramps, as well as color-ramp properties for material 
and color.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-01-06 00:19:47 UTC (rev 18353)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_access.h	2009-01-06 00:56:20 UTC (rev 18354)
@@ -62,6 +62,8 @@
 extern StructRNA RNA_CollisionModifier;
 extern StructRNA RNA_CollisionSensor;
 extern StructRNA RNA_CollisionSettings;
+extern StructRNA RNA_ColorRamp;
+extern StructRNA RNA_ColorRampElement;
 extern StructRNA RNA_ColorSequence;
 extern StructRNA RNA_Constraint;
 extern StructRNA RNA_ControlFluidSettings;

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c	2009-01-06 00:19:47 UTC (rev 18353)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_material.c	2009-01-06 00:56:20 UTC (rev 18354)
@@ -103,6 +103,17 @@
 	RNA_def_property_range(prop, 0.0f, 1.0f);
 	RNA_def_property_ui_text(prop, "Alpha", "");
 	RNA_def_property_update(prop, NC_MATERIAL|ND_SHADING_DRAW, NULL);
+	
+	/* Color bands */
+	prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "ramp_col");
+	RNA_def_property_struct_type(prop, "ColorRamp");
+	RNA_def_property_ui_text(prop, "Color Ramp", "");
+
+	prop= RNA_def_property(srna, "specularity_ramp", PROP_POINTER, PROP_NONE);
+	RNA_def_property_pointer_sdna(prop, NULL, "ramp_spec");
+	RNA_def_property_struct_type(prop, "ColorRamp");
+	RNA_def_property_ui_text(prop, "Specularity Ramp", "");
 }
 
 static void rna_def_material_diffuse(StructRNA *srna, PropertyRNA *prop)

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c	2009-01-06 00:19:47 UTC (rev 18353)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c	2009-01-06 00:56:20 UTC (rev 18354)
@@ -37,6 +37,58 @@
 
 #else
 
+void rna_def_color_ramp_element(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna= RNA_def_struct(brna, "ColorRampElement", NULL);
+	RNA_def_struct_sdna(srna, "CBData");
+	RNA_def_struct_ui_text(srna, "Color Ramp Element", "DOC_BROKEN");
+
+	prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
+	RNA_def_property_float_sdna(prop, NULL, "r");
+	RNA_def_property_array(prop, 4);
+	RNA_def_property_ui_text(prop, "Color", "");
+
+	prop= RNA_def_property(srna, "position", PROP_FLOAT, PROP_COLOR);
+	RNA_def_property_float_sdna(prop, NULL, "pos");
+	RNA_def_property_range(prop, 0, 1);
+	RNA_def_property_ui_text(prop, "Position", "");
+
+	/* XXX: CBData.cur? */
+}
+
+void rna_def_color_ramp(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	static EnumPropertyItem prop_interpolation_items[] = {
+		{1, "EASE", "Ease", ""},
+		{3, "CARDINAL", "Cardinal", ""},
+		{0, "LINEAR", "Linear", ""},
+		{2, "B_SPLINE", "B-Spline", ""},
+		{4, "CONSTANT", "Constant", ""},
+		{0, NULL, NULL, NULL}};
+
+	srna= RNA_def_struct(brna, "ColorRamp", NULL);
+	RNA_def_struct_sdna(srna, "ColorBand");
+	RNA_def_struct_ui_text(srna, "Color Ramp", "DOC_BROKEN");
+
+	prop= RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_COLOR);
+	RNA_def_property_collection_sdna(prop, NULL, "data", "tot");
+	RNA_def_property_struct_type(prop, "ColorRampElement");
+	RNA_def_property_ui_text(prop, "Elements", "");
+
+	/* XXX: CBData.flag, tot, cur ? */
+
+	prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "ipotype");
+	RNA_def_property_enum_items(prop, prop_interpolation_items);
+	RNA_def_property_ui_text(prop, "Interpolation", "");
+}
+
 void rna_def_mapping_texture(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -295,6 +347,8 @@
 
 	rna_def_mapping_texture(brna);
 	rna_def_environment_map(brna);
+	rna_def_color_ramp(brna);
+	rna_def_color_ramp_element(brna);
 
 	srna= RNA_def_struct(brna, "Texture", "ID");
 	RNA_def_struct_sdna(srna, "Tex");
@@ -437,11 +491,10 @@
 
 	/* XXX: plugin */
 
-	/*
-	prop= RNA_def_property(srna, "color_band", PROP_POINTER, PROP_NONE);
+	prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "coba");
-	RNA_def_property_struct_type(prop, "ColorBand");
-	RNA_def_property_ui_text(prop, "Color Band", "");*/
+	RNA_def_property_struct_type(prop, "ColorRamp");
+	RNA_def_property_ui_text(prop, "Color Ramp", "");
 
 	prop= RNA_def_property(srna, "environment_map", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "env");





More information about the Bf-blender-cvs mailing list