From 51e45bf615e1e2b4aca2edf9f7333b687c7d015e Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Tue, 24 Sep 2019 21:07:45 -0400 Subject: [PATCH] Remove hands. --- CameraPane.java | 1378 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 1,016 insertions(+), 362 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 69d4882..b558c23 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -1,4 +1,5 @@ +import com.bulletphysics.dynamics.RigidBody; import java.awt.*; import java.awt.event.*; import java.awt.image.*; @@ -110,7 +111,11 @@ //private Mat4f spotlightTransform = new Mat4f(); //private Mat4f spotlightInverseTransform = new Mat4f(); static GLContext glcontext = null; - /*static*/ com.sun.opengl.util.texture.Texture cubemap; + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; + boolean transformMode; + boolean reverseUP = false; static boolean frozen = false; boolean enablebackspace = false; // patch for back buffer refresh @@ -130,7 +135,7 @@ static boolean ZOOMBOXMODE = false; static boolean BOXMODE = false; static boolean IMAGEFLIP = false; -static boolean SMOOTHFOCUS = false; +static boolean SMOOTHFOCUS = true; // false; static boolean SPEAKERMOCAP = true; // jan 2014 false; static boolean SPEAKERCAMERA = false; static boolean SPEAKERFOCUS = false; @@ -164,16 +169,16 @@ // OPTIONS - boolean Skinshader = true; + boolean Skinshader = false; // true; boolean cameraLight = false; boolean UVdebug = false; boolean Udebug = false; boolean Vdebug = false; boolean NORMALdebug = false; - static boolean doublesided = false; // true; // reversed normals are awful for conformance + static boolean doublesided = true; // false; // reversed normals are awful for conformance boolean anisotropy = true; boolean softshadow = true; // slower but better false; - boolean opacityhalo = false; + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) boolean macromode = false; @@ -187,6 +192,19 @@ } private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); + + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException + { + try + { + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); + } catch (IOException e) + { + System.out.println("NAME = " + name); + e.printStackTrace(); // throw new RuntimeException(e); + return null; + } + } void SetAsGLRenderer(boolean b) { @@ -204,9 +222,10 @@ cameras = new Camera[2]; targetLookAts = new cVector[2]; - SetCamera(cam); + SetCamera(cam, true); - SetLight(new Camera(new cVector(10, 10, -20))); + // Warning: not used. + //SetLight(new Camera(new cVector(15, 10, -20))); object = o; @@ -524,7 +543,8 @@ LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); LA.vecCross(obj.v0, obj.v1, obj.v2); LA.vecNormalize(obj.v2); - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); + + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); } // P @@ -546,7 +566,7 @@ y += ny * obj.NORMALPUSH; z += nz * obj.NORMALPUSH; - gl.glNormal3f(nx, ny, nz); + SetGLNormal(gl, nx, ny, nz); } gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); SetColor(obj, pv); @@ -578,7 +598,7 @@ y += ny * obj.NORMALPUSH; z += nz * obj.NORMALPUSH; - gl.glNormal3f(nx, ny, nz); + SetGLNormal(gl, nx, ny, nz); } //System.out.println("vertexq = " + qv.s + ", " + qv.t); // boolean locked = false; @@ -626,7 +646,7 @@ y += ny * obj.NORMALPUSH; z += nz * obj.NORMALPUSH; - gl.glNormal3f(nx, ny, nz); + SetGLNormal(gl, nx, ny, nz); } // if ((dot&4) == 0) @@ -862,7 +882,7 @@ //// tris.postdraw(this); } - static Camera localcamera = new Camera(); + static Camera localAOcamera = new Camera(); static cVector from = new cVector(); static cVector to = new cVector(); @@ -871,7 +891,7 @@ CameraPane cp = this; Camera keep = cp.RenderCamera(); - cp.renderCamera = localcamera; + cp.renderCamera = localAOcamera; if (br.trimmed) { @@ -889,7 +909,7 @@ br.positions[i3 + 2] + br.normals[i3 + 2]); LA.xformPos(from, transform, from); LA.xformPos(to, transform, to); // RIGID ONLY - localcamera.setAim(from, to); + localAOcamera.setAim(from, to); CameraPane.occlusionbuffer.display(); @@ -923,7 +943,7 @@ to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); LA.xformPos(from, transform, from); LA.xformPos(to, transform, to); // RIGID ONLY - localcamera.setAim(from, to); + localAOcamera.setAim(from, to); CameraPane.occlusionbuffer.display(); @@ -1232,10 +1252,10 @@ { if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) { - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); } else { - gl.glNormal3f(0, 0, 1); + SetGLNormal(gl, 0, 0, 1); } if (c != null) @@ -1259,10 +1279,10 @@ { if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) { - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); } else { - gl.glNormal3f(0, 0, 1); + SetGLNormal(gl, 0, 0, 1); } if (c != null) { @@ -1287,10 +1307,10 @@ { if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) { - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); } else { - gl.glNormal3f(0, 0, 1); + SetGLNormal(gl, 0, 0, 1); } if (c != null) { @@ -1472,7 +1492,7 @@ { if (!selectmode) { - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); if (flipV) @@ -1484,6 +1504,8 @@ gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); } + float[] colorV = new float[4]; + void SetColor(Object3D obj, Vertex p0) { CameraPane display = this; @@ -1551,8 +1573,6 @@ { return; } - - float[] colorV = new float[3]; if (false) // marked) { @@ -1801,7 +1821,7 @@ display.modelParams7[0] = 0; display.modelParams7[1] = 1000; - display.modelParams7[2] = 0; + display.modelParams7[2] = material.parallax; display.modelParams7[3] = 0; //display.modelParams6[0] = 100; // criss de bug de bump @@ -2034,9 +2054,9 @@ switch(viewcode) { case 0: return "main"; - case 1: return "one"; - case 2: return "two"; - case 3: return "three"; + case 1: return "Red"; + case 2: return "Green"; + case 3: return "Blue"; case 4: return "light"; } @@ -2045,7 +2065,7 @@ static int camerachangeframe; - public boolean SetCamera(Camera cam) + public boolean SetCamera(Camera cam, boolean set) { // may 2014 if (cam == cameras[0] || cam == cameras[1]) // return false; @@ -2063,7 +2083,8 @@ camerachangeframe = Globals.framecount; - cam.hAspect = -1; // Read only + if (cam != null) + cam.hAspect = -1; // Read only cameras[0] = cam; targetLookAts[0] = new cVector(cam.lookAt); @@ -2073,11 +2094,14 @@ { cameras[i] = new Camera(cam.viewCode); } - - cameras[i].setAim(cam.location, cam.lookAt); - cameras[i].shaper_fovy = cam.shaper_fovy; - cameras[i].UP.set(cam.UP); - targetLookAts[i] = new cVector(cameras[i].lookAt); + + if (set) + { + cameras[i].setAim(cam.location, cam.lookAt); + cameras[i].shaper_fovy = cam.shaper_fovy; + cameras[i].UP.set(cam.UP); + targetLookAts[i] = new cVector(cameras[i].lookAt); + } } cameracount = 0; targetLookAt = targetLookAts[cameracount]; @@ -2086,7 +2110,7 @@ // Start with free camera SwitchCameras(true); - pingthread.jump = true; // optional? +// pingthread.jump = true; // optional? if (TRACKONCE) { @@ -2273,18 +2297,6 @@ public void ToggleTrack() { TRACK ^= true; - if (TRACK) - { - if (object.selection != null && - object.selection.size() > 0 && - object.selection.elementAt(0) != null && - !(object.selection.elementAt(0) instanceof Camera) && - !(object.selection.elementAt(0) instanceof ScriptNode)) - { - trackedobject = object.selection.elementAt(0); - repaint(); - } - } repaint(); } @@ -2376,7 +2388,8 @@ { //System.out.println("PROTECTION = " + cam.hAspect); //assert (cam.hAspect == 0); - cam.hAspect = 0; + if (cam != null) + cam.hAspect = 0; lightCamera = cam; } @@ -2457,6 +2470,18 @@ return CreateBim(bytes, width, height); } + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) + { + gl.glNormal3f(nx, ny, nz); + + if (ny > 0.9 || ny < -0.9) + // Ground or ceiling + gl.glVertexAttrib3f(4, 1, 0, 0); + else + // Walls + gl.glVertexAttrib3f(4, 0, 1, 0); + } + /**/ class CacheTexture { @@ -2499,7 +2524,7 @@ com.sun.opengl.util.texture.TextureIO.newTextureData( getClass().getClassLoader().getResourceAsStream(name), true, - com.sun.opengl.util.texture.TextureIO.PNG); + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); } catch (java.io.IOException e) { throw new javax.media.opengl.GLException(e); @@ -3565,6 +3590,8 @@ }; /**/ + static Object3D lastObject; + //com.sun.opengl.util.texture.Texture TextureData GetFileTexture(String name, boolean bump, int resolution) @@ -3601,6 +3628,8 @@ // return null; //if (i == 2) // return null; + // TIFF issue sept 2019 + System.err.println("lastObject = " + lastObject); e.printStackTrace(); name = name.split("\\.tif")[0] + ".jpg"; } @@ -6933,30 +6962,30 @@ short residu = 0; // wraparound workarounds - short fuck = (short) (buffer[i] & 0xFF); + short ww = (short) (buffer[i] & 0xFF); /* - residu += (fuck%2); - if(fuck/2 < 256-residu/2) + residu += (ww%2); + if(ww/2 < 256-residu/2) { - fuck = (short)((fuck/2) + residu/2); + ww = (short)((ww/2) + residu/2); if(residu == 2) residu = 0; } else { residu = 0; - fuck /= 2; + ww /= 2; } */ - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) { - fuck /= 2; + ww /= 2; } else { - fuck = (short) ((fuck / 2) + fuck % 2); + ww = (short) ((ww / 2) + ww % 2); } - buffer[i] = (byte) fuck; + buffer[i] = (byte) ww; } //System.out.print(bytes[i] + " "); //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; @@ -8345,7 +8374,7 @@ // else // if (!texname.startsWith("/")) // texname = "/Users/nbriere/Textures/" + texname; - if (!FileExists(texname)) + if (!FileExists(texname) && !texname.startsWith("@")) { texname = fallbackTextureName; } @@ -8423,7 +8452,16 @@ { // texturecache = textures.get(texname); // suspicious if (texturecache == null) - texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); + texturecache = new CacheTexture(GetResourceTexture("whitenoise.jpg", bump),resolution); + else + new Exception().printStackTrace(); + } else + { + if (texname.startsWith("@") && textureon) + { + // texturecache = textures.get(texname); // suspicious + if (texturecache == null) + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); else new Exception().printStackTrace(); } else @@ -8487,6 +8525,7 @@ texturecache = new CacheTexture(texturedata,resolution); //texture = GetTexture(tex, bump); } + } } //} } @@ -8601,7 +8640,9 @@ { tex.bw = texturecache.texturedata.getWidth(); tex.bh = texturecache.texturedata.getHeight(); - tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); + tex.bumpdata = //CompressJPEG(CreateBim( + ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); + //, tex.bw, tex.bh), 0.5f); } } } @@ -8755,10 +8796,12 @@ gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); MAXSTACK = temp[0]; - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); + if (Globals.DEBUG) + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); MAXSTACK = temp[0]; - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); + if (Globals.DEBUG) + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); // Use debug pipeline //drawable.setGL(new DebugGL(gl)); // @@ -8766,7 +8809,8 @@ gl = drawable.getGL(); // GL gl3 = getGL(); - System.out.println("INIT GL IS: " + gl.getClass().getName()); + if (Globals.DEBUG) + System.out.println("INIT GL IS: " + gl.getClass().getName()); //float pos[] = { 100, 100, 100, 0 }; @@ -8931,7 +8975,7 @@ if (cubemap == null) { - LoadEnvy(5); + //LoadEnvy(1); } //cubemap.enable(); @@ -9207,6 +9251,8 @@ void LoadEnvy(int which) { + assert(false); + String name; String ext; @@ -9218,37 +9264,58 @@ cubemap = null; return; case 1: - name = "cubemaps/box_"; - ext = "png"; + name = "cubemaps/rgb/"; + ext = "jpg"; reverseUP = false; break; case 2: - name = "cubemaps/uffizi_"; - ext = "png"; - break; // reverseUP = true; break; + name = "cubemaps/uffizi/"; + ext = "jpg"; + reverseUP = false; + break; case 3: - name = "cubemaps/CloudyHills_"; - ext = "tga"; + name = "cubemaps/CloudyHills/"; + ext = "jpg"; reverseUP = false; break; case 4: - name = "cubemaps/cornell_"; + name = "cubemaps/cornell/"; ext = "png"; reverseUP = false; break; + case 5: + name = "cubemaps/skycube/"; + ext = "jpg"; + reverseUP = false; + break; + case 6: + name = "cubemaps/SaintLazarusChurch3/"; + ext = "jpg"; + reverseUP = false; + break; + case 7: + name = "cubemaps/Sodermalmsallen/"; + ext = "jpg"; + reverseUP = false; + break; + case 8: + name = "cubemaps/Sodermalmsallen2/"; + ext = "jpg"; + reverseUP = false; + break; + case 9: + name = "cubemaps/UnionSquare/"; + ext = "jpg"; + reverseUP = false; + break; default: - name = "cubemaps/rgb_"; - ext = "png"; /*mipmap = true;*/ reverseUP = false; + name = "cubemaps/box/"; + ext = "png"; /*mipmap = true;*/ + reverseUP = false; break; } - - try - { - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); - } catch (IOException e) - { - throw new RuntimeException(e); - } + + LoadSkybox(name, ext, mipmap); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) @@ -9280,8 +9347,12 @@ static double[] model = new double[16]; double[] camera2light = new double[16]; double[] light2camera = new double[16]; - int newenvy = -1; - boolean envyoff = true; // false; + + //int newenvy = -1; + //boolean envyoff = false; + + String loadedskyboxname; + cVector light0 = new cVector(0, 0, 0); // 1,3,2); //float[] light0 = { 0,0,0 }; cVector dirlight = new cVector(0, 0, 1); // 1,3,2); @@ -9699,7 +9770,7 @@ if (renderCamera != lightCamera) //for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); @@ -9715,7 +9786,7 @@ if (renderCamera != lightCamera) //for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); @@ -9761,13 +9832,18 @@ rati = 1 / rati; gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); } - assert (newenvy == -1); + + //assert (newenvy == -1); + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); - DrawSkyBox(gl); + DrawSkyBox(gl, (float)rati); gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); - accPerspective(gl, renderCamera.shaper_fovy / ratio, + + boolean vr = capsLocked && !lightMode; + + accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1), ratio, //near_plane, far_plane, renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(), @@ -10630,9 +10706,18 @@ static boolean init = false; double[][] matrix = LA.newMatrix(); + + // This is to refresh the UI of the material panel. + ObjEditor patchMaterial; public void display(GLAutoDrawable drawable) { + if (patchMaterial.patchMaterial) + { + patchMaterial.patchMaterial = false; + patchMaterial.objectTabbedPane.setSelectedIndex(1); + } + if (Grafreed.savesound && Grafreed.hassound) { Grafreed.wav.save(); @@ -10728,6 +10813,112 @@ if (DrawMode() == DEFAULT) { + if (manipCamera == lightCamera) + { +// switch (e.getKeyCode()) +// { +// case DOWN_ARROW: +// lightCamera.DECAL /= 2; +// repaint(); +// break; +// case UP_ARROW: +// lightCamera.DECAL *= 2; +// repaint(); +// break; +// case LEFT_ARROW: +// lightCamera.SCALE /= 2; +// repaint(); +// break; +// case RIGHT_ARROW: +// lightCamera.SCALE *= 2; +// repaint(); +// break; +// default: +// break; + if (keys[DOWN_ARROW]) + { + lightCamera.DECAL /= 2; + } + + if (keys[UP_ARROW]) + { + lightCamera.DECAL *= 2; + } + + if (keys[LEFT_ARROW]) + { + lightCamera.SCALE /= 2; + } + + if (keys[RIGHT_ARROW]) + { + lightCamera.SCALE *= 2; + } + } + else + { + //pingthread.mute = true; + + boolean keyon = false; + + if (keys[DOWN_ARROW]) + { + speed = ++speedkey[DOWN_ARROW]; + if (speed > 20) + speed = 20; + GoDown(modifiers); + keyon = true; + } + else + speedkey[DOWN_ARROW] = 0; + + if (keys[UP_ARROW]) + { + speed = ++speedkey[UP_ARROW]; + if (speed > 20) + speed = 20; + GoUp(modifiers); + keyon = true; + } + else + speedkey[UP_ARROW] = 0; + + if (keys[LEFT_ARROW]) + { + speed = ++speedkey[LEFT_ARROW]; + if (speed > 20) + speed = 20; + GoLeft(modifiers); + keyon = true; + } + else + speedkey[LEFT_ARROW] = 0; + + if (keys[RIGHT_ARROW]) + { + speed = ++speedkey[RIGHT_ARROW]; + if (speed > 20) + speed = 20; + GoRight(modifiers); + keyon = true; + } + else + speedkey[RIGHT_ARROW] = 0; + + if (Globals.WALK && capsLocked) + { + Walk(); + keyon = true; + } + + if (keyon) + { + repaint(); + } + + //pingthread.mute = false; + } + currentlydrawing = true; } @@ -10801,7 +10992,7 @@ if (wait) { - Sleep(500); + Sleep(200); // blocks everything wait = false; } @@ -10916,7 +11107,7 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) //for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); for (int j = 0; j < 4; j++) { @@ -10931,7 +11122,7 @@ // if (parentcam != renderCamera) // not a light if (cam != lightCamera) //for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); @@ -11017,13 +11208,43 @@ gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); } - if (newenvy > -1) +// if (newenvy > -1) +// { +// LoadEnvy(newenvy); +// } +// +// newenvy = -1; + + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) { - LoadEnvy(newenvy); + if (cubemaprgb == null) + { + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); + } + + cubemap = cubemaprgb; } - - newenvy = -1; - + else + { + if (object.skyboxname != null) + { + if (!object.skyboxname.equals(this.loadedskyboxname)) + { + if (cubemap != null && cubemap != cubemaprgb) + cubemap.dispose(); + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); + loadedskyboxname = object.skyboxname; + } + } + else + { + cubemapcustom = null; + loadedskyboxname = null; + } + + cubemap = cubemapcustom; + } + ratio = ((double) getWidth()) / getHeight(); //System.out.println("ratio = " + ratio); @@ -11039,7 +11260,7 @@ if (!IsFrozen() && !ambientOcclusion) { - DrawSkyBox(gl); + DrawSkyBox(gl, (float)ratio); } //if (selection_view == -1) @@ -11222,9 +11443,9 @@ gl.glMatrixMode(GL.GL_MODELVIEW); -gl.glEnable(gl.GL_POLYGON_SMOOTH); -gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); -gl.glEnable(gl.GL_MULTISAMPLE); +//gl.glEnable(gl.GL_POLYGON_SMOOTH); +//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); +//gl.glEnable(gl.GL_MULTISAMPLE); } else { //gl.glDisable(GL.GL_TEXTURE_2D); @@ -11285,7 +11506,10 @@ //gl.glOrtho(-BOOST, BOOST, -BOOST, BOOST, 0.001, 1000); } else { - glu.gluPerspective(cam.shaper_fovy / ratio, ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); + boolean vr = capsLocked && !lightMode; + + glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 1.2 : 1), + ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); } } @@ -11325,7 +11549,7 @@ // if (cam != lightCamera) //for (int count = parentcam.GetTransformCount(); --count>=0;) - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 } LA.xformDir(lightposition, cam.toScreen, lightposition); @@ -11641,8 +11865,11 @@ repaint(); } - if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 + if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 + { + renderCamera.computeTransform(); repaint(); + } displaydone = true; } @@ -11717,9 +11944,23 @@ //GL gl = getGL(); if ((TRACK || SHADOWTRACK) || zoomonce) { + if (TRACK) + { + if (object.selection != null && + object.selection.size() > 0 && + object.selection.elementAt(0) != null && + !(object.selection.elementAt(0) instanceof Camera) && + !(object.selection.elementAt(0) instanceof ScriptNode)) + { + trackedobject = object.selection.elementAt(0); + //repaint(); + } + else + trackedobject = null; + } if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); - pingthread.StepToTarget(true); // true); + pingthread.StepToTarget(); // true); // zoomonce = false; } @@ -12399,51 +12640,80 @@ //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); - String program = + String programmin = // Min shader "!!ARBfp1.0\n" + - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + - "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + + "PARAM pow2 = { 2, 4, 8, 0.0 };" + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + + "PARAM light2cam0 = program.env[10];" + + "PARAM light2cam1 = program.env[11];" + + "PARAM light2cam2 = program.env[12];" + "TEMP temp;" + "TEMP light;" + "TEMP ndotl;" + "TEMP normal;" + "TEMP depth;" + + "TEMP eye;" + + "TEMP pos;" + - "MAD normal, fragment.color, zero123.z, -zero123.y;" + - + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + + Normalize("normal") + "MOV light, state.light[0].position;" + "DP3 ndotl.x, light, normal;" + + "MAX ndotl.x, ndotl.x, zero12t.x;" + // shadow - "MOV temp, fragment.texcoord[1];" + - TextureFetch("depth", "temp", "1") + + "MOV pos, fragment.texcoord[1];" + + "MOV temp, pos;" + + ShadowTextureFetch("depth", "temp", "1") + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + - + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + // No shadow when out of frustum //"SGE temp.y, depth.z, zero123.y;" + //"LRP temp.x, temp.y, zero123.y, temp.x;" + - "MUL ndotl.x, ndotl.x, temp.x;" + - "MAX ndotl.x, ndotl.x, pow2.y;" + + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow + // Backlit + "MOV pos.w, zero12t.y;" + // one + "DP4 eye.x, pos, light2cam0;" + + "DP4 eye.y, pos, light2cam1;" + + "DP4 eye.z, pos, light2cam2;" + + Normalize("eye") + + + "DP3 ndotl.y, -eye, normal;" + + //"MUL ndotl.y, ndotl.y, pow2.x;" + + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit + //"SUB ndotl.y, zero123.y, ndotl.y;" + + //"MUL ndotl.y, ndotl.y, pow2.z;" + + "ADD ndotl.y, ndotl.y, one.x;" + + "MUL ndotl.y, ndotl.y, pow_2.x;" + + + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient + + // Pigment "TEX temp, fragment.texcoord[0], texture[0], 2D;" + - "LRP temp, zero123.w, temp, one;" + // texture proportion - "MUL temp, temp, ndotl.x;" + + "LRP temp, zero12t.w, temp, one;" + // texture proportion + "MUL temp, temp, zero12t.w;" + // Times x - "MUL temp, temp, zero123.z;" + + //"MUL temp, temp, ndotl.y;" + + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + - "MOV temp.w, zero123.y;" + // reset alpha + "MUL temp, temp, ndotl.x;" + // lambert + "MOV temp.w, zero12t.y;" + // reset alpha "MOV result.color, temp;" + "END"; - String program2 = + String programmax = "!!ARBfp1.0\n" + //"OPTION ARB_fragment_program_shadow;" + @@ -12471,7 +12741,7 @@ "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough - "PARAM params7 = program.env[7];" + // noise power, opacity power + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax "PARAM options0 = program.env[63];" + // fog density, intensity, elevation "PARAM options1 = program.env[62];" + // fog rgb color "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen @@ -12581,20 +12851,20 @@ "MUL temp, floor, mapgrid.x;" + //"TEX depth0, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth0", "temp", "1") + + ShadowTextureFetch("depth0", "temp", "1") + "") + "ADD temp.x, temp.x, mapgrid.x;" + //"TEX depth1, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth1", "temp", "1") + + ShadowTextureFetch("depth1", "temp", "1") + "") + "ADD temp.y, temp.y, mapgrid.x;" + //"TEX depth2, temp, texture[1], 2D;" + - TextureFetch("depth2", "temp", "1") + + ShadowTextureFetch("depth2", "temp", "1") + "SUB temp.x, temp.x, mapgrid.x;" + //"TEX depth3, temp, texture[1], 2D;" + (((mode & FP_SOFTSHADOW) == 0) ? "" : - TextureFetch("depth3", "temp", "1") + + ShadowTextureFetch("depth3", "temp", "1") + "") + //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + //"MOV params, material;" + @@ -12716,7 +12986,7 @@ "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut // mar 2013 ??? "KIL alpha.a;" + "MOV alpha, texSamp.aaaa;" + // y;" + - "KIL alpha.a;" + + "KIL alpha.a;" + // not sure with parallax mapping /* "MUL temp.xy, temp, two;" + "TXB bump, temp, texture[0], 2D;" + @@ -12802,11 +13072,6 @@ "SUB bump0, bump0, half;" + "ADD bump, bump, bump0;" + - "MOV temp.x, texSamp.a;" + - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion - //"LRP texSamp0, params5.x, texSamp0, one;" + - "MOV texSamp.a, temp.x;" + - // double-sided /**/ (doublesided?"DP3 temp.z, normal, eye;" + @@ -12816,26 +13081,73 @@ "ADD temp.x, temp.x, one.x;" + "MUL normal, normal, temp.xxxx;":"" ) + - /**/ -//// Normalize("normal") + -//// "MAX normal.z, eps.x, normal.z;" + -// Normalize("normal") + - "MOV normald, normal;" + - "MOV normals, normal;" + + /**/ + + "MOV temp, fragment.texcoord[4];" + // UV base //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + + Normalize("UP") + + "XPD V, normal, UP;" + Normalize("V") + "XPD U, V, normal;" + Normalize("U") + + "MOV temp, fragment.texcoord[0];" + + +// "MAD normal, -temp.x, U, normal;" + +// "MAD normal, -temp.y, V, normal;" + +// Normalize("normal") + + +//// "MAX normal.z, eps.x, normal.z;" + +// Normalize("normal") + + "MOV normald, normal;" + + "MOV normals, normal;" + + // parallax mapping + + "DP3 temp2.x, V, eye;" + + "DP3 temp2.y, U, eye;" + + "DP3 temp2.z, normal, eye;" + + "RCP temp2.z, temp2.z;" + + + "DP3 temp2.w, texSamp, texSamp;" + // Height + "RSQ temp2.w, temp2.w;" + + "RCP temp2.w, temp2.w;" + + + "SUB temp2.w, temp2.w, half;" + + // "SGE temp.x, temp2.w, eps.x;" + + // "MUL temp2.w, temp2.w, temp.x;" + + + // "MOV texSamp, U;" + + + "MUL temp2.z, temp2.z, temp2.w;" + + "MUL temp2.z, temp2.z, params7.z;" + // parallax + + "MUL temp2, temp2, temp2.z;" + + + "SUB temp, temp, temp2;" + + + "TEX temp, temp, texture[0], 2D;" + + "POW temp.a, temp.a, params6.w;" + // punch through + + "ADD texSamp, temp, texSamp;" + + "MUL texSamp.xyz, half, texSamp;" + + + "MOV alpha, texSamp.aaaa;" + + +// parallax mapping + + "MOV temp.x, texSamp.a;" + + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion + //"LRP texSamp0, params5.x, texSamp0, one;" + + "MOV texSamp.a, temp.x;" + //"MOV temp, fragment.texcoord[0];" + // @@ -12968,7 +13280,7 @@ // display shadow only (fakedepth == 0) "SUB temp.x, half.x, shadow.x;" + "MOV temp.y, -params5.z;" + // params6.x;" + - "SLT temp.z, temp.y, -one2048th.x;" + + "SLT temp.z, temp.y, -c256i.x;" + "SUB temp.y, one.x, temp.z;" + "MUL temp.x, temp.x, temp.y;" + "KIL temp.x;" + @@ -13299,8 +13611,19 @@ //once = true; } - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); + String program = programmax; + + if (Globals.MINSHADER) + { + program = programmin; + } + + if (Globals.DEBUG) + { + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); + } + loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); //gl.glNewList(displayListID, GL.GL_COMPILE); @@ -13347,7 +13670,8 @@ "\n" + "END\n"; - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); + if (Globals.DEBUG) + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); //gl.glNewList(displayListID, GL.GL_COMPILE); @@ -13392,7 +13716,8 @@ return out; } - String TextureFetch(String dest, String src, String unit) + // Also does frustum culling + String ShadowTextureFetch(String dest, String src, String unit) { return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + "SGE " + src + ".w, " + src + ".x, eps.x;" + @@ -13604,7 +13929,7 @@ /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax //Object3D.cVector2[] vector2buffer; @@ -13771,7 +14096,7 @@ "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + @@ -13832,7 +14157,7 @@ "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + - //"MOV result.texcoord, vertex.texcoord;" + + //"MOV result.texcoord, vertex.fogcoord;" + "MOV result.texcoord, temp;" + // border fade "MOV result.texcoord[3], vertex.texcoord;" + @@ -13879,7 +14204,9 @@ //"ADD temp.z, temp.z, one;" + - "MOV result.color, temp;" + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir + + "MOV result.color, temp;" // Normal : "MOV result.color, vertex.color;") + ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" : "") + @@ -14014,10 +14341,13 @@ public void mouseClicked(MouseEvent e) { System.out.println("mouseClicked: " + e); + System.exit(0); } public void mousePressed(MouseEvent e) { + RigidBody.justclicked = true; + System.out.println("justclicked: " + e); //System.out.println("mousePressed: " + e); clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); } @@ -14052,10 +14382,12 @@ return; } - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + + boolean vr = capsLocked && !lightMode; // TIMER - if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !vr) // VR { keepboxmode = BOXMODE; keepsupport = SUPPORT; @@ -14096,7 +14428,7 @@ //} SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); + drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx()); anchorX = ax; anchorY = ay; prevX = px; @@ -14191,8 +14523,9 @@ // fev 2014??? if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); - pingthread.StepToTarget(true); // true); + pingthread.StepToTarget(); // true); } + // if (!LIVE) super.repaint(); } @@ -14255,14 +14588,15 @@ drag = false; //System.out.println("Mouse DOWN"); editObj = false; - ClickInfo info = new ClickInfo(); - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - info.pane = this; - info.camera = renderCamera; - info.x = x; - info.y = y; - info.modifiers = modifiersex; - editObj = object.doEditClick(info, 0); + //ClickInfo info = new ClickInfo(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; + object.clickInfo.x = x; + object.clickInfo.y = y; + object.clickInfo.modifiers = modifiersex; + editObj = object.doEditClick(//info, + 0); if (!editObj) { hasMarquee = true; @@ -14286,8 +14620,8 @@ //if (drawing) //return; - if ((e.getModifiersEx() & CTRL) != 0 - || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) + if ((e.getModifiersEx() & CTRL) != 0 || + (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) { //System.out.println("mouseDragged: " + e); clickEnd(e.getX(), e.getY(), e.getModifiersEx()); @@ -14311,9 +14645,17 @@ return targetLookAt; } + javax.vecmath.Point3d eye = new javax.vecmath.Point3d(); + javax.vecmath.Point3d eye2 = new javax.vecmath.Point3d(); + javax.vecmath.Vector3d dir = new javax.vecmath.Vector3d(); + + class PingThread extends Thread { boolean jump; + boolean live; + + boolean mute; // void JumpToTarget() // { @@ -14329,6 +14671,88 @@ // only one thread!? synchronized void StepToTarget(boolean jump) { + RigidBody.pos.x = 0; + RigidBody.pos.y = 0; + RigidBody.pos.z = 0; + if (RigidBody.justclicked) + { + RigidBody.pos.x = (float)manipCamera.lookAt.x; + RigidBody.pos.y = (float)manipCamera.lookAt.y; + RigidBody.pos.z = (float)manipCamera.lookAt.z; + RigidBody.wind.set(RigidBody.pos); + RigidBody.wind.x -= (float)manipCamera.location.x; + RigidBody.wind.y -= (float)manipCamera.location.y; + RigidBody.wind.z -= (float)manipCamera.location.z; + RigidBody.wind.normalize(); + } + + if (mute) + return; + + if (capsLocked && manipCamera.viewCode == 0) + { + eye.x = manipCamera.location.x; + eye.y = manipCamera.location.y + 0.25; + eye.z = manipCamera.location.z; + + dir.y = -1; + + Ray ray = new Ray(eye, dir); + + IntersectResult res = new IntersectResult(); + res.t = Double.POSITIVE_INFINITY; + + tmp.set(targetLookAt); + tmp.sub(manipCamera.location); + + double dist = tmp.length(); + + tmp.normalize(); + + eye2.x = manipCamera.location.x + tmp.x * 0.25; + eye2.y = manipCamera.location.y + 0.25; + eye2.z = manipCamera.location.z + tmp.z * 0.25; + + Ray ray2 = new Ray(eye2, dir); + + IntersectResult res2 = new IntersectResult(); + res2.t = Double.POSITIVE_INFINITY; + + if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25) + { + //tmp.set(manipCamera.location); + + manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t; + manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5; + manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t; + + //tmp.sub(manipCamera.location); + + targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t; + targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5; + targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t; + + targetLookAt.sub(manipCamera.location); + targetLookAt.normalize(); + targetLookAt.mul(dist); + targetLookAt.add(manipCamera.location); + + //if (tmp.dot(tmp) > 0.000001) + // System.out.println("INTERSECTION " + manipCamera.location); + + manipCamera.lookAt.set(targetLookAt); + + tmp.x = res.n.x; + tmp.y = res.n.y; + tmp.z = res.n.z; + tmp.x += res2.n.x; + tmp.y += res2.n.y; + tmp.z += res2.n.z; + tmp.normalize(); + manipCamera.UP.set(tmp); + } + } + tmp.set(targetLookAt); tmp.sub(manipCamera.lookAt); // june 2014 @@ -14366,7 +14790,7 @@ if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target { - jump = true; // step = 1; + // sep 2019 jump = true; // step = 1; } if (OEILONCE && OEIL) @@ -14401,7 +14825,10 @@ if (tmp.dot(tmp) < 0.00001) { zoomonce = false; + live = false; } + else + live = true; tmp.mul(step > step2 ? step : step2); } @@ -14428,7 +14855,7 @@ { if (LOOKAT) manipCamera.lookAt.add(tmp); - if (OEIL) + if (OEIL && !capsLocked) manipCamera.location.add(tmp); { @@ -14443,7 +14870,10 @@ lightCamera.computeTransform(); } } - manipCamera.computeTransform(); + if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0) + { + manipCamera.computeTransform(); + } } // ?????? mouseDown = true; //System.out.println("---------------- ---------- Paint " + tmp.length2()); @@ -14536,49 +14966,107 @@ } } } + PingThread pingthread = new PingThread(); - int delta = 5; - int speed = 5; + int delta = 1; + int speed = 1; + int walk = 8; boolean autorepeat = false; + void Walk() + { + manipCamera.BackForth(0, walk, 1000); + + targetLookAt.set(manipCamera.lookAt); + } + + void ViewAngle(float dy) + { + double factor = Math.exp(-dy/300.0); // (1 + dy/100); + + if (manipCamera.shaper_fovy * factor > 1 && + manipCamera.shaper_fovy * factor < 150) + { + manipCamera.shaper_fovy *= factor; + //System.out.println("fovy = " + shaper_fovy); + } + } + void GoDown(int mod) { MODIFIERS |= COMMAND; + boolean isVR = (mouseMode&VR)!=0; /**/ if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(0, -speed); - else - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); - /**/ - if ((mod & SHIFT) == SHIFT) { - mouseMode = mouseMode; // VR?? - } else - { - mouseMode |= BACKFORTH; +// if (isVR) +// manipCamera.RotateInterest(0, speed); +// else + if (isVR) + ViewAngle(-speed*delta); + else + manipCamera.Translate(0, -speed*delta, getWidth()); } + else + { + if (isVR) + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); + else + manipCamera.RotatePosition(0, -speed); + } + + /**/ +// if ((mod & SHIFT) == SHIFT) +// { +// mouseMode = mouseMode; // VR?? +// } else +// { +// mouseMode |= BACKFORTH; +// } + targetLookAt.set(manipCamera.lookAt); + //prevX = X = anchorX; prevY = Y = anchorY - (int) (renderCamera.Distance()); } void GoUp(int mod) { + RigidBody.justclicked = true; + MODIFIERS |= COMMAND; /**/ + boolean isVR = (mouseMode&VR)!=0; + if((mod&SHIFT) == SHIFT) - manipCamera.RotatePosition(0, speed); - else - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); - /**/ - if ((mod & SHIFT) == SHIFT) { - mouseMode = mouseMode; - } else - { - mouseMode |= BACKFORTH; +// if (isVR) +// manipCamera.RotateInterest(0, -speed); +// else + if (isVR) + ViewAngle(speed*delta); + else + manipCamera.Translate(0, speed*delta, getWidth()); } + else + { + if (isVR) + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); + else + manipCamera.RotatePosition(0, speed); + } + + /**/ +// if ((mod & SHIFT) == SHIFT) +// { +// mouseMode = mouseMode; +// } else +// { +// mouseMode |= BACKFORTH; +// } + targetLookAt.set(manipCamera.lookAt); + //prevX = X = anchorX; prevY = Y = anchorY + (int) (renderCamera.Distance()); } @@ -14588,18 +15076,29 @@ MODIFIERS |= COMMAND; /**/ if((mod&SHIFT) == SHIFT) - manipCamera.Translate(speed*delta, 0, getWidth()); + manipCamera.Translate(speed, 0, getWidth()); else - manipCamera.RotatePosition(speed, 0); + { + if ((mouseMode&VR)!=0) + manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0); + else + manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0); + } + /**/ - if ((mod & SHIFT) == SHIFT) - { - mouseMode = mouseMode; - } else - { - mouseMode |= ROTATE; - } // TRANSLATE; +// if ((mod & SHIFT) == SHIFT) +// { +// mouseMode = mouseMode; +// } else +// { +// mouseMode |= ROTATE; +// } // TRANSLATE; + //System.err.println("lookAt = " + manipCamera.lookAt); + //System.err.println("location = " + manipCamera.location); + + targetLookAt.set(manipCamera.lookAt); + prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); prevY = Y = anchorY; } @@ -14609,18 +15108,26 @@ MODIFIERS |= COMMAND; /**/ if((mod&SHIFT) == SHIFT) - manipCamera.Translate(-speed*delta, 0, getWidth()); + manipCamera.Translate(-speed, 0, getWidth()); else - manipCamera.RotatePosition(-speed, 0); + { + if ((mouseMode&VR)!=0) + manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0); + else + manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0); + } + /**/ - if ((mod & SHIFT) == SHIFT) - { - mouseMode = mouseMode; - } else - { - mouseMode |= ROTATE; - } // TRANSLATE; +// if ((mod & SHIFT) == SHIFT) +// { +// mouseMode = mouseMode; +// } else +// { +// mouseMode |= ROTATE; +// } // TRANSLATE; + targetLookAt.set(manipCamera.lookAt); + prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); prevY = Y = anchorY; } @@ -14662,15 +15169,16 @@ if (editObj) { drag = true; - ClickInfo info = new ClickInfo(); - info.bounds.setBounds(0, 0, + //ClickInfo info = new ClickInfo(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - info.pane = this; - info.camera = renderCamera; - info.x = x; - info.y = y; - object.GetWindow().copy - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; + object.clickInfo.x = x; + object.clickInfo.y = y; + object //.GetWindow().copy + .doEditDrag(//info, + (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -14753,6 +15261,11 @@ if ((mouseMode & ZOOM) != 0) { //if ((mouseMode & BACKFORTH) != 0) + if ((modifiersex & SHIFT) == SHIFT) + { + ViewAngle(dy); + } + else if ((mouseMode & VR) != 0) manipCamera.BackForth(dx, dy, getWidth()); else @@ -14819,24 +15332,30 @@ } } +// ClickInfo clickInfo = new ClickInfo(); + public void mouseMoved(MouseEvent e) { +//object.editWindow.frame. + setCursor(Cursor.getDefaultCursor()); + //System.out.println("mouseMoved: " + e); if (isRenderer) return; - ClickInfo ci = new ClickInfo(); - ci.x = e.getX(); - ci.y = e.getY(); - ci.modifiers = e.getModifiersEx(); - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); - ci.pane = this; - ci.camera = renderCamera; + // Mouse cursor feedback + object.clickInfo.x = e.getX(); + object.clickInfo.y = e.getY(); + object.clickInfo.modifiers = e.getModifiersEx(); + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); + object.clickInfo.pane = this; + object.clickInfo.camera = renderCamera; if (!isRenderer) { //ObjEditor editWindow = object.editWindow; //Object3D copy = editWindow.copy; - if (object.doEditClick(ci, 0)) + if (object.doEditClick(//clickInfo, + 0)) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else @@ -15004,8 +15523,10 @@ mouseMode |= ZOOM; } - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); - if (capsLocked) // || (modifiers & META) == META) + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); + boolean vr = capsLocked && !lightMode; + + if (vr) // || (modifiers & META) == META) { mouseMode |= VR; // BACKFORTH; } @@ -15017,7 +15538,8 @@ { mouseMode |= SELECT; } - if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) + if (//(modifiersex & SHIFT) == SHIFT || + forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) { mouseMode &= ~VR; mouseMode |= TRANSLATE; @@ -15061,8 +15583,18 @@ float SATPOW = 1; // 2; // 0.5f; float BRIPOW = 1; // 0.5f; // 0.5f; +static BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); + +// Create a new blank cursor. +static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor( + cursorImg, new Point(0, 0), "blank cursor"); + public void keyPressed(int key) { +// Set the blank cursor to the JFrame. +//object.editWindow.frame. + setCursor(blankCursor); + if (key >= '0' && key <= '5') clampbit = (key-'0'); @@ -15119,8 +15651,8 @@ case 'K': KOMPACTTEXTURE ^= true; //textures.clear(); - break; - case 'P': // Texture Projection macros + // break; + //case 'P': // Texture Projection macros // SAVETEXTURE ^= true; macromode = true; Udebug = Vdebug = NORMALdebug = false; programInitialized = false; @@ -15221,8 +15753,8 @@ RevertCamera(); repaint(); break; - case 'l': - //case 'L': + //case 'l': + case 'L': if (lightMode) { lightMode = false; @@ -15241,7 +15773,7 @@ targetLookAt.set(manipCamera.lookAt); repaint(); break; - case 'p': + case 'P': // p': // c'est quoi ca au juste? spherical ^= true; Skinshader ^= true; programInitialized = false; repaint(); @@ -15252,7 +15784,8 @@ break; case 'm': { - PrintMemory(); + //PrintMemory(); + ToggleImageFlip(); break; } case 'M': @@ -15279,27 +15812,31 @@ repaint(); break; case 'O': - Globals.drawMode = OCCLUSION; // WARNING - repaint(); - break; + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING + //repaint(); + //break; case 'o': OCCLUSION_CULLING ^= true; System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); break; - case '0': envyoff ^= true; repaint(); break; + //case '0': envyoff ^= true; repaint(); break; case '1': case '2': case '3': case '4': case '5': - newenvy = Character.getNumericValue(key); - repaint(); - break; case '6': case '7': case '8': case '9': - BGcolor = (key - '6')/3.f; + if (true) // envyoff) + { + BGcolor = (key - '1')/8.f; + } + else + { + //newenvy = Character.getNumericValue(key); + } repaint(); break; case '!': @@ -15369,7 +15906,21 @@ // kompactbit = 6; // break; case ' ': + capsLocked ^= true; + repaint(); + break; + case 'l': lightMode ^= true; + if (lightMode) + { + keepshadow = Globals.RENDERSHADOW; + Globals.RENDERSHADOW = false; + } + else + { + Globals.RENDERSHADOW = keepshadow; + } + Globals.lighttouched = true; manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; targetLookAt.set(manipCamera.lookAt); @@ -15377,6 +15928,10 @@ break; //case '`' : case ESC: + if (FULLSCREEN) + object.editWindow.ToggleFullScreen(); + break; + case 'p': RENDERPROGRAM += 1; RENDERPROGRAM %= 3; @@ -15415,6 +15970,10 @@ case ENTER: // object.editWindow.ScreenFit(); // Edit(); ToggleLive(); + if (capsLocked) + { + Globals.WALK ^= true; + } break; case DELETE: ClearSelection(); @@ -15451,17 +16010,23 @@ object.GetWindow().refreshContents(true); break; case '{': - manipCamera.shaper_fovy /= 1.1; + double factor = 1.1; + if (manipCamera.shaper_fovy / factor > 0.1) + manipCamera.shaper_fovy /= factor; System.out.println("FOV = " + manipCamera.shaper_fovy); repaint(); break; case '}': - manipCamera.shaper_fovy *= 1.1; + factor = 1.1; + if (manipCamera.shaper_fovy * factor < 150) + manipCamera.shaper_fovy *= factor; System.out.println("FOV = " + manipCamera.shaper_fovy); repaint(); break; case '[': - manipCamera.shaper_fovy /= 1.01; + factor = 1.01; + if (manipCamera.shaper_fovy / factor > 0.1) + manipCamera.shaper_fovy /= factor; if (false) //manipCamera.hAspect == 0) { double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); @@ -15477,7 +16042,9 @@ break; case ']': //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1; - manipCamera.shaper_fovy *= 1.01; + factor = 1.01; + if (manipCamera.shaper_fovy * factor < 150) + manipCamera.shaper_fovy *= factor; if (false) //manipCamera.hAspect == 0) { double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); @@ -15515,98 +16082,113 @@ } } + boolean keys[] = new boolean[256]; + int speedkey[] = new int[256]; + int modifiers = 0; + public void processKeyEvent(KeyEvent e) { switch (e.getID()) { case KeyEvent.KEY_PRESSED: - if (!autorepeat) - { - //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); - keyPressed(e.getKeyChar(), e.getModifiersEx()); - } - if (manipCamera == lightCamera) - { - switch (e.getKeyCode()) - { - case DOWN_ARROW: - lightCamera.DECAL /= 2; - repaint(); - break; - case UP_ARROW: - lightCamera.DECAL *= 2; - repaint(); - break; - case LEFT_ARROW: - lightCamera.SCALE /= 2; - repaint(); - break; - case RIGHT_ARROW: - lightCamera.SCALE *= 2; - repaint(); - break; - default: - break; - } - - System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); - } else - { - if (true) // !autorepeat) - { - boolean reset = true; - - switch (e.getKeyCode()) - { - case DOWN_ARROW: - GoDown(e.getModifiersEx()); - repaint(); - break; - case UP_ARROW: - GoUp(e.getModifiersEx()); - repaint(); - break; - case LEFT_ARROW: - GoLeft(e.getModifiersEx()); - repaint(); - break; - case RIGHT_ARROW: - GoRight(e.getModifiersEx()); - repaint(); - break; - default: - reset = false; - break; - } - - if (reset) - { - autorepeat = true; - - targetLookAt.set(manipCamera.lookAt); - } - } - } + keys[e.getKeyCode()] = true; + modifiers = e.getModifiersEx(); + keyPressed(e.getKeyChar(), modifiers); + //Globals.theRenderer.keyPressed(e.getKeyChar()); + repaint(); break; - case KeyEvent.KEY_TYPED: - break; +// if (!autorepeat) +// { +// //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); +// keyPressed(e.getKeyChar(), e.getModifiersEx()); +// } +// if (manipCamera == lightCamera) +// { +// switch (e.getKeyCode()) +// { +// case DOWN_ARROW: +// lightCamera.DECAL /= 2; +// repaint(); +// break; +// case UP_ARROW: +// lightCamera.DECAL *= 2; +// repaint(); +// break; +// case LEFT_ARROW: +// lightCamera.SCALE /= 2; +// repaint(); +// break; +// case RIGHT_ARROW: +// lightCamera.SCALE *= 2; +// repaint(); +// break; +// default: +// break; +// } +// +// System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); +// } else +// { +// if (true) // !autorepeat) +// { +// boolean reset = true; +// +// switch (e.getKeyCode()) +// { +// case DOWN_ARROW: +// GoDown(e.getModifiersEx()); +// repaint(); +// break; +// case UP_ARROW: +// GoUp(e.getModifiersEx()); +// repaint(); +// break; +// case LEFT_ARROW: +// GoLeft(e.getModifiersEx()); +// repaint(); +// break; +// case RIGHT_ARROW: +// GoRight(e.getModifiersEx()); +// repaint(); +// break; +// default: +// reset = false; +// break; +// } +// +// if (reset) +// { +// autorepeat = true; +// +// targetLookAt.set(manipCamera.lookAt); +// } +// } +// } +// break; +// case KeyEvent.KEY_TYPED: +// break; case KeyEvent.KEY_RELEASED: - { - switch (e.getKeyCode()) - { - case DOWN_ARROW: - case UP_ARROW: - case LEFT_ARROW: - case RIGHT_ARROW: - MODIFIERS &= ~COMMAND; - autorepeat = false; - break; - default: - break; - } + keys[e.getKeyCode()] = false; + modifiers = e.getModifiersEx(); keyReleased(e.getKeyChar(), e.getModifiersEx()); + repaint(); break; - } +// { +// switch (e.getKeyCode()) +// { +// case DOWN_ARROW: +// case UP_ARROW: +// case LEFT_ARROW: +// case RIGHT_ARROW: +// MODIFIERS &= ~COMMAND; +// autorepeat = false; +// break; +// default: +// break; +// } +// keyReleased(e.getKeyChar(), e.getModifiersEx()); +// break; +// } default: break; } @@ -15862,8 +16444,6 @@ int width = getBounds().width; int height = getBounds().height; - ClickInfo info = new ClickInfo(); - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); //Image img = CreateImage(width, height); //System.out.println("width = " + width + "; height = " + height + "\n"); @@ -15940,31 +16520,37 @@ } if (object != null && !hasMarquee) { + if (object.clickInfo == null) + object.clickInfo = new ClickInfo(); + ClickInfo info = object.clickInfo; + //ClickInfo info = new ClickInfo(); + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); + if (isRenderer) { - info.flags++; + object.clickInfo.flags++; double frameAspect = (double) width / (double) height; if (frameAspect > renderCamera.aspect) { int desired = (int) ((double) height * renderCamera.aspect); - info.bounds.width -= width - desired; - info.bounds.x += (width - desired) / 2; + object.clickInfo.bounds.width -= width - desired; + object.clickInfo.bounds.x += (width - desired) / 2; } else { int desired = (int) ((double) width / renderCamera.aspect); - info.bounds.height -= height - desired; - info.bounds.y += (height - desired) / 2; + object.clickInfo.bounds.height -= height - desired; + object.clickInfo.bounds.y += (height - desired) / 2; } } - info.g = gr; - info.camera = renderCamera; + object.clickInfo.g = gr; + object.clickInfo.camera = renderCamera; /* // Memory intensive (brep.verticescopy) if (!(object instanceof Composite)) object.draw(info, 0, false); // SLOW : */ - if (!isRenderer) + if (!isRenderer) // && drag) { Grafreed.Assert(object != null); Grafreed.Assert(object.selection != null); @@ -15972,9 +16558,9 @@ { int hitSomething = object.selection.get(0).hitSomething; - info.DX = 0; - info.DY = 0; - info.W = 1; + object.clickInfo.DX = 0; + object.clickInfo.DY = 0; + object.clickInfo.W = 1; if (hitSomething == Object3D.hitCenter) { info.DX = X; @@ -15986,13 +16572,14 @@ info.DY -= info.bounds.height/2; } - object.drawEditHandles(info, 0); + object.drawEditHandles(//info, + 0); if (drag && (X != 0 || Y != 0)) { switch (hitSomething) { - case Object3D.hitCenter: gr.setColor(Color.pink); + case Object3D.hitCenter: gr.setColor(Color.white); gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); break; case Object3D.hitRotate: gr.setColor(Color.yellow); @@ -16018,7 +16605,7 @@ if (hasMarquee) { gr.setXORMode(Color.white); - gr.setColor(Color.red); + gr.setColor(Color.white); if (!firstime) { gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); @@ -16177,7 +16764,8 @@ public boolean mouseDrag(Event evt, int x, int y) { - //System.out.println("mouseDrag: " + evt); + System.out.println("mouseDrag: " + evt); + System.exit(0); /* drag = true; //System.out.println("Mouse DRAG"); @@ -16296,6 +16884,7 @@ public boolean mouseUp(Event evt, int x, int y) { System.out.println("mouseUp: " + evt); + System.exit(0); /* locked = false; if (isRenderer) @@ -16485,6 +17074,8 @@ private /*static*/ boolean firstime; private /*static*/ cVector newView = new cVector(); private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, @@ -16497,29 +17088,67 @@ { com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); + int usedsuf = 0; + for (int i = 0; i < suffixes.length; i++) { - String resourceName = basename + suffixes[i] + "." + suffix; - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), - mipmapped, - FileUtil.getFileSuffix(resourceName)); - if (data == null) + String[] suffixe = suffixes; + String[] fallback = suffixes2; + String[] fallfallback = suffixes3; + + for (int c=usedsuf; --c>=0;) { - throw new IOException("Unable to load texture " + resourceName); +// String[] temp = suffixe; +// suffixe = fallback; +// fallback = fallfallback; +// fallfallback = temp; } + + String resourceName = basename + suffixe[i] + "." + suffix; + TextureData data; + + try + { + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), + mipmapped, + FileUtil.getFileSuffix(resourceName)); + } + catch (Exception e) + { + try + { + resourceName = basename + fallback[i] + "." + suffix; + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), + mipmapped, + FileUtil.getFileSuffix(resourceName)); + } + catch (Exception e2) + { + resourceName = basename + fallfallback[i] + "." + suffix; + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), + mipmapped, + FileUtil.getFileSuffix(resourceName)); + } + } + //System.out.println("Target = " + targets[i]); cubemap.updateImage(data, targets[i]); } return cubemap; } + int bigsphere = -1; float BGcolor = 0.5f; - private void DrawSkyBox(GL gl) + float ambientLight[] = {1f, 1f, 1f, 1.0f}; + + private void DrawSkyBox(GL gl, float ratio) { - if (envyoff || cubemap == null) + if (//envyoff || + WIREFRAME || + cubemap == null) { gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); gl.glClear(gl.GL_COLOR_BUFFER_BIT); @@ -16534,7 +17163,17 @@ // Compensates for ExaminerViewer's modification of modelview matrix gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); + gl.glScalef(1,ratio,1); +// colorV[0] = 2; +// colorV[1] = 2; +// colorV[2] = 2; +// colorV[3] = 1; +// gl.glDisable(gl.GL_COLOR_MATERIAL); +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); +// +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); + //gl.glActiveTexture(GL.GL_TEXTURE1); //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); @@ -16566,6 +17205,7 @@ { gl.glScalef(1.0f, -1.0f, 1.0f); } + gl.glScalef(-1.0f, 1.0f, 1.0f); gl.glMultMatrixd(viewrot_1, 0); gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); //viewer.updateInverseRotation(gl); @@ -16606,7 +17246,8 @@ gl.glDisable(GL.GL_TEXTURE_GEN_R); cubemap.disable(); - ////cubemap.unbind(); + //cubemap.dispose(); + if (CULLFACE) { gl.glEnable(gl.GL_CULL_FACE); @@ -16662,7 +17303,7 @@ gl.glScalef(1.0f, -1.0f, 1.0f); } - gl.glNormal3f(0.0f, 0.0f, 1.0f); + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); float step = 2; // 0.1666f; //0.25f; float stepv = 2; // step * 1652 / 998; @@ -16824,7 +17465,7 @@ //new Exception().printStackTrace(); System.out.println("select buffer init"); // Use debug pipeline - drawable.setGL(new DebugGL(drawable.getGL())); + //drawable.setGL(new DebugGL(drawable.getGL())); GL gl = drawable.getGL(); @@ -16951,7 +17592,7 @@ float depth = depths[y * TEX_SIZE + x]; - if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1) + if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1) { pointselection = false; @@ -17142,6 +17783,7 @@ public void init(GLAutoDrawable drawable) { + if (Globals.DEBUG) System.out.println("shadow buffer init"); GL gl = drawable.getGL(); @@ -17370,10 +18012,14 @@ gl.glFlush(); /**/ - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); - float[] pixels = occlusionsizebuffer.array(); + float[] depths = occlusiondepthbuffer.array(); + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); + + int[] pixels = selectsizebuffer.array(); + double r = 0, g = 0, b = 0; double count = 0; @@ -17384,7 +18030,7 @@ double FACTOR = 1; - for (int i = 0; i < pixels.length; i++) + for (int i = 0; i < depths.length; i++) { int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; @@ -17467,7 +18113,7 @@ double scale = ray.z; // 1; // cos - float depth = pixels[newindex]; + float depth = depths[newindex]; /* int newindex2 = (x + 1) * OCCLUSION_SIZE + y; @@ -17610,6 +18256,11 @@ static boolean DEBUG_SELECTION = false; boolean OCCLUSION_CULLING = false; //true; public boolean lightMode = false; + + private boolean keepshadow; + + static public boolean capsLocked = false; // VR + static public int indexcount = 0; /*static*/ cColor vertexOcclusion = new cColor(); //private int selection_view = -1; @@ -17664,11 +18315,14 @@ static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); static IntBuffer bigAAbuffer; static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); + + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); + static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); -- Gitblit v1.6.2