1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 /*
24  * This file is based on WME.
25  * http://dead-code.org/redir.php?target=wme
26  * Copyright (c) 2003-2013 Jan Nedoma and contributors
27  */
28 
29 #ifndef WINTERMUTE_MATERIAL_H
30 #define WINTERMUTE_MATERIAL_H
31 
32 #include "engines/wintermute/base/base_named_object.h"
33 
34 namespace Wintermute {
35 
36 class BaseSprite;
37 class BaseSurface;
38 class VideoTheoraPlayer;
39 class XFileLexer;
40 
41 struct ColorValue {
rColorValue42 	float &r() {
43 		return data[0];
44 	}
45 
rColorValue46 	float r() const {
47 		return data[0];
48 	}
49 
gColorValue50 	float &g() {
51 		return data[1];
52 	}
53 
gColorValue54 	float g() const {
55 		return data[1];
56 	}
57 
bColorValue58 	float &b() {
59 		return data[2];
60 	}
61 
bColorValue62 	float b() const {
63 		return data[2];
64 	}
65 
aColorValue66 	float &a() {
67 		return data[3];
68 	}
69 
aColorValue70 	float a() const {
71 		return data[3];
72 	}
73 
74 	float data[4];
75 };
76 
77 class Material : public BaseNamedObject {
78 public:
79 	Material(BaseGame *inGame);
80 	virtual ~Material();
81 
82 	ColorValue _diffuse;
83 	ColorValue _ambient;
84 	ColorValue _specular;
85 	ColorValue _emissive;
86 	float _shininess;
87 
88 	bool setTexture(const Common::String &filename, bool adoptName = false);
89 	bool setSprite(BaseSprite *sprite, bool adoptName = false);
90 	bool setTheora(VideoTheoraPlayer *theora, bool adoptName = false);
91 	BaseSurface *getSurface();
92 
93 	bool loadFromX(XFileLexer &lexer, const Common::String &filename);
94 
95 	bool invalidateDeviceObjects();
96 	bool restoreDeviceObjects();
97 
98 private:
99 	Common::String _textureFilename;
100 	BaseSurface *_surface;
101 	bool _ownedSurface;
102 	BaseSprite *_sprite;
103 	VideoTheoraPlayer *_theora;
104 };
105 
106 } // namespace Wintermute
107 
108 #endif
109