/[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 83 - (show annotations) (download)
Fri Jul 16 21:26:08 2010 UTC (10 years, 10 months ago) by william
File size: 2514 byte(s)
bulk commit --
** Enable Support for Skeletons & Bones

** A bug has found its way into the code
 -get an unhandled EHAccessViolation
 - I think the problem is in the Textures Class (or one of the sub-classes)

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
8 namespace gr2lib.core.coretypes.implementation
9 {
10 public class Skeleton : ISkeleton
11 {
12
13 public Skeleton()
14 {
15 this.SkeletonName = "Skeleton";
16 this.Bones = new List<Bone>();
17 this.LodType = 0;
18 //this.NativePointer = IntPtr.Zero;
19 //this.ExtendedData = IntPtr.Zero;
20 }
21
22
23 internal static Skeleton ReadFromMemory(IntPtr pointer)
24 {
25 if (pointer == IntPtr.Zero) return null;
26 native.Skeleton native = Helpers.ReadFromMemory<native.Skeleton>(pointer);
27 Skeleton managed = ReadFromNative(native);
28 managed.NativePointer = pointer;
29 return managed;
30 }
31
32 internal static Skeleton ReadFromNative(native.Skeleton native)
33 {
34 Skeleton managed = new Skeleton();
35 managed.SkeletonName = string.IsNullOrEmpty(native.Name) ? "{null}" : native.Name;
36 IntPtr[] bones = Helpers.ReadPtrArrayFromMemory<native.Bone>(native.Bones);
37 int boneLength = bones.Length;
38
39 foreach (IntPtr ptr in bones)
40 {
41 managed.Bones.Add(new Bone());
42 }
43
44 for (int i = 0; i < boneLength; i++)
45 {
46 managed.Bones[i] = Bone.ReadFromMemory(bones[i]);
47 }
48 managed.LodType = native.LodType;
49 managed.ExtendedData = native.ExtendedData;
50 return managed;
51 }
52
53 #region ISkeleton Members
54
55 private string _SkeletonName;
56 private List<Bone> _Bones;
57 private int _LodType;
58
59 public string SkeletonName { get { return _SkeletonName; } set { _SkeletonName = value; } }
60 public List<Bone> Bones { get { return _Bones; } set { _Bones = value; } }
61 public int LodType { get { return _LodType; } set { _LodType = value; } }
62 #endregion
63
64 #region INativePointer Members
65 private IntPtr _NativePointer;
66 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
67 #endregion
68
69 #region IExtendedData Members
70 private IntPtr _ExtendedData;
71 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
72 #endregion
73 }
74 }

  ViewVC Help
Powered by ViewVC 1.1.22