public ISSCBlockVector CalPlacingPosition(Vector3 hitPoint, Vector3 hittedBlockPosition)
    {
        Vector3 dir = hitPoint - hittedBlockPosition;

        dir = ISMath.Clip2NormalDirectionV2(dir);
        return(ISSCBGrid.WorldPositionToGridPosition(dir + hittedBlockPosition, moniter.transform.position));
    }
    void TmpGOAndSelectCubeDragingBehaviour(RaycastHit hit)
    {
        if (!moving)
        {
            return;
        }
        Vector3 position;

        if (!hit.collider)
        {
            return;
        }
        else if (hit.collider.gameObject.Equals(fallBackGO))
        {
            return;
        }
        else
        {
            position = ISSCBGrid.GridPositionToWorldPosition(core.CalPlacingPosition(hit.point, hit.collider.transform.position), core.moniter.transform.position);
            core.SelectBlock(position);
            if (!tmpGO)
            {
                return;
            }
            tmpGO.transform.Rotate(tmpGO.transform.up, 45 * Time.deltaTime);
            tmpGO.transform.position = position;
        }
    }
Example #3
0
    static string EncodeJson(ISSCBGrid grid)
    {
        int[] data = grid.GetRawData();

        JsonData json   = new JsonData();
        JsonData size   = new JsonData();
        JsonData blocks = new JsonData();

        ISSCBlockVector bv = grid.gridSize;

        size["x"] = bv.x.ToString();
        size["y"] = bv.y.ToString();
        size["z"] = bv.z.ToString();

        json["name"] = grid.name;
        json["size"] = size;

        for (int i = 0; i < data.Length; i++)
        {
            blocks [i.ToString()] = data [i];
        }
        json["blocks"] = blocks;

        string str = json.ToJson();

        return(str);
    }
    void UpdateUI()
    {
        if (core.currentFillingBlock != 0)
        {
            tipsImage.color = blockList.blocks [core.currentFillingBlock].GetComponent <MeshRenderer> ().sharedMaterial.color;
        }
        else
        {
            tipsImage.color = new Color(0, 0, 0, 0);
        }

        stateTips.sprite = GetStateSprite();
        selectTipBlock.transform.position = ISSCBGrid.GridPositionToWorldPosition(core.CurrentSelection(), core.moniter.transform.position);

        /*
         * if (userSelectionState == SelectionOperations.Cube) {
         *      cubeWidth.enabled = true;
         *      cubeWidth.text = "S :\t" + ((int)length).ToString () + " px";
         * } else {
         *      cubeWidth.enabled = false;
         * }
         *
         * if (userSelectionState == SelectionOperations.Sphere) {
         *      sphereRadius.enabled = true;
         *      sphereRadius.text = "R :\t" + ((int)radius).ToString () + " px";
         * } else {
         *      sphereRadius.enabled = false;
         * }
         */
    }
Example #5
0
	static public void CreateFile(ISSCBGrid dataSet, string path){
		string d = EncodeJson (dataSet);

		if(!path.EndsWith(".scb")) path += ".scb";
		string directory = path.Substring (0,path.LastIndexOf ("/"));
		if (!Directory.Exists (directory))Directory.CreateDirectory (directory);
		File.WriteAllText (path, d);
	}
	public void NewScene (ISSCBlockVector size, string name){
		data = new ISSCBGrid (size);
		data.name = name;
		data.SetBlock (data.GetCenterBlock (), rootBlock);
		Debug.Log ("New Scene Created");
		editorCamera.SetViewPoint (ISSCBGrid.GridPositionToWorldPosition (data.GetCenterBlock (), moniter.transform.position));
		moniter.SwitchDataSet (data);
	}
