Skip to content

Commit 135ffca

Browse files
committed
реализован выбор Queue Bucket у моделей превью материалов
1 parent 3ad1b1d commit 135ffca

File tree

7 files changed

+76
-1
lines changed

7 files changed

+76
-1
lines changed

resources/messages/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ AssetEditorDialogButtonOk=Choose
2828
AssetEditorDialogButtonCancel=Cancel
2929

3030
MaterialFileEditorMaterialTypeLabel=Material type
31+
MaterialFileEditorBucketTypeLabel=Queue Bucket
3132

3233
MaterialFileEditorTexturesComponentTitle=Textures
3334
MaterialFileEditorColorsComponentTitle=Colors

resources/messages/messages_ru.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ AssetEditorDialogButtonOk=Выбрать
2828
AssetEditorDialogButtonCancel=Отменить
2929

3030
MaterialFileEditorMaterialTypeLabel=Тип материала
31+
MaterialFileEditorBucketTypeLabel=Порядок рендера
3132

3233
MaterialFileEditorTexturesComponentTitle=Текстуры
3334
MaterialFileEditorColorsComponentTitle=Цвета

resources/ui/css/custom_ids.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@
161161
-fx-max-width: -fx-min-width;
162162
}
163163

164+
#MaterialFileEditorToolbarSmallBox {
165+
-fx-min-height: 28;
166+
-fx-pref-height: -fx-min-height;
167+
-fx-max-height: -fx-min-height;
168+
-fx-min-width: 150;
169+
-fx-pref-width: -fx-min-width;
170+
-fx-max-width: -fx-min-width;
171+
}
172+
164173
#MaterialFileEditorParameterContainer {
165174
-fx-background-color: -fx-color-panel-200;
166175
-fx-alignment: top-left;

