From 314b34423070cf127464da79a53cddf6b1c38587 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sat, 06 May 2017 20:33:17 -0400 Subject: [PATCH] Skin shader --- GroupEditor.java | 545 +++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 373 insertions(+), 172 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index f50fede..4fa02b1 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); @@ -221,13 +222,13 @@ 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); menu.add("-"); @@ -247,7 +248,8 @@ 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); csgItem = menu.add(new MenuItem("CSG")); @@ -283,6 +285,8 @@ genNormalsORGANItem.addActionListener(this); genNormalsCADItem = menu.add(new MenuItem("CAD Normals")); genNormalsCADItem.addActionListener(this); + genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals")); + genNormalsMESHItem.addActionListener(this); stripifyItem = menu.add(new MenuItem("Stripify")); stripifyItem.addActionListener(this); unstripifyItem = menu.add(new MenuItem("Unstripify")); @@ -292,8 +296,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 +312,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 +338,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 +367,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 +1021,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")); @@ -1048,15 +1069,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 +1080,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 +1443,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 +1535,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()); @@ -1570,7 +1624,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 +1780,7 @@ if (event.getSource() == invariantsItem) { System.out.println("Invariants:"); - GraphreeD.theApplet3D.universe.invariants(); + GrafreeD.theApplet3D.universe.invariants(); } else if (event.getSource() == memoryItem) { @@ -1796,10 +1850,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 +1897,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 +1911,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); @@ -1995,9 +2053,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 +2064,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); @@ -2049,9 +2107,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 +2122,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); @@ -2253,6 +2311,10 @@ { GenNormals(true); } else + if (event.getSource() == genNormalsMESHItem) + { + GenNormals(true); // TODO + } else if (event.getSource() == genNormalsORGANItem) { GenNormals(false); @@ -2352,6 +2414,10 @@ if (event.getSource() == parseverticesItem) { ParseVertices(); + } else + if (event.getSource() == textureFieldItem) + { + TextureVertices(); } else if (event.getSource() == alignItem) { @@ -2750,7 +2816,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 +3131,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); } @@ -3157,96 +3223,228 @@ //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() { for (int i=0; i<group.selection.size(); i++) @@ -3267,7 +3465,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 +3495,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 +3517,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 +3711,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 +4062,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 +4107,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 +4148,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 +4172,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 +4187,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 +4201,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 +4221,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 +4237,7 @@ void pasteInto(boolean copyit) { -// if (GraphreeD.clipboard == null) +// if (GrafreeD.clipboard == null) // return; if (group.selection.size() != 1) @@ -4072,9 +4270,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 +4282,7 @@ } } else { - linkSomething(GraphreeD.clipboard); //.get(0)); + linkSomething(GrafreeD.clipboard); //.get(0)); } } } @@ -4471,7 +4669,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 +4707,7 @@ void ImportVRMLX3D() { - if (GraphreeD.standAlone) + if (GrafreeD.standAlone) { /**/ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD); @@ -4526,7 +4724,7 @@ String GetFile(String dialogName) { - if (GraphreeD.standAlone) + if (GrafreeD.standAlone) { FileDialog browser = new FileDialog(objEditor.frame, dialogName, FileDialog.LOAD); browser.show(); @@ -4653,6 +4851,7 @@ private MenuItem clearItem; private MenuItem clearAllItem; private MenuItem genUVItem; + private MenuItem genNormalsMESHItem; private MenuItem genNormalsCADItem; private MenuItem genNormalsORGANItem; private MenuItem stripifyItem; @@ -4728,6 +4927,8 @@ private MenuItem particleItem; private MenuItem ragdollItem; private MenuItem ragdoll2Item; + private MenuItem heightFieldItem; + private MenuItem textureFieldItem; private MenuItem gridItem; private MenuItem rectoidItem; private MenuItem ellipsoidItem; -- Gitblit v1.6.2