Example #7
0
    public void SwitchDataSet(ISSCBGrid newDataSet)
    {
        gridData       = newDataSet;
        currentVersion = -1;
        ClearNCreateNewInSceneCaches(gridData.gridSize.Length());
        UpdateEntireScene();

        Debug.Log("data switched...");
    }
 public void NewScene(ISSCBlockVector size, string name)
 {
     data      = new ISSCBGrid(size);
     data.name = name;
     data.SetBlock(data.GetCenterBlock(), rootBlock);
     Debug.Log("New Scene Created");
     editorCamera.SetViewPoint(ISSCBGrid.GridPositionToWorldPosition(data.GetCenterBlock(), moniter.transform.position));
     moniter.SwitchDataSet(data);
 }
	public void SwitchDataSet (ISSCBGrid newDataSet)
	{
		gridData = newDataSet;
		currentVersion = -1;
		ClearNCreateNewInSceneCaches (gridData.gridSize.Length ());
		UpdateEntireScene ();

		Debug.Log ("data switched...");
	}
 void StopCamGLRenderAndPlacingSphere()
 {
     if (cameraScript.selecting)
     {
         Vector3 v1 = selectTipBlock.transform.position;
         ISSCGridPrimitiveShapeUtilities.CreateSphere(core.data, ISSCBGrid.WorldPositionToGridPosition(v1, core.moniter.transform.position), core.currentFillingBlock, radius);
         cameraScript.selecting = false;
         radius = 0;
     }
 }
 void StopCamGLRenderAndPlacingCube()
 {
     if (cameraScript.selecting)
     {
         Vector3         v1           = selectTipBlock.transform.position;
         ISSCBlockVector fromPosition = ISSCBGrid.WorldPositionToGridPosition(v1 + Vector3.one * length, core.moniter.transform.position);
         ISSCBlockVector toPosition   = ISSCBGrid.WorldPositionToGridPosition(v1 - Vector3.one * length, core.moniter.transform.position);
         ISSCGridPrimitiveShapeUtilities.CreateCube(core.data, core.currentFillingBlock, fromPosition, toPosition);
         cameraScript.selecting = false;
         length = 0;
     }
 }
	public static void CreateCube (ISSCBGrid grid, int fillWith, ISSCBlockVector from, ISSCBlockVector to)
	{
		if (!grid.IsBlockAvailable (from)) return;
		if (!grid.IsBlockAvailable (to)) return;
			
		ISSCBlockVector[] bvs = grid.BlocksOverlapCube(from,to);
		foreach(ISSCBlockVector bv in bvs){
			grid.SetBlock(bv,fillWith);
		}

		return;
	}
//	public static bool CreatePrimitive (ISSCBGrid grid, ModuleType moduleType, ISSCBlockVector origin, float radius, float height,Vector3 direction)
//	{
//		if (moduleType != ModuleType.Cone)
//			return false;
//		if (!grid.IsBlockAvailable (origin))
//			return false;
//		if (radius <= 0 || height <= 0)
//			return false;
//		return true;
//
//		
//	}

	public static void CreateCylinder (ISSCBGrid grid, int fillWith, ISSCBlockVector origin, float radius, float height)
	{
		if (!grid.IsBlockAvailable (origin)) return;
		if (radius <= 0 || height <= 0) return;
			
		ISSCBlockVector[] bvs = grid.BlocksOverlapCylinder(origin,radius,height);
		foreach(ISSCBlockVector bv in bvs){
			grid.SetBlock(bv,fillWith);
		}
		
		return;

	}
	void Start ()
	{
		blockList = ISSCDBlocksList.LoadList ();

		for (int i = 0; i < blockList.blocks.Length; i++)
			ISObjectPoolManager.New (blockList.blocks [i].gameObject, 1);

		gridData = new ISSCBGrid (grid);
		int length = gridData.gridSize.Length ();
		blockObjects = new GameObject[length];
		versionDataCache = new int[length];

		LightSetting ();
	}
	public static void CreateSphere (ISSCBGrid grid, ISSCBlockVector origin, int fillWith, float radius)
	{

		if (!grid.IsBlockAvailable (origin)) {
			Debug.LogError("Failed to create primitive : Not enough spaces");
			return;
		}
		if (radius <= 0) return;
			
		ISSCBlockVector[] bvs = grid.BlocksOverlapSphere(origin,radius);
		foreach(ISSCBlockVector bv in bvs){
			grid.SetBlock(bv,fillWith);
		}
	}
