PageRenderTime 65ms CodeModel.GetById 58ms app.highlight 5ms RepoModel.GetById 0ms app.codeStats 0ms

/opengles/src/Material.cpp

http://ftk.googlecode.com/
C++ | 84 lines | 24 code | 20 blank | 40 comment | 0 complexity | ad27dbb5ddc68a62d694dcb9bb1f4a3d MD5 | raw file
 1// ==========================================================================
 2//
 3// material.cpp	Rendering Context Class for 3D Rendering Library
 4//
 5//				Coloring and Material Related Operations
 6//
 7// --------------------------------------------------------------------------
 8//
 9// 08-07-2003	Hans-Martin Will	initial version
10//
11// --------------------------------------------------------------------------
12//
13// Copyright (c) 2004, Hans-Martin Will. All rights reserved.
14// 
15// Redistribution and use in source and binary forms, with or without 
16// modification, are permitted provided that the following conditions are 
17// met:
18// 
19//	 *  Redistributions of source code must retain the above copyright
20// 		notice, this list of conditions and the following disclaimer. 
21//   *	Redistributions in binary form must reproduce the above copyright
22// 		notice, this list of conditions and the following disclaimer in the 
23// 		documentation and/or other materials provided with the distribution. 
24// 
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
28// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
29// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
30// OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
31// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
33// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
35// THE POSSIBILITY OF SUCH DAMAGE.
36//
37// ==========================================================================
38
39
40#include "stdafx.h"
41#include "Material.h"
42
43
44using namespace EGL;
45
46
47// ==========================================================================
48// Material Class Members
49// ==========================================================================
50
51
52Material :: Material():
53	m_AmbientColor(F(0.2f), F(0.2f), F(0.2f), F(1.0f)),
54	m_DiffuseColor(F(0.8f), F(0.8f), F(0.8f), F(1.0f)),
55	m_SpecularExponent(0)
56{
57}
58
59void Material :: SetAmbientColor(const FractionalColor & color) {
60	m_AmbientColor = color;
61}
62
63
64void Material :: SetDiffuseColor(const FractionalColor & color) {
65	m_DiffuseColor = color;
66}
67
68
69void Material :: SetSpecularColor(const FractionalColor & color) {
70	m_SpecularColor = color;
71}
72
73
74void Material :: SetEmissiveColor(const FractionalColor & color) {
75	m_EmissiveColor = color;
76}
77
78
79void Material :: SetSpecularExponent(EGL_Fixed exponent) {
80	m_SpecularExponent = EGL_CLAMP(exponent, 0, EGL_FixedFromInt(128));
81}
82
83
84