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 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 tempsel = (Vector) 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 0) // child.count -= 1; child.DecCount(); //makeSomething(s); itemtomake.add(s); } for (int i=0; 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 0) { for (int i=0; i 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(); // // boolean epsequal = GrafreeD.epsequal; // GrafreeD.epsequal = true; // // for (int i=0; i> set = temprep.vertextable.entrySet(); // // for (java.util.Map.Entry 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=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 listUI = new Vector(); void EditSelection(boolean newWindow) { // aConstraints.gridy = 0; for (int i=0; i " + 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 tempsel = (Vector) 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; }