Example #16
0
    static public void CreateFile(ISSCBGrid dataSet, string path)
    {
        string d = EncodeJson(dataSet);

        if (!path.EndsWith(".scb"))
        {
            path += ".scb";
        }
        string directory = path.Substring(0, path.LastIndexOf("/"));

        if (!Directory.Exists(directory))
        {
            Directory.CreateDirectory(directory);
        }
        File.WriteAllText(path, d);
    }
    void CreateTmpGO(RaycastHit hit)
    {
        if (!hit.collider)
        {
            return;
        }
        moving = true;

        tmpVector1 = ISSCBGrid.WorldPositionToGridPosition(hit.transform.position, core.moniter.transform.position);
        tmpID      = core.data.GetRawData() [core.data.EncodeIndex(tmpVector1)];
        fallBackGO = hit.collider.gameObject;
        fallBackGO.SetActive(false);
        tmpGO = Instantiate(fallBackGO) as GameObject;
        tmpGO.SetActive(true);
        tmpGO.transform.localScale *= 0.8f;
        tmpGO.layer = ISSCLayerManager.tmpBlockLayer;
    }
Example #18
0
    void UpdateEntireScene()
    {
        int versionCheckResult = gridData.IsLastestVersion(currentVersion);

        if (versionCheckResult == -1)
        {
            return;
        }

        Debug.Log("New version detected, updating " + (versionCheckResult - currentVersion).ToString() + " changes...");

        int[] data = gridData.GetRawData();

        for (int i = 0; i < data.Length; i++)
        {
            if (data [i] == versionDataCache [i])
            {
                continue;
            }

            //Once a block is changed(otherwise, loop is continued), check the surrounding blocks and see if some of them also need to be updated.
            UpdateBlocksCacheIgroned(gridData.SurroundingBlocks(gridData.DecodeIndex(i)));

            versionDataCache [i] = data [i];

            ISSCBlockVector b = gridData.DecodeIndex(i);

            if (blockObjects [i])
            {
                ISObjectPoolManager.Unspawn(blockObjects [i]);
            }
            if (data [i] <= 1)
            {
                continue;
            }
            if (!gridData.IsBlockVisiable(b))
            {
                continue;
            }

            Vector3 position = ISSCBGrid.GridPositionToWorldPosition(b, transform.position);
            blockObjects [i] = ISObjectPoolManager.Spawn(blockList.blocks [data [i]].gameObject, position, Quaternion.identity) as GameObject;
        }

        currentVersion = versionCheckResult;
    }
Example #19
0
    void Start()
    {
        blockList = ISSCDBlocksList.LoadList();

        for (int i = 0; i < blockList.blocks.Length; i++)
        {
            ISObjectPoolManager.New(blockList.blocks [i].gameObject, 1);
        }

        gridData = new ISSCBGrid(grid);
        int length = gridData.gridSize.Length();

        blockObjects     = new GameObject[length];
        versionDataCache = new int[length];

        LightSetting();
    }
Example #20
0
	static ISSCBGrid DecodeJson(string data){
		JsonData json = JsonMapper.ToObject (data);

		int vectorX,vectorY,vectorZ;
		vectorX = int.Parse(json["size"]["x"].ToString());
		vectorY = int.Parse(json["size"]["y"].ToString());
		vectorZ = int.Parse(json["size"]["z"].ToString());
		ISSCBlockVector size = new ISSCBlockVector(vectorX,vectorY,vectorZ);

		ISSCBGrid grid = new ISSCBGrid(size);
		grid.name = json ["name"].ToString ();

		for(int i =0 ;i< grid.GetRawData().Length;i++){
			grid.SetBlock(grid.DecodeIndex(i),int.Parse(json["blocks"][i.ToString()].ToString()));//?
		}

		return grid;
	}
    public static void CreateSphere(ISSCBGrid grid, ISSCBlockVector origin, int fillWith, float radius)
    {
        if (!grid.IsBlockAvailable(origin))
        {
            Debug.LogError("Failed to create primitive : Not enough spaces");
            return;
        }
        if (radius <= 0)
        {
            return;
        }

        ISSCBlockVector[] bvs = grid.BlocksOverlapSphere(origin, radius);
        foreach (ISSCBlockVector bv in bvs)
        {
            grid.SetBlock(bv, fillWith);
        }
    }
