This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Light.cpp
68 lines (65 loc) · 2.56 KB
/
Light.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//--------------------------------------------------------------------------------
// This file is a portion of the Hieroglyph 3 Rendering Engine. It is distributed
// under the MIT License, available in the root of this distribution and
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Jason Zink
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
#include "PCH.h"
#include "Light.h"
#include "Scene.h"
#include "ViewPortDX11.h"
//--------------------------------------------------------------------------------
using namespace Glyph3;
//--------------------------------------------------------------------------------
Light::Light() :
Parameters( ),
m_DiffuseWriter( nullptr ),
m_AmbientWriter( nullptr ),
m_SpecularWriter( nullptr )
{
// By initializing these parameters, we gain a handle to the underlying
// parameter writer. We can hang on to the pointer for referencing later on
// when someone wants to change the color of the light or whatever.
m_DiffuseWriter = Parameters.SetVectorParameter( L"Id", Vector4f( 0.5f, 0.5f, 0.5f, 1.0f ) );
m_AmbientWriter = Parameters.SetVectorParameter( L"Ia", Vector4f( 0.25f, 0.25f, 0.25f, 0.25f ) );
m_SpecularWriter = Parameters.SetVectorParameter( L"Is", Vector4f( 1.0f, 1.0f, 1.0f, 1.0f ) );
}
//--------------------------------------------------------------------------------
Light::~Light()
{
}
//--------------------------------------------------------------------------------
void Light::SetDiffuse( const Vector4f& color )
{
m_DiffuseWriter->SetValue( color );
}
//--------------------------------------------------------------------------------
void Light::SetAmbient( const Vector4f& color )
{
m_AmbientWriter->SetValue( color );
}
//--------------------------------------------------------------------------------
void Light::SetSpecular( const Vector4f& color )
{
m_SpecularWriter->SetValue( color );
}
//--------------------------------------------------------------------------------
Vector4f Light::GetDiffuse( ) const
{
return( m_DiffuseWriter->GetValue() );
}
//--------------------------------------------------------------------------------
Vector4f Light::GetAmbient( ) const
{
return( m_AmbientWriter->GetValue() );
}
//--------------------------------------------------------------------------------
Vector4f Light::GetSpecular( ) const
{
return( m_SpecularWriter->GetValue() );
}
//--------------------------------------------------------------------------------