2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/modeling/material.h>
22 #include <dali/internal/event/modeling/material-impl.h>
27 const float Material::DEFAULT_OPACITY = 1.0f;
28 const float Material::DEFAULT_SHININESS = 0.5f;
29 const Vector4 Material::DEFAULT_AMBIENT_COLOR(0.2f, 0.2f, 0.2f, 1.0f);
30 const Vector4 Material::DEFAULT_DIFFUSE_COLOR (0.8f, 0.8f, 0.8f, 1.0f);
31 const Vector4 Material::DEFAULT_SPECULAR_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
32 const Vector4 Material::DEFAULT_EMISSIVE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
33 const Material::MappingMode Material::DEFAULT_MAPPING_MODE = Material::MAPPING_MODE_WRAP;
34 const size_t Material::DEFAULT_DIFFUSE_UV_INDEX = 0;
35 const size_t Material::DEFAULT_OPACITY_UV_INDEX = 0;
36 const size_t Material::DEFAULT_NORMAL_UV_INDEX = 0;
37 const bool Material::DEFAULT_HAS_HEIGHT_MAP = false;
40 Material Material::New(const std::string& name)
42 Internal::Material* internal = Internal::Material::New(name);
44 return Material(internal);
47 Material Material::DownCast( BaseHandle handle )
49 return Material( dynamic_cast<Dali::Internal::Material*>(handle.GetObjectPtr()) );
52 Material::Material(Internal::Material* internal)
53 : BaseHandle(internal)
65 Material::Material(const Material& handle)
70 Material& Material::operator=(const Material& rhs)
72 BaseHandle::operator=(rhs);
76 void Material::SetName(const std::string& name)
78 GetImplementation(*this).SetName(name);
81 const std::string& Material::GetName() const
83 return GetImplementation(*this).GetName();
86 void Material::SetOpacity(const float opacity)
88 GetImplementation(*this).SetOpacity(opacity);
91 float Material::GetOpacity() const
93 return GetImplementation(*this).GetOpacity();
96 void Material::SetShininess(const float shininess)
98 GetImplementation(*this).SetShininess(shininess);
101 float Material::GetShininess() const
103 return GetImplementation(*this).GetShininess();
106 void Material::SetAmbientColor(const Vector4& color)
108 GetImplementation(*this).SetAmbientColor(color);
111 const Vector4& Material::GetAmbientColor() const
113 return GetImplementation(*this).GetAmbientColor();
116 void Material::SetDiffuseColor(const Vector4& color)
118 GetImplementation(*this).SetDiffuseColor(color);
121 const Vector4& Material::GetDiffuseColor() const
123 return GetImplementation(*this).GetDiffuseColor();
126 void Material::SetSpecularColor(const Vector4& color)
128 GetImplementation(*this).SetSpecularColor(color);
131 const Vector4& Material::GetSpecularColor() const
133 return GetImplementation(*this).GetSpecularColor();
136 void Material::SetEmissiveColor(const Vector4& color)
138 GetImplementation(*this).SetEmissiveColor(color);
141 const Vector4& Material::GetEmissiveColor() const
143 return GetImplementation(*this).GetEmissiveColor();
146 void Material::SetDiffuseTexture(Image image)
148 GetImplementation(*this).SetDiffuseTexture(image);
151 Image Material::GetDiffuseTexture() const
153 return GetImplementation(*this).GetDiffuseTexture();
156 void Material::SetOpacityTexture(Image image)
158 GetImplementation(*this).SetOpacityTexture(image);
161 Image Material::GetOpacityTexture() const
163 return GetImplementation(*this).GetOpacityTexture();
166 void Material::SetNormalMap(Image image)
168 GetImplementation(*this).SetNormalMap(image);
171 Image Material::GetNormalMap() const
173 return GetImplementation(*this).GetNormalMap();
176 void Material::SetMapU(const unsigned int map)
178 GetImplementation(*this).SetMapU(map);
181 unsigned int Material::GetMapU() const
183 return GetImplementation(*this).GetMapU();
186 void Material::SetMapV(const unsigned int map)
188 GetImplementation(*this).SetMapV(map);
191 unsigned int Material::GetMapV() const
193 return GetImplementation(*this).GetMapV();
196 void Material::SetDiffuseUVIndex(const int index)
198 GetImplementation(*this).SetDiffuseUVIndex(index);
201 unsigned int Material::GetDiffuseUVIndex() const
203 return GetImplementation(*this).GetDiffuseUVIndex();
206 void Material::SetOpacityUVIndex(const int index)
208 GetImplementation(*this).SetOpacityUVIndex(index);
211 unsigned int Material::GetOpacityUVIndex() const
213 return GetImplementation(*this).GetOpacityUVIndex();
216 void Material::SetNormalUVIndex(const int index)
218 GetImplementation(*this).SetNormalUVIndex(index);
221 unsigned int Material::GetNormalUVIndex() const
223 return GetImplementation(*this).GetNormalUVIndex();
226 void Material::SetHasHeightMap(const bool flag)
228 GetImplementation(*this).SetHasHeightMap(flag);
231 bool Material::GetHasHeightMap() const
233 return GetImplementation(*this).GetHasHeightMap();
237 void Material::SetDiffuseTextureFileName(const std::string filename)
239 GetImplementation(*this).SetDiffuseTextureFileName(filename);
241 const std::string& Material::GetDiffuseFileName() const
243 return GetImplementation(*this).GetDiffuseTextureFileName();
245 void Material::SetOpacityTextureFileName(const std::string filename)
247 GetImplementation(*this).SetOpacityTextureFileName(filename);
249 const std::string& Material::GetOpacityTextureFileName() const
251 return GetImplementation(*this).GetOpacityTextureFileName();
253 void Material::SetNormalMapFileName(const std::string filename)
255 GetImplementation(*this).SetNormalMapFileName(filename);
257 const std::string& Material::GetNormalMapFileName() const
259 return GetImplementation(*this).GetNormalMapFileName();