/[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 79 - (show annotations) (download)
Thu Jul 15 21:50:56 2010 UTC (9 years, 6 months ago) by william
File size: 2035 byte(s)
create and implement interfaces for all core classes (for type casting)

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 internal static Material ReadFromMemory(IntPtr pointer)
14 {
15 if (pointer == IntPtr.Zero) return null;
16 native.Material native = Helpers.ReadFromMemory<native.Material>(pointer);
17 Material managed = ReadFromNative(native);
18 managed.NativePointer = pointer;
19 return managed;
20 }
21
22 internal static Material ReadFromNative(native.Material native)
23 {
24 Material managed = new Material();
25 managed.Name = native.Name;
26 IntPtr[] maps = Helpers.ReadPtrArrayFromMemory<native.Map>(native.Maps);
27 int length = maps.Length;
28 managed.Maps = new List<Map>(length);
29 for (int i = 0; i < length; i++)
30 {
31 managed.Maps[i] = Map.ReadFromMemory(maps[i]);
32 }
33 managed.Texture = Texture.ReadFromMemory(native.Texture);
34 managed.ExtendedData = native.ExtendedData;
35 return managed;
36 }
37
38 #region INativePointer Members
39 private IntPtr _NativePointer;
40 public IntPtr NativePointer { get { return _NativePointer; } set { _NativePointer = value; } }
41 #endregion
42
43 #region IMaterial Members
44 private string _Name;
45 private List<Map> _Maps;
46 private Texture _Texture;
47 private IntPtr _ExtendedData;
48
49
50 public string Name { get { return _Name; } set { _Name = value; } }
51 public List<Map> Maps { get { return _Maps; } set { _Maps = value; } }
52 public Texture Texture { get { return _Texture; } set { _Texture = value; } }
53 public IntPtr ExtendedData { get { return _ExtendedData; } set { _ExtendedData = value; } }
54 #endregion
55 }
56 }

  ViewVC Help
Powered by ViewVC 1.1.22