INFO804 Introduction à l'informatique graphique
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
rt::Material Struct Reference

#include <Material.h>

Public Member Functions

 Material ()
 Default constructor.
 
 Material (Color amb, Color diff, Color spec, Real shiny=0.0f, Real cdiff=1.0f, Real crefl=0.0f, Real crefr=0.0f, Real in_ridx=1.0f, Real out_ridx=1.0f)
 Constructor from colors and shinyness.
 

Static Public Member Functions

static Material mix (Real t, const Material &m1, const Material &m2)
 Mixes two material (t=0 gives m1, t=1 gives m2, t=0.5 gives their average)
 
static Material whitePlastic ()
 
static Material redPlastic ()
 
static Material bronze ()
 
static Material emerald ()
 
static Material glass ()
 

Public Attributes

Color ambient
 ambient color
 
Color diffuse
 diffuse color
 
Color specular
 specular color
 
Real shinyness
 shinyness (50: very high, 1: low )
 
Real coef_diffusion
 
Real coef_reflexion
 The material has some specularity if coef_reflexion > 0.0.
 
Real coef_refraction
 The material is transparent if coef_refraction > 0.0.
 
Real in_refractive_index
 
Real out_refractive_index
 Outside refractive index (1.0f if object is in the air otherwise >= 1.0f)
 

Detailed Description

This structure stores the material associated to a graphical object. object should have.

Definition at line 18 of file Material.h.

Constructor & Destructor Documentation

◆ Material() [1/2]

rt::Material::Material ( )
inline

Default constructor.

Definition at line 61 of file Material.h.

61{}

◆ Material() [2/2]

rt::Material::Material ( Color  amb,
Color  diff,
Color  spec,
Real  shiny = 0.0f,
Real  cdiff = 1.0f,
Real  crefl = 0.0f,
Real  crefr = 0.0f,
Real  in_ridx = 1.0f,
Real  out_ridx = 1.0f 
)
inline

Constructor from colors and shinyness.

Definition at line 64 of file Material.h.

67 : ambient( amb ), diffuse( diff ), specular( spec ), shinyness( shiny ),
68 coef_diffusion( cdiff ), coef_reflexion( crefl ), coef_refraction( crefr ),
69 in_refractive_index( in_ridx ), out_refractive_index( out_ridx )
70 {}
Real coef_refraction
The material is transparent if coef_refraction > 0.0.
Definition Material.h:36
Real shinyness
shinyness (50: very high, 1: low )
Definition Material.h:26
Real in_refractive_index
Definition Material.h:39
Color diffuse
diffuse color
Definition Material.h:22
Real out_refractive_index
Outside refractive index (1.0f if object is in the air otherwise >= 1.0f)
Definition Material.h:41
Real coef_diffusion
Definition Material.h:32
Real coef_reflexion
The material has some specularity if coef_reflexion > 0.0.
Definition Material.h:34
Color ambient
ambient color
Definition Material.h:20
Color specular
specular color
Definition Material.h:24

Member Function Documentation

◆ bronze()

static Material rt::Material::bronze ( )
inlinestatic

Definition at line 100 of file Material.h.

101 {
102 Material m;
103 m.ambient = Color( 0.1125, 0.0675, 0.054 );
104 m.diffuse = Color( 0.714, 0.4284, 0.18144 );
105 m.specular = Color( 0.9, 0.8, 0.7 );
106 // m.specular = Color( 0.393548, 0.271906, 0.166721 );
107 m.shinyness = 56; // 25.6;
108 m.coef_diffusion = 0.5f;
109 m.coef_reflexion = 0.75f;
110 m.coef_refraction = 0.0f;
111 m.in_refractive_index = 1.0f;
112 m.out_refractive_index = 1.0f;
113 return m;
114 }
Material()
Default constructor.
Definition Material.h:61

◆ emerald()

static Material rt::Material::emerald ( )
inlinestatic

Definition at line 115 of file Material.h.

116 {
117 Material m;
118 m.ambient = Color( 0.0f, 0.01f, 0.0f ); //Color( 0.0215, 0.1745, 0.0215 );
119 m.diffuse = Color( 0.09568, 0.77424, 0.10 );
120 m.specular = Color( 0.9, 1.0, 0.9 ); // Color( 0.633, 0.727811, 0.633 );
121 m.shinyness = 0.6*128.0;
122 m.coef_diffusion = 0.15f;
123 m.coef_reflexion = 0.5f;
124 m.coef_refraction = 0.65f;
125 m.in_refractive_index = 1.5f;
126 m.out_refractive_index = 1.0f;
127 return m;
128 }

◆ glass()