Example #22
0
    void LightSetting()
    {
        lights = GetComponentsInChildren <Light> ();
        lights [0].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(0, 0, 0), transform.position);
        lights [1].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(0, gridData.gridSize.y - 1, 0), transform.position);
        lights [2].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(gridData.gridSize.x - 1, 0, 0), transform.position);
        lights [3].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(gridData.gridSize.x - 1, gridData.gridSize.y - 1, 0), transform.position);
        lights [4].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(gridData.gridSize.x - 1, 0, gridData.gridSize.z - 1), transform.position);
        lights [5].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(gridData.gridSize.x - 1, gridData.gridSize.y - 1, gridData.gridSize.z - 1), transform.position);
        lights [6].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(0, 0, gridData.gridSize.z - 1), transform.position);
        lights [7].transform.position = ISSCBGrid.GridPositionToWorldPosition(new ISSCBlockVector(0, gridData.gridSize.y - 1, gridData.gridSize.z - 1), transform.position);

        for (int i = 0; i < lights.Length; i++)
        {
//		lights[i].transform.LookAt(ISSCBGrid.GridPositionToWorldPosition(gridData.GetCenterBlock(),transform.position));
            lights[i].range = Mathf.Sqrt(Mathf.Pow(gridData.gridSize.x - 1, 2) + Mathf.Pow(gridData.gridSize.y - 1, 2) + Mathf.Pow(gridData.gridSize.z - 1, 2));
//			lights[i].spotAngle = 90;
        }
    }
//	public static bool CreatePrimitive (ISSCBGrid grid, ModuleType moduleType, ISSCBlockVector origin, float radius, float height,Vector3 direction)
//	{
//		if (moduleType != ModuleType.Cone)
//			return false;
//		if (!grid.IsBlockAvailable (origin))
//			return false;
//		if (radius <= 0 || height <= 0)
//			return false;
//		return true;
//
//
//	}

    public static void CreateCylinder(ISSCBGrid grid, int fillWith, ISSCBlockVector origin, float radius, float height)
    {
        if (!grid.IsBlockAvailable(origin))
        {
            return;
        }
        if (radius <= 0 || height <= 0)
        {
            return;
        }

        ISSCBlockVector[] bvs = grid.BlocksOverlapCylinder(origin, radius, height);
        foreach (ISSCBlockVector bv in bvs)
        {
            grid.SetBlock(bv, fillWith);
        }

        return;
    }
    public static void CreateCube(ISSCBGrid grid, int fillWith, ISSCBlockVector from, ISSCBlockVector to)
    {
        if (!grid.IsBlockAvailable(from))
        {
            return;
        }
        if (!grid.IsBlockAvailable(to))
        {
            return;
        }

        ISSCBlockVector[] bvs = grid.BlocksOverlapCube(from, to);
        foreach (ISSCBlockVector bv in bvs)
        {
            grid.SetBlock(bv, fillWith);
        }

        return;
    }
Example #25
0
    static ISSCBGrid DecodeJson(string data)
    {
        JsonData json = JsonMapper.ToObject(data);

        int vectorX, vectorY, vectorZ;

        vectorX = int.Parse(json["size"]["x"].ToString());
        vectorY = int.Parse(json["size"]["y"].ToString());
        vectorZ = int.Parse(json["size"]["z"].ToString());
        ISSCBlockVector size = new ISSCBlockVector(vectorX, vectorY, vectorZ);

        ISSCBGrid grid = new ISSCBGrid(size);

        grid.name = json ["name"].ToString();

        for (int i = 0; i < grid.GetRawData().Length; i++)
        {
            grid.SetBlock(grid.DecodeIndex(i), int.Parse(json["blocks"][i.ToString()].ToString()));           //?
        }

        return(grid);
    }