src/com/ss/editor/Messages.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class Messages {
3939
public static final String ASSET_EDITOR_DIALOG_BUTTON_CANCEL;
4040

4141
public static final String MATERIAL_EDITOR_MATERIAL_TYPE_LABEL;
42+
public static final String MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL;
4243

4344
public static final String MATERIAL_FILE_EDITOR_TEXTURES_COMPONENT_TITLE;
4445
public static final String MATERIAL_FILE_EDITOR_COLORS_COMPONENT_TITLE;
@@ -156,6 +157,7 @@ public class Messages {
156157
public static final String EMPTY_MODEL_CREATOR_TITLE;
157158

158159
public static final String GLSL_FILE_EDITOR_NAME;
160+
;
159161

160162
static {
161163

@@ -184,7 +186,6 @@ public class Messages {
184186
FILE_EDITOR_ACTION_SAVE = bundle.getString("FileEditorActionSave");
185187

186188
POST_FILTER_EDITOR_MATERIAL_LABEL = bundle.getString("PostFilterEditorMaterialListLabel");
187-
188189
ASSET_EDITOR_DIALOG_TITLE = bundle.getString("AssetEditorDialogTitle");
189190
ASSET_EDITOR_DIALOG_BUTTON_OK = bundle.getString("AssetEditorDialogButtonOk");
190191
ASSET_EDITOR_DIALOG_BUTTON_CANCEL = bundle.getString("AssetEditorDialogButtonCancel");
@@ -212,6 +213,7 @@ public class Messages {
212213
MATERIAL_RENDER_STATE_WIREFRAME = bundle.getString("MaterialRenderStateWireframe");
213214

214215
MATERIAL_EDITOR_MATERIAL_TYPE_LABEL = bundle.getString("MaterialFileEditorMaterialTypeLabel");
216+
MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL = bundle.getString("MaterialFileEditorBucketTypeLabel");
215217

216218
TEXT_FILE_EDITOR_NAME = bundle.getString("TextFileEditorName");
217219
POST_FILTER_EDITOR_NAME = bundle.getString("PostFilterEditorName");

src/com/ss/editor/state/editor/impl/material/MaterialEditorState.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.jme3.math.Quaternion;
1212
import com.jme3.math.Vector3f;
1313
import com.jme3.renderer.Camera;
14+
import com.jme3.renderer.queue.RenderQueue;
1415
import com.jme3.scene.Geometry;
1516
import com.jme3.scene.Node;
1617
import com.jme3.scene.Spatial;
@@ -195,6 +196,28 @@ private void changeModeImpl(final ModelType modelType) {
195196
setCurrentModelType(modelType);
196197
}
197198

199+
/**
200+
* Смена типа Bucket.
201+
*/
202+
public void changeBucketType(final RenderQueue.Bucket bucket) {
203+
EXECUTOR_MANAGER.addEditorThreadTask(() -> changeBucketTypeImpl(bucket));
204+
}
205+
206+
/**
207+
* Процесс смены типа Bucket.
208+
*/
209+
private void changeBucketTypeImpl(final RenderQueue.Bucket bucket) {
210+
211+
final Geometry testQuad = getTestQuad();
212+
testQuad.setQueueBucket(bucket);
213+
214+
final Geometry testSphere = getTestSphere();
215+
testSphere.setQueueBucket(bucket);
216+
217+
final Geometry testBox = getTestBox();
218+
testBox.setQueueBucket(bucket);
219+
}
220+
198221
@Override
199222
public void initialize(final AppStateManager stateManager, final Application application) {
200223
super.initialize(stateManager, application);

src/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.jme3.asset.AssetManager;
44
import com.jme3.material.Material;
55
import com.jme3.material.MaterialDef;
6+
import com.jme3.renderer.queue.RenderQueue;
67
import com.ss.editor.FileExtensions;
78
import com.ss.editor.Messages;
89
import com.ss.editor.manager.ResourceManager;
@@ -23,6 +24,7 @@
2324
import java.nio.file.Files;
2425
import java.nio.file.Path;
2526

27+
import javafx.collections.FXCollections;
2628
import javafx.collections.ObservableList;
2729
import javafx.event.Event;
2830
import javafx.event.EventHandler;
@@ -62,6 +64,8 @@ public class MaterialFileEditor extends AbstractFileEditor<StackPane> {
6264

6365
private static final ResourceManager RESOURCE_MANAGER = ResourceManager.getInstance();
6466

67+
private static final RenderQueue.Bucket[] BUCKETS = RenderQueue.Bucket.values();
68+
6569
private static final Insets SMALL_OFFSET = new Insets(0, 0, 0, 3);
6670
private static final Insets BIG_OFFSET = new Insets(0, 0, 0, 6);
6771

@@ -120,6 +124,11 @@ public class MaterialFileEditor extends AbstractFileEditor<StackPane> {
120124
*/
121125
private ToggleButton lightButton;
122126

127+
/**
128+
* Выпадающий список с выбором RenderQueue.Bucket.
129+
*/
130+
private ComboBox<RenderQueue.Bucket> bucketComboBox;
131+
123132
/**
124133
* Список доступных типов материалов.
125134
*/
@@ -378,6 +387,13 @@ protected boolean needToolbar() {
378387
return true;
379388
}
380389

390+
/**
391+
* @return выпадающий список с выбором RenderQueue.Bucket.
392+
*/
393+
private ComboBox<RenderQueue.Bucket> getBucketComboBox() {
394+
return bucketComboBox;
395+
}
396+
381397
@Override
382398
protected void createToolbar(final HBox container) {
383399

@@ -405,13 +421,23 @@ protected void createToolbar(final HBox container) {
405421
materialDefinitionBox.setId(CSSIds.MATERIAL_FILE_EDITOR_TOOLBAR_BOX);
406422
materialDefinitionBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> changeType(newValue));
407423

424+
final Label bucketLabel = new Label(Messages.MATERIAL_FILE_EDITOR_BUCKET_TYPE_LABEL + ":");
425+
bucketLabel.setId(CSSIds.MATERIAL_FILE_EDITOR_TOOLBAR_LABEL);
426+
427+
bucketComboBox = new ComboBox<>(FXCollections.observableArrayList(BUCKETS));
428+
bucketComboBox.setId(CSSIds.MATERIAL_FILE_EDITOR_TOOLBAR_SMALL_BOX);
429+
bucketComboBox.getSelectionModel().select(RenderQueue.Bucket.Inherit);
430+
bucketComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> changeBucketType(newValue));
431+
408432
FXUtils.addToPane(createSaveAction(), container);
409433
FXUtils.addToPane(cubeButton, container);
410434
FXUtils.addToPane(sphereButton, container);
411435
FXUtils.addToPane(planeButton, container);
412436
FXUtils.addToPane(lightButton, container);
413437
FXUtils.addToPane(materialDefinitionLabel, container);
414438
FXUtils.addToPane(materialDefinitionBox, container);
439+
FXUtils.addToPane(bucketLabel, container);
440+
FXUtils.addToPane(bucketComboBox, container);
415441

416442
FXUtils.addClassTo(cubeButton, CSSClasses.TOOLBAR_BUTTON);
417443
FXUtils.addClassTo(cubeButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
@@ -423,12 +449,24 @@ protected void createToolbar(final HBox container) {
423449
FXUtils.addClassTo(lightButton, CSSClasses.FILE_EDITOR_TOOLBAR_BUTTON);
424450
FXUtils.addClassTo(materialDefinitionLabel, CSSClasses.MAIN_FONT_13);
425451
FXUtils.addClassTo(materialDefinitionBox, CSSClasses.MAIN_FONT_13);
452+
FXUtils.addClassTo(bucketLabel, CSSClasses.MAIN_FONT_13);
453+
FXUtils.addClassTo(bucketComboBox, CSSClasses.MAIN_FONT_13);
426454

427455
HBox.setMargin(cubeButton, SMALL_OFFSET);
428456
HBox.setMargin(sphereButton, SMALL_OFFSET);
429457
HBox.setMargin(planeButton, SMALL_OFFSET);
430458
HBox.setMargin(lightButton, BIG_OFFSET);
431459
HBox.setMargin(materialDefinitionLabel, BIG_OFFSET);
460+
HBox.setMargin(bucketLabel, BIG_OFFSET);
461+
}
462+
463+
/**
464+
* Обработка смны Bucket типа.
465+
*/
466+
private void changeBucketType(final RenderQueue.Bucket newValue) {
467+
468+
final MaterialEditorState editorState = getEditorState();
469+
editorState.changeBucketType(newValue);
432470
}
433471

434472
/**

src/com/ss/editor/ui/css/CSSIds.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface CSSIds {
3737

3838
public static final String MATERIAL_FILE_EDITOR_TOOLBAR_LABEL = "MaterialFileEditorToolbarLabel";
3939
public static final String MATERIAL_FILE_EDITOR_TOOLBAR_BOX = "MaterialFileEditorToolbarBox";
40+
public static final String MATERIAL_FILE_EDITOR_TOOLBAR_SMALL_BOX = "MaterialFileEditorToolbarSmallBox";
4041
public static final String MATERIAL_FILE_EDITOR_PARAMETER_CONTAINER = "MaterialFileEditorParameterContainer";
4142

4243
public static final String MATERIAL_PARAM_CONTROL_PARAM_NAME = "MaterialParamControlParamName";

0 commit comments

Comments
 (0)