Skip to content

Commit 5cb72c6

Browse files
committed
Updated the create skybox gui in the SDK so that it fits the new API and supports loading equirect Skybox maps.
1 parent 40177c1 commit 5cb72c6

5 files changed

Lines changed: 91 additions & 39 deletions

File tree

sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/AddSkyboxAction.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ private Spatial generateSkybox(WizardDescriptor wiz) {
6969
} else {
7070
Texture textureSingle = (Texture) wiz.getProperty("textureSingle");
7171
Vector3f normalScale = (Vector3f) wiz.getProperty("normalScale");
72-
boolean useSpheremap = (Boolean) wiz.getProperty("useSpheremap");
72+
SkyFactory.EnvMapType type = (SkyFactory.EnvMapType) wiz.getProperty("envMapType");
7373
boolean flipY = (Boolean) wiz.getProperty("flipY");
7474
// reload the texture so we can use flipY
7575
TextureKey key = (TextureKey) textureSingle.getKey();
7676
TextureKey newKey = new TextureKey(key.getName(), flipY);
7777
newKey.setGenerateMips(true);
78-
newKey.setAsCube(!useSpheremap);
79-
return SkyFactory.createSky(pm, pm.loadTexture(newKey), normalScale, useSpheremap);
78+
if(type == SkyFactory.EnvMapType.CubeMap){
79+
newKey.setTextureTypeHint(Texture.Type.CubeMap);
80+
}
81+
return SkyFactory.createSky(pm, pm.loadTexture(newKey), normalScale, type);
8082
}
8183
}
8284

sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/Bundle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ SkyboxVisualPanel2.multipleTexWestLoadButton.text=Load
1717
SkyboxVisualPanel2.multipleTexTopLoadButton.text=Load
1818
SkyboxVisualPanel2.multipleTexBottomLoadButton.text=Load
1919
SkyboxVisualPanel2.jLabel9.text=Normal Scale (x,y,z):
20-
SkyboxVisualPanel2.spheremapCheckBox.text=Sphere map
2120
SkyboxVisualPanel2.normal1X.text=1
2221
SkyboxVisualPanel2.normal1Y.text=1
2322
SkyboxVisualPanel2.normal1Z.text=1
@@ -32,3 +31,4 @@ SkyboxVisualPanel2.topPic.text=
3231
SkyboxVisualPanel2.bottomPic.text=
3332
SkyboxVisualPanel2.singlePic.text=
3433
SkyboxVisualPanel2.flipYcheckBox.text=Flip Y
34+
SkyboxVisualPanel2.jLabel10.text=Map type

sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/SkyboxVisualPanel2.form

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.1" encoding="UTF-8" ?>
1+
<?xml version="1.0" encoding="UTF-8" ?>
22