Example #26
0
    public void UpdateBlockCacheIgroned(ISSCBlockVector block)
    {
        int id = gridData.EncodeIndex(block);

        if (blockObjects [id])
        {
            ISObjectPoolManager.Unspawn(blockObjects [id]);
        }

        if (!gridData.IsBlockVisiable(block))
        {
            return;
        }
        int[] data = gridData.GetRawData();

        if (data [id] <= 1)
        {
            return;
        }

        Vector3 position = ISSCBGrid.GridPositionToWorldPosition(block, transform.position);

        blockObjects [id] = ISObjectPoolManager.Spawn(blockList.blocks [data [id]].gameObject, position, Quaternion.identity) as GameObject;
    }
Example #27
0
	static string EncodeJson (ISSCBGrid grid){
	
		int[] data = grid.GetRawData ();
	
		JsonData json = new JsonData ();
		JsonData size = new JsonData();
		JsonData blocks = new JsonData();

		ISSCBlockVector bv = grid.gridSize;
		size["x"] = bv.x.ToString();
		size["y"] = bv.y.ToString();
		size["z"] = bv.z.ToString();

		json["name"] = grid.name;
		json["size"] = size;
	
		for (int i = 0; i < data.Length; i++) {
			blocks [i.ToString()] = data [i];
		}
		json["blocks"] = blocks;

		string str = json.ToJson ();
		return str;
	}
Example #28
0
 public void OpenScene(ISSCBGrid newDataSet)
 {
     data = newDataSet;
     editorCamera.SetViewPoint(ISSCBGrid.GridPositionToWorldPosition(data.GetCenterBlock(), moniter.transform.position));
     moniter.SwitchDataSet(data);
 }
Example #29
0
 public ISSCBlockVector BlockForWorldPosition(Vector3 position)
 {
     return(ISSCBGrid.WorldPositionToGridPosition(position, moniter.transform.position));
 }
Example #30
0
 public void SelectBlock(Vector3 position)
 {
     SelectBlock(ISSCBGrid.WorldPositionToGridPosition(position, moniter.transform.position));
 }
Example #31
0
	public void OpenScene (ISSCBGrid newDataSet){
		data = newDataSet;
		editorCamera.SetViewPoint (ISSCBGrid.GridPositionToWorldPosition (data.GetCenterBlock (), moniter.transform.position));
		moniter.SwitchDataSet (data);
	}
