Added RNA for color ramps, as well as color-ramp properties for material
authorNicholas Bishop <nicholasbishop@gmail.com>
Tue, 6 Jan 2009 00:56:20 +0000 (00:56 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Tue, 6 Jan 2009 00:56:20 +0000 (00:56 +0000)
and color.

source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_texture.c

index 939753d39925b5b46e246df99c6b15928cc13aea..3223c1947e757747c31328943027987949ae64b2 100644 (file)
@@ -62,6 +62,8 @@ extern StructRNA RNA_CollectionProperty;
 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;
index 85698da2d82b0c0c3b43c3b1655d38875e78efa3..20bac17055463a9ffc93e505b77400a29a2f6825 100644 (file)
@@ -103,6 +103,17 @@ static void rna_def_material_colors(StructRNA *srna, PropertyRNA *prop)
        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)
index b35e763d0245019e1c8caeb9a2774e278d897f90..12dc72c26161fa78d275054afa6bd7029608ff80 100644 (file)
 
 #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 @@ void RNA_def_texture(BlenderRNA *brna)
 
        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 @@ void RNA_def_texture(BlenderRNA *brna)
 
        /* 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");