Normand Briere
2019-08-27 dce400da7c65d659129abf9bc6e8f38b360a63d2
Fix camera version + VR using spacebar.
6 files modified
93 ■■■■ changed files
CameraPane.java 36 ●●●● patch | view | raw | blame | history
Globals.java 2 ●●●●● patch | view | raw | blame | history
GroupEditor.java 4 ●●●● patch | view | raw | blame | history
ObjEditor.java 29 ●●●● patch | view | raw | blame | history
Object3D.java 21 ●●●● patch | view | raw | blame | history
cMaterial.java 1 ●●●● patch | view | raw | blame | history
CameraPane.java
....@@ -9840,7 +9840,10 @@
98409840 DrawSkyBox(gl, (float)rati);
98419841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
98429842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
9843
- accPerspective(gl, renderCamera.shaper_fovy / ratio,
9843
+
9844
+ boolean vr = capsLocked && !lightMode;
9845
+
9846
+ accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 2 : 1),
98449847 ratio,
98459848 //near_plane, far_plane,
98469849 renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(),
....@@ -11397,7 +11400,9 @@
1139711400 //gl.glOrtho(-BOOST, BOOST, -BOOST, BOOST, 0.001, 1000);
1139811401 } else
1139911402 {
11400
- glu.gluPerspective(cam.shaper_fovy / ratio, ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance());
11403
+ boolean vr = capsLocked && !lightMode;
11404
+
11405
+ glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 2 : 1), ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance());
1140111406 }
1140211407 }
1140311408
....@@ -14250,10 +14255,12 @@
1425014255 return;
1425114256 }
1425214257
14253
- boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14258
+ //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14259
+
14260
+ boolean vr = capsLocked && !lightMode;
1425414261
1425514262 // TIMER
14256
- if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14263
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !vr) // VR
1425714264 {
1425814265 keepboxmode = BOXMODE;
1425914266 keepsupport = SUPPORT;
....@@ -15239,8 +15246,10 @@
1523915246 mouseMode |= ZOOM;
1524015247 }
1524115248
15242
- boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
15243
- if (capsLocked) // || (modifiers & META) == META)
15249
+ //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
15250
+ boolean vr = capsLocked && !lightMode;
15251
+
15252
+ if (vr) // || (modifiers & META) == META)
1524415253 {
1524515254 mouseMode |= VR; // BACKFORTH;
1524615255 }
....@@ -15456,8 +15465,8 @@
1545615465 RevertCamera();
1545715466 repaint();
1545815467 break;
15459
- case 'l':
15460
- //case 'L':
15468
+ //case 'l':
15469
+ case 'L':
1546115470 if (lightMode)
1546215471 {
1546315472 lightMode = false;
....@@ -15515,8 +15524,8 @@
1551515524 break;
1551615525 case 'O':
1551715526 // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING
15518
- repaint();
15519
- break;
15527
+ //repaint();
15528
+ //break;
1552015529 case 'o':
1552115530 OCCLUSION_CULLING ^= true;
1552215531 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
....@@ -15608,6 +15617,10 @@
1560815617 // kompactbit = 6;
1560915618 // break;
1561015619 case ' ':
15620
+ capsLocked ^= true;
15621
+ repaint();
15622
+ break;
15623
+ case 'l':
1561115624 lightMode ^= true;
1561215625 Globals.lighttouched = true;
1561315626 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
....@@ -17911,6 +17924,9 @@
1791117924 static boolean DEBUG_SELECTION = false;
1791217925 boolean OCCLUSION_CULLING = false; //true;
1791317926 public boolean lightMode = false;
17927
+
17928
+ public boolean capsLocked = false; // VR
17929
+
1791417930 static public int indexcount = 0;
1791517931 /*static*/ cColor vertexOcclusion = new cColor();
1791617932 //private int selection_view = -1;
Globals.java
....@@ -1,6 +1,8 @@
11
22 public class Globals
33 {
4
+ static boolean SHOWINFO = true;
5
+
46 static boolean ADVANCED = false; // false;
57
68 static boolean NIMBUSLAF = false; // false;
GroupEditor.java
....@@ -5374,7 +5374,7 @@
53745374 if (tps != null && tps.length > 0 && tps[0].getLastPathComponent() instanceof Camera)
53755375 // a camera
53765376 {
5377
- if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crash the camera because of invalid lightspace
5377
+ if (tps[0].getLastPathComponent() != Globals.theRenderer.LightCamera()) // Crashes the camera because of invalid lightspace
53785378 {
53795379 CameraPane.camerachangeframe = 0; // don't refuse it
53805380 Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
....@@ -5426,7 +5426,7 @@
54265426
54275427 void refreshContents(boolean cp)
54285428 {
5429
- if (Globals.ADVANCED)
5429
+ if (Globals.SHOWINFO)
54305430 //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
54315431 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
54325432 {
ObjEditor.java
....@@ -1882,7 +1882,7 @@
18821882 tabbedPane.add(creditsPanel);
18831883 tabbedPane.setToolTipTextAt(3, "Credits");
18841884
1885
- if (Globals.ADVANCED)
1885
+ if (Globals.SHOWINFO)
18861886 {
18871887 objectPanel.add(infoPanel);
18881888 objectPanel.setIconAt(5, GetIcon("icons/info.png"));
....@@ -4469,6 +4469,8 @@
44694469 CopyChanged(copy);
44704470
44714471 SetVersionStates();
4472
+
4473
+ SetCameras();
44724474 }
44734475
44744476 public boolean Save(boolean user)
....@@ -4547,6 +4549,11 @@
45474549 void RefreshSelection()
45484550 {
45494551 Object3D selection = new Object3D();
4552
+
4553
+ if (objEditor.copy.selection == null)
4554
+ {
4555
+ objEditor.copy.selection = new Object3D();
4556
+ }
45504557
45514558 for (int i = 0; i < objEditor.copy.selection.size(); i++)
45524559 {
....@@ -4682,7 +4689,7 @@
46824689 // Option?
46834690 Replace();
46844691
4685
- System.err.println("Undo");
4692
+ //System.err.println("Previous");
46864693
46874694 //cRadio tab = GetCurrentTab();
46884695
....@@ -4711,6 +4718,8 @@
47114718
47124719 SetVersionStates();
47134720
4721
+ SetCameras();
4722
+
47144723 return true;
47154724 }
47164725
....@@ -4730,6 +4739,8 @@
47304739 CopyChanged(copy);
47314740
47324741 SetVersionStates();
4742
+
4743
+ SetCameras();
47334744
47344745 return true;
47354746 }
....@@ -4771,9 +4782,20 @@
47714782 //if (!tab.user[tab.versionindex])
47724783 // tab.graphs[tab.versionindex] = null;
47734784
4774
- SetVersionStates();
4785
+ SetVersionStates();
4786
+
4787
+ SetCameras();
47754788 }
47764789
4790
+ void SetCameras()
4791
+ {
4792
+ Camera neweye = (Camera)copy.GetObject(cameraView.cameras[0].GetUUID());
4793
+ Camera newlight = (Camera)copy.GetObject(cameraView.LightCamera().GetUUID());
4794
+
4795
+ cameraView.SetCamera(neweye);
4796
+ cameraView.SetLight(newlight);
4797
+ }
4798
+
47774799 void ImportGFD()
47784800 {
47794801 FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
....@@ -5119,6 +5141,7 @@
51195141 copy.versionindex = version;
51205142 CopyChanged(copy);
51215143 SetVersionStates();
5144
+ SetCameras();
51225145 }
51235146
51245147 return;
Object3D.java
....@@ -194,6 +194,8 @@
194194 {
195195 Object3D o;
196196
197
+ boolean isnew = false;
198
+
197199 if (hashtable.containsKey(GetUUID()))
198200 {
199201 o = hashtable.get(GetUUID());
....@@ -206,6 +208,8 @@
206208 }
207209 else
208210 {
211
+ isnew = true;
212
+
209213 o = new Object3D("copy of " + this.name);
210214
211215 hashtable.put(GetUUID(), o);
....@@ -222,12 +226,15 @@
222226
223227 blockloop = false;
224228 }
225
-
226
- ExtractBigData(o);
229
+
230
+ if (isnew)
231
+ ExtractBigData(o);
227232 }
228233
229234 void ExtractBigData(Object3D o)
230235 {
236
+ //System.err.println("ExtractBigData : " + this + " --> " + o);
237
+
231238 if (o.bRep != null)
232239 Grafreed.Assert(o.bRep == this.bRep);
233240
....@@ -238,8 +245,8 @@
238245 // o.bRep.support = null;
239246 // }
240247 o.selection = this.selection;
241
- o.versionlist = this.versionlist;
242
- o.versionindex = this.versionindex;
248
+ //o.versionlist = this.versionlist;
249
+ //o.versionindex = this.versionindex;
243250
244251 if (this.support != null)
245252 {
....@@ -355,6 +362,8 @@
355362
356363 void RestoreBigData(Object3D o)
357364 {
365
+ //System.err.println("RestoreBigData : " + this + " <-- " + o);
366
+
358367 this.bRep = o.bRep;
359368 if (this.support != null && o.transientrep != null)
360369 {
....@@ -363,8 +372,8 @@
363372
364373 this.selection = o.selection;
365374
366
- this.versionlist = o.versionlist;
367
- this.versionindex = o.versionindex;
375
+ //this.versionlist = o.versionlist;
376
+ //this.versionindex = o.versionindex;
368377 // July 2019 if (this.bRep != null)
369378 // this.bRep.support = o.transientrep;
370379 // this.support = o.support;
cMaterial.java
....@@ -41,7 +41,6 @@
4141
4242 public cMaterial(cMaterial mat)
4343 {
44
- this();
4544 if (mat != null)
4645 {
4746 Set(mat);