ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/gr2lib/trunk/gr2lib/core/coretypes/implementation/Bone.cs
Revision: 106
Committed: Sat Jul 17 14:52:37 2010 UTC (12 years, 4 months ago) by william
File size: 4071 byte(s)
Log Message:
implement Granny2ExceptionWriter

File Contents

# User Rev Content
1 william 83 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 william 95 using System.Diagnostics;
8 william 106 using gr2lib.core.exceptions;
9 william 83
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 william 95 this.InverseWorldTransform = new Matrix44();
20 william 83 this.LightInfo = new LightInfo();
21     this.CameraInfo = new CameraInfo();
22     this.LodError = 0;
23     }
24    
25     internal static Bone ReadFromMemory(IntPtr pointer)
26     {
27 william 86 try
28     {
29 william 83 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 william 86 }
35 william 106 catch (Exception ex)
36 william 86 {
37 william 95 StackTrace st = new StackTrace(true);
38 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
39 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
40 william 102 #endif
41 william 86 return default(Bone);
42     }
43 william 83 }
44    
45     internal static Bone ReadFromNative(native.Bone native)
46     {
47 william 86 try
48     {
49 william 83 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 william 95 //managed.ExtendedData = native.ExtendedData;
58 william 83
59     return managed;
60 william 86 }
61 william 106 catch (Exception ex)
62 william 86 {
63 william 95 StackTrace st = new StackTrace(true);
64 william 102 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
65 william 106 Granny2ExceptionWriter.WriteToConsole(ex,st);
66 william 102 #endif
67 william 86 return default(Bone);
68     }
69 william 83 }
70    
71     #region IBone Members
72    
73     private string _BoneName;
74     private int _ParentIndex;
75     private Transform _Transform;
76 william 95 private Matrix44 _InverseWorldTransform;
77 william 83 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 william 95 public Matrix44 InverseWorldTransform { get { return _InverseWorldTransform; } set { _InverseWorldTransform = value; } }
88    
89 william 83 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     }