Example #1
0
 public void MakeTexture(NsbmdModel mod, List <NsbmdModel.MatTexPalStruct> matList, int[] polMatList)
 {
     if (matList == null)
     {
         return;
     }
     Console.WriteLine("DEBUG: making texture for model '{0}'...");
     for (int i = 0; i < matList.Count; i++)
     {
         MakeTexture(mod, matList, i, false);
     }
 }
Example #2
0
        public void MakeTexture(NsbmdModel mod, List <NsbmdModel.MatTexPalStruct> matList, int idActualMaterial, Boolean modeSingular)
        {
            if (matList == null)
            {
                matList = mod.matTexPalList;
            }
            if (matList[idActualMaterial].format == 0)
            {
                return;
            }

            actualMat = matList[idActualMaterial];
            if (actualMat.palData == null)
            {
                return;
            }

            checkFormat();

            checkImageFlipRotated();

            //MapEditor.Console.AppendText("\nFinish create image " + image.Length);
            List <byte> list = new List <byte>();

            for (int j = 0; j < image.Length; j++)
            {
                list.Add(image[j].R);
                list.Add(image[j].G);
                list.Add(image[j].B);
                list.Add(image[j].A);
            }
            byte[] pixels = list.ToArray();

            if (isOneMaterialMap(matList, idActualMaterial))
            {
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, (int)0);
            }
            if (modeSingular == true)
            {
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, (int)1);
            }
            else
            {
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, (int)idActualMaterial + 1);
            }

            Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, 0x1908, actualMat.width, actualMat.heigth, 0, 0x1908, 0x1401, pixels);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, 0x2801, 0x2600);
            Gl.glTexParameteri(Gl.GL_TEXTURE_2D, 0x2800, 0x2600);
        }