/[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 106 - (show annotations) (download)
Sat Jul 17 14:52:37 2010 UTC (10 years, 9 months ago) by william
File size: 4071 byte(s)
implement Granny2ExceptionWriter

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

  ViewVC Help
Powered by ViewVC 1.1.22