Example #32
0
    public void Submit(string command)
    {
        if (command.StartsWith("select block"))
        {
            string argu = command.Substring(12);
            core.currentFillingBlock = int.Parse(argu);
        }
        else if (command.StartsWith("sb"))
        {
            string argu = command.Substring(2);
            core.currentFillingBlock = int.Parse(argu);
        }
        else if (command.StartsWith("save"))
        {
            string argu = command.Substring(command.IndexOf("\"") + 1, command.LastIndexOf("\"") - command.IndexOf("\"") - 1);
            core.SaveCurrentScene(Application.dataPath + "/Resources/SavedDatas/" + argu);
        }
        else if (command.StartsWith("load"))
        {
            string argu = command.Substring(command.IndexOf("\"") + 1, command.LastIndexOf("\"") - command.IndexOf("\"") - 1);
            core.OpenScene(Application.dataPath + "/Resources/SavedDatas/" + argu);
        }
        else if (command.StartsWith("new"))
        {
            string[] argus = ParseArguments(command);
            int      size  = int.Parse(argus [0]);
            core.NewScene(new ISSCBlockVector(size, size, size), "New Scene");
        }
        else if (command.StartsWith("sphere"))
        {
            string[]        argus        = ParseArguments(command);
            ISSCBlockVector center       = ParseBlockVector(argus [0]);
            int             r            = int.Parse(argus [1]);
            int             fillingBlock = int.Parse(argus [2]);

            ISSCGridPrimitiveShapeUtilities.CreateSphere(core.data, center, fillingBlock, r);
        }
        else if (command.StartsWith("cube"))
        {
            string[]        argus        = ParseArguments(command);
            ISSCBlockVector a            = ParseBlockVector(argus [0]);
            ISSCBlockVector b            = ParseBlockVector(argus [1]);
            int             fillingBlock = int.Parse(argus [2]);

            ISSCGridPrimitiveShapeUtilities.CreateCube(core.data, fillingBlock, a, b);
        }
        else if (command.StartsWith("move"))
        {
            string[]        argus = ParseArguments(command);
            ISSCBlockVector a     = ParseBlockVector(argus [0]);
            ISSCBlockVector b     = ParseBlockVector(argus [1]);
            bool            forceMove;
            switch (argus [2])
            {
            case "true":
                forceMove = true;
                break;

            case "false":
                forceMove = false;
                break;

            default:
                forceMove = true;
                break;
            }

            core.data.MoveBlock(a, b, forceMove);
        }
        else if (command.StartsWith("currentmoveto"))
        {
            string[]        argus = ParseArguments(command);
            ISSCBlockVector a     = ParseBlockVector(argus [0]);
            bool            forceMove;
            switch (argus [1])
            {
            case "true":
                forceMove = true;
                break;

            case "false":
                forceMove = false;
                break;

            default:
                forceMove = true;
                break;
            }
            ISSCBlockVector currentBlock = ISSCBGrid.WorldPositionToGridPosition(core.tipsBlock.transform.position, core.moniter.transform.position);
            core.data.MoveBlock(currentBlock, a, forceMove);
            core.tipsBlock.transform.position = ISSCBGrid.GridPositionToWorldPosition(a, core.moniter.transform.position);
            Debug.Log(ISSCBGrid.GridPositionToWorldPosition(a, core.moniter.transform.position));
        }
    }
 void StartCamGLRender()
 {
     cameraScript.selecting        = true;
     cameraScript.selectStartPoint = new Vector3(mouseCasterForLayerSelectingBlock.inputPosition.x / Screen.width, mouseCasterForLayerSelectingBlock.inputPosition.y / Screen.height, 0);
     depth = Vector3.Distance(viewingCamera.ScreenToWorldPoint(mouseCasterForLayerSelectingBlock.inputPosition), ISSCBGrid.GridPositionToWorldPosition(core.CurrentSelection(), core.moniter.transform.position));
 }
