/[gr2lib]/trunk/gr2lib/core/coretypes/implementation/Bone.cs
ViewVC logotype

Contents of /trunk/gr2lib/core/coretypes/implementation/Bone.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (show annotations) (download)
Sat Jul 24 04:16:43 2010 UTC (9 years, 3 months ago) by william
File size: 5364 byte(s)
continue to add xml documentation

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using gr2lib.core.interfaces;
6 using gr2lib.core.helpers;
7 using System.Diagnostics;
8 using gr2lib.core.exceptions;
9 using gr2lib.core.ui.helpers;
10
11 namespace gr2lib.core.coretypes.implementation
12 {
13 /// <summary>
14 /// Bone Class
15 /// </summary>
16 public class Bone : GrannyRigParentResource,IBone
17 {
18 /// <summary>
19 /// default constructor
20 /// </summary>
21 public Bone() : base("Bones")
22 {
23 this.BoneName = "rootBone";
24 this.ParentIndex = -1;
25 this.Transform = new Transform();
26 this.InverseWorldTransform = new Matrix44();
27 this.LightInfo = new LightInfo();
28 this.CameraInfo = new CameraInfo();
29 this.LodError = 0;
30 }
31
32 internal static Bone ReadFromMemory(IntPtr pointer)
33 {
34 try
35 {
36 if (pointer == IntPtr.Zero) return null;
37 native.Bone native = Helpers.ReadFromMemory<native.Bone>(pointer);
38 Bone managed = Bone.ReadFromNative(native);
39 managed.NativePointer = pointer;
40 return managed;
41 }
42 catch (Exception ex)
43 {
44 StackTrace st = new StackTrace(true);
45 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
46 Granny2ExceptionWriter.WriteToConsole(ex,st);
47 #endif
48 return default(Bone);
49 }
50 }
51
52 internal static Bone ReadFromNative(native.Bone native)
53 {
54 try
55 {
56 Bone managed = new Bone();
57 managed.BoneName = string.IsNullOrEmpty(native.Name) ? "{null}" : native.Name;
58 managed.ParentIndex = native.ParentIndex;
59 managed.Transform = Transform.ReadFromNative(native.Transform);
60 //managed.InverseWorldTransformNode.Matrix = new Geom.Matrix44(native.InverseWorldTransform);
61 managed.LodError = native.LodError;
62 managed.LightInfo = LightInfo.ReadFromMemory(native.LightInfo);
63 managed.CameraInfo = CameraInfo.ReadFromMemory(native.CameraInfo);
64 //managed.ExtendedData = native.ExtendedData;
65
66 return managed;
67 }
68 catch (Exception ex)
69 {
70 StackTrace st = new StackTrace(true);
71 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
72 Granny2ExceptionWriter.WriteToConsole(ex,st);
73 #endif
74 return default(Bone);
75 }
76 }
77
78 #region IBone Members
79
80 private string _BoneName;
81 private int _ParentIndex;
82 private Transform _Transform;
83 private Matrix44 _InverseWorldTransform;
84 private LightInfo _LightInfo;
85 private CameraInfo _CameraInfo;
86 private int _LodError;
87
88
89 /// <summary>
90 /// Get/set the bone name
91 /// </summary>
92 public string BoneName { get { return _BoneName; } set { _BoneName = value; } }
93 /// <summary>
94 /// Get/set the ParentIndex
95 /// </summary>
96 public int ParentIndex { get { return _ParentIndex; } set { _ParentIndex = value; } }
97 /// <summary>
98 /// Get/set the Transform
99 /// </summary>
100 public Transform Transform { get { return _Transform; } set { _Transform = value; } }
101 /// <summary>
102 /// Get/set the InverseWorldTransform
103 /// </summary>
104 public Matrix44 InverseWorldTransform { get { return _InverseWorldTransform; } set { _InverseWorldTransform = value; } }
105
106 /// <summary>
107 /// Get a value indicating if this instance has LightInfo
108 /// </summary>
109 public bool HasLightInfo { get { if (this.LightInfo == null) { return false; } else { return true; } } }
110 /// <summary>
111 /// Get a value indicating if this instance has CameraInfo
112 /// </summary>
113 public bool HasCameraInfo { get { if (this.CameraInfo == null) { return false; } else { return true; } } }
114
115 /// <summary>
116 /// Get/set the LightInfo
117 /// </summary>
118 public LightInfo LightInfo { get { return _LightInfo; } set { _LightInfo = value; } }
119 /// <summary>
120 /// Get/set the CameraInfo
121 /// </summary>
122 public CameraInfo CameraInfo { get { return _CameraInfo; } set { _CameraInfo = value; } }
123 /// <summary>
124 /// Get/set the LodError
125 /// </summary>
126 public int LodError { get { return _LodError; } set { _LodError = value; } }
127 #endregion
128
129 #region INativePointer Members
130 private IntPtr _NativePointer;
131 /// <summary>
132 /// When used in a derived class, gets the native pointer for this instance
133 /// </summary>
134 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
135 #endregion
136
137 #region IExtendedData Members
138 private IntPtr _ExtendedData;
139 /// <summary>
140 /// When used in a derived class, gets the ExtendedData pointer for this instance
141 /// </summary>
142 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
143 #endregion
144 }
145 }

  ViewVC Help
Powered by ViewVC 1.1.22