Normand Briere
2019-08-20 537f4ac57ae2b34f0a04fa63874c8ca6534c9a6d
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 static GLContext glcontext = null;
113
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -164,7 +168,7 @@
164168
165169
166170 // OPTIONS
167
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
168172 boolean cameraLight = false;
169173 boolean UVdebug = false;
170174 boolean Udebug = false;
....@@ -188,15 +192,16 @@
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190194
191
- public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192196 {
193197 try
194198 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196200 } catch (IOException e)
197201 {
198202 System.out.println("NAME = " + name);
199203 e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
200205 }
201206 }
202207
....@@ -2047,9 +2052,9 @@
20472052 switch(viewcode)
20482053 {
20492054 case 0: return "main";
2050
- case 1: return "one";
2051
- case 2: return "two";
2052
- case 3: return "three";
2055
+ case 1: return "Red";
2056
+ case 2: return "Green";
2057
+ case 3: return "Blue";
20532058 case 4: return "light";
20542059 }
20552060
....@@ -2512,7 +2517,7 @@
25122517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25132518 getClass().getClassLoader().getResourceAsStream(name),
25142519 true,
2515
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25162521 } catch (java.io.IOException e)
25172522 {
25182523 throw new javax.media.opengl.GLException(e);
....@@ -9233,6 +9238,8 @@
92339238
92349239 void LoadEnvy(int which)
92359240 {
9241
+ assert(false);
9242
+
92369243 String name;
92379244 String ext;
92389245
....@@ -10683,9 +10690,18 @@
1068310690 static boolean init = false;
1068410691
1068510692 double[][] matrix = LA.newMatrix();
10693
+
10694
+ // This is to refresh the UI of the material panel.
10695
+ ObjEditor patchMaterial;
1068610696
1068710697 public void display(GLAutoDrawable drawable)
1068810698 {
10699
+ if (patchMaterial.patchMaterial)
10700
+ {
10701
+ patchMaterial.patchMaterial = false;
10702
+ patchMaterial.objectPanel.setSelectedIndex(1);
10703
+ }
10704
+
1068910705 if (Grafreed.savesound && Grafreed.hassound)
1069010706 {
1069110707 Grafreed.wav.save();
....@@ -11077,18 +11093,34 @@
1107711093 //
1107811094 // newenvy = -1;
1107911095
11080
- if (object.skyboxname != null)
11096
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1108111097 {
11082
- if (!object.skyboxname.equals(this.loadedskyboxname))
11098
+ if (cubemaprgb == null)
1108311099 {
11084
- LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11085
- loadedskyboxname = object.skyboxname;
11100
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
1108611101 }
11102
+
11103
+ cubemap = cubemaprgb;
1108711104 }
1108811105 else
1108911106 {
11090
- cubemap = null;
11091
- loadedskyboxname = null;
11107
+ if (object.skyboxname != null)
11108
+ {
11109
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11110
+ {
11111
+ if (cubemap != null && cubemap != cubemaprgb)
11112
+ cubemap.dispose();
11113
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11114
+ loadedskyboxname = object.skyboxname;
11115
+ }
11116
+ }
11117
+ else
11118
+ {
11119
+ cubemapcustom = null;
11120
+ loadedskyboxname = null;
11121
+ }
11122
+
11123
+ cubemap = cubemapcustom;
1109211124 }
1109311125
1109411126 ratio = ((double) getWidth()) / getHeight();
....@@ -13396,8 +13428,12 @@
1339613428 program = programmin;
1339713429 }
1339813430
13399
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13400
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13431
+ if (Globals.DEBUG)
13432
+ {
13433
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13434
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13435
+ }
13436
+
1340113437 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1340213438
1340313439 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13444,7 +13480,8 @@
1344413480 "\n" +
1344513481 "END\n";
1344613482
13447
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13483
+ if (Globals.DEBUG)
13484
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1344813485 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1344913486
1345013487 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -14643,11 +14680,17 @@
1464314680 void GoDown(int mod)
1464414681 {
1464514682 MODIFIERS |= COMMAND;
14683
+ boolean isVR = (mouseMode&VR)!=0;
1464614684 /**/
1464714685 if((mod&SHIFT) == SHIFT)
14648
- manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14686
+ {
14687
+ if (isVR)
14688
+ manipCamera.RotateInterest(0, -speed);
14689
+ else
14690
+ manipCamera.RotatePosition(0, -speed);
14691
+ }
1464914692 else
14650
- manipCamera.RotatePosition(0, -speed);
14693
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
1465114694 /**/
1465214695 if ((mod & SHIFT) == SHIFT)
1465314696 {
....@@ -14657,6 +14700,8 @@
1465714700 mouseMode |= BACKFORTH;
1465814701 }
1465914702
14703
+ targetLookAt.set(manipCamera.lookAt);
14704
+
1466014705 //prevX = X = anchorX;
1466114706 prevY = Y = anchorY - (int) (renderCamera.Distance());
1466214707 }
....@@ -14665,10 +14710,17 @@
1466514710 {
1466614711 MODIFIERS |= COMMAND;
1466714712 /**/
14713
+ boolean isVR = (mouseMode&VR)!=0;
14714
+
1466814715 if((mod&SHIFT) == SHIFT)
14669
- manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14716
+ {
14717
+ if (isVR)
14718
+ manipCamera.RotateInterest(0, speed);
14719
+ else
14720
+ manipCamera.RotatePosition(0, speed);
14721
+ }
1467014722 else
14671
- manipCamera.RotatePosition(0, speed);
14723
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
1467214724 /**/
1467314725 if ((mod & SHIFT) == SHIFT)
1467414726 {
....@@ -14678,6 +14730,8 @@
1467814730 mouseMode |= BACKFORTH;
1467914731 }
1468014732
14733
+ targetLookAt.set(manipCamera.lookAt);
14734
+
1468114735 //prevX = X = anchorX;
1468214736 prevY = Y = anchorY + (int) (renderCamera.Distance());
1468314737 }
....@@ -14687,9 +14741,14 @@
1468714741 MODIFIERS |= COMMAND;
1468814742 /**/
1468914743 if((mod&SHIFT) == SHIFT)
14690
- manipCamera.Translate(speed*delta, 0, getWidth());
14744
+ manipCamera.Translate(speed*delta, 0, getWidth());
1469114745 else
14692
- manipCamera.RotatePosition(speed, 0);
14746
+ {
14747
+ if ((mouseMode&VR)!=0)
14748
+ manipCamera.RotateInterest(-speed, 0);
14749
+ else
14750
+ manipCamera.RotatePosition(speed, 0);
14751
+ }
1469314752 /**/
1469414753 if ((mod & SHIFT) == SHIFT)
1469514754 {
....@@ -14699,6 +14758,8 @@
1469914758 mouseMode |= ROTATE;
1470014759 } // TRANSLATE;
1470114760
14761
+ targetLookAt.set(manipCamera.lookAt);
14762
+
1470214763 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1470314764 prevY = Y = anchorY;
1470414765 }
....@@ -14708,9 +14769,15 @@
1470814769 MODIFIERS |= COMMAND;
1470914770 /**/
1471014771 if((mod&SHIFT) == SHIFT)
14711
- manipCamera.Translate(-speed*delta, 0, getWidth());
14772
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1471214773 else
14713
- manipCamera.RotatePosition(-speed, 0);
14774
+ {
14775
+ if ((mouseMode&VR)!=0)
14776
+ manipCamera.RotateInterest(speed, 0);
14777
+ else
14778
+ manipCamera.RotatePosition(-speed, 0);
14779
+ }
14780
+
1471414781 /**/
1471514782 if ((mod & SHIFT) == SHIFT)
1471614783 {
....@@ -14720,6 +14787,8 @@
1472014787 mouseMode |= ROTATE;
1472114788 } // TRANSLATE;
1472214789
14790
+ targetLookAt.set(manipCamera.lookAt);
14791
+
1472314792 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1472414793 prevY = Y = anchorY;
1472514794 }
....@@ -15222,8 +15291,8 @@
1522215291 case 'K':
1522315292 KOMPACTTEXTURE ^= true;
1522415293 //textures.clear();
15225
- break;
15226
- case 'P': // Texture Projection macros
15294
+ // break;
15295
+ //case 'P': // Texture Projection macros
1522715296 // SAVETEXTURE ^= true;
1522815297 macromode = true;
1522915298 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -15344,7 +15413,7 @@
1534415413 targetLookAt.set(manipCamera.lookAt);
1534515414 repaint();
1534615415 break;
15347
- case 'p':
15416
+ case 'P': // p':
1534815417 // c'est quoi ca au juste? spherical ^= true;
1534915418 Skinshader ^= true; programInitialized = false;
1535015419 repaint();
....@@ -16104,7 +16173,7 @@
1610416173 {
1610516174 switch (hitSomething)
1610616175 {
16107
- case Object3D.hitCenter: gr.setColor(Color.pink);
16176
+ case Object3D.hitCenter: gr.setColor(Color.white);
1610816177 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1610916178 break;
1611016179 case Object3D.hitRotate: gr.setColor(Color.yellow);
....@@ -16130,7 +16199,7 @@
1613016199 if (hasMarquee)
1613116200 {
1613216201 gr.setXORMode(Color.white);
16133
- gr.setColor(Color.red);
16202
+ gr.setColor(Color.white);
1613416203 if (!firstime)
1613516204 {
1613616205 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16769,7 +16838,8 @@
1676916838 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1677016839
1677116840 cubemap.disable();
16772
- ////cubemap.unbind();
16841
+ //cubemap.dispose();
16842
+
1677316843 if (CULLFACE)
1677416844 {
1677516845 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17305,6 +17375,7 @@
1730517375
1730617376 public void init(GLAutoDrawable drawable)
1730717377 {
17378
+ if (Globals.DEBUG)
1730817379 System.out.println("shadow buffer init");
1730917380
1731017381 GL gl = drawable.getGL();