/[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 102 - (show annotations) (download)
Sat Jul 17 13:54:18 2010 UTC (9 years, 2 months ago) by william
File size: 3986 byte(s)
add compiler directive to write exceptions to console or not

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
9 namespace gr2lib.core.coretypes.implementation
10 {
11 public class Bone : IBone
12 {
13 public Bone()
14 {
15 this.BoneName = "rootBone";
16 this.ParentIndex = -1;
17 this.Transform = new Transform();
18 this.InverseWorldTransform = new Matrix44();
19 this.LightInfo = new LightInfo();
20 this.CameraInfo = new CameraInfo();
21 this.LodError = 0;
22 }
23
24 internal static Bone ReadFromMemory(IntPtr pointer)
25 {
26 try
27 {
28 if (pointer == IntPtr.Zero) return null;
29 native.Bone native = Helpers.ReadFromMemory<native.Bone>(pointer);
30 Bone managed = Bone.ReadFromNative(native);
31 managed.NativePointer = pointer;
32 return managed;
33 }
34 catch
35 {
36 StackTrace st = new StackTrace(true);
37 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
38 Console.WriteLine(st.ToString());
39 #endif
40 return default(Bone);
41 }
42 }
43
44 internal static Bone ReadFromNative(native.Bone native)
45 {
46 try
47 {
48 Bone managed = new Bone();
49 managed.BoneName = string.IsNullOrEmpty(native.Name) ? "{null}" : native.Name;
50 managed.ParentIndex = native.ParentIndex;
51 managed.Transform = Transform.ReadFromNative(native.Transform);
52 //managed.InverseWorldTransformNode.Matrix = new Geom.Matrix44(native.InverseWorldTransform);
53 managed.LodError = native.LodError;
54 managed.LightInfo = LightInfo.ReadFromMemory(native.LightInfo);
55 managed.CameraInfo = CameraInfo.ReadFromMemory(native.CameraInfo);
56 //managed.ExtendedData = native.ExtendedData;
57
58 return managed;
59 }
60 catch
61 {
62 StackTrace st = new StackTrace(true);
63 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
64 Console.WriteLine(st.ToString());
65 #endif
66 return default(Bone);
67 }
68 }
69
70 #region IBone Members
71
72 private string _BoneName;
73 private int _ParentIndex;
74 private Transform _Transform;
75 private Matrix44 _InverseWorldTransform;
76 private LightInfo _LightInfo;
77 private CameraInfo _CameraInfo;
78 private int _LodError;
79
80
81
82 public string BoneName { get { return _BoneName; } set { _BoneName = value; } }
83 public int ParentIndex { get { return _ParentIndex; } set { _ParentIndex = value; } }
84 public Transform Transform { get { return _Transform; } set { _Transform = value; } }
85
86 public Matrix44 InverseWorldTransform { get { return _InverseWorldTransform; } set { _InverseWorldTransform = value; } }
87
88 public bool HasLightInfo { get { if (this.LightInfo == null) { return false; } else { return true; } } }
89 public bool HasCameraInfo { get { if (this.CameraInfo == null) { return false; } else { return true; } } }
90
91 public LightInfo LightInfo { get { return _LightInfo; } set { _LightInfo = value; } }
92 public CameraInfo CameraInfo { get { return _CameraInfo; } set { _CameraInfo = value; } }
93 public int LodError { get { return _LodError; } set { _LodError = value; } }
94 #endregion
95
96 #region INativePointer Members
97 private IntPtr _NativePointer;
98 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
99 #endregion
100
101 #region IExtendedData Members
102 private IntPtr _ExtendedData;
103 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
104 #endregion
105 }
106 }

  ViewVC Help
Powered by ViewVC 1.1.22