import java.awt.*;
|
import java.awt.event.*;
|
import java.awt.dnd.*;
|
import javax.swing.*;
|
import javax.swing.event.*;
|
import javax.swing.tree.*;
|
import java.util.Enumeration;
|
import java.util.Vector;
|
|
import java.awt.datatransfer.*;
|
|
import com.jme.math.Vector3f;
|
import com.jme.renderer.ColorRGBA;
|
|
//import buoy.widget.BFileChooser;
|
|
class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
|
ObjectUI,
|
Runnable,
|
ActionListener,
|
TreeSelectionListener,
|
DragGestureListener, DragSourceListener, DropTargetListener,
|
ItemListener // ListSelectionListener
|
{
|
//ObjEditor objEditor;
|
public void closeUI2()
|
{
|
ObjEditor oe = GetEditor();
|
|
//nameField.removeActionListener(this);
|
//oe.ctrlPanel.remove(nameField);
|
oe.closeUI();
|
}
|
|
public ObjEditor GetEditor2()
|
{
|
return objEditor; //.GetEditor();
|
}
|
|
/*
|
GroupEditor(Composite group, Object3D copy, GroupEditor callee)
|
{
|
super(group, copy, callee);
|
this.group = (Composite) copy;
|
//selectees = this.group.selectees;
|
|
SetupMenu2();
|
SetupUI2();
|
super.SetupUI(true);
|
SetupViews();
|
}
|
*/
|
|
GroupEditor(Object3D group, GroupEditor callee, boolean ui)
|
{
|
super(group, callee);
|
objEditor = callee.GetEditor();
|
|
this.copy = this.group = group;
|
//selectees = this.group.selectees;
|
|
if(ui)
|
SetupUI(objEditor);
|
}
|
|
GroupEditor(Object3D group, Object3D copy, GroupEditor callee)
|
{
|
//super(group, copy, callee);
|
super(group, copy, null, callee);
|
objEditor = this;
|
//objEditor = new ObjEditor(group, copy, null, callee);
|
|
this.copy = this.group = copy;
|
//selectees = this.group.selectees;
|
|
SetupMenu2(objEditor);
|
SetupUI2(objEditor);
|
objEditor.SetupUI(true);
|
SetupViews(objEditor);
|
|
((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
|
}
|
|
void CloneSelection(boolean supports)
|
{
|
// Object3D keep = GrafreeD.clipboard;
|
//Object3D obj;
|
for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
//obj = (Object3D)e.nextElement();
|
Object3D obj = group.selection.get(i);
|
Object3D clone = CloneObject(obj, supports);
|
|
makeSomething(clone, i==group.selection.size()-1);
|
}
|
}
|
|
void CloneClipboard(boolean supports)
|
{
|
assert(GrafreeD.clipboard.parent == null);
|
Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
|
GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
|
if (LA.isIdentity(GrafreeD.clipboard.toParent))
|
makeSomething(CloneObject(GrafreeD.clipboard.get(0), false));
|
else
|
makeSomething(CloneObject(GrafreeD.clipboard, false));
|
GrafreeD.clipboard.get(0).parent = keepparent;
|
}
|
|
static Object3D CloneObject(Object3D obj, boolean supports)
|
{
|
if (obj instanceof FileObject)
|
obj = obj.GetObject();
|
|
Object3D parent = obj.parent;
|
obj.parent = null;
|
// Object3D support = obj.support;
|
// obj.support = null;
|
if (!supports)
|
obj.SaveSupports();
|
Object3D clone = (Object3D)GrafreeD.clone(obj);
|
obj.parent = parent;
|
// obj.support = support;
|
// clone.support = support; // aout 2013
|
if (!supports)
|
obj.RestoreSupports();
|
clone.ResetDisplayList();
|
return clone;
|
}
|
|
void SetupUI(ObjEditor oe)
|
{
|
super.SetupUI2(oe);
|
|
/*
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridx = 0;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = ObjEditor.GRIDWIDTH+1;
|
oe.ctrlPanel.add(nameField = new JTextField(group.name), oe.aConstraints);
|
nameField.addActionListener(this);
|
oe.aConstraints.gridy += 1;
|
oe.aConstraints.gridwidth = 1;
|
*/
|
|
}
|
|
//JTextField nameField;
|
|
void SetupMenu2(ObjEditor oe)
|
{
|
oe.cameraMenu.add(lookAtItem = new MenuItem("Set Interest"));
|
//cameraMenu.add(lookFromItem = new MenuItem("Look From Selection"));
|
//cameraMenu.add(switchItem = new MenuItem("Reverse View"));
|
editLeafItem = oe.cameraMenu.add(new MenuItem("Edit Leaf"));
|
oe.cameraMenu.add("-");
|
openWindowItem = oe.cameraMenu.add(new MenuItem("Edit copy..."));
|
openWindowItem.addActionListener(this);
|
editLeafItem.addActionListener(this);
|
lookAtItem.addActionListener(this);
|
//lookFromItem.addActinoListener(this);
|
//switchItem.addActionListener(this);
|
Menu menu;
|
oe.menuBar.add(menu = new Menu("Edit"));
|
//editItem = menu.add(new MenuItem("Edit"));
|
//editItem.addActionListener(this);
|
duplicateItem = menu.add(new MenuItem("Duplicate"));
|
duplicateItem.addActionListener(this);
|
menu.add("-");
|
cloneItem = menu.add(new MenuItem("Clone"));
|
cloneItem.addActionListener(this);
|
cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
|
cloneSupportItem.addActionListener(this);
|
menu.add("-");
|
cutItem = menu.add(new MenuItem("Cut"));
|
cutItem.addActionListener(this);
|
copyItem = menu.add(new MenuItem("Copy"));
|
copyItem.addActionListener(this);
|
pasteItem = menu.add(new MenuItem("Paste"));
|
pasteItem.addActionListener(this);
|
pasteLinkItem = menu.add(new MenuItem("Paste link"));
|
pasteLinkItem.addActionListener(this);
|
pasteCloneItem = menu.add(new MenuItem("Paste clone"));
|
pasteCloneItem.addActionListener(this);
|
// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
|
// pasteExpandItem.addActionListener(this);
|
clearItem = menu.add(new MenuItem("Clear"));
|
clearItem.addActionListener(this);
|
clearAllItem = menu.add(new MenuItem("Clear All"));
|
clearAllItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Setting"));
|
resetMeshItem = menu.add(new MenuItem("Reset All"));
|
resetMeshItem.addActionListener(this);
|
stepAllItem = menu.add(new MenuItem("Step All"));
|
stepAllItem.addActionListener(this);
|
revertMeshItem = menu.add(new MenuItem("Revert Meshes"));
|
revertMeshItem.addActionListener(this);
|
resetreferencesItem = menu.add(new MenuItem("Reset Mesh References"));
|
resetreferencesItem.addActionListener(this);
|
menu.add("-");
|
overwriteGeoItem = menu.add(new MenuItem("Overwrite Geometry"));
|
overwriteGeoItem.addActionListener(this);
|
overwriteMatItem = menu.add(new MenuItem("Overwrite Material"));
|
overwriteMatItem.addActionListener(this);
|
synchronizeItem = menu.add(new MenuItem("Overwrite Transform"));
|
synchronizeItem.addActionListener(this);
|
overwriteNameItem = menu.add(new MenuItem("Overwrite Name"));
|
overwriteNameItem.addActionListener(this);
|
overwriteUVItem = menu.add(new MenuItem("Overwrite UV"));
|
overwriteUVItem.addActionListener(this);
|
menu.add("-");
|
generateMeshItem = menu.add(new MenuItem("Generate Meshes"));
|
generateMeshItem.addActionListener(this);
|
poseMeshItem = menu.add(new MenuItem("Set Pose Meshes"));
|
poseMeshItem.addActionListener(this);
|
menu.add("-");
|
resetsupportItem = menu.add(new MenuItem("Reset support"));
|
resetsupportItem.addActionListener(this);
|
linkverticesItem = menu.add(new MenuItem("Link to Support"));
|
linkverticesItem.addActionListener(this);
|
setMasterItem = menu.add(new MenuItem("Set Master Mesh"));
|
setMasterItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Group"));
|
grabItem = menu.add(new MenuItem("Grab"));
|
grabItem.addActionListener(this);
|
backItem = menu.add(new MenuItem("Back"));
|
backItem.addActionListener(this);
|
frontItem = menu.add(new MenuItem("Front"));
|
frontItem.addActionListener(this);
|
compositeItem = menu.add(new MenuItem("Composite"));
|
compositeItem.addActionListener(this);
|
menu.add("-");
|
randomItem = menu.add(new MenuItem("Random"));
|
randomItem.addActionListener(this);
|
physicsItem = menu.add(new MenuItem("Physics"));
|
physicsItem.addActionListener(this);
|
frameselectorItem = menu.add(new MenuItem("Frame Selector"));
|
frameselectorItem.addActionListener(this);
|
switchGeoItem = menu.add(new MenuItem("Switch Geometry"));
|
switchGeoItem.addActionListener(this);
|
switchTransfoItem = menu.add(new MenuItem("Switch Transform"));
|
switchTransfoItem.addActionListener(this);
|
morphItem = menu.add(new MenuItem("Morph"));
|
morphItem.addActionListener(this);
|
scriptNodeItem = menu.add(new MenuItem("Script Node"));
|
scriptNodeItem.addActionListener(this);
|
cameraItem = menu.add(new MenuItem("Camera"));
|
cameraItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Object"));
|
textureItem = menu.add(new MenuItem("Texture"));
|
textureItem.addActionListener(this);
|
csgItem = menu.add(new MenuItem("CSG"));
|
csgItem.addActionListener(this);
|
shadowXItem = menu.add(new MenuItem("Shadow X"));
|
shadowXItem.addActionListener(this);
|
shadowYItem = menu.add(new MenuItem("Shadow Y"));
|
shadowYItem.addActionListener(this);
|
shadowZItem = menu.add(new MenuItem("Shadow Z"));
|
shadowZItem.addActionListener(this);
|
linkerItem = menu.add(new MenuItem("Linker"));
|
linkerItem.addActionListener(this);
|
templateItem = menu.add(new MenuItem("Template"));
|
templateItem.addActionListener(this);
|
attributeItem = menu.add(new MenuItem("Attribute"));
|
attributeItem.addActionListener(this);
|
pointflowItem = menu.add(new MenuItem("Point Flow"));
|
pointflowItem.addActionListener(this);
|
menu.add("-");
|
transformgeometryItem = menu.add(new MenuItem("Transform Geometry"));
|
transformgeometryItem.addActionListener(this);
|
resetTransformItem = menu.add(new MenuItem("Reset Transform"));
|
resetTransformItem.addActionListener(this);
|
resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
|
resetCentroidItem.addActionListener(this);
|
ungroupItem = menu.add(new MenuItem("Ungroup"));
|
ungroupItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Geometry"));
|
genUVItem = menu.add(new MenuItem("Generate UV"));
|
genUVItem.addActionListener(this);
|
genNormalsORGANItem = menu.add(new MenuItem("Organic Normals"));
|
genNormalsORGANItem.addActionListener(this);
|
genNormalsCADItem = menu.add(new MenuItem("CAD Normals"));
|
genNormalsCADItem.addActionListener(this);
|
genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals"));
|
genNormalsMESHItem.addActionListener(this);
|
stripifyItem = menu.add(new MenuItem("Stripify"));
|
stripifyItem.addActionListener(this);
|
unstripifyItem = menu.add(new MenuItem("Unstripify"));
|
unstripifyItem.addActionListener(this);
|
trimItem = menu.add(new MenuItem("Trim"));
|
trimItem.addActionListener(this);
|
untrimItem = menu.add(new MenuItem("Untrim"));
|
untrimItem.addActionListener(this);
|
menu.add("-");
|
clearColorsItem = menu.add(new MenuItem("Clear AO"));
|
clearColorsItem.addActionListener(this);
|
reverseNormalsItem = menu.add(new MenuItem("Reverse Normals"));
|
reverseNormalsItem.addActionListener(this);
|
reverseTrianglesItem = menu.add(new MenuItem("Reverse Triangles"));
|
reverseTrianglesItem.addActionListener(this);
|
reduceMeshItem = menu.add(new MenuItem("Reduce mesh"));
|
reduceMeshItem.addActionListener(this);
|
reduce34MeshItem = menu.add(new MenuItem("Reduce mesh (34)"));
|
reduce34MeshItem.addActionListener(this);
|
increaseMeshItem = menu.add(new MenuItem("Increase mesh"));
|
increaseMeshItem.addActionListener(this);
|
smoothMeshItem = menu.add(new MenuItem("Smooth mesh"));
|
smoothMeshItem.addActionListener(this);
|
clipMeshItem = menu.add(new MenuItem("Clip mesh"));
|
clipMeshItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Attributes"));
|
clearMaterialsItem = menu.add(new MenuItem("Clear Materials"));
|
clearMaterialsItem.addActionListener(this);
|
menu.add("-");
|
liveleavesItem = menu.add(new MenuItem("Live Leaves"));
|
liveleavesItem.addActionListener(this);
|
unliveleavesItem = menu.add(new MenuItem("Unlive Leaves"));
|
unliveleavesItem.addActionListener(this);
|
supportleavesItem = menu.add(new MenuItem("Support Leaves"));
|
supportleavesItem.addActionListener(this);
|
unsupportleavesItem = menu.add(new MenuItem("Unsupport Leaves"));
|
unsupportleavesItem.addActionListener(this);
|
hideleavesItem = menu.add(new MenuItem("Hide Leaves"));
|
hideleavesItem.addActionListener(this);
|
showleavesItem = menu.add(new MenuItem("Show Leaves"));
|
showleavesItem.addActionListener(this);
|
markleavesItem = menu.add(new MenuItem("Mark Leaves"));
|
markleavesItem.addActionListener(this);
|
unmarkleavesItem = menu.add(new MenuItem("Unmark Leaves"));
|
unmarkleavesItem.addActionListener(this);
|
menu.add("-");
|
flipVItem = menu.add(new MenuItem("Flip V"));
|
flipVItem.addActionListener(this);
|
unflipVItem = menu.add(new MenuItem("Unflip V"));
|
unflipVItem.addActionListener(this);
|
lowTexturesItem = menu.add(new MenuItem("Low Texture (256)"));
|
lowTexturesItem.addActionListener(this);
|
normalTexturesItem = menu.add(new MenuItem("Normal Texture (512)"));
|
normalTexturesItem.addActionListener(this);
|
highTexturesItem = menu.add(new MenuItem("High Texture (1024)"));
|
highTexturesItem.addActionListener(this);
|
veryhighTexturesItem = menu.add(new MenuItem("Very high Texture (2048)"));
|
veryhighTexturesItem.addActionListener(this);
|
maxTexturesItem = menu.add(new MenuItem("Max Texture (4096)"));
|
maxTexturesItem.addActionListener(this);
|
panoTexturesItem = menu.add(new MenuItem("Panoramic Texture (8192)"));
|
panoTexturesItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Selection"));
|
attachPigmentItem = menu.add(new MenuItem("Attach Pigment..."));
|
attachPigmentItem.addActionListener(this);
|
attachBumpItem = menu.add(new MenuItem("Attach Bump..."));
|
attachBumpItem.addActionListener(this);
|
pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump"));
|
pigmentBumpItem.addActionListener(this);
|
detachPigmentItem = menu.add(new MenuItem("Detach Pigment"));
|
detachPigmentItem.addActionListener(this);
|
detachBumpItem = menu.add(new MenuItem("Detach Bump"));
|
detachBumpItem.addActionListener(this);
|
menu.add("-");
|
sortbysizeItem = menu.add(new MenuItem("Sort by size"));
|
sortbysizeItem.addActionListener(this);
|
sortbynameItem = menu.add(new MenuItem("Sort by name"));
|
sortbynameItem.addActionListener(this);
|
menu.add("-");
|
extractGeometriesItem = menu.add(new MenuItem("Link Geometry"));
|
extractGeometriesItem.addActionListener(this);
|
cloneGeometriesItem = menu.add(new MenuItem("Clone Geometry"));
|
cloneGeometriesItem.addActionListener(this);
|
shareGeometriesItem = menu.add(new MenuItem("Share Geometry"));
|
shareGeometriesItem.addActionListener(this);
|
mergeGeometriesItem = menu.add(new MenuItem("Merge Geometry"));
|
mergeGeometriesItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Insert"));
|
buildCreateMenu(menu);
|
|
|
oe.menuBar.add(menu = new Menu("Include"));
|
importGFDItem = menu.add(new MenuItem("GrafreeD Object..."));
|
importGFDItem.addActionListener(this);
|
importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D Object..."));
|
importVRMLX3DItem.addActionListener(this);
|
importOBJItem = menu.add(new MenuItem("OBJ Object..."));
|
importOBJItem.addActionListener(this);
|
import3DSItem = menu.add(new MenuItem("3DS Object..."));
|
import3DSItem.addActionListener(this);
|
|
oe.menuBar.add(menu = new Menu("Tools"));
|
buildToolsMenu(menu);
|
}
|
|
void SetupUI2(ObjEditor oe)
|
{
|
//new Exception().printStackTrace();
|
|
oe.radioPanel = new JPanel(new GridBagLayout());
|
oe.aConstraints.weightx = 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridwidth = 100;
|
oe.aConstraints.gridheight = 1;
|
// oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
|
|
oe.buttonGroup = new ButtonGroup();
|
cRadio clientButton = new cRadio(client.name);
|
radio = clientButton;
|
clientButton.addActionListener(this);
|
clientButton.setMnemonic(KeyEvent.VK_B);
|
clientButton.SetObject(client);
|
// clientButton.SetCamera(cameraView.renderCamera);
|
clientButton.setSelected(true);
|
oe.radioPanel.add(clientButton);
|
oe.buttonGroup.add(clientButton);
|
|
/*
|
cRadio dummyButton = new cRadio("1");
|
dummyButton.SetObject(null);
|
dummyButton.addActionListener(this);
|
oe.radioPanel.add(dummyButton);
|
oe.buttonGroup.add(dummyButton);
|
*/
|
aConstraints.gridy += 1;
|
oe.aConstraints.gridwidth = 1;
|
oe.aConstraints.gridx = 0;
|
|
oe.toolbarPanel.add(liveCB = new cCheckBox("Live", CameraPane.isLIVE()), oe.aConstraints);
|
liveCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT), oe.aConstraints);
|
supportCB.addItemListener(this);
|
|
// oe.aConstraints.gridx += 1;
|
// oe.toolbarPanel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), oe.aConstraints);
|
// localCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", CameraPane.CROWD), oe.aConstraints);
|
crowdCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA), oe.aConstraints);
|
smoothCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
|
fastCB.addItemListener(this);
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE), oe.aConstraints);
|
slowCB.addItemListener(this);
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.FAST), oe.aConstraints);
|
boxCB.addItemListener(this);
|
|
// oe.aConstraints.gridx += 1;
|
// oe.toolbarPanel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), oe.aConstraints);
|
// speakerMocapCB.addItemListener(this);
|
|
if (false)
|
{
|
// handled in scripts
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(speakerCameraCB = new cCheckBox("Cam", CameraPane.SPEAKERCAMERA), oe.aConstraints);
|
speakerCameraCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(speakerFocusCB = new cCheckBox("Focus", CameraPane.SPEAKERFOCUS), oe.aConstraints);
|
speakerFocusCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS), oe.aConstraints);
|
smoothfocusCB.addItemListener(this);
|
}
|
|
//oe.aConstraints.gridx += 1;
|
//oe.toolbarPanel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), oe.aConstraints);
|
// debugCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(oeilCB = new cCheckBox("O", CameraPane.OEIL), oe.aConstraints);
|
oeilCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(lookAtCB = new cCheckBox("T", CameraPane.LOOKAT), oe.aConstraints);
|
lookAtCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK), oe.aConstraints);
|
trackCB.addItemListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(screenfitButton = new cButton("@ ")); //, oe.aConstraints);
|
screenfitButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
// oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
|
// screenfitpointButton.addActionListener(this);
|
// oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(snapobjectButton = new cButton(" O+ ")); //, oe.aConstraints);
|
snapobjectButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
|
//aConstraints.gridx = 0;
|
//aConstraints.gridy += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.toolbarPanel.add(flashSelectionButton = new cButton(" ? ")); //, oe.aConstraints);
|
flashSelectionButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
//
|
oe.toolbarPanel.add(twoButton = new cButton(" |+| ")); //, oe.aConstraints);
|
twoButton.addActionListener(this);
|
oe.toolbarPanel.add(fourButton = new cButton("+|| ")); //, oe.aConstraints);
|
fourButton.addActionListener(this);
|
oe.toolbarPanel.add(sixButton = new cButton("+|+| ")); //, oe.aConstraints);
|
sixButton.addActionListener(this);
|
oe.toolbarPanel.add(threeButton = new cButton(" |+|+")); //, oe.aConstraints);
|
threeButton.addActionListener(this);
|
oe.toolbarPanel.add(sevenButton = new cButton("+|+|+")); //, oe.aConstraints);
|
sevenButton.addActionListener(this);
|
//
|
|
oe.toolbarPanel.add(rootButton = new cButton(" o o o E ")); //, oe.aConstraints);
|
rootButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
oe.toolbarPanel.add(closeButton = new cButton(" X ")); //, oe.aConstraints);
|
closeButton.addActionListener(this);
|
//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
|
//clearButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
|
oe.aConstraints.gridx = 1; //
|
oe.treePanel.add(editButton = new cButton("+"), oe.aConstraints);
|
editButton.addActionListener(this);
|
oe.aConstraints.gridx += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.treePanel.add(uneditButton = new cButton("-"), oe.aConstraints);
|
uneditButton.addActionListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.treePanel.add(clearPanelButton = new cButton("C"), oe.aConstraints);
|
clearPanelButton.addActionListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.treePanel.add(allParamsButton = new cButton("A"), oe.aConstraints);
|
allParamsButton.addActionListener(this);
|
|
oe.aConstraints.gridx += 1;
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.treePanel.add(unselectButton = new cButton("U"), oe.aConstraints);
|
unselectButton.addActionListener(this);
|
|
// oe.aConstraints.gridx += 1;
|
// oe.aConstraints.weighty = 0;
|
// oe.aConstraints.gridwidth = 1;
|
//
|
// oe.treePanel.add(recompileButton = new cButton("R"), oe.aConstraints);
|
// recompileButton.addActionListener(this);
|
|
// oe.aConstraints.gridx += 1;
|
// oe.treePanel.add(gcButton = new cButton("GC"), oe.aConstraints);
|
// gcButton.addActionListener(this);
|
|
oe.aConstraints.gridx = 0;
|
oe.aConstraints.gridy += 1;
|
|
//ctrlPanel.add(objList = new List(5, true));
|
oe.aConstraints.gridwidth = 100;
|
// oe.aConstraints.gridheight = 100;
|
oe.aConstraints.fill = GridBagConstraints.BOTH; // HORIZONTAL;
|
oe.aConstraints.gridheight = 1;
|
oe.aConstraints.weighty = 0.5;
|
oe.aConstraints.gridx = 0;
|
JScrollPane jSP;
|
//ctrlPanel.add(new JScrollPane(jTree = new cTree(new cTreeModel(this))), aConstraints);
|
oe.treePanel.add(jSP = new JScrollPane(oe.jTree = new cTree(null)), oe.aConstraints);
|
ResetModel();
|
oe.aConstraints.weighty = 0.5;
|
oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
|
oe.aConstraints.gridy += 1;
|
oe.aConstraints.gridwidth = 1;
|
|
oe.aConstraints.weighty = 0;
|
oe.aConstraints.gridwidth = 2;
|
|
oe.treePanel.add(colorCB = new cCheckBox("Color", (dropAttributes&Object3D.COLOR)!=0), oe.aConstraints);
|
colorCB.addItemListener(this);
|
oe.aConstraints.gridx += 2;
|
oe.treePanel.add(materialCB = new cCheckBox("Material", (dropAttributes&Object3D.MATERIAL)!=0), oe.aConstraints);
|
materialCB.addItemListener(this);
|
oe.aConstraints.gridx += 2;
|
oe.treePanel.add(textureCB = new cCheckBox("Texture", (dropAttributes&Object3D.TEXTURE)!=0), oe.aConstraints);
|
textureCB.addItemListener(this);
|
|
oe.aConstraints.gridx = 0;
|
oe.aConstraints.gridy += 1;
|
|
//jList.addListSelectionListener(this);
|
oe.jTree.addTreeSelectionListener(this);
|
//jTree.setRootVisible(false);
|
//jTree.setEditable(true);
|
oe.jTree.setDragEnabled(true);
|
//jTree.setPreferredSize(new Dimension(10,10));
|
jSP.setPreferredSize(new Dimension(100,200));
|
|
oe.jTree.setCellRenderer(new cTreeModel.Renderer());
|
|
/*DragGestureRecognizer dgr =*/ DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(oe.jTree, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
|
/*DropTarget*/ dropTarget = new DropTarget(oe.jTree, this);
|
|
/*
|
try{
|
dgr.addDragGestureListener(this);
|
}catch(Exception e) {}
|
*/
|
radio.layout = sevenButton;
|
oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
|
}
|
|
void EditObject(Object3D obj)
|
{
|
cRadio dummyButton = new cRadio(obj.name);
|
dummyButton.SetObject(obj);
|
dummyButton.layout = sevenButton;
|
dummyButton.SetCamera(cameraView.renderCamera, false);
|
dummyButton.addActionListener(this);
|
radioPanel.add(dummyButton);
|
buttonGroup.add(dummyButton);
|
dummyButton.doClick();
|
}
|
void SetupViews(ObjEditor oe)
|
{
|
oe.SetupViews();
|
|
System.out.println("SetupViews");
|
DragSource.getDefaultDragSource().createDefaultDragGestureRecognizer(
|
oe.cameraView, DnDConstants.ACTION_COPY_OR_MOVE, this); // ACTION_LINK ??
|
/*DropTarget dropTarget =*/ new DropTarget(oe.cameraView, this);
|
}
|
|
JCheckBox liveCB;
|
JCheckBox supportCB;
|
JCheckBox localCB;
|
JCheckBox crowdCB;
|
JCheckBox smoothCB;
|
JCheckBox fastCB;
|
JCheckBox slowCB;
|
JCheckBox boxCB;
|
JCheckBox trackCB;
|
JCheckBox smoothfocusCB;
|
// JCheckBox speakerMocapCB;
|
JCheckBox speakerCameraCB;
|
JCheckBox speakerFocusCB;
|
JCheckBox debugCB;
|
JCheckBox oeilCB;
|
JCheckBox lookAtCB;
|
|
// static int COLOR = 1;
|
// static int MATERIAL = 2;
|
// static int TEXTURE = 4;
|
|
int dropAttributes = Object3D.COLOR | Object3D.MATERIAL;
|
|
JCheckBox colorCB;
|
JCheckBox materialCB;
|
JCheckBox textureCB;
|
|
public void itemStateChanged(ItemEvent e)
|
{
|
// System.out.println("itemStateChanged = " + e);
|
if(e.getSource() == colorCB)
|
{
|
if (e.getStateChange() == ItemEvent.SELECTED)
|
dropAttributes |= Object3D.COLOR;
|
else
|
dropAttributes &= ~Object3D.COLOR;
|
}
|
else if(e.getSource() == materialCB)
|
{
|
if (e.getStateChange() == ItemEvent.SELECTED)
|
dropAttributes |= Object3D.MATERIAL;
|
else
|
dropAttributes &= ~Object3D.MATERIAL;
|
}
|
else if(e.getSource() == textureCB)
|
{
|
if (e.getStateChange() == ItemEvent.SELECTED)
|
dropAttributes |= Object3D.TEXTURE;
|
else
|
dropAttributes &= ~Object3D.TEXTURE;
|
}
|
else if(e.getSource() == liveCB)
|
{
|
cameraView.ToggleLive();
|
}
|
else if(e.getSource() == supportCB)
|
{
|
cameraView.ToggleSupport();
|
cameraView.repaint();
|
}
|
else if(e.getSource() == crowdCB)
|
{
|
cameraView.ToggleCrowd();
|
cameraView.repaint();
|
}
|
else if(e.getSource() == smoothCB)
|
{
|
cameraView.ToggleInertia();
|
cameraView.repaint();
|
}
|
else if(e.getSource() == localCB)
|
{
|
cameraView.ToggleLocal();
|
}
|
else if(e.getSource() == fastCB)
|
{
|
cameraView.ToggleFast();
|
}
|
else if(e.getSource() == slowCB)
|
{
|
cameraView.ToggleSlowPose();
|
}
|
else if(e.getSource() == boxCB)
|
{
|
cameraView.ToggleBoxMode();
|
Recompile();
|
cameraView.repaint();
|
// refreshContents();
|
}
|
else if(e.getSource() == smoothfocusCB)
|
{
|
cameraView.ToggleSmoothFocus();
|
}
|
else if(e.getSource() == speakerCameraCB)
|
{
|
cameraView.ToggleSpeakerCamera();
|
}
|
else if(e.getSource() == speakerFocusCB)
|
{
|
cameraView.ToggleSpeakerFocus();
|
}
|
else if(e.getSource() == debugCB)
|
{
|
cameraView.ToggleDebug();
|
cameraView.repaint();
|
}
|
else if(e.getSource() == trackCB)
|
{
|
cameraView.ToggleTrack();
|
}
|
else if(e.getSource() == oeilCB)
|
{
|
cameraView.ToggleOeil();
|
}
|
else if(e.getSource() == lookAtCB)
|
{
|
cameraView.ToggleLookAt();
|
}
|
else
|
{
|
super.itemStateChanged(e);
|
}
|
}
|
|
public void dragGestureRecognized(DragGestureEvent dge)
|
{
|
System.out.println("dragGestureRecognized : " + dge);
|
|
/**/
|
//DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveNoDrop, new StringSelection("Allo"), this);
|
TreePath path = new TreePath(objEditor.jTree.getSelectionPath().getLastPathComponent());
|
if ((path == null) || (path.getPathCount() <= 1)) {
|
// We can't move the root node or an empty selection
|
return;
|
}
|
//oldNode = (Object3D) path.getLastPathComponent();
|
TransferableTreePath transferable = new TransferableTreePath(path);
|
System.out.println("startDrag : " + dge);
|
DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultMoveDrop, transferable, null);
|
/**/
|
}
|
|
//Object3D oldNode;
|
//TransferableTreeNode transferable;
|
|
public void dragEnter(DropTargetDragEvent dtde)
|
// Called when a drag operation has encountered the DropTarget.
|
{
|
System.out.println("dragEnter : " + dtde);
|
}
|
public void dragExit(DropTargetEvent dte)
|
// The drag operation has departed the DropTarget without dropping.
|
{
|
System.out.println("dragExit : " + dte);
|
}
|
public void dragOver(DropTargetDragEvent dtde)
|
// Called when a drag operation is ongoing on the DropTarget.
|
{
|
//System.out.println("dragOver : " + dtde.getSource());
|
}
|
|
DropTarget dropTarget;
|
|
//Point location;
|
|
public void drop(DropTargetDropEvent dtde)
|
// The drag operation has terminated with a drop on this DropTarget.
|
{
|
objEditor.location = dtde.getLocation();
|
Component target = dtde.getDropTargetContext().getDropTarget().getComponent();
|
|
//assert dropTarget == dtde.getSource();
|
if (target instanceof CameraPane)
|
{
|
Object object = null;
|
Object debug = dtde.getTransferable();
|
DataFlavor[] flavors = dtde.getTransferable().getTransferDataFlavors();
|
|
for (int i=flavors.length; --i>=0;)
|
{
|
try
|
{
|
object = dtde.getTransferable().getTransferData(
|
flavors[i] // DataFlavor.imageFlavor // stringFlavor // dtde.getTransferable().getTransferDataFlavors()[0]
|
);
|
break;
|
}
|
catch(Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
String string = (String) object;
|
|
System.out.println("Transfer = " + object + "; drop : " + target);
|
// if( object instanceof java.io.File[])
|
// {
|
// //assert(false);
|
// objEditor.DropFile((java.io.File[]) object, true);
|
// return;
|
// }
|
if (string.charAt(0) == '/')
|
{
|
// file(s)
|
String[] names = string.split("\n");
|
|
java.io.File[] files = new java.io.File[names.length];
|
|
for (int i=names.length; --i>=0;)
|
{
|
files[i] = new java.io.File(names[i]);
|
}
|
|
objEditor.DropFile(files, true);
|
return;
|
}
|
// ??? Vector<Object3D> tempsel = (Vector<Object3D>) group.selection.clone();
|
|
// grosse patch: on ignore le transfert...
|
Object3D tempsel = group.selection;
|
|
if (tempsel.size() != 1)
|
return;
|
|
Object3D source = tempsel.get(0);
|
|
flashIt = false;
|
CameraPane pane = (CameraPane) target;
|
pane.clickStart(objEditor.location.x, objEditor.location.y, 0);
|
pane.clickEnd(objEditor.location.x, objEditor.location.y, 0, true);
|
|
if (group.selection.size() == 1)
|
{
|
DropObject(source); // tempsel.get(0));
|
}
|
|
Select(source/*tempsel.get(0)*/.GetTreePath(), true, true);
|
flashIt = true;
|
|
return;
|
}
|
|
assert target == objEditor.jTree;
|
TreePath destinationPath = objEditor.jTree.getPathForLocation(objEditor.location.x, objEditor.location.y);
|
try {
|
Object3D dummy = (Composite) destinationPath.getLastPathComponent();
|
} catch (Exception e) {
|
System.out.println("destinationPath : " + destinationPath);
|
return;
|
}
|
|
if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) // ?? LINK)
|
{
|
loadClipboard(true);
|
objEditor.jTree.setSelectionPath(destinationPath);
|
pasteInto(false);
|
} else {
|
loadClipboard(false);
|
objEditor.jTree.setSelectionPath(destinationPath);
|
pasteInto(false); // true); // ???
|
}
|
}
|
public void dropActionChanged(DropTargetDragEvent dtde)
|
// Called if the user has modified the current drop gesture
|
{
|
System.out.println("dropActionChanged : " + dtde);
|
}
|
|
// DRAG SOURCE
|
public void dragDropEnd(DragSourceDropEvent dsde)
|
// This method is invoked to signify that the Drag and Drop operation is complete.
|
{
|
System.out.println("dragDropEnd : " + dsde.getSource());
|
/*
|
if (//dsde.getDropSuccess() &&
|
true) //(dsde.getDropAction() == DnDConstants.ACTION_MOVE))
|
{
|
//((DefaultTreeModel) jTree.getModel()).removeNodeFromParent(oldNode);
|
loadClipboard(true);
|
}
|
*/
|
}
|
public void dragEnter(DragSourceDragEvent dsde)
|
// Called as the hotspot enters a platform dependent drop site.
|
{
|
System.out.println("dragEnter : " + dsde);
|
}
|
public void dragExit(DragSourceEvent dse)
|
// Called as the hotspot exits a platform dependent drop site.
|
{
|
System.out.println("dragExit : " + dse);
|
}
|
public void dragOver(DragSourceDragEvent dsde)
|
// Called as the hotspot moves over a platform dependent drop site.
|
{
|
//System.out.println("dragOver : " + dsde);
|
}
|
public void dropActionChanged(DragSourceDragEvent dsde)
|
// Called when the user has modified the drop gesture.
|
{
|
System.out.println("dropActionChanged : " + dsde);
|
System.out.println("Action: " + dsde.getDropAction());
|
System.out.println("Target Action: " + dsde.getTargetActions());
|
System.out.println("User Action: " + dsde.getUserAction());
|
}
|
|
public static DataFlavor TREE_PATH_FLAVOR = new DataFlavor(TreePath.class,
|
"Tree Path");
|
|
static class TransferableTreePath implements Transferable {
|
|
DataFlavor flavors[] = { TREE_PATH_FLAVOR };
|
|
TreePath path;
|
|
public TransferableTreePath(TreePath tp) {
|
path = tp;
|
}
|
|
public synchronized DataFlavor[] getTransferDataFlavors() {
|
return flavors;
|
}
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
return (flavor.getRepresentationClass() == TreePath.class);
|
}
|
|
public synchronized Object getTransferData(DataFlavor flavor)
|
throws UnsupportedFlavorException, java.io.IOException {
|
if (isDataFlavorSupported(flavor)) {
|
return path;
|
} else {
|
throw new UnsupportedFlavorException(flavor);
|
}
|
}
|
}
|
|
void Clear()
|
{
|
super.Clear();
|
|
group = null;
|
}
|
|
void DropObject(Object3D obj)
|
{
|
Object3D targ = group.selection.get(0);
|
|
targ.SetAttributes(obj, dropAttributes);
|
}
|
|
/*
|
public void doLayout()
|
{
|
super.doLayout();
|
int h = objList.getPreferredSize().height;
|
objList.setBounds(5, widgetPos, 190, h);
|
widgetPos += h + 5;
|
}
|
*/
|
|
void buildCreateMenu(Menu menu)
|
{
|
//heightFieldItem = menu.add(new MenuItem("Height Field"));
|
//heightFieldItem.addActionListener(this);
|
gridItem = menu.add(new MenuItem("Grid"));
|
gridItem.addActionListener(this);
|
rectoidItem = menu.add(new MenuItem("Box"));
|
rectoidItem.addActionListener(this);
|
ellipsoidItem = menu.add(new MenuItem("Sphere"));
|
ellipsoidItem.addActionListener(this);
|
coneItem = menu.add(new MenuItem("Cone"));
|
coneItem.addActionListener(this);
|
torusItem = menu.add(new MenuItem("Torus"));
|
torusItem.addActionListener(this);
|
superItem = menu.add(new MenuItem("Superellipsoid"));
|
superItem.addActionListener(this);
|
particleItem = menu.add(new MenuItem("Particle system"));
|
particleItem.addActionListener(this);
|
ragdollItem = menu.add(new MenuItem("Rag Walk"));
|
ragdollItem.addActionListener(this);
|
ragdoll2Item = menu.add(new MenuItem("Rag Fall"));
|
ragdoll2Item.addActionListener(this);
|
menu.add("-");
|
meshItem = menu.add(new MenuItem("Mesh"));
|
meshItem.addActionListener(this);
|
// meshGroupItem = menu.add(new MenuItem("Mesh Group"));
|
// meshGroupItem.addActionListener(this);
|
springItem = menu.add(new MenuItem("Spring"));
|
springItem.addActionListener(this);
|
flagItem = menu.add(new MenuItem("Flag"));
|
flagItem.addActionListener(this);
|
bezierItem = menu.add(new MenuItem("Patch"));
|
bezierItem.addActionListener(this);
|
checkerItem = menu.add(new MenuItem("Checker"));
|
checkerItem.addActionListener(this);
|
blobItem = menu.add(new MenuItem("Blob"));
|
blobItem.addActionListener(this);
|
latheItem = menu.add(new MenuItem("Lathe"));
|
latheItem.addActionListener(this);
|
lightItem = menu.add(new MenuItem("Light"));
|
lightItem.addActionListener(this);
|
menu.add("-");
|
//superLoopItem = menu.add(new MenuItem("Super Loop"));
|
//superLoopItem.addActionListener(this);
|
loopItem = menu.add(new MenuItem("Loop"));
|
loopItem.addActionListener(this);
|
doubleItem = menu.add(new MenuItem("Fork"));
|
doubleItem.addActionListener(this);
|
tripleItem = menu.add(new MenuItem("Trident"));
|
tripleItem.addActionListener(this);
|
}
|
|
void buildToolsMenu(Menu menu)
|
{
|
menu.add(animationItem = new CheckboxMenuItem("Animation..."));
|
animationItem.addItemListener(this);
|
animationItem.setState(CameraPane.ANIMATION);
|
|
menu.add("-");
|
parseverticesItem = menu.add(new MenuItem("Multiplicity"));
|
parseverticesItem.addActionListener(this);
|
textureFieldItem = menu.add(new MenuItem("Texture Field"));
|
textureFieldItem.addActionListener(this);
|
alignItem = menu.add(new MenuItem("Align"));
|
alignItem.addActionListener(this);
|
mirrorItem = menu.add(new MenuItem("Mirror Poses"));
|
mirrorItem.addActionListener(this);
|
reduceMorphItem = menu.add(new MenuItem("Reduce Morphs"));
|
reduceMorphItem.addActionListener(this);
|
reduce34MorphItem = menu.add(new MenuItem("Reduce Morphs (34)"));
|
reduce34MorphItem.addActionListener(this);
|
|
menu.add(computeAOItem = new MenuItem("Compute AO"));
|
computeAOItem.addActionListener(this);
|
menu.add("-");
|
|
menu.add(memoryItem = new MenuItem("Memory Usage"));
|
memoryItem.addActionListener(this);
|
menu.add(analyzeItem = new MenuItem("Analyze"));
|
analyzeItem.addActionListener(this);
|
menu.add(dumpItem = new MenuItem("Dump"));
|
dumpItem.addActionListener(this);
|
// menu.add(pathItem = new MenuItem("From-to path"));
|
// pathItem.addActionListener(this);
|
menu.add("-");
|
resetParentItem = menu.add(new MenuItem("Reset Parent"));
|
resetParentItem.addActionListener(this);
|
repairParentItem = menu.add(new MenuItem("Repair Parent"));
|
repairParentItem.addActionListener(this);
|
menu.add(invariantsItem = new MenuItem("Invariants"));
|
invariantsItem.addActionListener(this);
|
menu.add(recompileItem = new MenuItem("Recompile"));
|
recompileItem.addActionListener(this);
|
menu.add("-");
|
menu.add(editScriptItem = new MenuItem("Edit Script..."));
|
editScriptItem.addActionListener(this);
|
}
|
|
void ScreenFit()
|
{
|
if (group.selection == null || group.selection.size() == 0)
|
{
|
super.ScreenFit();
|
return; // true;
|
}
|
|
Object3D obj = (Object3D)group.selection.elementAt(0);
|
objEditor.ScreenFit(obj, false);
|
|
cameraView.pingthread.StepToTarget(true);
|
refreshContents();
|
}
|
|
Vertex vert1 = new Vertex(true);
|
Vertex vert2 = new Vertex(true);
|
Vertex vert3 = new Vertex(true);
|
Vertex vert4 = new Vertex(true);
|
|
void CastShadow(int axis)
|
{
|
//for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
for (int i=group.selection.size(); --i>=0;)
|
{
|
//Object3D child = (Object3D)e.nextElement();
|
Object3D child = (Object3D)group.selection.get(i);
|
|
CastShadow(child, axis);
|
}
|
}
|
|
void CastShadow(Object3D obj, int axis)
|
{
|
cVector minima = new cVector();
|
cVector maxima = new cVector();
|
obj.getBounds(minima, maxima, true);
|
|
if(obj.parent != null)
|
{
|
//obj.parent.TransformToWorld(vert1, vert1);
|
//obj.parent.TransformToWorld(vert2, vert2);
|
//obj.parent.TransformToWorld(vert3, vert3);
|
//obj.parent.TransformToWorld(vert4, vert4);
|
obj.parent.TransformToWorld(minima); //, minima);
|
obj.parent.TransformToWorld(maxima); //, maxima);
|
}
|
|
Object3D shadow = new Object3D("Shadow " + obj.name);
|
|
shadow.toParent = LA.newMatrix();
|
shadow.fromParent = LA.newMatrix();
|
|
shadow.bRep = new BoundaryRep();
|
|
shadow.bRep.redimension(4,2); // vertices / faces
|
|
cVector norm = null;
|
|
switch(axis)
|
{
|
case 0 :
|
vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
|
vert2.x = minima.x; vert2.y = maxima.y; vert2.z = minima.z;
|
vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
|
vert4.x = minima.x; vert4.y = maxima.y; vert4.z = maxima.z;
|
norm = cVector.X;
|
break;
|
case 1 :
|
vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
|
vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
|
vert3.x = minima.x; vert3.y = minima.y; vert3.z = maxima.z;
|
vert4.x = maxima.x; vert4.y = minima.y; vert4.z = maxima.z;
|
norm = cVector.Y;
|
break;
|
case 2 :
|
vert1.x = minima.x; vert1.y = minima.y; vert1.z = minima.z;
|
vert2.x = maxima.x; vert2.y = minima.y; vert2.z = minima.z;
|
vert3.x = minima.x; vert3.y = maxima.y; vert3.z = minima.z;
|
vert4.x = maxima.x; vert4.y = maxima.y; vert4.z = minima.z;
|
norm = cVector.Z;
|
break;
|
}
|
|
cVector interest = new cVector((vert1.x+vert2.x+vert3.x+vert4.x)/4,
|
(vert1.y+vert2.y+vert3.y+vert4.y)/4,
|
(vert1.z+vert2.z+vert3.z+vert4.z)/4);
|
|
LA.matTranslate(shadow.toParent, interest.x, interest.y, interest.z);
|
LA.matInvert(shadow.toParent, shadow.fromParent);
|
|
LA.vecSub(vert1, interest, vert1);
|
LA.vecSub(vert2, interest, vert2);
|
LA.vecSub(vert3, interest, vert3);
|
LA.vecSub(vert4, interest, vert4);
|
|
// ??
|
LA.vecCopy(norm, vert1.norm);
|
LA.vecCopy(norm, vert2.norm);
|
LA.vecCopy(norm, vert3.norm);
|
LA.vecCopy(norm, vert4.norm);
|
|
shadow.bRep.SetVertex(vert1, 0);
|
shadow.bRep.SetVertex(vert2, 1);
|
shadow.bRep.SetVertex(vert3, 2);
|
shadow.bRep.SetVertex(vert4, 3);
|
|
vert1.s = 0; vert1.t = 0;
|
vert2.s = 0; vert2.t = 1;
|
vert3.s = 1; vert3.t = 0;
|
vert4.s = 1; vert4.t = 1;
|
|
shadow.bRep.setFace(0, 0, 2, 1);
|
shadow.bRep.setFace(1, 1, 2, 3);
|
|
shadow.bRep.Trim(true, false, false, true, false);
|
|
shadow.material = new cMaterial(obj.material);
|
shadow.material.diffuse = 0.0001f;
|
shadow.material.specular = 0.0001f;
|
|
makeSomething(shadow);
|
}
|
|
/**
|
* applyExample
|
*/
|
private void applyExample(ParticleSystem particleGeom, String examType)
|
{
|
// if (exampleList == null || exampleList.getSelectedValue() == null)
|
// return;
|
// String examType = exampleList.getSelectedValue().toString();
|
// particleGeom.clearInfluences();
|
if ("FIRE".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
|
particleGeom.setMaximumAngle(0.20943952f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(1.0f);
|
particleGeom.setMinimumLifeTime(1.0000f);
|
particleGeom.setMaximumLifeTime(1.5000f);
|
particleGeom.setStartSize(40.0f);
|
particleGeom.setEndSize(400.0f);
|
particleGeom
|
.setStartColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(true);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(0.3f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("FOUNTAIN".equalsIgnoreCase(examType)) {
|
// particleGeom.addInfluence(SimpleParticleInfluenceFactory
|
// .createBasicGravity(new Vector3f(0, -3f, 0), true));
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
|
particleGeom.setMaximumAngle(0.2268928f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(1.0f);
|
particleGeom.setMinimumLifeTime(1.3000f);
|
particleGeom.setMaximumLifeTime(1.9500f);
|
particleGeom.setStartSize(10.0f);
|
particleGeom.setEndSize(10.0f);
|
particleGeom
|
.setStartColor(new ColorRGBA(0.0f, 0.0625f, 1.0f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.0f, 0.0625f, 1.0f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(1.1f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("LAVA".equalsIgnoreCase(examType)) {
|
// particleGeom.addInfluence(SimpleParticleInfluenceFactory
|
// .createBasicGravity(new Vector3f(0, -3f, 0), true));
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
|
particleGeom.setMaximumAngle(0.418f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(1.0f);
|
particleGeom.setMinimumLifeTime(1.0570f);
|
particleGeom.setMaximumLifeTime(1.5000f);
|
particleGeom.setStartSize(40.0f);
|
particleGeom.setEndSize(40.0f);
|
particleGeom
|
.setStartColor(new ColorRGBA(1.0f, 0.18f, 0.125f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(1.0f, 0.18f, 0.125f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(1.1f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("SMOKE".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 0.6f, 0.0f));
|
particleGeom.setMaximumAngle(0.36651915f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(0.2f);
|
particleGeom.setMinimumLifeTime(1.0000f);
|
particleGeom.setMaximumLifeTime(1.5000f);
|
particleGeom.setStartSize(32.5f);
|
particleGeom.setEndSize(40.0f);
|
particleGeom.setStartColor(new ColorRGBA(0.0f, 0.0f, 0.0f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(0.58f);
|
particleGeom.setParticleSpinSpeed(0.08f);
|
} else if ("RAIN".equalsIgnoreCase(examType)) {
|
// particleGeom.addInfluence(SimpleParticleInfluenceFactory
|
// .createBasicGravity(new Vector3f(0, -3f, 0), true));
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, -1.0f, 0.0f));
|
particleGeom.setMaximumAngle(3.1415927f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(0.5f);
|
particleGeom.setMinimumLifeTime(1.6260f);
|
particleGeom.setMaximumLifeTime(2.4000f);
|
particleGeom.setStartSize(9.1f);
|
particleGeom.setEndSize(13.6f);
|
particleGeom.setStartColor(new ColorRGBA(0.16078432f, 0.16078432f,
|
1.0f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.16078432f, 0.16078432f,
|
1.0f, 0.15686275f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(0.58f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("SNOW".equalsIgnoreCase(examType)) {
|
// particleGeom.addInfluence(SimpleParticleInfluenceFactory
|
// .createBasicGravity(new Vector3f(0, -3f, 0), true));
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, -1.0f, 0.0f));
|
particleGeom.setMaximumAngle(1.5707964f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(0.2f);
|
particleGeom.setMinimumLifeTime(1.0570f);
|
particleGeom.setMaximumLifeTime(1.5000f);
|
particleGeom.setStartSize(30.0f);
|
particleGeom.setEndSize(30.0f);
|
particleGeom.setStartColor(new ColorRGBA(0.3764706f, 0.3764706f,
|
0.3764706f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.3764706f, 0.3764706f,
|
0.3764706f, 0.1882353f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(0.59999996f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("JET".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(-1.0f, 0.0f, 0.0f));
|
particleGeom.setMaximumAngle(0.034906585f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(1.0f);
|
particleGeom.setMinimumLifeTime(.1000f);
|
particleGeom.setMaximumLifeTime(.1500f);
|
particleGeom.setStartSize(6.6f);
|
particleGeom.setEndSize(30.0f);
|
particleGeom.setStartColor(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.6f, 0.2f, 0.0f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(1.4599999f);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_WRAP);
|
} else if ("EXPLOSION".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
|
particleGeom.setMaximumAngle(3.1415927f);
|
particleGeom.setMinimumAngle(0);
|
particleGeom.getParticleController().setTimeStep(1.4f);
|
particleGeom.setMinimumLifeTime(1.0000f);
|
particleGeom.setMaximumLifeTime(1.5000f);
|
particleGeom.setStartSize(40.0f);
|
particleGeom.setEndSize(40.0f);
|
particleGeom
|
.setStartColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(1.0f, 0.24313726f,
|
0.03137255f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.getParticleController().setRepeatType(
|
Controller.RT_CLAMP);
|
} else if ("GROUND FOG".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 0.3f, 0.0f));
|
particleGeom.setMaximumAngle(1.5707964f);
|
particleGeom.setMinimumAngle(1.5707964f);
|
particleGeom.getParticleController().setTimeStep(0.5f);
|
particleGeom.setMinimumLifeTime(1.7740f);
|
particleGeom.setMaximumLifeTime(2.8000f);
|
particleGeom.setStartSize(35.4f);
|
particleGeom.setEndSize(40.0f);
|
particleGeom.setStartColor(new ColorRGBA(0.87058824f, 0.87058824f,
|
0.87058824f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.0f, 0.8f, 0.8f, 0.0f));
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.setReleaseRate(300);
|
particleGeom.setReleaseVariance(0.0f);
|
particleGeom.setInitialVelocity(1.0f);
|
particleGeom.setParticleSpinSpeed(0.0f);
|
} else if ("FIREFLIES".equalsIgnoreCase(examType)) {
|
particleGeom.setEmissionDirection(new Vector3f(0, 1, 0));
|
particleGeom.setStartSize(3f);
|
particleGeom.setEndSize(1.5f);
|
particleGeom.setOriginOffset(new Vector3f(0, 0, 0));
|
particleGeom.setInitialVelocity(.05f);
|
particleGeom.setMinimumLifeTime(5.000f);
|
particleGeom.setMaximumLifeTime(15.000f);
|
particleGeom.setStartColor(new ColorRGBA(1, 0, 0, 1));
|
particleGeom.setEndColor(new ColorRGBA(0, 1, 0, 1));
|
particleGeom.setMaximumAngle(com.jme.math.FastMath.PI);
|
particleGeom.getParticleController().setControlFlow(false);
|
particleGeom.getParticleController().setTimeStep(0.75f);
|
// SwarmInfluence swarm = new SwarmInfluence(new Vector3f(0, 0, 0),
|
// .001f);
|
// swarm.setMaxSpeed(.2f);
|
// swarm.setSpeedBump(0.025f);
|
// swarm.setTurnSpeed(FastMath.DEG_TO_RAD * 360);
|
// particleGeom.addInfluence(swarm);
|
}
|
|
particleGeom.warmUp(120);
|
// updateFromManager();
|
}
|
|
void Overwrite(int mask)
|
{
|
if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
|
{
|
Object3D content = GrafreeD.clipboard.get(0);
|
|
if (content instanceof cGroup && ((cGroup)content).transientlink )
|
content = ((cGroup)content).get(0);
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
//group.selection.get(i).Dump(true);
|
group.selection.get(i).overwriteThis(content, mask);
|
//group.selection.get(i).Dump(true);
|
}
|
refreshContents();
|
}
|
}
|
|
// void Recompile()
|
// {
|
// group.ResetDisplayList();
|
// group.HardTouch();
|
// }
|
//
|
public void actionPerformed(ActionEvent event) // , Object arg)
|
{
|
/*
|
if (event.getSource() == nameField)
|
{
|
//System.out.println(event);
|
applySelf();
|
// ?? parent.applySelf();
|
refreshContents();
|
//Refresh();
|
}
|
else
|
*/
|
if (event.getSource() == lookAtItem || event.getSource() == lookFromItem)
|
{
|
ScreenFit();
|
} else
|
if (event.getSource() == switchItem)
|
{
|
cVector v1 = new cVector();
|
cVector v2 = new cVector();
|
LA.vecCopy(objEditor.cameraView.renderCamera.location, v1);
|
LA.vecCopy(objEditor.cameraView.renderCamera.lookAt, v2);
|
objEditor.cameraView.renderCamera.setAim(v2, v1);
|
objEditor.cameraView.repaint();
|
} else
|
if (event.getSource() == rectoidItem)
|
{
|
makeSomething(new Box());
|
} else
|
if (event.getSource() == particleItem)
|
{
|
ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType);
|
ParticleController particleController = new ParticleController(particleGeom);
|
particleGeom.addController(particleController);
|
/*
|
// particleGeom.addInfluence(SimpleParticleInfluenceFactory
|
// .createBasicGravity(new Vector3f(0, -3f, 0), true));
|
particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
|
particleGeom.setMaximumAngle(0.2268928f);
|
particleGeom.getParticleController().setSpeed(1.0f);
|
particleGeom.setMinimumLifeTime(2000.0f);
|
particleGeom.setStartSize(1.0f);
|
particleGeom.setEndSize(10.0f);
|
particleGeom.setStartColor(new ColorRGBA(0.0f, 0.0625f, 1.0f, 1.0f));
|
particleGeom.setEndColor(new ColorRGBA(0.0f, 0.0625f, 1.0f, 0.0f));
|
particleGeom.warmUp(120);
|
*/
|
applyExample(particleGeom, "SMOKE");
|
makeSomething(particleGeom);
|
} else
|
if (event.getSource() == ragdollItem || event.getSource() == ragdoll2Item)
|
{
|
GenericJoint ragdoll = new GenericJoint(event.getSource() == ragdollItem);
|
|
ragdoll.toParent = LA.newMatrix();
|
ragdoll.fromParent = LA.newMatrix();
|
|
ragdoll.fromParent[1][1] = 1/1.03;
|
ragdoll.toParent[1][1] = 1.03;
|
|
ragdoll.fromParent[3][1] = 0.02;
|
ragdoll.toParent[3][1] = -0.02;
|
ragdoll.fromParent[3][2] = 0.01;
|
ragdoll.toParent[3][2] = -0.01;
|
|
makeSomething(ragdoll);
|
//makeSomething(new VehicleDemo());
|
} else
|
/*
|
*/
|
if (event.getSource() == heightFieldItem)
|
{
|
Object3D obj = new Object3D();
|
|
obj.CreateMaterial();
|
obj.bRep = new BoundaryRep();
|
|
obj.bRep.CreateMesh(new iHeightField()
|
{
|
public double f(double x, double y)
|
{
|
// The Mandelbrot set is represented by coloring
|
// each point (x,y) according to the number of
|
// iterations it takes before the while loop in
|
// this method ends. For points that are actually
|
// in the Mandelbrot set, or very close to it, the
|
// count will reach the maximum value, 80. These
|
// points will be colored purple. All other colors
|
// represent points that are definitely NOT in the set.
|
x -= 600;
|
y -= 500;
|
x /= 200;
|
y /= 200;
|
int count = 0;
|
double zx = x;
|
double zy = y;
|
while (count < 80 && Math.abs(x) < 100 && Math.abs(zy) < 100) {
|
double new_zx = zx*zx - zy*zy + x;
|
zy = 2*zx*zy + y;
|
zx = new_zx;
|
count++;
|
}
|
return count; // Math.sqrt(count);
|
}
|
}, 1000,1000);
|
|
makeSomething(obj);
|
} else
|
if (event.getSource() == gridItem)
|
{
|
makeSomething(new Grid());
|
} else
|
if (event.getSource() == ellipsoidItem)
|
{
|
makeSomething(new Sphere());
|
} else
|
if (event.getSource() == coneItem)
|
{
|
makeSomething(new Cone());
|
} else
|
if (event.getSource() == torusItem)
|
{
|
makeSomething(new Torus());
|
} else
|
if (event.getSource() == superItem)
|
{
|
makeSomething(new Superellipsoid());
|
} else
|
if (event.getSource() == blobItem)
|
{
|
Blob blob = new Blob();
|
BlobComponent comp = new BlobComponent();
|
blob.addChild(comp);
|
//blob.retile();
|
makeSomething(blob);
|
} else
|
if (event.getSource() == latheItem)
|
{
|
makeSomething(new Lathe());
|
} else
|
if (event.getSource() == bezierItem)
|
{
|
makeSomething(new BezierSurface());
|
} else
|
if (event.getSource() == checkerItem)
|
{
|
/*
|
Object3D obj = new BezierSurface(5,8);
|
|
//obj.toParent = LA.newMatrix();
|
LA.matScale(obj.toParent, 1.6,1,1);
|
LA.matScale(obj.toParent, 0.03,1,0.03);
|
LA.matXRotate(obj.toParent, Math.PI/2);
|
LA.matTranslate(obj.toParent, 0,0,-0.1);
|
LA.matConcat(obj.toParent, cameraView.renderCamera.fromParent, obj.toParent);
|
LA.matInvert(obj.toParent, obj.fromParent);
|
*/
|
makeSomething(new Checker());
|
} else
|
if (event.getSource() == meshItem)
|
{
|
Object3D itemtomake = new Object3D();
|
Object3D child;
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
child = (Object3D)group.selection.elementAt(i);
|
cMesh s = new cMesh(child);
|
// s.setup();
|
//if (child.count > 0)
|
// child.count -= 1;
|
child.DecCount();
|
//makeSomething(s);
|
itemtomake.add(s);
|
}
|
for (int i=0; i<itemtomake.size(); i++)
|
{
|
child = (Object3D)itemtomake.elementAt(i);
|
makeSomething(child);
|
}
|
} else
|
if (event.getSource() == springItem)
|
{
|
cSpring s = new cSpring();
|
s.setup();
|
makeSomething(s);
|
} else
|
if (event.getSource() == flagItem)
|
{
|
cSpring s = new cFlag();
|
s.setup();
|
makeSomething(s);
|
} else
|
if (event.getSource() == lightItem)
|
{
|
makeSomething(new Light());
|
} else
|
if (event.getSource() == csgItem)
|
{
|
group(new CSG());
|
} else
|
if (event.getSource() == templateItem)
|
{
|
group(new cTemplate());
|
} else
|
if (event.getSource() == attributeItem)
|
{
|
makeSomething(new Attribute());
|
} else
|
if (event.getSource() == pointflowItem)
|
{
|
makeSomething(new PointFlow());
|
} else
|
/*
|
if (event.getSource() == textureItem)
|
{
|
makeSomething(new Texture());
|
//return true;
|
} else
|
*/
|
|
if (event.getSource() == superLoopItem)
|
{
|
Composite g = new cGroup();
|
for (int i=0; i<15; i++)
|
{
|
for (int j=0; j<15; j++)
|
{
|
Superellipsoid s = new Superellipsoid();
|
s.east = i+0.0000001;
|
s.east = Math.pow(s.east/4,1.0);
|
s.north = j+0.0000001;
|
s.north = Math.pow(s.north/4,1.0);
|
s.recalculate();
|
LA.matTranslate(s.toParent, i*2, 0, j*2);
|
LA.matInvert(s.toParent, s.fromParent);
|
|
g.addChild(s);
|
}
|
}
|
|
group(g);
|
} else
|
if (event.getSource() == loopItem)
|
{
|
Composite csg = new GroupLeaf();
|
csg.count = 5;
|
group(csg);
|
Composite child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
} else
|
if (event.getSource() == doubleItem)
|
{
|
Composite csg = new GroupLeaf();
|
csg.count = 5;
|
group(csg);
|
Composite child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
} else
|
if (event.getSource() == tripleItem)
|
{
|
Composite csg = new GroupLeaf();
|
csg.count = 4;
|
group(csg);
|
Composite child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
child = new cGroup();
|
csg.addChild(child);
|
child.addChild(csg);
|
} else
|
|
if (event.getSource() == importGFDItem)
|
{
|
ImportGFD();
|
} else
|
if (event.getSource() == importVRMLX3DItem)
|
{
|
ImportVRMLX3D();
|
} else
|
if (event.getSource() == import3DSItem)
|
{
|
objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
|
} else
|
if (event.getSource() == importOBJItem)
|
{
|
objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
|
} else
|
if (event.getSource() == computeAOItem)
|
{
|
CameraPane.drawMode = CameraPane.OCCLUSION;
|
CameraPane.theRenderer.repaint();
|
} else
|
if (event.getSource() == recompileItem)
|
{
|
Recompile();
|
refreshContents();
|
} else
|
if (event.getSource() == editScriptItem)
|
{
|
OpenDialog();
|
refreshContents();
|
} else
|
if (event.getSource() == invariantsItem)
|
{
|
System.out.println("Invariants:");
|
GrafreeD.theApplet3D.universe.invariants();
|
} else
|
if (event.getSource() == memoryItem)
|
{
|
//System.out.println("Invariants:");
|
PrintMemory();
|
} else
|
if (event.getSource() == pathItem)
|
{
|
PrintPath();
|
} else
|
if (event.getSource() == analyzeItem)
|
{
|
AnalyzeObject();
|
} else
|
if (event.getSource() == dumpItem)
|
{
|
DumpObject();
|
} else
|
if (event.getSource() == screenfitButton)
|
{
|
//Reload(lastConverter, lastFilename, true);
|
ScreenFit();
|
} else
|
if (event.getSource() == screenfitpointButton)
|
{
|
//Reload(lastConverter, lastFilename, true);
|
ScreenFitPoint();
|
} else
|
if (event.getSource() == snapobjectButton)
|
{
|
//Reload(lastConverter, lastFilename, true);
|
SnapObject();
|
} else
|
// if (event.getSource() == recompileButton)
|
// {
|
// // CameraPane.textures.clear();
|
// Recompile();
|
// refreshContents();
|
// } else
|
if (event.getSource() == gcButton)
|
{
|
System.out.println("Memory (F/T/M) : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() + "/" + Runtime.getRuntime().maxMemory());
|
System.gc();
|
System.out.println("GC Memory (F/T/M) : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() + "/" + Runtime.getRuntime().maxMemory());
|
} else
|
if (event.getSource() == editLeafItem)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
if (obj instanceof GroupLeaf)
|
{
|
EditObject(((GroupLeaf)obj).get(-1));
|
}
|
}
|
refreshContents(true);
|
} else
|
if (event.getSource() == openWindowItem)
|
{
|
EditSelection(true);
|
} else
|
if (event.getSource() == cutItem || event.getSource() == clearButton)
|
{
|
loadClipboard(true);
|
} else
|
if (event.getSource() == duplicateItem)
|
{
|
Object3D keep = GrafreeD.clipboard;
|
loadClipboard(false);
|
paste(false);
|
GrafreeD.clipboard = keep;
|
} else
|
if (event.getSource() == cloneItem)
|
{
|
CloneSelection(false);
|
} else
|
if (event.getSource() == cloneSupportItem)
|
{
|
CloneSelection(true);
|
} else
|
if (event.getSource() == copyItem)
|
{
|
loadClipboard(false);
|
} else
|
if (event.getSource() == pasteItem)
|
{
|
paste(false);
|
} else
|
if (event.getSource() == pasteLinkItem)
|
{
|
pasteInto(false);
|
} else
|
if (event.getSource() == pasteCloneItem)
|
{
|
pasteInto(true);
|
} else
|
if (event.getSource() == pasteExpandItem)
|
{
|
paste(true);
|
} else
|
if (event.getSource() == synchronizeItem)
|
{
|
Overwrite(Object3D.TRANSFORM);
|
} else
|
if (event.getSource() == overwriteNameItem)
|
{
|
Overwrite(Object3D.NAME);
|
} else
|
if (event.getSource() == overwriteUVItem)
|
{
|
Overwrite(Object3D.UV);
|
} else
|
if (event.getSource() == overwriteMatItem)
|
{
|
/* july 2015
|
if ((dropAttributes & Object3D.TEXTURE) == 0)
|
Overwrite(Object3D.MATERIAL | Object3D.COLOR);
|
else
|
{
|
if ((dropAttributes & Object3D.COLOR) == 0 && (dropAttributes & Object3D.MATERIAL) == 0)
|
{
|
Overwrite(Object3D.TEXTURE);
|
}
|
else
|
{
|
Overwrite(Object3D.MATERIAL | Object3D.TEXTURE);
|
}
|
}
|
*/
|
|
Overwrite(dropAttributes);
|
}
|
if (event.getSource() == overwriteGeoItem)
|
{
|
Overwrite(Object3D.GEOMETRY);
|
// if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
|
// {
|
// Object3D content = GrafreeD.clipboard.get(0);
|
//
|
// if (content instanceof cGroup && ((cGroup)content).transientlink )
|
// content = ((cGroup)content).get(0);
|
//
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// group.selection.get(i).overwriteThis(content);
|
// }
|
// refreshContents();
|
// }
|
} else
|
if (event.getSource() == generateMeshItem)
|
{
|
//if (group.selection.size() == 1)
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// group.selection.get(i).generateMeshes();
|
// }
|
group.selection.generateMeshes();
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == extractGeometriesItem)
|
{
|
boolean one = false;
|
|
if (group.selection.size() == 1)
|
one = true;
|
|
Object3D content = new cGroup();
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
Object3D newgroup = new Object3D(sel.name);
|
sel.ExtractGeometries(newgroup, false);
|
if (one)
|
makeSomething(newgroup.get(0), false);
|
else
|
content.addChild(newgroup.get(0));
|
}
|
|
if (!one)
|
makeSomething(content, false);
|
|
//group.selection.ExtractGeometries();
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == cloneGeometriesItem)
|
{
|
boolean one = false;
|
|
if (group.selection.size() == 1)
|
one = true;
|
|
Object3D content = new cGroup();
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
Object3D newgroup = new Object3D(sel.name);
|
sel.ExtractGeometries(newgroup, true);
|
if (one)
|
makeSomething(newgroup.get(0), false);
|
else
|
content.addChild(newgroup.get(0));
|
}
|
|
if (!one)
|
makeSomething(content, false);
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == shareGeometriesItem)
|
{
|
boolean one = false;
|
|
if (group.selection.size() == 1)
|
one = true;
|
|
Object3D content = new cGroup();
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = new Merge(group.selection.get(i));
|
|
if (one)
|
makeSomething(sel, false);
|
else
|
content.addChild(sel);
|
}
|
|
if (!one)
|
makeSomething(content, false);
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == mergeGeometriesItem)
|
{
|
boolean one = false;
|
|
if (group.selection.size() == 1)
|
one = true;
|
|
Object3D content = new cGroup();
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
Object3D newgroup = new Object3D(sel.name);
|
cMesh mesh = new cMesh(sel);
|
mesh.setup();
|
mesh.ExtractGeometries(newgroup, false);
|
newgroup.get(0).bRep.Stripify();
|
newgroup.get(0).bRep.Untrim();
|
if (one)
|
makeSomething(newgroup.get(0), false);
|
else
|
content.addChild(newgroup.get(0));
|
}
|
|
if (!one)
|
makeSomething(content, false);
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == linkverticesItem)
|
{
|
// if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
|
// {
|
// Object3D content = GrafreeD.clipboard.get(0);
|
//
|
// if (content instanceof cGroup && ((cGroup)content).transientlink )
|
// content = ((cGroup)content).get(0);
|
//
|
// group.selection.get(0).linkVerticesThis(content);
|
// group.selection.get(0).setMasterThis(content); // should be identity
|
// refreshContents();
|
// }
|
if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
|
{
|
Object3D content = GrafreeD.clipboard.get(0);
|
|
if (content instanceof cGroup && ((cGroup)content).transientlink )
|
content = ((cGroup)content).get(0);
|
|
CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
boolean random = CameraPane.RANDOM;
|
CameraPane.RANDOM = false; // parse all random nodes
|
group.selection.get(i).linkVerticesThis(content);
|
// group.selection.get(i).setMasterThis(content); // should be identity
|
CameraPane.RANDOM = random;
|
}
|
CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
|
refreshContents();
|
}
|
} else
|
if (event.getSource() == resetsupportItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
boolean random = CameraPane.RANDOM;
|
CameraPane.RANDOM = false; // parse all random nodes
|
group.selection.get(i).linkVerticesThis(null);
|
CameraPane.RANDOM = random;
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == resetreferencesItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
group.selection.get(i).ClearReferences();
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == setMasterItem)
|
{
|
if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
|
{
|
Object3D content = GrafreeD.clipboard.get(0);
|
|
if (content instanceof cGroup && ((cGroup)content).transientlink )
|
content = ((cGroup)content).get(0);
|
|
group.selection.get(0).setMasterThis(content, false);
|
refreshContents();
|
}
|
} else
|
if (event.getSource() == poseMeshItem)
|
{
|
if (group.selection.size() == 1)
|
{
|
if (GrafreeD.clipboard.size() == 1)
|
{
|
Object3D content = GrafreeD.clipboard.get(0);
|
|
if (content instanceof cGroup && ((cGroup)content).transientlink )
|
content = ((cGroup)content).get(0);
|
|
group.selection.get(0).poseMeshThis(content);
|
}
|
else
|
group.selection.get(0).poseMeshThis(null);
|
refreshContents();
|
}
|
|
} else
|
if (event.getSource() == revertMeshItem)
|
{
|
RevertMeshes();
|
} else
|
if (event.getSource() == resetMeshItem)
|
{
|
ResetAll();
|
} else
|
if (event.getSource() == stepAllItem)
|
{
|
StepAll();
|
} else
|
if (event.getSource() == clearItem) // || event.getSource() == clearButton)
|
{
|
//int indices[] = jList.getSelectedIndices();
|
//for (int i = indices.length - 1; i >= 0; i--)
|
//objList.remove(indices[i]);
|
|
ClearSelection(false);
|
} else
|
if (event.getSource() == clearAllItem)
|
{
|
ClearSelection(true);
|
} else
|
if (event.getSource() == grabItem)
|
{
|
group(new cGroup(), true);
|
} else
|
if (event.getSource() == frontItem)
|
{
|
front();
|
} else
|
if (event.getSource() == backItem)
|
{
|
back();
|
} else
|
if (event.getSource() == cameraItem)
|
{
|
makeSomething(new Camera());
|
} else
|
if (event.getSource() == compositeItem)
|
{
|
group(new Composite());
|
} else
|
if (event.getSource() == randomItem)
|
{
|
RandomNode random = new RandomNode();
|
group(random);
|
if (random.size() > 0)
|
random.name = random.get(0).name + "Rnd";
|
} else
|
if (event.getSource() == physicsItem)
|
{
|
group(new PhysicsNode());
|
} else
|
if (event.getSource() == frameselectorItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
|
if (sel instanceof Mocap)
|
makeSomething(new FrameSelector((Mocap) sel), false);
|
}
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == switchGeoItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
|
makeSomething(new SwitchNode(sel, Object3D.GEOMETRY), false);
|
}
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == switchTransfoItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
|
makeSomething(new SwitchNode(sel, Object3D.TRANSFORM), false);
|
}
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == morphItem)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
|
makeSomething(new MorphNode(sel), false);
|
}
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == scriptNodeItem)
|
{
|
boolean atleastone = false;
|
|
if (group.selection.size() > 0)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D sel = group.selection.get(i);
|
|
if (sel instanceof ScriptNode)
|
{
|
ScriptNode ssn = (ScriptNode) sel;
|
|
String file = GetFile("Replace Script");
|
|
ScriptNode sn = new ScriptNode(file);
|
|
ssn.filename = sn.filename;
|
ssn.name = sn.name;
|
|
atleastone = true;
|
}
|
}
|
}
|
|
if (group.selection.size() == 0 || !atleastone)
|
{
|
String file = GetFile("Attach Script");
|
|
if (file != null)
|
{
|
makeSomething(new ScriptNode(file), false);
|
|
ResetModel();
|
refreshContents();
|
}
|
}
|
} else
|
if (event.getSource() == linkerItem)
|
{
|
group(new cLinker());
|
} else
|
if (event.getSource() == textureItem)
|
{
|
group(new TextureNode());
|
} else
|
if (event.getSource() == shadowXItem)
|
{
|
CastShadow(0);
|
} else
|
if (event.getSource() == shadowYItem)
|
{
|
CastShadow(1);
|
} else
|
if (event.getSource() == shadowZItem)
|
{
|
CastShadow(2);
|
} else
|
if (event.getSource() == ungroupItem)
|
{
|
ungroup();
|
} else
|
if (event.getSource() == genUVItem)
|
{
|
GenUV();
|
} else
|
if (event.getSource() == genNormalsCADItem)
|
{
|
GenNormals(true);
|
} else
|
if (event.getSource() == genNormalsMESHItem)
|
{
|
GenNormals(true); // TODO
|
} else
|
if (event.getSource() == genNormalsORGANItem)
|
{
|
GenNormals(false);
|
} else
|
if (event.getSource() == stripifyItem)
|
{
|
Stripify();
|
} else
|
if (event.getSource() == unstripifyItem)
|
{
|
Unstripify();
|
} else
|
if (event.getSource() == trimItem)
|
{
|
Trim();
|
} else
|
if (event.getSource() == untrimItem)
|
{
|
Untrim();
|
} else
|
if (event.getSource() == clearColorsItem)
|
{
|
ClearColors();
|
} else
|
if (event.getSource() == clearMaterialsItem)
|
{
|
ClearMaterials();
|
} else
|
if (event.getSource() == liveleavesItem)
|
{
|
LiveLeaves(true);
|
} else
|
if (event.getSource() == unliveleavesItem)
|
{
|
LiveLeaves(false);
|
} else
|
if (event.getSource() == supportleavesItem)
|
{
|
SupportLeaves(true);
|
} else
|
if (event.getSource() == unsupportleavesItem)
|
{
|
SupportLeaves(false);
|
} else
|
if (event.getSource() == hideleavesItem)
|
{
|
HideLeaves(true);
|
} else
|
if (event.getSource() == showleavesItem)
|
{
|
HideLeaves(false);
|
} else
|
if (event.getSource() == markleavesItem)
|
{
|
MarkLeaves(true);
|
} else
|
if (event.getSource() == unmarkleavesItem)
|
{
|
MarkLeaves(false);
|
} else
|
if (event.getSource() == flipVItem)
|
{
|
FlipV(true);
|
} else
|
if (event.getSource() == unflipVItem)
|
{
|
FlipV(false);
|
} else
|
if (event.getSource() == lowTexturesItem)
|
{
|
SetTexRes(0);
|
} else
|
if (event.getSource() == normalTexturesItem)
|
{
|
SetTexRes(1);
|
} else
|
if (event.getSource() == highTexturesItem)
|
{
|
SetTexRes(2);
|
} else
|
if (event.getSource() == veryhighTexturesItem)
|
{
|
SetTexRes(3);
|
} else
|
if (event.getSource() == maxTexturesItem)
|
{
|
SetTexRes(4);
|
} else
|
if (event.getSource() == panoTexturesItem)
|
{
|
SetTexRes(5);
|
} else
|
if (event.getSource() == reverseNormalsItem)
|
{
|
ReverseNormals();
|
} else
|
if (event.getSource() == parseverticesItem)
|
{
|
ParseVertices();
|
} else
|
if (event.getSource() == textureFieldItem)
|
{
|
TextureVertices();
|
} else
|
if (event.getSource() == alignItem)
|
{
|
Align();
|
} else
|
if (event.getSource() == mirrorItem)
|
{
|
MirrorPoses();
|
} else
|
if (event.getSource() == reduceMorphItem)
|
{
|
MeshReduction(false);
|
} else
|
if (event.getSource() == reduce34MorphItem)
|
{
|
MeshReduction(true);
|
} else
|
if (event.getSource() == reverseTrianglesItem)
|
{
|
ReverseTriangles();
|
} else
|
if (event.getSource() == reduceMeshItem)
|
{
|
ReduceMesh(false);
|
} else
|
if (event.getSource() == reduce34MeshItem)
|
{
|
ReduceMesh(true);
|
} else
|
if (event.getSource() == increaseMeshItem)
|
{
|
IncreaseMesh();
|
} else
|
if (event.getSource() == clipMeshItem)
|
{
|
ClipMesh();
|
} else
|
if (event.getSource() == smoothMeshItem)
|
{
|
SmoothMesh();
|
} else
|
if (event.getSource() == transformgeometryItem)
|
{
|
TransformGeometry();
|
} else
|
if (event.getSource() == resetTransformItem)
|
{
|
ResetTransform();
|
} else
|
if (event.getSource() == resetCentroidItem)
|
{
|
ResetCentroid();
|
} else
|
if (event.getSource() == resetParentItem)
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D obj = (Object3D)e.nextElement();
|
obj.parent = null;
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == repairParentItem)
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D obj = (Object3D)e.nextElement();
|
obj.RepairParent();
|
// for (int i=0; i<obj.size(); i++)
|
// {
|
// obj.get(i).parent = obj;
|
// }
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == sortbysizeItem)
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D obj = (Object3D)e.nextElement();
|
|
obj.SortBySize();
|
}
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == sortbynameItem)
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D obj = (Object3D)e.nextElement();
|
|
obj.SortByName();
|
}
|
|
ResetModel();
|
refreshContents();
|
} else
|
if (event.getSource() == attachPigmentItem)
|
{
|
String texture = GetFile("Attach pigment");
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.SetPigmentTexture(texture);
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == detachPigmentItem)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.ResetPigmentTexture();
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == attachBumpItem)
|
{
|
String texture = GetFile("Attach bump");
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.SetBumpTexture(texture);
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == detachBumpItem)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.SetBumpTexture(null);
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == pigmentBumpItem)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.SetBumpTexture(obj.GetPigmentTexture());
|
}
|
|
refreshContents();
|
} else
|
if (event.getSource() == flashSelectionButton)
|
{
|
CameraPane.flash = true;
|
refreshContents();
|
} else
|
if (event.getSource() == oneButton)
|
{
|
} else
|
if (event.getSource() == twoButton)
|
{
|
radio.layout = twoButton;
|
// bug
|
//gridPanel.setDividerLocation(1.0);
|
//bigPanel.setDividerLocation(0.0);
|
bigThree.remove(jtp);
|
bigThree.remove(cameraPanel);
|
bigThree.remove(XYZPanel);
|
aWindowConstraints.gridx = 0;
|
aWindowConstraints.gridy = 0;
|
aWindowConstraints.gridwidth = 1;
|
// aConstraints.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);
|
bigThree.revalidate();
|
} else
|
if (event.getSource() == threeButton)
|
{
|
radio.layout = threeButton;
|
bigThree.remove(jtp);
|
bigThree.remove(cameraPanel);
|
bigThree.remove(XYZPanel);
|
aWindowConstraints.gridx = 0;
|
aWindowConstraints.gridy = 0;
|
aWindowConstraints.gridwidth = 1;
|
// aConstraints.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;
|
aConstraints.fill = GridBagConstraints.VERTICAL;
|
bigThree.add(XYZPanel, aWindowConstraints);
|
bigThree.revalidate();
|
} else
|
if (event.getSource() == fourButton)
|
{
|
radio.layout = fourButton;
|
bigThree.remove(jtp);
|
bigThree.remove(cameraPanel);
|
bigThree.remove(XYZPanel);
|
aWindowConstraints.gridx = 0;
|
aWindowConstraints.gridy = 0;
|
aWindowConstraints.gridwidth = 1;
|
// aWindowConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.BOTH;
|
aWindowConstraints.weightx = 1;
|
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;
|
// aWindowConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.VERTICAL;
|
//bigThree.add(XYZPanel, aWindowConstraints);
|
bigThree.revalidate();
|
} else
|
if (event.getSource() == sixButton)
|
{
|
radio.layout = sixButton;
|
bigThree.remove(jtp);
|
bigThree.remove(cameraPanel);
|
bigThree.remove(XYZPanel);
|
aWindowConstraints.gridx = 0;
|
aWindowConstraints.gridy = 0;
|
aWindowConstraints.gridwidth = 1;
|
// aConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.VERTICAL;
|
aWindowConstraints.weightx = 0;
|
aWindowConstraints.weighty = 1;
|
bigThree.add(jtp, aWindowConstraints);
|
aWindowConstraints.weightx = 1;
|
aWindowConstraints.gridwidth = 3;
|
// aWindowConstraints.gridheight = 3;
|
aWindowConstraints.gridx = 1;
|
aWindowConstraints.fill = GridBagConstraints.BOTH;
|
bigThree.add(cameraPanel, aWindowConstraints);
|
aWindowConstraints.weightx = 0;
|
aWindowConstraints.gridx = 4;
|
aWindowConstraints.gridwidth = 1;
|
// aWindowConstraints.gridheight = 3;
|
aWindowConstraints.fill = GridBagConstraints.VERTICAL;
|
//bigThree.add(XYZPanel, aConstraints);
|
bigThree.revalidate();
|
} else
|
if (event.getSource() == sevenButton)
|
{
|
radio.layout = sevenButton;
|
bigThree.remove(jtp);
|
bigThree.remove(cameraPanel);
|
bigThree.remove(XYZPanel);
|
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;
|
// aWindowConstraints.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);
|
bigThree.revalidate();
|
} else
|
if (event.getSource() == rootButton)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
//if (obj != client)
|
EditObject(obj);
|
}
|
|
refreshContents(true);
|
} else
|
if (event.getSource() == closeButton)
|
{
|
//System.out.println("CLOSE: " + buttonGroup.getSelection());
|
cRadio ab;
|
for (Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
|
{
|
ab = (cRadio)e.nextElement();
|
if(ab.getModel().isSelected() && ab.GetObject() != client)
|
{
|
buttonGroup.remove(ab);
|
radioPanel.remove(ab);
|
|
ab.GetObject().editWindow = null;
|
// ab.GetObject().objectUI = null; // ?????????
|
|
((cRadio)radioPanel.getComponent(radioPanel.getComponentCount() - 1)).doClick();
|
break;
|
}
|
}
|
refreshContents(true);
|
} else
|
if (event.getSource() == editItem || event.getSource() == editButton)
|
{
|
EditSelection(false);
|
} else
|
if (event.getSource() == uneditButton)
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D child = (Object3D)e.nextElement();
|
if(child.editWindow != null)
|
objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
|
child.CloseUI();
|
listUI.remove(child);
|
|
child.editWindow = null; // ???????????
|
}
|
objEditor.ctrlPanel.revalidate();
|
//objEditor.jTree.clearSelection();
|
//objEditor.ResetSliders();
|
refreshContents(true);
|
} else
|
if (event.getSource() == clearPanelButton)
|
{
|
assert(copy == group);
|
//copy.ClearUI();
|
for (Object3D obj : listUI)
|
{
|
obj.CloseUI();
|
}
|
listUI.clear();
|
refreshContents(true);
|
} else
|
if (event.getSource() == allParamsButton)
|
{
|
assert(copy == group);
|
|
objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
|
|
for (Object3D obj : listUI)
|
{
|
obj.CloseUI();
|
}
|
|
allparams ^= true;
|
|
for (Object3D elem : listUI)
|
{
|
elem.openEditWindow(this, false);
|
elem.editWindow.refreshContents(true);
|
}
|
|
refreshContents(true);
|
} else
|
if (event.getSource() == unselectButton)
|
{
|
objEditor.jTree.clearSelection();
|
// ?? oct 2012 GrafreeD.clipboard.clear();
|
objEditor.ResetSliders();
|
refreshContents(true);
|
} else
|
if(event.getSource() instanceof cRadio)
|
{
|
group.parent = keepparent;
|
group.attributes = 0;
|
//group.editWindow = null;
|
/*cRadio*/ radio = (cRadio)event.getSource();
|
Object3D obj = radio.GetObject();
|
System.out.println("Edit " + obj);
|
if (true) // obj instanceof Composite) // obj.parent == null) // obj instanceof Composite)
|
{
|
group = //(Composite)
|
obj; // to do !!
|
}
|
else
|
{
|
group = new cGroup();
|
group.name = "TEMP";
|
//group.attributes = -1;
|
//group.parent = obj.parent;
|
LA.matCopy(obj.parent.GlobalTransformInv(), group.toParent);
|
LA.matCopy(obj.parent.GlobalTransform(), group.fromParent);
|
group.add(obj);
|
}
|
|
copy = group;
|
//CameraPane.theRenderer.object = group;
|
if(!useclient)
|
{
|
cameraView.renderCamera = radio.camera;
|
cameraView.manipCamera = radio.camera;
|
cameraView.eyeCamera = radio.camera;
|
cameraView.cameras[cameraView.cameracount] = radio.camera;
|
cameraView.targetLookAt.set(radio.camera.lookAt);
|
cameraView.object = group;
|
cameraView.lighttouched = true;
|
topView.object = group;
|
frontView.object = group;
|
sideView.object = group;
|
}
|
group.editWindow = this;
|
/*
|
currentLayout = radio.layout;
|
if (currentLayout == null)
|
currentLayout = sevenButton;
|
*/
|
radio.layout.doClick();
|
keepparent = group.parent;
|
// PARENT = NULL or not???
|
//group.parent = null; // ROOT
|
//group.attributes = -1;
|
ResetModel();
|
refreshContents(true);
|
}
|
else
|
{
|
//return super.action(event, arg);
|
super.actionPerformed(event);
|
}
|
}
|
|
boolean useclient = false;
|
cRadio radio;
|
|
void ToggleRoot()
|
{
|
useclient ^= true;
|
|
if (useclient)
|
{
|
cameraView.object = client;
|
cameraView.lighttouched = true;
|
//topView.object = client;
|
//frontView.object = client;
|
//sideView.object = client;
|
}
|
else
|
{
|
cameraView.object = group;
|
cameraView.lighttouched = true;
|
//topView.object = group;
|
//frontView.object = group;
|
//sideView.object = group;
|
}
|
|
refreshContents();
|
}
|
|
Object3D /*Composite*/ keepparent;
|
|
//TransformGeometry
|
void TransformGeometry()
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
obj.KeepTextureMatrices();
|
obj.TransformGeometry();
|
obj.RestoreTextureMatrices();
|
|
// if (obj.parent == null)
|
// {
|
// System.out.println("NULL PARENT!");
|
// new Exception().printStackTrace();
|
// }
|
// else
|
// TouchTransform(obj);
|
// //obj.parent.Touch();
|
}
|
|
refreshContents();
|
}
|
|
|
void ResetTransform()
|
{
|
ResetTransform(-1);
|
}
|
|
void ResetTransform(int mask)
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
if (obj.toParent == null)
|
continue;
|
|
if (mask == -1)
|
{
|
if (obj instanceof Camera) // jan 2014
|
{
|
LA.matIdentity(obj.toParent);
|
LA.matIdentity(obj.fromParent);
|
}
|
else
|
{
|
obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
|
obj.fromParent = null; // LA.matIdentity(obj.fromParent);
|
}
|
TouchTransform(obj);
|
continue;
|
}
|
if ((mask&2) != 0) // Scale
|
{
|
obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
|
obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
|
obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
|
obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
|
obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
|
obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
|
}
|
if ((mask&4) != 0) // Rotation
|
{
|
// ?
|
}
|
if ((mask&1) != 0) // Translation
|
{
|
if (obj.toParent != null)
|
{
|
obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
|
obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
|
}
|
}
|
if (obj.parent == null)
|
{
|
System.out.println("NULL PARENT!");
|
// new Exception().printStackTrace();
|
}
|
else
|
TouchTransform(obj);
|
//obj.parent.Touch();
|
}
|
|
refreshContents();
|
}
|
|
void TouchTransform(Object3D obj)
|
{
|
// june 2014
|
if (obj.parent == null)
|
return;
|
|
if (obj.parent instanceof BezierPatch)
|
{
|
((BezierSurface)obj.parent.parent).currentHandle = (Sphere)obj;
|
obj.parent.parent.recalculate();
|
obj.parent.Touch();
|
}
|
else
|
obj.parent.Touch();
|
}
|
|
void FlipTransform()
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
System.out.println("flip " + obj);
|
LA.matIdentity(Object3D.mat);
|
Object3D.mat[0][0] = -1;
|
|
if (obj.toParent == null)
|
{
|
obj.toParent = LA.newMatrix();
|
obj.fromParent = LA.newMatrix();
|
}
|
|
LA.matConcat(Object3D.mat, obj.fromParent, obj.fromParent);
|
LA.matInvert(obj.fromParent, obj.toParent);
|
if (obj.parent == null)
|
{
|
System.out.println("NULL PARENT!");
|
new Exception().printStackTrace();
|
}
|
else
|
TouchTransform(obj);
|
//obj.parent.Touch();
|
}
|
|
refreshContents();
|
}
|
|
void ResetCentroid()
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
System.out.println("reset centroid: " + obj);
|
if (obj.toParent == null)
|
{
|
obj.toParent = LA.newMatrix();
|
obj.fromParent = LA.newMatrix();
|
}
|
LA.matIdentity(Object3D.mat);
|
obj.getBounds(minima, maxima, false);
|
Object3D.mat[3][0] = -(minima.x + maxima.x)/2;
|
Object3D.mat[3][1] = -(minima.y + maxima.y)/2;
|
Object3D.mat[3][2] = -(minima.z + maxima.z)/2;
|
obj.TransformMesh(Object3D.mat);
|
Object3D.mat[3][0] = (minima.x + maxima.x)/2;
|
Object3D.mat[3][1] = (minima.y + maxima.y)/2;
|
Object3D.mat[3][2] = (minima.z + maxima.z)/2;
|
LA.matConcat(Object3D.mat, obj.toParent, obj.toParent);
|
//Object3D.mat[3][0] = -Object3D.mat[3][0];
|
//Object3D.mat[3][1] = -Object3D.mat[3][1];
|
//Object3D.mat[3][2] = -Object3D.mat[3][2];
|
LA.matInvert(obj.toParent, obj.fromParent);
|
if (obj.parent == null)
|
{
|
System.out.println("NULL PARENT!");
|
new Exception().printStackTrace();
|
}
|
else
|
obj.parent.Touch();
|
}
|
|
refreshContents();
|
}
|
|
void PrintMemory()
|
{
|
try
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
int size = obj.MemorySize();
|
|
System.err.println((size/1024) + " KB is the size of " + obj);
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
void PrintPath()
|
{
|
try
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
CameraPane.PrintFromTos(obj);
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
void AnalyzeObject()
|
{
|
try
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
System.out.println("Object is: " + obj);
|
GrafreeD.AnalyzeObject(obj);
|
System.out.println("Boundary rep: " + obj.bRep);
|
GrafreeD.AnalyzeObject(obj.bRep);
|
|
// System.err.println((size/1024) + " KB is the size of " + obj);
|
}
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
void DumpObject()
|
{
|
Object3D obj;
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
obj = (Object3D)e.nextElement();
|
|
obj.Dump(true);
|
|
// System.err.println((size/1024) + " KB is the size of " + obj);
|
}
|
}
|
|
void ClearSelection(boolean all)
|
{
|
group.ClearSelection(all);
|
|
ResetModel();
|
refreshContents();
|
}
|
|
void GenUV()
|
{
|
group.GenUVS();
|
|
refreshContents();
|
}
|
|
void GenNormals(boolean crease)
|
{
|
group.GenNormalsS(crease);
|
|
refreshContents();
|
}
|
|
void Stripify()
|
{
|
group.StripifyS();
|
|
refreshContents();
|
}
|
|
void Unstripify()
|
{
|
group.UnstripifyS();
|
|
refreshContents();
|
}
|
|
void Trim()
|
{
|
group.TrimS();
|
|
refreshContents();
|
}
|
|
void Untrim()
|
{
|
group.UntrimS();
|
|
refreshContents();
|
}
|
|
void ClearColors()
|
{
|
group.ClearColorsS();
|
|
refreshContents();
|
}
|
|
void ReverseNormals()
|
{
|
group.ReverseNormalsS();
|
|
refreshContents();
|
}
|
|
//Object3D buffer;
|
cVector temp = new cVector();
|
// BoundaryRep temprep;
|
// Object3D nodes;
|
// Vector<Vertex> vertices;
|
//
|
// cGroup buffer;
|
//
|
// public void Vertex(Object3D node, Vertex v)
|
// {
|
//// vertices.add(v);
|
//// nodes.addElement(node);
|
////
|
//// if (temprep.GetCache(v) != null)
|
//// {
|
//// temprep.Remove(v);
|
//// } else
|
//// {
|
//// temprep.Remember(v);
|
//// }
|
//
|
// //Object3D node = nodes.get(index);
|
// temp.set(v); // vertices.get(index)); // temprep.GetVertex(k));
|
// // System.out.println("temp = " + temp.x + ", " + temp.y + ", " + temp.z);
|
//
|
// LA.xformPos(temp, node.GlobalTransformInv(), temp);
|
//
|
// // System.out.println("tem+ = " + temp.x + ", " + temp.y + ", " + temp.z);
|
//
|
// cGroup g = new cGroup();
|
//
|
// if (g.toParent == null)
|
// {
|
// g.toParent = LA.newMatrix();
|
// g.fromParent = LA.newMatrix();
|
// }
|
// LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
|
// LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
|
//
|
// g.add(GrafreeD.clipboard);
|
//
|
// buffer.add(g);
|
// }
|
//
|
// public void Face(Object3D node, Face f)
|
// {
|
//
|
// }
|
//
|
// void ParseVerticesOld() // ??
|
// {
|
// //if (group.selection.size() != 1)
|
// // return;
|
//
|
// temprep = new BoundaryRep();
|
// nodes = new Object3D();
|
// vertices = new Vector<Vertex>();
|
//
|
// boolean epsequal = GrafreeD.epsequal;
|
// GrafreeD.epsequal = true;
|
//
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// Object3D buffer = new cGroup(group.selection.get(i).name + "+");
|
//
|
// group.selection.get(i).Parse(
|
//this );
|
//
|
// int repsize = temprep.VertexCount();
|
// int tablesize = temprep.vertextable.size();
|
// int nodesize = nodes.size();
|
//
|
// assert(vertices.size() == nodes.size());
|
//
|
// temprep.vertextable.elements();
|
//
|
// java.util.Set<java.util.Map.Entry<Vertex,Vertex>> set = temprep.vertextable.entrySet();
|
//
|
// for (java.util.Map.Entry<Vertex,Vertex> entry : set)
|
// {
|
// cGroup g = new cGroup();
|
//
|
// int index = vertices.indexOf(entry.getValue()); // temprep.vertextable.(k));
|
//
|
// Object3D node = nodes.get(index);
|
// temp.set(vertices.get(index)); // temprep.GetVertex(k));
|
// // System.out.println("temp = " + temp.x + ", " + temp.y + ", " + temp.z);
|
//
|
// LA.xformPos(temp, node.GlobalTransformInv(), temp);
|
//
|
// // System.out.println("tem+ = " + temp.x + ", " + temp.y + ", " + temp.z);
|
//
|
// if (g.toParent == null)
|
// {
|
// g.toParent = LA.newMatrix();
|
// g.fromParent = LA.newMatrix();
|
// }
|
// LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
|
// LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
|
//
|
// g.add(GrafreeD.clipboard);
|
//
|
// buffer.add(g);
|
// }
|
//
|
// makeSomething(buffer, i==group.selection.size()-1);
|
// }
|
//
|
// GrafreeD.epsequal = epsequal;
|
//
|
// //buffer = null;
|
// temprep = null;
|
// nodes = null;
|
//
|
// refreshContents();
|
// }
|
|
void ParseVertices()
|
{
|
boolean epsequal = GrafreeD.epsequal;
|
GrafreeD.epsequal = true;
|
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
final cGroup buffer = new cGroup(group.selection.get(i).name + "+");
|
|
group.selection.get(i).Parse(
|
|
new iParse()
|
{
|
public void Vertex(Object3D node, Vertex v)
|
{
|
temp.set(v);
|
LA.xformPos(temp, node.GlobalTransformInv(), temp);
|
|
cGroup g = new cGroup();
|
|
if (g.toParent == null)
|
{
|
g.toParent = LA.newMatrix();
|
g.fromParent = LA.newMatrix();
|
}
|
LA.matTranslate(g.toParent, temp.x, temp.y, temp.z);
|
LA.matTranslate(g.fromParent, -temp.x, -temp.y, -temp.z);
|
|
g.add(GrafreeD.clipboard);
|
|
buffer.add(g);
|
}
|
|
public void Face(Object3D node, Face f)
|
{
|
|
}
|
}
|
);
|
|
makeSomething(buffer, i==group.selection.size()-1);
|
}
|
|
GrafreeD.epsequal = epsequal;
|
|
refreshContents();
|
}
|
|
void TextureVertices()
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
group.selection.get(i).Parse(
|
new iParse()
|
{
|
public void Vertex(Object3D node, Vertex v)
|
{
|
cTexture tex = node.GetTextures();
|
String pigment = Object3D.GetPigment(tex);
|
//String bump = Object3D.GetBump(tex);
|
|
com.sun.opengl.util.texture.TextureData texturedata = CameraPane.theRenderer.GetTextureData(pigment, false, node.texres);
|
|
double s = v.s;
|
|
if (s == 1)
|
s = 0;
|
|
double t = v.t;
|
|
if (t == 1)
|
t = 0;
|
|
int indexs = (int) (texturedata.getWidth() * s);
|
int indext = (int) (texturedata.getHeight() * t);
|
|
int index = indext * texturedata.getWidth() + indexs;
|
|
java.nio.ByteBuffer bytebuf = (java.nio.ByteBuffer)texturedata.getBuffer();
|
|
int slide = bytebuf.capacity() / texturedata.getWidth() / texturedata.getHeight();
|
|
float scale = bytebuf.get(index*slide) & 0xFF;
|
scale += bytebuf.get(index*slide+1) & 0xFF;
|
scale += bytebuf.get(index*slide+2) & 0xFF;
|
scale /= 3;
|
|
scale /= 0xFF;
|
// c'est quoi ca? scale /= 4;
|
|
//v.AO = scale;
|
|
v.x += v.norm.x * scale;
|
v.y += v.norm.y * scale;
|
v.z += v.norm.z * scale;
|
}
|
|
public void Face(Object3D node, Face f)
|
{
|
}
|
}
|
);
|
}
|
|
refreshContents();
|
}
|
|
void Align()
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D obj = group.selection.get(i);
|
|
LA.matTranslate(obj.toParent, i/2f, 0, 0);
|
LA.matTranslateInv(obj.fromParent, -i/2f, 0, 0);
|
}
|
|
refreshContents();
|
}
|
|
static void MirrorPoses(Object3D poses, Object3D ref, Object3D newgroup, boolean update)
|
{
|
poses.Untrim();
|
|
// ref.SaveSupports();
|
// Object3D par = ref.parent;
|
// ref.parent = null;
|
// Object3D lowres = (Object3D) GrafreeD.clone(ref);
|
// ref.parent = par;
|
// ref.RestoreSupports();
|
|
Object3D lowres = CloneObject(ref, false);
|
|
SwitchNode sn = new SwitchNode(poses, Object3D.GEOMETRY);
|
|
boolean random = CameraPane.RANDOM;
|
CameraPane.RANDOM = false; // parse all random nodes
|
lowres.linkVerticesThis(null);
|
lowres.linkVerticesThis(sn);
|
CameraPane.RANDOM = random;
|
|
System.err.flush();
|
|
System.out.println("Processing " + newgroup.name);
|
System.out.println(" reference = " + ref);
|
// for (int i=0; i<poses.size(); i++)
|
// {
|
// }
|
for (int i=0; i<sn.getNumFrames(); i++)
|
{
|
sn.child = i;
|
//if (update)
|
sn.Update();
|
lowres.resetMaster(false);
|
// lowres.SaveSupports();
|
// par = lowres.parent;
|
// lowres.parent = null;
|
// Object3D newlow = (Object3D) GrafreeD.clone(lowres);
|
Object3D newlow = CloneObject(lowres, false);
|
newlow.name = sn.switchobject.get(i).name;
|
System.out.println(" pose#" + i + " = " + newlow);
|
newgroup.addChild(newlow);
|
// lowres.parent = par;
|
// lowres.RestoreSupports();
|
}
|
}
|
|
// For morphing low-res meshes:
|
// - clipboard contains low-res mesh
|
// - selection contains high-res meshes
|
// - create a temporary switch to pose the low-res
|
// - low-res is conformed to switch (first high-res)
|
// - perform a copy of each pose
|
void MirrorPoses()
|
{
|
if (group.selection.size() != 1)
|
return;
|
|
Object3D poses = group.selection.get(0);
|
Object3D ref = GrafreeD.clipboard.get(0);
|
|
Object3D newgroup = new Object3D("Po:" + poses.name);
|
|
MirrorPoses(poses, ref, newgroup, true);
|
|
makeSomething(newgroup);
|
|
Recompile(); // ???
|
|
refreshContents();
|
}
|
|
void SetAsReduced(Object3D o)
|
{
|
if (o.bRep != null)
|
o.bRep.reduced = true;
|
|
for (int j=o.Size(); --j>=0;)
|
{
|
Object3D c = o.get(j);
|
|
SetAsReduced(c);
|
}
|
}
|
|
void MeshReduction(Object3D o, boolean reduction34)
|
{
|
// if (o.reduced)
|
// return;
|
|
if (o.bRep != null)
|
{
|
if (o.bRep.reduced)
|
return;
|
|
o.ReduceMesh(reduction34, false);
|
//o.ReduceMesh(false);
|
o.Stripify();
|
System.gc();
|
return;
|
}
|
|
for (int i=o.Size(); --i>=0;)
|
{
|
Object3D child = o.get(i);
|
|
if (child instanceof MorphNode)
|
{
|
MorphNode morph = (MorphNode) child;
|
|
Object3D group = new Object3D();
|
|
Object3D reduced = CloneObject(morph.morphobject.get(0), false);
|
|
reduced.ReduceMesh(reduction34, false);
|
//reduced.ReduceMesh(false);
|
reduced.Stripify();
|
//System.gc();
|
|
MirrorPoses(morph.morphobject, reduced, group, false);
|
|
morph.morphobject.overwriteThis(group, Object3D.GEOMETRY);
|
|
MorphNode newmorph = new MorphNode(morph.morphobject);
|
|
morph.bRep = newmorph.bRep;
|
|
SetAsReduced(morph);
|
SetAsReduced(morph.morphobject);
|
// morph.bRep.reduced = true;
|
// if (morph.morphobject.bRep != null)
|
// morph.morphobject.bRep.reduced = true;
|
// for (int j=morph.morphobject.Size(); --j>=0;)
|
// {
|
// Object3D c = morph.morphobject.get(j);
|
//
|
// if (c.bRep != null)
|
// c.bRep.reduced = true;
|
// }
|
//makeSomething(group);
|
//return;
|
}
|
else
|
if (child instanceof SwitchNode)
|
{
|
SwitchNode switchnode = (SwitchNode) child;
|
|
Object3D group = new Object3D();
|
|
Object3D reduced = CloneObject(switchnode.switchobject.get(0), false);
|
|
reduced.ReduceMesh(reduction34, false);
|
//reduced.ReduceMesh(false);
|
reduced.Stripify();
|
//System.gc();
|
|
MirrorPoses(switchnode.switchobject, reduced, group, false);
|
|
switchnode.switchobject.overwriteThis(group, Object3D.GEOMETRY);
|
|
SwitchNode newswitch = new SwitchNode(switchnode.switchobject, Object3D.GEOMETRY);
|
|
// morph.bRep = newmorph.bRep;
|
switchnode.overwriteThis(newswitch, Object3D.GEOMETRY);
|
|
SetAsReduced(switchnode);
|
SetAsReduced(switchnode.switchobject);
|
// if (switchnode.bRep != null)
|
// switchnode.bRep.reduced = true;
|
//// morph.switchobject.reduced = true;
|
// if (switchnode.switchobject.bRep != null)
|
// switchnode.switchobject.bRep.reduced = true;
|
// for (int j=switchnode.switchobject.Size(); --j>=0;)
|
// {
|
// Object3D c = switchnode.switchobject.get(j);
|
//
|
// if (c.bRep != null)
|
// c.bRep.reduced = true;
|
// }
|
}
|
else
|
MeshReduction(child, reduction34);
|
}
|
}
|
|
void ResetReducedFlag(Object3D o)
|
{
|
if (o.bRep != null)
|
o.bRep.reduced = false;
|
|
for (int i=o.Size(); --i>=0;)
|
{
|
Object3D child = o.get(i);
|
|
ResetReducedFlag(child);
|
}
|
}
|
|
void MeshReduction(boolean reduction34)
|
{
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
Object3D elem = (Object3D)group.selection.elementAt(i);
|
|
elem.resetMaster(false);
|
MeshReduction(elem, reduction34);
|
|
elem.RelinkToSupport();
|
}
|
|
refreshContents();
|
}
|
|
void ReverseTriangles()
|
{
|
group.ReverseTrianglesS();
|
|
refreshContents();
|
}
|
|
boolean reduction34;
|
|
public void run()
|
{
|
group.selection.ReduceMesh(reduction34, false);
|
group.selection.RelinkToSupport(); // july 2014
|
System.out.println("DONE.");
|
refreshContents();
|
CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
|
}
|
|
void ReduceMesh(boolean reduction34)
|
{
|
this.reduction34 = reduction34;
|
//group.RemoveOneTriangleS();
|
// group.selection.ReduceMesh(onlyone);
|
Thread thread = new Thread(this);
|
|
thread.start();
|
|
// System.out.println("DONE.");
|
// refreshContents();
|
}
|
|
void IncreaseMesh()
|
{
|
group.selection.IncreaseMesh();
|
System.out.println("DONE.");
|
refreshContents();
|
}
|
|
void ClipMesh()
|
{
|
if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
|
{
|
Object3D content = GrafreeD.clipboard.get(0);
|
|
if (content instanceof cGroup && ((cGroup)content).transientlink )
|
content = ((cGroup)content).get(0);
|
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// group.selection.get(i).ClipMesh(GrafreeD.clipboard);
|
// }
|
group.selection.ClipMesh(GrafreeD.clipboard);
|
}
|
// group.selection.ClipMesh(GrafreeD.clipboard);
|
System.out.println("DONE.");
|
refreshContents();
|
}
|
|
void SmoothMesh()
|
{
|
group.selection.SmoothMesh();
|
System.out.println("DONE.");
|
refreshContents();
|
}
|
|
void ClearMaterials()
|
{
|
group.selection.ClearMaterials();
|
refreshContents();
|
}
|
|
void FlipV(boolean flip)
|
{
|
group.selection.FlipV(flip);
|
refreshContents();
|
}
|
|
void LiveLeaves(boolean hide)
|
{
|
group.selection.LiveLeaves(hide);
|
refreshContents();
|
}
|
|
void SupportLeaves(boolean hide)
|
{
|
group.selection.SupportLeaves(hide);
|
refreshContents();
|
}
|
|
void HideLeaves(boolean hide)
|
{
|
group.selection.HideLeaves(hide);
|
refreshContents();
|
}
|
|
void MarkLeaves(boolean hide)
|
{
|
group.selection.MarkLeaves(hide);
|
refreshContents();
|
}
|
|
void SetTexRes(int tr)
|
{
|
group.selection.SetTexRes(tr);
|
refreshContents();
|
}
|
|
void RevertMeshes()
|
{
|
group.selection.RevertMeshes();
|
refreshContents();
|
}
|
void ResetAll()
|
{
|
group.selection.ResetAll();
|
refreshContents();
|
}
|
void StepAll()
|
{
|
group.selection.StepAll();
|
refreshContents();
|
}
|
|
// public void applySelf()
|
// {
|
// //group.name = nameField.getText();
|
// //objEditor.applySelf();
|
//
|
// if (group.selection == null || group.selection.size() == 0)
|
// super.applySelf();
|
// else
|
// {
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// Object3D elem = (Object3D)group.selection.elementAt(i);
|
//
|
// Object3D keep = objEditor.copy;
|
// objEditor.copy = elem;
|
// objEditor.holdon = i < group.selection.size() - 1;
|
// try
|
// {
|
// objEditor.applySelf(false);
|
// }
|
// catch (Error e)
|
// {
|
// System.out.println("PROTECTED CRASH");
|
// e.printStackTrace();
|
// }
|
// objEditor.holdon = false;
|
// objEditor.copy = keep;
|
// }
|
// }
|
// }
|
|
// void ClearMaterial()
|
// {
|
// if (group.selection.size() == 0)
|
// super.ClearMaterial();
|
// else
|
// {
|
// for (int i=0; i<group.selection.size(); i++)
|
// {
|
// Object3D elem = (Object3D)group.selection.elementAt(i);
|
//
|
// Object3D keep = copy;
|
// copy = elem;
|
// super.ClearMaterial();
|
// copy = keep;
|
// }
|
// }
|
// }
|
|
static boolean allparams = true;
|
|
static Vector<Object3D> listUI = new Vector<Object3D>();
|
|
void EditSelection(boolean newWindow)
|
{
|
// aConstraints.gridy = 0;
|
for (int i=0; i<group.selection.size(); i++)
|
{
|
//System.out.println("edit : " + objectPanel.indexOfTab("Material"));
|
//objectPanel.setEnabledAt(objectPanel.indexOfTab("Material"), false);
|
objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
|
|
Object3D elem = (Object3D)group.selection.elementAt(i);
|
if(elem != group)
|
{
|
// if (!(elem instanceof Composite))
|
// newWindow = false;
|
listUI.add(elem);
|
elem.openEditWindow(this, newWindow); //, false);
|
System.out.println("edit : " + elem);
|
elem.editWindow.refreshContents(true); // ? new
|
}
|
}
|
}
|
|
/*
|
public void Select2(Object3D child, boolean deselect)
|
{
|
assert(false);
|
//assert child.parent == group;
|
//assert group.children.indexOf(child) != -1;
|
|
//System.out.println("select : " + group + " --> " + child);
|
|
///
|
if (deselect)
|
{
|
//group.deselectAll();
|
//freeze = true;
|
objEditor.jTree.clearSelection();
|
//freeze = false;
|
}
|
|
//group.addSelectee(child);
|
|
//refreshContents();
|
///
|
|
//jList.setSelectedIndex(group.children.indexOf(child));
|
objEditor.jTree.addSelectionPath(child.GetTreePath());
|
//jTree.expandPath(child.GetTreePath());
|
}
|
*/
|
|
public void valueChanged(ListSelectionEvent e)
|
//public boolean handleEvent(Event event)
|
{
|
if (freezemodel) return;
|
|
//System.out.println("valueChanged " + e);
|
//new Exception().printStackTrace();
|
|
freezemodel = true;
|
|
//switch (event.id)
|
{
|
//case 701: // Event.LIST_SELECT
|
//case 702: // Event.LIST_DESELECT
|
group.deselectAll();
|
int indices[] = jList.getSelectedIndices();
|
for (int i=0; i < indices.length; i++)
|
{
|
Object3D child = (Object3D)group.Children().elementAt(indices[i]);
|
group.addSelectee(child);
|
}
|
|
refreshContents();
|
//return true;
|
}
|
//return super.handleEvent(event);
|
|
freezemodel = false;
|
}
|
|
boolean flashIt = true;
|
|
public void valueChanged(TreeSelectionEvent e)
|
//public boolean handleEvent(Event event)
|
{
|
if (freezemodel) return;
|
|
//System.out.println("valueChanged " + e);
|
//new Exception().printStackTrace();
|
|
freezemodel = true;
|
|
/**/
|
//switch (event.id)
|
{
|
//case 701: // Event.LIST_SELECT
|
//case 702: // Event.LIST_DESELECT
|
group.deselectAll();
|
TreePath tps[] = objEditor.jTree.getSelectionPaths();
|
objEditor.ClearInfo(); // .GetMaterial());
|
if (tps != null)
|
{
|
for (int i=0; i < tps.length; i++)
|
{
|
Object3D child = (Object3D) tps[i].getLastPathComponent();
|
|
//if (child.parent != null)
|
//child.parent.addSelectee(child);
|
group.addSelectee(child);
|
objEditor.SetMaterial(child); // .GetMaterial());
|
objEditor.AddInfo(child, this, true); // .GetMaterial());
|
System.err.println("info : " + child.GetPath());
|
}
|
}
|
else
|
{
|
objEditor.SetMaterial(group); // .GetMaterial());
|
objEditor.AddInfo(group, this, true); // .GetMaterial());
|
System.err.println("info : " + group.GetPath());
|
}
|
|
objEditor.SetText(); // jan 2014
|
|
if (flashIt && !CameraPane.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
|
CameraPane.flash = true;
|
|
if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera)
|
// a camera
|
{
|
CameraPane.camerachangeframe = 0; // don't refuse it
|
CameraPane.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
|
// CameraPane.theRenderer.renderCamera = CameraPane.theRenderer.manipCamera;
|
// CameraPane.theRenderer.eyeCamera = CameraPane.theRenderer.manipCamera;
|
}
|
|
refreshContents();
|
//return true;
|
}
|
//return super.handleEvent(event);
|
/**/
|
|
freezemodel = false;
|
}
|
|
void linkSomething(Object3D thing)
|
{
|
makeSomething(thing, true);
|
}
|
|
void linkSomething(Object3D thing, boolean resetmodel) // deselect)
|
{
|
makeSomething(thing, resetmodel); // deselect);
|
}
|
|
void makeSomething(Object3D thing)
|
{
|
objEditor.makeSomething(thing, true);
|
}
|
|
/*synchronized*/ void makeSomething2(Object3D thing, boolean resetmodel) // deselect)
|
{
|
//assert(false);
|
objEditor.makeSomething(thing, resetmodel); // deselect);
|
//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);
|
}
|
}
|
/**/
|
|
/*
|
group.addChild(thing);
|
//group.addSelectee(thing);
|
//int index = objList.getItemCount();
|
//objList.add(thing.name);
|
//objList.select(index);
|
//group.refreshEditWindow();
|
ResetModel();
|
refreshContents();
|
|
if ((thing instanceof CSG))
|
objEditor.EditSelection();
|
*/
|
}
|
|
void ResetModel2()
|
{
|
objEditor.ResetModel();
|
/*
|
group = (Composite) objEditor.client;
|
group.selectees = new Vector();
|
|
//new Exception().printStackTrace();
|
freeze = true;
|
jTree.setModel(new cTreeModel(group));
|
jTree.setCellRenderer(new cTreeModel.Renderer());
|
freeze = false;
|
//group.refreshEditWindow();
|
//refreshContents();
|
*/
|
}
|
|
void loadClipboard(boolean cut)
|
{
|
if (group.selection.isEmpty())
|
return;
|
GrafreeD.clipboardIsTempGroup = false;
|
Composite tGroup = null;
|
if (group.selection.size() > 0) // 1)
|
{
|
tGroup = new cGroup();
|
GrafreeD.clipboardIsTempGroup = true;
|
}
|
|
if (cut)
|
{
|
//int indices[] = jList.getSelectedIndices();
|
//for (int i = indices.length - 1; i >= 0; i--)
|
//jList.remove(indices[i]);
|
|
while (group.selection.size() > 0)
|
{
|
Object3D child = (Object3D)group.selection.elementAt(0);
|
//Composite tmp = new cGroup();
|
Object3D tmp = child; // new cGroup();
|
/*
|
if(child == group)
|
{
|
group.selectees.remove(child);
|
continue;
|
}
|
*/
|
//tmp.fromParent = child.parent.GlobalTransform();
|
if(child.parent!=null && !LA.isIdentity(child.parent.GlobalTransform()))
|
{
|
tmp = new cGroup();
|
tmp.toParent = LA.newMatrix();
|
tmp.fromParent = LA.newMatrix();
|
((cGroup)tmp).transientlink = true;
|
LA.matCopy(child.parent.GlobalTransform(), tmp.fromParent);;
|
LA.matInvert(tmp.fromParent, tmp.toParent);
|
}
|
group.removeChild(child);
|
if(true) // !LA.isIdentity(tmp.fromParent))
|
{
|
// LA.matInvert(tmp.fromParent, tmp.toParent);
|
if (tmp != child)
|
tmp.add/*Child*/(child); // ???
|
//System.out.println("cut " + child);
|
//System.out.println("parent = " + child.parent);
|
// tmp.addChild(child);
|
if (GrafreeD.clipboardIsTempGroup)
|
tGroup.add/*Child*/(tmp);
|
else
|
GrafreeD.clipboard = tmp;
|
}
|
else
|
if (GrafreeD.clipboardIsTempGroup)
|
tGroup.add/*Child*/(child);
|
else
|
GrafreeD.clipboard = child;
|
}
|
|
//ResetModel();
|
} else
|
{
|
for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
|
{
|
Object3D child = (Object3D)e.nextElement();
|
Object3D elem = child; // .deepCopy();
|
//Composite tmp = new cGroup();
|
Object3D tmp = child; // new cGroup();
|
//tmp.fromParent = child.parent.GlobalTransform();
|
// if(child.parent != null)
|
// LA.matCopy(child.parent.GlobalTransform(), tmp.fromParent);
|
if(child.parent!=null && !LA.isIdentity(child.parent.GlobalTransform()))
|
{
|
tmp = new cGroup();
|
((cGroup)tmp).transientlink = true;
|
tmp.toParent = LA.newMatrix();
|
tmp.fromParent = LA.newMatrix();
|
LA.matCopy(child.parent.GlobalTransform(), tmp.fromParent);;
|
LA.matInvert(tmp.fromParent, tmp.toParent);
|
}
|
if(true) // !LA.isIdentity(tmp.fromParent))
|
{
|
//LA.matInvert(tmp.fromParent, tmp.toParent);
|
if (tmp != child)
|
tmp.add/*Child*/(elem); // ???
|
//System.out.println("cut " + elem);
|
//System.out.println("parent = " + elem.parent);
|
// tmp.addChild(elem);
|
if (GrafreeD.clipboardIsTempGroup)
|
tGroup.add/*Child*/(tmp);
|
else
|
GrafreeD.clipboard = tmp;
|
}
|
else
|
if (GrafreeD.clipboardIsTempGroup)
|
tGroup.add/*Child*/(child);
|
else
|
GrafreeD.clipboard = child;
|
}
|
|
}
|
if (GrafreeD.clipboardIsTempGroup)
|
GrafreeD.clipboard = tGroup;
|
if (cut)
|
{
|
ResetModel();
|
refreshContents();
|
}
|
}
|
|
void paste(boolean expand)
|
{
|
// if (GrafreeD.clipboard == null)
|
// return;
|
boolean first = true;
|
|
if (GrafreeD.clipboardIsTempGroup)
|
{
|
Composite temp;
|
|
/*
|
if (expand)
|
temp = (Composite)Applet3D.clipboard.copyExpand();
|
else
|
temp = (Composite)Applet3D.clipboard.deepCopy();
|
*/
|
Object3D elem;
|
for (Enumeration e = /*temp.children*/GrafreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name))
|
{
|
Object3D child = (Object3D)e.nextElement();
|
|
if (child instanceof cGroup && ((cGroup)child).transientlink )
|
child = ((cGroup)child).get(0);
|
|
Object3D /*Composite*/ keepparent = child.parent;
|
child.parent = null; // Avoid copy?
|
if(expand)
|
elem = child.copyExpand(); // ?
|
else
|
elem = child.deepCopy(); // ?
|
child.parent = keepparent;
|
//if (GrafreeD.clipboardIsTempGroup && LA.isIdentity(elem.fromParent))
|
// elem = elem.get(0);
|
makeSomething(elem, true); // ?? first);
|
//group.addChild(elem);
|
first = false;
|
//int index = objList.getItemCount();
|
}
|
} else
|
{
|
/*
|
Object3D copy = Applet3D.clipboard.deepCopy();
|
//group.addChild(copy);
|
makeSomething(copy);
|
//int index = objList.getItemCount();
|
//objList.add(copy.name);
|
*/
|
//Composite temp = new Composite();
|
//Object3D cb = Applet3D.clipboard;
|
//temp.addChild(cb);
|
//makeSomething((expand?temp.copyExpand():temp.deepCopy()).get(0));
|
assert(GrafreeD.clipboard.parent == null);
|
Object3D /*Composite*/ keepparent = GrafreeD.clipboard.get(0).parent;
|
GrafreeD.clipboard.get(0).parent = null; // Avoid copy?
|
if (LA.isIdentity(GrafreeD.clipboard.toParent))
|
makeSomething(expand?GrafreeD.clipboard.get(0).copyExpand():GrafreeD.clipboard.get(0).deepCopy());
|
else
|
makeSomething(expand?GrafreeD.clipboard.copyExpand():GrafreeD.clipboard.deepCopy());
|
GrafreeD.clipboard.get(0).parent = keepparent;
|
}
|
|
ResetModel();
|
refreshContents();
|
}
|
|
void pasteInto(boolean copyit)
|
{
|
// if (GrafreeD.clipboard == null)
|
// return;
|
|
if (group.selection.size() != 1)
|
return;
|
|
// beurk
|
//Composite tmpgroup = (Composite) objEditor.copy; // group;
|
Object3D tmpgroup = (Object3D) objEditor.copy; // group;
|
Object3D /*Composite*/ restore;
|
|
try
|
{
|
objEditor.copy /*group*/ = /* (Composite)*/ group.selection.get(0);
|
restore = objEditor.copy.parent;
|
//objEditor.copy.parent = group.parent; // null
|
} catch (Exception e)
|
{
|
System.out.println("ERROR pasteLink : " + group.selection);
|
return;
|
}
|
|
try // protect object editor copy
|
{
|
if (copyit)
|
{
|
// paste(false);
|
CloneClipboard(false); // sept 2014
|
}
|
else
|
{
|
boolean first = true;
|
|
if (GrafreeD.clipboardIsTempGroup)
|
{
|
Composite temp = (Composite)GrafreeD.clipboard;
|
Object3D copy;
|
for (Enumeration e = temp.children.elements(); e.hasMoreElements();)
|
{
|
Object3D child = (Object3D)e.nextElement();
|
linkSomething(child, first);
|
first = false;
|
}
|
} else
|
{
|
linkSomething(GrafreeD.clipboard); //.get(0));
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
System.out.println("PROTECTED CRASH");
|
e.printStackTrace();
|
}
|
|
objEditor.copy.parent = restore;
|
objEditor.copy /*group*/ = tmpgroup;
|
|
ResetModel();
|
refreshContents();
|
}
|
|
void group(Object3D csg)
|
{
|
group(csg, false);
|
}
|
|
void back()
|
{
|
int selcount = group.selection.size();
|
|
if (selcount != 1)
|
return;
|
|
Object3D object = group.selection.get(0);
|
|
if (object.parent != null)
|
{
|
int index = object.parent.indexOf(object);
|
|
if (index == 0)
|
return;
|
|
Object3D theobj = object.parent.remove(index);
|
assert(theobj == object);
|
|
object.parent.insertElementAt(object, index-1);
|
}
|
|
ResetModel();
|
Select(object.GetTreePath(), true, false); // unselect... false);
|
refreshContents();
|
}
|
void front()
|
{
|
int selcount = group.selection.size();
|
|
if (selcount != 1)
|
return;
|
|
Object3D object = group.selection.get(0);
|
|
if (object.parent != null)
|
{
|
int index = object.parent.indexOf(object);
|
|
if (index+1 >= object.parent.size())
|
return;
|
|
Object3D theobj = object.parent.remove(index);
|
assert(theobj == object);
|
|
object.parent.insertElementAt(object, index+1);
|
}
|
|
ResetModel();
|
Select(object.GetTreePath(), true, false); // unselect... false);
|
refreshContents();
|
}
|
|
void group(Object3D csg, boolean grab)
|
{
|
if (//false) // why??
|
!group.selection.isEmpty())
|
{
|
/*
|
int indices[] = objList.getSelectedIndexes();
|
for (int i = indices.length - 1; i >= 0; i--)
|
objList.remove(indices[i]);
|
*/
|
|
//Composite csg = new Composite();
|
|
int selcount = group.selection.size();
|
|
Object3D child;
|
for (; group.selection.size() > 0;)
|
{
|
child = (Object3D)group.selection.firstElement(); // ??? lastElement();
|
if(child == group)
|
{
|
group.selection.remove(child);
|
continue;
|
}
|
Composite tmp = new cGroup();
|
tmp.toParent = LA.newMatrix();
|
tmp.fromParent = LA.newMatrix();
|
if(child.parent != null)
|
LA.matCopy(child.parent.GlobalTransform(), tmp.fromParent);
|
|
LA.matInvert(group.GlobalTransform(), tmp.toParent);
|
LA.matConcat(tmp.toParent, tmp.fromParent, tmp.fromParent);
|
|
group.removeChild(child);
|
if(!LA.isIdentityEps(tmp.fromParent))
|
{
|
LA.matInvert(tmp.fromParent, tmp.toParent);
|
csg.addChild(tmp);
|
tmp.addChild(child);
|
|
if (grab && selcount == 1)
|
{
|
makeSomething(tmp);
|
return;
|
}
|
}
|
else
|
{
|
if (grab && selcount == 1)
|
{
|
makeSomething(child);
|
return;
|
}
|
|
csg.addChild(child);
|
}
|
}
|
|
try
|
{
|
objEditor.jTree.clearSelection();
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
if (false) // !group.selection.isEmpty())
|
{
|
/*
|
int indices[] = objList.getSelectedIndexes();
|
for (int i = indices.length - 1; i >= 0; i--)
|
objList.remove(indices[i]);
|
*/
|
|
//Composite csg = new Composite();
|
|
int selcount = group.selection.size();
|
|
Object3D child;
|
for (; group.selection.size() > 0;)
|
{
|
child = (Object3D)group.selection.firstElement(); // ??? lastElement();
|
if(child == group)
|
{
|
group.selection.remove(child);
|
continue;
|
}
|
|
group.removeChild(child);
|
|
if (grab && selcount == 1)
|
{
|
makeSomething(child);
|
return;
|
}
|
|
csg.addChild(child);
|
}
|
|
try
|
{
|
objEditor.jTree.clearSelection();
|
}
|
catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
|
//Object3D node = new cGroup();
|
//node.add(csg);
|
//makeSomething(node);
|
makeSomething(csg);
|
}
|
|
void ungroup()
|
{
|
/*
|
boolean first = true;
|
|
int indices[] = jList.getSelectedIndices();
|
for (int i = indices.length - 1; i >= 0; i--)
|
{
|
Object3D child = (Object3D)group.children.elementAt(indices[i]);
|
if (child instanceof Composite)
|
{
|
//objList.remove(indices[i]);
|
group.removeChild(child);
|
Object3D grandchild;
|
for (Composite comp = (Composite)child; comp.children.size() > 0;) // objList.add(grandchild.name))
|
{
|
grandchild = (Object3D)comp.children.elementAt(0);
|
comp.removeChild(grandchild);
|
LA.matConcat(grandchild.toParent, comp.toParent, grandchild.toParent);
|
group.addChild(grandchild);
|
//makeSomething(grandchild, first);
|
first = false;
|
}
|
}
|
}
|
|
ResetModel();
|
refreshContents();
|
*/
|
}
|
|
void refreshContents2()
|
{
|
objEditor.refreshContents();
|
|
/*
|
jTree.repaint();
|
|
if (true) return; // freeze) return;
|
|
//ResetModel();
|
|
//System.out.println("Vector = " + (group.GetSelectionTreePaths()));
|
//System.out.println("Array = " + (group.GetSelectionTreePaths().toArray()));
|
jTree.clearSelection();
|
|
Object[] list = group.GetSelectionTreePaths().toArray();
|
for (int i=0; i<list.length; i++)
|
{
|
jTree.addSelectionPath((cTreePath) list[i]);
|
}
|
*/
|
}
|
|
/*
|
static class cFileChooser extends JFileChooser
|
{
|
public void setUI(javax.swing.plaf.ComponentUI ui)
|
{
|
super.setUI(ui);
|
}
|
}
|
|
static cFileChooser chooser = new cFileChooser();
|
*/
|
|
/*
|
void DropFile(java.io.File[] files, boolean textures)
|
{
|
assert(false);
|
for(java.io.File file : files)
|
{
|
String filename = file.getAbsolutePath();
|
|
// 3D models
|
if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
|
{
|
lastConverter = new com.jmex.model.converters.MaxToJme();
|
LoadFile(filename, lastConverter);
|
continue;
|
}
|
if (filename.endsWith(".obj") || filename.endsWith(".OBJ"))
|
{
|
lastConverter = new com.jmex.model.converters.ObjToJme();
|
LoadFile(filename, lastConverter);
|
continue;
|
}
|
|
// Images/textures
|
if (textures &&
|
(filename.toLowerCase().endsWith(".jpg") ||
|
filename.toLowerCase().endsWith(".gif") ||
|
filename.toLowerCase().endsWith(".png") ||
|
filename.toLowerCase().endsWith(".tif") ||
|
filename.toLowerCase().endsWith(".tiff")))
|
{
|
DropTexture(filename);
|
continue;
|
}
|
|
//makeSomething(ReadGFD(filename));
|
objEditor.ReadGFD(filename, this);
|
}
|
}
|
|
void DropTexture(String filename)
|
{
|
Vector<Object3D> tempsel = (Vector<Object3D>) group.selectees.clone();
|
|
flashIt = false;
|
CameraPane pane = (CameraPane) objEditor.cameraView;
|
pane.clickStart(location.x, location.y, 0);
|
pane.clickEnd(location.x, location.y, 0, true);
|
|
if (group.selectees.size() == 1)
|
{
|
Object3D targ = group.selectees.get(0);
|
|
targ.SetTexture(new cTexture(filename));
|
}
|
|
boolean first = true;
|
for(Object3D o : tempsel)
|
{
|
Select(o, first);
|
first = false;
|
}
|
|
flashIt = true;
|
|
refreshContents();
|
}
|
|
LoadJMEThread loadThread;
|
|
class LoadJMEThread extends Thread
|
{
|
com.jmex.model.converters.FormatConverter converter;
|
java.util.Stack stack;
|
|
LoadJMEThread(com.jmex.model.converters.FormatConverter conv)
|
{
|
converter = conv;
|
stack = new java.util.Stack();
|
}
|
|
void add(String filename)
|
{
|
stack.push(filename);
|
}
|
|
public void run()
|
{
|
for(;;)
|
{
|
try{sleep(10);}catch(Exception e){};
|
if(!stack.empty())
|
{
|
objEditor.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
String filename = (String)stack.pop();
|
System.out.println(" ------- ------- ------ ------ ----- LOADING... " + filename);
|
LoadFile0(filename, converter);
|
System.gc();
|
}
|
else
|
objEditor.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
}
|
|
//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(converter);
|
loadThread.start();
|
}
|
|
loadThread.add(fullname);
|
}
|
*/
|
|
void ImportGFD()
|
{
|
FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
String fullname = browser.getDirectory() + filename;
|
|
//Object3D readobj =
|
objEditor.ReadGFD(fullname, objEditor);
|
//makeSomething(readobj);
|
}
|
}
|
|
/*
|
public void Callback(Object obj)
|
{
|
if(obj == null)
|
return;
|
|
if (obj instanceof Object3D)
|
// BEURK
|
makeSomething((Object3D) obj);
|
else
|
DropFile((java.io.File[]) obj, false);
|
}
|
*/
|
|
/*
|
public void DragGesture()
|
{
|
// Patch for DnD failure
|
objEditor.jTree.clearSelection();
|
objEditor.ResetSliders();
|
}
|
*/
|
|
void ImportVRMLX3D()
|
{
|
if (GrafreeD.standAlone)
|
{
|
/**/
|
FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
String fullname = browser.getDirectory() + filename;
|
LoadVRMLX3D(fullname);
|
}
|
/**/
|
}
|
}
|
|
String GetFile(String dialogName)
|
{
|
if (GrafreeD.standAlone)
|
{
|
FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD);
|
browser.show();
|
String filename = browser.getFile();
|
if (filename != null && filename.length() > 0)
|
{
|
String fullname = browser.getDirectory() + filename;
|
|
return fullname;
|
// try
|
// {
|
// java.io.File file = new java.io.File(fullname);
|
// java.net.URL url = file.toURI().toURL();
|
//
|
// return file.toString(); // new cTexture(file.toString());
|
// }
|
// catch(java.io.IOException e2) { e2.printStackTrace(); }
|
}
|
}
|
|
return null;
|
}
|
|
static class cListModel implements ListModel
|
{
|
Vector objList = new Vector();
|
|
cListModel(GroupEditor owner)
|
{
|
//int index = 0;
|
for (Enumeration e = owner.group.Children().elements(); e.hasMoreElements();)
|
{
|
Object3D child = (Object3D)e.nextElement();
|
objList.add(child.name);
|
//if (owner.group.isSelected(child))
|
//objList.setSelectedIndex(index);
|
//index++;
|
}
|
}
|
|
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)
|
{
|
}
|
}
|
|
|
cButton flashSelectionButton;
|
cButton editButton;
|
cButton uneditButton;
|
cButton clearpanelButton;
|
cButton allParamsButton;
|
cButton unselectButton;
|
|
cButton screenfitButton;
|
cButton screenfitpointButton;
|
cButton snapobjectButton;
|
// cButton recompileButton;
|
cButton gcButton;
|
cButton clearButton;
|
cButton rootButton;
|
cButton closeButton;
|
|
cButton setsupportButton;
|
|
cButton twoButton;
|
cButton sixButton;
|
cButton threeButton;
|
cButton sevenButton;
|
cButton fourButton; // full panel
|
cButton oneButton; // full XYZ
|
//cButton currentLayout;
|
|
//
|
//Composite
|
Object3D // to do !!
|
group;
|
//Vector selectees;
|
JList jList;
|
//JTree jTree;
|
private MenuItem lookAtItem;
|
private MenuItem lookFromItem;
|
private MenuItem switchItem;
|
private MenuItem cutItem;
|
private MenuItem duplicateItem;
|
private MenuItem cloneItem;
|
private MenuItem cloneSupportItem;
|
private MenuItem overwriteGeoItem;
|
private MenuItem overwriteMatItem;
|
private MenuItem overwriteNameItem;
|
private MenuItem overwriteUVItem;
|
private MenuItem synchronizeItem;
|
private MenuItem resetsupportItem;
|
private MenuItem resetreferencesItem;
|
private MenuItem linkverticesItem;
|
private MenuItem setMasterItem;
|
private MenuItem resetMeshItem;
|
private MenuItem stepAllItem;
|
private MenuItem revertMeshItem;
|
private MenuItem poseMeshItem;
|
private MenuItem generateMeshItem;
|
private MenuItem extractGeometriesItem;
|
private MenuItem cloneGeometriesItem;
|
private MenuItem shareGeometriesItem;
|
private MenuItem mergeGeometriesItem;
|
private MenuItem copyItem;
|
private MenuItem pasteItem;
|
private MenuItem pasteLinkItem;
|
private MenuItem pasteCloneItem;
|
private MenuItem pasteExpandItem;
|
private MenuItem clearItem;
|
private MenuItem clearAllItem;
|
private MenuItem genUVItem;
|
private MenuItem genNormalsMESHItem;
|
private MenuItem genNormalsCADItem;
|
private MenuItem genNormalsORGANItem;
|
private MenuItem stripifyItem;
|
private MenuItem unstripifyItem;
|
private MenuItem trimItem;
|
private MenuItem untrimItem;
|
|
private MenuItem clearColorsItem;
|
private MenuItem parseverticesItem;
|
private MenuItem alignItem;
|
private MenuItem mirrorItem;
|
private MenuItem reduceMorphItem;
|
private MenuItem reduce34MorphItem;
|
private MenuItem reverseNormalsItem;
|
private MenuItem reverseTrianglesItem;
|
private MenuItem reduceMeshItem;
|
private MenuItem reduce34MeshItem;
|
private MenuItem increaseMeshItem;
|
private MenuItem clipMeshItem;
|
private MenuItem smoothMeshItem;
|
private MenuItem clearMaterialsItem;
|
|
private MenuItem liveleavesItem;
|
private MenuItem unliveleavesItem;
|
private MenuItem supportleavesItem;
|
private MenuItem unsupportleavesItem;
|
private MenuItem hideleavesItem;
|
private MenuItem showleavesItem;
|
private MenuItem markleavesItem;
|
private MenuItem unmarkleavesItem;
|
|
private MenuItem flipVItem;
|
private MenuItem unflipVItem;
|
private MenuItem lowTexturesItem;
|
private MenuItem normalTexturesItem;
|
private MenuItem highTexturesItem;
|
private MenuItem veryhighTexturesItem;
|
private MenuItem maxTexturesItem;
|
private MenuItem panoTexturesItem;
|
|
private MenuItem resetCentroidItem;
|
private MenuItem transformgeometryItem;
|
private MenuItem resetTransformItem;
|
private MenuItem grabItem;
|
private MenuItem backItem;
|
private MenuItem frontItem;
|
private MenuItem cameraItem;
|
private MenuItem compositeItem;
|
private MenuItem randomItem;
|
private MenuItem physicsItem;
|
private MenuItem frameselectorItem;
|
private MenuItem scriptNodeItem;
|
private MenuItem switchGeoItem;
|
private MenuItem switchTransfoItem;
|
private MenuItem morphItem;
|
private MenuItem linkerItem;
|
private MenuItem ungroupItem;
|
private MenuItem editItem;
|
private MenuItem openWindowItem;
|
private MenuItem editLeafItem;
|
|
private MenuItem resetParentItem;
|
private MenuItem repairParentItem;
|
private MenuItem sortbysizeItem;
|
private MenuItem sortbynameItem;
|
|
private MenuItem attachPigmentItem;
|
private MenuItem detachPigmentItem;
|
private MenuItem attachBumpItem;
|
private MenuItem detachBumpItem;
|
private MenuItem pigmentBumpItem;
|
|
private MenuItem particleItem;
|
private MenuItem ragdollItem;
|
private MenuItem ragdoll2Item;
|
private MenuItem heightFieldItem;
|
private MenuItem textureFieldItem;
|
private MenuItem gridItem;
|
private MenuItem rectoidItem;
|
private MenuItem ellipsoidItem;
|
private MenuItem coneItem;
|
private MenuItem torusItem;
|
private MenuItem superItem;
|
private MenuItem blobItem;
|
private MenuItem latheItem;
|
private MenuItem bezierItem;
|
private MenuItem checkerItem;
|
private MenuItem meshItem;
|
// private MenuItem meshGroupItem;
|
private MenuItem springItem;
|
private MenuItem flagItem;
|
private MenuItem lightItem;
|
private MenuItem csgItem;
|
private MenuItem templateItem;
|
private MenuItem textureItem;
|
private MenuItem shadowXItem;
|
private MenuItem shadowYItem;
|
private MenuItem shadowZItem;
|
private MenuItem attributeItem;
|
private MenuItem pointflowItem;
|
|
private MenuItem superLoopItem;
|
|
private MenuItem loopItem;
|
private MenuItem doubleItem;
|
private MenuItem tripleItem;
|
|
private MenuItem importGFDItem;
|
private MenuItem importVRMLX3DItem;
|
private MenuItem import3DSItem;
|
private MenuItem importOBJItem;
|
|
private MenuItem computeAOItem;
|
private MenuItem recompileItem;
|
private MenuItem editScriptItem;
|
private MenuItem invariantsItem;
|
private MenuItem memoryItem;
|
private MenuItem pathItem;
|
private MenuItem analyzeItem;
|
private MenuItem dumpItem;
|
//boolean freezemodel = false;
|
}
|