1. package GL.Materials is 
  2.  
  3.   -- Material. Doc from the VRML 1.0 spec (refers to OpenGL): 
  4.  
  5.   --  * The ambient color reflects ambient light evenly from all parts of 
  6.   --    an object regardless of viewing and lighting angles. 
  7.   -- 
  8.   --  * The diffuse color reflects all VRML light sources depending on the 
  9.   --    angle of the surface with respect to the light source. 
  10.   --    The more directly the surface faces the light, the more 
  11.   --    diffuse light reflects. 
  12.   -- 
  13.   --  * The specular color and shininess determine the specular highlights, 
  14.   --    e.g., the shiny spots on an apple. When the angle from the light 
  15.   --    to the surface is close to the angle from the surface to the viewer, 
  16.   --    the specular color is added to the diffuse and ambient color 
  17.   --    calculations. 
  18.   --    Lower shininess values produce soft glows, while higher values 
  19.   --    result in sharper, smaller highlights. 
  20.   -- 
  21.   --  * Emissive color models "glowing" objects. This can be useful for 
  22.   --    displaying radiosity - based models (where the light energy of the 
  23.   --    room is computed explicitly), or for displaying scientific data. 
  24.  
  25.   type Material_type is record 
  26.     ambient, 
  27.     diffuse, 
  28.     specular, 
  29.     emission   : GL.Material_Float_vector; 
  30.     shininess  : GL.C_Float; -- 0.0 .. 128.0 
  31.   end record; 
  32.  
  33.   function is_Transparent (Self : Material_type) return Boolean; 
  34.  
  35.   neutral_material : 
  36.     constant Material_type := (ambient =>        (0.2, 0.2, 0.2, 1.0), 
  37.                               diffuse =>        (0.8, 0.8, 0.8, 1.0), 
  38.                               specular =>       (0.0, 0.0, 0.0, 1.0), 
  39.                               emission =>       (0.0, 0.0, 0.0, 1.0), 
  40.                               shininess =>      0.0); 
  41.                               -- ^ the values are GL defaults. 
  42.  
  43.   -- A few colour - dominant materials: 
  44.  
  45.   Red    : constant Material_type := ( 
  46.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  47.     diffuse   => (1.0, 0.0, 0.0, 1.0), 
  48.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  49.     emission  => (0.0, 0.0, 0.0, 1.0), 
  50.     shininess => 12.8 
  51. ); 
  52.  
  53.   Orange    : constant Material_type := ( 
  54.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  55.     diffuse   => (0.992157, 0.513726, 0.0, 1.0), 
  56.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  57.     emission  => (0.0, 0.0, 0.0, 1.0), 
  58.     shininess => 12.8 
  59. ); 
  60.  
  61.   Yellow    : constant Material_type := ( 
  62.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  63.     diffuse   => (1.0, 0.964706, 0.0, 1.0), 
  64.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  65.     emission  => (0.0, 0.0, 0.0, 1.0), 
  66.     shininess => 12.8 
  67. ); 
  68.  
  69.   Green    : constant Material_type := ( 
  70.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  71.     diffuse   => (0.0, 1.0, 0.0, 1.0), 
  72.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  73.     emission  => (0.0, 0.0, 0.0, 1.0), 
  74.     shininess => 12.8 
  75. ); 
  76.  
  77.   Indigo    : constant Material_type := ( 
  78.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  79.     diffuse   => (0.0980392, 0.0, 0.458824, 1.0), 
  80.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  81.     emission  => (0.0, 0.0, 0.0, 1.0), 
  82.     shininess => 12.8 
  83. ); 
  84.  
  85.   Blue    : constant Material_type := ( 
  86.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  87.     diffuse   => (0.0, 0.0, 1.0, 1.0), 
  88.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  89.     emission  => (0.0, 0.0, 0.0, 1.0), 
  90.     shininess => 12.8 
  91. ); 
  92.  
  93.   Violet    : constant Material_type := ( 
  94.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  95.     diffuse   => (0.635294, 0.0, 1.0, 1.0), 
  96.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  97.     emission  => (0.0, 0.0, 0.0, 1.0), 
  98.     shininess => 12.8 
  99. ); 
  100.  
  101.   White    : constant Material_type := ( 
  102.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  103.     diffuse   => (0.992157, 0.992157, 0.992157, 1.0), 
  104.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  105.     emission  => (0.0, 0.0, 0.0, 1.0), 
  106.     shininess => 12.8 
  107. ); 
  108.  
  109.   Black    : constant Material_type := ( 
  110.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  111.     diffuse   => (0.0, 0.0, 0.0, 1.0), 
  112.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  113.     emission  => (0.0, 0.0, 0.0, 1.0), 
  114.     shininess => 12.8 
  115. ); 
  116.  
  117.   Medium_Gray    : constant Material_type := ( 
  118.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  119.     diffuse   => (0.454902, 0.454902, 0.454902, 1.0), 
  120.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  121.     emission  => (0.0, 0.0, 0.0, 1.0), 
  122.     shininess => 12.8 
  123. ); 
  124.  
  125.   Light_Gray    : constant Material_type := ( 
  126.     ambient   => (0.0, 0.0, 0.0, 1.0), 
  127.     diffuse   => (0.682353, 0.682353, 0.682353, 1.0), 
  128.     specular  => (0.0225, 0.0225, 0.0225, 1.0), 
  129.     emission  => (0.0, 0.0, 0.0, 1.0), 
  130.     shininess => 12.8 
  131. ); 
  132.  
  133.   -- A few "material" materials: 
  134.  
  135.   Glass    : constant Material_type := ( 
  136.               ambient   => (0.0, 0.0, 0.0, 1.0), 
  137.               diffuse   => (0.588235, 0.670588, 0.729412, 1.0), 
  138.               specular  => (0.9, 0.9, 0.9, 1.0), 
  139.               emission  => (0.0, 0.0, 0.0, 1.0), 
  140.               shininess => 96.0 
  141. ); 
  142.  
  143.   Brass     : constant Material_type := ( 
  144.             ambient =>        (0.329412, 0.223529, 0.027451, 1.0), 
  145.             diffuse =>        (0.780392, 0.568627, 0.113725, 1.0), 
  146.             specular =>       (0.992157, 0.941176, 0.807843, 1.0), 
  147.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  148.             shininess =>      27.8974); 
  149.   Bronze     : constant Material_type := ( 
  150.             ambient =>        (0.2125, 0.1275, 0.054, 1.0), 
  151.             diffuse =>        (0.714, 0.4284, 0.18144, 1.0), 
  152.             specular =>       (0.393548, 0.271906, 0.166721, 1.0), 
  153.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  154.             shininess =>      25.6); 
  155.   Polished_Bronze     : constant Material_type := ( 
  156.             ambient =>        (0.25, 0.148, 0.06475, 1.0), 
  157.             diffuse =>        (0.4, 0.2368, 0.1036, 1.0), 
  158.             specular =>       (0.774597, 0.458561, 0.200621, 1.0), 
  159.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  160.             shininess =>      76.8); 
  161.   Chrome     : constant Material_type := ( 
  162.             ambient =>        (0.25, 0.25, 0.25, 1.0), 
  163.             diffuse =>        (0.4, 0.4, 0.4, 1.0), 
  164.             specular =>       (0.774597, 0.774597, 0.774597, 1.0), 
  165.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  166.             shininess =>      76.8); 
  167.   Copper     : constant Material_type := ( 
  168.             ambient =>        (0.19125, 0.0735, 0.0225, 1.0), 
  169.             diffuse =>        (0.7038, 0.27048, 0.0828, 1.0), 
  170.             specular =>       (0.256777, 0.137622, 0.086014, 1.0), 
  171.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  172.             shininess =>      12.8); 
  173.   Polished_Copper     : constant Material_type := ( 
  174.             ambient =>        (0.2295, 0.08825, 0.0275, 1.0), 
  175.             diffuse =>        (0.5508, 0.2118, 0.066, 1.0), 
  176.             specular =>       (0.580594, 0.223257, 0.0695701, 1.0), 
  177.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  178.             shininess =>      51.2); 
  179.   Gold     : constant Material_type := ( 
  180.             ambient =>        (0.24725, 0.1995, 0.0745, 1.0), 
  181.             diffuse =>        (0.75164, 0.60648, 0.22648, 1.0), 
  182.             specular =>       (0.628281, 0.555802, 0.366065, 1.0), 
  183.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  184.             shininess =>      51.2); 
  185.   Polished_Gold     : constant Material_type := ( 
  186.             ambient =>        (0.24725, 0.2245, 0.0645, 1.0), 
  187.             diffuse =>        (0.34615, 0.3143, 0.0903, 1.0), 
  188.             specular =>       (0.797357, 0.723991, 0.208006, 1.0), 
  189.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  190.             shininess =>      83.2); 
  191.   Pewter     : constant Material_type := ( 
  192.             ambient =>        (0.105882, 0.058824, 0.113725, 1.0), 
  193.             diffuse =>        (0.427451, 0.470588, 0.541176, 1.0), 
  194.             specular =>       (0.333333, 0.333333, 0.521569, 1.0), 
  195.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  196.             shininess =>      9.84615); 
  197.   Silver     : constant Material_type := ( 
  198.             ambient =>        (0.19225, 0.19225, 0.19225, 1.0), 
  199.             diffuse =>        (0.50754, 0.50754, 0.50754, 1.0), 
  200.             specular =>       (0.508273, 0.508273, 0.508273, 1.0), 
  201.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  202.             shininess =>      51.2); 
  203.   Polished_Silver     : constant Material_type := ( 
  204.             ambient =>        (0.23125, 0.23125, 0.23125, 1.0), 
  205.             diffuse =>        (0.2775, 0.2775, 0.2775, 1.0), 
  206.             specular =>       (0.773911, 0.773911, 0.773911, 1.0), 
  207.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  208.             shininess =>      89.6); 
  209.   Emerald     : constant Material_type := ( 
  210.             ambient =>        (0.0215, 0.1745, 0.0215, 0.55), 
  211.             diffuse =>        (0.07568, 0.61424, 0.07568, 0.55), 
  212.             specular =>       (0.633, 0.727811, 0.633, 0.55), 
  213.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  214.             shininess =>      76.8); 
  215.   Jade     : constant Material_type := ( 
  216.             ambient =>        (0.135, 0.2225, 0.1575, 0.95), 
  217.             diffuse =>        (0.54, 0.89, 0.63, 0.95), 
  218.             specular =>       (0.316228, 0.316228, 0.316228, 0.95), 
  219.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  220.             shininess =>      12.8); 
  221.   Obsidian     : constant Material_type := ( 
  222.             ambient =>        (0.05375, 0.05, 0.06625, 0.82), 
  223.             diffuse =>        (0.18275, 0.17, 0.22525, 0.82), 
  224.             specular =>       (0.332741, 0.328634, 0.346435, 0.82), 
  225.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  226.             shininess =>      38.4); 
  227.   Pearl     : constant Material_type := ( 
  228.             ambient =>        (0.25, 0.20725, 0.20725, 0.922), 
  229.             diffuse =>        (1.0, 0.829, 0.829, 0.922), 
  230.             specular =>       (0.296648, 0.296648, 0.296648, 0.922), 
  231.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  232.             shininess =>      11.264); 
  233.   Ruby     : constant Material_type := ( 
  234.             ambient =>        (0.1745, 0.01175, 0.01175, 0.55), 
  235.             diffuse =>        (0.61424, 0.04136, 0.04136, 0.55), 
  236.             specular =>       (0.727811, 0.626959, 0.626959, 0.55), 
  237.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  238.             shininess =>      76.8); 
  239.   Turquoise     : constant Material_type := ( 
  240.             ambient =>        (0.1, 0.18725, 0.1745, 0.8), 
  241.             diffuse =>        (0.396, 0.74151, 0.69102, 0.8), 
  242.             specular =>       (0.297254, 0.30829, 0.306678, 0.8), 
  243.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  244.             shininess =>      12.8); 
  245.   Black_Plastic     : constant Material_type := ( 
  246.             ambient =>        (0.0, 0.0, 0.0, 1.0), 
  247.             diffuse =>        (0.01, 0.01, 0.01, 1.0), 
  248.             specular =>       (0.50, 0.50, 0.50, 1.0), 
  249.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  250.             shininess =>      32.0); 
  251.   Black_Rubber     : constant Material_type := ( 
  252.             ambient =>        (0.02, 0.02, 0.02, 1.0), 
  253.             diffuse =>        (0.01, 0.01, 0.01, 1.0), 
  254.             specular =>       (0.4, 0.4, 0.4, 1.0), 
  255.             emission =>       (0.0, 0.0, 0.0, 0.0), 
  256.             shininess =>      10.0); 
  257.  
  258.   VRML_Defaults    : constant Material_type := ( 
  259.             ambient =>        (0.2, 0.2, 0.2, 1.0), 
  260.             diffuse =>        (0.8, 0.8, 0.8, 1.0), 
  261.             specular =>       (0.0, 0.0, 0.0, 1.0), 
  262.             emission =>       (0.0, 0.0, 0.0, 1.0), 
  263.             shininess =>       25.6); 
  264.  
  265. end GL.Materials;