예제 #1
0
    public void generateVoxels(Vox.VoxelEditor editor)
    {
        editor.wipe();
        generationParameters.setTo(editor);
        editor.initialize();
        switch (selectedGenerationMode)
        {
        case 0:
            editor.setToHeight();
            break;

        case 1:
            editor.setToSphere();
            break;

        case 2:
            editor.setToProcedural();
            break;

        case 3:
            editor.heightmaps          = generationParameters.heightmaps;
            editor.heightmapSubstances = generationParameters.heightmapSubstances;
            editor.setToHeightmap();
            break;
        }
        editor.generateRenderers();
        setupGeneration = false;
    }
예제 #2
0
    protected void doManageGUI(Vox.VoxelEditor editor)
    {
        // actions
        GUILayout.Label("Actions", labelBigFont);
        if (GUILayout.Button("Generate New"))
        {
            setupGeneration      = true;
            generationParameters = new VoxelEditorParameters();
            generationParameters.setFrom(editor);
        }
        if (editor.hasVoxelData())
        {
            if (GUILayout.Button("Erase"))
            {
                if (EditorUtility.DisplayDialog("Erase Voxels?", "Are you sure you want to erase all voxel data?", "Erase", "Cancel"))
                {
                    editor.wipe();
                }
            }
            if (GUILayout.Button(editor.hasRenderers()? "Reskin": "Skin", buttonBigFont) && validateSubstances(editor))
            {
                editor.generateRenderers();
            }
            if (editor.hasRenderers() && GUILayout.Button("Clear Skin") && validateSubstances(editor))
            {
                editor.clearRenderers();
            }
            if (GUILayout.Button("Export"))
            {
                editor.export(EditorUtility.SaveFilePanel("Choose File to Export To", "", "Voxels", "vox"));
            }
        }
        if (GUILayout.Button("Import"))
        {
            if (!editor.import(EditorUtility.OpenFilePanel("Choose File to Import From", "", "vox")))
            {
                EditorUtility.DisplayDialog("Wrong Voxel Format", "The file you chose was an unknown or incompatible voxel format version.", "OK");
            }
        }

        if (!editor.hasVoxelData())
        {
            return;
        }

        GUILayout.Label("Properties", labelBigFont);

        doGeneralPropertiesGUI(editor);

        // TODO: implement LOD and uncomment this
//		// LOD
//		SerializedProperty useLod = ob.FindProperty("useLod");
//		EditorGUILayout.PropertyField(useLod, new GUIContent("Use Level of Detail"));
//		if (useLod.boolValue) {
//			++EditorGUI.indentLevel;
//			SerializedProperty lodDetail = ob.FindProperty("lodDetail");
//			EditorGUILayout.PropertyField(lodDetail, new GUIContent("Target Level of Detail"));
//			if (lodDetail.floatValue > 1000)
//				lodDetail.floatValue = 1000;
//			else if (lodDetail.floatValue < 0.1f)
//				lodDetail.floatValue = 0.1f;
//
//			SerializedProperty curLodDetail = ob.FindProperty("curLodDetail");
//			if (Application.isPlaying) {
//				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Current Level of Detail"));
//			} else {
//				EditorGUILayout.PropertyField(curLodDetail, new GUIContent("Starting Level of Detail"));
//			}
//
//			if (curLodDetail.floatValue > 1000)
//				curLodDetail.floatValue = 1000;
//			else if (curLodDetail.floatValue < 0.1f)
//				curLodDetail.floatValue = 0.1f;
//			--EditorGUI.indentLevel;
//		}

        // do substances
        doSubstancesGUI(serializedObject);


        // show statistics
        showStatistics = doBigFoldout(showStatistics, "Statistics");
        if (showStatistics)
        {
            EditorGUILayout.LabelField("Chunk Count: " + editor.renderers.Count);
            doTreeSizeGUI(editor);
            EditorGUILayout.LabelField("Vertex Count: " + editor.vertexCount);
            EditorGUILayout.LabelField("Triangle Count: " + editor.triangleCount);
        }
    }