My grid is getting created on the wonk

I have tried to debug this but I honestly cant see anything wrong with it, I was wondering if anybody can help.

Basically what it does is process a 64x64 pixel texture and deletes sections of a grid based on the luminance of each pixel, I am in the process of revamping my code and all was going well until I reached this bit, I cant see why it would be making my grids come out with a diagonal slant as if each iteration was offsetting by one unit to the right.

heres what it looked like right in the obsolete code

![alt text][1]

and here is it in the new code

![alt text][2]

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class NoiseProcessor : MonoBehaviour
{
	
	public Texture2D noiseTex;
	public static Color[] pxList = new Color [4096];	
	
	// INIT
	void Start ()
	{
		pxList = noiseTex.GetPixels();
		TextureTranslator();
	}
	
	//CubeGrid.GridArray_.gridColumn*.name*_
_*	void TextureTranslator(){	*_
 
_*		int counter = 0;*_
 
_*		for ( int row = 0; row < 63; row++ ){*_
_*			for (int col = 0; col < 63; col++ ){*_
 
*				//Debug.Log(row + "_" + col);*
 
 
_*				if(isNotBlack(counter)){*_
 
_*					Cube.destroyBlock((GameObject)CubeGrid.GridArray[row].gridColumn[col].gameObject);*_
_*				}*_ 
_*				Debug.Log(counter + " " + pxList[counter].grayscale);*_
_*				counter++;			*_
_*			}*_
_*		}*_
_*	}*_
 
_*	// is not black fuction ~ returns bool*_ 
_*	bool isNotBlack(int i){*_
_		if(pxList*.grayscale <= 0.3){*_
_*			return false;*_
_*		} else {*_
_*			return true;*_
_*		}*_
_*	}*_
_*}*_
_*
*_

*[1]: http://img171.imageshack.us/img171/317/rightk.jpg*_
*[2]: http://img15.imageshack.us/img15/4527/wrongs.jpg*_

thanks for fixing the formatting

–

1 Answer

1

FIXED: The for loop conditional operator should have been <= not < it was the classic off-by-one error…FACEPALM!