Example #34
0
    static void LoadFromSCB()
    {
        //First, we ask user to select a .scb file to load.w

        EditorUtility.DisplayProgressBar("Load from SCB", "Waiting for user action...", 0);

        string path = EditorUtility.OpenFilePanel("Choose SCB", Application.dataPath, "scb");

        if (string.IsNullOrEmpty(path))
        {
            EditorUtility.ClearProgressBar();
            return;
        }

        int shouldFill             = EditorUtility.DisplayDialogComplex("Fill ?", "Do you want to fill the model ?", "Yep", "NO !", "Nevermind !");
        int shouldConnectWithJoint = EditorUtility.DisplayDialogComplex("Apply Physic Connections ?", "Do you want to apply physic connections to blocks ?", "Yep", "NO !", "Nevermind !");

        EditorUtility.DisplayProgressBar("Load from SCB", "Reading file...", 0);

        //Once we have the file path, we parse its name, and use FileUtilities to load it.
        string    fileName = path.Substring(path.LastIndexOf("/"));
        ISSCBGrid dataSet  = ISSCDGridFileUtilities.LoadFromFile(path);

        /*
         * if (!dataSet) {
         *      Debug.Log ("Failed to create : could not open data set...");
         *      EditorUtility.ClearProgressBar ();
         *      return;
         * }
         */

        EditorUtility.DisplayProgressBar("Load from SCB", "Loading files...", 0.5f);

        //FileUntilities return the data set means the file is vaild, so now we can start the creation process,
        //First, create the root object, and load all blocks

        ISSCDBlocksList   blockList = ISSCDBlocksList.LoadList();
        GameObject        rootObj   = new GameObject(string.IsNullOrEmpty(dataSet.name) ? fileName : dataSet.name);
        List <GameObject> childrens = new List <GameObject> ();
        Transform         rootTrans = rootObj.transform;

        //It should be zero, just make sure.
        rootTrans.position = Vector3.zero;

        EditorUtility.DisplayProgressBar("Load from SCB", "Loading files...", 1);

        int[]   rawData        = dataSet.GetRawData();
        Vector3 centerPosition = ISSCBGrid.GridPositionToWorldPosition(dataSet.GetCenterBlock(), rootTrans.position);

        EditorUtility.DisplayProgressBar("Load from SCB", "Creating GameObjects...", 0);

        for (int i = 0; i < rawData.Length; i++)
        {
            if (rawData [i] <= 1)
            {
                continue;
            }

            ISSCBlockVector b = dataSet.DecodeIndex(i);

            if (shouldFill != 0 && !dataSet.IsBlockVisiable(b))
            {
                continue;
            }

            Vector3    position = ISSCBGrid.GridPositionToWorldPosition(b, rootTrans.position) - centerPosition;
            GameObject obj      = ISObjectPoolManager.Spawn(blockList.blocks [rawData [i]].gameObject, position, Quaternion.identity) as GameObject;
            obj.GetComponent <ISSCBlock> ().blockID = i;
            obj.name             = "Block " + i.ToString();
            obj.transform.parent = rootObj.transform;
            childrens.Add(obj);

            EditorUtility.DisplayProgressBar("Load from SCB", "Creating GameObjects...", (float)i / (float)rawData.Length);
        }

        Selection.activeObject = rootObj;

        EditorUtility.ClearProgressBar();

        //Now, if we need to apply physic connects, continue !
        if (shouldConnectWithJoint != 0)
        {
            return;
        }
        EditorUtility.DisplayProgressBar("Applying Physic Connections", "Processing...", 0);

        //Since we're using data set ID to create blocks, ID in list would be its ID of data set.
        for (int i = 0; i < childrens.Count; i++)
        {
            GameObject        operatingObj = childrens [i];
            int               objectID     = operatingObj.GetComponent <ISSCBlock> ().blockID;
            ISSCBlockVector   bv           = dataSet.DecodeIndex(objectID);
            ISSCBlockVector[] surrounds    = dataSet.SurroundingBlocks(bv);

            for (int j = 0; j < surrounds.Length; j++)
            {
                int toConnectObjectID = dataSet.EncodeIndex(surrounds [j]);
                if (rawData [toConnectObjectID] <= 1)
                {
                    continue;
                }
                GameObject toConnect = null;

                foreach (GameObject obj in childrens)
                {
                    if (obj.GetComponent <ISSCBlock>().blockID == toConnectObjectID)
                    {
                        toConnect = obj;
                        break;
                    }
                }

                if (!toConnect)
                {
                    continue;
                }

                FixedJoint joint = operatingObj.AddComponent <FixedJoint> ();
                joint.connectedBody = toConnect.GetComponent <Rigidbody> () ? toConnect.GetComponent <Rigidbody> () : toConnect.AddComponent <Rigidbody> ();
            }

            EditorUtility.DisplayProgressBar("Applying Physic Connections", "Processing " + i.ToString() + " of " + childrens.Count + " objects..", (float)i / (float)childrens.Count);
        }


        //Start validing, in another word, this will make me programs easier :)
        for (int i = 0; i < childrens.Count; i++)
        {
            Rigidbody r = childrens [i].GetComponent <Rigidbody> ();
            if (r)
            {
                r.isKinematic = false;
            }
            else
            {
                Debug.LogError("Failed to vaild : Unknown error");
            }

            FixedJoint[] joints = childrens [i].GetComponents <FixedJoint> ();
            for (int j = 0; j < joints.Length; j++)
            {
                if (!joints [j].connectedBody)
                {
                    DestroyImmediate(joints [j]);
                }
            }

            EditorUtility.DisplayProgressBar("Applying Physic Connections", "Vailding " + i.ToString() + " of " + childrens.Count + " objects..", (float)i / (float)childrens.Count);
        }

        EditorUtility.ClearProgressBar();
    }