2 * Copyright(c) 2019 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.
21 /// A class encapsulating the property map of the mesh visual.
23 /// <since_tizen> 3 </since_tizen>
24 public class MeshVisual : VisualMap
26 private string _objectURL = null;
27 private string _materialtURL = null;
28 private string _texturesPath = null;
29 private MeshVisualShadingModeValue? _shadingMode = null;
30 private bool? _useMipmapping = null;
31 private bool? _useSoftNormals = null;
32 private Vector3 _lightPosition = null;
37 /// <since_tizen> 3 </since_tizen>
38 public MeshVisual() : base()
43 /// Gets or sets the location of the ".obj" file.<br />
46 /// <since_tizen> 3 </since_tizen>
47 public string ObjectURL
61 /// Gets or sets the location of the ".mtl" file.<br />
62 /// If not specified, then a textureless object is assumed.<br />
65 /// <since_tizen> 3 </since_tizen>
66 public string MaterialtURL
74 _materialtURL = value;
80 /// Gets or sets the path to the directory the textures (including gloss and normal) are stored in.<br />
81 /// Mandatory if using material.<br />
83 /// <since_tizen> 3 </since_tizen>
84 public string TexturesPath
92 _texturesPath = value;
98 /// Gets or sets the type of shading mode that the mesh will use.<br />
99 /// If anything the specified shading mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.<br />
100 /// If not specified, it will use the best it can support (will try MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting first).<br />
103 /// <since_tizen> 3 </since_tizen>
104 public MeshVisualShadingModeValue ShadingMode
108 return _shadingMode ?? (MeshVisualShadingModeValue.TexturedWithDetailedSpecularLighting);
112 _shadingMode = value;
118 /// Gets or sets whether to use mipmaps for textures or not.<br />
119 /// If not specified, the default is true.<br />
122 /// <since_tizen> 3 </since_tizen>
123 public bool UseMipmapping
127 return _useMipmapping ?? (true);
131 _useMipmapping = value;
137 /// Gets or sets whether to average normals at each point to smooth textures or not.<br />
138 /// If not specified, the default is true.<br />
141 /// <since_tizen> 3 </since_tizen>
142 public bool UseSoftNormals
146 return _useSoftNormals ?? (true);
150 _useSoftNormals = value;
156 /// Gets or sets the position, in the stage space, of the point light that applies lighting to the model.<br />
157 /// This is based off the stage's dimensions, so using the width and the height of the stage halved will correspond to the center,
158 /// and using all zeroes will place the light at the top-left corner.<br />
159 /// If not specified, the default is an offset outwards from the center of the screen.<br />
162 /// <since_tizen> 3 </since_tizen>
163 public Vector3 LightPosition
167 return _lightPosition;
171 _lightPosition = value;
177 /// Compose the out visual map.
179 /// <since_tizen> 3 </since_tizen>
180 protected override void ComposingPropertyMap()
182 if (_objectURL != null)
184 _outputVisualMap = new PropertyMap();
185 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Mesh));
186 _outputVisualMap.Add(MeshVisualProperty.ObjectURL, new PropertyValue(_objectURL));
187 if (_materialtURL != null) { _outputVisualMap.Add(MeshVisualProperty.MaterialtURL, new PropertyValue(_materialtURL)); }
188 if (_texturesPath != null) { _outputVisualMap.Add(MeshVisualProperty.TexturesPath, new PropertyValue(_texturesPath)); }
189 if (_shadingMode != null) { _outputVisualMap.Add(MeshVisualProperty.ShadingMode, new PropertyValue((int)_shadingMode)); }
190 if (_useMipmapping != null) { _outputVisualMap.Add(MeshVisualProperty.UseMipmapping, new PropertyValue((bool)_useMipmapping)); }
191 if (_useSoftNormals != null) { _outputVisualMap.Add(MeshVisualProperty.UseSoftNormals, new PropertyValue((bool)_useSoftNormals)); }
192 base.ComposingPropertyMap();