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 primetive visual.
23 /// <since_tizen> 3 </since_tizen>
24 public class PrimitiveVisual : VisualMap
26 private PrimitiveVisualShapeType? _shape = null;
27 private Color _mixColorForPrimitiveVisual = null;
28 private int? _slices = null;
29 private int? _stacks = null;
30 private float? _scaleTopRadius = null;
31 private float? _scaleBottomRadius = null;
32 private float? _scaleHeight = null;
33 private float? _scaleRadius = null;
34 private Vector3 _scaleDimensions = null;
35 private float? _bevelPercentage = null;
36 private float? _bevelSmoothness = null;
37 private Vector3 _lightPosition = null;
42 /// <since_tizen> 3 </since_tizen>
43 public PrimitiveVisual() : base()
48 /// Gets or sets the specific shape to render.<br />
49 /// If not specified, the default is PrimitiveVisualShapeType.Sphere.<br />
52 /// <since_tizen> 3 </since_tizen>
53 public PrimitiveVisualShapeType Shape
57 return _shape ?? (PrimitiveVisualShapeType.Sphere);
67 /// Gets or sets the color of the shape.<br />
68 /// If not specified, the default is Color (0.5, 0.5, 0.5, 1.0).<br />
69 /// Applies to all shapes.<br />
72 /// <since_tizen> 3 </since_tizen>
73 public new Color MixColor
77 return _mixColorForPrimitiveVisual ?? (new Color(0.5f, 0.5f, 0.5f, 1.0f));
81 _mixColorForPrimitiveVisual = value;
87 /// Gets or sets the number of slices as you go around the shape.<br />
88 /// For spheres and conical frustrums, this determines how many divisions there are as you go around the object.<br />
89 /// If not specified, the default is 128.<br />
90 /// The range is from 1 to 255.<br />
93 /// <since_tizen> 3 </since_tizen>
98 return _slices ?? (128);
108 /// Gets or sets the number of stacks as you go down the shape.<br />
109 /// For spheres, 'stacks' determines how many layers there are as you go down the object.<br />
110 /// If not specified, the default is 128.<br />
111 /// The range is from 1 to 255.<br />
114 /// <since_tizen> 3 </since_tizen>
119 return _stacks ?? (128);
129 /// Gets or sets the scale of the radius of the top circle of a conical frustrum.<br />
130 /// If not specified, the default is 1.0f.<br />
131 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br />
132 /// Only values greater than or equal to 0.0f are accepted.<br />
135 /// <since_tizen> 3 </since_tizen>
136 public float ScaleTopRadius
140 return _scaleTopRadius ?? (1.0f);
144 _scaleTopRadius = value;
150 /// Gets or sets the scale of the radius of the bottom circle of a conical frustrum.<br />
151 /// If not specified, the default is 1.5f.<br />
152 /// Applies to: - PrimitiveVisualShapeType.ConicalFrustrum<br />
153 /// - PrimitiveVisualShapeType.Cone<br />
154 /// Only values greater than or equal to 0.0f are accepted.<br />
157 /// <since_tizen> 3 </since_tizen>
158 public float ScaleBottomRadius
162 return _scaleBottomRadius ?? (1.5f);
166 _scaleBottomRadius = value;
172 /// Gets or sets the scale of the height of a conic.<br />
173 /// If not specified, the default is 3.0f.<br />
174 /// Applies to:<br />
175 /// - PrimitiveVisualShapeType.ConicalFrustrum<br />
176 /// - PrimitiveVisualShapeType.Cone<br />
177 /// - PrimitiveVisualShapeType.Cylinder<br />
178 /// Only values greater than or equal to 0.0f are accepted.<br />
181 /// <since_tizen> 3 </since_tizen>
182 public float ScaleHeight
186 return _scaleHeight ?? (3.0f);
190 _scaleHeight = value;
196 /// Gets or sets the scale of the radius of a cylinder.<br />
197 /// If not specified, the default is 1.0f.<br />
198 /// Applies to:<br />
199 /// - PrimitiveVisualShapeType.Cylinder<br />
200 /// Only values greater than or equal to 0.0f are accepted.<br />
203 /// <since_tizen> 3 </since_tizen>
204 public float ScaleRadius
208 return _scaleRadius ?? (1.0f);
212 _scaleRadius = value;
218 /// Gets or sets the dimensions of a cuboid. Scales in the same fashion as a 9-patch image.<br />
219 /// If not specified, the default is Vector3.One.<br />
220 /// Applies to:<br />
221 /// - PrimitiveVisualShapeType.Cube<br />
222 /// - PrimitiveVisualShapeType.Octahedron<br />
223 /// - PrimitiveVisualShapeType.BevelledCube<br />
224 /// Each Vector3 parameter should be greater than or equal to 0.0f.<br />
227 /// <since_tizen> 3 </since_tizen>
228 public Vector3 ScaleDimensions
232 return _scaleDimensions ?? (Vector3.One);
236 _scaleDimensions = value;
242 /// Gets or sets determines how bevelled the cuboid should be, based off the smallest dimension.<br />
243 /// Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube.<br />
244 /// If not specified, the default is 0.0f (no bevel).<br />
245 /// Applies to:<br />
246 /// - PrimitiveVisualShapeType.BevelledCube<br />
247 /// The range is from 0.0f to 1.0f.<br />
250 /// <since_tizen> 3 </since_tizen>
251 public float BevelPercentage
255 return _bevelPercentage ?? (0.0f);
259 _bevelPercentage = value;
265 /// Gets or sets descriptions of how smooth the bevelled edges should be.<br />
266 /// If not specified, the default is 0.0f (sharp edges).<br />
267 /// Applies to:<br />
268 /// - PrimitiveVisualShapeType.BevelledCube<br />
269 /// The range is from 0.0f to 1.0f.<br />
272 /// <since_tizen> 3 </since_tizen>
273 public float BevelSmoothness
277 return _bevelSmoothness ?? (0.0f);
281 _bevelSmoothness = value;
287 /// Gets or sets the position, in the stage space, of the point light that applies lighting to the model.<br />
288 /// This is based off the stage's dimensions, so using the width and the height of the stage halved will correspond to the center,
289 /// and using all zeroes will place the light at the top-left corner.<br />
290 /// If not specified, the default is an offset outwards from the center of the screen.<br />
291 /// Applies to all shapes.<br />
294 /// <since_tizen> 3 </since_tizen>
295 public Vector3 LightPosition
299 return _lightPosition;
303 _lightPosition = value;
309 /// Compose the out visual map.
311 /// <since_tizen> 3 </since_tizen>
312 protected override void ComposingPropertyMap()
314 _outputVisualMap = new PropertyMap(); ;
315 _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Primitive));
316 if (_shape != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Shape, new PropertyValue((int)_shape)); }
317 if (_mixColorForPrimitiveVisual != null) { _outputVisualMap.Add(PrimitiveVisualProperty.MixColor, new PropertyValue(_mixColorForPrimitiveVisual)); }
318 if (_slices != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Slices, new PropertyValue((int)_slices)); }
319 if (_stacks != null) { _outputVisualMap.Add(PrimitiveVisualProperty.Stacks, new PropertyValue((int)_stacks)); }
320 if (_scaleTopRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleTopRadius, new PropertyValue((float)_scaleTopRadius)); }
321 if (_scaleBottomRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleBottomRadius, new PropertyValue((float)_scaleBottomRadius)); }
322 if (_scaleHeight != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleHeight, new PropertyValue((float)_scaleHeight)); }
323 if (_scaleRadius != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleRadius, new PropertyValue((float)_scaleRadius)); }
324 if (_scaleDimensions != null) { _outputVisualMap.Add(PrimitiveVisualProperty.ScaleDimensions, new PropertyValue(_scaleDimensions)); }
325 if (_bevelPercentage != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelPercentage, new PropertyValue((float)_bevelPercentage)); }
326 if (_bevelSmoothness != null) { _outputVisualMap.Add(PrimitiveVisualProperty.BevelSmoothness, new PropertyValue((float)_bevelSmoothness)); }
327 if (_lightPosition != null) { _outputVisualMap.Add(PrimitiveVisualProperty.LightPosition, new PropertyValue(_lightPosition)); }
328 base.ComposingPropertyMap();