├── DataMosh.pde ├── data ├── family.jpg ├── fractal.gif ├── fractal_spiral.gif ├── gorilla.gif ├── hex.gif ├── mandelbrot.gif ├── manson.jpg ├── pendulum.gif ├── puppy.jpg ├── spectrum.jpg ├── spiral.gif └── triangle.gif └── libraries ├── JMyron ├── copy these into processing root or system32 │ ├── DSVL.dll │ └── myron_ezcam.dll └── library │ ├── JMyron.dll │ ├── JMyron.jar │ ├── export.txt │ └── libJMyron.jnilib ├── gifAnimation ├── docs │ └── index.html ├── examples │ ├── gifDisplay │ │ ├── data │ │ │ └── lavalamp.gif │ │ └── gifDisplay.pde │ └── gifExport │ │ ├── data │ │ └── processing.png │ │ └── gifExport.pde ├── library │ └── gifAnimation.jar └── src │ ├── Gif.java │ ├── GifDecoder.java │ ├── GifEncoder.java │ └── GifMaker.java ├── library3402223586595970989download └── peasycam.zip ├── msafluid ├── examples │ ├── MSAFluidDemo │ │ ├── MSAFluidDemo.pde │ │ ├── Particle.pde │ │ ├── ParticleSystem.pde │ │ └── TuioHandler.pde │ └── MSAFluidTuioDemo │ │ ├── MSAFluidTuioDemo.pde │ │ ├── Particle.pde │ │ ├── ParticleSystem.pde │ │ └── TuioHandler.pde ├── library │ └── MSAFluid.jar ├── reference │ ├── allclasses-frame.html │ ├── allclasses-noframe.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── msafluid │ │ ├── MSAFluidSolver.html │ │ ├── MSAFluidSolver2D.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html │ ├── overview-tree.html │ ├── package-list │ ├── resources │ │ └── inherit.gif │ ├── stylesheet.css │ └── template │ │ ├── HelloWorld.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html └── src │ └── msafluid │ └── MSAFluidSolver2D.java ├── peasy ├── CameraState.java ├── DampedAction.java ├── InterpolationManager.java ├── InterpolationUtil.java ├── PeasyCam.java ├── PeasyDragHandler.java ├── PeasyWheelHandler.java └── org │ └── apache │ └── commons │ └── math │ ├── MathException.java │ └── geometry │ ├── CardanEulerSingularityException.java │ ├── NotARotationMatrixException.java │ ├── Rotation.java │ ├── RotationOrder.java │ └── Vector3D.java ├── peasycam ├── examples │ └── HelloPeasy │ │ └── HelloPeasy.pde ├── library.properties ├── library │ └── peasycam.jar ├── reference │ ├── allclasses-frame.html │ ├── allclasses-noframe.html │ ├── constant-values.html │ ├── deprecated-list.html │ ├── help-doc.html │ ├── index-all.html │ ├── index.html │ ├── overview-frame.html │ ├── overview-summary.html │ ├── overview-tree.html │ ├── package-list │ ├── peasy │ │ ├── CameraState.html │ │ ├── DampedAction.html │ │ ├── InterpolationUtil.html │ │ ├── PeasyCam.AbstractInterp.html │ │ ├── PeasyCam.html │ │ ├── PeasyDragHandler.html │ │ ├── PeasyWheelHandler.html │ │ ├── org │ │ │ └── apache │ │ │ │ └── commons │ │ │ │ └── math │ │ │ │ ├── MathException.html │ │ │ │ ├── geometry │ │ │ │ ├── CardanEulerSingularityException.html │ │ │ │ ├── NotARotationMatrixException.html │ │ │ │ ├── Rotation.html │ │ │ │ ├── RotationOrder.html │ │ │ │ ├── Vector3D.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ └── package-tree.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ └── package-tree.html │ │ ├── package-frame.html │ │ ├── package-summary.html │ │ └── package-tree.html │ ├── resources │ │ └── inherit.gif │ ├── serialized-form.html │ └── stylesheet.css └── src │ └── peasy │ ├── CameraState.java │ ├── DampedAction.java │ ├── InterpolationManager.java │ ├── InterpolationUtil.java │ ├── PeasyCam.java │ ├── PeasyDragHandler.java │ ├── PeasyWheelHandler.java │ └── org │ └── apache │ └── commons │ └── math │ ├── MathException.java │ └── geometry │ ├── CardanEulerSingularityException.java │ ├── NotARotationMatrixException.java │ ├── Rotation.java │ ├── RotationOrder.java │ └── Vector3D.java └── traer_physics_lib_src ├── physics └── library │ └── physics.jar └── src ├── Attraction.java ├── EulerIntegrator.java ├── Force.java ├── Integrator.java ├── ModifiedEulerIntegrator.java ├── Particle.java ├── ParticleSystem.java ├── RungeKuttaIntegrator.java ├── Spring.java └── Vector3D.java /DataMosh.pde: -------------------------------------------------------------------------------- 1 | import processing.opengl.*; 2 | import gifAnimation.*; 3 | import JMyron.*; 4 | 5 | PImage currentFrame, prevFrame, staticImage; 6 | PImage[] allFrames; 7 | // currentFrame and prevFrame are the location to temporarily store the previous 8 | // and current frame. 9 | int NROWS, NCOLS; 10 | int PIXELSIZE = 6; //has to be even 11 | final float LIMIT = 30.0; 12 | 13 | int w, h; 14 | // w and h are the size of the grid. 15 | JMyron camera; 16 | 17 | boolean USE_GIF = false; 18 | boolean USE_BLEND_MODE = true; 19 | boolean PAUSE = false; 20 | 21 | int blendMode = LIGHTEST; 22 | int videoWidth = 640; 23 | int videoHeight = 480; 24 | 25 | void setup(){ 26 | 27 | size(1280, 960, OPENGL); 28 | //hint(ENABLE_OPENGL_4X_SMOOTH); 29 | frameRate(60); 30 | 31 | camera = new JMyron(); 32 | camera.start(videoWidth, videoHeight); 33 | camera.findGlobs(0); 34 | 35 | currentFrame = createImage(videoWidth,videoHeight,ARGB); 36 | prevFrame = createImage(videoWidth,videoHeight,ARGB); 37 | staticImage = createImage(videoWidth,videoHeight,ARGB); 38 | 39 | NROWS = int(currentFrame.height/PIXELSIZE); 40 | NCOLS = int(currentFrame.width/PIXELSIZE); 41 | 42 | w = currentFrame.width/NCOLS; 43 | h = currentFrame.height/NROWS; 44 | 45 | if(USE_GIF) 46 | { 47 | allFrames = Gif.getPImages(this, "gorilla.gif"); 48 | currentFrame.width = allFrames[1].width; 49 | currentFrame.height = allFrames[1].height; 50 | } 51 | } 52 | 53 | int frameCounter = 0; 54 | void draw(){ 55 | if(!PAUSE) 56 | { 57 | if(USE_GIF) 58 | { 59 | if(frameCounter > allFrames.length-2) 60 | { 61 | frameCounter = 0; 62 | }else{ 63 | frameCounter++; 64 | } 65 | } 66 | 67 | background(#FFFFFF); 68 | // copy the image from currentFrame to prevFrame - the previous frame. 69 | prevFrame.copy(currentFrame,0,0,currentFrame.width,currentFrame.height,0,0,prevFrame.width,prevFrame.height); 70 | prevFrame.updatePixels(); 71 | camera.update(); 72 | 73 | if(USE_GIF) 74 | { 75 | currentFrame = allFrames[frameCounter]; 76 | }else{ 77 | // update the current frame to currentFrame. 78 | camera.imageCopy(currentFrame.pixels); 79 | } 80 | currentFrame.updatePixels(); 81 | 82 | findFlow(); 83 | 84 | if(USE_BLEND_MODE){ staticImage.blend(currentFrame, 0, 0, videoWidth, videoHeight, 0, 0, videoWidth, videoHeight, blendMode); } 85 | image(staticImage, videoWidth, 0, videoWidth, videoHeight); 86 | } 87 | } 88 | 89 | void dataMosh(Point p1, Point p2) { 90 | if(p1.x < staticImage.width && p1.y < staticImage.height) 91 | { 92 | int dx = int(p2.x - p1.x); 93 | int dy = int(p2.y - p1.y); 94 | 95 | for (int y = 0 - (h/2); y < (h/2); y++) { 96 | for (int x = 0 - (w/2); x < (w/2); x++) { 97 | if(p2.x+x < staticImage.width-1 && p2.y+y < staticImage.height-1) 98 | { 99 | color c1 = staticImage.pixels[(p2.y+y)*staticImage.width+(p2.x+x)]; 100 | 101 | for(int xLine = p1.x; xLine < p2.x; xLine++){ 102 | int yLine = p1.y + (dy) * (xLine-p1.x)/(dx); 103 | staticImage.pixels[(yLine+y)*staticImage.width+(xLine+x)] = c1; 104 | } 105 | } 106 | } 107 | } 108 | } 109 | } 110 | 111 | void keyPressed() 112 | { 113 | if(key == 'w') 114 | { 115 | staticImage = createImage(videoWidth,videoHeight,ARGB); 116 | camera.update(); 117 | camera.imageCopy(staticImage.pixels); 118 | staticImage.updatePixels(); 119 | }else if(key == 'i'){ 120 | staticImage = loadImage("manson.jpg"); 121 | staticImage.updatePixels(); 122 | }else if(key == 'p'){ 123 | PAUSE = !PAUSE; 124 | }else if(key == 'b'){ 125 | USE_BLEND_MODE = !USE_BLEND_MODE; 126 | } 127 | 128 | switch(key) 129 | { 130 | case '1': 131 | blendMode = ADD; 132 | break; 133 | case '2': 134 | blendMode = SUBTRACT; 135 | break; 136 | case '3': 137 | blendMode = LIGHTEST; 138 | break; 139 | case '4': 140 | blendMode = DARKEST; 141 | break; 142 | case '5': 143 | blendMode = DIFFERENCE; 144 | break; 145 | case '6': 146 | blendMode = EXCLUSION; 147 | break; 148 | case '7': 149 | blendMode = MULTIPLY; 150 | break; 151 | case '8': 152 | blendMode = SCREEN; 153 | break; 154 | case '9': 155 | blendMode = OVERLAY; 156 | break; 157 | case '0': 158 | blendMode = BLEND; 159 | break; 160 | } 161 | } 162 | 163 | //OPTICAL FLOW FUNCTIONS 164 | 165 | void findFlow() { 166 | int xOff = w/2; 167 | int yOff = h/2; 168 | for (int r=1;r. 24 | */ 25 | 26 | package gifAnimation; 27 | 28 | import java.awt.Color; 29 | import java.awt.image.BufferedImage; 30 | import processing.core.PApplet; 31 | import processing.core.PConstants; 32 | import processing.core.PImage; 33 | 34 | public class GifMaker implements PConstants { 35 | public final static int DISPOSE_NOTHING = 0; 36 | public final static int DISPOSE_KEEP = 1; 37 | public final static int DISPOSE_RESTORE_BACKGROUND = 2; 38 | public final static int DISPOSE_REMOVE = 3; 39 | private GifEncoder encoder; 40 | private PApplet parent; 41 | 42 | public GifMaker(PApplet parent, String filename) { 43 | this.parent = parent; 44 | parent.registerDispose(this); 45 | encoder = initEncoder(filename); 46 | } 47 | 48 | public GifMaker(PApplet parent, String filename, int quality) { 49 | this.parent = parent; 50 | parent.registerDispose(this); 51 | encoder = initEncoder(filename); 52 | setQuality(quality); 53 | } 54 | 55 | public GifMaker(PApplet parent, String filename, int quality, int bgColor) { 56 | this.parent = parent; 57 | parent.registerDispose(this); 58 | encoder = initEncoder(filename); 59 | setQuality(quality); 60 | setTransparent(bgColor); 61 | } 62 | 63 | /* 64 | * finish stuff up when sketch is killed 65 | */ 66 | public void dispose() { 67 | finish(); 68 | } 69 | 70 | private GifEncoder initEncoder(String filename) { 71 | GifEncoder returnEncoder = new GifEncoder(); 72 | returnEncoder.start(parent.savePath(filename)); 73 | return returnEncoder; 74 | } 75 | 76 | /* 77 | * adds a delay to the last added frame int in milliseconds 78 | */ 79 | public void setDelay(int delay) { 80 | encoder.setDelay(delay); 81 | } 82 | 83 | /* 84 | * set the disposal mode for the last added frame 85 | * 86 | * from GIF specs: CODE MEANING 00 Nothing special 01 KEEP - retain the 87 | * current image 02 RESTORE BACKGROUND - restore the background color 03 88 | * REMOVE - remove the current image, and restore whatever image was beneath 89 | * it. 90 | */ 91 | public void setDispose(int dispose) { 92 | encoder.setDispose(dispose); 93 | } 94 | 95 | /** 96 | * description taken from GifEncoder-class: Sets quality of color 97 | * quantization (conversion of images to the maximum 256 colors allowed by 98 | * the GIF specification). Lower values (minimum = 1) produce better colors, 99 | * but slow processing significantly. 10 is the default, and produces good 100 | * color mapping at reasonable speeds. Values greater than 20 do not yield 101 | * significant improvements in speed. 102 | * 103 | * @param quality 104 | * int greater than 0. 105 | * @return 106 | */ 107 | public void setQuality(int quality) { 108 | encoder.setQuality(quality); 109 | } 110 | 111 | /* 112 | * sets the amount of times the animation should repeat 113 | * 114 | */ 115 | public void setRepeat(int repeat) { 116 | encoder.setRepeat(repeat); 117 | } 118 | 119 | /* 120 | * sets the size of the GIF-file. if this method is not invoked, the size of 121 | * the first added frame will be the image size. 122 | */ 123 | public void setSize(int width, int height) { 124 | encoder.setSize(width, height); 125 | } 126 | 127 | /* 128 | * Sets the transparent color. Every pixel with this color will be 129 | * transparent in the output File 130 | */ 131 | public void setTransparent(int color) { 132 | setTransparent((int) parent.red(color), (int) parent.green(color), 133 | (int) parent.blue(color)); 134 | } 135 | 136 | public void setTransparent(float red, float green, float blue) { 137 | setTransparent((int) red, (int) green, (int) blue); 138 | } 139 | 140 | public void setTransparent(int red, int green, int blue) { 141 | encoder.setTransparent(new Color(red, green, blue)); 142 | } 143 | 144 | /* 145 | * adds a frame to the current animation takes a PImage, or a pixel-array. 146 | * if no parameter is passed, the currently displayed pixels in the sketch 147 | * window is used. 148 | */ 149 | public void addFrame() { 150 | parent.loadPixels(); 151 | addFrame(parent.pixels, parent.width, parent.height); 152 | } 153 | 154 | public void addFrame(PImage newImage) { 155 | addFrame(newImage.pixels, newImage.width, newImage.height); 156 | } 157 | 158 | public void addFrame(int[] pixels, int width, int height) { 159 | BufferedImage frame = new BufferedImage(width, height, 160 | BufferedImage.TYPE_INT_ARGB); 161 | frame.setRGB(0, 0, width, height, pixels, 0, width); 162 | encoder.addFrame(frame); 163 | } 164 | 165 | /* 166 | * finishes off the GIF-file and saves it to the given filename 167 | * in the sketch directory. if the file already exists, it will 168 | * be overridden! 169 | */ 170 | public boolean finish() { 171 | return encoder.finish(); 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /libraries/library3402223586595970989download/peasycam.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GODPUS/processing-datamosh/34faf4cfc22bbdb4791aee4935b928e7c8eba012/libraries/library3402223586595970989download/peasycam.zip -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidDemo/MSAFluidDemo.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Demo of the MSAFluid library (www.memo.tv/msafluid_for_processing) 4 | Move mouse to add dye and forces to the fluid. 5 | Click mouse to turn off fluid rendering seeing only particles and their paths. 6 | Demonstrates feeding input into the fluid and reading data back (to update the particles). 7 | Also demonstrates using Vertex Arrays for particle rendering. 8 | 9 | /*********************************************************************** 10 | 11 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 12 | *** The Mega Super Awesome Visuals Company *** 13 | * All rights reserved. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions are met: 17 | * 18 | * * Redistributions of source code must retain the above copyright 19 | * notice, this list of conditions and the following disclaimer. 20 | * * Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * * Neither the name of MSA Visuals nor the names of its contributors 24 | * may be used to endorse or promote products derived from this software 25 | * without specific prior written permission. 26 | * 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 29 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 32 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 33 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 34 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 35 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 36 | * OF THE POSSIBILITY OF SUCH DAMAGE. 37 | * 38 | * ***********************************************************************/ 39 | 40 | import msafluid.*; 41 | 42 | import processing.opengl.*; 43 | import javax.media.opengl.*; 44 | 45 | final float FLUID_WIDTH = 120; 46 | 47 | float invWidth, invHeight; // inverse of screen dimensions 48 | float aspectRatio, aspectRatio2; 49 | 50 | MSAFluidSolver2D fluidSolver; 51 | 52 | ParticleSystem particleSystem; 53 | 54 | PImage imgFluid; 55 | 56 | boolean drawFluid = true; 57 | 58 | void setup() { 59 | size(960, 640, OPENGL); // use OPENGL rendering for bilinear filtering on texture 60 | // size(screen.width * 49/50, screen.height * 49/50, OPENGL); 61 | hint( ENABLE_OPENGL_4X_SMOOTH ); // Turn on 4X antialiasing 62 | 63 | invWidth = 1.0f/width; 64 | invHeight = 1.0f/height; 65 | aspectRatio = width * invHeight; 66 | aspectRatio2 = aspectRatio * aspectRatio; 67 | 68 | // create fluid and set options 69 | fluidSolver = new MSAFluidSolver2D((int)(FLUID_WIDTH), (int)(FLUID_WIDTH * height/width)); 70 | fluidSolver.enableRGB(true).setFadeSpeed(0.003).setDeltaT(0.5).setVisc(0.0001); 71 | 72 | // create image to hold fluid picture 73 | imgFluid = createImage(fluidSolver.getWidth(), fluidSolver.getHeight(), RGB); 74 | 75 | // create particle system 76 | particleSystem = new ParticleSystem(); 77 | 78 | // init TUIO 79 | initTUIO(); 80 | } 81 | 82 | 83 | void mouseMoved() { 84 | float mouseNormX = mouseX * invWidth; 85 | float mouseNormY = mouseY * invHeight; 86 | float mouseVelX = (mouseX - pmouseX) * invWidth; 87 | float mouseVelY = (mouseY - pmouseY) * invHeight; 88 | 89 | addForce(mouseNormX, mouseNormY, mouseVelX, mouseVelY); 90 | } 91 | 92 | void draw() { 93 | updateTUIO(); 94 | fluidSolver.update(); 95 | 96 | if(drawFluid) { 97 | for(int i=0; i 0) { 129 | if(x<0) x = 0; 130 | else if(x>1) x = 1; 131 | if(y<0) y = 0; 132 | else if(y>1) y = 1; 133 | 134 | float colorMult = 5; 135 | float velocityMult = 30.0f; 136 | 137 | int index = fluidSolver.getIndexForNormalizedPosition(x, y); 138 | 139 | color drawColor; 140 | 141 | colorMode(HSB, 360, 1, 1); 142 | float hue = ((x + y) * 180 + frameCount) % 360; 143 | drawColor = color(hue, 1, 1); 144 | colorMode(RGB, 1); 145 | 146 | fluidSolver.rOld[index] += red(drawColor) * colorMult; 147 | fluidSolver.gOld[index] += green(drawColor) * colorMult; 148 | fluidSolver.bOld[index] += blue(drawColor) * colorMult; 149 | 150 | particleSystem.addParticles(x * width, y * height, 10); 151 | fluidSolver.uOld[index] += dx * velocityMult; 152 | fluidSolver.vOld[index] += dy * velocityMult; 153 | } 154 | } 155 | 156 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidDemo/Particle.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | class Particle { 33 | final static float MOMENTUM = 0.5; 34 | final static float FLUID_FORCE = 0.6; 35 | 36 | float x, y; 37 | float vx, vy; 38 | float radius; // particle's size 39 | float alpha; 40 | float mass; 41 | 42 | void init(float x, float y) { 43 | this.x = x; 44 | this.y = y; 45 | vx = 0; 46 | vy = 0; 47 | radius = 5; 48 | alpha = random(0.3, 1); 49 | mass = random(0.1, 1); 50 | } 51 | 52 | 53 | void update() { 54 | // only update if particle is visible 55 | if(alpha == 0) return; 56 | 57 | // read fluid info and add to velocity 58 | int fluidIndex = fluidSolver.getIndexForNormalizedPosition(x * invWidth, y * invHeight); 59 | vx = fluidSolver.u[fluidIndex] * width * mass * FLUID_FORCE + vx * MOMENTUM; 60 | vy = fluidSolver.v[fluidIndex] * height * mass * FLUID_FORCE + vy * MOMENTUM; 61 | 62 | // update position 63 | x += vx; 64 | y += vy; 65 | 66 | // bounce of edges 67 | if(x<0) { 68 | x = 0; 69 | vx *= -1; 70 | } 71 | else if(x > width) { 72 | x = width; 73 | vx *= -1; 74 | } 75 | 76 | if(y<0) { 77 | y = 0; 78 | vy *= -1; 79 | } 80 | else if(y > height) { 81 | y = height; 82 | vy *= -1; 83 | } 84 | 85 | // hackish way to make particles glitter when the slow down a lot 86 | if(vx * vx + vy * vy < 1) { 87 | vx = random(-1, 1); 88 | vy = random(-1, 1); 89 | } 90 | 91 | // fade out a bit (and kill if alpha == 0); 92 | alpha *= 0.999; 93 | if(alpha < 0.01) alpha = 0; 94 | 95 | } 96 | 97 | 98 | void updateVertexArrays(int i, FloatBuffer posBuffer, FloatBuffer colBuffer) { 99 | int vi = i * 4; 100 | posBuffer.put(vi++, x - vx); 101 | posBuffer.put(vi++, y - vy); 102 | posBuffer.put(vi++, x); 103 | posBuffer.put(vi++, y); 104 | 105 | int ci = i * 6; 106 | colBuffer.put(ci++, alpha); 107 | colBuffer.put(ci++, alpha); 108 | colBuffer.put(ci++, alpha); 109 | colBuffer.put(ci++, alpha); 110 | colBuffer.put(ci++, alpha); 111 | colBuffer.put(ci++, alpha); 112 | } 113 | 114 | 115 | void drawOldSchool(GL gl) { 116 | gl.glColor3f(alpha, alpha, alpha); 117 | gl.glVertex2f(x-vx, y-vy); 118 | gl.glVertex2f(x, y); 119 | } 120 | 121 | } 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidDemo/ParticleSystem.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | import java.nio.FloatBuffer; 33 | import com.sun.opengl.util.*; 34 | 35 | boolean renderUsingVA = true; 36 | 37 | void fadeToColor(GL gl, float r, float g, float b, float speed) { 38 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); 39 | gl.glColor4f(r, g, b, speed); 40 | gl.glBegin(GL.GL_QUADS); 41 | gl.glVertex2f(0, 0); 42 | gl.glVertex2f(width, 0); 43 | gl.glVertex2f(width, height); 44 | gl.glVertex2f(0, height); 45 | gl.glEnd(); 46 | } 47 | 48 | 49 | class ParticleSystem { 50 | FloatBuffer posArray; 51 | FloatBuffer colArray; 52 | 53 | final static int maxParticles = 5000; 54 | int curIndex; 55 | 56 | Particle[] particles; 57 | 58 | ParticleSystem() { 59 | particles = new Particle[maxParticles]; 60 | for(int i=0; i 0) { 83 | particles[i].update(); 84 | particles[i].updateVertexArrays(i, posArray, colArray); 85 | } 86 | } 87 | gl.glEnableClientState(GL.GL_VERTEX_ARRAY); 88 | gl.glVertexPointer(2, GL.GL_FLOAT, 0, posArray); 89 | 90 | gl.glEnableClientState(GL.GL_COLOR_ARRAY); 91 | gl.glColorPointer(3, GL.GL_FLOAT, 0, colArray); 92 | 93 | gl.glDrawArrays(GL.GL_LINES, 0, maxParticles * 2); 94 | } 95 | else { 96 | gl.glBegin(GL.GL_LINES); // start drawing points 97 | for(int i=0; i 0) { 99 | particles[i].update(); 100 | particles[i].drawOldSchool(gl); // use oldschool renderng 101 | } 102 | } 103 | gl.glEnd(); 104 | } 105 | 106 | gl.glDisable(GL.GL_BLEND); 107 | pgl.endGL(); 108 | } 109 | 110 | 111 | void addParticles(float x, float y, int count ){ 112 | for(int i=0; i= maxParticles) curIndex = 0; 120 | } 121 | 122 | } 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidDemo/TuioHandler.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | void initTUIO() { 33 | // implemented in the TUIO example 34 | } 35 | 36 | 37 | void updateTUIO() { 38 | // implemented in the TUIO example 39 | } 40 | 41 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidTuioDemo/MSAFluidTuioDemo.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * 3 | * Demo of the MSAFluid library (www.memo.tv/msafluid_for_processing) controlled by TUIO 4 | * Move mouse to add dye and forces to the fluid. 5 | * Alternatively use a TUIO tracker/server to control remotely (www.tuio.org) 6 | * 7 | * Click mouse to turn off fluid rendering seeing only particles and their paths. 8 | * Demonstrates feeding input into the fluid and reading data back (to update the particles). 9 | * Also demonstrates using Vertex Arrays for particle rendering. 10 | * 11 | /*********************************************************************** 12 | 13 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 14 | *** The Mega Super Awesome Visuals Company *** 15 | * All rights reserved. 16 | * 17 | * Redistribution and use in source and binary forms, with or without 18 | * modification, are permitted provided that the following conditions are met: 19 | * 20 | * * Redistributions of source code must retain the above copyright 21 | * notice, this list of conditions and the following disclaimer. 22 | * * Redistributions in binary form must reproduce the above copyright 23 | * notice, this list of conditions and the following disclaimer in the 24 | * documentation and/or other materials provided with the distribution. 25 | * * Neither the name of MSA Visuals nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 30 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 31 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 35 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 36 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 37 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 38 | * OF THE POSSIBILITY OF SUCH DAMAGE. 39 | * 40 | * ***********************************************************************/ 41 | 42 | import msafluid.*; 43 | 44 | import processing.opengl.*; 45 | import javax.media.opengl.*; 46 | 47 | final float FLUID_WIDTH = 120; 48 | 49 | float invWidth, invHeight; // inverse of screen dimensions 50 | float aspectRatio, aspectRatio2; 51 | 52 | MSAFluidSolver2D fluidSolver; 53 | 54 | ParticleSystem particleSystem; 55 | 56 | PImage imgFluid; 57 | 58 | boolean drawFluid = true; 59 | 60 | void setup() { 61 | size(960, 640, OPENGL); // use OPENGL rendering for bilinear filtering on texture 62 | // size(screen.width * 49/50, screen.height * 49/50, OPENGL); 63 | hint( ENABLE_OPENGL_4X_SMOOTH ); // Turn on 4X antialiasing 64 | 65 | invWidth = 1.0f/width; 66 | invHeight = 1.0f/height; 67 | aspectRatio = width * invHeight; 68 | aspectRatio2 = aspectRatio * aspectRatio; 69 | 70 | // create fluid and set options 71 | fluidSolver = new MSAFluidSolver2D((int)(FLUID_WIDTH), (int)(FLUID_WIDTH * height/width)); 72 | fluidSolver.enableRGB(true).setFadeSpeed(0.003).setDeltaT(0.5).setVisc(0.0001); 73 | 74 | // create image to hold fluid picture 75 | imgFluid = createImage(fluidSolver.getWidth(), fluidSolver.getHeight(), RGB); 76 | 77 | // create particle system 78 | particleSystem = new ParticleSystem(); 79 | 80 | // init TUIO 81 | initTUIO(); 82 | } 83 | 84 | 85 | void mouseMoved() { 86 | float mouseNormX = mouseX * invWidth; 87 | float mouseNormY = mouseY * invHeight; 88 | float mouseVelX = (mouseX - pmouseX) * invWidth; 89 | float mouseVelY = (mouseY - pmouseY) * invHeight; 90 | 91 | addForce(mouseNormX, mouseNormY, mouseVelX, mouseVelY); 92 | } 93 | 94 | void draw() { 95 | updateTUIO(); 96 | fluidSolver.update(); 97 | 98 | if(drawFluid) { 99 | for(int i=0; i 0) { 131 | if(x<0) x = 0; 132 | else if(x>1) x = 1; 133 | if(y<0) y = 0; 134 | else if(y>1) y = 1; 135 | 136 | float colorMult = 5; 137 | float velocityMult = 30.0f; 138 | 139 | int index = fluidSolver.getIndexForNormalizedPosition(x, y); 140 | 141 | color drawColor; 142 | 143 | colorMode(HSB, 360, 1, 1); 144 | float hue = ((x + y) * 180 + frameCount) % 360; 145 | drawColor = color(hue, 1, 1); 146 | colorMode(RGB, 1); 147 | 148 | fluidSolver.rOld[index] += red(drawColor) * colorMult; 149 | fluidSolver.gOld[index] += green(drawColor) * colorMult; 150 | fluidSolver.bOld[index] += blue(drawColor) * colorMult; 151 | 152 | particleSystem.addParticles(x * width, y * height, 10); 153 | fluidSolver.uOld[index] += dx * velocityMult; 154 | fluidSolver.vOld[index] += dy * velocityMult; 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidTuioDemo/Particle.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | class Particle { 33 | final static float MOMENTUM = 0.5; 34 | final static float FLUID_FORCE = 0.6; 35 | 36 | float x, y; 37 | float vx, vy; 38 | float radius; // particle's size 39 | float alpha; 40 | float mass; 41 | 42 | void init(float x, float y) { 43 | this.x = x; 44 | this.y = y; 45 | vx = 0; 46 | vy = 0; 47 | radius = 5; 48 | alpha = random(0.3, 1); 49 | mass = random(0.1, 1); 50 | } 51 | 52 | 53 | void update() { 54 | // only update if particle is visible 55 | if(alpha == 0) return; 56 | 57 | // read fluid info and add to velocity 58 | int fluidIndex = fluidSolver.getIndexForNormalizedPosition(x * invWidth, y * invHeight); 59 | vx = fluidSolver.u[fluidIndex] * width * mass * FLUID_FORCE + vx * MOMENTUM; 60 | vy = fluidSolver.v[fluidIndex] * height * mass * FLUID_FORCE + vy * MOMENTUM; 61 | 62 | // update position 63 | x += vx; 64 | y += vy; 65 | 66 | // bounce of edges 67 | if(x<0) { 68 | x = 0; 69 | vx *= -1; 70 | } 71 | else if(x > width) { 72 | x = width; 73 | vx *= -1; 74 | } 75 | 76 | if(y<0) { 77 | y = 0; 78 | vy *= -1; 79 | } 80 | else if(y > height) { 81 | y = height; 82 | vy *= -1; 83 | } 84 | 85 | // hackish way to make particles glitter when the slow down a lot 86 | if(vx * vx + vy * vy < 1) { 87 | vx = random(-1, 1); 88 | vy = random(-1, 1); 89 | } 90 | 91 | // fade out a bit (and kill if alpha == 0); 92 | alpha *= 0.999; 93 | if(alpha < 0.01) alpha = 0; 94 | 95 | } 96 | 97 | 98 | void updateVertexArrays(int i, FloatBuffer posBuffer, FloatBuffer colBuffer) { 99 | int vi = i * 4; 100 | posBuffer.put(vi++, x - vx); 101 | posBuffer.put(vi++, y - vy); 102 | posBuffer.put(vi++, x); 103 | posBuffer.put(vi++, y); 104 | 105 | int ci = i * 6; 106 | colBuffer.put(ci++, alpha); 107 | colBuffer.put(ci++, alpha); 108 | colBuffer.put(ci++, alpha); 109 | colBuffer.put(ci++, alpha); 110 | colBuffer.put(ci++, alpha); 111 | colBuffer.put(ci++, alpha); 112 | } 113 | 114 | 115 | void drawOldSchool(GL gl) { 116 | gl.glColor3f(alpha, alpha, alpha); 117 | gl.glVertex2f(x-vx, y-vy); 118 | gl.glVertex2f(x, y); 119 | } 120 | 121 | } 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidTuioDemo/ParticleSystem.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | import java.nio.FloatBuffer; 33 | import com.sun.opengl.util.*; 34 | 35 | boolean renderUsingVA = true; 36 | 37 | void fadeToColor(GL gl, float r, float g, float b, float speed) { 38 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); 39 | gl.glColor4f(r, g, b, speed); 40 | gl.glBegin(GL.GL_QUADS); 41 | gl.glVertex2f(0, 0); 42 | gl.glVertex2f(width, 0); 43 | gl.glVertex2f(width, height); 44 | gl.glVertex2f(0, height); 45 | gl.glEnd(); 46 | } 47 | 48 | 49 | class ParticleSystem { 50 | FloatBuffer posArray; 51 | FloatBuffer colArray; 52 | 53 | final static int maxParticles = 5000; 54 | int curIndex; 55 | 56 | Particle[] particles; 57 | 58 | ParticleSystem() { 59 | particles = new Particle[maxParticles]; 60 | for(int i=0; i 0) { 83 | particles[i].update(); 84 | particles[i].updateVertexArrays(i, posArray, colArray); 85 | } 86 | } 87 | gl.glEnableClientState(GL.GL_VERTEX_ARRAY); 88 | gl.glVertexPointer(2, GL.GL_FLOAT, 0, posArray); 89 | 90 | gl.glEnableClientState(GL.GL_COLOR_ARRAY); 91 | gl.glColorPointer(3, GL.GL_FLOAT, 0, colArray); 92 | 93 | gl.glDrawArrays(GL.GL_LINES, 0, maxParticles * 2); 94 | } 95 | else { 96 | gl.glBegin(GL.GL_LINES); // start drawing points 97 | for(int i=0; i 0) { 99 | particles[i].update(); 100 | particles[i].drawOldSchool(gl); // use oldschool renderng 101 | } 102 | } 103 | gl.glEnd(); 104 | } 105 | 106 | gl.glDisable(GL.GL_BLEND); 107 | pgl.endGL(); 108 | } 109 | 110 | 111 | void addParticles(float x, float y, int count ){ 112 | for(int i=0; i= maxParticles) curIndex = 0; 120 | } 121 | 122 | } 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /libraries/msafluid/examples/MSAFluidTuioDemo/TuioHandler.pde: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | 3 | Copyright (c) 2008, 2009, Memo Akten, www.memo.tv 4 | *** The Mega Super Awesome Visuals Company *** 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * * Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * * Neither the name of MSA Visuals nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 | * OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * ***********************************************************************/ 31 | 32 | import TUIO.*; 33 | TuioProcessing tuioClient; 34 | 35 | final static float tuioCursorSpeedMult = 0.02f; // the iphone screen is so small, easy to rack up huge velocities! need to scale down 36 | final static float tuioStationaryForce = 0.001; // force exerted when cursor is stationary 37 | final static float tuioDoubleTapDistanceThreshold2 = 0.01; // distance squared (in tuio units) of last two taps in order to count as doubletap 38 | final static float tuioDoubleTapTimeThreshold = 0.2; // seconds between last two taps in order to count as doubletap 39 | 40 | TuioPoint tuioLastTap; // stores last tap information (to detect double tap) 41 | boolean tuioDoubleTap = false; 42 | 43 | void initTUIO() { 44 | tuioClient = new TuioProcessing(this); 45 | } 46 | 47 | 48 | void updateTUIO() { 49 | Vector tuioCursorList = tuioClient.getTuioCursors(); 50 | for (int i=0;i 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 26 | 27 |
MSAFluidSolver2D 24 |
25 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 26 | 27 |
MSAFluidSolver2D 24 |
25 |
28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Constant Field Values

