From f1c718cce66e5651a0dae91375db6ebfaded1a92 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sat, 27 Apr 2019 21:33:41 -0400
Subject: [PATCH] Test unfold UV
---
BoundaryRep.java | 150 +++++++++++++++++++++++++++++
timeflow/app/TimeflowApp.java | 6 +
CameraPane.java | 29 ++++-
GroupEditor.java | 42 +++++++-
GrafreeD.java | 9 +
Object3D.java | 4
timeflow/views/IntroView.java | 9 +
7 files changed, 227 insertions(+), 22 deletions(-)
diff --git a/BoundaryRep.java b/BoundaryRep.java
index cbdb1a9..05b3429 100644
--- a/BoundaryRep.java
+++ b/BoundaryRep.java
@@ -3155,7 +3155,27 @@
*/
}
- void GenUV()
+ void UnfoldUV()
+ {
+ for (int i = 0; i < VertexCount(); i++)
+ {
+ Vertex v = GetVertex(i);
+
+ v.x = v.s;
+ v.y = v.t;
+ v.z = 0;
+
+ v.norm.x = 0;
+ v.norm.y = 0;
+ v.norm.z = 1;
+
+ SetVertex(v, i);
+ }
+ }
+
+ float power = 2;
+
+ void GenUV() // float power)
{
Trim();
@@ -3219,6 +3239,115 @@
y -= 0.5;
z -= 0.5;
+ double ax = Math.abs(x);
+ double ay = Math.abs(y);
+ double max = ax;
+ if (max < ay)
+ {
+ max = ay;
+ }
+
+ x /= max;
+ y /= max;
+
+ double angle = Math.acos(Math.abs(z*2));
+
+ double k = angle / Math.PI * 2;
+
+ // k == 0 => uv = 0 (center)
+ // k == 1 => uv = -1,1 (border)
+
+ if (i == 0)
+ System.out.println("power = " + power);
+
+ double length1 = (ax+ay)/max;
+ double length2 = Math.sqrt(ax*ax + ay*ay) / max;
+
+ double t = k;
+
+ t = Math.pow(t, 3);
+
+ // Interpolate between k/length2 (center) and k (border)
+ k = k / length2 * (1 - t) + k * t;
+
+ double u = k*x;
+ double v = k*y;
+
+ u /= 2;
+ v /= 2;
+ u += 0.5;
+ v += 0.5;
+
+ uvmap[i2] = (float) u;
+ uvmap[i2+1] = (float) v;
+ }
+ }
+
+ void GenUVold(float power)
+ {
+ Trim();
+
+ cVector boxcenter = null;
+ cVector minima, maxima;
+ minima = new cVector();
+ maxima = new cVector();
+ minima.x = minima.y = minima.z = Double.MAX_VALUE;
+ maxima.x = maxima.y = maxima.z = -Double.MAX_VALUE;
+ for (int i = 0; i < VertexCount(); i++)
+ {
+ Vertex v = GetVertex(i);
+
+ if (minima.x > v.x)
+ {
+ minima.x = v.x;
+ }
+ if (minima.y > v.y)
+ {
+ minima.y = v.y;
+ }
+ if (minima.z > v.z)
+ {
+ minima.z = v.z;
+ }
+
+ if (maxima.x < v.x)
+ {
+ maxima.x = v.x;
+ }
+ if (maxima.y < v.y)
+ {
+ maxima.y = v.y;
+ }
+ if (maxima.z < v.z)
+ {
+ maxima.z = v.z;
+ }
+ }
+
+ boxcenter = new cVector((maxima.x + minima.x) / 2, (maxima.y + minima.y) / 2, (maxima.z + minima.z) / 2);
+ int i2 = 0, i3 = 0;
+ for (int i = 0; i < positions.length/3; i++, i3 += 3, i2 += 2)
+ {
+// //uvmap[i2] = (float) normals[i3]*0.5f + 0.5f; // v.x;
+// //uvmap[i2 + 1] = (float) normals[i3+1]*0.5f + 0.5f; //z;
+// uvmap[i2] = (float) (positions[i3] - boxcenter.x);
+// uvmap[i2 + 1] = (float) (positions[i3+2] - boxcenter.z);
+// uvmap[i2] = (float) Math.atan2(positions[i3+1] - boxcenter.y, positions[i3] - boxcenter.x);
+// uvmap[i2 + 1] = (float)(positions[i3+2] - boxcenter.z);
+ // box UV
+ double x = positions[i3] - minima.x; // - Math.floor(positions[i3]);
+ double y = positions[i3+1] - minima.y; // - Math.floor(positions[i3+1]);
+ double z = positions[i3+2] - minima.z; // - Math.floor(positions[i3+2]);
+
+ // [-1/2, 1/2]
+ x /= maxima.x - minima.x;
+ y /= maxima.y - minima.y;
+ z /= maxima.z - minima.z;
+
+ x -= 0.5;
+ y -= 0.5;
+ z -= 0.5;
+
// x *= 2;
// y *= 2;
// z *= 2;
@@ -3245,6 +3374,15 @@
z = Math.cos(angle/2);
+ assert(z >= 0);
+ assert(z <= 1);
+
+ /**/
+ //z = Math.pow(z, power); //1.08f);
+
+ if (i == 0)
+ System.out.println("power = " + power);
+
// sqrt(k2*x2 + k2*z2 + y2) = length
// k2*x2 + k2*z2 = length2 - y2
// k2 = (length2 - y2) / (x2 + z2)
@@ -3264,6 +3402,7 @@
x *= k;
y *= k;
+ /**/
double max = Math.abs(x);
if (max < Math.abs(y))
@@ -3276,10 +3415,15 @@
}
// max = Math.sqrt(max*2)/2;
+// double x2 = Math.pow(Math.abs(x), 1/power);
+// double y2 = Math.pow(Math.abs(y), 1/power);
+// double z2 = Math.pow(Math.abs(z), 1/power);
+// max = Math.pow(x2 + y2 + z2, power);
// if (!(max > 0))
- assert(max > 0);
-
+ //assert(max > 0);
+ assert(max >= 0);
+
x /= max;
y /= max;
z /= max;
diff --git a/CameraPane.java b/CameraPane.java
index 8c8c173..55e5ab4 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -86,12 +86,14 @@
static boolean FULLSCREEN = false;
static boolean SUPPORT = true;
static boolean INERTIA = true;
-static boolean FAST = false;
+static boolean FAST = true; // false;
static boolean SLOWPOSE = false;
static boolean FOOTCONTACT = true;
static int tickcount = 0; // slow pose issue
+static boolean BUTTONLESSWHEEL = false;
+static boolean ZOOMBOXMODE = false;
static boolean BOXMODE = false;
static boolean IMAGEFLIP = false;
static boolean SMOOTHFOCUS = false;
@@ -223,6 +225,11 @@
public boolean IsBoxMode()
{
return BOXMODE;
+ }
+
+ public boolean IsZoomBoxMode()
+ {
+ return ZOOMBOXMODE;
}
public void ClearDepth()
@@ -1612,12 +1619,12 @@
//col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
if (!material.multiply)
{
- display.color = color;
+ display.color = material.color;
display.saturation = material.modulation;
}
else
{
- display.color *= color*2;
+ display.color *= material.color*2;
display.saturation *= material.modulation*2;
}
@@ -2168,6 +2175,11 @@
public void ToggleBoxMode()
{
BOXMODE ^= true;
+ }
+
+ public void ToggleZoomBoxMode()
+ {
+ ZOOMBOXMODE ^= true;
}
public void ToggleSmoothFocus()
@@ -13523,6 +13535,7 @@
//System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
+ if (BUTTONLESSWHEEL)
if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
{
return;
@@ -13531,7 +13544,7 @@
boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
// TIMER
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
{
keepboxmode = BOXMODE;
keepsupport = SUPPORT;
@@ -13748,11 +13761,11 @@
public void mouseDragged(MouseEvent e)
{
+ //System.out.println("mouseDragged: " + e);
if (isRenderer)
movingcamera = true;
//if (drawing)
//return;
- //System.out.println("mouseDragged: " + e);
if ((e.getModifiersEx() & CTRL) != 0
|| (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
{
@@ -14287,7 +14300,6 @@
public void mouseMoved(MouseEvent e)
{
//System.out.println("mouseMoved: " + e);
-
if (isRenderer)
return;
@@ -15100,8 +15112,9 @@
protected void processMouseMotionEvent(MouseEvent e)
{
- //System.out.println("processMouseMotionEvent: " + mouseMode);
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
{
mouseMoved(e);
} else
diff --git a/GrafreeD.java b/GrafreeD.java
index 1527f55..44e3600 100644
--- a/GrafreeD.java
+++ b/GrafreeD.java
@@ -595,6 +595,9 @@
public static void main(String argv[])
{
+ String osArch = System.getProperty("os.arch");
+ System.out.println("os.arch = " + osArch);
+
if (argv.length == 0)
{
String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
@@ -626,7 +629,11 @@
System.out.println("jarfile = " + jarfile);
jarpath = jarpath.substring(1, jarpath.length());
System.out.println("jarpath = " + jarpath);
- command += "native" + File.separator + "windows_amd64";
+ command += "native" + File.separator;
+ if (osArch.equals("amd64"))
+ command += "windows_amd64";
+ else
+ command += "windows_i586";
}
else
command += "native" + File.separator + "macosx";
diff --git a/GroupEditor.java b/GroupEditor.java
index 02ade54..b72085f 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -438,10 +438,16 @@
oe.aConstraints.gridx = 0;
oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE()), oe.aConstraints);
+ liveCB.setToolTipText("Enabled animation");
liveCB.addItemListener(this);
oe.aConstraints.gridx += 1;
+ oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
+ fastCB.setToolTipText("Fast mode");
+ fastCB.addItemListener(this);
+ oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT), oe.aConstraints);
+ supportCB.setToolTipText("Enabled rigging");
supportCB.addItemListener(this);
// oe.aConstraints.gridx += 1;
@@ -450,21 +456,26 @@
oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD), oe.aConstraints);
+ crowdCB.setToolTipText("Used for crowds");
crowdCB.addItemListener(this);
oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA), oe.aConstraints);
+ smoothCB.setToolTipText("Snapping delay");
smoothCB.addItemListener(this);
oe.aConstraints.gridx += 1;
- oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
- fastCB.addItemListener(this);
- oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE), oe.aConstraints);
+ slowCB.setToolTipText("Smooth interpolation");
slowCB.addItemListener(this);
oe.aConstraints.gridx += 1;
- oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.FAST), oe.aConstraints);
+ oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE), oe.aConstraints);
+ boxCB.setToolTipText("Display bounding boxes");
boxCB.addItemListener(this);
+ oe.aConstraints.gridx += 1;
+ oe.toolbarPanel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE), oe.aConstraints);
+ zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
+ zoomBoxCB.addItemListener(this);
// oe.aConstraints.gridx += 1;
// oe.toolbarPanel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), oe.aConstraints);
@@ -491,19 +502,22 @@
// debugCB.addItemListener(this);
oe.aConstraints.gridx += 1;
- oe.toolbarPanel.add(oeilCB = new cCheckBox("O", CameraPane.OEIL), oe.aConstraints);
+ oe.toolbarPanel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL), oe.aConstraints);
oeilCB.addItemListener(this);
oe.aConstraints.gridx += 1;
- oe.toolbarPanel.add(lookAtCB = new cCheckBox("T", CameraPane.LOOKAT), oe.aConstraints);
+ oe.toolbarPanel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT), oe.aConstraints);
+ lookAtCB.setToolTipText("Look-at target");
lookAtCB.addItemListener(this);
oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK), oe.aConstraints);
+ trackCB.setToolTipText("Enable tracking");
trackCB.addItemListener(this);
oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(screenfitButton = new cButton("@ ")); //, oe.aConstraints);
+ screenfitButton.setToolTipText("Screen fit");
screenfitButton.addActionListener(this);
oe.aConstraints.gridx += 1;
// oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
@@ -511,6 +525,7 @@
// oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(snapobjectButton = new cButton(" O+ ")); //, oe.aConstraints);
snapobjectButton.addActionListener(this);
+ snapobjectButton.setToolTipText("Snap Object");
oe.aConstraints.gridx += 1;
//aConstraints.gridx = 0;
@@ -519,6 +534,7 @@
oe.aConstraints.gridwidth = 1;
oe.toolbarPanel.add(flashSelectionButton = new cButton(" ? ")); //, oe.aConstraints);
+ flashSelectionButton.setToolTipText("Show selection");
flashSelectionButton.addActionListener(this);
oe.toolbarPanel.add(new cButton(" ", false));
@@ -529,21 +545,28 @@
//
oe.toolbarPanel.add(twoButton = new cButton(" |+| ")); //, oe.aConstraints);
+ twoButton.setToolTipText("Show center view only");
twoButton.addActionListener(this);
oe.toolbarPanel.add(fourButton = new cButton("+|| ")); //, oe.aConstraints);
fourButton.addActionListener(this);
+ fourButton.setToolTipText("Show left panel only");
oe.toolbarPanel.add(sixButton = new cButton("+|+| ")); //, oe.aConstraints);
+ sixButton.setToolTipText("2-column layout left");
sixButton.addActionListener(this);
oe.toolbarPanel.add(threeButton = new cButton(" |+|+")); //, oe.aConstraints);
+ threeButton.setToolTipText("2-column layout right");
threeButton.addActionListener(this);
oe.toolbarPanel.add(sevenButton = new cButton("+|+|+")); //, oe.aConstraints);
+ sevenButton.setToolTipText("3-column layout");
sevenButton.addActionListener(this);
//
- oe.toolbarPanel.add(rootButton = new cButton(" o o o E ")); //, oe.aConstraints);
+ oe.toolbarPanel.add(rootButton = new cButton(" o o o ")); //, oe.aConstraints);
+ rootButton.setToolTipText("Edit object in new tab");
rootButton.addActionListener(this);
oe.aConstraints.gridx += 1;
oe.toolbarPanel.add(closeButton = new cButton(" X ")); //, oe.aConstraints);
+ closeButton.setToolTipText("Close tab");
closeButton.addActionListener(this);
//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
//clearButton.addActionListener(this);
@@ -676,6 +699,7 @@
JCheckBox fastCB;
JCheckBox slowCB;
JCheckBox boxCB;
+ JCheckBox zoomBoxCB;
JCheckBox trackCB;
JCheckBox smoothfocusCB;
// JCheckBox speakerMocapCB;
@@ -756,6 +780,10 @@
cameraView.repaint();
// refreshContents();
}
+ else if(e.getSource() == zoomBoxCB)
+ {
+ cameraView.ToggleZoomBoxMode();
+ }
else if(e.getSource() == smoothfocusCB)
{
cameraView.ToggleSmoothFocus();
diff --git a/Object3D.java b/Object3D.java
index 8beaebd..70c7ead 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -2906,7 +2906,8 @@
{
if (bRep != null)
{
- bRep.GenUV();
+ bRep.GenUV(); //1);
+ //bRep.UnfoldUV();
Touch();
}
}
@@ -5898,6 +5899,7 @@
return;
}
+ //bRep.GenUV(1/material.diffuseness);
// bRep.lock = true;
//javax.media.opengl.GL gl = display.GetGL();
diff --git a/timeflow/app/TimeflowApp.java b/timeflow/app/TimeflowApp.java
index d2c47c4..f70bc07 100755
--- a/timeflow/app/TimeflowApp.java
+++ b/timeflow/app/TimeflowApp.java
@@ -1,5 +1,6 @@
package timeflow.app;
+import java.net.URL;
import timeflow.app.ui.*;
import timeflow.app.actions.*;
import timeflow.app.ui.filter.*;
@@ -696,7 +697,9 @@
System.out.println("getVisibleFiles = " + dir);
try
{
- String[] s = new File(TimeflowApp.class.getClassLoader().getResource(dir).toURI()).list();
+ final URL resource = TimeflowApp.class.getClassLoader().getResource(dir);
+ System.out.println("resource = " + resource);
+ String[] s = new File(resource.toURI()).list();
ArrayList<String> real = new ArrayList<String>();
for (int i = 0; i < s.length; i++)
{
@@ -709,6 +712,7 @@
}
catch (Exception e)
{
+ e.printStackTrace();
return new String[0];
}
}
diff --git a/timeflow/views/IntroView.java b/timeflow/views/IntroView.java
index 6bd480f..ea61f6d 100755
--- a/timeflow/views/IntroView.java
+++ b/timeflow/views/IntroView.java
@@ -73,7 +73,14 @@
{
try
{
- String sidebar = IO.read(new File(IntroView.class.getClassLoader().getResource("timeflow/settings/sidebar.html").toURI()));
+ //resource = jar:file:/Users/nbriere/Projects/GrafreeD/dist/GrafreeD.jar!/timeflow/settings/sidebar.html
+ //java.lang.IllegalArgumentException: URI is not hierarchical
+
+ //if (true) return;
+
+ final URL resource = IntroView.class.getClassLoader().getResource("sidebar.html");
+ System.out.println("resource = " + resource);
+ String sidebar = IO.read(new File(resource.toURI()));
controls = new HtmlControls(sidebar);
} catch (Exception e)
{
--
Gitblit v1.6.2