Normand Briere
2019-04-28 f1c718cce66e5651a0dae91375db6ebfaded1a92
Test unfold UV
7 files modified
249 ■■■■■ changed files
BoundaryRep.java 150 ●●●●● patch | view | raw | blame | history
CameraPane.java 29 ●●●● patch | view | raw | blame | history
GrafreeD.java 9 ●●●● patch | view | raw | blame | history
GroupEditor.java 42 ●●●● patch | view | raw | blame | history
Object3D.java 4 ●●● patch | view | raw | blame | history
timeflow/app/TimeflowApp.java 6 ●●●● patch | view | raw | blame | history
timeflow/views/IntroView.java 9 ●●●● patch | view | raw | blame | history
BoundaryRep.java
....@@ -3155,7 +3155,27 @@
31553155 */
31563156 }
31573157
3158
- void GenUV()
3158
+ void UnfoldUV()
3159
+ {
3160
+ for (int i = 0; i < VertexCount(); i++)
3161
+ {
3162
+ Vertex v = GetVertex(i);
3163
+
3164
+ v.x = v.s;
3165
+ v.y = v.t;
3166
+ v.z = 0;
3167
+
3168
+ v.norm.x = 0;
3169
+ v.norm.y = 0;
3170
+ v.norm.z = 1;
3171
+
3172
+ SetVertex(v, i);
3173
+ }
3174
+ }
3175
+
3176
+ float power = 2;
3177
+
3178
+ void GenUV() // float power)
31593179 {
31603180 Trim();
31613181
....@@ -3219,6 +3239,115 @@
32193239 y -= 0.5;
32203240 z -= 0.5;
32213241
3242
+ double ax = Math.abs(x);
3243
+ double ay = Math.abs(y);
3244
+ double max = ax;
3245
+ if (max < ay)
3246
+ {
3247
+ max = ay;
3248
+ }
3249
+
3250
+ x /= max;
3251
+ y /= max;
3252
+
3253
+ double angle = Math.acos(Math.abs(z*2));
3254
+
3255
+ double k = angle / Math.PI * 2;
3256
+
3257
+ // k == 0 => uv = 0 (center)
3258
+ // k == 1 => uv = -1,1 (border)
3259
+
3260
+ if (i == 0)
3261
+ System.out.println("power = " + power);
3262
+
3263
+ double length1 = (ax+ay)/max;
3264
+ double length2 = Math.sqrt(ax*ax + ay*ay) / max;
3265
+
3266
+ double t = k;
3267
+
3268
+ t = Math.pow(t, 3);
3269
+
3270
+ // Interpolate between k/length2 (center) and k (border)
3271
+ k = k / length2 * (1 - t) + k * t;
3272
+
3273
+ double u = k*x;
3274
+ double v = k*y;
3275
+
3276
+ u /= 2;
3277
+ v /= 2;
3278
+ u += 0.5;
3279
+ v += 0.5;
3280
+
3281
+ uvmap[i2] = (float) u;
3282
+ uvmap[i2+1] = (float) v;
3283
+ }
3284
+ }
3285
+
3286
+ void GenUVold(float power)
3287
+ {
3288
+ Trim();
3289
+
3290
+ cVector boxcenter = null;
3291
+ cVector minima, maxima;
3292
+ minima = new cVector();
3293
+ maxima = new cVector();
3294
+ minima.x = minima.y = minima.z = Double.MAX_VALUE;
3295
+ maxima.x = maxima.y = maxima.z = -Double.MAX_VALUE;
3296
+ for (int i = 0; i < VertexCount(); i++)
3297
+ {
3298
+ Vertex v = GetVertex(i);
3299
+
3300
+ if (minima.x > v.x)
3301
+ {
3302
+ minima.x = v.x;
3303
+ }
3304
+ if (minima.y > v.y)
3305
+ {
3306
+ minima.y = v.y;
3307
+ }
3308
+ if (minima.z > v.z)
3309
+ {
3310
+ minima.z = v.z;
3311
+ }
3312
+
3313
+ if (maxima.x < v.x)
3314
+ {
3315
+ maxima.x = v.x;
3316
+ }
3317
+ if (maxima.y < v.y)
3318
+ {
3319
+ maxima.y = v.y;
3320
+ }
3321
+ if (maxima.z < v.z)
3322
+ {
3323
+ maxima.z = v.z;
3324
+ }
3325
+ }
3326
+
3327
+ boxcenter = new cVector((maxima.x + minima.x) / 2, (maxima.y + minima.y) / 2, (maxima.z + minima.z) / 2);
3328
+ int i2 = 0, i3 = 0;
3329
+ for (int i = 0; i < positions.length/3; i++, i3 += 3, i2 += 2)
3330
+ {
3331
+// //uvmap[i2] = (float) normals[i3]*0.5f + 0.5f; // v.x;
3332
+// //uvmap[i2 + 1] = (float) normals[i3+1]*0.5f + 0.5f; //z;
3333
+// uvmap[i2] = (float) (positions[i3] - boxcenter.x);
3334
+// uvmap[i2 + 1] = (float) (positions[i3+2] - boxcenter.z);
3335
+// uvmap[i2] = (float) Math.atan2(positions[i3+1] - boxcenter.y, positions[i3] - boxcenter.x);
3336
+// uvmap[i2 + 1] = (float)(positions[i3+2] - boxcenter.z);
3337
+ // box UV
3338
+ double x = positions[i3] - minima.x; // - Math.floor(positions[i3]);
3339
+ double y = positions[i3+1] - minima.y; // - Math.floor(positions[i3+1]);
3340
+ double z = positions[i3+2] - minima.z; // - Math.floor(positions[i3+2]);
3341
+
3342
+ // [-1/2, 1/2]
3343
+ x /= maxima.x - minima.x;
3344
+ y /= maxima.y - minima.y;
3345
+ z /= maxima.z - minima.z;
3346
+
3347
+ x -= 0.5;
3348
+ y -= 0.5;
3349
+ z -= 0.5;
3350
+
32223351 // x *= 2;
32233352 // y *= 2;
32243353 // z *= 2;
....@@ -3245,6 +3374,15 @@
32453374
32463375 z = Math.cos(angle/2);
32473376
3377
+ assert(z >= 0);
3378
+ assert(z <= 1);
3379
+
3380
+ /**/
3381
+ //z = Math.pow(z, power); //1.08f);
3382
+
3383
+ if (i == 0)
3384
+ System.out.println("power = " + power);
3385
+
32483386 // sqrt(k2*x2 + k2*z2 + y2) = length
32493387 // k2*x2 + k2*z2 = length2 - y2
32503388 // k2 = (length2 - y2) / (x2 + z2)
....@@ -3264,6 +3402,7 @@
32643402
32653403 x *= k;
32663404 y *= k;
3405
+ /**/
32673406
32683407 double max = Math.abs(x);
32693408 if (max < Math.abs(y))
....@@ -3276,10 +3415,15 @@
32763415 }
32773416
32783417 // max = Math.sqrt(max*2)/2;
3418
+// double x2 = Math.pow(Math.abs(x), 1/power);
3419
+// double y2 = Math.pow(Math.abs(y), 1/power);
3420
+// double z2 = Math.pow(Math.abs(z), 1/power);
3421
+// max = Math.pow(x2 + y2 + z2, power);
32793422
32803423 // if (!(max > 0))
3281
- assert(max > 0);
3282
-
3424
+ //assert(max > 0);
3425
+ assert(max >= 0);
3426
+
32833427 x /= max;
32843428 y /= max;
32853429 z /= max;
CameraPane.java
....@@ -86,12 +86,14 @@
8686 static boolean FULLSCREEN = false;
8787 static boolean SUPPORT = true;
8888 static boolean INERTIA = true;
89
-static boolean FAST = false;
89
+static boolean FAST = true; // false;
9090 static boolean SLOWPOSE = false;
9191 static boolean FOOTCONTACT = true;
9292
9393 static int tickcount = 0; // slow pose issue
9494
95
+static boolean BUTTONLESSWHEEL = false;
96
+static boolean ZOOMBOXMODE = false;
9597 static boolean BOXMODE = false;
9698 static boolean IMAGEFLIP = false;
9799 static boolean SMOOTHFOCUS = false;
....@@ -223,6 +225,11 @@
223225 public boolean IsBoxMode()
224226 {
225227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
226233 }
227234
228235 public void ClearDepth()
....@@ -1612,12 +1619,12 @@
16121619 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131620 if (!material.multiply)
16141621 {
1615
- display.color = color;
1622
+ display.color = material.color;
16161623 display.saturation = material.modulation;
16171624 }
16181625 else
16191626 {
1620
- display.color *= color*2;
1627
+ display.color *= material.color*2;
16211628 display.saturation *= material.modulation*2;
16221629 }
16231630
....@@ -2168,6 +2175,11 @@
21682175 public void ToggleBoxMode()
21692176 {
21702177 BOXMODE ^= true;
2178
+ }
2179
+
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
21712183 }
21722184
21732185 public void ToggleSmoothFocus()
....@@ -13523,6 +13535,7 @@
1352313535
1352413536 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513537
13538
+ if (BUTTONLESSWHEEL)
1352613539 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713540 {
1352813541 return;
....@@ -13531,7 +13544,7 @@
1353113544 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213545
1353313546 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13547
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513548 {
1353613549 keepboxmode = BOXMODE;
1353713550 keepsupport = SUPPORT;
....@@ -13748,11 +13761,11 @@
1374813761
1374913762 public void mouseDragged(MouseEvent e)
1375013763 {
13764
+ //System.out.println("mouseDragged: " + e);
1375113765 if (isRenderer)
1375213766 movingcamera = true;
1375313767 //if (drawing)
1375413768 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375613769 if ((e.getModifiersEx() & CTRL) != 0
1375713770 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375813771 {
....@@ -14287,7 +14300,6 @@
1428714300 public void mouseMoved(MouseEvent e)
1428814301 {
1428914302 //System.out.println("mouseMoved: " + e);
14290
-
1429114303 if (isRenderer)
1429214304 return;
1429314305
....@@ -15100,8 +15112,9 @@
1510015112
1510115113 protected void processMouseMotionEvent(MouseEvent e)
1510215114 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15115
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15116
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515118 {
1510615119 mouseMoved(e);
1510715120 } else
GrafreeD.java
....@@ -595,6 +595,9 @@
595595
596596 public static void main(String argv[])
597597 {
598
+ String osArch = System.getProperty("os.arch");
599
+ System.out.println("os.arch = " + osArch);
600
+
598601 if (argv.length == 0)
599602 {
600603 String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
....@@ -626,7 +629,11 @@
626629 System.out.println("jarfile = " + jarfile);
627630 jarpath = jarpath.substring(1, jarpath.length());
628631 System.out.println("jarpath = " + jarpath);
629
- command += "native" + File.separator + "windows_amd64";
632
+ command += "native" + File.separator;
633
+ if (osArch.equals("amd64"))
634
+ command += "windows_amd64";
635
+ else
636
+ command += "windows_i586";
630637 }
631638 else
632639 command += "native" + File.separator + "macosx";
GroupEditor.java
....@@ -438,10 +438,16 @@
438438 oe.aConstraints.gridx = 0;
439439
440440 oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE()), oe.aConstraints);
441
+ liveCB.setToolTipText("Enabled animation");
441442 liveCB.addItemListener(this);
442443
443444 oe.aConstraints.gridx += 1;
445
+ oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
446
+ fastCB.setToolTipText("Fast mode");
447
+ fastCB.addItemListener(this);
448
+ oe.aConstraints.gridx += 1;
444449 oe.toolbarPanel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT), oe.aConstraints);
450
+ supportCB.setToolTipText("Enabled rigging");
445451 supportCB.addItemListener(this);
446452
447453 // oe.aConstraints.gridx += 1;
....@@ -450,21 +456,26 @@
450456
451457 oe.aConstraints.gridx += 1;
452458 oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD), oe.aConstraints);
459
+ crowdCB.setToolTipText("Used for crowds");
453460 crowdCB.addItemListener(this);
454461
455462 oe.aConstraints.gridx += 1;
456463 oe.toolbarPanel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA), oe.aConstraints);
464
+ smoothCB.setToolTipText("Snapping delay");
457465 smoothCB.addItemListener(this);
458466
459467 oe.aConstraints.gridx += 1;
460
- oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
461
- fastCB.addItemListener(this);
462
- oe.aConstraints.gridx += 1;
463468 oe.toolbarPanel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE), oe.aConstraints);
469
+ slowCB.setToolTipText("Smooth interpolation");
464470 slowCB.addItemListener(this);
465471 oe.aConstraints.gridx += 1;
466
- oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.FAST), oe.aConstraints);
472
+ oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE), oe.aConstraints);
473
+ boxCB.setToolTipText("Display bounding boxes");
467474 boxCB.addItemListener(this);
475
+ oe.aConstraints.gridx += 1;
476
+ oe.toolbarPanel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE), oe.aConstraints);
477
+ zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
478
+ zoomBoxCB.addItemListener(this);
468479
469480 // oe.aConstraints.gridx += 1;
470481 // oe.toolbarPanel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), oe.aConstraints);
....@@ -491,19 +502,22 @@
491502 // debugCB.addItemListener(this);
492503
493504 oe.aConstraints.gridx += 1;
494
- oe.toolbarPanel.add(oeilCB = new cCheckBox("O", CameraPane.OEIL), oe.aConstraints);
505
+ oe.toolbarPanel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL), oe.aConstraints);
495506 oeilCB.addItemListener(this);
496507
497508 oe.aConstraints.gridx += 1;
498
- oe.toolbarPanel.add(lookAtCB = new cCheckBox("T", CameraPane.LOOKAT), oe.aConstraints);
509
+ oe.toolbarPanel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT), oe.aConstraints);
510
+ lookAtCB.setToolTipText("Look-at target");
499511 lookAtCB.addItemListener(this);
500512
501513 oe.aConstraints.gridx += 1;
502514 oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK), oe.aConstraints);
515
+ trackCB.setToolTipText("Enable tracking");
503516 trackCB.addItemListener(this);
504517
505518 oe.aConstraints.gridx += 1;
506519 oe.toolbarPanel.add(screenfitButton = new cButton("@ ")); //, oe.aConstraints);
520
+ screenfitButton.setToolTipText("Screen fit");
507521 screenfitButton.addActionListener(this);
508522 oe.aConstraints.gridx += 1;
509523 // oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
....@@ -511,6 +525,7 @@
511525 // oe.aConstraints.gridx += 1;
512526 oe.toolbarPanel.add(snapobjectButton = new cButton(" O+ ")); //, oe.aConstraints);
513527 snapobjectButton.addActionListener(this);
528
+ snapobjectButton.setToolTipText("Snap Object");
514529 oe.aConstraints.gridx += 1;
515530
516531 //aConstraints.gridx = 0;
....@@ -519,6 +534,7 @@
519534 oe.aConstraints.gridwidth = 1;
520535
521536 oe.toolbarPanel.add(flashSelectionButton = new cButton(" ? ")); //, oe.aConstraints);
537
+ flashSelectionButton.setToolTipText("Show selection");
522538 flashSelectionButton.addActionListener(this);
523539
524540 oe.toolbarPanel.add(new cButton(" ", false));
....@@ -529,21 +545,28 @@
529545
530546 //
531547 oe.toolbarPanel.add(twoButton = new cButton(" |+| ")); //, oe.aConstraints);
548
+ twoButton.setToolTipText("Show center view only");
532549 twoButton.addActionListener(this);
533550 oe.toolbarPanel.add(fourButton = new cButton("+|| ")); //, oe.aConstraints);
534551 fourButton.addActionListener(this);
552
+ fourButton.setToolTipText("Show left panel only");
535553 oe.toolbarPanel.add(sixButton = new cButton("+|+| ")); //, oe.aConstraints);
554
+ sixButton.setToolTipText("2-column layout left");
536555 sixButton.addActionListener(this);
537556 oe.toolbarPanel.add(threeButton = new cButton(" |+|+")); //, oe.aConstraints);
557
+ threeButton.setToolTipText("2-column layout right");
538558 threeButton.addActionListener(this);
539559 oe.toolbarPanel.add(sevenButton = new cButton("+|+|+")); //, oe.aConstraints);
560
+ sevenButton.setToolTipText("3-column layout");
540561 sevenButton.addActionListener(this);
541562 //
542563
543
- oe.toolbarPanel.add(rootButton = new cButton(" o o o E ")); //, oe.aConstraints);
564
+ oe.toolbarPanel.add(rootButton = new cButton(" o o o ")); //, oe.aConstraints);
565
+ rootButton.setToolTipText("Edit object in new tab");
544566 rootButton.addActionListener(this);
545567 oe.aConstraints.gridx += 1;
546568 oe.toolbarPanel.add(closeButton = new cButton(" X ")); //, oe.aConstraints);
569
+ closeButton.setToolTipText("Close tab");
547570 closeButton.addActionListener(this);
548571 //oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
549572 //clearButton.addActionListener(this);
....@@ -676,6 +699,7 @@
676699 JCheckBox fastCB;
677700 JCheckBox slowCB;
678701 JCheckBox boxCB;
702
+ JCheckBox zoomBoxCB;
679703 JCheckBox trackCB;
680704 JCheckBox smoothfocusCB;
681705 // JCheckBox speakerMocapCB;
....@@ -756,6 +780,10 @@
756780 cameraView.repaint();
757781 // refreshContents();
758782 }
783
+ else if(e.getSource() == zoomBoxCB)
784
+ {
785
+ cameraView.ToggleZoomBoxMode();
786
+ }
759787 else if(e.getSource() == smoothfocusCB)
760788 {
761789 cameraView.ToggleSmoothFocus();
Object3D.java
....@@ -2906,7 +2906,8 @@
29062906 {
29072907 if (bRep != null)
29082908 {
2909
- bRep.GenUV();
2909
+ bRep.GenUV(); //1);
2910
+ //bRep.UnfoldUV();
29102911 Touch();
29112912 }
29122913 }
....@@ -5898,6 +5899,7 @@
58985899 return;
58995900 }
59005901
5902
+ //bRep.GenUV(1/material.diffuseness);
59015903 // bRep.lock = true;
59025904
59035905 //javax.media.opengl.GL gl = display.GetGL();
timeflow/app/TimeflowApp.java
....@@ -1,5 +1,6 @@
11 package timeflow.app;
22
3
+import java.net.URL;
34 import timeflow.app.ui.*;
45 import timeflow.app.actions.*;
56 import timeflow.app.ui.filter.*;
....@@ -696,7 +697,9 @@
696697 System.out.println("getVisibleFiles = " + dir);
697698 try
698699 {
699
- String[] s = new File(TimeflowApp.class.getClassLoader().getResource(dir).toURI()).list();
700
+ final URL resource = TimeflowApp.class.getClassLoader().getResource(dir);
701
+ System.out.println("resource = " + resource);
702
+ String[] s = new File(resource.toURI()).list();
700703 ArrayList<String> real = new ArrayList<String>();
701704 for (int i = 0; i < s.length; i++)
702705 {
....@@ -709,6 +712,7 @@
709712 }
710713 catch (Exception e)
711714 {
715
+ e.printStackTrace();
712716 return new String[0];
713717 }
714718 }
timeflow/views/IntroView.java
....@@ -73,7 +73,14 @@
7373 {
7474 try
7575 {
76
- String sidebar = IO.read(new File(IntroView.class.getClassLoader().getResource("timeflow/settings/sidebar.html").toURI()));
76
+ //resource = jar:file:/Users/nbriere/Projects/GrafreeD/dist/GrafreeD.jar!/timeflow/settings/sidebar.html
77
+ //java.lang.IllegalArgumentException: URI is not hierarchical
78
+
79
+ //if (true) return;
80
+
81
+ final URL resource = IntroView.class.getClassLoader().getResource("sidebar.html");
82
+ System.out.println("resource = " + resource);
83
+ String sidebar = IO.read(new File(resource.toURI()));
7784 controls = new HtmlControls(sidebar);
7885 } catch (Exception e)
7986 {