absence_thelab

view src/3deng/material.cpp @ 0:1cffe3409164

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 01:46:07 +0300
parents
children
line source
1 #include "material.h"
3 Material::Material() {
4 memset(this, 0, sizeof(Material));
5 Diffuse.r = Ambient.r = 1.0f;
6 Diffuse.g = Ambient.g = 1.0f;
7 Diffuse.b = Ambient.b = 1.0f;
8 Diffuse.a = Ambient.a = 1.0f;
9 Specular.r = Specular.g = Specular.b = 1.0f;
10 EnvBlend = 1.0f;
11 Alpha = 1.0f;
12 }
14 Material::Material(float r, float g, float b, float a) {
16 memset(this, 0, sizeof(Material));
17 Diffuse.r = Ambient.r = r;
18 Diffuse.g = Ambient.g = g;
19 Diffuse.b = Ambient.b = b;
20 Diffuse.a = Ambient.a = a;
21 Specular.r = Specular.g = Specular.b = 1.0f;
22 EnvBlend = 1.0f;
23 Alpha = 1.0f;
24 }
26 void Material::SetAmbient(float r, float g, float b) {
27 Ambient.r = r;
28 Ambient.g = g;
29 Ambient.b = b;
30 Ambient.a = 1.0f;
31 }
33 void Material::SetAmbient(const Color &col) {
34 Ambient.r = col.r;
35 Ambient.g = col.g;
36 Ambient.b = col.b;
37 Ambient.a = col.a;
38 }
41 void Material::SetDiffuse(float r, float g, float b) {
42 Diffuse.r = r;
43 Diffuse.g = g;
44 Diffuse.b = b;
45 Diffuse.a = 1.0f;
46 }
48 void Material::SetDiffuse(const Color &col) {
49 Diffuse.r = col.r;
50 Diffuse.g = col.g;
51 Diffuse.b = col.b;
52 Diffuse.a = col.a;
53 }
56 void Material::SetSpecular(float r, float g, float b) {
57 Specular.r = r;
58 Specular.g = g;
59 Specular.b = b;
60 Specular.a = 1.0f;
61 }
63 void Material::SetSpecular(const Color &col) {
64 Specular.r = col.r;
65 Specular.g = col.g;
66 Specular.b = col.b;
67 Specular.a = col.a;
68 }
70 void Material::SetEmissive(float r, float g, float b) {
71 Emissive.r = r;
72 Emissive.g = g;
73 Emissive.b = b;
74 Emissive.a = 1.0f;
75 }
77 void Material::SetEmissive(const Color &col) {
78 Emissive.r = col.r;
79 Emissive.g = col.g;
80 Emissive.b = col.b;
81 Emissive.a = col.a;
82 }
84 void Material::SetEnvBlend(float value) {
85 EnvBlend = value;
86 }
88 void Material::SetSpecularPower(float pow) {
89 Power = pow;
90 SpecularEnable = pow > 0.0f ? true : false;
91 }
93 void Material::SetAlpha(float alpha) {
94 Alpha = alpha;
95 }
97 void Material::SetTexture(Texture *texture, TextureType type) {
98 Maps[type] = texture;
99 }