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

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using gr2lib.core.typedefs;
5 using gr2lib.core.helpers;
6 using Microsoft.Xna.Framework;
7 using gr2lib.core.interfaces;
8 using System.Diagnostics;
9 using gr2lib.core.exceptions;
10 namespace gr2lib.core.coretypes.implementation
11 {
12
13
14 public class ArtToolInfo : IArtToolInfo
15 {
16 private FilePath _fromArtToolName;
17 private granny_int32 _artToolMajorRevision;
18 private granny_int32 _artToolMinorRevision;
19 private granny_real32 _unitsPerMeter;
20
21
22
23
24 private Vector3 _Origin;
25 private Vector3 _Right;
26 private Vector3 _Up;
27 private Vector3 _Back;
28
29 public ArtToolInfo()
30 {
31 this.FromArtToolName = "";
32 this.ArtToolMajorRevision = 0;
33 this.ArtToolMinorRevision = 0;
34 this.UnitsPerMeter = 1;
35 //this.ExtendedData = IntPtr.Zero;
36 //this.NativePointer = IntPtr.Zero;
37 this.Origin = new Vector3(0, 0, 0);
38 this.Right = new Vector3(0, 0, 0);
39 this.Up = new Vector3(0, 0, 0);
40 this.Back = new Vector3(0, 0, 0);
41
42
43 }
44 internal static ArtToolInfo ReadFromMemory(IntPtr pointer)
45 {
46 try
47 {
48
49 if (pointer == IntPtr.Zero) return null;
50 native.ArtToolInfo native = Helpers.ReadFromMemory<native.ArtToolInfo>(pointer);
51 ArtToolInfo managed = ReadFromNative(native);
52 managed.NativePointer = pointer;
53 return managed;
54 }
55 catch (Exception ex)
56 {
57 StackTrace st = new StackTrace(true);
58 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
59 Granny2ExceptionWriter.WriteToConsole(ex,st);
60 #endif
61 return default(ArtToolInfo);
62 }
63 }
64 internal static ArtToolInfo ReadFromNative(gr2lib.core.coretypes.native.ArtToolInfo native)
65 {
66 try
67 {
68 ArtToolInfo managed = new ArtToolInfo();
69 managed.FromArtToolName = string.IsNullOrEmpty(native.FromArtToolName) ? "{null}" : native.FromArtToolName;
70 managed.ArtToolMajorRevision = native.ArtToolMajorRevision;
71 managed.ArtToolMinorRevision = native.ArtToolMinorRevision;
72 //managed.ArtToolPointerSize = native.ArtToolPointerSize;
73 managed.UnitsPerMeter = native.UnitsPerMeter;
74 managed.Origin = new Vector3(native.Origin.X, native.Origin.Y, native.Origin.Z);
75 managed.Right = new Vector3(native.Right.X, native.Right.Y, native.Right.Z);
76 managed.Up = new Vector3(native.Up.X, native.Up.Y, native.Up.Z);
77 managed.Back = new Vector3(native.Back.X, native.Back.Y, native.Back.Z);
78 managed.ExtendedData = native.ExtendedData;
79 //managed.OnInvalidate();
80 return managed;
81 }
82 catch (Exception ex)
83 {
84 StackTrace st = new StackTrace(true);
85 #if ENABLE_EXCEPTION_OUTPUT_TO_CONSOLE
86 Granny2ExceptionWriter.WriteToConsole(ex,st);
87 #endif
88 return default(ArtToolInfo);
89 }
90 }
91
92 #region IArtToolInfo Members
93 public FilePath FromArtToolName { get { return _fromArtToolName; } set { _fromArtToolName = value; } }
94 public granny_int32 ArtToolMajorRevision { get { return _artToolMajorRevision; } set { _artToolMajorRevision = value; } }
95 public granny_int32 ArtToolMinorRevision { get { return _artToolMinorRevision; } set { _artToolMinorRevision = value; } }
96 public granny_real32 UnitsPerMeter { get { return _unitsPerMeter; } set { _unitsPerMeter = value; } }
97 public Vector3 Origin { get { return _Origin; } set { _Origin = value; } }
98 public Vector3 Right { get { return _Right; } set { _Right = value; } }
99 public Vector3 Up { get { return _Up; } set { _Up = value; } }
100 public Vector3 Back { get { return _Back; } set { _Back = value; } }
101
102 #endregion
103
104 #region INativePointer Members
105 private IntPtr _NativePointer;
106 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
107 #endregion
108
109 #region IExtendedData Members
110 private IntPtr _ExtendedData;
111 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
112 #endregion
113
114 }
115 }
116