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.
21 internal class Matrix : global::System.IDisposable
23 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24 protected bool swigCMemOwn;
26 internal Matrix(global::System.IntPtr cPtr, bool cMemoryOwn)
28 swigCMemOwn = cMemoryOwn;
29 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Matrix obj)
34 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 //A Flag to check who called Dispose(). (By User or DisposeQueue)
39 private bool isDisposeQueued = false;
40 //A Flat to check if it is already disposed.
41 protected bool disposed = false;
48 isDisposeQueued = true;
49 DisposeQueue.Instance.Add(this);
55 //Throw excpetion if Dispose() is called in separate thread.
56 if (!Window.IsInstalled())
58 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
63 Dispose(DisposeTypes.Implicit);
67 Dispose(DisposeTypes.Explicit);
68 System.GC.SuppressFinalize(this);
72 protected virtual void Dispose(DisposeTypes type)
79 if (type == DisposeTypes.Explicit)
82 //Release your own managed resources here.
83 //You should release all of your own disposable objects here.
87 //Release your own unmanaged resources here.
88 //You should not access any managed member here except static instance.
89 //because the execution order of Finalizes is non-deterministic.
91 if (swigCPtr.Handle != global::System.IntPtr.Zero)
96 NDalicPINVOKE.delete_Matrix(swigCPtr);
98 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
105 public static Vector4 operator *(Matrix arg1, Vector4 arg2)
107 return arg1.Multiply(arg2);
110 public Matrix() : this(NDalicPINVOKE.new_Matrix__SWIG_0(), true)
112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 public Matrix(bool initialize) : this(NDalicPINVOKE.new_Matrix__SWIG_1(initialize), true)
117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120 public Matrix(float[] array) : this(NDalicPINVOKE.new_Matrix__SWIG_2(array), true)
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 public Matrix(Rotation rotation) : this(NDalicPINVOKE.new_Matrix__SWIG_3(Rotation.getCPtr(rotation)), true)
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 public Matrix(Matrix matrix) : this(NDalicPINVOKE.new_Matrix__SWIG_4(Matrix.getCPtr(matrix)), true)
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 public Matrix Assign(Matrix matrix)
137 Matrix ret = new Matrix(NDalicPINVOKE.Matrix_Assign(swigCPtr, Matrix.getCPtr(matrix)), false);
138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 public static Matrix IDENTITY
146 global::System.IntPtr cPtr = NDalicPINVOKE.Matrix_IDENTITY_get();
147 Matrix ret = (cPtr == global::System.IntPtr.Zero) ? null : new Matrix(cPtr, false);
148 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153 public void SetIdentity()
155 NDalicPINVOKE.Matrix_SetIdentity(swigCPtr);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159 public void SetIdentityAndScale(Vector3 scale)
161 NDalicPINVOKE.Matrix_SetIdentityAndScale(swigCPtr, Vector3.getCPtr(scale));
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public void InvertTransform(Matrix result)
167 NDalicPINVOKE.Matrix_InvertTransform(swigCPtr, Matrix.getCPtr(result));
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 bool ret = NDalicPINVOKE.Matrix_Invert(swigCPtr);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 public void Transpose()
180 NDalicPINVOKE.Matrix_Transpose(swigCPtr);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 public Vector3 GetXAxis()
186 Vector3 ret = new Vector3(NDalicPINVOKE.Matrix_GetXAxis(swigCPtr), true);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 public Vector3 GetYAxis()
193 Vector3 ret = new Vector3(NDalicPINVOKE.Matrix_GetYAxis(swigCPtr), true);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 public Vector3 GetZAxis()
200 Vector3 ret = new Vector3(NDalicPINVOKE.Matrix_GetZAxis(swigCPtr), true);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 public void SetXAxis(Vector3 axis)
207 NDalicPINVOKE.Matrix_SetXAxis(swigCPtr, Vector3.getCPtr(axis));
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 public void SetYAxis(Vector3 axis)
213 NDalicPINVOKE.Matrix_SetYAxis(swigCPtr, Vector3.getCPtr(axis));
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 public void SetZAxis(Vector3 axis)
219 NDalicPINVOKE.Matrix_SetZAxis(swigCPtr, Vector3.getCPtr(axis));
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 public Vector4 GetTranslation()
225 Vector4 ret = new Vector4(NDalicPINVOKE.Matrix_GetTranslation(swigCPtr), false);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 public Vector3 GetTranslation3()
232 Vector3 ret = new Vector3(NDalicPINVOKE.Matrix_GetTranslation3(swigCPtr), false);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 public void SetTranslation(Vector4 translation)
239 NDalicPINVOKE.Matrix_SetTranslation__SWIG_0(swigCPtr, Vector4.getCPtr(translation));
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 public void SetTranslation(Vector3 translation)
245 NDalicPINVOKE.Matrix_SetTranslation__SWIG_1(swigCPtr, Vector3.getCPtr(translation));
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 public void OrthoNormalize()
251 NDalicPINVOKE.Matrix_OrthoNormalize(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 public SWIGTYPE_p_float AsFloat()
257 global::System.IntPtr cPtr = NDalicPINVOKE.Matrix_AsFloat__SWIG_0(swigCPtr);
258 SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 public static void Multiply(Matrix result, Matrix lhs, Matrix rhs)
265 NDalicPINVOKE.Matrix_Multiply__SWIG_0(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Matrix.getCPtr(rhs));
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 public static void Multiply(Matrix result, Matrix lhs, Rotation rhs)
271 NDalicPINVOKE.Matrix_Multiply__SWIG_1(Matrix.getCPtr(result), Matrix.getCPtr(lhs), Rotation.getCPtr(rhs));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 public Vector4 Multiply(Vector4 rhs)
277 Vector4 ret = new Vector4(NDalicPINVOKE.Matrix_Multiply__SWIG_2(swigCPtr, Vector4.getCPtr(rhs)), true);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 public bool EqualTo(Matrix rhs)
284 bool ret = NDalicPINVOKE.Matrix_EqualTo(swigCPtr, Matrix.getCPtr(rhs));
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 public bool NotEqualTo(Matrix rhs)
291 bool ret = NDalicPINVOKE.Matrix_NotEqualTo(swigCPtr, Matrix.getCPtr(rhs));
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 public void SetTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
298 NDalicPINVOKE.Matrix_SetTransformComponents(swigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 public void SetInverseTransformComponents(Vector3 scale, Rotation rotation, Vector3 translation)
304 NDalicPINVOKE.Matrix_SetInverseTransformComponents__SWIG_0(swigCPtr, Vector3.getCPtr(scale), Rotation.getCPtr(rotation), Vector3.getCPtr(translation));
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 public void SetInverseTransformComponents(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 translation)
310 NDalicPINVOKE.Matrix_SetInverseTransformComponents__SWIG_1(swigCPtr, Vector3.getCPtr(xAxis), Vector3.getCPtr(yAxis), Vector3.getCPtr(zAxis), Vector3.getCPtr(translation));
311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 public void GetTransformComponents(Vector3 position, Rotation rotation, Vector3 scale)
316 NDalicPINVOKE.Matrix_GetTransformComponents(swigCPtr, Vector3.getCPtr(position), Rotation.getCPtr(rotation), Vector3.getCPtr(scale));
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();