2 * Copyright (c) 2017 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.
23 /// RelativeVector3 is a three-dimensional vector.
24 /// All values (x, y, z and w) should be between [0, 1].
26 public class RelativeVector3 : global::System.IDisposable
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 protected bool swigCMemOwn;
31 internal RelativeVector3(global::System.IntPtr cPtr, bool cMemoryOwn)
33 swigCMemOwn = cMemoryOwn;
34 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RelativeVector3 obj)
39 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 //A Flag to check who called Dispose(). (By User or DisposeQueue)
43 private bool isDisposeQueued = false;
44 //A Flat to check if it is already disposed.
45 protected bool disposed = false;
51 isDisposeQueued = true;
52 DisposeQueue.Instance.Add(this);
58 //Throw excpetion if Dispose() is called in separate thread.
59 if (!Window.IsInstalled())
61 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
66 Dispose(DisposeTypes.Implicit);
70 Dispose(DisposeTypes.Explicit);
71 System.GC.SuppressFinalize(this);
75 protected virtual void Dispose(DisposeTypes type)
82 if(type == DisposeTypes.Explicit)
85 //Release your own managed resources here.
86 //You should release all of your own disposable objects here.
89 //Release your own unmanaged resources here.
90 //You should not access any managed member here except static instance.
91 //because the execution order of Finalizes is non-deterministic.
93 if (swigCPtr.Handle != global::System.IntPtr.Zero)
98 NDalicPINVOKE.delete_Vector3(swigCPtr);
100 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
107 /// The addition operator.
109 /// <param name="arg1">The vector to add.</param>
110 /// <param name="arg2">Th vector to add.</param>
111 /// <returns>The vector containing the result of the addition.</returns>
112 public static RelativeVector3 operator +(RelativeVector3 arg1, RelativeVector3 arg2)
114 RelativeVector3 result = arg1.Add(arg2);
120 /// The subtraction operator.
122 /// <param name="arg1">The vector to subtract.</param>
123 /// <param name="arg2">The vector to subtract.</param>
124 /// <returns>The vector containing the result of the subtraction.</returns>
125 public static RelativeVector3 operator -(RelativeVector3 arg1, RelativeVector3 arg2)
127 RelativeVector3 result = arg1.Subtract(arg2);
133 /// The multiplication operator.
135 /// <param name="arg1">The vector to multiply.</param>
136 /// <param name="arg2">The vector to multiply.</param>
137 /// <returns>The vector containing the result of the multiplication.</returns>
138 public static RelativeVector3 operator *(RelativeVector3 arg1, RelativeVector3 arg2)
140 RelativeVector3 result = arg1.Multiply(arg2);
146 /// The multiplication operator.
148 /// <param name="arg1">The vector to multiply.</param>
149 /// <param name="arg2">The float value to scale the vector.</param>
150 /// <returns>The vector containing the result of the scaling.</returns>
151 public static RelativeVector3 operator *(RelativeVector3 arg1, float arg2)
153 RelativeVector3 result = arg1.Multiply(arg2);
159 /// The division operator.
161 /// <param name="arg1">The vector to divide.</param>
162 /// <param name="arg2">The vector to divide.</param>
163 /// <returns>The vector containing the result of the division.</returns>
164 public static RelativeVector3 operator /(RelativeVector3 arg1, RelativeVector3 arg2)
166 RelativeVector3 result = arg1.Divide(arg2);
172 /// The division operator.
174 /// <param name="arg1">The vector to divide.</param>
175 /// <param name="arg2">The float value to scale the vector by.</param>
176 /// <returns>The vector containing the result of the scaling.</returns>
177 public static RelativeVector3 operator /(RelativeVector3 arg1, float arg2)
179 RelativeVector3 result = arg1.Divide(arg2);
186 /// The const array subscript operator overload. Should be 0, 1 or 2.
188 /// <param name="index">The subscript index.</param>
189 /// <returns>The float at the given index.</returns>
190 public float this[uint index]
194 return ValueOfIndex(index);
200 internal static RelativeVector3 GetRelativeVector3FromPtr(global::System.IntPtr cPtr)
202 RelativeVector3 ret = new RelativeVector3(cPtr, false);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 public RelativeVector3() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// <param name="x">The x component.</param>
220 /// <param name="y">The y component.</param>
221 /// <param name="z">The z component.</param>
222 public RelativeVector3(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// <param name="relativeVector2">The RelativeVector2 to create this vector from.</param>
234 public RelativeVector3(RelativeVector2 relativeVector2) : this(NDalicPINVOKE.new_Vector3__SWIG_3(RelativeVector2.getCPtr(relativeVector2)), true)
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// <param name="relativeVector4">The RelativeVector4 to create this vector from.</param>
243 public RelativeVector3(RelativeVector4 relativeVector4) : this(NDalicPINVOKE.new_Vector3__SWIG_4(RelativeVector4.getCPtr(relativeVector4)), true)
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 private RelativeVector3 Add(RelativeVector3 rhs)
251 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Add(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 private RelativeVector3 Subtract(RelativeVector3 rhs)
258 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 private RelativeVector3 Multiply(RelativeVector3 rhs)
265 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270 private RelativeVector3 Multiply(float rhs)
272 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277 private RelativeVector3 Divide(RelativeVector3 rhs)
279 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, RelativeVector3.getCPtr(rhs)), true);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 private RelativeVector3 Divide(float rhs)
286 RelativeVector3 ret = new RelativeVector3(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291 private float ValueOfIndex(uint index)
293 float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 /// Compares if the rhs is equal to.
301 /// <param name="rhs">The vector to compare.</param>
302 /// <returns>Returns true if the two vectors are equal, otherwise false.</returns>
303 public bool EqualTo(RelativeVector3 rhs)
305 bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 /// Compares if the rhs is not equal to.
313 /// <param name="rhs">The vector to compare.</param>
314 /// <returns>Returns true if the two vectors are not equal, otherwise false.</returns>
315 public bool NotEqualTo(RelativeVector3 rhs)
317 bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, RelativeVector3.getCPtr(rhs));
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
331 NDalicPINVOKE.Vector3_X_set(swigCPtr, value);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 float ret = NDalicPINVOKE.Vector3_X_get(swigCPtr);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 NDalicPINVOKE.Vector3_Y_set(swigCPtr, value);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355 float ret = NDalicPINVOKE.Vector3_Y_get(swigCPtr);
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 NDalicPINVOKE.Vector3_Z_set(swigCPtr, value);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 float ret = NDalicPINVOKE.Vector3_Z_get(swigCPtr);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382 public static implicit operator Vector3(RelativeVector3 relativeVector3)
384 return new Vector3(relativeVector3.X, relativeVector3.Y, relativeVector3.Z);
389 public static implicit operator RelativeVector3(Vector3 vec)
394 return new RelativeVector3(vec.X, vec.Y, vec.Z);
397 internal static void ValueCheck(RelativeVector3 relativeVector3)
399 if(relativeVector3.X < 0.0f)
401 relativeVector3.X = 0.0f;
402 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
404 else if(relativeVector3.X > 1.0f)
406 relativeVector3.X = 1.0f;
407 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
409 if(relativeVector3.Y < 0.0f)
411 relativeVector3.Y = 0.0f;
412 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
414 else if(relativeVector3.Y > 1.0f)
416 relativeVector3.Y = 1.0f;
417 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
419 if(relativeVector3.Z < 0.0f)
421 relativeVector3.Z = 0.0f;
422 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
424 else if(relativeVector3.Z > 1.0f)
426 relativeVector3.Z = 1.0f;
427 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
431 internal static void ValueCheck(float value)
436 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
438 else if(value > 1.0f)
441 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");