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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 187 - (show annotations) (download)
Sat Jul 24 04:16:43 2010 UTC (9 years, 4 months ago) by william
File size: 4042 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 using System.Windows.Forms;
11
12 namespace gr2lib.core.coretypes.implementation
13 {
14 /// <summary>
15 /// Skeleton Class
16 /// </summary>
17 public class Skeleton : GrannyRigParentResource,ISkeleton
18 {
19 /// <summary>
20 /// default constructor
21 /// </summary>
22 public Skeleton() : base("Skeletons")
23 {
24 this.SkeletonName = "Skeleton";
25 this.Bones = new List<Bone>();
26 this.LodType = 0;
27 //this.NativePointer = IntPtr.Zero;
28 //this.ExtendedData = IntPtr.Zero;
29 }
30
31
32 internal static Skeleton ReadFromMemory(IntPtr pointer)
33 {
34 try
35 {
36 if (pointer == IntPtr.Zero) return null;
37 native.Skeleton native = Helpers.ReadFromMemory<native.Skeleton>(pointer);
38 Skeleton managed = 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(Skeleton);
49 }
50 }
51
52 internal static Skeleton ReadFromNative(native.Skeleton native)
53 {
54 try
55 {
56 Skeleton managed = new Skeleton();
57 managed.SkeletonName = string.IsNullOrEmpty(native.Name) ? "{null}" : native.Name;
58 IntPtr[] bones = Helpers.ReadPtrArrayFromMemory<native.Bone>(native.Bones);
59 int boneLength = bones.Length;
60
61 foreach (IntPtr ptr in bones)
62 {
63 managed.Bones.Add(new Bone());
64 Application.DoEvents();
65 }
66
67 for (int i = 0; i < boneLength; i++)
68 {
69 managed.Bones[i] = Bone.ReadFromMemory(bones[i]);
70 Application.DoEvents();
71 }
72 managed.LodType = native.LodType;
73 managed.ExtendedData = native.ExtendedData;
74 return managed;
75 }
76 catch (Exception ex)
77 {
78 StackTrace st = new StackTrace(true);
79 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
80 Granny2ExceptionWriter.WriteToConsole(ex,st);
81 #endif
82 return default(Skeleton);
83 }
84 }
85
86 #region ISkeleton Members
87
88 private string _SkeletonName;
89 private List<Bone> _Bones;
90 private int _LodType;
91
92 /// <summary>
93 /// get/set name
94 /// </summary>
95 public string SkeletonName { get { return _SkeletonName; } set { _SkeletonName = value; } }
96 /// <summary>
97 /// get/set bones
98 /// </summary>
99 public List<Bone> Bones { get { return _Bones; } set { _Bones = value; } }
100 /// <summary>
101 /// get/set lodtype
102 /// </summary>
103 public int LodType { get { return _LodType; } set { _LodType = value; } }
104 #endregion
105
106 #region INativePointer Members
107 private IntPtr _NativePointer;
108 /// <summary>
109 /// When used in a derived class, gets the native pointer for this instance
110 /// </summary>
111 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
112 #endregion
113
114 #region IExtendedData Members
115 private IntPtr _ExtendedData;
116 /// <summary>
117 /// When used in a derived class, gets the ExtendedData pointer for this instance
118 /// </summary>
119 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
120 #endregion
121 }
122 }

  ViewVC Help
Powered by ViewVC 1.1.22