2009-12-03 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / projection.cpp
blob07287ceb7756eacc4d1f187c8302e808e9798f43
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * projection.cpp:
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2009 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
13 #include <config.h>
15 #include <math.h>
16 #include <string.h>
18 #include "projection.h"
19 #include "eventargs.h"
22 // Matrix3D
25 Matrix3D::Matrix3D ()
27 SetObjectType (Type::MATRIX3D);
29 // initialize the matrix as the identity
30 memset (matrix, 0, sizeof (double) * 16);
31 matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.0;
34 void
35 Matrix3D::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
37 if (args->GetProperty ()->GetOwnerType() != Type::MATRIX3D) {
38 DependencyObject::OnPropertyChanged (args, error);
39 return;
42 if (args->GetId () == Matrix3D::M11Property)
43 matrix[0] = args->GetNewValue()->AsDouble ();
44 else if (args->GetId () == Matrix3D::M12Property)
45 matrix[1] = args->GetNewValue()->AsDouble ();
46 else if (args->GetId () == Matrix3D::M13Property)
47 matrix[2] = args->GetNewValue()->AsDouble ();
48 else if (args->GetId () == Matrix3D::M14Property)
49 matrix[3] = args->GetNewValue()->AsDouble ();
50 else if (args->GetId () == Matrix3D::M21Property)
51 matrix[4] = args->GetNewValue()->AsDouble ();
52 else if (args->GetId () == Matrix3D::M22Property)
53 matrix[5] = args->GetNewValue()->AsDouble ();
54 else if (args->GetId () == Matrix3D::M23Property)
55 matrix[6] = args->GetNewValue()->AsDouble ();
56 else if (args->GetId () == Matrix3D::M24Property)
57 matrix[7] = args->GetNewValue()->AsDouble ();
58 else if (args->GetId () == Matrix3D::M31Property)
59 matrix[8] = args->GetNewValue()->AsDouble ();
60 else if (args->GetId () == Matrix3D::M32Property)
61 matrix[9] = args->GetNewValue()->AsDouble ();
62 else if (args->GetId () == Matrix3D::M33Property)
63 matrix[10] = args->GetNewValue()->AsDouble ();
64 else if (args->GetId () == Matrix3D::M34Property)
65 matrix[11] = args->GetNewValue()->AsDouble ();
66 else if (args->GetId () == Matrix3D::OffsetXProperty)
67 matrix[12] = args->GetNewValue()->AsDouble ();
68 else if (args->GetId () == Matrix3D::OffsetYProperty)
69 matrix[13] = args->GetNewValue()->AsDouble ();
70 else if (args->GetId () == Matrix3D::OffsetZProperty)
71 matrix[14] = args->GetNewValue()->AsDouble ();
72 else if (args->GetId () == Matrix3D::M44Property)
73 matrix[15] = args->GetNewValue()->AsDouble ();
75 NotifyListenersOfPropertyChange (args, error);