Normand Briere
2019-08-28 47745d8ade7238a188f7ab78eaf5e8a269d96fdd
Smooth keys + box editor.
8 files modified
477 ■■■■ changed files
BiparamEditor.java 7 ●●●●● patch | view | raw | blame | history
Box.java 66 ●●●● patch | view | raw | blame | history
BoxEditor.java 106 ●●●● patch | view | raw | blame | history
Camera.java 2 ●●● patch | view | raw | blame | history
CameraPane.java 275 ●●●●● patch | view | raw | blame | history
Composite.java 2 ●●● patch | view | raw | blame | history
ObjEditor.java 17 ●●●● patch | view | raw | blame | history
Object3D.java 2 ●●● patch | view | raw | blame | history
BiparamEditor.java
....@@ -72,7 +72,7 @@
7272
7373 int count = 50;
7474
75
- uDivsField = (cNumberSlider)AddSlider(uvPanel, "U #", biparam.minUDivs, (int)(count*this.biparam.uStretch()) + biparam.minUDivs, biparam.uDivs).getComponent(1);
75
+ uDivsField = (cNumberSlider)AddSlider(uvPanel, "U #", biparam.minUDivs, (int)(count*this.biparam.uStretch() / 2) + biparam.minUDivs, biparam.uDivs).getComponent(1);
7676 vDivsField = (cNumberSlider)AddSlider(uvPanel, "V #", biparam.minVDivs, (int)(count) + biparam.minVDivs, biparam.vDivs).getComponent(1);
7777
7878 oe.ctrlPanel.add(uvPanel);
....@@ -104,8 +104,8 @@
104104 if (biparam instanceof Cone) // ends)
105105 {
106106 oe.ctrlPanel.add(optionCB = new JCheckBox("Close Surface", biparam.endcaps)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
107
- optionCB.addItemListener(this);
108
-oe.ctrlPanel.Return();
107
+ optionCB.addItemListener(this);
108
+ oe.ctrlPanel.Return();
109109 //endcaps.setState(!biparam.endcaps);
110110 }
111111 }
....@@ -142,6 +142,7 @@
142142 if (//e.getSource() == nameField ||
143143 e.getSource() == optionCB)
144144 {
145
+ new Exception().printStackTrace();
145146 //System.out.println(e);
146147 applySelf();
147148 //super.applySelf();
Box.java
....@@ -2,6 +2,8 @@
22 {
33 static final long serialVersionUID = 0;
44
5
+ boolean open;
6
+
57 Box()
68 {
79 inPnt = new cVector();
....@@ -9,9 +11,6 @@
911 minima = LA.newVector(-0.5, 0, -0.5);
1012 maxima = LA.newVector(0.5, 1, 0.5);
1113 bRep = new BoundaryRep();
12
- bRep.redimension(8, 12);
13
- for (int i=0; i < 12; i++)
14
- bRep.setFace(i, faces[i]);
1514
1615 recalculate();
1716 CreateMaterial();
....@@ -27,11 +26,11 @@
2726 protected void deepCopySelf(Object3D other)
2827 {
2928 super.deepCopySelf(other);
30
- Box rec = (Box)other;
31
- rec.minima = new cVector();
32
- LA.vecCopy(minima, rec.minima);
33
- rec.maxima = new cVector();
34
- LA.vecCopy(maxima, rec.maxima);
29
+// Box rec = (Box)other;
30
+// rec.minima = new cVector();
31
+// LA.vecCopy(minima, rec.minima);
32
+// rec.maxima = new cVector();
33
+// LA.vecCopy(maxima, rec.maxima);
3534 }
3635
3736 void createEditWindow(GroupEditor callee, boolean newWindow)
....@@ -39,12 +38,12 @@
3938 //editWindow = new BoxEditor(this, deepCopy(), callee);
4039 /**/
4140 if (newWindow)
42
- objectUI = new ObjEditor(this, deepCopy(), callee);
41
+ objectUI = new BoxEditor(this, deepCopy(), callee);
4342 else
44
- objectUI = new ObjEditor(this, callee);
43
+ objectUI = new BoxEditor(this, callee);
4544 editWindow = objectUI.GetEditor();
46
- if (!newWindow)
47
- ((ObjEditor)objectUI).SetupUI2(callee);
45
+// if (!newWindow)
46
+// ((ObjEditor)objectUI).SetupUI2(callee);
4847 /**/
4948 }
5049
....@@ -64,6 +63,19 @@
6463
6564 void recalculate()
6665 {
66
+ if (open)
67
+ {
68
+ bRep.redimension(8, 8);
69
+ for (int i=0; i < 8; i++)
70
+ bRep.setFace(i, facesopen[i]);
71
+ }
72
+ else
73
+ {
74
+ bRep.redimension(8, 12);
75
+ for (int i=0; i < 12; i++)
76
+ bRep.setFace(i, faces[i]);
77
+ }
78
+
6779 for (int i=0; i < 8; i++)
6880 {
6981 double x = i >= 4 ? maxima.x : minima.x;
....@@ -71,7 +83,7 @@
7183 double z = i % 2 != 0 ? maxima.z : minima.z;
7284 bRep.setVertex(i, x, y, z, umap[i], vmap[i]);
7385 }
74
-
86
+
7587 // bRep.Trim(false, false);
7688
7789 super.recalculate();
....@@ -139,5 +151,33 @@
139151 }
140152 };
141153
154
+ static int facesopen[][] = {
155
+ {
156
+ 0, 1, 3
157
+ }, {
158
+ 0, 3, 2
159
+ }, {
160
+// 2, 3, 7
161
+// }, {
162
+// 2, 7, 6
163
+// }, {
164
+ 1, 5, 7
165
+ }, {
166
+ 1, 7, 3
167
+ }, {
168
+ 4, 6, 7
169
+ }, {
170
+ 4, 7, 5
171
+ }, {
172
+// 0, 4, 5
173
+// }, {
174
+// 0, 5, 1
175
+// }, {
176
+ 0, 2, 6
177
+ }, {
178
+ 0, 6, 4
179
+ }
180
+ };
181
+
142182 protected cVector inPnt;
143183 }
BoxEditor.java
....@@ -9,31 +9,46 @@
99
1010 class BoxEditor extends ObjEditor
1111 {
12
+ BoxEditor(Box inBox, GroupEditor callee)
13
+ {
14
+ super(inBox, callee);
15
+
16
+ //objEditor = new BiparamEditor(inCone, this, callee);
17
+ objEditor = callee.GetEditor();
18
+
19
+ this.box = inBox;
20
+
21
+ SetupUI2(GetEditor());
22
+ }
23
+
1224
1325 BoxEditor(Box inBox, Object3D copy, GroupEditor callee)
1426 {
1527 super(inBox, copy, callee);
28
+
29
+ new Exception().printStackTrace();
30
+
1631 box = (Box) copy;
17
- ctrlPanel.add(minLabel = new JLabel("Minima"), aConstraints);
18
- aConstraints.gridx += 1;
19
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
20
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
21
- ctrlPanel.add(minimaField = new NumberField(), aConstraints);
22
- aConstraints.gridwidth = 1;
23
- minimaField.setVector(box.minima);
24
- aConstraints.gridx = 0;
25
- aConstraints.gridy += 1;
26
- aConstraints.fill = GridBagConstraints.NONE;
27
- ctrlPanel.add(maxLabel = new JLabel("Maxima"), aConstraints);
28
- aConstraints.gridx += 1;
29
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
30
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
31
- ctrlPanel.add(maximaField = new NumberField(), aConstraints);
32
- aConstraints.gridwidth = 1;
33
- maximaField.setVector(box.maxima);
34
- aConstraints.fill = GridBagConstraints.NONE;
35
- aConstraints.gridx = 0;
36
- aConstraints.gridy += 1;
32
+// ctrlPanel.add(minLabel = new JLabel("Minima"), aConstraints);
33
+// aConstraints.gridx += 1;
34
+// aConstraints.fill = GridBagConstraints.HORIZONTAL;
35
+// aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
36
+// ctrlPanel.add(minimaField = new NumberField(), aConstraints);
37
+// aConstraints.gridwidth = 1;
38
+// minimaField.setVector(box.minima);
39
+// aConstraints.gridx = 0;
40
+// aConstraints.gridy += 1;
41
+// aConstraints.fill = GridBagConstraints.NONE;
42
+// ctrlPanel.add(maxLabel = new JLabel("Maxima"), aConstraints);
43
+// aConstraints.gridx += 1;
44
+// aConstraints.fill = GridBagConstraints.HORIZONTAL;
45
+// aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
46
+// ctrlPanel.add(maximaField = new NumberField(), aConstraints);
47
+// aConstraints.gridwidth = 1;
48
+// maximaField.setVector(box.maxima);
49
+// aConstraints.fill = GridBagConstraints.NONE;
50
+// aConstraints.gridx = 0;
51
+// aConstraints.gridy += 1;
3752 }
3853
3954 void Clear()
....@@ -53,17 +68,56 @@
5368 }
5469 */
5570
71
+ void SetupUI2(ObjEditor oe)
72
+ {
73
+ super.SetupUI2(oe);
74
+
75
+ oe.ctrlPanel.add(optionCB = new JCheckBox("Close Surface", box.open)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
76
+ optionCB.addItemListener(this);
77
+ oe.ctrlPanel.Return();
78
+ }
79
+
80
+ public void itemStateChanged(ItemEvent e)
81
+ {
82
+ if (//e.getSource() == nameField ||
83
+ e.getSource() == optionCB)
84
+ {
85
+ box.open = (e.getStateChange() == ItemEvent.SELECTED);
86
+
87
+ applySelf();
88
+
89
+ objEditor.refreshContents();
90
+ }
91
+ else
92
+ {
93
+ super.itemStateChanged(e);
94
+ }
95
+ }
96
+
97
+
98
+ public void closeUI()
99
+ {
100
+ ObjEditor oe = GetEditor();
101
+
102
+ oe.ctrlPanel.remove(optionCB);
103
+
104
+ super.closeUI();
105
+ }
106
+
56107 public void applySelf()
57108 {
58109 // june 2013 super.applySelf();
59
- minimaField.getVector(box.minima);
60
- maximaField.getVector(box.maxima);
110
+// minimaField.getVector(box.minima);
111
+// maximaField.getVector(box.maxima);
61112 box.recalculate();
62113 }
63114
64115 Box box;
65
- JLabel minLabel;
66
- JLabel maxLabel;
67
- NumberField minimaField;
68
- NumberField maximaField;
116
+
117
+// JLabel minLabel;
118
+// JLabel maxLabel;
119
+// NumberField minimaField;
120
+// NumberField maximaField;
121
+
122
+ JCheckBox optionCB;
69123 }
Camera.java
....@@ -328,7 +328,7 @@
328328 location.set(lookAt);
329329 lookAt.set(cStatic.point1);
330330
331
- //computeTransform();
331
+ computeTransform();
332332 }
333333
334334 //synchronized // june 2014
CameraPane.java
....@@ -8642,7 +8642,9 @@
86428642 {
86438643 tex.bw = texturecache.texturedata.getWidth();
86448644 tex.bh = texturecache.texturedata.getHeight();
8645
- tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8645
+ tex.bumpdata = //CompressJPEG(CreateBim(
8646
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8647
+ //, tex.bw, tex.bh), 0.5f);
86468648 }
86478649 }
86488650 }
....@@ -10813,6 +10815,83 @@
1081310815
1081410816 if (DrawMode() == DEFAULT)
1081510817 {
10818
+ if (manipCamera == lightCamera)
10819
+ {
10820
+// switch (e.getKeyCode())
10821
+// {
10822
+// case DOWN_ARROW:
10823
+// lightCamera.DECAL /= 2;
10824
+// repaint();
10825
+// break;
10826
+// case UP_ARROW:
10827
+// lightCamera.DECAL *= 2;
10828
+// repaint();
10829
+// break;
10830
+// case LEFT_ARROW:
10831
+// lightCamera.SCALE /= 2;
10832
+// repaint();
10833
+// break;
10834
+// case RIGHT_ARROW:
10835
+// lightCamera.SCALE *= 2;
10836
+// repaint();
10837
+// break;
10838
+// default:
10839
+// break;
10840
+ if (keys[DOWN_ARROW])
10841
+ {
10842
+ lightCamera.DECAL /= 2;
10843
+ }
10844
+
10845
+ if (keys[UP_ARROW])
10846
+ {
10847
+ lightCamera.DECAL *= 2;
10848
+ }
10849
+
10850
+ if (keys[LEFT_ARROW])
10851
+ {
10852
+ lightCamera.SCALE /= 2;
10853
+ }
10854
+
10855
+ if (keys[RIGHT_ARROW])
10856
+ {
10857
+ lightCamera.SCALE *= 2;
10858
+ }
10859
+ }
10860
+ else
10861
+ {
10862
+ //pingthread.mute = true;
10863
+
10864
+ boolean keyon = false;
10865
+
10866
+ if (keys[DOWN_ARROW])
10867
+ {
10868
+ GoDown(modifiers);
10869
+ keyon = true;
10870
+ }
10871
+
10872
+ if (keys[UP_ARROW])
10873
+ {
10874
+ GoUp(modifiers);
10875
+ keyon = true;
10876
+ }
10877
+
10878
+ if (keys[LEFT_ARROW])
10879
+ {
10880
+ GoLeft(modifiers);
10881
+ keyon = true;
10882
+ }
10883
+
10884
+ if (keys[RIGHT_ARROW])
10885
+ {
10886
+ GoRight(modifiers);
10887
+ keyon = true;
10888
+ }
10889
+
10890
+ if (keyon)
10891
+ repaint();
10892
+ //pingthread.mute = false;
10893
+ }
10894
+
1081610895 currentlydrawing = true;
1081710896 }
1081810897
....@@ -11337,9 +11416,9 @@
1133711416
1133811417 gl.glMatrixMode(GL.GL_MODELVIEW);
1133911418
11340
-gl.glEnable(gl.GL_POLYGON_SMOOTH);
11341
-gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11342
-gl.glEnable(gl.GL_MULTISAMPLE);
11419
+//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11420
+//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11421
+//gl.glEnable(gl.GL_MULTISAMPLE);
1134311422 } else
1134411423 {
1134511424 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -14521,6 +14600,8 @@
1452114600 {
1452214601 boolean jump;
1452314602
14603
+ boolean mute;
14604
+
1452414605 // void JumpToTarget()
1452514606 // {
1452614607 // StepToTarget(true);
....@@ -14535,6 +14616,9 @@
1453514616 // only one thread!? synchronized
1453614617 void StepToTarget(boolean jump)
1453714618 {
14619
+ if (mute)
14620
+ return;
14621
+
1453814622 tmp.set(targetLookAt);
1453914623 tmp.sub(manipCamera.lookAt); // june 2014
1454014624
....@@ -14828,6 +14912,9 @@
1482814912 mouseMode |= ROTATE;
1482914913 } // TRANSLATE;
1483014914
14915
+ //System.err.println("lookAt = " + manipCamera.lookAt);
14916
+ //System.err.println("location = " + manipCamera.location);
14917
+
1483114918 targetLookAt.set(manipCamera.lookAt);
1483214919
1483314920 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
....@@ -15767,98 +15854,112 @@
1576715854 }
1576815855 }
1576915856
15857
+ boolean keys[] = new boolean[256];
15858
+ int modifiers = 0;
15859
+
1577015860 public void processKeyEvent(KeyEvent e)
1577115861 {
1577215862 switch (e.getID())
1577315863 {
1577415864 case KeyEvent.KEY_PRESSED:
15775
- if (!autorepeat)
15776
- {
15777
- //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode()));
15778
- keyPressed(e.getKeyChar(), e.getModifiersEx());
15779
- }
15780
- if (manipCamera == lightCamera)
15781
- {
15782
- switch (e.getKeyCode())
15783
- {
15784
- case DOWN_ARROW:
15785
- lightCamera.DECAL /= 2;
15786
- repaint();
15787
- break;
15788
- case UP_ARROW:
15789
- lightCamera.DECAL *= 2;
15790
- repaint();
15791
- break;
15792
- case LEFT_ARROW:
15793
- lightCamera.SCALE /= 2;
15794
- repaint();
15795
- break;
15796
- case RIGHT_ARROW:
15797
- lightCamera.SCALE *= 2;
15798
- repaint();
15799
- break;
15800
- default:
15801
- break;
15802
- }
15803
-
15804
- System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE);
15805
- } else
15806
- {
15807
- if (true) // !autorepeat)
15808
- {
15809
- boolean reset = true;
15810
-
15811
- switch (e.getKeyCode())
15812
- {
15813
- case DOWN_ARROW:
15814
- GoDown(e.getModifiersEx());
15815
- repaint();
15816
- break;
15817
- case UP_ARROW:
15818
- GoUp(e.getModifiersEx());
15819
- repaint();
15820
- break;
15821
- case LEFT_ARROW:
15822
- GoLeft(e.getModifiersEx());
15823
- repaint();
15824
- break;
15825
- case RIGHT_ARROW:
15826
- GoRight(e.getModifiersEx());
15827
- repaint();
15828
- break;
15829
- default:
15830
- reset = false;
15831
- break;
15832
- }
15833
-
15834
- if (reset)
15835
- {
15836
- autorepeat = true;
15837
-
15838
- targetLookAt.set(manipCamera.lookAt);
15839
- }
15840
- }
15841
- }
15865
+ keys[e.getKeyCode()] = true;
15866
+ modifiers = e.getModifiersEx();
15867
+ keyPressed(e.getKeyChar(), modifiers);
15868
+ //Globals.theRenderer.keyPressed(e.getKeyChar());
15869
+ repaint();
1584215870 break;
15843
- case KeyEvent.KEY_TYPED:
15844
- break;
15871
+// if (!autorepeat)
15872
+// {
15873
+// //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode()));
15874
+// keyPressed(e.getKeyChar(), e.getModifiersEx());
15875
+// }
15876
+// if (manipCamera == lightCamera)
15877
+// {
15878
+// switch (e.getKeyCode())
15879
+// {
15880
+// case DOWN_ARROW:
15881
+// lightCamera.DECAL /= 2;
15882
+// repaint();
15883
+// break;
15884
+// case UP_ARROW:
15885
+// lightCamera.DECAL *= 2;
15886
+// repaint();
15887
+// break;
15888
+// case LEFT_ARROW:
15889
+// lightCamera.SCALE /= 2;
15890
+// repaint();
15891
+// break;
15892
+// case RIGHT_ARROW:
15893
+// lightCamera.SCALE *= 2;
15894
+// repaint();
15895
+// break;
15896
+// default:
15897
+// break;
15898
+// }
15899
+//
15900
+// System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE);
15901
+// } else
15902
+// {
15903
+// if (true) // !autorepeat)
15904
+// {
15905
+// boolean reset = true;
15906
+//
15907
+// switch (e.getKeyCode())
15908
+// {
15909
+// case DOWN_ARROW:
15910
+// GoDown(e.getModifiersEx());
15911
+// repaint();
15912
+// break;
15913
+// case UP_ARROW:
15914
+// GoUp(e.getModifiersEx());
15915
+// repaint();
15916
+// break;
15917
+// case LEFT_ARROW:
15918
+// GoLeft(e.getModifiersEx());
15919
+// repaint();
15920
+// break;
15921
+// case RIGHT_ARROW:
15922
+// GoRight(e.getModifiersEx());
15923
+// repaint();
15924
+// break;
15925
+// default:
15926
+// reset = false;
15927
+// break;
15928
+// }
15929
+//
15930
+// if (reset)
15931
+// {
15932
+// autorepeat = true;
15933
+//
15934
+// targetLookAt.set(manipCamera.lookAt);
15935
+// }
15936
+// }
15937
+// }
15938
+// break;
15939
+// case KeyEvent.KEY_TYPED:
15940
+// break;
1584515941 case KeyEvent.KEY_RELEASED:
15846
- {
15847
- switch (e.getKeyCode())
15848
- {
15849
- case DOWN_ARROW:
15850
- case UP_ARROW:
15851
- case LEFT_ARROW:
15852
- case RIGHT_ARROW:
15853
- MODIFIERS &= ~COMMAND;
15854
- autorepeat = false;
15855
- break;
15856
- default:
15857
- break;
15858
- }
15942
+ keys[e.getKeyCode()] = false;
15943
+ modifiers = e.getModifiersEx();
1585915944 keyReleased(e.getKeyChar(), e.getModifiersEx());
15945
+ repaint();
1586015946 break;
15861
- }
15947
+// {
15948
+// switch (e.getKeyCode())
15949
+// {
15950
+// case DOWN_ARROW:
15951
+// case UP_ARROW:
15952
+// case LEFT_ARROW:
15953
+// case RIGHT_ARROW:
15954
+// MODIFIERS &= ~COMMAND;
15955
+// autorepeat = false;
15956
+// break;
15957
+// default:
15958
+// break;
15959
+// }
15960
+// keyReleased(e.getKeyChar(), e.getModifiersEx());
15961
+// break;
15962
+// }
1586215963 default:
1586315964 break;
1586415965 }
Composite.java
....@@ -877,7 +877,7 @@
877877 }
878878 catch (Exception e)
879879 {
880
- System.err.println("FAILED: " + this);
880
+ // System.err.println("FAILED: " + this);
881881 failedPigment = true;
882882 }
883883
ObjEditor.java
....@@ -136,10 +136,19 @@
136136 {
137137 BufferedImage image;
138138
139
- if (name.endsWith("jpg"))
140
- // Much faster!
141
- image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
142
- else
139
+// if (name.endsWith("jpg"))
140
+// {
141
+// try
142
+// {
143
+// // Much faster!
144
+// image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
145
+// }
146
+// catch (Exception e)
147
+// {
148
+// image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
149
+// }
150
+// }
151
+// else
143152 image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
144153
145154 // if (image.getWidth() > 48 && image.getHeight() > 48)
Object3D.java
....@@ -6351,7 +6351,7 @@
63516351 }
63526352 catch (Exception e)
63536353 {
6354
- System.err.println("FAILED: " + this);
6354
+ // System.err.println("FAILED: " + this);
63556355 failedPigment = true;
63566356 }
63576357