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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83 - (show annotations) (download)
Fri Jul 16 21:26:08 2010 UTC (9 years, 10 months ago) by william
File size: 2590 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.helpers;
6 using gr2lib.core.interfaces;
7 namespace gr2lib.core.coretypes.implementation
8 {
9
10
11 public class Material : IMaterial
12 {
13 public Material()
14 {
15 //this.NativePointer = IntPtr.Zero;
16 //this.ExtendedData = IntPtr.Zero;
17 this.Name = "";
18 this.Maps = new List<Map>();
19 this.Texture = new Texture();
20
21 }
22
23 internal static Material ReadFromMemory(IntPtr pointer)
24 {
25 if (pointer == IntPtr.Zero) return null;
26 native.Material native = Helpers.ReadFromMemory<native.Material>(pointer);
27 Material managed = ReadFromNative(native);
28 managed.NativePointer = pointer;
29 return managed;
30 }
31
32 internal static Material ReadFromNative(native.Material native)
33 {
34 Material managed = new Material();
35 managed.Name = native.Name;
36 IntPtr[] maps = Helpers.ReadPtrArrayFromMemory<native.Map>(native.Maps);
37 int length = maps.Length;
38 managed.Maps = new List<Map>(length);
39 foreach (IntPtr ptr in maps)
40 {
41 managed.Maps.Add(new Map());
42 }
43 for (int i = 0; i < length; i++)
44 {
45 managed.Maps[i] = Map.ReadFromMemory(maps[i]);
46 }
47 managed.Texture = Texture.ReadFromMemory(native.Texture);
48 managed.ExtendedData = native.ExtendedData;
49 return managed;
50 }
51
52 #region INativePointer Members
53 private IntPtr _NativePointer;
54 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
55 #endregion
56
57 #region IMaterial Members
58 private string _Name;
59 private List<Map> _Maps;
60 private Texture _Texture;
61 public string Name { get { return _Name; } set { _Name = value; } }
62 public List<Map> Maps { get { return _Maps; } set { _Maps = value; } }
63 public Texture Texture { get { return _Texture; } set { _Texture = value; } }
64 public bool IsTexture { get { if (Texture == null) { return false; } else { return true; } } }
65 #endregion
66
67 #region IExtendedData Members
68 private IntPtr _ExtendedData;
69 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
70 #endregion
71 }
72 }

  ViewVC Help
Powered by ViewVC 1.1.22