79 |
80 |
81 | Contents 84 | 85 | 86 | 87 | 88 | 90 | 91 |
89 | msafluid.*
92 | 93 |

94 | 95 | 96 | 97 | 98 | 99 | 100 | 102 | 103 | 104 | 105 | 106 | 107 |
msafluid.MSAFluidSolver2D
101 | public final java.lang.StringVERSION"1.3.0"
108 | 109 |

110 | 111 |

112 |


113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 133 | 136 | 137 | 138 | 139 | 142 | 158 | 159 |
134 | 135 |
160 | 161 | 162 | 163 |
164 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 165 | 166 | 167 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Deprecated API

79 |
80 |
81 | Contents
    82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 105 | 108 | 109 | 110 | 111 | 114 | 130 | 131 |
106 | 107 |
132 | 133 | 134 | 135 |
136 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 137 | 138 | 139 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Javadocs: MSAFluid 8 | 9 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | <H2> 28 | Frame Alert</H2> 29 | 30 | <P> 31 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 32 | <BR> 33 | Link to<A HREF="msafluid/package-summary.html">Non-frame version.</A> 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/msafluid/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | msafluid (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | msafluid 20 | 21 | 22 | 27 | 28 |
23 | Classes  24 | 25 |
26 | MSAFluidSolver2D
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/msafluid/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | msafluid (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 46 | 49 | 50 | 51 | 52 | 55 | 71 | 72 |
47 | 48 |
73 | 74 | 75 | 76 |
77 |

78 | Package msafluid 79 |

80 | 81 | 82 | 83 | 85 | 86 | 87 | 88 | 96 | 97 |
84 | Class Summary
MSAFluidSolver2Dthis is a class for solving real-time fluid dynamics simulations based on Navier-Stokes equations 89 | and code from Jos Stam's paper "Real-Time Fluid Dynamics for Games" http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf 90 | Other useful resources and implementations I looked at while building this lib: 91 | Mike Ash (C) - http://mikeash.com/?page=pyblog/fluid-simulation-for-dummies.html 92 | Alexander McKenzie (Java) - http://www.multires.caltech.edu/teaching/demos/java/stablefluids.htm 93 | Pierluigi Pesenti (AS3 port of Alexander's) - http://blog.oaxoa.com/2008/01/21/actionscript-3-fluids-simulation/ 94 | Gustav Taxen (C) - http://www.nada.kth.se/~gustavt/fluids/ 95 | Dave Wallin (C++) - http://nuigroup.com/touchlib/ (uses portions from Gustav's)
98 |   99 | 100 |

101 |

102 |
103 |
104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 124 | 127 | 128 | 129 | 130 | 133 | 149 | 150 |
125 | 126 |
151 | 152 | 153 | 154 |
155 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 156 | 157 | 158 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/msafluid/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | msafluid Class Hierarchy (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Hierarchy For Package msafluid 79 |

80 |
81 |

82 | Class Hierarchy 83 |

84 | 88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 141 | 142 | 143 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Class Hierarchy (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Hierarchy For All Packages

79 |
80 |
81 |
Package Hierarchies:
msafluid
82 |
83 |

84 | Class Hierarchy 85 |

86 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 |
142 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 143 | 144 | 145 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/package-list: -------------------------------------------------------------------------------- 1 | msafluid 2 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GODPUS/processing-datamosh/34faf4cfc22bbdb4791aee4935b928e7c8eba012/libraries/msafluid/reference/resources/inherit.gif -------------------------------------------------------------------------------- /libraries/msafluid/reference/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | /* Define colors, fonts and other style attributes here to override the defaults */ 3 | /* processingLibs style by andreas schlegel, sojamo */ 4 | 5 | 6 | body { 7 | margin : 0; 8 | padding : 0; 9 | padding-left : 10px; 10 | padding-right : 8px; 11 | background-color : #FFFFFF; 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.7em; 15 | font-weight : normal; 16 | line-height : normal; 17 | margin-bottom:30px; 18 | } 19 | 20 | 21 | 22 | 23 | /* Headings */ 24 | h1, h2, h3, h4, h5, th { 25 | font-family :Arial, Helvetica, sans-serif; 26 | font-size:1.2em; 27 | } 28 | 29 | 30 | p { 31 | font-size : 1em; 32 | width:80%; 33 | } 34 | 35 | pre, code { 36 | font-family : "Courier New", Courier, monospace; 37 | font-size : 12px; 38 | line-height : normal; 39 | } 40 | 41 | 42 | 43 | table { 44 | border:0; 45 | margin-bottom:10px; 46 | margin-top:10px; 47 | } 48 | 49 | 50 | tr, td { 51 | border-top: 0px solid; 52 | border-left: 0px solid; 53 | padding-top:8px; 54 | padding-bottom:8px; 55 | } 56 | 57 | 58 | 59 | hr { 60 | border:0; 61 | height:1px; 62 | padding:0; 63 | margin:0; 64 | margin-bottom:4px; 65 | 66 | } 67 | 68 | 69 | 70 | dd, th, td, font { 71 | font-size:1.0em; 72 | line-height:1.0em; 73 | } 74 | 75 | 76 | 77 | dt { 78 | margin-bottom:0px; 79 | } 80 | 81 | 82 | 83 | dd { 84 | margin-top:2px; 85 | margin-bottom:4px; 86 | } 87 | 88 | 89 | 90 | a { 91 | text-decoration: underline; 92 | font-weight: normal; 93 | } 94 | 95 | a:hover, 96 | a:active { 97 | text-decoration: underline; 98 | font-weight: normal; 99 | } 100 | 101 | a:visited, 102 | a:link:visited { 103 | text-decoration: underline; 104 | font-weight: normal; 105 | } 106 | 107 | 108 | img { 109 | border: 0px solid #000000; 110 | } 111 | 112 | 113 | 114 | /* Navigation bar fonts */ 115 | .NavBarCell1 { 116 | border:0; 117 | } 118 | 119 | .NavBarCell1Rev { 120 | border:0; 121 | } 122 | 123 | .NavBarFont1 { 124 | font-family: Arial, Helvetica, sans-serif; 125 | font-size:1.1em; 126 | } 127 | 128 | 129 | .NavBarFont1 b { 130 | font-weight:normal; 131 | } 132 | 133 | 134 | 135 | .NavBarFont1:after, .NavBarFont1Rev:after { 136 | font-weight:normal; 137 | content: " \\"; 138 | } 139 | 140 | 141 | .NavBarFont1Rev { 142 | font-family: Arial, Helvetica, sans-serif; 143 | font-size:1.1em; 144 | } 145 | 146 | .NavBarFont1Rev b { 147 | font-family: Arial, Helvetica, sans-serif; 148 | font-size:1.1em; 149 | font-weight:normal; 150 | } 151 | 152 | .NavBarCell2 { 153 | font-family: Arial, Helvetica, sans-serif; 154 | } 155 | 156 | .NavBarCell3 { 157 | font-family: Arial, Helvetica, sans-serif; 158 | } 159 | 160 | 161 | 162 | font.FrameItemFont { 163 | font-family: Helvetica, Arial, sans-serif; 164 | font-size:1.1em; 165 | line-height:1.1em; 166 | } 167 | 168 | font.FrameHeadingFont { 169 | font-family: Helvetica, Arial, sans-serif; 170 | line-height:32px; 171 | } 172 | 173 | /* Font used in left-hand frame lists */ 174 | .FrameTitleFont { 175 | font-family: Helvetica, Arial, sans-serif 176 | } 177 | 178 | 179 | .toggleList { 180 | padding:0; 181 | margin:0; 182 | margin-top:12px; 183 | } 184 | 185 | .toggleList dt { 186 | font-weight:bold; 187 | font-size:12px; 188 | font-family:arial,sans-serif; 189 | padding:0px; 190 | margin:10px 0px 10px 0px; 191 | } 192 | 193 | .toggleList dt span { 194 | font-family: monospace; 195 | padding:0; 196 | margin:0; 197 | } 198 | 199 | 200 | .toggleList dd { 201 | margin:0; 202 | padding:0; 203 | } 204 | 205 | html.isjs .toggleList dd { 206 | display: none; 207 | } 208 | 209 | .toggleList pre { 210 | padding: 4px 4px 4px 4px; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | /* COLORS */ 218 | 219 | pre, code { 220 | color: #000000; 221 | } 222 | 223 | 224 | body { 225 | color : #333333; 226 | background-color :#FFFFFF; 227 | } 228 | 229 | 230 | h1, h2, h3, h4, h5, h6 { 231 | color:#555; 232 | } 233 | 234 | a, 235 | .toggleList dt { 236 | color: #1a7eb0; 237 | } 238 | 239 | a:hover, 240 | a:active { 241 | color: #1a7eb0; 242 | } 243 | 244 | a:visited, 245 | a:link:visited { 246 | color: #1a7eb0; 247 | } 248 | 249 | td,tr { 250 | border-color: #999999; 251 | } 252 | 253 | hr { 254 | color:#999999; 255 | background:#999999; 256 | } 257 | 258 | 259 | .TableHeadingColor { 260 | background: #dcdcdc; 261 | color: #555; 262 | } 263 | 264 | 265 | .TableSubHeadingColor { 266 | background: #EEEEFF 267 | } 268 | 269 | .TableRowColor { 270 | background: #FFFFFF 271 | } 272 | 273 | 274 | .NavBarCell1 { 275 | background-color:#dcdcdc; 276 | color:#000; 277 | } 278 | 279 | .NavBarCell1 a { 280 | color:#333; 281 | } 282 | 283 | 284 | .NavBarCell1Rev { 285 | background-color:transparent; 286 | } 287 | 288 | .NavBarFont1 { 289 | color:#333; 290 | } 291 | 292 | 293 | .NavBarFont1Rev { 294 | color:#fff; 295 | } 296 | 297 | .NavBarCell2 { 298 | background-color:#999; 299 | } 300 | 301 | .NavBarCell2 a { 302 | color:#fff; 303 | } 304 | 305 | 306 | 307 | .NavBarCell3 { 308 | background-color:#dcdcdc; 309 | } 310 | 311 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/template/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | template (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | template 20 | 21 | 22 | 27 | 28 |
23 | Classes  24 | 25 |
26 | HelloWorld
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/template/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | template (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 46 | 49 | 50 | 51 | 52 | 55 | 71 | 72 |
47 | 48 |
73 | 74 | 75 | 76 |
77 |

78 | Package template 79 |

80 | 81 | 82 | 83 | 85 | 86 | 87 | 88 | 89 | 90 |
84 | Class Summary
HelloWorldthis is a template class and can be used to start a new processing library.
91 |   92 | 93 |

94 |

95 |
96 |
97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 117 | 120 | 121 | 122 | 123 | 126 | 142 | 143 |
118 | 119 |
144 | 145 | 146 | 147 |
148 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 149 | 150 | 151 | -------------------------------------------------------------------------------- /libraries/msafluid/reference/template/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | template Class Hierarchy (Javadocs: MSAFluid) 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Hierarchy For Package template 79 |

80 |
81 |

82 | Class Hierarchy 83 |

84 |
    85 |
  • java.lang.Object 87 |
88 |
89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 109 | 112 | 113 | 114 | 115 | 118 | 134 | 135 |
110 | 111 |
136 | 137 | 138 | 139 |
140 | processing library MSAFluid by Mehmet Akten. (c) MSA Visuals 2009 141 | 142 | 143 | -------------------------------------------------------------------------------- /libraries/peasy/CameraState.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | import java.io.Serializable; 22 | 23 | import peasy.org.apache.commons.math.geometry.Rotation; 24 | import peasy.org.apache.commons.math.geometry.Vector3D; 25 | import processing.core.PApplet; 26 | import processing.core.PGraphics; 27 | 28 | public class CameraState implements Serializable { 29 | private static final long serialVersionUID = 1L; 30 | final Rotation rotation; 31 | final Vector3D center; 32 | final double distance; 33 | 34 | public CameraState(final Rotation rotation, final Vector3D center, 35 | final double distance) { 36 | this.rotation = rotation; 37 | this.center = center; 38 | this.distance = distance; 39 | } 40 | 41 | public void apply(final PApplet a) { 42 | if (a.recorder != null) { 43 | apply(a.recorder); 44 | } 45 | apply(a.g); 46 | } 47 | 48 | public void apply(final PGraphics g) { 49 | PeasyCam.apply(g, center, rotation, distance); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /libraries/peasy/DampedAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | /** 22 | * Based on a damned clever and aesthetic idea by David Bollinger. 23 | * 24 | * http://www.davebollinger.com/works/p5/catmouse/CatMouse.pde.txt 25 | * 26 | * @author jdf 27 | * 28 | */ 29 | abstract public class DampedAction { 30 | private final PeasyCam p; 31 | private double velocity; 32 | private final double damping; 33 | 34 | public DampedAction(final PeasyCam p) { 35 | this(p, 0.16); 36 | } 37 | 38 | public DampedAction(final PeasyCam p, final double friction) { 39 | this.p = p; 40 | this.velocity = 0; 41 | this.damping = 1.0 - friction; 42 | p.getApplet().registerDraw(this); 43 | } 44 | 45 | public void impulse(final double impulse) { 46 | velocity += impulse; 47 | } 48 | 49 | public void draw() { 50 | if (velocity == 0) { 51 | return; 52 | } 53 | behave(velocity); 54 | p.feed(); 55 | velocity *= damping; 56 | if (Math.abs(velocity) < .001) { 57 | velocity = 0; 58 | } 59 | } 60 | 61 | public void stop() { 62 | velocity = 0; 63 | } 64 | 65 | abstract protected void behave(final double velocity); 66 | } 67 | -------------------------------------------------------------------------------- /libraries/peasy/InterpolationManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package peasy; 5 | 6 | import peasy.PeasyCam.AbstractInterp; 7 | 8 | class InterpolationManager { 9 | private AbstractInterp currentInterpolator = null; 10 | 11 | protected synchronized void startInterpolation(final AbstractInterp interpolation) { 12 | cancelInterpolation(); 13 | currentInterpolator = interpolation; 14 | currentInterpolator.start(); 15 | } 16 | 17 | protected synchronized void cancelInterpolation() { 18 | if (currentInterpolator != null) { 19 | currentInterpolator.cancel(); 20 | currentInterpolator = null; 21 | } 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /libraries/peasy/InterpolationUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | import peasy.org.apache.commons.math.geometry.Rotation; 22 | import peasy.org.apache.commons.math.geometry.Vector3D; 23 | 24 | public class InterpolationUtil { 25 | 26 | // Thanks to Michael Kaufmann for improvements to this function. 27 | static public Rotation slerp(final Rotation a, final Rotation b, final double t) { 28 | final double a0 = a.getQ0(), a1 = a.getQ1(), a2 = a.getQ2(), a3 = a.getQ3(); 29 | double b0 = b.getQ0(), b1 = b.getQ1(), b2 = b.getQ2(), b3 = b.getQ3(); 30 | 31 | double cosTheta = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3; 32 | if (cosTheta < 0) { 33 | b0 = -b0; 34 | b1 = -b1; 35 | b2 = -b2; 36 | b3 = -b3; 37 | cosTheta = -cosTheta; 38 | } 39 | 40 | final double theta = Math.acos(cosTheta); 41 | final double sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta); 42 | 43 | double w1, w2; 44 | if (sinTheta > 0.001) { 45 | w1 = Math.sin((1.0 - t) * theta) / sinTheta; 46 | w2 = Math.sin(t * theta) / sinTheta; 47 | } else { 48 | w1 = 1.0 - t; 49 | w2 = t; 50 | } 51 | return new Rotation(w1 * a0 + w2 * b0, w1 * a1 + w2 * b1, w1 * a2 + w2 * b2, w1 52 | * a3 + w2 * b3, true); 53 | } 54 | 55 | static public double smooth(final double a, final double b, final double t) { 56 | final double smooth = (t * t * (3 - 2 * t)); 57 | return (b * smooth) + (a * (1 - smooth)); 58 | 59 | } 60 | 61 | static public Vector3D smooth(final Vector3D a, final Vector3D b, final double t) { 62 | return new Vector3D(smooth(a.getX(), b.getX(), t), smooth(a.getY(), b.getY(), t), 63 | smooth(a.getZ(), b.getZ(), t)); 64 | } 65 | 66 | static public double linear(final double a, final double b, final double t) { 67 | return a + (b - a) * t; 68 | } 69 | 70 | static public Vector3D linear(final Vector3D a, final Vector3D b, final double t) { 71 | return new Vector3D(linear(a.getX(), b.getX(), t), linear(a.getY(), b.getY(), t), 72 | linear(a.getZ(), b.getZ(), t)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /libraries/peasy/PeasyDragHandler.java: -------------------------------------------------------------------------------- 1 | package peasy; 2 | 3 | public interface PeasyDragHandler { 4 | public void handleDrag(final double dx, final double dy); 5 | } 6 | -------------------------------------------------------------------------------- /libraries/peasy/PeasyWheelHandler.java: -------------------------------------------------------------------------------- 1 | package peasy; 2 | 3 | public interface PeasyWheelHandler { 4 | public void handleWheel(final int delta); 5 | } 6 | -------------------------------------------------------------------------------- /libraries/peasy/org/apache/commons/math/geometry/CardanEulerSingularityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | import peasy.org.apache.commons.math.MathException; 21 | 22 | /** 23 | * This class represents exceptions thrown while extractiong Cardan or Euler 24 | * angles from a rotation. 25 | * 26 | * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 27 | * 2008) $ 28 | * @since 1.2 29 | */ 30 | public class CardanEulerSingularityException extends MathException { 31 | 32 | /** 33 | * Simple constructor. build an exception with a default message. 34 | * 35 | * @param isCardan 36 | * if true, the rotation is related to Cardan angles, if false it 37 | * is related to EulerAngles 38 | */ 39 | public CardanEulerSingularityException(final boolean isCardan) { 40 | super(isCardan ? "Cardan angles singularity" : "Euler angles singularity", 41 | new Object[0]); 42 | } 43 | 44 | /** Serializable version identifier */ 45 | private static final long serialVersionUID = -1360952845582206770L; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /libraries/peasy/org/apache/commons/math/geometry/NotARotationMatrixException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | import peasy.org.apache.commons.math.MathException; 21 | 22 | /** 23 | * This class represents exceptions thrown while building rotations from 24 | * matrices. 25 | * 26 | * @version $Revision: 627994 $ $Date: 2008-02-15 03:16:05 -0700 (Fri, 15 Feb 27 | * 2008) $ 28 | * @since 1.2 29 | */ 30 | 31 | public class NotARotationMatrixException extends MathException { 32 | 33 | /** 34 | * Simple constructor. Build an exception by translating and formating a 35 | * message 36 | * 37 | * @param specifier 38 | * format specifier (to be translated) 39 | * @param parts 40 | * to insert in the format (no translation) 41 | */ 42 | public NotARotationMatrixException(final String specifier, final Object[] parts) { 43 | super(specifier, parts); 44 | } 45 | 46 | /** Serializable version identifier */ 47 | private static final long serialVersionUID = 5647178478658937642L; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /libraries/peasy/org/apache/commons/math/geometry/RotationOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | /** 21 | * This class is a utility representing a rotation order specification for 22 | * Cardan or Euler angles specification. 23 | * 24 | * This class cannot be instanciated by the user. He can only use one of the 25 | * twelve predefined supported orders as an argument to either the 26 | * {@link Rotation#Rotation(RotationOrder,double,double,double)} constructor or 27 | * the {@link Rotation#getAngles} method. 28 | * 29 | * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 30 | * 2008) $ 31 | * @since 1.2 32 | */ 33 | public final class RotationOrder { 34 | 35 | /** 36 | * Private constructor. This is a utility class that cannot be instantiated 37 | * by the user, so its only constructor is private. 38 | * 39 | * @param name 40 | * name of the rotation order 41 | * @param a1 42 | * axis of the first rotation 43 | * @param a2 44 | * axis of the second rotation 45 | * @param a3 46 | * axis of the third rotation 47 | */ 48 | private RotationOrder(final String name, final Vector3D a1, final Vector3D a2, 49 | final Vector3D a3) { 50 | this.name = name; 51 | this.a1 = a1; 52 | this.a2 = a2; 53 | this.a3 = a3; 54 | } 55 | 56 | /** 57 | * Get a string representation of the instance. 58 | * 59 | * @return a string representation of the instance (in fact, its name) 60 | */ 61 | public String toString() { 62 | return name; 63 | } 64 | 65 | /** 66 | * Get the axis of the first rotation. 67 | * 68 | * @return axis of the first rotation 69 | */ 70 | public Vector3D getA1() { 71 | return a1; 72 | } 73 | 74 | /** 75 | * Get the axis of the second rotation. 76 | * 77 | * @return axis of the second rotation 78 | */ 79 | public Vector3D getA2() { 80 | return a2; 81 | } 82 | 83 | /** 84 | * Get the axis of the second rotation. 85 | * 86 | * @return axis of the second rotation 87 | */ 88 | public Vector3D getA3() { 89 | return a3; 90 | } 91 | 92 | /** 93 | * Set of Cardan angles. this ordered set of rotations is around X, then 94 | * around Y, then around Z 95 | */ 96 | public static final RotationOrder XYZ = new RotationOrder("XYZ", Vector3D.plusI, 97 | Vector3D.plusJ, Vector3D.plusK); 98 | 99 | /** 100 | * Set of Cardan angles. this ordered set of rotations is around X, then 101 | * around Z, then around Y 102 | */ 103 | public static final RotationOrder XZY = new RotationOrder("XZY", Vector3D.plusI, 104 | Vector3D.plusK, Vector3D.plusJ); 105 | 106 | /** 107 | * Set of Cardan angles. this ordered set of rotations is around Y, then 108 | * around X, then around Z 109 | */ 110 | public static final RotationOrder YXZ = new RotationOrder("YXZ", Vector3D.plusJ, 111 | Vector3D.plusI, Vector3D.plusK); 112 | 113 | /** 114 | * Set of Cardan angles. this ordered set of rotations is around Y, then 115 | * around Z, then around X 116 | */ 117 | public static final RotationOrder YZX = new RotationOrder("YZX", Vector3D.plusJ, 118 | Vector3D.plusK, Vector3D.plusI); 119 | 120 | /** 121 | * Set of Cardan angles. this ordered set of rotations is around Z, then 122 | * around X, then around Y 123 | */ 124 | public static final RotationOrder ZXY = new RotationOrder("ZXY", Vector3D.plusK, 125 | Vector3D.plusI, Vector3D.plusJ); 126 | 127 | /** 128 | * Set of Cardan angles. this ordered set of rotations is around Z, then 129 | * around Y, then around X 130 | */ 131 | public static final RotationOrder ZYX = new RotationOrder("ZYX", Vector3D.plusK, 132 | Vector3D.plusJ, Vector3D.plusI); 133 | 134 | /** 135 | * Set of Euler angles. this ordered set of rotations is around X, then 136 | * around Y, then around X 137 | */ 138 | public static final RotationOrder XYX = new RotationOrder("XYX", Vector3D.plusI, 139 | Vector3D.plusJ, Vector3D.plusI); 140 | 141 | /** 142 | * Set of Euler angles. this ordered set of rotations is around X, then 143 | * around Z, then around X 144 | */ 145 | public static final RotationOrder XZX = new RotationOrder("XZX", Vector3D.plusI, 146 | Vector3D.plusK, Vector3D.plusI); 147 | 148 | /** 149 | * Set of Euler angles. this ordered set of rotations is around Y, then 150 | * around X, then around Y 151 | */ 152 | public static final RotationOrder YXY = new RotationOrder("YXY", Vector3D.plusJ, 153 | Vector3D.plusI, Vector3D.plusJ); 154 | 155 | /** 156 | * Set of Euler angles. this ordered set of rotations is around Y, then 157 | * around Z, then around Y 158 | */ 159 | public static final RotationOrder YZY = new RotationOrder("YZY", Vector3D.plusJ, 160 | Vector3D.plusK, Vector3D.plusJ); 161 | 162 | /** 163 | * Set of Euler angles. this ordered set of rotations is around Z, then 164 | * around X, then around Z 165 | */ 166 | public static final RotationOrder ZXZ = new RotationOrder("ZXZ", Vector3D.plusK, 167 | Vector3D.plusI, Vector3D.plusK); 168 | 169 | /** 170 | * Set of Euler angles. this ordered set of rotations is around Z, then 171 | * around Y, then around Z 172 | */ 173 | public static final RotationOrder ZYZ = new RotationOrder("ZYZ", Vector3D.plusK, 174 | Vector3D.plusJ, Vector3D.plusK); 175 | 176 | /** Name of the rotations order. */ 177 | private final String name; 178 | 179 | /** Axis of the first rotation. */ 180 | private final Vector3D a1; 181 | 182 | /** Axis of the second rotation. */ 183 | private final Vector3D a2; 184 | 185 | /** Axis of the third rotation. */ 186 | private final Vector3D a3; 187 | 188 | } 189 | -------------------------------------------------------------------------------- /libraries/peasycam/examples/HelloPeasy/HelloPeasy.pde: -------------------------------------------------------------------------------- 1 | import peasy.*; 2 | 3 | PeasyCam cam; 4 | 5 | void setup() { 6 | size(200,200,P3D); 7 | cam = new PeasyCam(this, 100); 8 | cam.setMinimumDistance(50); 9 | cam.setMaximumDistance(500); 10 | } 11 | void draw() { 12 | rotateX(-.5); 13 | rotateY(-.5); 14 | background(0); 15 | fill(255,0,0); 16 | box(30); 17 | pushMatrix(); 18 | translate(0,0,20); 19 | fill(0,0,255); 20 | box(5); 21 | popMatrix(); 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /libraries/peasycam/library.properties: -------------------------------------------------------------------------------- 1 | name=PeasyCam 2 | category=3D 3 | authorList=[Jonathan Feinberg](http://mrfeinberg.com/) 4 | url=http://mrfeinberg.com/peasycam/ 5 | sentence=A mouse driven camera-control library for 3D sketches. 6 | paragraph=null 7 | version=105 8 | prettyVersion=null 9 | -------------------------------------------------------------------------------- /libraries/peasycam/library/peasycam.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GODPUS/processing-datamosh/34faf4cfc22bbdb4791aee4935b928e7c8eba012/libraries/peasycam/library/peasycam.jar -------------------------------------------------------------------------------- /libraries/peasycam/reference/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 49 | 50 |
CameraState 25 |
26 | CardanEulerSingularityException 27 |
28 | DampedAction 29 |
30 | InterpolationUtil 31 |
32 | MathException 33 |
34 | NotARotationMatrixException 35 |
36 | PeasyCam 37 |
38 | PeasyDragHandler 39 |
40 | PeasyWheelHandler 41 |
42 | Rotation 43 |
44 | RotationOrder 45 |
46 | Vector3D 47 |
48 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | All Classes 20 |
21 | 22 | 23 | 24 | 49 | 50 |
CameraState 25 |
26 | CardanEulerSingularityException 27 |
28 | DampedAction 29 |
30 | InterpolationUtil 31 |
32 | MathException 33 |
34 | NotARotationMatrixException 35 |
36 | PeasyCam 37 |
38 | PeasyDragHandler 39 |
40 | PeasyWheelHandler 41 |
42 | Rotation 43 |
44 | RotationOrder 45 |
46 | Vector3D 47 |
48 |
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Constant Field Values

84 |
85 |
86 | Contents 89 | 90 | 91 | 92 | 93 | 95 | 96 |
94 | peasy.*
97 | 98 |

99 | 100 | 101 | 102 | 103 | 104 | 105 | 107 | 108 | 109 | 110 | 111 | 112 |
peasy.PeasyCam
106 | public final java.lang.StringVERSION"105"
113 | 114 |

115 | 116 |

117 |


118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 139 | 142 | 143 | 144 | 145 | 148 | 164 | 165 |
140 | 141 |
166 | 167 | 168 | 169 |
170 | processing library peasycam by Jonathan Feinberg. (c) 2011 171 | 172 | 173 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Javadocs: peasycam 8 | 9 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | <H2> 31 | Frame Alert</H2> 32 | 33 | <P> 34 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 35 | <BR> 36 | Link to<A HREF="overview-summary.html">Non-frame version.</A> 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
22 |
25 | 26 | 27 | 28 | 40 | 41 |
All Classes 29 |

30 | 31 | Packages 32 |
33 | peasy 34 |
35 | peasy.org.apache.commons.math 36 |
37 | peasy.org.apache.commons.math.geometry 38 |
39 |

42 | 43 |

44 |   45 | 46 | 47 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |


29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Javadocs: peasycam 84 |

85 |
86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 |
90 | Packages
peasy 
peasy.org.apache.commons.math 
peasy.org.apache.commons.math.geometry 
105 | 106 |

107 |  


108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 129 | 132 | 133 | 134 | 135 | 138 | 154 | 155 |
130 | 131 |
156 | 157 | 158 | 159 |
160 | processing library peasycam by Jonathan Feinberg. (c) 2011 161 | 162 | 163 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/package-list: -------------------------------------------------------------------------------- 1 | peasy 2 | peasy.org.apache.commons.math 3 | peasy.org.apache.commons.math.geometry 4 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/org/apache/commons/math/geometry/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy.org.apache.commons.math.geometry (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | peasy.org.apache.commons.math.geometry 20 | 21 | 22 | 31 | 32 |
23 | Classes  24 | 25 |
26 | Rotation 27 |
28 | RotationOrder 29 |
30 | Vector3D
33 | 34 | 35 | 36 | 37 | 44 | 45 |
38 | Exceptions  39 | 40 |
41 | CardanEulerSingularityException 42 |
43 | NotARotationMatrixException
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/org/apache/commons/math/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy.org.apache.commons.math (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | peasy.org.apache.commons.math 20 | 21 | 22 | 27 | 28 |
23 | Exceptions  24 | 25 |
26 | MathException
29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/org/apache/commons/math/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy.org.apache.commons.math (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |

82 | Package peasy.org.apache.commons.math 83 |

84 | 85 | 86 | 87 | 89 | 90 | 91 | 92 | 93 | 94 |
88 | Exception Summary
MathExceptionBase class for commons-math checked exceptions.
95 |   96 | 97 |

98 |

99 |
100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 122 | 125 | 126 | 127 | 128 | 131 | 147 | 148 |
123 | 124 |
149 | 150 | 151 | 152 |
153 | processing library peasycam by Jonathan Feinberg. (c) 2011 154 | 155 | 156 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/org/apache/commons/math/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy.org.apache.commons.math Class Hierarchy (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Hierarchy For Package peasy.org.apache.commons.math 84 |

85 |
86 |
87 |
Package Hierarchies:
All Packages
88 |
89 |

90 | Class Hierarchy 91 |

92 |
    93 |
  • java.lang.Object
      94 |
    • java.lang.Throwable (implements java.io.Serializable) 95 |
        96 |
      • java.lang.Exception 98 |
      99 |
    100 |
101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 123 | 126 | 127 | 128 | 129 | 132 | 148 | 149 |
124 | 125 |
150 | 151 | 152 | 153 |
154 | processing library peasycam by Jonathan Feinberg. (c) 2011 155 | 156 | 157 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | peasy 20 | 21 | 22 | 29 | 30 |
23 | Interfaces  24 | 25 |
26 | PeasyDragHandler 27 |
28 | PeasyWheelHandler
31 | 32 | 33 | 34 | 35 | 46 | 47 |
36 | Classes  37 | 38 |
39 | CameraState 40 |
41 | DampedAction 42 |
43 | InterpolationUtil 44 |
45 | PeasyCam
48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/peasy/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | peasy Class Hierarchy (Javadocs: peasycam) 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 50 | 53 | 54 | 55 | 56 | 59 | 75 | 76 |
51 | 52 |
77 | 78 | 79 | 80 |
81 |
82 |

83 | Hierarchy For Package peasy 84 |

85 |
86 |
87 |
Package Hierarchies:
All Packages
88 |
89 |

90 | Class Hierarchy 91 |

92 | 97 |

98 | Interface Hierarchy 99 |

100 | 102 |
103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 124 | 127 | 128 | 129 | 130 | 133 | 149 | 150 |
125 | 126 |
151 | 152 | 153 | 154 |
155 | processing library peasycam by Jonathan Feinberg. (c) 2011 156 | 157 | 158 | -------------------------------------------------------------------------------- /libraries/peasycam/reference/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GODPUS/processing-datamosh/34faf4cfc22bbdb4791aee4935b928e7c8eba012/libraries/peasycam/reference/resources/inherit.gif -------------------------------------------------------------------------------- /libraries/peasycam/reference/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | /* Define colors, fonts and other style attributes here to override the defaults */ 3 | /* processingLibs style by andreas schlegel, sojamo */ 4 | 5 | 6 | body { 7 | margin : 0; 8 | padding : 0; 9 | padding-left : 10px; 10 | padding-right : 8px; 11 | background-color : #FFFFFF; 12 | font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; 13 | font-size : 100%; 14 | font-size : 0.7em; 15 | font-weight : normal; 16 | line-height : normal; 17 | margin-bottom:30px; 18 | } 19 | 20 | 21 | 22 | 23 | /* Headings */ 24 | h1, h2, h3, h4, h5, th { 25 | font-family :Arial, Helvetica, sans-serif; 26 | font-size:1.2em; 27 | } 28 | 29 | 30 | p { 31 | font-size : 1em; 32 | width:80%; 33 | } 34 | 35 | pre, code { 36 | font-family : "Courier New", Courier, monospace; 37 | font-size : 12px; 38 | line-height : normal; 39 | } 40 | 41 | 42 | 43 | table { 44 | border:0; 45 | margin-bottom:10px; 46 | margin-top:10px; 47 | } 48 | 49 | 50 | tr, td { 51 | border-top: 0px solid; 52 | border-left: 0px solid; 53 | padding-top:8px; 54 | padding-bottom:8px; 55 | } 56 | 57 | 58 | 59 | hr { 60 | border:0; 61 | height:1px; 62 | padding:0; 63 | margin:0; 64 | margin-bottom:4px; 65 | 66 | } 67 | 68 | 69 | 70 | dd, th, td, font { 71 | font-size:1.0em; 72 | line-height:1.0em; 73 | } 74 | 75 | 76 | 77 | dt { 78 | margin-bottom:0px; 79 | } 80 | 81 | 82 | 83 | dd { 84 | margin-top:2px; 85 | margin-bottom:4px; 86 | } 87 | 88 | 89 | 90 | a { 91 | text-decoration: underline; 92 | font-weight: normal; 93 | } 94 | 95 | a:hover, 96 | a:active { 97 | text-decoration: underline; 98 | font-weight: normal; 99 | } 100 | 101 | a:visited, 102 | a:link:visited { 103 | text-decoration: underline; 104 | font-weight: normal; 105 | } 106 | 107 | 108 | img { 109 | border: 0px solid #000000; 110 | } 111 | 112 | 113 | 114 | /* Navigation bar fonts */ 115 | .NavBarCell1 { 116 | border:0; 117 | } 118 | 119 | .NavBarCell1Rev { 120 | border:0; 121 | } 122 | 123 | .NavBarFont1 { 124 | font-family: Arial, Helvetica, sans-serif; 125 | font-size:1.1em; 126 | } 127 | 128 | 129 | .NavBarFont1 b { 130 | font-weight:normal; 131 | } 132 | 133 | 134 | 135 | .NavBarFont1:after, .NavBarFont1Rev:after { 136 | font-weight:normal; 137 | content: " \\"; 138 | } 139 | 140 | 141 | .NavBarFont1Rev { 142 | font-family: Arial, Helvetica, sans-serif; 143 | font-size:1.1em; 144 | } 145 | 146 | .NavBarFont1Rev b { 147 | font-family: Arial, Helvetica, sans-serif; 148 | font-size:1.1em; 149 | font-weight:normal; 150 | } 151 | 152 | .NavBarCell2 { 153 | font-family: Arial, Helvetica, sans-serif; 154 | } 155 | 156 | .NavBarCell3 { 157 | font-family: Arial, Helvetica, sans-serif; 158 | } 159 | 160 | 161 | 162 | font.FrameItemFont { 163 | font-family: Helvetica, Arial, sans-serif; 164 | font-size:1.1em; 165 | line-height:1.1em; 166 | } 167 | 168 | font.FrameHeadingFont { 169 | font-family: Helvetica, Arial, sans-serif; 170 | line-height:32px; 171 | } 172 | 173 | /* Font used in left-hand frame lists */ 174 | .FrameTitleFont { 175 | font-family: Helvetica, Arial, sans-serif 176 | } 177 | 178 | 179 | .toggleList { 180 | padding:0; 181 | margin:0; 182 | margin-top:12px; 183 | } 184 | 185 | .toggleList dt { 186 | font-weight:bold; 187 | font-size:12px; 188 | font-family:arial,sans-serif; 189 | padding:0px; 190 | margin:10px 0px 10px 0px; 191 | } 192 | 193 | .toggleList dt span { 194 | font-family: monospace; 195 | padding:0; 196 | margin:0; 197 | } 198 | 199 | 200 | .toggleList dd { 201 | margin:0; 202 | padding:0; 203 | } 204 | 205 | html.isjs .toggleList dd { 206 | display: none; 207 | } 208 | 209 | .toggleList pre { 210 | padding: 4px 4px 4px 4px; 211 | } 212 | 213 | 214 | 215 | 216 | 217 | /* COLORS */ 218 | 219 | pre, code { 220 | color: #000000; 221 | } 222 | 223 | 224 | body { 225 | color : #333333; 226 | background-color :#FFFFFF; 227 | } 228 | 229 | 230 | h1, h2, h3, h4, h5, h6 { 231 | color:#555; 232 | } 233 | 234 | a, 235 | .toggleList dt { 236 | color: #1a7eb0; 237 | } 238 | 239 | a:hover, 240 | a:active { 241 | color: #1a7eb0; 242 | } 243 | 244 | a:visited, 245 | a:link:visited { 246 | color: #1a7eb0; 247 | } 248 | 249 | td,tr { 250 | border-color: #999999; 251 | } 252 | 253 | hr { 254 | color:#999999; 255 | background:#999999; 256 | } 257 | 258 | 259 | .TableHeadingColor { 260 | background: #dcdcdc; 261 | color: #555; 262 | } 263 | 264 | 265 | .TableSubHeadingColor { 266 | background: #EEEEFF 267 | } 268 | 269 | .TableRowColor { 270 | background: #FFFFFF 271 | } 272 | 273 | 274 | .NavBarCell1 { 275 | background-color:#dcdcdc; 276 | color:#000; 277 | } 278 | 279 | .NavBarCell1 a { 280 | color:#333; 281 | } 282 | 283 | 284 | .NavBarCell1Rev { 285 | background-color:transparent; 286 | } 287 | 288 | .NavBarFont1 { 289 | color:#333; 290 | } 291 | 292 | 293 | .NavBarFont1Rev { 294 | color:#fff; 295 | } 296 | 297 | .NavBarCell2 { 298 | background-color:#999; 299 | } 300 | 301 | .NavBarCell2 a { 302 | color:#fff; 303 | } 304 | 305 | 306 | 307 | .NavBarCell3 { 308 | background-color:#dcdcdc; 309 | } 310 | 311 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/CameraState.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | import java.io.Serializable; 22 | 23 | import peasy.org.apache.commons.math.geometry.Rotation; 24 | import peasy.org.apache.commons.math.geometry.Vector3D; 25 | import processing.core.PApplet; 26 | import processing.core.PGraphics; 27 | 28 | public class CameraState implements Serializable { 29 | private static final long serialVersionUID = 1L; 30 | final Rotation rotation; 31 | final Vector3D center; 32 | final double distance; 33 | 34 | public CameraState(final Rotation rotation, final Vector3D center, 35 | final double distance) { 36 | this.rotation = rotation; 37 | this.center = center; 38 | this.distance = distance; 39 | } 40 | 41 | public void apply(final PApplet a) { 42 | if (a.recorder != null) { 43 | apply(a.recorder); 44 | } 45 | apply(a.g); 46 | } 47 | 48 | public void apply(final PGraphics g) { 49 | PeasyCam.apply(g, center, rotation, distance); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/DampedAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | /** 22 | * Based on a damned clever and aesthetic idea by David Bollinger. 23 | * 24 | * http://www.davebollinger.com/works/p5/catmouse/CatMouse.pde.txt 25 | * 26 | * @author jdf 27 | * 28 | */ 29 | abstract public class DampedAction { 30 | private final PeasyCam p; 31 | private double velocity; 32 | private final double damping; 33 | 34 | public DampedAction(final PeasyCam p) { 35 | this(p, 0.16); 36 | } 37 | 38 | public DampedAction(final PeasyCam p, final double friction) { 39 | this.p = p; 40 | this.velocity = 0; 41 | this.damping = 1.0 - friction; 42 | p.getApplet().registerDraw(this); 43 | } 44 | 45 | public void impulse(final double impulse) { 46 | velocity += impulse; 47 | } 48 | 49 | public void draw() { 50 | if (velocity == 0) { 51 | return; 52 | } 53 | behave(velocity); 54 | p.feed(); 55 | velocity *= damping; 56 | if (Math.abs(velocity) < .001) { 57 | velocity = 0; 58 | } 59 | } 60 | 61 | public void stop() { 62 | velocity = 0; 63 | } 64 | 65 | abstract protected void behave(final double velocity); 66 | } 67 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/InterpolationManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package peasy; 5 | 6 | import peasy.PeasyCam.AbstractInterp; 7 | 8 | class InterpolationManager { 9 | private AbstractInterp currentInterpolator = null; 10 | 11 | protected synchronized void startInterpolation(final AbstractInterp interpolation) { 12 | cancelInterpolation(); 13 | currentInterpolator = interpolation; 14 | currentInterpolator.start(); 15 | } 16 | 17 | protected synchronized void cancelInterpolation() { 18 | if (currentInterpolator != null) { 19 | currentInterpolator.cancel(); 20 | currentInterpolator = null; 21 | } 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/InterpolationUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | The PeasyCam Processing library, which provides an easy-peasy 3 | camera for 3D sketching. 4 | 5 | Copyright 2008 Jonathan Feinberg 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | package peasy; 20 | 21 | import peasy.org.apache.commons.math.geometry.Rotation; 22 | import peasy.org.apache.commons.math.geometry.Vector3D; 23 | 24 | public class InterpolationUtil { 25 | 26 | // Thanks to Michael Kaufmann for improvements to this function. 27 | static public Rotation slerp(final Rotation a, final Rotation b, final double t) { 28 | final double a0 = a.getQ0(), a1 = a.getQ1(), a2 = a.getQ2(), a3 = a.getQ3(); 29 | double b0 = b.getQ0(), b1 = b.getQ1(), b2 = b.getQ2(), b3 = b.getQ3(); 30 | 31 | double cosTheta = a0 * b0 + a1 * b1 + a2 * b2 + a3 * b3; 32 | if (cosTheta < 0) { 33 | b0 = -b0; 34 | b1 = -b1; 35 | b2 = -b2; 36 | b3 = -b3; 37 | cosTheta = -cosTheta; 38 | } 39 | 40 | final double theta = Math.acos(cosTheta); 41 | final double sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta); 42 | 43 | double w1, w2; 44 | if (sinTheta > 0.001) { 45 | w1 = Math.sin((1.0 - t) * theta) / sinTheta; 46 | w2 = Math.sin(t * theta) / sinTheta; 47 | } else { 48 | w1 = 1.0 - t; 49 | w2 = t; 50 | } 51 | return new Rotation(w1 * a0 + w2 * b0, w1 * a1 + w2 * b1, w1 * a2 + w2 * b2, w1 52 | * a3 + w2 * b3, true); 53 | } 54 | 55 | static public double smooth(final double a, final double b, final double t) { 56 | final double smooth = (t * t * (3 - 2 * t)); 57 | return (b * smooth) + (a * (1 - smooth)); 58 | 59 | } 60 | 61 | static public Vector3D smooth(final Vector3D a, final Vector3D b, final double t) { 62 | return new Vector3D(smooth(a.getX(), b.getX(), t), smooth(a.getY(), b.getY(), t), 63 | smooth(a.getZ(), b.getZ(), t)); 64 | } 65 | 66 | static public double linear(final double a, final double b, final double t) { 67 | return a + (b - a) * t; 68 | } 69 | 70 | static public Vector3D linear(final Vector3D a, final Vector3D b, final double t) { 71 | return new Vector3D(linear(a.getX(), b.getX(), t), linear(a.getY(), b.getY(), t), 72 | linear(a.getZ(), b.getZ(), t)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/PeasyDragHandler.java: -------------------------------------------------------------------------------- 1 | package peasy; 2 | 3 | public interface PeasyDragHandler { 4 | public void handleDrag(final double dx, final double dy); 5 | } 6 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/PeasyWheelHandler.java: -------------------------------------------------------------------------------- 1 | package peasy; 2 | 3 | public interface PeasyWheelHandler { 4 | public void handleWheel(final int delta); 5 | } 6 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/org/apache/commons/math/geometry/CardanEulerSingularityException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | import peasy.org.apache.commons.math.MathException; 21 | 22 | /** 23 | * This class represents exceptions thrown while extractiong Cardan or Euler 24 | * angles from a rotation. 25 | * 26 | * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 27 | * 2008) $ 28 | * @since 1.2 29 | */ 30 | public class CardanEulerSingularityException extends MathException { 31 | 32 | /** 33 | * Simple constructor. build an exception with a default message. 34 | * 35 | * @param isCardan 36 | * if true, the rotation is related to Cardan angles, if false it 37 | * is related to EulerAngles 38 | */ 39 | public CardanEulerSingularityException(final boolean isCardan) { 40 | super(isCardan ? "Cardan angles singularity" : "Euler angles singularity", 41 | new Object[0]); 42 | } 43 | 44 | /** Serializable version identifier */ 45 | private static final long serialVersionUID = -1360952845582206770L; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/org/apache/commons/math/geometry/NotARotationMatrixException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | import peasy.org.apache.commons.math.MathException; 21 | 22 | /** 23 | * This class represents exceptions thrown while building rotations from 24 | * matrices. 25 | * 26 | * @version $Revision: 627994 $ $Date: 2008-02-15 03:16:05 -0700 (Fri, 15 Feb 27 | * 2008) $ 28 | * @since 1.2 29 | */ 30 | 31 | public class NotARotationMatrixException extends MathException { 32 | 33 | /** 34 | * Simple constructor. Build an exception by translating and formating a 35 | * message 36 | * 37 | * @param specifier 38 | * format specifier (to be translated) 39 | * @param parts 40 | * to insert in the format (no translation) 41 | */ 42 | public NotARotationMatrixException(final String specifier, final Object[] parts) { 43 | super(specifier, parts); 44 | } 45 | 46 | /** Serializable version identifier */ 47 | private static final long serialVersionUID = 5647178478658937642L; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /libraries/peasycam/src/peasy/org/apache/commons/math/geometry/RotationOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package peasy.org.apache.commons.math.geometry; 19 | 20 | /** 21 | * This class is a utility representing a rotation order specification for 22 | * Cardan or Euler angles specification. 23 | * 24 | * This class cannot be instanciated by the user. He can only use one of the 25 | * twelve predefined supported orders as an argument to either the 26 | * {@link Rotation#Rotation(RotationOrder,double,double,double)} constructor or 27 | * the {@link Rotation#getAngles} method. 28 | * 29 | * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 30 | * 2008) $ 31 | * @since 1.2 32 | */ 33 | public final class RotationOrder { 34 | 35 | /** 36 | * Private constructor. This is a utility class that cannot be instantiated 37 | * by the user, so its only constructor is private. 38 | * 39 | * @param name 40 | * name of the rotation order 41 | * @param a1 42 | * axis of the first rotation 43 | * @param a2 44 | * axis of the second rotation 45 | * @param a3 46 | * axis of the third rotation 47 | */ 48 | private RotationOrder(final String name, final Vector3D a1, final Vector3D a2, 49 | final Vector3D a3) { 50 | this.name = name; 51 | this.a1 = a1; 52 | this.a2 = a2; 53 | this.a3 = a3; 54 | } 55 | 56 | /** 57 | * Get a string representation of the instance. 58 | * 59 | * @return a string representation of the instance (in fact, its name) 60 | */ 61 | public String toString() { 62 | return name; 63 | } 64 | 65 | /** 66 | * Get the axis of the first rotation. 67 | * 68 | * @return axis of the first rotation 69 | */ 70 | public Vector3D getA1() { 71 | return a1; 72 | } 73 | 74 | /** 75 | * Get the axis of the second rotation. 76 | * 77 | * @return axis of the second rotation 78 | */ 79 | public Vector3D getA2() { 80 | return a2; 81 | } 82 | 83 | /** 84 | * Get the axis of the second rotation. 85 | * 86 | * @return axis of the second rotation 87 | */ 88 | public Vector3D getA3() { 89 | return a3; 90 | } 91 | 92 | /** 93 | * Set of Cardan angles. this ordered set of rotations is around X, then 94 | * around Y, then around Z 95 | */ 96 | public static final RotationOrder XYZ = new RotationOrder("XYZ", Vector3D.plusI, 97 | Vector3D.plusJ, Vector3D.plusK); 98 | 99 | /** 100 | * Set of Cardan angles. this ordered set of rotations is around X, then 101 | * around Z, then around Y 102 | */ 103 | public static final RotationOrder XZY = new RotationOrder("XZY", Vector3D.plusI, 104 | Vector3D.plusK, Vector3D.plusJ); 105 | 106 | /** 107 | * Set of Cardan angles. this ordered set of rotations is around Y, then 108 | * around X, then around Z 109 | */ 110 | public static final RotationOrder YXZ = new RotationOrder("YXZ", Vector3D.plusJ, 111 | Vector3D.plusI, Vector3D.plusK); 112 | 113 | /** 114 | * Set of Cardan angles. this ordered set of rotations is around Y, then 115 | * around Z, then around X 116 | */ 117 | public static final RotationOrder YZX = new RotationOrder("YZX", Vector3D.plusJ, 118 | Vector3D.plusK, Vector3D.plusI); 119 | 120 | /** 121 | * Set of Cardan angles. this ordered set of rotations is around Z, then 122 | * around X, then around Y 123 | */ 124 | public static final RotationOrder ZXY = new RotationOrder("ZXY", Vector3D.plusK, 125 | Vector3D.plusI, Vector3D.plusJ); 126 | 127 | /** 128 | * Set of Cardan angles. this ordered set of rotations is around Z, then 129 | * around Y, then around X 130 | */ 131 | public static final RotationOrder ZYX = new RotationOrder("ZYX", Vector3D.plusK, 132 | Vector3D.plusJ, Vector3D.plusI); 133 | 134 | /** 135 | * Set of Euler angles. this ordered set of rotations is around X, then 136 | * around Y, then around X 137 | */ 138 | public static final RotationOrder XYX = new RotationOrder("XYX", Vector3D.plusI, 139 | Vector3D.plusJ, Vector3D.plusI); 140 | 141 | /** 142 | * Set of Euler angles. this ordered set of rotations is around X, then 143 | * around Z, then around X 144 | */ 145 | public static final RotationOrder XZX = new RotationOrder("XZX", Vector3D.plusI, 146 | Vector3D.plusK, Vector3D.plusI); 147 | 148 | /** 149 | * Set of Euler angles. this ordered set of rotations is around Y, then 150 | * around X, then around Y 151 | */ 152 | public static final RotationOrder YXY = new RotationOrder("YXY", Vector3D.plusJ, 153 | Vector3D.plusI, Vector3D.plusJ); 154 | 155 | /** 156 | * Set of Euler angles. this ordered set of rotations is around Y, then 157 | * around Z, then around Y 158 | */ 159 | public static final RotationOrder YZY = new RotationOrder("YZY", Vector3D.plusJ, 160 | Vector3D.plusK, Vector3D.plusJ); 161 | 162 | /** 163 | * Set of Euler angles. this ordered set of rotations is around Z, then 164 | * around X, then around Z 165 | */ 166 | public static final RotationOrder ZXZ = new RotationOrder("ZXZ", Vector3D.plusK, 167 | Vector3D.plusI, Vector3D.plusK); 168 | 169 | /** 170 | * Set of Euler angles. this ordered set of rotations is around Z, then 171 | * around Y, then around Z 172 | */ 173 | public static final RotationOrder ZYZ = new RotationOrder("ZYZ", Vector3D.plusK, 174 | Vector3D.plusJ, Vector3D.plusK); 175 | 176 | /** Name of the rotations order. */ 177 | private final String name; 178 | 179 | /** Axis of the first rotation. */ 180 | private final Vector3D a1; 181 | 182 | /** Axis of the second rotation. */ 183 | private final Vector3D a2; 184 | 185 | /** Axis of the third rotation. */ 186 | private final Vector3D a3; 187 | 188 | } 189 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/physics/library/physics.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GODPUS/processing-datamosh/34faf4cfc22bbdb4791aee4935b928e7c8eba012/libraries/traer_physics_lib_src/physics/library/physics.jar -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Attraction.java: -------------------------------------------------------------------------------- 1 | // attract positive repel negative 2 | 3 | package traer.physics; 4 | 5 | public class Attraction implements Force 6 | { 7 | Particle a; 8 | Particle b; 9 | float k; 10 | boolean on; 11 | float distanceMin; 12 | float distanceMinSquared; 13 | 14 | public Attraction( Particle a, Particle b, float k, float distanceMin ) 15 | { 16 | this.a = a; 17 | this.b = b; 18 | this.k = k; 19 | on = true; 20 | this.distanceMin = distanceMin; 21 | this.distanceMinSquared = distanceMin*distanceMin; 22 | } 23 | 24 | protected void setA( Particle p ) 25 | { 26 | a = p; 27 | } 28 | 29 | protected void setB( Particle p ) 30 | { 31 | b = p; 32 | } 33 | 34 | public final float getMinimumDistance() 35 | { 36 | return distanceMin; 37 | } 38 | 39 | public final void setMinimumDistance( float d ) 40 | { 41 | distanceMin = d; 42 | distanceMinSquared = d*d; 43 | } 44 | 45 | public final void turnOff() 46 | { 47 | on = false; 48 | } 49 | 50 | public final void turnOn() 51 | { 52 | on = true; 53 | } 54 | 55 | public final void setStrength( float k ) 56 | { 57 | this.k = k; 58 | } 59 | 60 | public final Particle getOneEnd() 61 | { 62 | return a; 63 | } 64 | 65 | public final Particle getTheOtherEnd() 66 | { 67 | return b; 68 | } 69 | 70 | public void apply() 71 | { 72 | if ( on && ( a.isFree() || b.isFree() ) ) 73 | { 74 | float a2bX = a.position().x() - b.position().x(); 75 | float a2bY = a.position().y() - b.position().y(); 76 | float a2bZ = a.position().z() - b.position().z(); 77 | 78 | float a2bDistanceSquared = a2bX*a2bX + a2bY*a2bY + a2bZ*a2bZ; 79 | 80 | if ( a2bDistanceSquared < distanceMinSquared ) 81 | a2bDistanceSquared = distanceMinSquared; 82 | 83 | float force = k * a.mass * b.mass / a2bDistanceSquared; 84 | 85 | float length = (float)Math.sqrt( a2bDistanceSquared ); 86 | 87 | // make unit vector 88 | 89 | a2bX /= length; 90 | a2bY /= length; 91 | a2bZ /= length; 92 | 93 | // multiply by force 94 | 95 | a2bX *= force; 96 | a2bY *= force; 97 | a2bZ *= force; 98 | 99 | // apply 100 | 101 | if ( a.isFree() ) 102 | a.force().add( -a2bX, -a2bY, -a2bZ ); 103 | if ( b.isFree() ) 104 | b.force().add( a2bX, a2bY, a2bZ ); 105 | } 106 | } 107 | 108 | public final float getStrength() 109 | { 110 | return k; 111 | } 112 | 113 | public final boolean isOn() 114 | { 115 | return on; 116 | } 117 | 118 | public final boolean isOff() 119 | { 120 | return !on; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/EulerIntegrator.java: -------------------------------------------------------------------------------- 1 | package traer.physics; 2 | 3 | public class EulerIntegrator implements Integrator 4 | { 5 | ParticleSystem s; 6 | 7 | public EulerIntegrator( ParticleSystem s ) 8 | { 9 | this.s = s; 10 | } 11 | 12 | public void step( float t ) 13 | { 14 | s.clearForces(); 15 | s.applyForces(); 16 | 17 | for ( int i = 0; i < s.numberOfParticles(); i++ ) 18 | { 19 | Particle p = (Particle)s.getParticle( i ); 20 | if ( p.isFree() ) 21 | { 22 | p.velocity().add( p.force().x()/(p.mass()*t), p.force().y()/(p.mass()*t), p.force().z()/(p.mass()*t) ); 23 | p.position().add( p.velocity().x()/t, p.velocity().y()/t, p.velocity().z()/t ); 24 | } 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Force.java: -------------------------------------------------------------------------------- 1 | /* 2 | * May 29, 2005 3 | */ 4 | 5 | package traer.physics; 6 | 7 | /** 8 | * @author jeffrey traer bernstein 9 | * 10 | */ 11 | public interface Force 12 | { 13 | public void turnOn(); 14 | public void turnOff(); 15 | public boolean isOn(); 16 | public boolean isOff(); 17 | public void apply(); 18 | } 19 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Integrator.java: -------------------------------------------------------------------------------- 1 | package traer.physics; 2 | 3 | public interface Integrator 4 | { 5 | public void step( float t ); 6 | } 7 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/ModifiedEulerIntegrator.java: -------------------------------------------------------------------------------- 1 | package traer.physics; 2 | 3 | public class ModifiedEulerIntegrator implements Integrator 4 | { 5 | ParticleSystem s; 6 | 7 | public ModifiedEulerIntegrator( ParticleSystem s ) 8 | { 9 | this.s = s; 10 | } 11 | 12 | public void step( float t ) 13 | { 14 | s.clearForces(); 15 | s.applyForces(); 16 | 17 | float halftt = 0.5f*t*t; 18 | 19 | for ( int i = 0; i < s.numberOfParticles(); i++ ) 20 | { 21 | Particle p = s.getParticle( i ); 22 | if ( p.isFree() ) 23 | { 24 | float ax = p.force().x()/p.mass(); 25 | float ay = p.force().y()/p.mass(); 26 | float az = p.force().z()/p.mass(); 27 | 28 | p.position().add( p.velocity().x()/t, p.velocity().y()/t, p.velocity().z()/t ); 29 | p.position().add( ax*halftt, ay*halftt, az*halftt ); 30 | p.velocity().add( ax/t, ay/t, az/t ); 31 | } 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Particle.java: -------------------------------------------------------------------------------- 1 | 2 | package traer.physics; 3 | 4 | public class Particle 5 | { 6 | protected Vector3D position; 7 | protected Vector3D velocity; 8 | protected Vector3D force; 9 | protected float mass; 10 | protected float age; 11 | protected boolean dead; 12 | 13 | boolean fixed; 14 | 15 | public Particle( float m ) 16 | { 17 | position = new Vector3D(); 18 | velocity = new Vector3D(); 19 | force = new Vector3D(); 20 | mass = m; 21 | fixed = false; 22 | age = 0; 23 | dead = false; 24 | } 25 | 26 | /* (non-Javadoc) 27 | * @see traer.physics.AbstractParticle#distanceTo(traer.physics.Particle) 28 | */ 29 | public final float distanceTo( Particle p ) 30 | { 31 | return this.position().distanceTo( p.position() ); 32 | } 33 | 34 | /* (non-Javadoc) 35 | * @see traer.physics.AbstractParticle#makeFixed() 36 | */ 37 | public final void makeFixed() 38 | { 39 | fixed = true; 40 | velocity.clear(); 41 | } 42 | 43 | /* (non-Javadoc) 44 | * @see traer.physics.AbstractParticle#isFixed() 45 | */ 46 | public final boolean isFixed() 47 | { 48 | return fixed; 49 | } 50 | 51 | /* (non-Javadoc) 52 | * @see traer.physics.AbstractParticle#isFree() 53 | */ 54 | public final boolean isFree() 55 | { 56 | return !fixed; 57 | } 58 | 59 | /* (non-Javadoc) 60 | * @see traer.physics.AbstractParticle#makeFree() 61 | */ 62 | public final void makeFree() 63 | { 64 | fixed = false; 65 | } 66 | 67 | /* (non-Javadoc) 68 | * @see traer.physics.AbstractParticle#position() 69 | */ 70 | public final Vector3D position() 71 | { 72 | return position; 73 | } 74 | 75 | public final Vector3D velocity() 76 | { 77 | return velocity; 78 | } 79 | 80 | /* (non-Javadoc) 81 | * @see traer.physics.AbstractParticle#mass() 82 | */ 83 | public final float mass() 84 | { 85 | return mass; 86 | } 87 | 88 | /* (non-Javadoc) 89 | * @see traer.physics.AbstractParticle#setMass(float) 90 | */ 91 | public final void setMass( float m ) 92 | { 93 | mass = m; 94 | } 95 | 96 | /* (non-Javadoc) 97 | * @see traer.physics.AbstractParticle#force() 98 | */ 99 | public final Vector3D force() 100 | { 101 | return force; 102 | } 103 | 104 | /* (non-Javadoc) 105 | * @see traer.physics.AbstractParticle#age() 106 | */ 107 | public final float age() 108 | { 109 | return age; 110 | } 111 | 112 | protected void reset() 113 | { 114 | age = 0; 115 | dead = false; 116 | position.clear(); 117 | velocity.clear(); 118 | force.clear(); 119 | mass = 1f; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/ParticleSystem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * May 29, 2005 3 | */ 4 | package traer.physics; 5 | 6 | import java.util.*; 7 | 8 | public class ParticleSystem 9 | { 10 | public static final int RUNGE_KUTTA = 0; 11 | public static final int MODIFIED_EULER = 1; 12 | 13 | protected static final float DEFAULT_GRAVITY = 0; 14 | protected static final float DEFAULT_DRAG = 0.001f; 15 | 16 | ArrayList particles; 17 | ArrayList springs; 18 | ArrayList attractions; 19 | ArrayList customForces = new ArrayList(); 20 | 21 | Integrator integrator; 22 | 23 | Vector3D gravity; 24 | float drag; 25 | 26 | boolean hasDeadParticles = false; 27 | 28 | public final void setIntegrator( int integrator ) 29 | { 30 | switch ( integrator ) 31 | { 32 | case RUNGE_KUTTA: 33 | this.integrator = new RungeKuttaIntegrator( this ); 34 | break; 35 | case MODIFIED_EULER: 36 | this.integrator = new ModifiedEulerIntegrator( this ); 37 | break; 38 | } 39 | } 40 | 41 | public final void setGravity( float x, float y, float z ) 42 | { 43 | gravity.set( x, y, z ); 44 | } 45 | 46 | // default down gravity 47 | public final void setGravity( float g ) 48 | { 49 | gravity.set( 0, g, 0 ); 50 | } 51 | 52 | public final void setDrag( float d ) 53 | { 54 | drag = d; 55 | } 56 | 57 | public final void tick() 58 | { 59 | tick( 1 ); 60 | } 61 | 62 | public final void tick( float t ) 63 | { 64 | integrator.step( t ); 65 | } 66 | 67 | public final Particle makeParticle( float mass, float x, float y, float z ) 68 | { 69 | Particle p = new Particle( mass ); 70 | p.position().set( x, y, z ); 71 | particles.add( p ); 72 | return p; 73 | } 74 | 75 | public final Particle makeParticle() 76 | { 77 | return makeParticle( 1.0f, 0f, 0f, 0f ); 78 | } 79 | 80 | public final Spring makeSpring( Particle a, Particle b, float ks, float d, float r ) 81 | { 82 | Spring s = new Spring( a, b, ks, d, r ); 83 | springs.add( s ); 84 | return s; 85 | } 86 | 87 | public final Attraction makeAttraction( Particle a, Particle b, float k, float minDistance ) 88 | { 89 | Attraction m = new Attraction( a, b, k, minDistance ); 90 | attractions.add( m ); 91 | return m; 92 | } 93 | 94 | public final void clear() 95 | { 96 | particles.clear(); 97 | springs.clear(); 98 | attractions.clear(); 99 | } 100 | 101 | public ParticleSystem( float g, float somedrag ) 102 | { 103 | integrator = new RungeKuttaIntegrator( this ); 104 | particles = new ArrayList(); 105 | springs = new ArrayList(); 106 | attractions = new ArrayList(); 107 | gravity = new Vector3D( 0, g, 0 ); 108 | drag = somedrag; 109 | } 110 | 111 | public ParticleSystem( float gx, float gy, float gz, float somedrag ) 112 | { 113 | integrator = new RungeKuttaIntegrator( this ); 114 | particles = new ArrayList(); 115 | springs = new ArrayList(); 116 | attractions = new ArrayList(); 117 | gravity = new Vector3D( gx, gy, gz ); 118 | drag = somedrag; 119 | } 120 | 121 | public ParticleSystem() 122 | { 123 | integrator = new RungeKuttaIntegrator( this ); 124 | particles = new ArrayList(); 125 | springs = new ArrayList(); 126 | attractions = new ArrayList(); 127 | gravity = new Vector3D( 0, ParticleSystem.DEFAULT_GRAVITY, 0 ); 128 | drag = ParticleSystem.DEFAULT_DRAG; 129 | } 130 | 131 | protected final void applyForces() 132 | { 133 | if ( !gravity.isZero() ) 134 | { 135 | for ( int i = 0; i < particles.size(); ++i ) 136 | { 137 | Particle p = (Particle)particles.get( i ); 138 | p.force.add( gravity ); 139 | } 140 | } 141 | 142 | for ( int i = 0; i < particles.size(); ++i ) 143 | { 144 | Particle p = (Particle)particles.get( i ); 145 | p.force.add( p.velocity.x() * -drag, p.velocity.y() * -drag, p.velocity.z() * -drag ); 146 | } 147 | 148 | for ( int i = 0; i < springs.size(); i++ ) 149 | { 150 | Spring f = (Spring)springs.get( i ); 151 | f.apply(); 152 | } 153 | 154 | for ( int i = 0; i < attractions.size(); i++ ) 155 | { 156 | Attraction f = (Attraction)attractions.get( i ); 157 | f.apply(); 158 | } 159 | 160 | for ( int i = 0; i < customForces.size(); i++ ) 161 | { 162 | Force f = (Force)customForces.get( i ); 163 | f.apply(); 164 | } 165 | } 166 | 167 | protected final void clearForces() 168 | { 169 | Iterator i = particles.iterator(); 170 | while ( i.hasNext() ) 171 | { 172 | Particle p = (Particle)i.next(); 173 | p.force.clear(); 174 | } 175 | } 176 | 177 | public final int numberOfParticles() 178 | { 179 | return particles.size(); 180 | } 181 | 182 | public final int numberOfSprings() 183 | { 184 | return springs.size(); 185 | } 186 | 187 | public final int numberOfAttractions() 188 | { 189 | return attractions.size(); 190 | } 191 | 192 | public final Particle getParticle( int i ) 193 | { 194 | return (Particle)particles.get( i ); 195 | } 196 | 197 | public final Spring getSpring( int i ) 198 | { 199 | return (Spring)springs.get( i ); 200 | } 201 | 202 | public final Attraction getAttraction( int i ) 203 | { 204 | return (Attraction)attractions.get( i ); 205 | } 206 | 207 | public final void addCustomForce( Force f ) 208 | { 209 | customForces.add( f ); 210 | } 211 | 212 | public final int numberOfCustomForces() 213 | { 214 | return customForces.size(); 215 | } 216 | 217 | public final Force getCustomForce( int i ) 218 | { 219 | return (Force)customForces.get( i ); 220 | } 221 | 222 | public final Force removeCustomForce( int i ) 223 | { 224 | return (Force)customForces.remove( i ); 225 | } 226 | 227 | public final void removeParticle( Particle p ) 228 | { 229 | particles.remove( p ); 230 | } 231 | 232 | public final Spring removeSpring( int i ) 233 | { 234 | return (Spring)springs.remove( i ); 235 | } 236 | 237 | public final Attraction removeAttraction( int i ) 238 | { 239 | return (Attraction)attractions.remove( i ); 240 | } 241 | 242 | public final void removeAttraction( Attraction s ) 243 | { 244 | attractions.remove( s ); 245 | } 246 | 247 | public final void removeSpring( Spring a ) 248 | { 249 | springs.remove( a ); 250 | } 251 | 252 | public final void removeCustomForce( Force f ) 253 | { 254 | customForces.remove( f ); 255 | } 256 | 257 | } -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Spring.java: -------------------------------------------------------------------------------- 1 | /* 2 | * May 29, 2005 3 | */ 4 | 5 | package traer.physics; 6 | 7 | /** 8 | * @author jeffrey traer bernstein 9 | * 10 | */ 11 | public class Spring implements Force 12 | { 13 | float springConstant; 14 | float damping; 15 | float restLength; 16 | Particle a, b; 17 | boolean on; 18 | 19 | public Spring( Particle A, Particle B, float ks, float d, float r ) 20 | { 21 | springConstant = ks; 22 | damping = d; 23 | restLength = r; 24 | a = A; 25 | b = B; 26 | on = true; 27 | } 28 | 29 | public final void turnOff() 30 | { 31 | on = false; 32 | } 33 | 34 | public final void turnOn() 35 | { 36 | on = true; 37 | } 38 | 39 | public final boolean isOn() 40 | { 41 | return on; 42 | } 43 | 44 | public final boolean isOff() 45 | { 46 | return !on; 47 | } 48 | 49 | public final Particle getOneEnd() 50 | { 51 | return a; 52 | } 53 | 54 | public final Particle getTheOtherEnd() 55 | { 56 | return b; 57 | } 58 | 59 | public final float currentLength() 60 | { 61 | return a.position().distanceTo( b.position() ); 62 | } 63 | 64 | public final float restLength() 65 | { 66 | return restLength; 67 | } 68 | 69 | public final float strength() 70 | { 71 | return springConstant; 72 | } 73 | 74 | public final void setStrength( float ks ) 75 | { 76 | springConstant = ks; 77 | } 78 | 79 | public final float damping() 80 | { 81 | return damping; 82 | } 83 | 84 | public final void setDamping( float d ) 85 | { 86 | damping = d; 87 | } 88 | 89 | public final void setRestLength( float l ) 90 | { 91 | restLength = l; 92 | } 93 | 94 | public final void apply() 95 | { 96 | if ( on && ( a.isFree() || b.isFree() ) ) 97 | { 98 | float a2bX = a.position().x - b.position().x; 99 | float a2bY = a.position().y - b.position().y; 100 | float a2bZ = a.position().z - b.position().z; 101 | 102 | float a2bDistance = (float)Math.sqrt( a2bX*a2bX + a2bY*a2bY + a2bZ*a2bZ ); 103 | 104 | if ( a2bDistance == 0 ) 105 | { 106 | a2bX = 0; 107 | a2bY = 0; 108 | a2bZ = 0; 109 | } 110 | else 111 | { 112 | a2bX /= a2bDistance; 113 | a2bY /= a2bDistance; 114 | a2bZ /= a2bDistance; 115 | } 116 | 117 | 118 | // spring force is proportional to how much it stretched 119 | 120 | float springForce = -( a2bDistance - restLength ) * springConstant; 121 | 122 | 123 | // want velocity along line b/w a & b, damping force is proportional to this 124 | 125 | float Va2bX = a.velocity().x - b.velocity().x; 126 | float Va2bY = a.velocity().y - b.velocity().y; 127 | float Va2bZ = a.velocity().z - b.velocity().z; 128 | 129 | float dampingForce = -damping * ( a2bX*Va2bX + a2bY*Va2bY + a2bZ*Va2bZ ); 130 | 131 | 132 | // forceB is same as forceA in opposite direction 133 | 134 | float r = springForce + dampingForce; 135 | 136 | a2bX *= r; 137 | a2bY *= r; 138 | a2bZ *= r; 139 | 140 | if ( a.isFree() ) 141 | a.force().add( a2bX, a2bY, a2bZ ); 142 | if ( b.isFree() ) 143 | b.force().add( -a2bX, -a2bY, -a2bZ ); 144 | } 145 | } 146 | 147 | protected void setA( Particle p ) 148 | { 149 | a = p; 150 | } 151 | 152 | protected void setB( Particle p ) 153 | { 154 | b = p; 155 | } 156 | } -------------------------------------------------------------------------------- /libraries/traer_physics_lib_src/src/Vector3D.java: -------------------------------------------------------------------------------- 1 | package traer.physics; 2 | 3 | 4 | public class Vector3D 5 | { 6 | float x; 7 | float y; 8 | float z; 9 | 10 | public Vector3D( float X, float Y, float Z ) { x = X; y = Y; z = Z; } 11 | public Vector3D() { x = 0; y = 0; z = 0; } 12 | public Vector3D( Vector3D p ) { x = p.x; y = p.y; z = p.z; } 13 | 14 | public final float z() { return z; } 15 | public final float y() { return y; } 16 | public final float x() { return x; } 17 | 18 | public final void setX( float X ) { x = X; } 19 | public final void setY( float Y ) { y = Y; } 20 | public final void setZ( float Z ) { z = Z; } 21 | 22 | public final void set( float X, float Y, float Z ) { x = X; y = Y; z = Z; } 23 | 24 | public final void set( Vector3D p ) { x = p.x; y = p.y; z = p.z; } 25 | 26 | public final void add( Vector3D p ) { x += p.x; y += p.y; z += p.z; } 27 | public final void subtract( Vector3D p ) { x -= p.x; y -= p.y; z -= p.z; } 28 | 29 | public final void add( float a, float b, float c ) { x += a; y += b; z += c; } 30 | public final void subtract( float a, float b, float c ) { x -= a; y -= b; z -= c; } 31 | 32 | public final Vector3D multiplyBy( float f ) { x *= f; y *= f; z*= f; return this; } 33 | 34 | public final float distanceTo( Vector3D p ) { return (float)Math.sqrt( distanceSquaredTo( p ) ); } 35 | 36 | public final float distanceSquaredTo( Vector3D p ) { float dx = x-p.x; float dy = y-p.y; float dz = z-p.z; return dx*dx + dy*dy + dz*dz; } 37 | 38 | public final float distanceTo( float x, float y, float z ) 39 | { 40 | float dx = this.x - x; 41 | float dy = this.y - y; 42 | float dz = this.z - z; 43 | return (float)Math.sqrt( dx*dx + dy*dy + dz*dz ); 44 | } 45 | 46 | public final float dot( Vector3D p ) { return x*p.x + y*p.y + z*p.z; } 47 | public final float length() { return (float)Math.sqrt( x*x + y*y + z*z ); } 48 | public final float lengthSquared() { return x*x + y*y + z*z; } 49 | 50 | public final void clear() { x = 0; y = 0; z = 0; } 51 | 52 | public final String toString() { return new String( "(" + x + ", " + y + ", " + z + ")" ); } 53 | 54 | public final Vector3D cross( Vector3D p ) 55 | { 56 | return new Vector3D( this.y*p.z - this.z*p.y, 57 | this.x*p.z - this.z*p.x, 58 | this.x*p.y - this.y*p.x ); 59 | } 60 | 61 | public boolean isZero() 62 | { 63 | return x == 0 && y == 0 && z == 0; 64 | } 65 | } 66 | --------------------------------------------------------------------------------