Normand Briere
2019-07-24 ebd16116fc612bf14e2469ba27dd7ee54918eabb
CameraPane.java
....@@ -12400,7 +12400,52 @@
1240012400 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1240112401
1240212402 String program =
12403
+ // Min shader
1240312404 "!!ARBfp1.0\n" +
12405
+ "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" +
12406
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12407
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12408
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12409
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12410
+ "TEMP temp;" +
12411
+ "TEMP light;" +
12412
+ "TEMP ndotl;" +
12413
+ "TEMP normal;" +
12414
+ "TEMP depth;" +
12415
+
12416
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
+
12418
+ "MOV light, state.light[0].position;" +
12419
+ "DP3 ndotl.x, light, normal;" +
12420
+
12421
+ // shadow
12422
+ "MOV temp, fragment.texcoord[1];" +
12423
+ TextureFetch("depth", "temp", "1") +
12424
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
+ "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
+
12427
+
12428
+ // No shadow when out of frustum
12429
+ //"SGE temp.y, depth.z, zero123.y;" +
12430
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12431
+
12432
+ "MUL ndotl.x, ndotl.x, temp.x;" +
12433
+ "MAX ndotl.x, ndotl.x, pow2.y;" +
12434
+
12435
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12436
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12437
+ "MUL temp, temp, ndotl.x;" +
12438
+
12439
+ "MUL temp, temp, zero123.z;" +
12440
+
12441
+ "MOV temp.w, zero123.y;" + // reset alpha
12442
+
12443
+ "MOV result.color, temp;" +
12444
+ "END";
12445
+
12446
+ String program2 =
12447
+ "!!ARBfp1.0\n" +
12448
+
1240412449 //"OPTION ARB_fragment_program_shadow;" +
1240512450 "PARAM light2cam0 = program.env[10];" +
1240612451 "PARAM light2cam1 = program.env[11];" +
....@@ -12515,8 +12560,7 @@
1251512560 "TEMP shininess;" +
1251612561 "\n" +
1251712562 "MOV texSamp, one;" +
12518
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12519
-
12563
+
1252012564 "MOV mapgrid.x, one2048th.x;" +
1252112565 "MOV temp, fragment.texcoord[1];" +
1252212566 /*
....@@ -12921,7 +12965,7 @@
1292112965 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1292212966 "") +
1292312967
12924
- // display shadow only (bump == 0)
12968
+ // display shadow only (fakedepth == 0)
1292512969 "SUB temp.x, half.x, shadow.x;" +
1292612970 "MOV temp.y, -params5.z;" + // params6.x;" +
1292712971 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13353,20 +13397,20 @@
1335313397 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1335413398 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1335513399 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13400
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13401
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1335613402 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13357
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13358
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13359
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13360
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13403
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13404
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1336113405 //"SWZ buffer, temp, w,w,w,w;";
13362
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13406
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1336313407 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1336413408 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1336513409 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13366
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13410
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1336713411
13368
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13369
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13412
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13413
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1337013414 }
1337113415
1337213416 String Shadow(String depth, String shadow)
....@@ -13413,7 +13457,7 @@
1341313457 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1341413458 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341513459
13416
- // No shadow when out of frustrum
13460
+ // No shadow when out of frustum
1341713461 "SGE temp.x, " + depth + ".z, one.z;" +
1341813462 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1341913463 "";
....@@ -14211,14 +14255,15 @@
1421114255 drag = false;
1421214256 //System.out.println("Mouse DOWN");
1421314257 editObj = false;
14214
- ClickInfo info = new ClickInfo();
14215
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14216
- info.pane = this;
14217
- info.camera = renderCamera;
14218
- info.x = x;
14219
- info.y = y;
14220
- info.modifiers = modifiersex;
14221
- editObj = object.doEditClick(info, 0);
14258
+ //ClickInfo info = new ClickInfo();
14259
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14260
+ object.clickInfo.pane = this;
14261
+ object.clickInfo.camera = renderCamera;
14262
+ object.clickInfo.x = x;
14263
+ object.clickInfo.y = y;
14264
+ object.clickInfo.modifiers = modifiersex;
14265
+ editObj = object.doEditClick(//info,
14266
+ 0);
1422214267 if (!editObj)
1422314268 {
1422414269 hasMarquee = true;
....@@ -14618,15 +14663,16 @@
1461814663 if (editObj)
1461914664 {
1462014665 drag = true;
14621
- ClickInfo info = new ClickInfo();
14622
- info.bounds.setBounds(0, 0,
14666
+ //ClickInfo info = new ClickInfo();
14667
+ object.clickInfo.bounds.setBounds(0, 0,
1462314668 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14624
- info.pane = this;
14625
- info.camera = renderCamera;
14626
- info.x = x;
14627
- info.y = y;
14628
- object.GetWindow().copy
14629
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14669
+ object.clickInfo.pane = this;
14670
+ object.clickInfo.camera = renderCamera;
14671
+ object.clickInfo.x = x;
14672
+ object.clickInfo.y = y;
14673
+ object //.GetWindow().copy
14674
+ .doEditDrag(//info,
14675
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1463014676 } else
1463114677 {
1463214678 if (x < startX)
....@@ -14775,24 +14821,27 @@
1477514821 }
1477614822 }
1477714823
14824
+// ClickInfo clickInfo = new ClickInfo();
14825
+
1477814826 public void mouseMoved(MouseEvent e)
1477914827 {
1478014828 //System.out.println("mouseMoved: " + e);
1478114829 if (isRenderer)
1478214830 return;
1478314831
14784
- ClickInfo ci = new ClickInfo();
14785
- ci.x = e.getX();
14786
- ci.y = e.getY();
14787
- ci.modifiers = e.getModifiersEx();
14788
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14789
- ci.pane = this;
14790
- ci.camera = renderCamera;
14832
+ // Mouse cursor feedback
14833
+ object.clickInfo.x = e.getX();
14834
+ object.clickInfo.y = e.getY();
14835
+ object.clickInfo.modifiers = e.getModifiersEx();
14836
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14837
+ object.clickInfo.pane = this;
14838
+ object.clickInfo.camera = renderCamera;
1479114839 if (!isRenderer)
1479214840 {
1479314841 //ObjEditor editWindow = object.editWindow;
1479414842 //Object3D copy = editWindow.copy;
14795
- if (object.doEditClick(ci, 0))
14843
+ if (object.doEditClick(//clickInfo,
14844
+ 0))
1479614845 {
1479714846 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1479814847 } else
....@@ -15818,8 +15867,6 @@
1581815867
1581915868 int width = getBounds().width;
1582015869 int height = getBounds().height;
15821
- ClickInfo info = new ClickInfo();
15822
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1582315870 //Image img = CreateImage(width, height);
1582415871 //System.out.println("width = " + width + "; height = " + height + "\n");
1582515872
....@@ -15896,31 +15943,37 @@
1589615943 }
1589715944 if (object != null && !hasMarquee)
1589815945 {
15946
+ if (object.clickInfo == null)
15947
+ object.clickInfo = new ClickInfo();
15948
+ ClickInfo info = object.clickInfo;
15949
+ //ClickInfo info = new ClickInfo();
15950
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
15951
+
1589915952 if (isRenderer)
1590015953 {
15901
- info.flags++;
15954
+ object.clickInfo.flags++;
1590215955 double frameAspect = (double) width / (double) height;
1590315956 if (frameAspect > renderCamera.aspect)
1590415957 {
1590515958 int desired = (int) ((double) height * renderCamera.aspect);
15906
- info.bounds.width -= width - desired;
15907
- info.bounds.x += (width - desired) / 2;
15959
+ object.clickInfo.bounds.width -= width - desired;
15960
+ object.clickInfo.bounds.x += (width - desired) / 2;
1590815961 } else
1590915962 {
1591015963 int desired = (int) ((double) width / renderCamera.aspect);
15911
- info.bounds.height -= height - desired;
15912
- info.bounds.y += (height - desired) / 2;
15964
+ object.clickInfo.bounds.height -= height - desired;
15965
+ object.clickInfo.bounds.y += (height - desired) / 2;
1591315966 }
1591415967 }
1591515968
15916
- info.g = gr;
15917
- info.camera = renderCamera;
15969
+ object.clickInfo.g = gr;
15970
+ object.clickInfo.camera = renderCamera;
1591815971 /*
1591915972 // Memory intensive (brep.verticescopy)
1592015973 if (!(object instanceof Composite))
1592115974 object.draw(info, 0, false); // SLOW :
1592215975 */
15923
- if (!isRenderer)
15976
+ if (!isRenderer) // && drag)
1592415977 {
1592515978 Grafreed.Assert(object != null);
1592615979 Grafreed.Assert(object.selection != null);
....@@ -15928,9 +15981,9 @@
1592815981 {
1592915982 int hitSomething = object.selection.get(0).hitSomething;
1593015983
15931
- info.DX = 0;
15932
- info.DY = 0;
15933
- info.W = 1;
15984
+ object.clickInfo.DX = 0;
15985
+ object.clickInfo.DY = 0;
15986
+ object.clickInfo.W = 1;
1593415987 if (hitSomething == Object3D.hitCenter)
1593515988 {
1593615989 info.DX = X;
....@@ -15942,7 +15995,8 @@
1594215995 info.DY -= info.bounds.height/2;
1594315996 }
1594415997
15945
- object.drawEditHandles(info, 0);
15998
+ object.drawEditHandles(//info,
15999
+ 0);
1594616000
1594716001 if (drag && (X != 0 || Y != 0))
1594816002 {
....@@ -15955,7 +16009,7 @@
1595516009 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1595616010 break;
1595716011 case Object3D.hitScale: gr.setColor(Color.cyan);
15958
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16012
+ gr.drawLine(X, Y, 0, 0);
1595916013 break;
1596016014 }
1596116015