From 655810d1c4e710e7c85772b8dde96772dbcf274b Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 01 Jul 2018 11:50:49 -0400 Subject: [PATCH] Major mocap changes. --- GroupEditor.java | 667 ++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 481 insertions(+), 186 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index f50fede..d7a1c3e 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -14,7 +14,7 @@ //import buoy.widget.BFileChooser; -class GroupEditor extends ObjEditor implements iParse, //iCallBack, +class GroupEditor extends ObjEditor implements //iParse, //iCallBack, ObjectUI, Runnable, ActionListener, @@ -83,7 +83,7 @@ void CloneSelection(boolean supports) { - // Object3D keep = GraphreeD.clipboard; + // Object3D keep = GrafreeD.clipboard; //Object3D obj; for (int i=0; i<group.selection.size(); i++)// Enumeration e = group.selection.elements(); e.hasMoreElements();) { @@ -97,14 +97,14 @@ void CloneClipboard(boolean supports) { - assert(GraphreeD.clipboard.parent == null); - Object3D /*Composite*/ keepparent = GraphreeD.clipboard.get(0).parent; - GraphreeD.clipboard.get(0).parent = null; // Avoid copy? - if (LA.isIdentity(GraphreeD.clipboard.toParent)) - makeSomething(CloneObject(GraphreeD.clipboard.get(0), false)); + 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(GraphreeD.clipboard, false)); - GraphreeD.clipboard.get(0).parent = keepparent; + makeSomething(CloneObject(GrafreeD.clipboard, false)); + GrafreeD.clipboard.get(0).parent = keepparent; } static Object3D CloneObject(Object3D obj, boolean supports) @@ -118,7 +118,7 @@ // obj.support = null; if (!supports) obj.SaveSupports(); - Object3D clone = (Object3D)GraphreeD.clone(obj); + Object3D clone = (Object3D)GrafreeD.clone(obj); obj.parent = parent; // obj.support = support; // clone.support = support; // aout 2013 @@ -188,8 +188,9 @@ clearItem.addActionListener(this); clearAllItem = menu.add(new MenuItem("Clear All")); clearAllItem.addActionListener(this); - menu.add("-"); - resetMeshItem = menu.add(new MenuItem("Reset All")); + + 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); @@ -218,18 +219,24 @@ resetsupportItem.addActionListener(this); linkverticesItem = menu.add(new MenuItem("Link to Support")); linkverticesItem.addActionListener(this); + relinkverticesItem = menu.add(new MenuItem("Re-link to Support")); + relinkverticesItem.addActionListener(this); setMasterItem = menu.add(new MenuItem("Set Master Mesh")); setMasterItem.addActionListener(this); - oe.menuBar.add(menu = new Menu("Object")); + oe.menuBar.add(menu = new Menu("Group")); grabItem = menu.add(new MenuItem("Grab")); grabItem.addActionListener(this); - frontItem = menu.add(new MenuItem("Front")); - frontItem.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); + hideItem = menu.add(new MenuItem("Hide")); + hideItem.addActionListener(this); + ungroupItem = menu.add(new MenuItem("Ungroup")); + ungroupItem.addActionListener(this); menu.add("-"); randomItem = menu.add(new MenuItem("Random")); randomItem.addActionListener(this); @@ -247,9 +254,12 @@ scriptNodeItem.addActionListener(this); cameraItem = menu.add(new MenuItem("Camera")); cameraItem.addActionListener(this); - menu.add("-"); + + oe.menuBar.add(menu = new Menu("Object")); textureItem = menu.add(new MenuItem("Texture")); textureItem.addActionListener(this); + billboardItem = menu.add(new MenuItem("Billboard")); + billboardItem.addActionListener(this); csgItem = menu.add(new MenuItem("CSG")); csgItem.addActionListener(this); shadowXItem = menu.add(new MenuItem("Shadow X")); @@ -267,14 +277,12 @@ 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); + transformgeometryItem = menu.add(new MenuItem("Transform Geometry")); + transformgeometryItem.addActionListener(this); oe.menuBar.add(menu = new Menu("Geometry")); genUVItem = menu.add(new MenuItem("Generate UV")); @@ -283,6 +291,10 @@ genNormalsORGANItem.addActionListener(this); genNormalsCADItem = menu.add(new MenuItem("CAD Normals")); genNormalsCADItem.addActionListener(this); + genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals")); + genNormalsMESHItem.addActionListener(this); + genNormalsMINEItem = menu.add(new MenuItem("My Normals")); + genNormalsMINEItem.addActionListener(this); stripifyItem = menu.add(new MenuItem("Stripify")); stripifyItem.addActionListener(this); unstripifyItem = menu.add(new MenuItem("Unstripify")); @@ -292,8 +304,6 @@ untrimItem = menu.add(new MenuItem("Untrim")); untrimItem.addActionListener(this); menu.add("-"); - clearMaterialsItem = menu.add(new MenuItem("Clear Materials")); - clearMaterialsItem.addActionListener(this); clearColorsItem = menu.add(new MenuItem("Clear AO")); clearColorsItem.addActionListener(this); reverseNormalsItem = menu.add(new MenuItem("Reverse Normals")); @@ -310,6 +320,10 @@ 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); @@ -332,27 +346,18 @@ flipVItem.addActionListener(this); unflipVItem = menu.add(new MenuItem("Unflip V")); unflipVItem.addActionListener(this); - lowTexturesItem = menu.add(new MenuItem("Low Texture")); + lowTexturesItem = menu.add(new MenuItem("Low Texture (256)")); lowTexturesItem.addActionListener(this); - normalTexturesItem = menu.add(new MenuItem("Normal Texture")); + normalTexturesItem = menu.add(new MenuItem("Normal Texture (512)")); normalTexturesItem.addActionListener(this); - highTexturesItem = menu.add(new MenuItem("High Texture")); + highTexturesItem = menu.add(new MenuItem("High Texture (1024)")); highTexturesItem.addActionListener(this); - veryhighTexturesItem = menu.add(new MenuItem("Very high Texture")); + veryhighTexturesItem = menu.add(new MenuItem("Very high Texture (2048)")); veryhighTexturesItem.addActionListener(this); - maxTexturesItem = menu.add(new MenuItem("Max Texture")); + maxTexturesItem = menu.add(new MenuItem("Max Texture (4096)")); maxTexturesItem.addActionListener(this); - panoTexturesItem = menu.add(new MenuItem("Panoramic Texture")); + panoTexturesItem = menu.add(new MenuItem("Panoramic Texture (8192)")); panoTexturesItem.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("Selection")); attachPigmentItem = menu.add(new MenuItem("Attach Pigment...")); @@ -370,9 +375,31 @@ 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("Tools")); + + + 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); } @@ -1002,6 +1029,8 @@ 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")); @@ -1014,6 +1043,8 @@ torusItem.addActionListener(this); superItem = menu.add(new MenuItem("Superellipsoid")); superItem.addActionListener(this); + kleinItem = menu.add(new MenuItem("Klein Bottle")); + kleinItem.addActionListener(this); particleItem = menu.add(new MenuItem("Particle system")); particleItem.addActionListener(this); ragdollItem = menu.add(new MenuItem("Rag Walk")); @@ -1048,15 +1079,6 @@ doubleItem.addActionListener(this); tripleItem = menu.add(new MenuItem("Trident")); tripleItem.addActionListener(this); - menu.add("-"); - importGFDItem = menu.add(new MenuItem("GraphreeD 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); } void buildToolsMenu(Menu menu) @@ -1068,6 +1090,8 @@ 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")); @@ -1429,9 +1453,9 @@ void Overwrite(int mask) { - if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) { - Object3D content = GraphreeD.clipboard.get(0); + Object3D content = GrafreeD.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -1521,6 +1545,46 @@ 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()); @@ -1540,6 +1604,10 @@ if (event.getSource() == superItem) { makeSomething(new Superellipsoid()); + } else + if (event.getSource() == kleinItem) + { + makeSomething(new Klein()); } else if (event.getSource() == blobItem) { @@ -1570,7 +1638,7 @@ LA.matConcat(obj.toParent, cameraView.renderCamera.fromParent, obj.toParent); LA.matInvert(obj.toParent, obj.fromParent); */ - makeSomething(new CheckerIG()); + makeSomething(new Checker()); } else if (event.getSource() == meshItem) { @@ -1726,7 +1794,7 @@ if (event.getSource() == invariantsItem) { System.out.println("Invariants:"); - GraphreeD.theApplet3D.universe.invariants(); + GrafreeD.theApplet3D.universe.invariants(); } else if (event.getSource() == memoryItem) { @@ -1796,10 +1864,10 @@ } else if (event.getSource() == duplicateItem) { - Object3D keep = GraphreeD.clipboard; + Object3D keep = GrafreeD.clipboard; loadClipboard(false); paste(false); - GraphreeD.clipboard = keep; + GrafreeD.clipboard = keep; } else if (event.getSource() == cloneItem) { @@ -1843,8 +1911,9 @@ } else if (event.getSource() == overwriteMatItem) { + /* july 2015 if ((dropAttributes & Object3D.TEXTURE) == 0) - Overwrite(Object3D.MATERIAL); + Overwrite(Object3D.MATERIAL | Object3D.COLOR); else { if ((dropAttributes & Object3D.COLOR) == 0 && (dropAttributes & Object3D.MATERIAL) == 0) @@ -1856,13 +1925,16 @@ Overwrite(Object3D.MATERIAL | Object3D.TEXTURE); } } + */ + + Overwrite(dropAttributes); } if (event.getSource() == overwriteGeoItem) { Overwrite(Object3D.GEOMETRY); -// if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1) +// if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) // { -// Object3D content = GraphreeD.clipboard.get(0); +// Object3D content = GrafreeD.clipboard.get(0); // // if (content instanceof cGroup && ((cGroup)content).transientlink ) // content = ((cGroup)content).get(0); @@ -1945,23 +2017,28 @@ if (group.selection.size() == 1) one = true; + Object3D merge = null; + Object3D content = new cGroup(); for (int i=0; i<group.selection.size(); i++) { - Object3D sel = new Merge(group.selection.get(i)); + merge = new Merge(group.selection.get(i)); if (one) - makeSomething(sel, false); + makeSomething(merge, false); else - content.addChild(sel); + content.addChild(merge); } if (!one) - makeSomething(content, false); - - ResetModel(); - refreshContents(); + makeSomething(content, true); + else + { + ResetModel(); + Select(merge.GetTreePath(), true, false); // unselect... false); + refreshContents(); + } } else if (event.getSource() == mergeGeometriesItem) { @@ -1995,9 +2072,9 @@ } else if (event.getSource() == linkverticesItem) { -// if (group.selection.size() == 1 && GraphreeD.clipboard.size() == 1) +// if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1) // { -// Object3D content = GraphreeD.clipboard.get(0); +// Object3D content = GrafreeD.clipboard.get(0); // // if (content instanceof cGroup && ((cGroup)content).transientlink ) // content = ((cGroup)content).get(0); @@ -2006,9 +2083,9 @@ // group.selection.get(0).setMasterThis(content); // should be identity // refreshContents(); // } - if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) { - Object3D content = GraphreeD.clipboard.get(0); + Object3D content = GrafreeD.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2038,6 +2115,15 @@ refreshContents(); } else + if (event.getSource() == relinkverticesItem) + { + boolean random = CameraPane.RANDOM; + CameraPane.RANDOM = false; // parse all random nodes + group.selection.RelinkToSupport(); + CameraPane.RANDOM = random; + + refreshContents(); + } else if (event.getSource() == resetreferencesItem) { for (int i=0; i<group.selection.size(); i++) @@ -2049,9 +2135,9 @@ } else if (event.getSource() == setMasterItem) { - if (group.selection.size() == 1 && GraphreeD.clipboard.size() == 1) + if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1) { - Object3D content = GraphreeD.clipboard.get(0); + Object3D content = GrafreeD.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2064,9 +2150,9 @@ { if (group.selection.size() == 1) { - if (GraphreeD.clipboard.size() == 1) + if (GrafreeD.clipboard.size() == 1) { - Object3D content = GraphreeD.clipboard.get(0); + Object3D content = GrafreeD.clipboard.get(0); if (content instanceof cGroup && ((cGroup)content).transientlink ) content = ((cGroup)content).get(0); @@ -2106,6 +2192,10 @@ if (event.getSource() == grabItem) { group(new cGroup(), true); + } else + if (event.getSource() == hideItem) + { + group(new HiddenObject()); } else if (event.getSource() == frontItem) { @@ -2229,6 +2319,10 @@ { group(new TextureNode()); } else + if (event.getSource() == billboardItem) + { + group(new BillboardNode()); + } else if (event.getSource() == shadowXItem) { CastShadow(0); @@ -2243,7 +2337,15 @@ } else if (event.getSource() == ungroupItem) { - ungroup(); + //ungroup(); + for (int i=0; i<group.selection.size(); i++) + { + Ungroup(group.selection.get(i)); + } + + ClearSelection(false); + + refreshContents(); } else if (event.getSource() == genUVItem) { @@ -2253,9 +2355,17 @@ { GenNormals(true); } else + if (event.getSource() == genNormalsMESHItem) + { + GenNormals(true); // TODO + } else if (event.getSource() == genNormalsORGANItem) { GenNormals(false); + } else + if (event.getSource() == genNormalsMINEItem) + { + GenNormalsMINE(); } else if (event.getSource() == stripifyItem) { @@ -2352,6 +2462,10 @@ if (event.getSource() == parseverticesItem) { ParseVertices(); + } else + if (event.getSource() == textureFieldItem) + { + TextureVertices(); } else if (event.getSource() == alignItem) { @@ -2750,7 +2864,7 @@ if (event.getSource() == unselectButton) { objEditor.jTree.clearSelection(); - // ?? oct 2012 GraphreeD.clipboard.clear(); + // ?? oct 2012 GrafreeD.clipboard.clear(); objEditor.ResetSliders(); refreshContents(true); } else @@ -3065,9 +3179,9 @@ obj = (Object3D)e.nextElement(); System.out.println("Object is: " + obj); - GraphreeD.AnalyzeObject(obj); + GrafreeD.AnalyzeObject(obj); System.out.println("Boundary rep: " + obj.bRep); - GraphreeD.AnalyzeObject(obj.bRep); + GrafreeD.AnalyzeObject(obj.bRep); // System.err.println((size/1024) + " KB is the size of " + obj); } @@ -3109,6 +3223,13 @@ void GenNormals(boolean crease) { group.GenNormalsS(crease); + + refreshContents(); + } + + void GenNormalsMINE() + { + group.selection.GenNormalsMINE(); refreshContents(); } @@ -3157,104 +3278,250 @@ //Object3D buffer; cVector temp = new cVector(); - BoundaryRep temprep; - Object3D nodes; - Vector<Vertex> vertices; - - 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); - } - } - - public void Face(Object3D node, Face f) - { - - } - +// 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() { - //if (group.selection.size() != 1) - // return; - - temprep = new BoundaryRep(); - nodes = new Object3D(); - vertices = new Vector<Vertex>(); - - boolean epsequal = GraphreeD.epsequal; - GraphreeD.epsequal = true; + 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 + "+"); + final cGroup 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(); + group.selection.get(i).Parse( + + new iParse() + { + public void Vertex(Object3D node, Vertex v) + { + temp.set(v); + LA.xformPos(temp, node.GlobalTransformInv(), temp); - assert(vertices.size() == nodes.size()); - - temprep.vertextable.elements(); - - java.util.Set<java.util.Map.Entry<Vertex,Vertex>> set = temprep.vertextable.entrySet(); + cGroup g = new cGroup(); - for (java.util.Map.Entry<Vertex,Vertex> entry : set) - { - 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); - 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); + g.add(GrafreeD.clipboard); - 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); + buffer.add(g); + } - g.add(GraphreeD.clipboard); + public void Face(Object3D node, Face f) + { - buffer.add(g); - } + } + } + ); makeSomething(buffer, i==group.selection.size()-1); } - GraphreeD.epsequal = epsequal; - - //buffer = null; - temprep = null; - nodes = null; + 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() { + if (group.selection.size() == 0) + return; + + cVector bbmin = new cVector(); + cVector bbmax = new cVector(); + + group.selection.get(0).getBounds(bbmin, bbmax, true); + + double dx = bbmax.x - bbmin.x; + double dy = bbmax.y - bbmin.y; + double dz = bbmax.z - bbmin.z; + + double scale = Math.sqrt(dx*dx + dy*dy + dz*dz); + 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); + LA.matTranslate(obj.toParent, i * scale, 0, 0); + LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0); } refreshContents(); @@ -3267,7 +3534,7 @@ // ref.SaveSupports(); // Object3D par = ref.parent; // ref.parent = null; -// Object3D lowres = (Object3D) GraphreeD.clone(ref); +// Object3D lowres = (Object3D) GrafreeD.clone(ref); // ref.parent = par; // ref.RestoreSupports(); @@ -3297,7 +3564,7 @@ // lowres.SaveSupports(); // par = lowres.parent; // lowres.parent = null; -// Object3D newlow = (Object3D) GraphreeD.clone(lowres); +// Object3D newlow = (Object3D) GrafreeD.clone(lowres); Object3D newlow = CloneObject(lowres, false); newlow.name = sn.switchobject.get(i).name; System.out.println(" pose#" + i + " = " + newlow); @@ -3319,7 +3586,7 @@ return; Object3D poses = group.selection.get(0); - Object3D ref = GraphreeD.clipboard.get(0); + Object3D ref = GrafreeD.clipboard.get(0); Object3D newgroup = new Object3D("Po:" + poses.name); @@ -3513,20 +3780,20 @@ void ClipMesh() { - if (/*group.selection.size() == 1 &&*/ GraphreeD.clipboard.size() == 1) + if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1) { - Object3D content = GraphreeD.clipboard.get(0); + 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(GraphreeD.clipboard); +// group.selection.get(i).ClipMesh(GrafreeD.clipboard); // } - group.selection.ClipMesh(GraphreeD.clipboard); + group.selection.ClipMesh(GrafreeD.clipboard); } -// group.selection.ClipMesh(GraphreeD.clipboard); +// group.selection.ClipMesh(GrafreeD.clipboard); System.out.println("DONE."); refreshContents(); } @@ -3864,12 +4131,12 @@ { if (group.selection.isEmpty()) return; - GraphreeD.clipboardIsTempGroup = false; + GrafreeD.clipboardIsTempGroup = false; Composite tGroup = null; if (group.selection.size() > 0) // 1) { tGroup = new cGroup(); - GraphreeD.clipboardIsTempGroup = true; + GrafreeD.clipboardIsTempGroup = true; } if (cut) @@ -3909,16 +4176,16 @@ //System.out.println("cut " + child); //System.out.println("parent = " + child.parent); // tmp.addChild(child); - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) tGroup.add/*Child*/(tmp); else - GraphreeD.clipboard = tmp; + GrafreeD.clipboard = tmp; } else - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) tGroup.add/*Child*/(child); else - GraphreeD.clipboard = child; + GrafreeD.clipboard = child; } //ResetModel(); @@ -3950,21 +4217,21 @@ //System.out.println("cut " + elem); //System.out.println("parent = " + elem.parent); // tmp.addChild(elem); - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) tGroup.add/*Child*/(tmp); else - GraphreeD.clipboard = tmp; + GrafreeD.clipboard = tmp; } else - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) tGroup.add/*Child*/(child); else - GraphreeD.clipboard = child; + GrafreeD.clipboard = child; } } - if (GraphreeD.clipboardIsTempGroup) - GraphreeD.clipboard = tGroup; + if (GrafreeD.clipboardIsTempGroup) + GrafreeD.clipboard = tGroup; if (cut) { ResetModel(); @@ -3974,11 +4241,11 @@ void paste(boolean expand) { - // if (GraphreeD.clipboard == null) + // if (GrafreeD.clipboard == null) // return; boolean first = true; - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) { Composite temp; @@ -3989,7 +4256,7 @@ temp = (Composite)Applet3D.clipboard.deepCopy(); */ Object3D elem; - for (Enumeration e = /*temp.children*/GraphreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name)) + for (Enumeration e = /*temp.children*/GrafreeD.clipboard.elements(); e.hasMoreElements();) // objList.add(copy.name)) { Object3D child = (Object3D)e.nextElement(); @@ -4003,7 +4270,7 @@ else elem = child.deepCopy(); // ? child.parent = keepparent; - //if (GraphreeD.clipboardIsTempGroup && LA.isIdentity(elem.fromParent)) + //if (GrafreeD.clipboardIsTempGroup && LA.isIdentity(elem.fromParent)) // elem = elem.get(0); makeSomething(elem, true); // ?? first); //group.addChild(elem); @@ -4023,14 +4290,14 @@ //Object3D cb = Applet3D.clipboard; //temp.addChild(cb); //makeSomething((expand?temp.copyExpand():temp.deepCopy()).get(0)); - assert(GraphreeD.clipboard.parent == null); - Object3D /*Composite*/ keepparent = GraphreeD.clipboard.get(0).parent; - GraphreeD.clipboard.get(0).parent = null; // Avoid copy? - if (LA.isIdentity(GraphreeD.clipboard.toParent)) - makeSomething(expand?GraphreeD.clipboard.get(0).copyExpand():GraphreeD.clipboard.get(0).deepCopy()); + 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?GraphreeD.clipboard.copyExpand():GraphreeD.clipboard.deepCopy()); - GraphreeD.clipboard.get(0).parent = keepparent; + makeSomething(expand?GrafreeD.clipboard.copyExpand():GrafreeD.clipboard.deepCopy()); + GrafreeD.clipboard.get(0).parent = keepparent; } ResetModel(); @@ -4039,7 +4306,7 @@ void pasteInto(boolean copyit) { -// if (GraphreeD.clipboard == null) +// if (GrafreeD.clipboard == null) // return; if (group.selection.size() != 1) @@ -4072,9 +4339,9 @@ { boolean first = true; - if (GraphreeD.clipboardIsTempGroup) + if (GrafreeD.clipboardIsTempGroup) { - Composite temp = (Composite)GraphreeD.clipboard; + Composite temp = (Composite)GrafreeD.clipboard; Object3D copy; for (Enumeration e = temp.children.elements(); e.hasMoreElements();) { @@ -4084,7 +4351,7 @@ } } else { - linkSomething(GraphreeD.clipboard); //.get(0)); + linkSomething(GrafreeD.clipboard); //.get(0)); } } } @@ -4276,6 +4543,26 @@ makeSomething(csg); } + void Ungroup(Object3D g) + { + if (g instanceof HiddenObject) + { + HiddenObject h = (HiddenObject) g; + + for (int i=0; i<h.ActualSize(); i++) + { + objEditor.makeSomething(h.get(i), false); + } + } + else + { + for (int i=0; i<g.Size(); i++) + { + objEditor.makeSomething(g.get(i), false); + } + } + } + void ungroup() { /* @@ -4471,7 +4758,7 @@ void ImportGFD() { - FileDialog browser = new FileDialog(objEditor.frame, "Import GraphreeD", FileDialog.LOAD); + FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD); browser.show(); String filename = browser.getFile(); if (filename != null && filename.length() > 0) @@ -4509,7 +4796,7 @@ void ImportVRMLX3D() { - if (GraphreeD.standAlone) + if (GrafreeD.standAlone) { /**/ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD); @@ -4526,7 +4813,7 @@ String GetFile(String dialogName) { - if (GraphreeD.standAlone) + if (GrafreeD.standAlone) { FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD); browser.show(); @@ -4635,6 +4922,7 @@ private MenuItem resetsupportItem; private MenuItem resetreferencesItem; private MenuItem linkverticesItem; + private MenuItem relinkverticesItem; private MenuItem setMasterItem; private MenuItem resetMeshItem; private MenuItem stepAllItem; @@ -4653,8 +4941,10 @@ private MenuItem clearItem; private MenuItem clearAllItem; private MenuItem genUVItem; + private MenuItem genNormalsMESHItem; private MenuItem genNormalsCADItem; private MenuItem genNormalsORGANItem; + private MenuItem genNormalsMINEItem; private MenuItem stripifyItem; private MenuItem unstripifyItem; private MenuItem trimItem; @@ -4696,6 +4986,7 @@ private MenuItem resetCentroidItem; private MenuItem transformgeometryItem; private MenuItem resetTransformItem; + private MenuItem hideItem; private MenuItem grabItem; private MenuItem backItem; private MenuItem frontItem; @@ -4728,12 +5019,15 @@ 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 kleinItem; private MenuItem blobItem; private MenuItem latheItem; private MenuItem bezierItem; @@ -4746,6 +5040,7 @@ private MenuItem csgItem; private MenuItem templateItem; private MenuItem textureItem; + private MenuItem billboardItem; private MenuItem shadowXItem; private MenuItem shadowYItem; private MenuItem shadowZItem; -- Gitblit v1.6.2