diff libinterp/corefcn/graphics.in.h @ 21789:6afdf40be534

Implement graphics object "light" (patch #8943). * graphics.in.h (light): New class. * graphics.in.h (patch, surface): Make default value of facelighting property compatible with Matlab. * graphics.cc: Add function default_light_position. Export function __go_light__. * gl-render.h (opengl_renderer): Declare opengl_renderer::draw_light. New private properties "view_vector", "num_lights" and "current_light". Delete private property "has_light". * gl-render.cc (opengl_renderer::draw_light): New function. (opengl_renderer::draw): Handle drawing for light property. Support for up to GL_MAX_LIGHTS light sources (at least 8, limited by OpenGL). Set view_vector before drawing anything. Set OpenGL ambient light color before drawing other axes objects. Respect setting of "specularcolorreflectance" on patches and surfaces. Set normals of OpenGL faces in patch objects if possible. Support lighting modes "reverselit" and "unlit". Only enable OpenGL lighting if normals are defined for patch. * scripts/plot/draw/light.m: New function. * scripts/plot/draw/module.mk: Update. * __unimplemented__.m: Remove "light" from list. * __gnuplot_draw_axes__.m: Do not throw an error if light object is present. * doc/interpreter/genpropdoc.m, doc/interpreter/module.mk, doc/interpreter/plot.txi: Document light and related properties. * NEWS: Mention new feature.
author mmuetzel <markus.muetzel@gmx.de>
date Mon, 30 May 2016 13:17:13 +0200
parents 2aef506f3fec
children 6780a8657be3
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.in.h	Sat May 28 13:33:37 2016 +0200
+++ b/libinterp/corefcn/graphics.in.h	Mon May 30 13:17:13 2016 +0200
@@ -4815,6 +4815,55 @@
 
 // ---------------------------------------------------------------------
 
+class OCTINTERP_API light : public base_graphics_object
+{
+public:
+  class OCTINTERP_API properties : public base_properties
+  {
+    // See the genprops.awk script for an explanation of the
+    // properties declarations.
+    // Programming note: Keep property list sorted if new ones are added.
+
+    BEGIN_PROPERTIES (light)
+      color_property color , color_values (1, 1, 1)
+      array_property position , default_light_position ()
+      radio_property style , "{infinite}|local"
+    END_PROPERTIES
+
+  protected:
+    void init (void)
+    {
+      position.add_constraint (dim_vector (1, 3));
+    }
+  };
+
+private:
+  properties xproperties;
+
+public:
+  light (const graphics_handle& mh, const graphics_handle& p)
+    : base_graphics_object (), xproperties (mh, p)
+  { }
+
+  ~light (void) { }
+
+  base_properties& get_properties (void) { return xproperties; }
+
+  const base_properties& get_properties (void) const { return xproperties; }
+
+  bool valid_object (void) const { return true; }
+
+  bool has_readonly_property (const caseless_str& pname) const
+  {
+    bool retval = xproperties.has_readonly_property (pname);
+    if (! retval)
+      retval = base_properties::has_readonly_property (pname);
+    return retval;
+  }
+};
+
+// ---------------------------------------------------------------------
+
 class OCTINTERP_API patch : public base_graphics_object
 {
 public:
@@ -4859,7 +4908,7 @@
       radio_property erasemode , "{normal}|background|xor|none"
       double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp"))
       color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp"))
-      radio_property facelighting , "{none}|flat|gouraud|phong"
+      radio_property facelighting , "none|{flat}|gouraud|phong"
       array_property facenormals m , Matrix ()
       radio_property facenormalsmode , "{auto}|manual"
       array_property faces u , default_patch_faces ()
@@ -5062,7 +5111,7 @@
       radio_property erasemode , "{normal}|none|xor|background"
       double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap"))
       color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap"), color_values (0, 0, 0))
-      radio_property facelighting , "{none}|flat|gouraud|phong"
+      radio_property facelighting , "none|{flat}|gouraud|phong"
       array_property facenormals m , Matrix ()
       radio_property facenormalsmode , "{auto}|manual"
       // FIXME: interpreter is not a Matlab surface property