33
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
44
<AuxValues>
@@ -127,7 +127,7 @@
127127
</Group>
128128
</Group>
129129
</Group>
130-
<EmptySpace pref="27" max="32767" attributes="0"/>
130+
<EmptySpace pref="29" max="32767" attributes="0"/>
131131
</Group>
132132
</Group>
133133
</DimensionLayout>
@@ -172,7 +172,7 @@
172172
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
173173
<Component id="multipleTexTopLoadButton" alignment="3" min="-2" max="-2" attributes="0"/>
174174
</Group>
175-
<EmptySpace max="-2" attributes="0"/>
175+
<EmptySpace max="32767" attributes="0"/>
176176
</Group>
177177
<Group type="102" alignment="0" attributes="0">
178178
<Component id="westPic" min="-2" pref="20" max="-2" attributes="0"/>
@@ -376,11 +376,17 @@
376376
<Group type="102" attributes="0">
377377
<EmptySpace max="-2" attributes="0"/>
378378
<Group type="103" groupAlignment="0" attributes="0">
379+
<Component id="flipYcheckBox" alignment="0" min="-2" pref="100" max="-2" attributes="1"/>
379380
<Group type="102" alignment="0" attributes="0">
380-
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
381+
<Component id="jLabel10" min="-2" max="-2" attributes="0"/>
381382
<EmptySpace max="-2" attributes="0"/>
383+
<Component id="mapTypeCombo" min="-2" pref="166" max="-2" attributes="0"/>
384+
</Group>
385+
<Group type="102" alignment="0" attributes="0">
386+
<Component id="jLabel8" min="-2" max="-2" attributes="0"/>
387+
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
382388
<Component id="singleTexLoadButton" min="-2" max="-2" attributes="0"/>
383-
<EmptySpace max="-2" attributes="0"/>
389+
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
384390
<Component id="singlePic" min="-2" pref="20" max="-2" attributes="0"/>
385391
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
386392
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
@@ -391,12 +397,8 @@
391397
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
392398
<Component id="normal2Z" min="-2" pref="21" max="-2" attributes="1"/>
393399
</Group>
394-
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
395-
<Component id="flipYcheckBox" alignment="1" max="32767" attributes="1"/>
396-
<Component id="spheremapCheckBox" alignment="1" max="32767" attributes="1"/>
397-
</Group>
398400
</Group>
399-
<EmptySpace pref="31" max="32767" attributes="0"/>
401+
<EmptySpace max="32767" attributes="0"/>
400402
</Group>
401403
</Group>
402404
</DimensionLayout>
@@ -420,7 +422,10 @@
420422
</Group>
421423
</Group>
422424
<EmptySpace type="unrelated" max="-2" attributes="0"/>
423-
<Component id="spheremapCheckBox" min="-2" max="-2" attributes="0"/>
425+
<Group type="103" groupAlignment="3" attributes="0">
426+
<Component id="mapTypeCombo" alignment="3" min="-2" max="-2" attributes="0"/>
427+
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
428+
</Group>
424429
<EmptySpace max="-2" attributes="0"/>
425430
<Component id="flipYcheckBox" min="-2" max="-2" attributes="0"/>
426431
<EmptySpace pref="75" max="32767" attributes="0"/>
@@ -474,24 +479,39 @@
474479
</Property>
475480
</Properties>
476481
</Component>
477-
<Component class="javax.swing.JCheckBox" name="spheremapCheckBox">
482+
<Component class="javax.swing.JLabel" name="singlePic">
478483
<Properties>
479484
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
480-
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.spheremapCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
485+
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.singlePic.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
481486
</Property>
482487
</Properties>
483488
</Component>
484-
<Component class="javax.swing.JLabel" name="singlePic">
489+
<Component class="javax.swing.JCheckBox" name="flipYcheckBox">
485490
<Properties>
486491
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
487-
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.singlePic.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
492+
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.flipYcheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
488493
</Property>
489494
</Properties>
490495
</Component>
491-
<Component class="javax.swing.JCheckBox" name="flipYcheckBox">
496+
<Component class="javax.swing.JComboBox" name="mapTypeCombo">
497+
<Properties>
498+
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
499+
<StringArray count="4">
500+
<StringItem index="0" value="Item 1"/>
501+
<StringItem index="1" value="Item 2"/>
502+
<StringItem index="2" value="Item 3"/>
503+
<StringItem index="3" value="Item 4"/>
504+
</StringArray>
505+
</Property>
506+
</Properties>
507+
<Events>
508+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mapTypeComboActionPerformed"/>
509+
</Events>
510+
</Component>
511+
<Component class="javax.swing.JLabel" name="jLabel10">
492512
<Properties>
493513
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
494-
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.flipYcheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
514+
<ResourceString bundle="com/jme3/gde/terraineditor/sky/Bundle.properties" key="SkyboxVisualPanel2.jLabel10.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
495515
</Property>
496516
</Properties>
497517
</Component>

sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/sky/SkyboxVisualPanel2.java

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@
3636
import com.jme3.gde.core.properties.preview.DDSPreview;
3737
import com.jme3.gde.core.scene.SceneApplication;
3838
import com.jme3.texture.Texture;
39+
import com.jme3.util.SkyFactory;
3940
import java.awt.Component;
41+
import javax.swing.ComboBoxModel;
42+
import javax.swing.DefaultComboBoxModel;
4043
import javax.swing.Icon;
4144
import javax.swing.JCheckBox;
45+
import javax.swing.JComboBox;
4246
import javax.swing.JPanel;
4347
import javax.swing.JTextField;
4448
import jme3tools.converters.ImageToAwt;
@@ -51,6 +55,12 @@ public final class SkyboxVisualPanel2 extends JPanel {
5155
/** Creates new form SkyboxVisualPanel2 */
5256
public SkyboxVisualPanel2() {
5357
initComponents();
58+
59+
DefaultComboBoxModel<SkyFactory.EnvMapType> model = new DefaultComboBoxModel<SkyFactory.EnvMapType>();
60+
for (SkyFactory.EnvMapType value : SkyFactory.EnvMapType.values()) {
61+
model.addElement(value);
62+
}
63+
mapTypeCombo.setModel(model);
5464
}
5565

5666
@Override
@@ -140,11 +150,12 @@ private void initComponents() {
140150
normal2X = new javax.swing.JTextField();
141151
normal2Y = new javax.swing.JTextField();
142152
normal2Z = new javax.swing.JTextField();
143-
spheremapCheckBox = new javax.swing.JCheckBox();
144153
singlePic = new javax.swing.JLabel();
145154
flipYcheckBox = new javax.swing.JCheckBox();
155+
mapTypeCombo = new javax.swing.JComboBox();
156+
jLabel10 = new javax.swing.JLabel();
146157

147-
titleLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
158+
titleLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
148159
org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.titleLabel.text")); // NOI18N
149160

150161
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.jLabel1.text")); // NOI18N
@@ -279,7 +290,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
279290
.addComponent(multipleTexTopLoadButton)
280291
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
281292
.addComponent(topPic, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))))
282-
.addContainerGap(27, Short.MAX_VALUE))
293+
.addContainerGap(29, Short.MAX_VALUE))
283294
);
284295
multipleTexturePanelLayout.setVerticalGroup(
285296
multipleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -315,7 +326,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
315326
.addGroup(multipleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
316327
.addComponent(jLabel5)
317328
.addComponent(multipleTexTopLoadButton))
318-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
329+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
319330
.addGroup(multipleTexturePanelLayout.createSequentialGroup()
320331
.addComponent(westPic, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
321332
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
@@ -346,24 +357,36 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
346357

347358
normal2Z.setText(org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.normal2Z.text")); // NOI18N
348359

349-
org.openide.awt.Mnemonics.setLocalizedText(spheremapCheckBox, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.spheremapCheckBox.text")); // NOI18N
350-
351360
org.openide.awt.Mnemonics.setLocalizedText(singlePic, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.singlePic.text")); // NOI18N
352361

353362
org.openide.awt.Mnemonics.setLocalizedText(flipYcheckBox, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.flipYcheckBox.text")); // NOI18N
354363

364+
mapTypeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
365+
mapTypeCombo.addActionListener(new java.awt.event.ActionListener() {
366+
public void actionPerformed(java.awt.event.ActionEvent evt) {
367+
mapTypeComboActionPerformed(evt);
368+
}
369+
});
370+
371+
org.openide.awt.Mnemonics.setLocalizedText(jLabel10, org.openide.util.NbBundle.getMessage(SkyboxVisualPanel2.class, "SkyboxVisualPanel2.jLabel10.text")); // NOI18N
372+
355373
javax.swing.GroupLayout singleTexturePanelLayout = new javax.swing.GroupLayout(singleTexturePanel);
356374
singleTexturePanel.setLayout(singleTexturePanelLayout);
357375
singleTexturePanelLayout.setHorizontalGroup(
358376
singleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
359377
.addGroup(singleTexturePanelLayout.createSequentialGroup()
360378
.addContainerGap()
361379
.addGroup(singleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
380+
.addComponent(flipYcheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
362381
.addGroup(singleTexturePanelLayout.createSequentialGroup()
363-
.addComponent(jLabel8)
382+
.addComponent(jLabel10)
364383
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
384+
.addComponent(mapTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
385+
.addGroup(singleTexturePanelLayout.createSequentialGroup()
386+
.addComponent(jLabel8)
387+
.addGap(21, 21, 21)
365388
.addComponent(singleTexLoadButton)
366-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
389+
.addGap(2, 2, 2)
367390
.addComponent(singlePic, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
368391
.addGap(39, 39, 39)
369392
.addComponent(jLabel9)
@@ -372,11 +395,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
372395
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
373396
.addComponent(normal2Y, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
374397
.addGap(6, 6, 6)
375-
.addComponent(normal2Z, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
376-
.addGroup(singleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
377-
.addComponent(flipYcheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
378-
.addComponent(spheremapCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
379-
.addContainerGap(31, Short.MAX_VALUE))
398+
.addComponent(normal2Z, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
399+
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
380400
);
381401
singleTexturePanelLayout.setVerticalGroup(
382402
singleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -394,7 +414,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
394414
.addComponent(normal2Z, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
395415
.addComponent(jLabel9))))
396416
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
397-
.addComponent(spheremapCheckBox)
417+
.addGroup(singleTexturePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
418+
.addComponent(mapTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
419+
.addComponent(jLabel10))
398420
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
399421
.addComponent(flipYcheckBox)
400422
.addContainerGap(75, Short.MAX_VALUE))
@@ -565,11 +587,17 @@ private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt)
565587
}
566588
}
567589
}//GEN-LAST:event_singleTexLoadButtonActionPerformed
590+
591+
private void mapTypeComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mapTypeComboActionPerformed
592+
// TODO add your handling code here:
593+
}//GEN-LAST:event_mapTypeComboActionPerformed
594+
568595
// Variables declaration - do not modify//GEN-BEGIN:variables
569596
private javax.swing.JLabel bottomPic;
570597
private javax.swing.JLabel eastPic;
571598
private javax.swing.JCheckBox flipYcheckBox;
572599
private javax.swing.JLabel jLabel1;
600+
private javax.swing.JLabel jLabel10;
573601
private javax.swing.JLabel jLabel2;
574602
private javax.swing.JLabel jLabel3;
575603
private javax.swing.JLabel jLabel4;
@@ -578,6 +606,7 @@ private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt)
578606
private javax.swing.JLabel jLabel7;
579607
private javax.swing.JLabel jLabel8;
580608
private javax.swing.JLabel jLabel9;
609+
private javax.swing.JComboBox mapTypeCombo;
581610
private javax.swing.JButton multipleTexBottomLoadButton;
582611
private javax.swing.JButton multipleTexEastLoadButton;
583612
private javax.swing.JButton multipleTexNorthLoadButton;
@@ -596,7 +625,6 @@ private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt)
596625
private javax.swing.JButton singleTexLoadButton;
597626
private javax.swing.JPanel singleTexturePanel;
598627
private javax.swing.JLabel southPic;
599-
private javax.swing.JCheckBox spheremapCheckBox;
600628
private javax.swing.JLabel titleLabel;
601629
private javax.swing.JLabel topPic;
602630
private javax.swing.JLabel westPic;
@@ -626,10 +654,11 @@ public JTextField getNormal2Z() {
626654
return normal2Z;
627655
}
628656

629-
public JCheckBox getSpheremapCheckBox() {
630-
return spheremapCheckBox;
657+
public SkyFactory.EnvMapType getEnvMapType(){
658+
return (SkyFactory.EnvMapType)mapTypeCombo.getSelectedItem();
631659
}
632660

661+
633662
public JCheckBox getFlipYCheckBox() {
634663
return flipYcheckBox;
635664
}

0 commit comments

Comments
 (0)