|
import aurelienribon.tweenengine.*;
|
import aurelienribon.tweenengine.equations.*;
|
|
import java.awt.*;
|
import java.awt.event.*;
|
import javax.swing.*;
|
import javax.swing.event.*;
|
import javax.swing.text.*;
|
import java.io.*;
|
|
import javax.swing.UIManager;
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
//import javax.swing.plaf.ColorUIResource;
|
//import javax.swing.plaf.metal.DefaultMetalTheme;
|
|
//import javax.media.opengl.GLCanvas;
|
|
import //weka.core.
|
matrix.Matrix;
|
|
class ObjEditor /*extends JFrame*/ implements iCallBack, ObjectUI,
|
ActionListener, ChangeListener,
|
InputMethodListener,
|
CaretListener,
|
MouseWheelListener,
|
ItemListener,
|
iSendInfo
|
//KeyListener
|
{
|
|
// SCRIPT
|
|
transient JFrame textpanel = null;
|
transient JButton cancelbutton = null;
|
transient JButton okbutton = null;
|
|
static GridBagConstraints aScriptConstraints;
|
transient JTextArea textarea;
|
|
//String script;
|
|
JTextArea GetArea()
|
{
|
if (textarea == null)
|
{
|
textarea = new JTextArea();
|
textarea.setText(copy.scriptnode.scripttext);
|
textarea.setFont(textarea.getFont().deriveFont(10, 14f));
|
textarea.setForeground(Color.WHITE);
|
textarea.setOpaque(false);
|
textarea.setLineWrap(true);
|
textarea.setWrapStyleWord(true);
|
}
|
|
return textarea;
|
}
|
|
void OpenDialog()
|
{
|
if (copy.scriptnode == null)
|
{
|
copy.scriptnode = new ScriptNode(copy);
|
}
|
|
if (textpanel == null)
|
{
|
textpanel = new JFrame();
|
textpanel.setBackground(Color.gray);
|
textpanel.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
textpanel.setLayout(new GridBagLayout());
|
|
aScriptConstraints = new GridBagConstraints(0,0,1,1, 1.0,1.0,
|
GridBagConstraints.NORTHEAST,
|
GridBagConstraints.BOTH,
|
new Insets(1,1,1,1), 0,0);
|
aScriptConstraints.weighty = 1;
|
aScriptConstraints.gridwidth = 1;
|
textpanel.add(GetArea(), aScriptConstraints);
|
|
okbutton = new JButton("OK");
|
aScriptConstraints.gridy += 1;
|
aScriptConstraints.weighty = 0;
|
textpanel.add(okbutton, aScriptConstraints);
|
|
cancelbutton = new JButton("Cancel");
|
aScriptConstraints.gridx += 1;
|
aScriptConstraints.weighty = 0;
|
textpanel.add(cancelbutton, aScriptConstraints);
|
|
//textpanel.setVisible(true);
|
//textpanel.repaint();
|
textpanel.setSize(500,500); //okbutton.getHeight());
|
|
okbutton.addActionListener(this);
|
cancelbutton.addActionListener(this);
|
}
|
|
textpanel.setVisible(true);
|
}
|
|
|
/*
|
public void keyTyped(KeyEvent e)
|
{
|
System.out.println("keyTyped: " + e);
|
}
|
|
public void keyPressed(KeyEvent e)
|
{
|
System.out.println("keyPressed: " + e);
|
}
|
|
public void keyReleased(KeyEvent e)
|
{
|
System.out.println("keyReleased: " + e);
|
}
|
|
void keyPressed(int key, int modifiers)
|
{
|
System.out.println("KEY PRESSED");
|
CameraPane.theRenderer.keyPressed(key, modifiers);
|
}
|
*/
|
|
static GridBagConstraints aConstraints;
|
static GridBagConstraints aWindowConstraints;
|
GroupEditor callee;
|
JFrame frame;
|
static int GRIDWIDTH = 100; // 4;
|
|
public void closeUI()
|
{
|
//new Exception().printStackTrace();
|
System.out.println("this = " + this);
|
System.out.println("objEditor = " + objEditor);
|
//nameField.removeActionListener(this);
|
objEditor.ctrlPanel.remove(nameField);
|
|
if (!GroupEditor.allparams)
|
return;
|
|
objEditor.ctrlPanel.remove(liveCB);
|
objEditor.ctrlPanel.remove(hideCB);
|
objEditor.ctrlPanel.remove(markCB);
|
|
objEditor.ctrlPanel.remove(randomCB);
|
objEditor.ctrlPanel.remove(speedupCB);
|
objEditor.ctrlPanel.remove(rewindCB);
|
|
objEditor.ctrlPanel.remove(resetButton);
|
objEditor.ctrlPanel.remove(stepButton);
|
// objEditor.ctrlPanel.remove(stepAllButton);
|
// objEditor.ctrlPanel.remove(resetAllButton);
|
objEditor.ctrlPanel.remove(link2masterCB);
|
//objEditor.ctrlPanel.remove(flipVCB);
|
//objEditor.ctrlPanel.remove(texresMenu);
|
objEditor.ctrlPanel.remove(slowerButton);
|
objEditor.ctrlPanel.remove(fasterButton);
|
objEditor.ctrlPanel.remove(remarkButton);
|
}
|
|
public ObjEditor GetEditor()
|
{
|
return objEditor; //.GetEditor();
|
}
|
ObjEditor objEditor;
|
|
/*
|
ObjEditor(Object3D inClient)
|
{
|
// For node edition
|
objEditor = this;
|
|
client = inClient;
|
copy = client;
|
}
|
*/
|
public void caretUpdate(CaretEvent e)
|
{
|
//System.out.println("caretUpdate " + e);
|
actionPerformed(new ActionEvent(nameField, 0, ""));
|
}
|
|
public void caretPositionChanged(InputMethodEvent event)
|
{
|
System.out.println("caretPositionChanged " + event);
|
}
|
|
public void inputMethodTextChanged(InputMethodEvent event)
|
{
|
System.out.println("inputMethodTextChanged " + event);
|
}
|
|
ObjEditor(Object3D inClient, GroupEditor callee)
|
{
|
objEditor = callee.GetEditor();
|
|
client = inClient;
|
copy = client;
|
|
// "this" is not called: SetupUI2(objEditor);
|
}
|
|
ObjEditor(Object3D inClient, ObjectUI p, GroupEditor callee)
|
{
|
assert false;
|
this.callee = callee;
|
|
//parent = p;
|
|
client = inClient;
|
copy = client;
|
|
SetupUI2(callee.GetEditor());
|
}
|
|
// TEMP
|
ObjEditor(Object3D inClient, Object3D localCopy, GroupEditor callee)
|
{
|
this(inClient, localCopy, null, callee);
|
}
|
|
ObjEditor(Object3D inClient, Object3D localCopy, ObjectUI p, GroupEditor callee)
|
{
|
//localCopy.parent = null;
|
|
frame = new JFrame();
|
objEditor = this;
|
this.callee = callee;
|
|
//parent = p;
|
|
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
|
//gd.setFullScreenWindow(this);
|
//setResizable(false);
|
//if (!isDisplayable())
|
//setUndecorated(true);
|
|
System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
|
client = inClient;
|
copy = localCopy;
|
copy.editWindow = this;
|
|
SetupMenu();
|
|
//SetupName(objEditor); // new
|
|
frame.setTitle(client.GetName());
|
//frame.show();
|
}
|
|
public boolean action(Event event, Object obj)
|
{
|
return frame.action(event, obj);
|
}
|
|
void SetupMenu()
|
{
|
frame.setMenuBar(menuBar = new MenuBar());
|
menuBar.add(windowMenu = new Menu("File"));
|
windowMenu.add(loadItem = new MenuItem("Load..."));
|
windowMenu.add("-");
|
windowMenu.add(saveItem = new MenuItem("Save"));
|
windowMenu.add(saveAsItem = new MenuItem("Save As..."));
|
//windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
|
windowMenu.add("-");
|
windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
|
windowMenu.add(reexportItem = new MenuItem("Re-export"));
|
windowMenu.add("-");
|
if (client.parent != null)
|
{
|
windowMenu.add(closeItem = new MenuItem("Close"));
|
} else
|
{
|
windowMenu.add(closeItem = new MenuItem("Exit"));
|
}
|
|
loadItem.addActionListener(this);
|
saveItem.addActionListener(this);
|
saveAsItem.addActionListener(this);
|
exportAsItem.addActionListener(this);
|
reexportItem.addActionListener(this);
|
//povItem.addActionListener(this);
|
closeItem.addActionListener(this);
|
|
menuBar.add(cameraMenu = new Menu("View"));
|
//cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
|
//zBufferItem.addActionListener(this);
|
//cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
|
//normalLensItem.addActionListener(this);
|
cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
|
revertCameraItem.addActionListener(this);
|
cameraMenu.add(toggleFullItem = new CheckboxMenuItem("Full Screen"));
|
toggleFullItem.addItemListener(this);
|
toggleFullItem.setState(CameraPane.FULLSCREEN);
|
cameraMenu.add("-");
|
cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
|
toggleTextureItem.addItemListener(this);
|
toggleTextureItem.setState(CameraPane.textureon);
|
cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
|
toggleLiveItem.addItemListener(this);
|
toggleLiveItem.setState(CameraPane.isLIVE());
|
cameraMenu.add(stepItem = new MenuItem("Step"));
|
stepItem.addActionListener(this);
|
// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
|
// toggleDLItem.addItemListener(this);
|
// toggleDLItem.setState(false);
|
cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
|
toggleRenderItem.addItemListener(this);
|
toggleRenderItem.setState(!CameraPane.frozen);
|
cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
|
toggleDebugItem.addItemListener(this);
|
toggleDebugItem.setState(CameraPane.DEBUG);
|
cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
|
toggleFrustumItem.addItemListener(this);
|
toggleFrustumItem.setState(CameraPane.FRUSTUM);
|
cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
|
toggleFootContactItem.addItemListener(this);
|
toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
|
cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
|
toggleRandomItem.addItemListener(this);
|
toggleRandomItem.setState(CameraPane.RANDOM);
|
cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
|
toggleHandleItem.addItemListener(this);
|
toggleHandleItem.setState(CameraPane.HANDLES);
|
cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
|
togglePaintItem.addItemListener(this);
|
togglePaintItem.setState(CameraPane.PAINTMODE);
|
// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
|
// toggleRootItem.addItemListener(this);
|
// toggleRootItem.setState(false);
|
// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
|
// animationItem.addItemListener(this);
|
// animationItem.setState(CameraPane.ANIMATION);
|
cameraMenu.add("-");
|
cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
|
editCameraItem.addActionListener(this);
|
|
objectPanel = new JTabbedPane();
|
toolbarPanel = new JPanel();
|
toolbarPanel.setName("Toolbar");
|
treePanel = new JPanel();
|
treePanel.setName("Tree");
|
ctrlPanel = new JPanel(); // new GridBagLayout());
|
ctrlPanel.setName("Edit");
|
materialPanel = new JPanel();
|
materialPanel.setName("Material");
|
/*JTextPane*/
|
infoarea = createTextPane();
|
infoarea.setEditable(true);
|
SetText();
|
// infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
|
// infoarea.setOpaque(false);
|
// //infoarea.setForeground(textcolor);
|
infoarea.setLineWrap(true);
|
infoarea.setWrapStyleWord(true);
|
infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
|
infoPanel.setPreferredSize(new Dimension(50, 200));
|
infoPanel.setName("Info");
|
//infoPanel.setLayout(new BorderLayout());
|
//infoPanel.add(createTextPane());
|
|
mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, objectPanel);
|
mainPanel.setName("Main");
|
mainPanel.setContinuousLayout(true);
|
mainPanel.setOneTouchExpandable(true);
|
mainPanel.setDividerLocation(1.0);
|
mainPanel.setDividerSize(9);
|
mainPanel.setResizeWeight(0);
|
|
//ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
|
//mainPanel.setLayout(new GridBagLayout());
|
toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
treePanel.setLayout(new GridBagLayout());
|
ctrlPanel.setLayout(new GridBagLayout());
|
materialPanel.setLayout(new GridBagLayout());
|
|
aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
|
GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0);
|
aWindowConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
|
GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0);
|
aWindowConstraints.anchor = GridBagConstraints.NORTH;
|
|
// june 2013 aConstraints.weighty = 0;
|
// aConstraints.gridwidth = 1;
|
// if (client.parent != null)
|
// {
|
// ctrlPanel.add(okButton = new cButton("OK"), aConstraints);
|
// }
|
// aConstraints.gridx += 1;
|
// if (client.parent != null) // ???
|
// ctrlPanel.add(applyButton = new cButton("Apply"), aConstraints);
|
// aConstraints.gridx += 1;
|
// if (client.parent != null)
|
// ctrlPanel.add(cancelButton = new cButton("Close"), aConstraints);
|
// aConstraints.gridx = 0;
|
//
|
// aConstraints.gridy += 1;
|
// aConstraints.weighty = 0;
|
// aConstraints.gridwidth = 1;
|
//
|
// if (okButton != null)
|
// okButton.addActionListener(this);
|
// if (applyButton != null)
|
// applyButton.addActionListener(this);
|
// if (cancelButton != null)
|
// cancelButton.addActionListener(this);
|
|
//SetupUI();
|
}
|
|
static String newline = "\n";
|
protected static final String buttonString = "JButton";
|
StyledDocument doc;
|
JTextArea infoarea;
|
|
void ClearInfo()
|
{
|
try
|
{
|
doc.remove(0, doc.getLength());
|
} catch (BadLocationException ble)
|
{
|
System.err.println("Couldn't insert initial text into text pane.");
|
}
|
}
|
|
void SetText()
|
{
|
try
|
{
|
infoarea.setText(doc.getText(0, doc.getLength()));
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
String selection = infoarea.getText();
|
java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
|
java.awt.datatransfer.Clipboard clipboard =
|
Toolkit.getDefaultToolkit().getSystemClipboard();
|
//clipboard.setContents(data, data);
|
}
|
|
void SetInfo(Object3D sel)
|
{
|
// not used
|
ClearInfo();
|
// AddInfo(sel);
|
// SetText();
|
}
|
|
static cVector minima = new cVector();
|
static cVector maxima = new cVector();
|
static boolean debug = true; // false;
|
|
static void AddInfo(Object3D sel, iSendInfo si, boolean full)
|
{
|
// sel = sel.GetObject();
|
|
//SendInfo("Name:", "bold");
|
if (sel.GetTextures() != null || debug)
|
{
|
si.SendInfo(sel.toString(), "bold");
|
//SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
|
if (sel.Size() > 0)
|
{
|
si.SendInfo("#children = " + sel.Size(), "regular");
|
}
|
si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
|
if (debug)
|
{
|
try
|
{
|
sel.getBounds(minima, maxima, true);
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
if (full)
|
si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
|
|
if (sel.bRep != null)
|
{
|
si.SendInfo(" BRep: " + sel.bRep.hashCode(), "regular");
|
si.SendInfo(" Geo: " + sel.bRep.FaceCount() + " triangles, " + sel.bRep.VertexCount()
|
+ " vertices; ", "regular");
|
si.SendInfo(" Storage: " + sel.bRep, "regular");
|
si.SendInfo(" Display list: " + sel.bRep.displaylist, "regular");
|
if (sel.bRep.vertextable != null)
|
{
|
si.SendInfo(" ... has vertextable. ", "regular");
|
}
|
if (sel.bRep.support != null)
|
{
|
si.SendInfo(" bRep support: " + sel.bRep.support, "regular");
|
}
|
}
|
if (sel.transientrep != null)
|
{
|
si.SendInfo(" transientrep: " + sel.transientrep.hashCode(), "regular");
|
si.SendInfo(" Geo: " + sel.transientrep.FaceCount() + " triangles;" + sel.transientrep.VertexCount()
|
+ " vertices; ", "regular");
|
si.SendInfo(" Storage: " + sel.transientrep, "regular");
|
}
|
if (sel.support != null)
|
{
|
si.SendInfo(" support: " + sel.support, "regular");
|
}
|
if (sel.scriptnode != null)
|
{
|
si.SendInfo(" script: " + sel.scriptnode.scripttext, "regular");
|
}
|
if (sel.toParent != null)
|
{
|
sel.GlobalTransformInv();
|
|
maxima.x = sel.toParent[3][0];
|
maxima.y = sel.toParent[3][1];
|
maxima.z = sel.toParent[3][2];
|
si.SendInfo(" Orig: " + maxima, "regular");
|
maxima.x = sel.toParent[0][0];
|
maxima.y = sel.toParent[1][1];
|
maxima.z = sel.toParent[2][2];
|
si.SendInfo(" Scale: " + maxima, "regular");
|
maxima.x = sel.globalTransform[3][0];
|
maxima.y = sel.globalTransform[3][1];
|
maxima.z = sel.globalTransform[3][2];
|
if (full)
|
si.SendInfo(" Global Orig: " + maxima, "regular");
|
maxima.x = sel.globalTransform[0][0];
|
maxima.y = sel.globalTransform[1][1];
|
maxima.z = sel.globalTransform[2][2];
|
if (full)
|
si.SendInfo(" Global Scale: " + maxima, "regular");
|
}
|
}
|
si.SendInfo(" Transform count: " + sel.transformcount, "regular");
|
si.SendInfo(" Max count: " + sel.maxcount, "regular");
|
// SendInfo(" countdown: " + sel.countdown + newline, "regular");
|
// SendInfo(" delay: " + sel.delay + newline, "regular");
|
// live, hide, ...
|
//?? SendInfo(" Orig: " + maxima + newline, "regular");
|
si.SendInfo((debug ? " Texture: " : " ") + sel.GetTextures(), "bold");
|
// SendInfo((debug ? " Material: " : " ") + sel.material + newline, "regular");
|
if (sel instanceof cMesh)
|
{
|
cMesh mesh = (cMesh) sel;
|
si.SendInfo(" Mesh ref: " + mesh.ref, "regular");
|
si.SendInfo(" Mesh pose: " + mesh.pose, "regular");
|
si.SendInfo(" Mesh avoider: " + mesh.W, "regular");
|
si.SendInfo(" Mesh phys: " + mesh.Phys, "regular");
|
// SendInfo(" Mesh avoider: " + mesh.W.ActingForces??? + newline, "regular");
|
}
|
if (sel instanceof Mocap)
|
{
|
Mocap mocap = (Mocap) sel;
|
si.SendInfo(" Mocap fullname: " + mocap.fullname, "regular");
|
si.SendInfo(" Mocap wavname: " + mocap.wavname, "regular");
|
si.SendInfo(" Mocap #frames: " + mocap.bvh.animation.getNumFrames(), "regular");
|
si.SendInfo(" Mocap frame: " + mocap.frame, "regular");
|
si.SendInfo(" Mocap baseframe: " + mocap.baseframe, "regular");
|
si.SendInfo(" Mocap beginframe: " + mocap.beginframe, "regular");
|
si.SendInfo(" Mocap endframe: " + mocap.endframe, "regular");
|
}
|
if (sel instanceof ScriptNode)
|
{
|
ScriptNode sn = (ScriptNode) sel;
|
si.SendInfo(" Script name: " + sn.filename, "regular");
|
}
|
|
si.SendInfo((debug ? " Path: " : " ") + sel.GetPath(), "regular");
|
|
// System.err.println("info : " + sel.GetPath());
|
if (sel instanceof PointFlow)
|
{
|
CameraPane.pointflow = (PointFlow) sel;
|
}
|
}
|
}
|
|
public void SendInfo(String text, String style)
|
{
|
try
|
{
|
doc.insertString(doc.getLength(), text + newline,
|
doc.getStyle(style));
|
} catch (BadLocationException ble)
|
{
|
System.err.println("Couldn't insert initial text into text pane.");
|
}
|
}
|
|
private JTextArea createTextPane()
|
{
|
String[] initString =
|
{
|
"This is an editable JTextPane, ", //regular
|
"another ", //italic
|
"styled ", //bold
|
"text ", //small
|
"component, ", //large
|
"which supports embedded components..." + newline,//regular
|
" " + newline, //button
|
"...and embedded icons..." + newline, //regular
|
" ", //icon
|
newline + "JTextPane is a subclass of JEditorPane that "
|
+ "uses a StyledEditorKit and StyledDocument, and provides "
|
+ "cover methods for interacting with those objects."
|
};
|
|
String[] initStyles =
|
{
|
"regular", "italic", "bold", "small", "large",
|
"regular", "button", "regular", "icon",
|
"regular"
|
};
|
|
JTextPane textPane = new JTextPane();
|
textPane.setEditable(true);
|
/*StyledDocument*/ doc = textPane.getStyledDocument();
|
addStylesToDocument(doc);
|
|
try
|
{
|
for (int j = 0; j < 2; j++)
|
{
|
for (int i = 0; i < initString.length; i++)
|
{
|
doc.insertString(doc.getLength(), initString[i],
|
doc.getStyle(initStyles[i]));
|
}
|
}
|
} catch (BadLocationException ble)
|
{
|
System.err.println("Couldn't insert initial text into text pane.");
|
}
|
|
return new JTextArea(); // textPane;
|
}
|
|
protected void addStylesToDocument(StyledDocument doc)
|
{
|
//Initialize some styles.
|
Style def = StyleContext.getDefaultStyleContext().
|
getStyle(StyleContext.DEFAULT_STYLE);
|
|
Style regular = doc.addStyle("regular", def);
|
StyleConstants.setFontFamily(def, "SansSerif");
|
|
Style s = doc.addStyle("italic", regular);
|
StyleConstants.setItalic(s, true);
|
|
s = doc.addStyle("bold", regular);
|
StyleConstants.setBold(s, true);
|
|
s = doc.addStyle("small", regular);
|
StyleConstants.setFontSize(s, 10);
|
|
s = doc.addStyle("large", regular);
|
StyleConstants.setFontSize(s, 16);
|
|
s = doc.addStyle("icon", regular);
|
StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
|
// ImageIcon pigIcon = createImageIcon("images/Pig.gif",
|
// "a cute pig");
|
// if (pigIcon != null) {
|
// StyleConstants.setIcon(s, pigIcon);
|
//}
|
|
s = doc.addStyle("button", regular);
|
StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
|
// ImageIcon soundIcon = createImageIcon("images/sound.gif",
|
// "sound icon");
|
JButton button = new JButton();
|
// if (soundIcon != null) {
|
// button.setIcon(soundIcon);
|
// } else {
|
button.setText("BEEP");
|
// }
|
button.setCursor(Cursor.getDefaultCursor());
|
button.setMargin(new Insets(0, 0, 0, 0));
|
button.setActionCommand(buttonString);
|
button.addActionListener(this);
|
StyleConstants.setComponent(s, button);
|
}
|
|
/** Returns an ImageIcon, or null if the path was invalid. */
|
protected static ImageIcon createImageIcon(String path,
|
String description)
|
{
|
java.net.URL imgURL = GrafreeD.class.getResource(path);
|
if (imgURL != null)
|
{
|
return new ImageIcon(imgURL, description);
|
} else
|
{
|
System.err.println("Couldn't find file: " + path);
|
return null;
|
}
|
}
|
|
void SetupWindow()
|
{
|
SetupUI(false);
|
SetupViews();
|
}
|
|
void SetupUI(boolean withMaterial)
|
{
|
if (withMaterial)
|
{
|
SetupMaterial(materialPanel);
|
}
|
//SetupName();
|
//SetupViews();
|
}
|
// JLabel uDivsLabel;
|
// JLabel vDivsLabel;
|
// NumberSlider uDivsField;
|
// NumberSlider vDivsField;
|
// JCheckBox endcaps;
|
JCheckBox liveCB;
|
JCheckBox hideCB;
|
JCheckBox link2masterCB;
|
JCheckBox markCB;
|
JCheckBox randomCB;
|
JCheckBox speedupCB;
|
JCheckBox rewindCB;
|
JCheckBox flipVCB;
|
JComboBox texresMenu;
|
JButton resetButton;
|
JButton stepButton;
|
JButton stepAllButton;
|
JButton resetAllButton;
|
JButton slowerButton;
|
JButton fasterButton;
|
JButton remarkButton;
|
|
JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
|
{
|
JCheckBox cb;
|
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridwidth = 1; // 3;
|
// oe.aConstraints.weightx = 1;
|
// oe.aConstraints.anchor = GridBagConstraints.WEST;
|
oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
cb.addItemListener(this);
|
// oe.aConstraints.anchor = GridBagConstraints.EAST;
|
oe.aConstraints.gridwidth = 1;
|
oe.aConstraints.gridx += 1;
|
|
return cb;
|
}
|
|
cButton AddButton(ObjEditor oe, String label)
|
{
|
cButton cb;
|
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.weightx = 1;
|
// oe.aConstraints.anchor = GridBagConstraints.WEST;
|
oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
|
cb.addActionListener(this);
|
// oe.aConstraints.anchor = GridBagConstraints.EAST;
|
oe.aConstraints.gridwidth = 1;
|
oe.aConstraints.gridx += 1;
|
|
return cb;
|
}
|
|
JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
|
{
|
JComboBox combo;
|
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
oe.aConstraints.gridx += 1;
|
combo.addActionListener(this);
|
|
return combo;
|
}
|
|
NumberSlider AddSlider(JPanel ctrlPanel, String label, double min, double max, double current, double pow)
|
{
|
NumberSlider combo;
|
|
JLabel jlabel = new JLabel(label);
|
|
aConstraints.fill = GridBagConstraints.VERTICAL;
|
jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.gridwidth = 2;
|
ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
aConstraints.gridx += 1;
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(combo = new NumberSlider(min, max, pow), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = 1;
|
|
combo.setFloat(current);
|
|
combo.label = jlabel;
|
|
combo.addChangeListener(this);
|
|
return combo;
|
}
|
|
NumberSlider AddSlider(JPanel ctrlPanel, String label, int min, int max, int current)
|
{
|
NumberSlider combo;
|
|
JLabel jlabel = new JLabel(label);
|
|
aConstraints.fill = GridBagConstraints.VERTICAL;
|
jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.gridwidth = 2;
|
ctrlPanel.add(jlabel, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
aConstraints.gridx += 1;
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(combo = new NumberSlider(min, max), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = 1;
|
|
combo.setInteger(current);
|
|
combo.label = jlabel;
|
|
combo.addChangeListener(this);
|
|
return combo;
|
}
|
|
JTextArea AddText(JPanel ctrlPanel, String name)
|
{
|
JTextArea text;
|
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(text = new JTextArea(name), aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
|
text.addCaretListener(this);
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = 1;
|
|
return text;
|
}
|
|
void Remove(JCheckBox j)
|
{
|
j.removeItemListener(this);
|
objEditor.ctrlPanel.remove(j);
|
}
|
|
void Remove(JButton j)
|
{
|
j.removeActionListener(this);
|
objEditor.ctrlPanel.remove(j);
|
}
|
|
void Remove(JComboBox j)
|
{
|
j.removeActionListener(this);
|
objEditor.ctrlPanel.remove(j);
|
}
|
|
void Remove(NumberSlider j)
|
{
|
j.removeChangeListener(this);
|
objEditor.ctrlPanel.remove(j.label);
|
objEditor.ctrlPanel.remove(j);
|
}
|
|
/*
|
*/
|
void Return() // ObjEditor oe)
|
{
|
aConstraints.gridy += 1;
|
aConstraints.gridx = 0;
|
}
|
|
class cListModel implements ComboBoxModel
|
{
|
|
java.util.Vector objList; // = new Vector();
|
Object obj;
|
int startWith;
|
|
cListModel(java.util.Vector ol, int first)
|
{
|
objList = ol;
|
startWith = first;
|
//first = owner.csg.csgType - 1;
|
}
|
|
public void addListDataListener(ListDataListener l)
|
{
|
}
|
|
public Object getElementAt(int index)
|
{
|
return objList.get(index);
|
}
|
|
public int getSize()
|
{
|
return objList.size();
|
}
|
|
public void removeListDataListener(ListDataListener l)
|
{
|
}
|
|
public Object getSelectedItem()
|
{
|
if (obj == null)
|
{
|
return objList.get(startWith);
|
}
|
return obj;
|
}
|
|
public void setSelectedItem(Object o)
|
{
|
obj = o;
|
}
|
}
|
|
void SetupUI2(ObjEditor oe)
|
{
|
// oe.aConstraints.weightx = 0;
|
// oe.aConstraints.weighty = 0;
|
// oe.aConstraints.gridx = 0;
|
// oe.aConstraints.gridy = 0;
|
SetupName(oe);
|
|
if (!GroupEditor.allparams)
|
return;
|
|
liveCB = AddCheckBox(oe, "Live", copy.live);
|
link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
|
hideCB = AddCheckBox(oe, "Hide", copy.hide);
|
// Return();
|
markCB = AddCheckBox(oe, "Mark", copy.marked);
|
rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
|
randomCB = AddCheckBox(oe, "Rand", copy.random);
|
Return();
|
resetButton = AddButton(oe, "Reset");
|
stepButton = AddButton(oe, "Step");
|
// resetAllButton = AddButton(oe, "Reset All");
|
// stepAllButton = AddButton(oe, "Step All");
|
speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
|
// Return();
|
slowerButton = AddButton(oe, "Slow");
|
fasterButton = AddButton(oe, "Fast");
|
remarkButton = AddButton(oe, "Rem");
|
|
Return();
|
|
// oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
|
// ObjEditor.aConstraints.gridx += 1;
|
|
// flipVCB = AddCheckBox(oe, "Flip V", copy.flipV);
|
// Return(oe);
|
//
|
// java.util.Vector list = new java.util.Vector();
|
// list.add("Low res texture");
|
// list.add("Normal");
|
// list.add("High res");
|
// texresMenu = AddCombo(oe, list, copy.texres);
|
// Return(oe);
|
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(uDivsLabel = new JLabel("U #"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(uDivsField = new NumberSlider(0, 64), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridwidth = 1;
|
// oe.aConstraints.fill = 0;
|
// oe.aConstraints.gridx -= 1;
|
// oe.aConstraints.fill = GridBagConstraints.VERTICAL;
|
// oe.ctrlPanel.add(vDivsLabel = new JLabel("V #"), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; // 1;
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// oe.ctrlPanel.add(vDivsField = new NumberSlider(0, 64), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// uDivsField.setInteger(2);
|
// vDivsField.setInteger(3);
|
// uDivsField.addChangeListener(this);
|
// vDivsField.addChangeListener(this);
|
// oe.aConstraints.fill = 0;
|
// oe.aConstraints.gridx -= 1;
|
// oe.aConstraints.gridwidth = 1;
|
// if (true)
|
// {
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridwidth = 3;
|
// oe.aConstraints.anchor = GridBagConstraints.WEST;
|
// oe.ctrlPanel.add(endcaps = new JCheckBox("Close Surface", true), oe.aConstraints, oe.ctrlPanel.getComponentCount()-2);
|
// endcaps.addItemListener(this);
|
// oe.aConstraints.anchor = GridBagConstraints.EAST;
|
// oe.aConstraints.gridwidth = 1;
|
// //endcaps.setState(!biparam.endcaps);
|
// }
|
// oe.aConstraints.gridy += 1;
|
// oe.aConstraints.gridx = 0;
|
}
|
|
void SetupName(ObjEditor oe)
|
{
|
/**
|
//new Exception().printStackTrace();
|
// System.out.println("editor = " + this);
|
// System.out.println("objecteditor? = " + oe);
|
// System.out.println("callee = " + this.callee);
|
// System.out.println("client = " + this.client);
|
// System.out.println("copy = " + this.copy);
|
// System.out.println("---------------");
|
//System.out.println("OE = " + oe);
|
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridx = 0;
|
if(objEditor == this)
|
{
|
oe.aConstraints.weighty = 1;
|
oe.aConstraints.gridy = 100;
|
}
|
else
|
{
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridy += 1;
|
}
|
oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH+1;
|
oe.ctrlPanel.add(nameField = new JTextArea(copy.GetName()), oe.aConstraints, oe.ctrlPanel.getComponentCount()-1);
|
//nameField.addActionListener(this);
|
//nameField.addInputMethodListener(this);
|
nameField.addCaretListener(this);
|
if(objEditor == this)
|
{
|
oe.aConstraints.gridy = 0; // Remove for "Edit copy..."
|
}
|
else
|
{
|
oe.aConstraints.gridy += 1;
|
}
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
/**/
|
nameField = AddText(oe.ctrlPanel, copy.GetName());
|
Return();
|
|
//ctrlPanel.add(textureButton = new Button("Texture..."));
|
//textureButton.setEnabled(false);
|
//applyButton.setEnabled(inClient.parent != null);
|
}
|
|
Camera GetCamera(Object3D obj, int viewcode)
|
{
|
if ((obj instanceof Camera) && ((Camera) obj).viewCode == viewcode)
|
{
|
return (Camera) obj;
|
}
|
|
if (!(obj instanceof Composite))
|
{
|
return null;
|
}
|
|
Composite comp = (Composite) obj;
|
|
for (int i = 0; i < comp.Size(); i++)
|
{
|
Object3D child = comp.reserve(i);
|
//Applet3D.tracein("child = ", child);
|
Camera cam = GetCamera(child, viewcode);
|
comp.release(i);
|
//Applet3D.traceout("child = ", child);
|
if (cam != null)
|
{
|
if (cam.hAspect != 0) // && cam.hAspect != -1)
|
{
|
System.out.println("HHH = " + cam.hAspect);
|
}
|
return cam;
|
}
|
}
|
|
return null;
|
}
|
|
void SetupViews()
|
{
|
//topScroll = new CameraScroller();
|
//frontScroll = new CameraScroller();
|
//sideScroll = new CameraScroller();
|
|
//topScroll.setLabel("------------------------------ XY (top) ---------------------------------------------------");
|
//frontScroll.setLabel("------------------------------ XZ (front) ---------------------------------------------------");
|
//sideScroll.setLabel("------------------------------- YZ (side) ---------------------------------------------------");
|
|
// GridBagConstraints gbc = (GridBagConstraints) GrafreeD.clone(aConstraints);
|
Camera cam = GetCamera(copy, 0);
|
|
Composite cams = null;
|
|
if (cam == null || !(copy.get(0) instanceof cGroup))
|
{
|
System.out.println("CREATE CAMERAS");
|
cams = new cTemplate();
|
cams.name = "Cameras";
|
copy.insertElementAt(cams, 0);
|
//cams.parent = copy;
|
|
cam = new Camera(); // LA.newVector(3, 2, 1));
|
cams.addChild(cam);
|
cam = new Camera(1);
|
cams.addChild(cam);
|
cam = new Camera(2);
|
cams.addChild(cam);
|
cam = new Camera(3);
|
cams.addChild(cam);
|
cam = new Camera(4); // Light
|
cams.addChild(cam);
|
} else
|
{
|
cams = (cGroup) copy.get(0);
|
}
|
|
cam = GetCamera(copy, 1);
|
topView = new CameraPane(copy, cam, false); // topScroll.cameraPane;
|
topView.linecolor = topView.linecolorZ;
|
cam = GetCamera(copy, 2);
|
frontView = new CameraPane(copy, cam, false); // frontScroll.cameraPane;
|
frontView.linecolor = topView.linecolorY;
|
cam = GetCamera(copy, 3);
|
sideView = new CameraPane(copy, cam, false); // sideScroll.cameraPane;
|
sideView.linecolor = topView.linecolorX;
|
|
cam = GetCamera(copy, 0);
|
cameraView = new CameraPane(copy, cam, false);
|
cam = GetCamera(copy, 4);
|
cameraView.SetLight(cam);
|
|
cameraView.SetAsGLRenderer(true);
|
//cameraView.camera.perspective = true;
|
|
//worldView = new gov.nasa.worldwind.awt.WorldWindowGLCanvas();
|
|
//JPanel worldPanel =
|
// new gov.nasa.worldwind.examples.ApplicationTemplate.AppPanel(null, true);
|
//worldPanel.setName("World");
|
/*JPanel*/ cameraPanel =
|
new JPanel(new BorderLayout());
|
cameraPanel.add(cameraView);
|
|
//topView.camera = ;
|
//frontView.camera = new Camera(2);
|
//sideView.camera = new Camera(3);
|
if (false)
|
{
|
topView.SetAsGLRenderer(true);
|
frontView.SetAsGLRenderer(true);
|
sideView.SetAsGLRenderer(true);
|
}
|
|
//cameraView.object = copy;
|
//topView.object = copy;
|
//frontView.object = copy;
|
//sideView.object = copy;
|
|
XYZPanel = new JPanel();
|
XYZPanel.setLayout(new GridLayout(3, 1, 5, 5));
|
|
XYZPanel.add(/*BorderLayout.SOUTH,*/sideView); // Scroll);
|
XYZPanel.add(/*BorderLayout.CENTER,*/frontView); // Scroll);
|
XYZPanel.add(/*BorderLayout.NORTH,*/topView); // Scroll);
|
|
/*
|
gridPanel = new JPanel(); //new BorderLayout());
|
gridPanel.setLayout(new GridLayout(1, 2));
|
|
gridPanel.add(cameraView);
|
gridPanel.add(XYZPanel);
|
*/
|
gridPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, cameraPanel, XYZPanel); //new BorderLayout());
|
gridPanel.setContinuousLayout(true);
|
gridPanel.setOneTouchExpandable(true);
|
gridPanel.setDividerLocation(1.0);
|
gridPanel.setDividerSize(9);
|
gridPanel.setResizeWeight(0.85);
|
|
// aConstraints.weighty = 0;
|
//System.out.println("THIS = " + this);
|
// juin 2013
|
//SetupName(this); // new
|
|
// System.out.println("Constraints = " + aConstraints);
|
// aConstraints.gridx = 0;
|
// aConstraints.gridy = 0;
|
// aConstraints.gridwidth = 1;
|
////
|
//// ctrlPanel.add(clearPanelButton = new cButton("Clear Panel"), aConstraints, ctrlPanel.getComponentCount()-1);
|
//// clearPanelButton.addActionListener(this);
|
////
|
//// aConstraints.gridy += 1;
|
// clearPanelButton = AddButton(this, "Clear Panel");
|
// Return(this);
|
// aConstraints.weighty = 0;
|
// aConstraints.gridy = 0;
|
|
//JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
//tmp.setName("Edit");
|
objectPanel.add(materialPanel);
|
JPanel north = new JPanel(new BorderLayout());
|
north.setName("Edit");
|
north.add(ctrlPanel, BorderLayout.NORTH);
|
objectPanel.add(north);
|
objectPanel.add(infoPanel);
|
|
/*
|
aConstraints.gridx = 0;
|
aConstraints.gridwidth = 1;
|
mainPanel.add(treePanel, aConstraints);
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
mainPanel.add(objectPanel, aConstraints);
|
*/
|
|
scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
|
VERTICAL_SCROLLBAR_AS_NEEDED,
|
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
//JPanel jsp = mainPanel;
|
scrollpane.setName("Scene");
|
//jsp.setViewportView(ctrlPanel);
|
scrollpane.setWheelScrollingEnabled(true);
|
scrollpane.addMouseWheelListener(this); // Default not fast enough
|
|
/*JTabbedPane*/ jtp = new JTabbedPane();
|
jtp.add(scrollpane);
|
|
jtp.add(FSPane = new cFileSystemPane(this));
|
|
optionsPanel = new JPanel(new GridBagLayout());
|
|
optionsPanel.setName("Options");
|
jtp.add(optionsPanel);
|
|
|
/*
|
cTree jTree = new cTree(null);
|
ToolTipManager.sharedInstance().registerComponent(jTree);
|
jTree.setCellRenderer(new cFileSystemModel.Renderer());
|
jTree.setModel(new cFileSystemModel(
|
//java.io.File.listRoots()[1])
|
javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(),
|
new cFilter("3ds")
|
));
|
jTree.setDragEnabled(true);
|
|
JScrollPane tree = new cFileSystemPane(jTree);
|
tree.setName("File system");
|
//jTree.addTreeSelectionListener(this);
|
//jTree.setRootVisible(false);
|
//jTree.setEditable(true);
|
|
jtp.add(tree);
|
*/
|
|
bigPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jtp, gridPanel);
|
bigPanel.setContinuousLayout(true);
|
bigPanel.setOneTouchExpandable(true);
|
bigPanel.setDividerLocation(0.8);
|
bigPanel.setDividerSize(15);
|
bigPanel.setResizeWeight(0.15);
|
bigPanel.setName("Scene");
|
|
//bigPanel.setLayout(new BorderLayout());
|
//bigPanel.setSize(new Dimension(10,10));
|
//bigPanel.add(ctrlPanel);
|
//bigPanel.add(gridPanel);
|
bigThree = new JPanel();
|
//big.setLayout(new FlowLayout(FlowLayout.LEFT));
|
bigThree.setLayout(new GridBagLayout()); //1,3,5,5));
|
aWindowConstraints.gridx = 0;
|
aWindowConstraints.gridy = 0;
|
aWindowConstraints.gridwidth = 1;
|
// aWindowConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.VERTICAL;
|
aWindowConstraints.weightx = 0;
|
aWindowConstraints.weighty = 1;
|
bigThree.add(jtp, aWindowConstraints);
|
aWindowConstraints.weightx = 1;
|
aWindowConstraints.gridwidth = 3;
|
// aConstraints.gridheight = 3;
|
aWindowConstraints.gridx = 1;
|
aWindowConstraints.fill = GridBagConstraints.BOTH;
|
bigThree.add(cameraPanel, aWindowConstraints);
|
aWindowConstraints.weightx = 0;
|
aWindowConstraints.gridx = 4;
|
aWindowConstraints.gridwidth = 1;
|
// aConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.VERTICAL;
|
bigThree.add(XYZPanel, aWindowConstraints);
|
|
// // SIDE EFFECT!!!
|
// aConstraints.gridx = 0;
|
// aConstraints.gridy = 0;
|
// aConstraints.weighty = 0;
|
// aConstraints.gridheight = 1;
|
|
framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
|
framePanel.setContinuousLayout(true);
|
framePanel.setOneTouchExpandable(true);
|
framePanel.setDividerLocation(0.8);
|
//framePanel.setDividerSize(15);
|
//framePanel.setResizeWeight(0.15);
|
framePanel.setName("Frame");
|
|
frame.getContentPane().setLayout(new BorderLayout());
|
/**/
|
JTabbedPane worldPane = new JTabbedPane();
|
//worldPane.add(bigPanel);
|
//worldPane.add(worldPanel);
|
/**/
|
frame.getContentPane().add(/*"Center",*/framePanel);
|
//frame.getContentPane().add(/*"Center",*/ worldPane);
|
|
// aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
|
|
frame.setSize(1024, 768);
|
frame.show();
|
|
gridPanel.setDividerLocation(1.0);
|
|
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
frame.addWindowListener(new WindowAdapter()
|
{
|
|
public void windowClosing(WindowEvent e)
|
{
|
Close();
|
}
|
});
|
}
|
|
JTree GetTree()
|
{
|
return objEditor.jTree;
|
}
|
|
void ClearCtrlPanel()
|
{
|
//System.out.println("Clear panel");
|
ctrlPanel.removeAll();
|
}
|
|
void SetupMaterial(JPanel ctrlPanel)
|
{
|
aConstraints.weighty = 0;
|
//aConstraints.weightx = 1;
|
/*
|
ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
|
materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
*/
|
|
aConstraints.gridwidth = 1;
|
ctrlPanel.add(createMaterialButton = new cButton("Create"), aConstraints);
|
aConstraints.gridx += 1;
|
aConstraints.weighty = 0;
|
aConstraints.gridwidth = 1;
|
|
/*
|
ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
|
aConstraints.gridx += 1;
|
aConstraints.weighty = 0;
|
aConstraints.gridwidth = 1;
|
*/
|
|
ctrlPanel.add(clearMaterialButton = new cButton("Clear"), aConstraints);
|
aConstraints.gridx += 1;
|
|
ctrlPanel.add(resetSlidersButton = new cButton("Reset"), aConstraints);
|
|
aConstraints.gridx += 1;
|
|
ctrlPanel.add(propagateToggle = new cCheckBox("Prop", propagate), aConstraints);
|
|
aConstraints.gridx += 1;
|
|
ctrlPanel.add(multiplyToggle = new cCheckBox("Mult", false), aConstraints);
|
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.weighty = 0;
|
aConstraints.gridwidth = 1;
|
/**/
|
//aConstraints.weighty = 0;
|
////aConstraints.weightx = 1;
|
//aConstraints.weighty = 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
|
//aConstraints.gridx += 1;
|
ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
|
aConstraints.weighty = 0;
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(colorLabel = new JLabel("Color/hue"), aConstraints);
|
colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
//aConstraints.weightx = 0;
|
ctrlPanel.add(colorField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(modulationLabel = new JLabel("Saturation"), aConstraints);
|
modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(modulationField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(textureLabel = new JLabel("Texture"), aConstraints);
|
textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(textureField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(anisoLabel = new JLabel("AnisoU"), aConstraints);
|
anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(anisoField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(anisoVLabel = new JLabel("AnisoV"), aConstraints);
|
anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(anisoVField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(shadowbiasLabel = new JLabel("Shadowbias"), aConstraints);
|
shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(shadowbiasField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
//aConstraints.weighty = 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
|
//aConstraints.gridx += 1;
|
ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
|
aConstraints.weighty = 0;
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(diffuseLabel = new JLabel("Diffuse"), aConstraints);
|
diffuseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(diffuseField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(diffusenessLabel = new JLabel("Diffusion"), aConstraints);
|
diffusenessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(diffusenessField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(selfshadowLabel = new JLabel("Selfshadow"), aConstraints);
|
selfshadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(selfshadowField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(sheenLabel = new JLabel("Sheen"), aConstraints);
|
sheenLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(sheenField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(subsurfaceLabel = new JLabel("Subsurface"), aConstraints);
|
subsurfaceLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(subsurfaceField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(shadowLabel = new JLabel("Shadowing"), aConstraints);
|
shadowLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(shadowField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(fakedepthLabel = new JLabel("Fakedepth"), aConstraints);
|
fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(fakedepthField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
//aConstraints.weighty = 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
|
//aConstraints.gridx += 1;
|
ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
|
aConstraints.weighty = 0;
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(specularLabel = new JLabel("Specular"), aConstraints);
|
specularLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(specularField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(lightareaLabel = new JLabel("Lightarea"), aConstraints);
|
lightareaLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(lightareaField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(shininessLabel = new JLabel("Roughness"), aConstraints);
|
shininessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(shininessField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(metalnessLabel = new JLabel("Metalness"), aConstraints);
|
metalnessLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(metalnessField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(velvetLabel = new JLabel("Velvet"), aConstraints);
|
velvetLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(velvetField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
shiftField = AddSlider(ctrlPanel, "Shift", 0.001, 50, copy.material.shift, -1);
|
Return();
|
// ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
|
// shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
// aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
// aConstraints.gridx += 1;
|
// aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
// ctrlPanel.add(shiftField = new NumberSlider(0.001,50,-1 /*.5*/), aConstraints);
|
// aConstraints.gridx = 0;
|
// aConstraints.gridy += 1;
|
// aConstraints.gridwidth = 1;
|
|
//aConstraints.weighty = 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
|
//aConstraints.gridx += 1;
|
ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
|
aConstraints.weighty = 0;
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(cameraLabel = new JLabel("GlobalLight"), aConstraints);
|
cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(cameraField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(ambientLabel = new JLabel("Ambient"), aConstraints);
|
ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(ambientField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(backlitLabel = new JLabel("Backlit"), aConstraints);
|
backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(backlitField = new NumberSlider(0.001, 50, -1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(opacityLabel = new JLabel("Opacity"), aConstraints);
|
opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(opacityField = new NumberSlider(0.001, 1, -0.1), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
aConstraints.weighty = 0;
|
|
ctrlPanel.add(bumpLabel = new JLabel("Bump"), aConstraints);
|
bumpLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(bumpField = new NumberSlider(0.0, 2), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(noiseLabel = new JLabel("Noise"), aConstraints);
|
noiseLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(noiseField = new NumberSlider(0.0, 1/*5*/), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(powerLabel = new JLabel("Turbulance"), aConstraints);
|
powerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(powerField = new NumberSlider(0.0, 5), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(borderfadeLabel = new JLabel("Borderfade"), aConstraints);
|
borderfadeLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(borderfadeField = new NumberSlider(0.0, 2), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(fogLabel = new JLabel("Punch"), aConstraints);
|
fogLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(fogField = new NumberSlider(0.0, 20), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
ctrlPanel.add(opacityPowerLabel = new JLabel("Halo"), aConstraints);
|
opacityPowerLabel.setHorizontalAlignment(SwingConstants.TRAILING);
|
aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
aConstraints.gridx += 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
|
ctrlPanel.add(opacityPowerField = new NumberSlider(0.0, 10 /*10 dec 2013*/), aConstraints);
|
aConstraints.gridx = 0;
|
aConstraints.gridy += 1;
|
aConstraints.gridwidth = 1;
|
|
//aConstraints.weighty = 1;
|
aConstraints.gridwidth = ObjEditor.GRIDWIDTH; // 100;
|
//aConstraints.gridx += 1;
|
ctrlPanel.add(new JLabel("----------------------------------"), aConstraints);
|
aConstraints.weighty = 0;
|
|
aConstraints.gridx = 0;
|
aConstraints.gridy = 0;
|
aConstraints.gridwidth = 1;
|
|
SetMaterial(copy); // .GetMaterial());
|
|
colorField.addChangeListener(this);
|
modulationField.addChangeListener(this);
|
metalnessField.addChangeListener(this);
|
diffuseField.addChangeListener(this);
|
specularField.addChangeListener(this);
|
shininessField.addChangeListener(this);
|
shiftField.addChangeListener(this);
|
ambientField.addChangeListener(this);
|
lightareaField.addChangeListener(this);
|
diffusenessField.addChangeListener(this);
|
velvetField.addChangeListener(this);
|
sheenField.addChangeListener(this);
|
subsurfaceField.addChangeListener(this);
|
backlitField.addChangeListener(this);
|
anisoField.addChangeListener(this);
|
anisoVField.addChangeListener(this);
|
cameraField.addChangeListener(this);
|
selfshadowField.addChangeListener(this);
|
shadowField.addChangeListener(this);
|
textureField.addChangeListener(this);
|
opacityField.addChangeListener(this);
|
fakedepthField.addChangeListener(this);
|
shadowbiasField.addChangeListener(this);
|
bumpField.addChangeListener(this);
|
noiseField.addChangeListener(this);
|
powerField.addChangeListener(this);
|
borderfadeField.addChangeListener(this);
|
fogField.addChangeListener(this);
|
opacityPowerField.addChangeListener(this);
|
/**/
|
|
resetSlidersButton.addActionListener(this);
|
clearMaterialButton.addActionListener(this);
|
createMaterialButton.addActionListener(this);
|
|
propagateToggle.addItemListener(this);
|
multiplyToggle.addItemListener(this);
|
}
|
|
void DropFile(java.io.File[] files, boolean textures)
|
{
|
for (java.io.File file : files)
|
{
|
String filename = file.getAbsolutePath();
|
|
if (filename.endsWith(".switch"))
|
{
|
LoadSwitch(filename);
|
continue;
|
}
|
|
// 3D models
|
if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
|
{
|
lastConverter = new com.jmex.model.converters.MaxToJme();
|
LoadFile(filename, lastConverter);
|
continue;
|
}
|
if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
|
{
|
try
|
{
|
java.net.URL url = file.toURI().toURL();
|
// converter.setProperty( "texurl", url );
|
// java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
|
// converter.convert( , bos );
|
|
com.jmex.model.collada.ColladaImporter.load(url.openStream(), "allo");
|
|
Object3D newobj = new cJME().Read(com.jmex.model.collada.ColladaImporter.getModel());
|
makeSomething(newobj, true);
|
} catch (Exception e)
|
{
|
}
|
// lastConverter = new com.jmex.model.collada.ColladaToJme();
|
// LoadFile(filename, lastConverter);
|
continue;
|
}
|
if (filename.endsWith(".obj") || filename.endsWith(".OBJ"))
|
{
|
//lastConverter = new com.jmex.model.converters.ObjToJme();
|
//LoadFile(filename, lastConverter);
|
LoadObjFile(filename);
|
continue;
|
} // if(inFile.getName().toUpperCase().endsWith(".DAE"))
|
if (filename.endsWith(".gfd") || filename.endsWith(".GFD"))
|
{
|
LoadGFDFile(filename);
|
continue;
|
}
|
if (filename.endsWith(".bvh") || filename.endsWith(".BVH"))
|
{
|
LoadBVHFile(filename, true);
|
continue;
|
}
|
|
if (filename.toUpperCase().endsWith(".DAE"))
|
{
|
LoadCollada(filename, true);
|
continue;
|
}
|
|
if (filename.endsWith(".wrl") || filename.endsWith(".WRL")
|
|| filename.endsWith(".x3d") || filename.endsWith(".X3D"))
|
{
|
LoadVRMLX3D(filename);
|
continue;
|
}
|
|
// Images/textures
|
if (filename.toLowerCase().endsWith(".jpg")
|
|| filename.toLowerCase().endsWith(".jpeg")
|
|| filename.toLowerCase().endsWith(".gif")
|
|| filename.toLowerCase().endsWith(".png")
|
|| filename.toLowerCase().endsWith(".tre")
|
|| filename.toLowerCase().endsWith(".bmp")
|
|| filename.toLowerCase().endsWith(".tga")
|
|| filename.toLowerCase().endsWith(".sgi")
|
|| filename.toLowerCase().endsWith(".tif")
|
|| filename.toLowerCase().endsWith(".tiff"))
|
{
|
if (textures)
|
DropTexture(filename);
|
else
|
CreateBillboard(filename);
|
continue;
|
}
|
|
//makeSomething(ReadGFD(filename));
|
ReadGFD(filename, this);
|
}
|
|
ResetModel();
|
}
|
|
void CreateBillboard(String filename)
|
{
|
Object3D source = null;
|
Object3D group = copy;
|
|
if (group.selection.size() > 0)
|
{
|
source = group.selection.get(0);
|
}
|
|
Grid grid = new Grid(1,1);
|
grid.material = null;
|
|
grid.toParent = LA.newMatrix();
|
grid.fromParent = LA.newMatrix();
|
LA.matYRotate(grid.toParent, Math.PI/2);
|
LA.matXRotate(grid.toParent, -Math.PI/2);
|
LA.matXRotate(grid.fromParent, Math.PI/2);
|
LA.matYRotate(grid.fromParent, -Math.PI/2);
|
|
BillboardNode bb = new BillboardNode();
|
bb.addChild(grid);
|
|
Object3D newgroup = new Object3D();
|
newgroup.CreateMaterial();
|
|
File file = new File(filename);
|
newgroup.name = file.getName();
|
newgroup.addChild(bb);
|
|
Object3D main = newgroup;
|
|
main.SetPigmentTexture(filename);
|
|
if (source != null)
|
{
|
main.material = new cMaterial(source.material);
|
if (main.projectedVertices.length < source.projectedVertices.length)
|
{
|
main.projectedVertices = new Object3D.cVector2[source.projectedVertices.length];
|
}
|
|
for (int i=0; i<source.projectedVertices.length; i++)
|
{
|
main.projectedVertices[i].x = source.projectedVertices[i].x;
|
main.projectedVertices[i].y = source.projectedVertices[i].y;
|
}
|
|
main.texres = source.texres;
|
}
|
|
makeSomething(newgroup, false);
|
}
|
|
Point location;
|
|
void DropTexture(String filename)
|
{
|
// assert(copy instanceof Composite);
|
// Composite group = (Composite) copy;
|
Object3D group = copy;
|
|
//??? java.util.Vector<Object3D> tempsel = (java.util.Vector<Object3D>) group.selection.clone();
|
Object3D source = null;
|
|
if (group.selection.size() > 0)
|
{
|
source = group.selection.get(0);
|
}
|
|
//? flashIt = false;
|
CameraPane pane = (CameraPane) cameraView;
|
pane.clickStart(location.x, location.y, 0);
|
pane.clickEnd(location.x, location.y, 0, true);
|
|
if (group.selection.size() == 1)
|
{
|
Object3D targ = group.selection.get(0);
|
|
if (filename.endsWith("NRM.jpg") || filename.endsWith("Normal.jpg") || filename.endsWith("Bump.jpg") || filename.endsWith("_B.jpg"))
|
{
|
targ.SetBumpTexture(filename);
|
} else
|
{
|
targ.SetPigmentTexture(filename);
|
}
|
}
|
|
// ?? boolean first = true;
|
// for(Object3D o : tempsel)
|
// {
|
// Select(o.GetTreePath(), first);
|
// first = false;
|
// }
|
|
if (source != null)
|
{
|
Select(source.GetTreePath(), true, true);
|
}
|
|
//? flashIt = true;
|
|
refreshContents();
|
}
|
|
void LoadVRMLX3D(String fullname)
|
{
|
try
|
{
|
//org.j3d.renderer.aviatrix3d.loader.AVModel scene = new org.xj3d.loaders.ogl.VRML97Loader().load(new java.io.File(fullname));
|
org.j3d.renderer.aviatrix3d.loader.AVModel scene = new org.xj3d.loaders.ogl.X3DLoader().load(new java.io.File(fullname));
|
//org.j3d.renderer.aviatrix3d.loader.AVModel scene = new org.j3d.renderer.aviatrix3d.loader.discreet.MaxLoader().load(new java.io.File(fullname));
|
System.out.println("Scene = " + scene);
|
makeSomething(cAviatrix.Read(scene.getModelRoot()), true);
|
System.gc();
|
//refreshContents();
|
} catch (java.io.IOException e2)
|
{
|
e2.printStackTrace();
|
}
|
}
|
LoadJMEThread loadThread;
|
|
class LoadJMEThread extends Thread
|
{
|
//String filename;
|
//com.jmex.model.converters.FormatConverter converter;
|
|
java.util.Stack stack;
|
|
LoadJMEThread(/*String fullname, com.jmex.model.converters.FormatConverter conv*/)
|
{
|
//filename = fullname;
|
//converter = conv;
|
stack = new java.util.Stack();
|
}
|
|
void add(String filename, com.jmex.model.converters.FormatConverter conv)
|
{
|
stack.push(filename);
|
stack.push(conv);
|
}
|
|
public void run()
|
{
|
boolean wasbusy = false;
|
|
for (;;)
|
{
|
try
|
{
|
sleep(10);
|
} catch (Exception e)
|
{
|
};
|
if (!stack.empty())
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
com.jmex.model.converters.FormatConverter converter = (com.jmex.model.converters.FormatConverter) stack.pop();
|
String filename = (String) stack.pop();
|
System.out.println(" ------- ------- ------ ------ ----- LOADING... " + filename);
|
LoadFile0(filename, converter);
|
System.gc();
|
|
wasbusy = true;
|
} else
|
{
|
if (wasbusy)
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
wasbusy = false;
|
}
|
}
|
}
|
|
//LoadFile0(filename, converter);
|
}
|
}
|
LoadOBJThread loadObjThread;
|
|
class LoadOBJThread extends Thread
|
{
|
//String filename;
|
//com.jmex.model.converters.FormatConverter converter;
|
|
java.util.Stack stack;
|
|
LoadOBJThread(/*String fullname, com.jmex.model.converters.FormatConverter conv*/)
|
{
|
//filename = fullname;
|
//converter = conv;
|
stack = new java.util.Stack();
|
}
|
|
void add(String filename)
|
{
|
stack.push(filename);
|
}
|
|
public void run()
|
{
|
boolean wasbusy = false;
|
|
for (;;)
|
{
|
try
|
{
|
sleep(10);
|
} catch (Exception e)
|
{
|
};
|
if (!stack.empty())
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
String filename = (String) stack.pop();
|
System.out.println(" ------- ------- ------ ------ ----- LOADING... " + filename);
|
makeSomething(ReadOBJ(filename), true);
|
System.gc();
|
|
wasbusy = true;
|
} else
|
{
|
if (wasbusy)
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
wasbusy = false;
|
}
|
}
|
}
|
|
//LoadFile0(filename, converter);
|
}
|
}
|
|
void LoadFile0(String fullname, com.jmex.model.converters.FormatConverter converter)
|
{
|
Reload(converter, fullname, true);
|
}
|
|
void LoadFile(String fullname, com.jmex.model.converters.FormatConverter converter)
|
{
|
//lastFilename = fullname;
|
//cJME.count = 0;
|
//LoadFile0(fullname);
|
//new LoadJMEThread(fullname, converter).start();
|
if (loadThread == null)
|
{
|
loadThread = new LoadJMEThread(/*fullname, converter*/);
|
loadThread.start();
|
}
|
|
loadThread.add(fullname, converter);
|
}
|
|
void LoadObjFile(String fullname)
|
{
|
/*
|
//lastFilename = fullname;
|
if(loadObjThread == null)
|
{
|
loadObjThread = new LoadOBJThread();
|
loadObjThread.start();
|
}
|
|
loadObjThread.add(fullname);
|
*/
|
|
System.out.println("Loading " + fullname);
|
makeSomething(new FileObject(fullname, true), true);
|
}
|
|
void LoadGFDFile(String fullname)
|
{
|
System.out.println("Loading " + fullname);
|
makeSomething(new FileObject(fullname, false), true);
|
}
|
|
void LoadBVHFile(String fullname, boolean changename)
|
{
|
System.out.println("Loading " + fullname);
|
|
mocap.reader.BVHReader rd = new mocap.reader.BVHReader(0.75);
|
try
|
{
|
File file = new File(fullname);
|
|
Mocap mocap = new Mocap("Mocap" + file.getName());
|
|
mocap.bvh = rd.readFile(file);
|
//System.err.println("NEW MOCAP fullname = " + fullname);
|
mocap.fullname = fullname;
|
//initFigure(bvh.skeleton, f.getName(), offset);
|
|
//? mocap.setPose(0);
|
|
// mocap.SmoothAnimData(); // FilterAnimData();
|
|
// for (int i=50; --i>=0;)
|
// mocap.SmoothAnimData(); // much reduces shakiness
|
|
// CROWD
|
//if (!changename)
|
// mocap.SetPositionDelta();
|
|
mocap.live = true;
|
|
if (copy.selection.size() > 0 && copy.selection.get(0) instanceof Mocap)
|
{
|
Mocap sel = (Mocap) copy.selection.get(0);
|
|
sel.fullname = fullname;
|
|
if (changename)
|
{
|
sel.name = mocap.name;
|
}
|
sel.bvh.animation = mocap.bvh.animation;
|
|
sel.endframe = sel.bvh.animation.getNumFrames(); // june 2013
|
|
sel.smoothed = false;
|
|
// if (!changename)
|
//sel.SetPositionDelta(false, true, true, true/*?*/); // false
|
sel.SetGlobalTransform();
|
sel.LoadData();
|
sel.Rewind();
|
sel.Fade();
|
// sel.setPose(0);
|
refreshContents();
|
} else
|
{
|
mocap.Reset();
|
// new skeleton
|
makeSomething(mocap, true); // true);
|
}
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
// CameraPane.tickcount = 64; // global slow pose for half a second
|
}
|
|
static void LoadBVHFile(String fullname, Object3D select, boolean changename, int beginframe, int endframe)
|
{
|
// june 2014
|
beginframe = 0; endframe = 0;
|
|
if (fullname == null)
|
{
|
System.err.println("NO MOCAP for " + select);
|
return;
|
}
|
System.out.println("Loading FULL " + fullname);
|
|
mocap.reader.BVHReader rd = new mocap.reader.BVHReader(0.75);
|
try
|
{
|
Mocap sel = (Mocap) select;
|
|
File file = new File(fullname);
|
|
// Mocap mocap = new Mocap("Mocap" + file.getName());
|
|
if (select.random) // june 2014 && !CameraPane.FAST)
|
{
|
// suppose a random crowd. We need longer mocap data.
|
System.err.println("MOCAP EXTENSION (load)");
|
rd.mocapextension = rd.EXTENSION;
|
}
|
|
//mocap.
|
sel.bvh = rd.readFile(file);
|
//System.err.println("NEW2 MOCAP fullname = " + fullname);
|
// mocap.fullname = fullname;
|
//initFigure(bvh.skeleton, f.getName(), offset);
|
|
//sel.skeleton = null;
|
sel.smoothed = false;
|
|
// CROWD
|
// if (!changename)
|
// mocap.SetPositionDelta();
|
|
//? mocap.setPose(0);
|
|
// mocap.SmoothAnimData(); // FilterAnimData();
|
|
// for (int i=50; --i>=0;)
|
// mocap.SmoothAnimData(); // much reduces shakiness
|
|
// CROWD
|
//if (!changename)
|
// mocap.SetPositionDelta();
|
|
// mocap.live = true;
|
|
sel.fullname = fullname;
|
|
sel.endframe = endframe;
|
|
sel.firstframe = 0;
|
sel.lastframe = 0;
|
|
if (sel.endframe == 0)
|
{
|
sel.endframe = sel.bvh.animation.getNumFrames();
|
}
|
|
if (beginframe != -1)
|
{
|
sel.beginframe = beginframe;
|
} else
|
{
|
sel.beginframe = 0; // (int)(Math.random()*endframe);
|
}
|
// if (changename)
|
// sel.name = mocap.name;
|
|
// sel.bvh.animation = mocap.bvh.animation;
|
|
// for (int i=50; --i>=0;)
|
// sel.SmoothAnimData(); // much reduces shakiness
|
|
if (!changename)
|
{
|
//sel.SetPositionDelta(false, true, true, true/*?*/);
|
sel.SetGlobalTransform();
|
sel.LoadData();
|
sel.Rewind();
|
sel.Fade();
|
}
|
|
// sel.setPose(0);
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
CameraPane.tickcount = 64; // global slow pose for half a second
|
}
|
|
void LoadSwitch(String fullname)
|
{
|
try
|
{
|
File file = new File(fullname);
|
|
File[] files = file.listFiles();
|
|
int count = 0;
|
|
for (int i = files.length; --i >= 0;)
|
{
|
if (files[i].getName().endsWith(".obj"))
|
{
|
count++;
|
}
|
}
|
|
boolean stripify = cJME.stripify;
|
cJME.stripify = false; // Poses change stripification
|
|
if (copy.selection.Size() > 0 && copy.selection.get(0).Size() == count) // not good
|
{
|
// replace
|
Object3D target = copy.selection.get(0);
|
|
for (int i = files.length; --i >= 0;)
|
{
|
String filename = files[i].getAbsolutePath();
|
|
if (!filename.endsWith(".obj"))
|
{
|
continue;
|
}
|
|
Object3D obj = ReadOBJ(filename);
|
|
target.get(--count).overwriteThis(obj, Object3D.GEOMETRY);
|
target.get(count).name = files[i].getName().split(".obj")[0];
|
}
|
|
refreshContents();
|
} else
|
{
|
Object3D newgroup = new Object3D(file.getName());
|
|
for (int i=0; i<files.length; i++)
|
{
|
String filename = files[i].getAbsolutePath();
|
|
if (!filename.endsWith(".obj"))
|
continue;
|
|
Object3D obj = ReadOBJ(filename);
|
|
Object3D tmpgroup = new Object3D(obj.name);
|
cMesh mesh = new cMesh(obj);
|
mesh.setup();
|
mesh.ExtractGeometries(tmpgroup, false);
|
tmpgroup.get(0).bRep.Stripify();
|
tmpgroup.get(0).bRep.Untrim();
|
obj = tmpgroup.get(0);
|
|
newgroup.addChild(obj);
|
}
|
|
// load
|
makeSomething(newgroup, true);
|
}
|
|
cJME.stripify = stripify;
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
com.jmex.model.converters.FormatConverter lastConverter;
|
String lastFilename;
|
|
void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
|
{
|
if (GrafreeD.standAlone)
|
{
|
/**/
|
FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
String fullname = browser.getDirectory() + filename;
|
lastConverter = converter;
|
LoadFile(fullname, lastConverter);
|
}
|
/**/
|
|
// Note: source for ExampleFileFilter can be found in FileChooserDemo,
|
// under the demo/jfc directory in the JDK.
|
/*
|
Filter filter = new Filter(ext);
|
//filter.addExtension("3ds");
|
//filter.addExtension("gif");
|
//filter.setDescription("JPG & GIF Images");
|
chooser.setUI(new cFileChooserUI(chooser));
|
chooser.updateUI();
|
chooser.setFileFilter(filter);
|
chooser.setDragEnabled(true);
|
chooser.setMultiSelectionEnabled(true);
|
chooser.setDialogTitle(dialogName);
|
*/
|
/*
|
BFileChooser chooser = new BFileChooser(BFileChooser.OPEN_FILE, dialogName);
|
chooser.setMultipleSelectionEnabled(true);
|
if( chooser.showDialog(null) )
|
{
|
System.out.println("ALLO");
|
for (java.io.File f : chooser.getSelectedFiles())
|
{
|
lastConverter = converter;
|
lastFilename = f.getAbsolutePath();
|
System.out.println(lastFilename);
|
cJME.count = 0;
|
Reload(false, ext.equals("3ds"));
|
}
|
System.gc();
|
}
|
*/
|
}
|
}
|
|
static Object3D ReadOBJ(String filename)
|
{
|
try
|
{
|
ObjectFile f = new ObjectFile();
|
com.sun.j3d.loaders.Scene s = null;
|
|
String[] splits = filename.split("/");
|
System.out.println("Loading... " + filename);
|
|
s = f.load(filename);
|
|
System.gc();
|
// System.gc();
|
// System.gc();
|
System.out.println("Reading... " + splits[splits.length - 1]);
|
Object3D object = new cJ3D().Read(s, splits[splits.length - 1].split("\\.")[0]);
|
// object.SetPigmentTexture(file.toString() + object.GetPigmentTexture());
|
// object.SetBumpTexture(file.toString() + object.GetBumpTexture());
|
return object;
|
} catch (//FileNotFound
|
Exception e)
|
{
|
System.err.println(e);
|
}
|
|
return null;
|
}
|
|
void Reload(com.jmex.model.converters.FormatConverter converter, String filename, boolean gc)
|
{
|
if (filename == null)
|
{
|
return;
|
}
|
|
try
|
{
|
//com.jmex.model.converters.FormatConverter converter = new com.jmex.model.converters.ObjToJme();
|
java.io.File file = new java.io.File(filename);
|
java.net.URL url = file.toURI().toURL();
|
converter.setProperty("texurl", url);
|
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
|
converter.convert(url.openStream(), bos);
|
com.jme.scene.Spatial scene = (com.jme.scene.Spatial) com.jme.util.export.binary.BinaryImporter.getInstance().load(
|
new java.io.ByteArrayInputStream(bos.toByteArray()));
|
|
System.out.println("Scene = " + scene);
|
Object3D newobj = new cJME().Read(scene);
|
newobj.name = file.getName();
|
//if(.xxx
|
newobj.name = newobj.name.substring(0, newobj.name.length() - 4);
|
makeSomething(newobj, true);
|
if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
|
{
|
// Patch
|
//Composite group = (Composite) copy;
|
Object3D group = (Object3D) copy;
|
|
if (group.name.equals("TEMP"))
|
{
|
group = (Composite) group.get(0);
|
}
|
|
LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
|
LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
|
}
|
//cJME.count++;
|
//cJME.count %= 12;
|
if (gc)
|
{
|
System.gc();
|
}
|
} catch (java.io.IOException e2)
|
{
|
e2.printStackTrace();
|
}
|
}
|
|
void LoadCollada(String filename, boolean gc)
|
{
|
if (filename == null)
|
{
|
return;
|
}
|
// try
|
{
|
//com.jmex.model.converters.FormatConverter converter = new com.jmex.model.converters.ObjToJme();
|
java.io.File inFile = new java.io.File(filename);
|
com.jme.scene.Spatial collada = null;
|
// if(inFile.getName().toUpperCase().endsWith(".DAE"))
|
{
|
FileInputStream input = null;
|
try
|
{
|
input = new FileInputStream(inFile);
|
} catch (FileNotFoundException e1)
|
{
|
}
|
if (input == null)
|
{
|
System.exit(0);
|
}
|
|
|
try
|
{
|
String modelName = inFile.getName().substring(0,
|
inFile.getName().indexOf("."));
|
com.jmex.model.collada.ColladaImporter.load(input, modelName);
|
collada = com.jmex.model.collada.ColladaImporter.getModel();
|
com.jmex.model.collada.ColladaImporter.cleanUp();
|
} catch (Exception e)
|
{
|
}
|
|
collada.updateGeometricState(0, true);
|
collada.updateRenderState();
|
|
System.out.println("Collada Scene = " + collada);
|
Object3D newobj = new cJME().Read(collada);
|
newobj.name = inFile.getName();
|
//if(.xxx
|
newobj.name = newobj.name.substring(0, newobj.name.length() - 4);
|
makeSomething(newobj, true);
|
}
|
if (gc)
|
{
|
System.gc();
|
}
|
}
|
// catch(java.io.IOException e2) { e2.printStackTrace(); }
|
}
|
|
public void Callback(Object obj)
|
{
|
//assert(false);
|
if (obj == null)
|
{
|
return;
|
}
|
|
if (obj instanceof Object3D)
|
// BEURK
|
{
|
new Exception().printStackTrace();
|
makeSomething((Object3D) obj, true);
|
} else
|
{
|
DropFile((java.io.File[]) obj, false);
|
}
|
}
|
|
public void DragGesture()
|
{
|
//assert(false);
|
// Patch for DnD failure
|
if (GetTree() != null)
|
{
|
GetTree().clearSelection();
|
}
|
ResetSliders();
|
}
|
|
static void scrollByUnits(JScrollBar scrollbar, int direction,
|
int units)
|
{
|
// This method is called from BasicScrollPaneUI to implement wheel
|
// scrolling, as well as from scrollByUnit().
|
int delta;
|
|
for (int i = 0; i < units; i++)
|
{
|
if (direction > 0)
|
{
|
delta = scrollbar.getUnitIncrement(direction);
|
} else
|
{
|
delta = -scrollbar.getUnitIncrement(direction);
|
}
|
|
int oldValue = scrollbar.getValue();
|
int newValue = oldValue + delta;
|
|
// Check for overflow.
|
if (delta > 0 && newValue < oldValue)
|
{
|
newValue = scrollbar.getMaximum();
|
} else if (delta < 0 && newValue > oldValue)
|
{
|
newValue = scrollbar.getMinimum();
|
}
|
if (oldValue == newValue)
|
{
|
break;
|
}
|
scrollbar.setValue(newValue);
|
}
|
}
|
|
static void scrollByBlock(JScrollBar scrollbar, int direction)
|
{
|
// This method is called from BasicScrollPaneUI to implement wheel
|
// scrolling, and also from scrollByBlock().
|
int oldValue = scrollbar.getValue();
|
int blockIncrement = scrollbar.getBlockIncrement(direction);
|
int delta = blockIncrement * ((direction > 0) ? +1 : -1);
|
int newValue = oldValue + delta;
|
|
// Check for overflow.
|
if (delta > 0 && newValue < oldValue)
|
{
|
newValue = scrollbar.getMaximum();
|
} else if (delta < 0 && newValue > oldValue)
|
{
|
newValue = scrollbar.getMinimum();
|
}
|
|
scrollbar.setValue(newValue);
|
}
|
|
public void mouseWheelMoved(MouseWheelEvent e)
|
{
|
if (scrollpane.isWheelScrollingEnabled()
|
&& e.getScrollAmount() != 0)
|
{
|
JScrollBar toScroll = scrollpane.getVerticalScrollBar();
|
int direction = 0;
|
// find which scrollbar to scroll, or return if none
|
if (toScroll == null || !toScroll.isVisible())
|
{
|
toScroll = scrollpane.getHorizontalScrollBar();
|
if (toScroll == null || !toScroll.isVisible())
|
{
|
return;
|
}
|
}
|
direction = e.getWheelRotation() < 0 ? -1 : 1;
|
if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL)
|
{
|
scrollByUnits(toScroll, direction,
|
e.getScrollAmount() * 10);
|
} else if (e.getScrollType()
|
== MouseWheelEvent.WHEEL_BLOCK_SCROLL)
|
{
|
scrollByBlock(toScroll, direction);
|
}
|
}
|
}
|
cFileSystemPane FSPane;
|
|
void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
|
{
|
current.Set(mat); // ...
|
anchor.Set(mat); // ...
|
|
freezematerial = true;
|
colorField.setFloat(mat.color);
|
modulationField.setFloat(mat.modulation);
|
metalnessField.setFloat(mat.metalness);
|
diffuseField.setFloat(mat.diffuse);
|
specularField.setFloat(mat.specular);
|
shininessField.setFloat(mat.shininess);
|
shiftField.setFloat(mat.shift);
|
ambientField.setFloat(mat.ambient);
|
lightareaField.setFloat(mat.lightarea);
|
diffusenessField.setFloat(mat.factor);
|
velvetField.setFloat(mat.velvet);
|
sheenField.setFloat(mat.sheen);
|
subsurfaceField.setFloat(mat.subsurface);
|
backlitField.setFloat(mat.bump);
|
anisoField.setFloat(mat.aniso);
|
anisoVField.setFloat(mat.anisoV);
|
cameraField.setFloat(mat.cameralight);
|
selfshadowField.setFloat(mat.diffuseness);
|
shadowField.setFloat(mat.shadow);
|
textureField.setFloat(mat.texture);
|
opacityField.setFloat(mat.opacity);
|
fakedepthField.setFloat(mat.fakedepth);
|
shadowbiasField.setFloat(mat.shadowbias);
|
bumpField.setInteger(1); // dec 2013
|
noiseField.setInteger(0);
|
powerField.setInteger(0);
|
borderfadeField.setInteger(0);
|
fogField.setInteger(0);
|
opacityPowerField.setInteger(0);
|
|
if (others != null && others.length > 0 && others[0] != null)
|
{
|
bumpField.setFloat(others[0].x / 1000.0f);
|
noiseField.setFloat(others[0].y / 1000.0f);
|
if (others.length > 1)
|
{
|
borderfadeField.setFloat(others[1].x / 1000.0f);
|
fogField.setFloat(others[1].y / 1000.0f);
|
if (others.length > 2)
|
{
|
powerField.setFloat(others[2].x / 1000.0f);
|
opacityPowerField.setFloat(others[2].y / 1000.0f);
|
}
|
}
|
}
|
freezematerial = false;
|
}
|
|
void SetMaterial(Object3D object)
|
{
|
cMaterial mat = object.material;
|
|
if (mat == null)
|
{
|
ResetSliders();
|
return;
|
}
|
|
multiplyToggle.setSelected(mat.multiply);
|
|
assert (object.projectedVertices != null);
|
|
if (object.projectedVertices.length <= 2)
|
{
|
// Side effect...
|
Object3D.cVector2[] keep = object.projectedVertices;
|
object.projectedVertices = new Object3D.cVector2[3];
|
for (int i = 0; i < 3; i++)
|
{
|
if (i < keep.length)
|
{
|
object.projectedVertices[i] = keep[i];
|
} else
|
{
|
object.projectedVertices[i] = new Object3D.cVector2();
|
}
|
/*
|
if(keep.length == 0)
|
object.projectedVertices[0] = new Object3D.cVector2();
|
else
|
object.projectedVertices[0] = keep[0];
|
object.projectedVertices[1] = new Object3D.cVector2();
|
*/
|
}
|
}
|
|
SetMaterial(mat, object.projectedVertices);
|
}
|
|
void ResetSliders()
|
{
|
cMaterial mid = new cMaterial(1);
|
|
mid.color = mid.modulation = mid.metalness = 0.1f;
|
mid.subsurface = mid.aniso = mid.anisoV = 0.1f;
|
mid.texture = 0.1f;
|
//mid.shadow = 0.25f;
|
// mid.shift = 1.5f;
|
// mid.sheen = 10f;
|
|
SetMaterial(mid, null);
|
}
|
|
void SetAnchorMaterial(cMaterial mat)
|
{
|
anchor.Set(mat);
|
}
|
|
void Clear()
|
{
|
cameraView.Clear();
|
topView.Clear();
|
sideView.Clear();
|
frontView.Clear();
|
|
copy = client = null;
|
}
|
|
void labelAndField(Component label, Component field)
|
{
|
int lblWidth = label.getPreferredSize().width;
|
label.setBounds(5, widgetPos, lblWidth, textHeight);
|
field.setBounds(5 + lblWidth, widgetPos, 190 - lblWidth, textHeight);
|
widgetPos += textHeight;
|
}
|
|
/*
|
public void doLayout()
|
{
|
super.doLayout();
|
int width = bigPanel.getSize().width;
|
int height = bigPanel.getSize().height;
|
ctrlPanel.setBounds(0, 0, 200, height);
|
gridPanel.setBounds(200, 0, width - 200, height);
|
widgetPos = 5;
|
textHeight = nameField.getPreferredSize().height;
|
nameField.setBounds(5, widgetPos, 190, textHeight);
|
widgetPos += textHeight + 5;
|
buttonHeight = textureButton.getPreferredSize().height;
|
textureButton.setBounds(5, widgetPos, 190, buttonHeight);
|
widgetPos += buttonHeight + 5;
|
applyButton.setBounds(5, height - buttonHeight - 5, 190, buttonHeight);
|
}
|
*/
|
public void Select(cTreePath child, boolean deselect, boolean raise)
|
{
|
//assert(false);
|
//assert child.parent == group;
|
//assert group.children.indexOf(child) != -1;
|
|
System.err.println("selection : " + child); // + " --> " + child.Leaf());
|
|
//CameraPane.pointflow = null;
|
|
// if (child.Leaf() instanceof PointFlow)
|
// {
|
// CameraPane.pointflow = (PointFlow) child.Leaf();
|
// }
|
|
/**/
|
if (deselect)
|
{
|
//group.deselectAll();
|
//freeze = true;
|
GetTree().clearSelection();
|
//freeze = false;
|
}
|
|
//group.addSelectee(child);
|
|
//refreshContents();
|
/**/
|
|
//new Exception().printStackTrace();
|
|
//jList.setSelectedIndex(group.children.indexOf(child));
|
javax.swing.tree.TreePath path;
|
|
if (raise)
|
{
|
path = child.Raise2Material().GetTreePath();
|
} else
|
{
|
path = child.GetTreePath();
|
}
|
|
if (GetTree().isPathSelected(path) && !CameraPane.movingcamera)
|
{
|
GetTree().removeSelectionPath(path);
|
} else
|
{
|
GetTree().addSelectionPath(path);
|
}
|
//GetTree().expandPath(path);
|
}
|
|
public void itemStateChanged(ItemEvent event)
|
{
|
// System.out.println("Propagate = " + propagate);
|
if (event.getSource() == propagateToggle)
|
{
|
propagate ^= true;
|
} else if (event.getSource() == multiplyToggle)
|
{
|
//copy.material.multiply ^= true;
|
//copy.selection.Multiply(multiply)
|
} else if (event.getSource() == toggleRenderItem)
|
{
|
cameraView.ToggleRender();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleDebugItem)
|
{
|
cameraView.ToggleDebug();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleFrustumItem)
|
{
|
cameraView.ToggleFrustum();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleFootContactItem)
|
{
|
cameraView.ToggleFootContact();
|
return;
|
} else if (event.getSource() == toggleLiveItem)
|
{
|
cameraView.ToggleLive();
|
return;
|
} else if (event.getSource() == toggleDLItem)
|
{
|
cameraView.ToggleDL();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleTextureItem)
|
{
|
cameraView.ToggleTexture();
|
// june 2013 copy.HardTouch();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleFullItem)
|
{
|
if (CameraPane.FULLSCREEN)
|
{
|
frame.getContentPane().remove(/*"Center",*/bigThree);
|
framePanel.add(bigThree);
|
frame.getContentPane().add(/*"Center",*/framePanel);
|
} else
|
{
|
frame.getContentPane().remove(/*"Center",*/framePanel);
|
frame.getContentPane().add(/*"Center",*/bigThree);
|
}
|
frame.validate();
|
cameraView.ToggleFullScreen();
|
|
return;
|
} else if (event.getSource() == toggleRandomItem)
|
{
|
cameraView.ToggleRandom();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleHandleItem)
|
{
|
cameraView.ToggleHandles();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == togglePaintItem)
|
{
|
cameraView.TogglePaint();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == toggleRootItem)
|
{
|
ToggleRoot();
|
return;
|
} else if (event.getSource() == animationItem)
|
{
|
ToggleAnimation();
|
return;
|
} else if (event.getSource() == flipVCB)
|
{
|
copy.flipV ^= true;
|
return;
|
} else if (event.getSource() == liveCB)
|
{
|
copy.live ^= true;
|
return;
|
} else if (event.getSource() == hideCB)
|
{
|
copy.hide ^= true;
|
copy.Touch(); // display list issue
|
objEditor.refreshContents();
|
return;
|
} else if (event.getSource() == link2masterCB)
|
{
|
copy.link2master ^= true;
|
return;
|
}
|
if (event.getSource() == randomCB)
|
{
|
copy.random ^= true;
|
return;
|
}
|
if (event.getSource() == speedupCB)
|
{
|
copy.speedup ^= true;
|
return;
|
}
|
if (event.getSource() == rewindCB)
|
{
|
copy.rewind ^= true;
|
return;
|
}
|
if (event.getSource() == markCB)
|
{
|
copy.SwitchMark();
|
|
objEditor.refreshContents();
|
return;
|
}
|
}
|
|
public void actionPerformed(ActionEvent event)
|
{
|
// SCRIPT DIALOG
|
if (event.getSource() == okbutton)
|
{
|
textpanel.setVisible(false);
|
textpanel.remove(textarea);
|
|
copy.scriptnode.scripttext = GetArea().getText();
|
|
copy.scriptnode.Reset();
|
|
textarea = null;
|
textpanel = null;
|
}
|
if (event.getSource() == cancelbutton)
|
{
|
textpanel.setVisible(false);
|
textpanel.remove(textarea);
|
|
textarea = null;
|
textpanel = null;
|
}
|
|
//applySelf();
|
//client.refreshEditWindow();
|
//refreshContents();
|
if (event.getSource() == nameField)
|
{
|
//System.out.println("ObjEditor " + event);
|
applySelf0(true);
|
//parent.applySelf();
|
objEditor.refreshContents();
|
} else if (event.getSource() == resetButton)
|
{
|
CameraPane.fullreset = true;
|
copy.Reset(); // ResetMeshes();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == stepItem)
|
{
|
cameraView.ONESTEP = true;
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == stepButton)
|
{
|
copy.Step();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == slowerButton)
|
{
|
copy.Slower();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == fasterButton)
|
{
|
copy.Faster();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == remarkButton)
|
{
|
copy.Remark();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == stepAllButton)
|
{
|
copy.StepAll();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else if (event.getSource() == resetAllButton)
|
{
|
//CameraPane.fullreset = true;
|
copy.ResetAll(); // ResetMeshes();
|
copy.Touch();
|
objEditor.refreshContents();
|
} else // if (event.getSource() == okButton)
|
// {
|
// System.out.println("Obj :: ok");
|
// applySelf();
|
// copy.deepCopySelf(client);
|
// ////client.refreshEditWindow();
|
// //client.closeEditWindow();
|
// Apply();
|
// Close();
|
// } else
|
// if (event.getSource() == applyButton)
|
// {
|
// System.out.println("Obj :: apply");
|
// applySelf();
|
// copy.deepCopySelf(client);
|
// //client.refreshEditWindow();
|
// Apply();
|
// } else
|
// if (event.getSource() == cancelButton)
|
// {
|
// System.out.println("Obj :: cancel");
|
// //applySelf();
|
// ////client.refreshEditWindow();
|
// //client.closeEditWindow();
|
// Close();
|
// }
|
// else
|
if (event.getSource() == resetSlidersButton)
|
{
|
ResetSliders();
|
} else if (event.getSource() == clearMaterialButton)
|
{
|
ClearMaterial();
|
} else if (event.getSource() == createMaterialButton)
|
{
|
CreateMaterial();
|
} else if (event.getSource() == clearPanelButton)
|
{
|
copy.ClearUI();
|
refreshContents(true);
|
} /*
|
}
|
|
public boolean action(Event event, Object arg)
|
{
|
*/ else if (event.getSource() == closeItem)
|
{
|
Close();
|
//return true;
|
} else if (event.getSource() == loadItem)
|
{
|
load();
|
//return true;
|
} else if (event.getSource() == saveItem)
|
{
|
save();
|
//return true;
|
} else if (event.getSource() == saveAsItem)
|
{
|
saveAs();
|
//return true;
|
} else if (event.getSource() == reexportItem)
|
{
|
reexport();
|
//return true;
|
} else if (event.getSource() == exportAsItem)
|
{
|
export();
|
//return true;
|
} else if (event.getSource() == povItem)
|
{
|
generatePOV();
|
//return true;
|
} else if (event.getSource() == zBufferItem)
|
{
|
try
|
{
|
System.out.println("Obj :: UI");
|
//MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
|
MetalLookAndFeel.setCurrentTheme(new Theme(Constants.beigeTheme));
|
UIManager.setLookAndFeel(new MetalLookAndFeel());
|
((JComponent) frame.getContentPane()).updateUI();
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
//return true;
|
} /*
|
if (event.getSource() == normalLensItem)
|
{
|
cameraView.renderCamera.focalLength = 1;
|
cameraView.repaint();
|
//return true;
|
}
|
*/ else if (event.getSource() == editCameraItem)
|
{
|
cameraView.ProtectCamera();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == revertCameraItem)
|
{
|
cameraView.RevertCamera();
|
cameraView.repaint();
|
return;
|
} else if (event.getSource() == textureButton)
|
{
|
return; // true;
|
} else // combos...
|
if (event.getSource() == texresMenu)
|
{
|
System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
|
copy.texres = texresMenu.getSelectedIndex();
|
return;
|
}
|
//else
|
{
|
//return super.actionPerformed(event); //, arg);
|
}
|
}
|
|
void ToggleAnimation()
|
{
|
if (!CameraPane.ANIMATION)
|
{
|
FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
CameraPane.filename = browser.getDirectory() + filename;
|
//CameraPane.framecount = 0;
|
CameraPane.imagecount = 0;
|
|
CameraPane.ANIMATION ^= true;
|
|
GrafreeD.wav.cursor = 0;
|
GrafreeD.wav.loop = 0;
|
}
|
} else
|
{
|
CameraPane.ANIMATION ^= true;
|
}
|
}
|
|
void ToggleRoot()
|
{
|
assert false;
|
}
|
|
void Close()
|
{
|
if (client.parent != null)
|
{
|
client.closeEditWindow();
|
callee.refreshContents();
|
} else
|
{
|
System.exit(0);
|
}
|
}
|
|
void Apply()
|
{
|
client.refreshEditWindow();
|
if (callee != null)
|
{
|
callee.refreshContents();
|
}
|
}
|
|
void ClearMaterial()
|
{
|
// copy??
|
copy.ClearMaterialS();
|
if (copy.selection.size() > 0)
|
//SetMaterial(copy);
|
{
|
SetMaterial(copy.selection.get(0));
|
}
|
copy.SoftTouch();
|
refreshContents(true);
|
}
|
|
void CreateMaterial()
|
{
|
//copy.ClearMaterial(); // PATCH
|
copy.CreateMaterialS(multiplyToggle.isSelected());
|
if (copy.selection.size() > 0)
|
//SetMaterial(copy);
|
{
|
SetMaterial(copy.selection.get(0));
|
}
|
|
copy.SoftTouch();
|
refreshContents(true);
|
}
|
|
void loadClipboard(boolean cut)
|
{
|
System.err.println("hmm...");
|
}
|
|
void ClearSelection(boolean all)
|
{
|
assert false;
|
}
|
|
void PrintMemory()
|
{
|
assert false;
|
}
|
|
void ResetTransform()
|
{
|
assert false;
|
}
|
|
void ResetTransform(int mask)
|
{
|
assert false;
|
}
|
|
void FlipTransform()
|
{
|
assert false;
|
}
|
|
void ReduceMesh(boolean onlyone)
|
{
|
assert false;
|
}
|
|
void ResetCentroid()
|
{
|
assert false;
|
}
|
|
void EditSelection()
|
{
|
}
|
|
void Recompile()
|
{
|
copy.ResetBlockLoop(); // temporary problem
|
|
boolean random = CameraPane.RANDOM;
|
CameraPane.RANDOM = false; // parse everything
|
copy.ResetDisplayList();
|
copy.HardTouch();
|
CameraPane.RANDOM = random;
|
}
|
|
// public void applySelf()
|
// {
|
// //System.out.println("Object :: applySelf");
|
// if(false) // copy instanceof Composite)
|
// {
|
// Composite group = (Composite) copy;
|
//
|
// if (group.selection.size() == 0)
|
// applySelf(false);
|
// else
|
// {
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// Object3D elem = (Object3D)group.selection.elementAt(i);
|
//
|
// Object3D keep = copy;
|
// copy = elem;
|
// holdon = i < group.selection.size() - 1;
|
// applySelf(false);
|
// holdon = false;
|
// copy = keep;
|
// }
|
// }
|
// }
|
// else
|
// applySelf(true);
|
// }
|
void applySelf0(boolean name)
|
{
|
if (name)
|
{
|
copy.name = nameField.getText();
|
if (frame != null)
|
{
|
frame.setTitle(copy.name); // + " (id=" + copy.displaylist + ")");
|
}
|
}
|
|
if (materialtouched)
|
{
|
//if (copy.material == null)
|
//copy.material = new cMaterial(copy.GetMaterial());
|
|
current.color = (float) colorField.getFloat();
|
current.modulation = (float) modulationField.getFloat();
|
current.metalness = (float) metalnessField.getFloat();
|
current.diffuse = (float) diffuseField.getFloat();
|
current.specular = (float) specularField.getFloat();
|
current.shininess = (float) shininessField.getFloat();
|
current.shift = (float) shiftField.getFloat();
|
current.ambient = (float) ambientField.getFloat();
|
current.lightarea = (float) lightareaField.getFloat();
|
current.factor = (float) diffusenessField.getFloat();
|
current.velvet = (float) velvetField.getFloat();
|
current.sheen = (float) sheenField.getFloat();
|
current.subsurface = (float) subsurfaceField.getFloat();
|
current.bump = (float) backlitField.getFloat();
|
current.aniso = (float) anisoField.getFloat();
|
current.anisoV = (float) anisoVField.getFloat();
|
current.cameralight = (float) cameraField.getFloat();
|
current.diffuseness = (float) selfshadowField.getFloat();
|
current.shadow = (float) shadowField.getFloat();
|
current.texture = (float) textureField.getFloat();
|
current.opacity = (float) opacityField.getFloat();
|
current.fakedepth = (float) fakedepthField.getFloat();
|
current.shadowbias = (float) shadowbiasField.getFloat();
|
|
if (!NumberSlider.frozen)
|
{
|
//System.out.println("Propagate = " + propagate);
|
copy.UpdateMaterial(anchor, current, propagate);
|
if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
|
{
|
copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
|
copy.projectedVertices[0].y = (int) (noiseField.getFloat() * 1000);
|
if (copy.projectedVertices.length > 1)
|
{
|
copy.projectedVertices[1].x = (int) (borderfadeField.getFloat() * 1000);
|
copy.projectedVertices[1].y = (int) (fogField.getFloat() * 1000);
|
if (copy.projectedVertices.length > 2)
|
{
|
copy.projectedVertices[2].x = (int) (powerField.getFloat() * 1000);
|
copy.projectedVertices[2].y = (int) (opacityPowerField.getFloat() * 1000);
|
}
|
}
|
}
|
}
|
|
if (!holdon)
|
{
|
anchor.Set(current);
|
}
|
}
|
|
copy.SoftTouch();
|
copy.ResetTransparency();
|
//copy.Touch();
|
}
|
|
public void stateChanged(ChangeEvent e)
|
{
|
// assert(false);
|
|
if (freezematerial)
|
{
|
return;
|
}
|
|
if (e.getSource() == fogdensityField
|
|| e.getSource() == fogintensityField
|
|| e.getSource() == elevationField
|
|| e.getSource() == focusField
|
|| e.getSource() == apertureField
|
|| e.getSource() == shadowblurField)
|
{
|
System.exit(0);
|
cameraView.options1[0] = (float) focusField.getFloat() * 10;
|
cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
|
cameraView.options1[2] = (float) shadowblurField.getFloat();
|
cameraView.options2[0] = (float) fogdensityField.getFloat() / 100;
|
cameraView.options2[1] = (float) fogintensityField.getFloat() / 25;
|
cameraView.options2[2] = (float) elevationField.getFloat() / 100;
|
|
//System.out.println("Focus = " + cameraView.options1[0]);
|
//System.out.println("Aperture = " + cameraView.options1[1]);
|
//System.out.println("ShadowBlur = " + cameraView.options1[2]);
|
//System.out.println("Fog = " + cameraView.options2[0]);
|
//System.out.println("Intensity = " + cameraView.options2[1]);
|
//System.out.println("Elevation = " + cameraView.options2[2]);
|
|
cameraView.repaint();
|
} else
|
//if (e.getSource() == diffuseField ||
|
{
|
//System.out.println("stateChanged = " + this);
|
materialtouched = true;
|
applySelf();
|
//System.out.println("this = " + this);
|
//System.out.println("PARENT = " + parent);
|
//if (parent != null)
|
// parent.applySelf();
|
refreshContents();
|
// ??? client.refreshEditWindow();
|
}
|
//else
|
//super.stateChanged(e);
|
}
|
|
public void applySelf()
|
{
|
//group.name = nameField.getText();
|
//objEditor.applySelf();
|
|
assert (objEditor == this);
|
if (copy.selection == null || copy.selection.size() == 0)
|
//super.applySelf()
|
; else
|
{
|
for (int i = 0; i < copy.selection.size(); i++)
|
{
|
Object3D elem = (Object3D) copy.selection.elementAt(i);
|
|
Object3D keep = objEditor.copy;
|
objEditor.holdon = i < copy.selection.size() - 1;
|
objEditor.copy = elem;
|
try
|
{
|
objEditor.applySelf0(false);
|
} catch (Error e)
|
{
|
System.out.println("PROTECTED CRASH");
|
e.printStackTrace();
|
}
|
objEditor.holdon = false;
|
objEditor.copy = keep;
|
}
|
}
|
}
|
|
void SnapObject()
|
{
|
Object3D obj = (Object3D)copy.selection.elementAt(0);
|
SnapObject(obj);
|
}
|
|
void SnapObject(Object3D obj)
|
{
|
Object3D point = CameraPane.selectedpoint;
|
|
cVector v = new cVector();
|
point.TransformToWorld(v);
|
obj.TransformToLocal(v);
|
|
//LA.xformPos(v, point.toParent);
|
//LA.xformPos(v, obj.fromParent);
|
|
// System.err.println("v = " + v);
|
|
if (obj.toParent == null)
|
{
|
obj.toParent = LA.newMatrix();
|
obj.fromParent = LA.newMatrix();
|
}
|
|
double[][] mat = LA.newMatrix();
|
|
double vertical = v.y;
|
|
//vertical = 0;
|
|
LA.matTranslate(mat, v.x, vertical, v.z);
|
LA.matConcat(obj.toParent, mat, obj.toParent);
|
LA.matIdentity(mat);
|
LA.matTranslate(mat, -v.x, -vertical, -v.z);
|
LA.matConcat(mat, obj.fromParent, obj.fromParent);
|
|
refreshContents();
|
}
|
|
void ScreenFit()
|
{
|
if (false) // copy instanceof Composite)
|
{
|
Composite group = (Composite) copy;
|
|
if (group.selection.size() == 0)
|
{
|
ScreenFit();
|
return;
|
}
|
|
Object3D obj = group.selection.elementAt(0);
|
ScreenFit(obj, false);
|
} else
|
{
|
ScreenFit(copy, false);
|
}
|
}
|
static cVector interest = new cVector();
|
static cVector centroid = new cVector();
|
|
void ScreenFit(Object3D obj, boolean shadowonly)
|
{
|
//cVector origin = new cVector(0,0,0);
|
// cVector minima = new cVector();
|
// cVector maxima = new cVector();
|
// // try
|
// {
|
// obj.getBounds(minima, maxima, true);
|
// }
|
// // catch(Exception e)
|
// //{
|
// // e.printStackTrace();
|
// //}
|
// //cVector interest = new cVector(0,0,0);
|
// cVector interest = new cVector((minima.x+maxima.x)/2,
|
// (minima.y+maxima.y)/2,
|
// (minima.z+maxima.z)/2);
|
//
|
// // crash protection
|
// if (Double.isNaN(interest.x))
|
// return;
|
|
boolean success = obj.getCentroid(centroid); // sept 2014, true);
|
|
if (!success)
|
//new Exception().printStackTrace();
|
{
|
System.err.println("NO CENTROID FOR : " + obj);
|
}
|
|
if (Double.isNaN(centroid.x))
|
{
|
System.err.println("interestBUG : " + centroid);
|
return;
|
}
|
|
// CameraPane.selectedpoint.toParent[3][0] = centroid.x;
|
// CameraPane.selectedpoint.toParent[3][1] = centroid.y;
|
// CameraPane.selectedpoint.toParent[3][2] = centroid.z;
|
|
// System.out.println("ScreenFit : " + this);
|
// System.out.println("obj : " + obj);
|
if (!CameraPane.TRACK)
|
{
|
// System.out.println("centroid : " + centroid);
|
}
|
// System.out.println("minima : " + minima);
|
// System.out.println("maxima : " + maxima);
|
|
interest.set(centroid); // aout 2013
|
|
double height = interest.y;
|
|
if (obj.parent != null)
|
{
|
obj.parent.TransformToWorld(interest);
|
}
|
|
if (!CameraPane.TRACK)
|
{
|
// System.out.println("interest : " + interest);
|
}
|
//if (event.getSource() == lookAtItem)
|
{
|
/*
|
cVector delta = new cVector();
|
// manipCamera?
|
delta.set(cameraView.renderCamera.location);
|
delta.add(interest);
|
delta.sub(cameraView.renderCamera.lookAt);
|
cameraView.renderCamera.setLocation(delta);
|
*/
|
|
if (height != 0)
|
{
|
double k = 1; // 0.1;
|
|
interest.y = k * interest.y + (1 - k) * height;
|
}
|
|
CameraPane.zoomonce = true;
|
|
// june 2014
|
Camera parentcam = cameraView.manipCamera;
|
|
if (cameraView.manipCamera == cameraView.cameras[0])
|
{
|
parentcam = cameraView.cameras[1];
|
}
|
|
if (cameraView.manipCamera == cameraView.cameras[1])
|
{
|
parentcam = cameraView.cameras[0];
|
}
|
|
|
//assert (parentcam != manipCamera);
|
if (parentcam == cameraView.manipCamera) // probably the light
|
return;
|
|
cameraView.lightLookAt.set(interest);
|
|
if (!shadowonly)
|
{
|
for (int count = parentcam.GetTransformCount(); --count>=0;)
|
LA.xformPos(interest, parentcam.toParent, interest);
|
|
cameraView.targetLookAt.set(interest);
|
}
|
|
cameraView.pingthread.StepToTarget(false); // fev 2014
|
/*
|
delta.set(topView.renderCamera.location);
|
delta.add(interest);
|
delta.sub(topView.renderCamera.lookAt);
|
topView.renderCamera.setLocation(delta);
|
delta.set(frontView.renderCamera.location);
|
delta.add(interest);
|
delta.sub(frontView.renderCamera.lookAt);
|
frontView.renderCamera.setLocation(delta);
|
delta.set(sideView.renderCamera.location);
|
delta.add(interest);
|
delta.sub(sideView.renderCamera.lookAt);
|
sideView.renderCamera.setLocation(delta);
|
*/
|
|
//cameraView.renderCamera.setFocus(interest);
|
//topView.renderCamera.setFocus(interest);
|
//frontView.renderCamera.setFocus(interest);
|
//sideView.renderCamera.setFocus(interest);
|
}
|
//else
|
// cameraView.renderCamera.setLocation(interest);
|
cameraView.renderCamera.computeTransform();
|
topView.renderCamera.computeTransform();
|
frontView.renderCamera.computeTransform();
|
sideView.renderCamera.computeTransform();
|
}
|
|
void ScreenFit0(Object3D obj, boolean shadowonly)
|
{
|
ScreenFit(obj, shadowonly);
|
cameraView.repaint();
|
topView.repaint();
|
frontView.repaint();
|
sideView.repaint();
|
}
|
|
void ScreenFitPoint()
|
{
|
Object3D obj = CameraPane.selectedpoint;
|
|
objEditor.ScreenFit(obj, false);
|
|
cameraView.pingthread.StepToTarget(true); // aout 2013
|
refreshContents();
|
}
|
|
void refreshContents()
|
{
|
refreshContents(false);
|
}
|
|
void refreshContents(boolean cp)
|
{
|
//System.out.println("REPAINT : " + this);
|
if (topView == null)
|
{
|
new Exception().printStackTrace();
|
return;
|
}
|
topView.repaint();
|
frontView.repaint();
|
sideView.repaint();
|
cameraView.repaint();
|
|
/* Balloons? */
|
|
if (cp)
|
{
|
if (GetTree() != null)
|
{
|
GetTree().repaint();
|
}
|
|
radioPanel.revalidate();
|
radioPanel.repaint();
|
ctrlPanel.revalidate(); // ? new
|
ctrlPanel.repaint();
|
}
|
}
|
|
static TweenManager tweenManager = new TweenManager();
|
|
void makeSomething(Object3D thing, boolean resetmodel) // deselect)
|
{
|
//Tween.set(thing, 0).target(1).start(tweenManager);
|
//Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
|
// if (thing instanceof GenericJointDemo)
|
// Tween.to(thing, 0, 100)
|
// .target(0, 0, -50)
|
// .ease(Linear.INOUT)
|
// //.delay(1000)
|
// //.repeat(2, 200)
|
// .start(tweenManager);
|
// assert(copy instanceof Composite);
|
/*Composite*/ Object3D group = /*(Composite)*/ copy;
|
|
// if (group.name.equals("TEMP"))
|
// {
|
// if (!(group.get(0) instanceof Composite))
|
// {
|
// System.out.println("NO GROUP TO ADD " + thing);
|
// return;
|
// }
|
//
|
// group = (Composite) group.get(0);
|
// }
|
|
System.out.println("makeSomething of " + thing);
|
|
/*
|
if (deselect && jList != null)
|
{
|
int indices[] = jList.getSelectedIndices();
|
for (int i = indices.length - 1; i >= 0; i--)
|
{
|
//objList.deselect(indices[i]);
|
Object3D obj = (Object3D)group.children.elementAt(indices[i]);
|
group.removeSelectee(obj);
|
}
|
}
|
/**/
|
|
if (false) // group.parent == null)
|
{
|
group.addChild(thing);
|
} else
|
{
|
if (true) // ?? group.parent != null)
|
{
|
/*
|
Composite tmp = new cGroup();
|
if(group.parent != null)
|
LA.matCopy(group.parent.GlobalTransform(), tmp.fromParent);
|
if(!LA.isIdentity(tmp.fromParent))
|
{
|
LA.matInvert(tmp.fromParent, tmp.toParent);
|
group.addChild(tmp);
|
tmp.addChild(thing);
|
}
|
else
|
group.addChild(thing);
|
*/
|
if (false) // why??
|
// !LA.isIdentity(group.GlobalTransform()))
|
{
|
Composite tmp = new cGroup();
|
tmp.toParent = LA.newMatrix();
|
tmp.fromParent = LA.newMatrix();
|
LA.matCopy(group.GlobalTransform(), tmp.toParent);
|
LA.matInvert(tmp.toParent, tmp.fromParent);
|
tmp.addChild(thing);
|
group.addChild(tmp);
|
} else
|
{
|
group.addChild(thing);
|
}
|
} else
|
{
|
group.addChild(thing);
|
}
|
}
|
//group.addSelectee(thing);
|
//int index = objList.getItemCount();
|
//objList.add(thing.name);
|
//objList.select(index);
|
//group.refreshEditWindow();
|
if (resetmodel)
|
{
|
ResetModel();
|
Select(thing.GetTreePath(), true, false); // unselect... false);
|
refreshContents();
|
}
|
|
//if ((thing instanceof CSG))
|
// objEditor.EditSelection();
|
}
|
|
void ResetModel()
|
{
|
//assert(copy instanceof Composite);
|
Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
|
|
// necessary? group.selection = new Object3D(); // java.util.Vector();
|
|
//new Exception().printStackTrace();
|
freezemodel = true;
|
GetTree().setModel(new cTreeModel(group));
|
GetTree().setCellRenderer(new cTreeModel.Renderer());
|
//group.refreshEditWindow();
|
//refreshContents();
|
|
if (copy.selection == null)
|
{
|
copy.selection = new Object3D();
|
}
|
|
for (int j = 0; j < copy.selection.size(); j++)
|
{
|
Object3D item = copy.selection.get(j);
|
|
if (item instanceof cGroup && ((cGroup) item).transientlink)
|
{
|
item = ((cGroup) item).get(0);
|
}
|
|
if (item.count <= 1) // ??? == 0)
|
{
|
copy.selection.remove(item);
|
}
|
}
|
|
boolean first = true;
|
|
for (int i = copy.selection.size(); --i >= 0;)
|
{
|
Object3D item = copy.selection.get(i);
|
|
if (item instanceof cGroup && ((cGroup) item).transientlink)
|
{
|
item = ((cGroup) item).get(0);
|
}
|
|
Select(item.GetTreePath(), first, false);
|
first = false;
|
}
|
|
freezemodel = false;
|
}
|
|
/*
|
void ResetModel()
|
{
|
assert false;
|
}
|
*/
|
class LoadGFDThread extends Thread
|
{
|
//String filename;
|
//iCallBack callback;
|
|
java.util.Stack stack;
|
|
LoadGFDThread(/*String fullname, iCallBack cb*/)
|
{
|
//filename = fullname;
|
//callback = cb;
|
stack = new java.util.Stack();
|
}
|
|
void add(String filename, iCallBack cb)
|
{
|
stack.push(filename);
|
stack.push(cb);
|
}
|
|
public void run()
|
{
|
boolean wasbusy = false;
|
|
for (;;)
|
{
|
try
|
{
|
sleep(10);
|
} catch (Exception e)
|
{
|
};
|
if (!stack.empty())
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
iCallBack callback = (iCallBack) stack.pop();
|
String filename = (String) stack.pop();
|
System.out.println(" ------- ------- ------ ------ ----- LOADING2... " + filename);
|
callback.Callback(ReadGFD(filename));
|
System.gc();
|
wasbusy = true;
|
} else
|
{
|
if (wasbusy)
|
{
|
frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
wasbusy = false;
|
}
|
}
|
}
|
}
|
}
|
LoadGFDThread loadGFDThread;
|
|
void ReadGFD(String fullname, iCallBack cb)
|
{
|
if (loadGFDThread == null)
|
{
|
loadGFDThread = new LoadGFDThread(/*fullname, cb*/);
|
loadGFDThread.start();
|
}
|
|
loadGFDThread.add(fullname, cb);
|
}
|
|
static Object3D ReadGFD(String fullname)
|
{
|
Object3D readobj = null;
|
|
try
|
{
|
java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
|
java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
|
|
readobj = (Object3D) p.readObject();
|
istream.close();
|
|
readobj.ResetDisplayList();
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
// catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
|
// catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
|
// catch(ClassNotFoundException e) { System.out.println("ClassNotFoundException"); e.printStackTrace(); }
|
// catch(ClassCastException e) {}
|
|
return readobj;
|
}
|
|
static Object3D ReadGFDz(String fullname)
|
{
|
Object3D readobj = null;
|
|
try
|
{
|
java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
|
java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
|
java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
|
|
readobj = (Object3D) p.readObject();
|
|
istream.close();
|
zstream.close();
|
|
readobj.ResetDisplayList();
|
} catch (java.io.StreamCorruptedException e)
|
{
|
e.printStackTrace();
|
} catch (java.io.IOException e)
|
{
|
System.out.println("IOexception");
|
e.printStackTrace();
|
} catch (ClassNotFoundException e)
|
{
|
System.out.println("ClassNotFoundException");
|
e.printStackTrace();
|
} catch (ClassCastException e)
|
{
|
}
|
|
return readobj;
|
}
|
|
void LoadIt(Object obj)
|
{
|
System.out.println("Loaded " + obj);
|
//new Exception().printStackTrace();
|
Object3D readobj = (Object3D) obj;
|
|
// may 2014
|
readobj.RepairTexture(); // Serialization issue
|
|
if (readobj != null)
|
{
|
try
|
{
|
//readobj.deepCopySelf(copy);
|
copy.clear(); // june 2014
|
for (int i = 0; i < readobj.size(); i++)
|
{
|
Object3D child = readobj.get(i); // reserve(i);
|
// if (child == null)
|
// continue;
|
if (true) // child instanceof Composite)
|
{
|
//Composite cams = (Composite) child;
|
Object3D cams = (Object3D) child;
|
if (!(cams instanceof FileObject) /*&& cams.count > 0 ZEROCOUNT*/ && cams.size() > 0 && cams.get(0) instanceof Camera)
|
{
|
System.out.println("UPDATE CAMS");
|
// patch
|
// june 2014 for (int j = 0; j < 5; j++)
|
// {
|
// Object3D cam = cams.get(j);
|
// // oct 2012 if(cam.parent == null)
|
// cam.parent = copy.get(0); // cams;
|
// }
|
cameraView.SetCamera((Camera) cams.get(0));
|
// MAJOR CRASH!!
|
cameraView.SetLight((Camera) cams.get(4));
|
topView.SetCamera((Camera) cams.get(1));
|
frontView.SetCamera((Camera) cams.get(2));
|
sideView.SetCamera((Camera) cams.get(3));
|
|
// copy.get(0).clear();
|
// copy.get(0).addAll(cams);
|
|
//readobj.release(i);
|
// continue;
|
}
|
}
|
child.parent = null;
|
(/*(Composite)*/copy).addChild(child);
|
|
// readobj.release(i);
|
}
|
} catch (ClassCastException e)
|
{
|
assert (false);
|
Composite c = (Composite) copy;
|
c.children.clear();
|
CSG csg = new CSG();
|
Object3D /*Composite*/ parent = copy.parent;
|
readobj.deepCopySelf(csg);
|
copy.parent = parent;
|
c.addChild(csg);
|
}
|
|
ResetModel();
|
copy.HardTouch(); // recompile?
|
refreshContents();
|
}
|
}
|
|
void load() // throws ClassNotFoundException
|
{
|
if (GrafreeD.standAlone)
|
{
|
FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
copy.ClearUI();
|
copy.clear(); // force
|
|
lastname = browser.getDirectory() + filename;
|
/*Object3D readobj =*/ ReadGFD(lastname, new iCallBack()
|
{
|
|
public void Callback(Object obj)
|
{
|
LoadIt(obj);
|
}
|
|
public void DragGesture()
|
{
|
}
|
});
|
/*
|
try
|
{
|
FileInputStream istream = new FileInputStream(lastname);
|
ObjectInputStream p = new ObjectInputStream(istream);
|
|
readobj = (Object3D) p.readObject();
|
istream.close();
|
|
readobj.Reset();
|
|
Composite parent = client.parent;
|
|
//System.out.println("read obj = " + readobj);
|
readobj.deepCopySelf(copy);
|
//System.out.println("local obj = " + copy);
|
//client = copy = readobj;
|
//client.editWindow = this;
|
//client.parent = parent;
|
//Apply();
|
|
ResetModel();
|
refreshContents();
|
}
|
catch(IOException e) { e.printStackTrace(); }
|
catch(ClassNotFoundException e) { e.printStackTrace(); }
|
catch(ClassCastException e)
|
*/
|
|
/*
|
try
|
{
|
readobj.deepCopySelf(copy);
|
}
|
catch(ClassCastException e)
|
{
|
Composite c = (Composite) copy;
|
c.children.clear();
|
CSG csg = new CSG();
|
Composite parent = copy.parent;
|
readobj.deepCopySelf(csg);
|
copy.parent = parent;
|
c.addChild(csg);
|
}
|
ResetModel();
|
refreshContents();
|
*/
|
}
|
} else
|
{
|
//new TextFrame(buffer.toString());
|
}
|
}
|
|
void save()
|
{
|
if (lastname == null)
|
{
|
return;
|
}
|
|
try
|
{
|
FileOutputStream ostream = new FileOutputStream(lastname);
|
ObjectOutputStream p = new ObjectOutputStream(ostream);
|
|
p.writeObject(copy);
|
p.flush();
|
|
ostream.close();
|
|
//FileOutputStream fos = new FileOutputStream(fullname);
|
//PrintStream ps = new PrintStream(fos);
|
//ps.print(buffer.toString());
|
} catch (IOException e)
|
{
|
}
|
}
|
String lastname;
|
|
void saveAs()
|
{
|
if (GrafreeD.standAlone)
|
{
|
FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
|
browser.setVisible(true);
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
lastname = browser.getDirectory() + filename;
|
save();
|
}
|
} else
|
{
|
//new TextFrame(buffer.toString());
|
}
|
}
|
|
void reexport()
|
{
|
if (copy.selection.size() == 0)
|
return;
|
|
Object3D object = copy.selection.get(0);
|
|
FileObject fileobj = null;
|
|
if (object instanceof FileObject)
|
fileobj = (FileObject)object;
|
|
if (object.fileparent != null)
|
{
|
assert(fileobj == null);
|
|
fileobj = (FileObject) object.fileparent;
|
}
|
|
if (fileobj != null)
|
{
|
System.out.println("WriteObject " + object + " : " + fileobj.name);
|
WriteObject(object, fileobj.name);
|
}
|
}
|
|
void export()
|
{
|
if (copy.selection.size() == 0)
|
return;
|
|
if (copy.selection.get(0) instanceof Mocap)
|
{
|
// Export Motion Capture
|
FileDialog browser = new FileDialog(frame, "Export Motion", FileDialog.SAVE);
|
browser.setVisible(true);
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
if (!filename.endsWith(".bvh"))
|
{
|
filename += ".bvh";
|
}
|
|
try
|
{
|
FileOutputStream ostream = new FileOutputStream(browser.getDirectory() + filename);
|
OutputStreamWriter writer = new OutputStreamWriter(ostream);
|
|
writer.write(MocapHeader.header);
|
copy.selection.get(0).WriteTo(writer);
|
writer.flush();
|
|
writer.close();
|
ostream.close();
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
|
}
|
}
|
else
|
//if (GrafreeD.standAlone)
|
{
|
FileDialog browser = new FileDialog(frame, "Export", FileDialog.SAVE);
|
browser.setVisible(true);
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
if (!filename.endsWith(".gfd"))
|
{
|
filename += ".gfd";
|
}
|
//lastname = browser.getDirectory() + filename;
|
//save();
|
WriteObject(copy.selection.get(0), browser.getDirectory() + filename);
|
}
|
// } else
|
// {
|
// //new TextFrame(buffer.toString());
|
}
|
}
|
|
void WriteObject(Object3D obj, String filename)
|
{
|
try
|
{
|
FileOutputStream ostream = new FileOutputStream(filename);
|
// ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
|
ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
|
|
Object3D objectparent = obj.parent;
|
obj.parent = null;
|
|
Object3D object = (Object3D) GrafreeD.clone(obj);
|
|
obj.parent = objectparent;
|
|
//Object3D parent = object.parent;
|
|
object.parent = null;
|
// OK... object.Stripify();
|
|
p.writeObject(object);
|
p.flush();
|
|
ostream.close();
|
// zstream.close();
|
|
// group.selection.get(0).parent = parent;
|
//FileOutputStream fos = new FileOutputStream(fullname);
|
//PrintStream ps = new PrintStream(fos);
|
//ps.print(buffer.toString());
|
} catch (IOException e)
|
{
|
}
|
}
|
|
void generatePOV()
|
{
|
StringBuffer buffer = new StringBuffer(5000);
|
Rectangle bnds = cameraView.getBounds();
|
buffer.append("#default {\n texture {\n");
|
buffer.append(" pigment { color rgb <1,1,1> }\n");
|
buffer.append(" finish { ambient 0.2 diffuse 0.6 phong 0.2 } } }\n\n");
|
buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
|
cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
|
copy.generatePOV(buffer);
|
if (GrafreeD.standAlone)
|
{
|
FileDialog browser = new FileDialog(frame, "Export POV", 1);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
String fullname = browser.getDirectory() + filename;
|
try
|
{
|
FileOutputStream fos = new FileOutputStream(fullname);
|
PrintStream ps = new PrintStream(fos);
|
ps.print(buffer.toString());
|
} catch (IOException e)
|
{
|
}
|
}
|
} else
|
{
|
new TextFrame(buffer.toString());
|
}
|
}
|
|
Object3D client;
|
Object3D copy;
|
MenuBar menuBar;
|
Menu windowMenu;
|
MenuItem loadItem;
|
MenuItem saveItem;
|
MenuItem saveAsItem;
|
MenuItem exportAsItem;
|
MenuItem reexportItem;
|
MenuItem povItem;
|
MenuItem closeItem;
|
Menu cameraMenu;
|
CheckboxMenuItem zBufferItem;
|
//MenuItem normalLensItem;
|
MenuItem editCameraItem;
|
MenuItem revertCameraItem;
|
CheckboxMenuItem toggleLiveItem;
|
MenuItem stepItem;
|
CheckboxMenuItem toggleFullItem;
|
CheckboxMenuItem toggleRenderItem;
|
CheckboxMenuItem toggleDebugItem;
|
CheckboxMenuItem toggleFrustumItem;
|
CheckboxMenuItem toggleFootContactItem;
|
CheckboxMenuItem toggleDLItem;
|
CheckboxMenuItem toggleTextureItem;
|
CheckboxMenuItem toggleRandomItem;
|
CheckboxMenuItem toggleRootItem;
|
CheckboxMenuItem animationItem;
|
CheckboxMenuItem toggleHandleItem;
|
CheckboxMenuItem togglePaintItem;
|
JSplitPane mainPanel;
|
JScrollPane scrollpane;
|
JPanel toolbarPanel;
|
JPanel treePanel;
|
JPanel radioPanel;
|
ButtonGroup buttonGroup;
|
JPanel ctrlPanel;
|
JPanel materialPanel;
|
JScrollPane infoPanel;
|
JPanel optionsPanel;
|
JTabbedPane objectPanel;
|
JPanel XYZPanel;
|
JSplitPane gridPanel;
|
JSplitPane bigPanel;
|
JPanel bigThree;
|
JTabbedPane jtp;
|
JPanel cameraPanel;
|
JSplitPane framePanel;
|
JTextArea/*Field*/ nameField;
|
cButton textureButton;
|
cButton okButton;
|
cButton applyButton;
|
cButton cancelButton;
|
cButton resetSlidersButton;
|
cButton clearMaterialButton;
|
cButton createMaterialButton;
|
cCheckBox propagateToggle;
|
cCheckBox multiplyToggle;
|
cButton clearPanelButton;
|
//CameraScroller topScroll;
|
//CameraScroller frontScroll;
|
//CameraScroller sideScroll;
|
CameraPane topView;
|
CameraPane frontView;
|
CameraPane sideView;
|
CameraPane cameraView;
|
// GLCanvas worldView;
|
int labelHeight;
|
int textHeight;
|
int buttonHeight;
|
int widgetPos;
|
static final int panelWidth = 200;
|
static final int panelMargin = 5;
|
static final int itemWidth = 190;
|
boolean materialtouched = false;
|
boolean propagate = true;
|
boolean freezematerial = false;
|
boolean freezemodel = false;
|
boolean holdon = false; // multiple selection
|
cMaterial anchor = new cMaterial(1);
|
cMaterial current = new cMaterial();
|
JLabel fogdensityLabel;
|
NumberSlider fogdensityField;
|
JLabel fogintensityLabel;
|
NumberSlider fogintensityField;
|
JLabel elevationLabel;
|
NumberSlider elevationField;
|
JLabel focusLabel;
|
NumberSlider focusField;
|
JLabel apertureLabel;
|
NumberSlider apertureField;
|
JLabel shadowblurLabel;
|
NumberSlider shadowblurField;
|
// MATERIAL
|
JLabel materialLabel;
|
JLabel colorLabel;
|
NumberSlider colorField;
|
JLabel modulationLabel;
|
NumberSlider modulationField;
|
JLabel metalnessLabel;
|
NumberSlider metalnessField;
|
JLabel diffuseLabel;
|
NumberSlider diffuseField;
|
JLabel specularLabel;
|
NumberSlider specularField;
|
JLabel shininessLabel;
|
NumberSlider shininessField;
|
JLabel shiftLabel;
|
NumberSlider shiftField;
|
JLabel ambientLabel;
|
NumberSlider ambientField;
|
JLabel lightareaLabel;
|
NumberSlider lightareaField;
|
JLabel diffusenessLabel;
|
NumberSlider diffusenessField;
|
JLabel velvetLabel;
|
NumberSlider velvetField;
|
JLabel sheenLabel;
|
NumberSlider sheenField;
|
JLabel subsurfaceLabel;
|
NumberSlider subsurfaceField;
|
//JLabel bumpLabel;
|
//NumberSlider bumpField;
|
JLabel backlitLabel;
|
NumberSlider backlitField;
|
JLabel anisoLabel;
|
NumberSlider anisoField;
|
JLabel anisoVLabel;
|
NumberSlider anisoVField;
|
JLabel cameraLabel;
|
NumberSlider cameraField;
|
JLabel selfshadowLabel;
|
NumberSlider selfshadowField;
|
JLabel shadowLabel;
|
NumberSlider shadowField;
|
JLabel textureLabel;
|
NumberSlider textureField;
|
JLabel opacityLabel;
|
NumberSlider opacityField;
|
JLabel fakedepthLabel;
|
NumberSlider fakedepthField;
|
JLabel shadowbiasLabel;
|
NumberSlider shadowbiasField;
|
JLabel bumpLabel;
|
NumberSlider bumpField;
|
JLabel noiseLabel;
|
NumberSlider noiseField;
|
JLabel powerLabel;
|
NumberSlider powerField;
|
JLabel borderfadeLabel;
|
NumberSlider borderfadeField;
|
JLabel fogLabel;
|
NumberSlider fogField;
|
JLabel opacityPowerLabel;
|
NumberSlider opacityPowerField;
|
JTree jTree;
|
//ObjectUI parent;
|
}
|