From 0c1f740dd6ddd6432dc29266e42ef851e26027bb Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 13 Aug 2019 21:21:38 -0400
Subject: [PATCH] Random node + optimizations.
---
ObjEditor.java | 77 +++++++++------
SwitchNode.java | 11 +
GroupLeaf.java | 2
cMaterial.java | 2
RandomEditor.java | 36 ++++--
CameraPane.java | 13 +
Globals.java | 2
SwitchEditor.java | 3
GroupEditor.java | 5
cTexture.java | 3
ParticleNode.java | 2
RandomNode.java | 54 ++++++++--
Object3D.java | 88 ++++++++++-------
13 files changed, 195 insertions(+), 103 deletions(-)
diff --git a/CameraPane.java b/CameraPane.java
index 778fb13..ebdca60 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -113,6 +113,8 @@
/*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
/*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
/*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
+ boolean transformMode;
+
boolean reverseUP = false;
static boolean frozen = false;
boolean enablebackspace = false; // patch for back buffer refresh
@@ -2515,7 +2517,7 @@
com.sun.opengl.util.texture.TextureIO.newTextureData(
getClass().getClassLoader().getResourceAsStream(name),
true,
- com.sun.opengl.util.texture.TextureIO.PNG);
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
} catch (java.io.IOException e)
{
throw new javax.media.opengl.GLException(e);
@@ -11082,11 +11084,11 @@
//
// newenvy = -1;
- if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
{
if (cubemaprgb == null)
{
- cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb" + "/", "jpg", false);
}
cubemap = cubemaprgb;
@@ -11097,6 +11099,8 @@
{
if (!object.skyboxname.equals(this.loadedskyboxname))
{
+ if (cubemap != null && cubemap != cubemaprgb)
+ cubemap.dispose();
cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
loadedskyboxname = object.skyboxname;
}
@@ -16788,7 +16792,8 @@
gl.glDisable(GL.GL_TEXTURE_GEN_R);
cubemap.disable();
- ////cubemap.unbind();
+ //cubemap.dispose();
+
if (CULLFACE)
{
gl.glEnable(gl.GL_CULL_FACE);
diff --git a/Globals.java b/Globals.java
index cc0475f..efa09ba 100644
--- a/Globals.java
+++ b/Globals.java
@@ -1,7 +1,7 @@
public class Globals
{
- public static boolean TOOLTIPS = false;
+ public static boolean TOOLTIPS = true; // false;
public static boolean ADVANCED = false;
public static boolean DEBUG = false;
diff --git a/GroupEditor.java b/GroupEditor.java
index 4faf49e..9f3c422 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -1043,8 +1043,8 @@
// maxButton.addActionListener(this);
}
-// cButton gcButton;
-//
+ cButton gcButton;
+
// oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
// gcButton.setToolTipText("Garbage collect");
// gcButton.addActionListener(new ActionListener()
@@ -5325,6 +5325,7 @@
boolean allComposites = true;
+ if (group.selection != null)
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
{
if (!(e.nextElement() instanceof Composite))
diff --git a/GroupLeaf.java b/GroupLeaf.java
index 98da0c9..9c7e5f5 100644
--- a/GroupLeaf.java
+++ b/GroupLeaf.java
@@ -21,7 +21,7 @@
{
super(name);
- addChild(new cGroup("Leaf"));
+ addChild(new cGroup(name + "Leaf"));
}
Object3D deepCopy()
diff --git a/ObjEditor.java b/ObjEditor.java
index 4b4a90a..c07bcab 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -75,8 +75,16 @@
return new cCheckBox(icon, border);
}
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
+
ImageIcon GetIcon(String name)
{
+ javax.swing.ImageIcon iconCache = icons.get(name);
+ if (iconCache != null)
+ {
+ return iconCache;
+ }
+
try
{
BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
@@ -94,10 +102,14 @@
// }
javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
+
+ icons.put(name, icon);
+
return icon;
}
catch (Exception e)
{
+ //icons.put(name, null);
return null;
}
}
@@ -433,7 +445,7 @@
ChangeListener changeListener = new ChangeListener()
{
- String name;
+ //String name;
public void stateChanged(ChangeEvent changeEvent)
{
@@ -453,33 +465,34 @@
// EditSelection(false);
// }
- if (objectPanel.getSelectedIndex() == 4)
- {
- name = copy.skyboxname;
-
- if (name == null)
- {
- name = "";
- }
-
- copy.skyboxname = "cubemaps/default-skyboxes/rgb";
- copy.skyboxext = "jpg";
- }
- else
- {
- if (name != null)
- {
- if (name.equals(""))
- {
- copy.skyboxname = null;
- copy.skyboxext = null;
- }
- else
- {
- copy.skyboxname = name;
- }
- }
- }
+// if (objectPanel.getSelectedIndex() == 4)
+// {
+// name = copy.skyboxname;
+//
+// if (name == null)
+// {
+// name = "";
+// }
+//
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
+// copy.skyboxext = "jpg";
+// }
+// else
+// {
+// if (name != null)
+// {
+// if (name.equals(""))
+// {
+// copy.skyboxname = null;
+// copy.skyboxext = null;
+// }
+// else
+// {
+// copy.skyboxname = name;
+// }
+// }
+// }
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
// refreshContents(false); // To refresh Info tab
cameraView.repaint();
@@ -1676,9 +1689,9 @@
scenePanel.add(tabbedPane);
//if (Globals.ADVANCED)
- tabbedPane.add(infoPanel);
- tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
- tabbedPane.setToolTipTextAt(3, "Information");
+// tabbedPane.add(infoPanel);
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
+// tabbedPane.setToolTipTextAt(3, "Information");
/*
cTree jTree = new cTree(null);
@@ -4781,6 +4794,8 @@
if (muteSlider)
return;
+ Replace();
+
int version = versionSlider.getInteger();
if (version != -1 && copy.versionlist[version] != null)
diff --git a/Object3D.java b/Object3D.java
index cc8b73b..3772174 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -5574,6 +5574,11 @@
if (fullname == null)
return "";
+ if (fullname.pigment != null)
+ {
+ return fullname.pigment;
+ }
+
// System.out.println("Fullname = " + fullname);
// Does not work on Windows due to C:
@@ -5586,7 +5591,7 @@
if (split.length == 0)
{
- return "";
+ return fullname.pigment = "";
}
if (split.length <= 2)
@@ -5594,22 +5599,27 @@
if (fullname.name.endsWith(":"))
{
// Windows
- return fullname.name.substring(0, fullname.name.length()-1);
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
}
- return split[0];
+ return fullname.pigment = split[0];
}
// Windows
assert(split.length == 4);
- return split[0] + ":" + split[1];
+ return fullname.pigment = split[0] + ":" + split[1];
}
static String GetBump(cTexture fullname)
{
if (fullname == null)
return "";
+
+ if (fullname.bump != null)
+ {
+ return fullname.bump;
+ }
// System.out.println("Fullname = " + fullname);
// Does not work on Windows due to C:
@@ -5621,12 +5631,12 @@
if (split.length == 0)
{
- return "";
+ return fullname.bump = "";
}
if (split.length == 1)
{
- return "";
+ return fullname.bump = "";
}
if (split.length == 2)
@@ -5634,16 +5644,16 @@
if (fullname.name.endsWith(":"))
{
// Windows
- return "";
+ return fullname.bump = "";
}
- return split[1];
+ return fullname.bump = split[1];
}
// Windows
assert(split.length == 4);
- return split[2] + ":" + split[3];
+ return fullname.bump = split[2] + ":" + split[3];
}
String GetPigmentTexture()
@@ -5726,6 +5736,9 @@
texname = "";
GetTextures().name = texname + ":" + GetBump(GetTextures());
+
+ GetTextures().pigment = null;
+
Touch();
}
@@ -5798,6 +5811,8 @@
texname = "";
GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
+
+ GetTextures().bump = null;
Touch();
}
@@ -7422,7 +7437,29 @@
// {
// CameraPane.Ymax = spoth;
// }
- spot.translate(32, 32);
+// if (CameraPane.Xmin > spot.x)
+// {
+// CameraPane.Xmin = spot.x;
+// }
+// if (CameraPane.Xmax < spotw)
+// {
+// CameraPane.Xmax = spotw;
+// }
+// if (CameraPane.Ymin > spot.y)
+// {
+// CameraPane.Ymin = spot.y;
+// }
+// if (CameraPane.Ymax < spoth)
+// {
+// CameraPane.Ymax = spoth;
+// }
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
+ spot.translate(32, 0);
+ clickInfo.g.setColor(Color.yellow);
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
+
+ spot.translate(32, 64);
spotw = spot.x + spot.width;
spoth = spot.y + spot.height;
clickInfo.g.setColor(Color.cyan);
@@ -7443,28 +7480,7 @@
// {
// CameraPane.Ymax = spoth;
// }
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
- //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
- spot.translate(0, -32);
- clickInfo.g.setColor(Color.yellow);
- clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
clickInfo.g.setColor(Color.green);
-// if (CameraPane.Xmin > spot.x)
-// {
-// CameraPane.Xmin = spot.x;
-// }
-// if (CameraPane.Xmax < spotw)
-// {
-// CameraPane.Xmax = spotw;
-// }
-// if (CameraPane.Ymin > spot.y)
-// {
-// CameraPane.Ymin = spot.y;
-// }
-// if (CameraPane.Ymax < spoth)
-// {
-// CameraPane.Ymax = spoth;
-// }
clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
(int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
//info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
@@ -7523,12 +7539,14 @@
retval = true;
}
spot.translate(0, 32);
+ spot.translate(32, 0);
+ spot.translate(0, 32);
if (spot.contains(clickInfo.x, clickInfo.y))
{
hitSomething = hitScale;
double scale = 0.005f * clickInfo.camera.Distance();
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
double sign = 1;
if (hScale < 0)
{
@@ -7540,7 +7558,7 @@
//hScale = 0.01;
}
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
sign = 1;
if (vScale < 0)
{
@@ -7755,7 +7773,7 @@
break;
case hitScale: // scale
- double hScale = (double) (clickInfo.x - centerPt.x) / 32;
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
double sign = 1;
if (hScale < 0)
{
@@ -7767,7 +7785,7 @@
//hScale = 0.01;
}
- double vScale = (double) (clickInfo.y - centerPt.y) / 32;
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
sign = 1;
if (vScale < 0)
{
diff --git a/ParticleNode.java b/ParticleNode.java
index 9977719..d7e2b28 100644
--- a/ParticleNode.java
+++ b/ParticleNode.java
@@ -356,7 +356,7 @@
if (support != null && link2master)
geo = support;
- if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW) // june 2013
+ if (live && Globals.isLIVE() && (display.DrawMode() == display.SHADOW || !Globals.RENDERSHADOW)) // june 2013
{
Step();
}
diff --git a/RandomEditor.java b/RandomEditor.java
index 85b7563..864154b 100644
--- a/RandomEditor.java
+++ b/RandomEditor.java
@@ -9,14 +9,15 @@
class RandomEditor extends ObjEditor implements //ItemListener,
ChangeListener, ObjectUI, ActionListener
{
- cGridBag childPanel;
+ cGridBag itemPanel;
+ private cGridBag dampPanel;
RandomEditor(RandomNode inBP, GroupEditor callee)
{
super(inBP,callee);
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
- switchnode = (RandomNode) inBP;
+ randomnode = (RandomNode) inBP;
// parent = p;
//SetupUI2(callee.objEditor);
@@ -35,7 +36,7 @@
objEditor = callee.GetEditor(); // new ObjEditor(inBP, this, callee);
- switchnode = (RandomNode) inBP;
+ randomnode = (RandomNode) inBP;
parent = p;
SetupUI2(callee.objEditor);
@@ -49,7 +50,7 @@
//objEditor = new ObjEditor(inBP, copy, this, callee);
// ?? super.parent = p;
- switchnode = (RandomNode) copy;
+ randomnode = (RandomNode) copy;
parent = p;
//objEditor.SetupUI(false); // ?
@@ -60,24 +61,30 @@
void SetupUI2(ObjEditor oe)
{
super.SetupUI2(oe);
- childPanel = AddSlider(oe.ctrlPanel, "Item: ", 0, switchnode.Size()-1, switchnode.rnd);
+ itemPanel = AddSlider(oe.ctrlPanel, "Item: ", 0, randomnode.Size()-1, randomnode.rndIndex);
- childField = (cNumberSlider)childPanel.getComponent(1);
+ itemField = (cNumberSlider)itemPanel.getComponent(1);
oe.ctrlPanel.Return();
+
+ oe.ctrlPanel.Return();
+ dampPanel = AddSlider(oe.ctrlPanel, "Damp: ", 0, 300, randomnode.damp);
+
+ dampField = (cNumberSlider)dampPanel.getComponent(1);
+ oe.ctrlPanel.Return();
}
void Clear()
{
objEditor.Clear();
- switchnode = null;
+ randomnode = null;
}
public void stateChanged(ChangeEvent e)
{
//System.out.println("Biparam :: stateChanged");
- if (e.getSource() == childField)
+ if (e.getSource() == itemField || e.getSource() == dampField)
{
//System.out.println("#U = " + biparam.uDivs);
//System.out.println("#V = " + biparam.vDivs);
@@ -94,7 +101,7 @@
void Refresh()
{
- switchnode.rnd = childField.getInteger();
+ randomnode.rndIndex = itemField.getInteger();
refreshContents();
}
@@ -102,7 +109,8 @@
/**/
public void applySelf()
{
- switchnode.rnd = childField.getInteger();
+ randomnode.rndIndex = itemField.getInteger();
+ randomnode.damp = dampField.getInteger(); // biparam.minUDivs, 99);
}
/**/
@@ -111,7 +119,8 @@
ObjEditor oe = objEditor;
//Remove(childField);
- oe.ctrlPanel.remove(this.childPanel);
+ oe.ctrlPanel.remove(this.itemPanel);
+ oe.ctrlPanel.remove(this.dampPanel);
super.closeUI();
}
@@ -126,8 +135,9 @@
objEditor.refreshContents();
}
- RandomNode switchnode;
- cNumberSlider childField;
+ RandomNode randomnode;
+ cNumberSlider itemField;
+ cNumberSlider dampField;
ObjectUI parent;
diff --git a/RandomNode.java b/RandomNode.java
index 7d0d7b3..81b7d4e 100644
--- a/RandomNode.java
+++ b/RandomNode.java
@@ -38,7 +38,7 @@
return super.size();
}
- int rnd = -1;
+ int rndIndex = -1;
static int globalseed = 0;
static int globalseed2 = 0; // mocap frames???
@@ -54,6 +54,35 @@
super.ResetRandom();
}
+ int damp;
+ transient int countdamp;
+ transient int globaloffset;
+
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
+ {
+ if (live && Globals.isLIVE() && (display.DrawMode() == display.SHADOW || !Globals.RENDERSHADOW) &&
+ currentframe != Globals.framecount)
+ {
+ currentframe = Globals.framecount;
+
+ if (countdamp <= 0)
+ {
+ countdamp = damp;
+
+ globaloffset += 1;
+ }
+ else
+ {
+ if (CameraPane.FAST)
+ countdamp -= CameraPane.STEP;
+ else
+ countdamp--;
+ }
+ }
+
+ super.DrawNode(display, root, selected);
+ }
+
int firstchoice = 0;
// int currentpass = 0;
@@ -66,8 +95,8 @@
// if (!link2master && rnd != -1)
// new Exception().printStackTrace();
- if (!random && rnd != -1) // freeze current value
- return super.reserve(rnd);
+ if (!random && rndIndex != -1) // freeze current value
+ return super.reserve(rndIndex);
if (firstchoice == 0)
firstchoice = (int)(Math.random()*super.Size()) + 1;
@@ -91,11 +120,11 @@
}
//int tabarnak = super.Size();
- rnd = gcount%super.Size(); //
+ rndIndex = gcount%super.Size(); //
//(int)(Math.random()*super.size());
//globalcount++;
- gcount += Grafreed.mix3(rnd+12345,firstchoice*12345,gcount);
+ gcount += Grafreed.mix3(rndIndex+12345,firstchoice*12345,gcount);
gcount &= 0x7fffffff;
@@ -105,12 +134,17 @@
globalseed = gcount;
if (!random) // aout 2013 link2master)
- rnd = whatevercount++;
+ rndIndex = whatevercount++;
- rnd %= super.Size();
+ if (live) // aout 2019
+ {
+ rndIndex += globaloffset;
+ }
+
+ rndIndex %= super.Size();
//GraphreeD.tracein("RESERVE " + this + " = ", i);
- Object3D child = super.get(rnd);
+ Object3D child = super.get(rndIndex);
//Applet3D.tracein("RESERVE ", child);
child.count--;
@@ -139,11 +173,11 @@
// globalcount--;
- super.get(rnd).count++;
+ super.get(rndIndex).count++;
//assert (child.count >= 0);
if (random) // volatile value
- rnd = -1;
+ rndIndex = -1;
}
void createEditWindow(GroupEditor callee, boolean newWindow)
diff --git a/SwitchEditor.java b/SwitchEditor.java
index 19f7e34..3940f44 100644
--- a/SwitchEditor.java
+++ b/SwitchEditor.java
@@ -11,6 +11,7 @@
{
private cGridBag dampPanel;
private cGridBag framePanel;
+
SwitchEditor(SwitchNode inBP, GroupEditor callee)
{
super(inBP,callee);
@@ -86,7 +87,7 @@
frameField = (cNumberSlider)framePanel.getComponent(1);
oe.ctrlPanel.Return();
- dampPanel = AddSlider(oe.ctrlPanel, "Damp: ", 0, 500, switchnode.speed);
+ dampPanel = AddSlider(oe.ctrlPanel, "Damp: ", 0, 300, switchnode.speed);
speedField = (cNumberSlider)dampPanel.getComponent(1);
oe.ctrlPanel.Return();
diff --git a/SwitchNode.java b/SwitchNode.java
index 96c3568..7189ebc 100644
--- a/SwitchNode.java
+++ b/SwitchNode.java
@@ -41,7 +41,7 @@
switchobject.count = 1; // hide
}
- transient boolean restarted;
+ //transient boolean restarted;
transient int countspeed;
transient boolean toggleneutral;
@@ -59,7 +59,7 @@
}
if (live && Globals.isLIVE() && display.DrawMode() == display.SHADOW)
{
- if (countspeed == 0)
+ if (countspeed <= 0)
{
countspeed = speed;
@@ -92,7 +92,12 @@
}
else
- countspeed--;
+ {
+ if (CameraPane.FAST)
+ countspeed -= CameraPane.STEP;
+ else
+ countspeed--;
+ }
}
if (bRep == null)
diff --git a/cMaterial.java b/cMaterial.java
index 98e4639..fe3d2ea 100644
--- a/cMaterial.java
+++ b/cMaterial.java
@@ -362,7 +362,7 @@
float diffuse = 0.75f, specular = 0.25f, shininess = 0.75f, shift = 1;
float ambient = 0.001f, lightarea = 0.025f, factor = 0.001f, velvet = 0.001f;
float sheen = 1f, subsurface = 0.001f, bump = 0.75f, aniso = 0.001f, anisoV = 0.001f;
- float cameralight = 0.2f, diffuseness = 0.001f, shadow = 5f, texture = 1f, opacity = 1;
+ float cameralight = 0.3f, diffuseness = 0.001f, shadow = 5f, texture = 1f, opacity = 1;
float fakedepth = 0.5f, shadowbias = 0.01f; // 0.001f;
boolean multiply;
diff --git a/cTexture.java b/cTexture.java
index 6c5d9f7..51caa46 100644
--- a/cTexture.java
+++ b/cTexture.java
@@ -32,6 +32,9 @@
String name;
+ transient String pigment;
+ transient String bump;
+
int pw, ph;
byte[] pigmentdata;
--
Gitblit v1.6.2