99import com .jme3 .input .controls .KeyTrigger ;
1010import com .jme3 .light .DirectionalLight ;
1111import com .jme3 .material .Material ;
12- import com .jme3 .math .Quaternion ;
1312import com .jme3 .math .Vector3f ;
14- import com .jme3 .renderer .Camera ;
1513import com .jme3 .renderer .RenderManager ;
1614import com .jme3 .renderer .RendererException ;
1715import com .jme3 .renderer .queue .RenderQueue .Bucket ;
2321import com .ss .editor .EditorThread ;
2422import com .ss .editor .model .EditorCamera ;
2523import com .ss .editor .model .tool .TangentGenerator ;
24+ import com .ss .editor .plugin .api .editor .Advanced3DFileEditor ;
2625import com .ss .editor .plugin .api .editor .part3d .AdvancedPBRWithStudioSky3DEditorState ;
2726import com .ss .editor .ui .component .editor .impl .material .MaterialFileEditor ;
2827import com .ss .editor .util .EditorUtil ;
3433import org .jetbrains .annotations .Nullable ;
3534
3635/**
37- * The implementation the 3D part of the {@link MaterialFileEditor}.
36+ * The implementation the 3D part of the {@link MaterialFileEditor} but it can be reused in other cases .
3837 *
3938 * @author JavaSaBr
4039 */
41- public class MaterialEditor3DState extends AdvancedPBRWithStudioSky3DEditorState <MaterialFileEditor > {
40+ public class MaterialEditor3DState < T extends Advanced3DFileEditor > extends AdvancedPBRWithStudioSky3DEditorState <T > {
4241
4342 @ NotNull
4443 private static final Vector3f QUAD_OFFSET = new Vector3f (0 , -2 , 2 );
@@ -102,7 +101,7 @@ public class MaterialEditor3DState extends AdvancedPBRWithStudioSky3DEditorState
102101 *
103102 * @param fileEditor the file editor
104103 */
105- public MaterialEditor3DState (@ NotNull final MaterialFileEditor fileEditor ) {
104+ public MaterialEditor3DState (@ NotNull final T fileEditor ) {
106105 super (fileEditor );
107106 this .testBox = new Geometry ("Box" , new Box (2 , 2 , 2 ));
108107 this .testSphere = new Geometry ("Sphere" , new Sphere (30 , 30 , 2 ));
@@ -128,7 +127,7 @@ public MaterialEditor3DState(@NotNull final MaterialFileEditor fileEditor) {
128127 protected void registerActionHandlers (@ NotNull final ObjectDictionary <String , BooleanFloatConsumer > actionHandlers ) {
129128 super .registerActionHandlers (actionHandlers );
130129
131- final MaterialFileEditor fileEditor = getFileEditor ();
130+ final T fileEditor = getFileEditor ();
132131
133132 actionHandlers .put (KEY_S , (isPressed , tpf ) -> fileEditor .handleKeyAction (KeyCode .S , isPressed , isControlDown (), isButtonMiddleDown ()));
134133 actionHandlers .put (KEY_C , (isPressed , tpf ) -> fileEditor .handleKeyAction (KeyCode .C , isPressed , isControlDown (), isButtonMiddleDown ()));
@@ -145,21 +144,21 @@ protected void registerActionListener(@NotNull final InputManager inputManager)
145144 /**
146145 * @return the test box.
147146 */
148- private @ NotNull Geometry getTestBox () {
147+ protected @ NotNull Geometry getTestBox () {
149148 return testBox ;
150149 }
151150
152151 /**
153152 * @return the test quad.
154153 */
155- private @ NotNull Geometry getTestQuad () {
154+ protected @ NotNull Geometry getTestQuad () {
156155 return testQuad ;
157156 }
158157
159158 /**
160159 * @return the test sphere.
161160 */
162- private @ NotNull Geometry getTestSphere () {
161+ protected @ NotNull Geometry getTestSphere () {
163162 return testSphere ;
164163 }
165164
@@ -175,7 +174,7 @@ public void updateMaterial(@NotNull final Material material) {
175174 /**
176175 * Update the {@link Material} in the {@link EditorThread}.
177176 */
178- private void updateMaterialImpl (@ NotNull final Material material ) {
177+ protected void updateMaterialImpl (@ NotNull final Material material ) {
179178
180179 final Geometry testBox = getTestBox ();
181180 testBox .setMaterial (material );
@@ -209,7 +208,7 @@ public void changeMode(@NotNull final ModelType modelType) {
209208 /**
210209 * Change the {@link ModelType} in the {@link EditorThread}.
211210 */
212- private void changeModeImpl (@ NotNull final ModelType modelType ) {
211+ protected void changeModeImpl (@ NotNull final ModelType modelType ) {
213212
214213 final Node modelNode = getModelNode ();
215214 modelNode .detachAllChildren ();
@@ -244,7 +243,7 @@ public void changeBucketType(@NotNull final Bucket bucket) {
244243 /**
245244 * Change the {@link Bucket} in the {@link EditorThread}.
246245 */
247- private void changeBucketTypeImpl (@ NotNull final Bucket bucket ) {
246+ protected void changeBucketTypeImpl (@ NotNull final Bucket bucket ) {
248247
249248 final Geometry testQuad = getTestQuad ();
250249 testQuad .setQueueBucket (bucket );
@@ -280,29 +279,28 @@ protected boolean needLightForCamera() {
280279 /**
281280 * @return the current model mode.
282281 */
283- @ NotNull
284- private ModelType getCurrentModelType () {
282+ protected @ NotNull ModelType getCurrentModelType () {
285283 return notNull (currentModelType );
286284 }
287285
288286 /**
289287 * @param currentModelType the current model mode.
290288 */
291- private void setCurrentModelType (@ NotNull final ModelType currentModelType ) {
289+ protected void setCurrentModelType (@ NotNull final ModelType currentModelType ) {
292290 this .currentModelType = currentModelType ;
293291 }
294292
295293 /**
296294 * @return true if the light is enabled.
297295 */
298- private boolean isLightEnabled () {
296+ protected boolean isLightEnabled () {
299297 return lightEnabled ;
300298 }
301299
302300 /**
303301 * @param lightEnabled true if the light is enabled.
304302 */
305- private void setLightEnabled (final boolean lightEnabled ) {
303+ protected void setLightEnabled (final boolean lightEnabled ) {
306304 this .lightEnabled = lightEnabled ;
307305 }
308306
@@ -318,7 +316,7 @@ public void updateLightEnabled(final boolean enabled) {
318316 /**
319317 * Update the light in the scene in the {@link EditorThread}.
320318 */
321- private void updateLightEnabledImpl (boolean enabled ) {
319+ protected void updateLightEnabledImpl (boolean enabled ) {
322320 if (enabled == isLightEnabled ()) return ;
323321
324322 final DirectionalLight light = getLightForCamera ();
@@ -333,22 +331,6 @@ private void updateLightEnabledImpl(boolean enabled) {
333331 setLightEnabled (enabled );
334332 }
335333
336- @ Override
337- protected void postCameraUpdate (final float tpf ) {
338- super .postCameraUpdate (tpf );
339-
340- final Geometry testQuad = getTestQuad ();
341-
342- if (testQuad .getParent () != null ) {
343-
344- final Quaternion localRotation = testQuad .getLocalRotation ();
345- final Camera camera = EDITOR .getCamera ();
346-
347- localRotation .lookAt (camera .getLocation (), camera .getUp ());
348- testQuad .setLocalRotation (localRotation );
349- }
350- }
351-
352334 @ Override
353335 protected boolean needUpdateCameraLight () {
354336 return false ;
0 commit comments