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

Diff of /trunk/gr2lib/core/coretypes/implementation/Texture.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/gr2lib/core/coretypes/implementation/Texture.cs	2010/07/19 06:23:28	141
+++ trunk/gr2lib/core/coretypes/implementation/Texture.cs	2010/07/19 09:17:53	142
@@ -12,7 +12,7 @@
 
 namespace gr2lib.core.coretypes.implementation
 {
-    public class Texture : GrannyRigParentResource, ITexture
+    public class Texture : ITexture
     {
         private GrannyRigResource _rigResource;
 
@@ -30,9 +30,11 @@
         {
             return this.FromFileName.Name;
         }
-        
 
-        public Texture() : base("Textures")
+        private string _ParentResourceName;
+        protected internal string ParentResourceName { get { return "Textures"; } }
+
+        public Texture()// : base("Textures")
         {
             this.FromFileName = "";
             this.TextureType = 0;
@@ -47,7 +49,6 @@
             this._rigResource = new GrannyRigResource();
         }
         public Texture(int index)
-            : base("Textures")
         {
             this.FromFileName = "";
             this.TextureType = 0;
@@ -62,6 +63,24 @@
             this._rigResource = new GrannyRigResource();
             this.Index = index;
         }
+
+        internal static native.Texture AssignToStructure(Texture texture)
+        {
+            native.Texture _texture_struct = new gr2lib.core.coretypes.native.Texture();
+
+            _texture_struct.Encoding = texture.Encoding;
+            _texture_struct.ExtendedData = texture.ExtendedData;
+            _texture_struct.FromFileName = texture.FromFileName.FullPath;
+            _texture_struct.Height = texture.Height;
+            //_texture_struct.Images = texture.Images;
+            _texture_struct.Layout = Layout.AssignToStructure(texture.Layout);
+            _texture_struct.SubFormat = texture.SubFormat;
+            _texture_struct.TextureType = texture.TextureType;
+            _texture_struct.Width = texture.Width;
+
+            return _texture_struct;
+        }
+
         internal static Texture ReadFromMemory(IntPtr pointer)
         {
             try 
@@ -105,8 +124,21 @@
                 }
                 for (int i = 0; i < length; i++)
                 {
-                    managed.Images[i] = Image.ReadFromMemory(images[i]);
+                    managed.Images[i] = Image.ReadFromMemory(images[i]);   
+                }
+
+                for (int i = 0; i < managed.Images.Count; i++)
+                {
+                    for (int j = 0; j < managed.Images[i].MIPLevels.Count; j++)
+                    {
+                        for (int k = 0; k < managed.Images[i].MIPLevels[j].Pixels.Count; k++)
+                        {
+                            managed.Images[i].MIPLevels[j].Pixels[k].ReferenceTexture = managed;
+                        }
+                    }
                 }
+
+
                 managed.ExtendedData = native.ExtendedData;
                 return managed;
             }

 

  ViewVC Help
Powered by ViewVC 1.1.22