Mercurial > octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
21788:43f613cca3ab | 21789:6afdf40be534 |
---|---|
4813 } | 4813 } |
4814 }; | 4814 }; |
4815 | 4815 |
4816 // --------------------------------------------------------------------- | 4816 // --------------------------------------------------------------------- |
4817 | 4817 |
4818 class OCTINTERP_API light : public base_graphics_object | |
4819 { | |
4820 public: | |
4821 class OCTINTERP_API properties : public base_properties | |
4822 { | |
4823 // See the genprops.awk script for an explanation of the | |
4824 // properties declarations. | |
4825 // Programming note: Keep property list sorted if new ones are added. | |
4826 | |
4827 BEGIN_PROPERTIES (light) | |
4828 color_property color , color_values (1, 1, 1) | |
4829 array_property position , default_light_position () | |
4830 radio_property style , "{infinite}|local" | |
4831 END_PROPERTIES | |
4832 | |
4833 protected: | |
4834 void init (void) | |
4835 { | |
4836 position.add_constraint (dim_vector (1, 3)); | |
4837 } | |
4838 }; | |
4839 | |
4840 private: | |
4841 properties xproperties; | |
4842 | |
4843 public: | |
4844 light (const graphics_handle& mh, const graphics_handle& p) | |
4845 : base_graphics_object (), xproperties (mh, p) | |
4846 { } | |
4847 | |
4848 ~light (void) { } | |
4849 | |
4850 base_properties& get_properties (void) { return xproperties; } | |
4851 | |
4852 const base_properties& get_properties (void) const { return xproperties; } | |
4853 | |
4854 bool valid_object (void) const { return true; } | |
4855 | |
4856 bool has_readonly_property (const caseless_str& pname) const | |
4857 { | |
4858 bool retval = xproperties.has_readonly_property (pname); | |
4859 if (! retval) | |
4860 retval = base_properties::has_readonly_property (pname); | |
4861 return retval; | |
4862 } | |
4863 }; | |
4864 | |
4865 // --------------------------------------------------------------------- | |
4866 | |
4818 class OCTINTERP_API patch : public base_graphics_object | 4867 class OCTINTERP_API patch : public base_graphics_object |
4819 { | 4868 { |
4820 public: | 4869 public: |
4821 class OCTINTERP_API properties : public base_properties | 4870 class OCTINTERP_API properties : public base_properties |
4822 { | 4871 { |
4857 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) | 4906 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) |
4858 radio_property edgelighting , "{none}|flat|gouraud|phong" | 4907 radio_property edgelighting , "{none}|flat|gouraud|phong" |
4859 radio_property erasemode , "{normal}|background|xor|none" | 4908 radio_property erasemode , "{normal}|background|xor|none" |
4860 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp")) | 4909 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
4861 color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) | 4910 color_property facecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) |
4862 radio_property facelighting , "{none}|flat|gouraud|phong" | 4911 radio_property facelighting , "none|{flat}|gouraud|phong" |
4863 array_property facenormals m , Matrix () | 4912 array_property facenormals m , Matrix () |
4864 radio_property facenormalsmode , "{auto}|manual" | 4913 radio_property facenormalsmode , "{auto}|manual" |
4865 array_property faces u , default_patch_faces () | 4914 array_property faces u , default_patch_faces () |
4866 array_property facevertexalphadata , Matrix () | 4915 array_property facevertexalphadata , Matrix () |
4867 array_property facevertexcdata u , Matrix () | 4916 array_property facevertexcdata u , Matrix () |
5060 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) | 5109 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("none|flat|interp")) |
5061 radio_property edgelighting , "{none}|flat|gouraud|phong" | 5110 radio_property edgelighting , "{none}|flat|gouraud|phong" |
5062 radio_property erasemode , "{normal}|none|xor|background" | 5111 radio_property erasemode , "{normal}|none|xor|background" |
5063 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap")) | 5112 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp|texturemap")) |
5064 color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap"), color_values (0, 0, 0)) | 5113 color_property facecolor , color_property (radio_values ("none|{flat}|interp|texturemap"), color_values (0, 0, 0)) |
5065 radio_property facelighting , "{none}|flat|gouraud|phong" | 5114 radio_property facelighting , "none|{flat}|gouraud|phong" |
5066 array_property facenormals m , Matrix () | 5115 array_property facenormals m , Matrix () |
5067 radio_property facenormalsmode , "{auto}|manual" | 5116 radio_property facenormalsmode , "{auto}|manual" |
5068 // FIXME: interpreter is not a Matlab surface property | 5117 // FIXME: interpreter is not a Matlab surface property |
5069 // Octave uses this for legend() with the string displayname. | 5118 // Octave uses this for legend() with the string displayname. |
5070 radio_property interpreter , "{tex}|none|latex" | 5119 radio_property interpreter , "{tex}|none|latex" |