public static int GetIndex( VoxelVolumeCreator obj, Vector3 pos, bool convertCoordsToLocalSpace ) { if (convertCoordsToLocalSpace) pos = obj.myTrans.InverseTransformPoint(pos); // Add offset pos += new Vector3(obj.centerOffset[0], obj.centerOffset[1], obj.centerOffset[2]) * obj.voxelScale; int x = (int)Mathf.Floor( pos.x/obj.voxelScale ); int y = (int)Mathf.Floor( pos.y/obj.voxelScale ); int z = (int)Mathf.Floor( pos.z/obj.voxelScale ); //Debug.Log("Adding voxel at data coords x="+x+", y="+y+", z="+z); return GetIndex( x,y,z, obj.dimensions ); }
public static void Initialize(VoxelVolumeCreator volume_in, VoxelVolumeCreatorEditor callback_in) { vol = volume_in; callback = callback_in; //scrollPosition = Vector2.zero; // Get or create if (myWindow == null) { myWindow = (VoxelColorPaletteWindow)EditorWindow.GetWindow (typeof (VoxelColorPaletteWindow)); // Returns the window } //myWindow.ShowUtility(); //myWindow.ShowAuxWindow(); initialized = true; colorEntriesAcross = (int)(myWindow.position.width/200f); }
void Initialize() { // === Cache === if (colorWheel == null) //lightTrans == null || { #if VCE_DEBUG Debug.Log( "VCE: Initializing VoxelVolumeCreatorEditor cache...." ); #endif InitializeCache(); } // === Cache vol === vol = (VoxelVolumeCreator)target; if (PrefabUtility.GetPrefabType(vol) == PrefabType.Prefab) { vol.isPrefab = true; return; } else { vol.isPrefab = false; } volObject = vol.gameObject; if (!vol.initialized) { vol.Initialize(); vol.Reset(); } #if VCE_DEBUG //Rect handleRect = new Rect(0,0,Screen.width, Screen.height); //Handles.DrawCamera(new Rect(0,0,Screen.width, Screen.height), handles.currentCamera); //DrawBounds(); #endif initialized = true; EditorPrefs.SetString( "lastObj", vol.gameObject.name ); }