static Material rt::Material::glass ( )
inlinestatic

Definition at line 129 of file Material.h.

130 {
131 Material m;
132 m.ambient = Color( 0.0, 0.0, 0.0 );
133 m.diffuse = Color( 0.95, 0.95, 1.0 );
134 m.specular = Color( 1.0, 1.0, 1.0 );
135 m.shinyness = 80.0f;
136 m.coef_diffusion = 0.01f;
137 m.coef_reflexion = 0.05f;
138 m.coef_refraction = 0.98f;
139 m.in_refractive_index = 1.5f;
140 m.out_refractive_index = 1.0f;
141 return m;
142 }

◆ mix()

static Material rt::Material::mix ( Real  t,
const Material m1,
const Material m2 
)
inlinestatic

Mixes two material (t=0 gives m1, t=1 gives m2, t=0.5 gives their average)

Definition at line 44 of file Material.h.

45 {
46 Material m;
47 Real s = 1.0f - t;
48 m.ambient = s * m1.ambient + t * m2.ambient;
49 m.diffuse = s * m1.diffuse + t * m2.diffuse;
50 m.specular = s * m1.specular + t * m2.specular;
51 m.shinyness = s * m1.shinyness + t * m2.shinyness;
52 m.coef_diffusion = s * m1.coef_diffusion + t * m2.coef_diffusion;
53 m.coef_reflexion = s * m1.coef_reflexion + t * m2.coef_reflexion;
54 m.coef_refraction = s * m1.coef_refraction + t * m2.coef_refraction;
55 m.in_refractive_index = s * m1.in_refractive_index + t * m2.in_refractive_index;
56 m.out_refractive_index = s * m1.out_refractive_index + t * m2.out_refractive_index;
57 return m;
58 }
float Real
the type for representing a real number.

◆ redPlastic()

static Material rt::Material::redPlastic ( )
inlinestatic

Definition at line 86 of file Material.h.

87 {
88 Material m;
89 m.ambient = Color( 0.1, 0.0, 0.0 );
90 m.diffuse = Color( 0.85, 0.05, 0.05 );
91 m.specular = Color( 1.0, 0.8, 0.8 );
92 m.shinyness = 5.0;
93 m.coef_diffusion = 1.0f;
94 m.coef_reflexion = 0.05f;
95 m.coef_refraction = 0.0f;
96 m.in_refractive_index = 1.0f;
97 m.out_refractive_index = 1.0f;
98 return m;
99 }

◆ whitePlastic()

static Material rt::Material::whitePlastic ( )
inlinestatic

Definition at line 72 of file Material.h.

73 {
74 Material m;
75 m.ambient = Color( 0.1, 0.1, 0.1 );
76 m.diffuse = Color( 0.7, 0.7, 0.7 );
77 m.specular = Color( 1.0, 1.0, 0.98 );
78 m.shinyness = 5.0;
79 m.coef_diffusion = 0.9f;
80 m.coef_reflexion = 0.1f;
81 m.coef_refraction = 0.0f;
82 m.in_refractive_index = 1.0f;
83 m.out_refractive_index = 1.0f;
84 return m;
85 }

Member Data Documentation

◆ ambient

Color rt::Material::ambient

ambient color

Definition at line 20 of file Material.h.

◆ coef_diffusion

Real rt::Material::coef_diffusion

The material is perfectly diffuse if coef_diffusion == 1.0, otherwise it may have reflexion / transparency properties.

Definition at line 32 of file Material.h.

◆ coef_reflexion

Real rt::Material::coef_reflexion

The material has some specularity if coef_reflexion > 0.0.

Definition at line 34 of file Material.h.

◆ coef_refraction

Real rt::Material::coef_refraction

The material is transparent if coef_refraction > 0.0.

Definition at line 36 of file Material.h.

◆ diffuse

Color rt::Material::diffuse

diffuse color

Definition at line 22 of file Material.h.

◆ in_refractive_index

Real rt::Material::in_refractive_index

Refractive index (1.0f in vacuum, 1.31 in ice, 1.52 window glass, 1.33 water Inside refractive index (for transparent medium) (>= 1.0f)

Definition at line 39 of file Material.h.

◆ out_refractive_index

Real rt::Material::out_refractive_index

Outside refractive index (1.0f if object is in the air otherwise >= 1.0f)

Definition at line 41 of file Material.h.

◆ shinyness

Real rt::Material::shinyness

shinyness (50: very high, 1: low )

Definition at line 26 of file Material.h.

◆ specular

Color rt::Material::specular

specular color

Definition at line 24 of file Material.h.


The documentation for this struct was generated from the following file: