Salve ragazzi , ho questo codice java che utilizza la libreria openGL ; la finestra che contiene la visualizzazione openGL è un'applet ; vi mostro il codice :
codice:import processing.core.*; import tuio.*; import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class ringoffire extends PApplet { // we need to import the TUIO library // and declare a TuioClient variable TuioClient tuioClient; PFont font; Particle[] particles; int numParticles = 1000;//origin 10000 boolean lines = true; int w = 1024; int h = 768; public void setup() { size(w, h,P3D); background(0); noStroke(); fill(0); loop(); hint(ENABLE_NATIVE_FONTS); font = createFont("Arial", 18); particles = new Particle[numParticles]; for(int i=0;i<numParticles;i++) { particles[i] = new Particle(); particles[i].x = random(w); particles[i].y = random(h); particles[i].vx = random(-1,1); particles[i].vy = random (-1,1); } // an instance of the TuioClient // since we ad "this" class as an argument the TuioClient expects // an implementation of the TUIO callback methods (see below) tuioClient = new TuioClient(this); } // within the draw method we retrieve an array of TuioObject and TuioCursor // from the TuioClient and then loop over both lists to draw the graphical feedback. public void draw() { fill(0,0,255, 1); rect(0, 0, w, h); for(int i=0;i<numParticles;i++) { particles[i].move(); particles[i].render(); } TuioCursor[] tuioCursorList = tuioClient.getTuioCursors(); for (int i=0;i<tuioCursorList.length;i++) { TuioCursor tcur = tuioCursorList[i]; TuioPoint[] pointList = tcur.getPath(); if (pointList.length>0) { lines = !lines; particles[i].lines = lines; // stroke(0,0,255); TuioPoint start_point = pointList[0]; for (int j=0;j<pointList.length;j++) { TuioPoint end_point = pointList[j]; // line(start_point.getScreenX(width),start_point.getScreenY(height),end_point.getScreenX(width),end_point.getScreenY(height)); //println("X " + start_point.getScreenX(width)); start_point = end_point; } } } } // these callback methods are called whenever a TUIO event occurs // called when a cursor is added to the scene public void addTuioCursor(TuioCursor tcur) { println("add cursor "+tcur.getFingerID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY()); } // called when a cursor is moved public void updateTuioCursor (TuioCursor tcur) { println("update cursor "+tcur.getFingerID()+" ("+tcur.getSessionID()+ ") " +tcur.getX()+" "+tcur.getY() +" "+tcur.getMotionSpeed()+" "+tcur.getMotionAccel()); } // called when a cursor is removed from the scene public void removeTuioCursor(TuioCursor tcur) { println("remove cursor "+tcur.getFingerID()+" ("+tcur.getSessionID()+")"); } // called after each message bundle // representing the end of an image frame public void refresh(long timestamp) { //redraw(); } class Particle { public float x = 0; public float y = 0; public float vx = 100; public float vy = 100; public float k = .91f;//origin.08 public boolean lines = true; public int col = color( 255,20); private float grav = 0; private float angle = 0; public void Particle() { } public void move() { TuioCursor[] tuioCursorList = tuioClient.getTuioCursors(); for (int i=0;i<tuioCursorList.length;i++) { TuioCursor tcur = tuioCursorList[i]; float dx =tcur.getScreenX(width) - x; float dy = tcur.getScreenY(height) - y; float dist = sqrt(dx*dx + dy*dy); angle += .01f;//.05origin if(dist < 100)//100 origin { float tx = tcur.getScreenX(width) - dx / dist * (cos(angle) * 1 + 50);//*50origin float ty = tcur.getScreenY(height) - dy / dist * (sin(angle) * 1 + 50);//*50origin vx += (tx - x) * k; vy += (ty - y) * k; } else { float force = 200000 / (dist * dist);//oringin 2000 vx += force * dx / dist; vy += force * dy / dist; } vx += random(-1, 1); vy += random(-1.5f, 1.5f); vy += grav; vx *= .95f; vy *= .95f; x += vx; y += vy; if(x > w) { x = w; vx *= -1; } if(x<0) { x = 0; vx *= -1; } if(y > h) { y = h; vy *= -1; } if(y < 0) { y = 0; vy *= -1; } } } public void render() { stroke(col); if(lines) { line(x, y, x-vx, y-vy); } else { point(x,y); //ellipse(x, y,20,20); } /* stroke(random(125,255),0,0); if(lines) { line(x, y, x-vx, y-vy); } else { //point(x,y); //ellipse(x, y,20,20); }*/ } } static public void main(String args[]) { PApplet.main(new String[] { "ringoffire" }); }}
Proprio nella parte finale del codice , viene dichiarato il main :
static public void main(String args[]) { PApplet.main(new String[] { "ringoffire" }); }}
dove PAppet è una classe(facente parte della libreria core.jar del progetto all'url http://dev.processing.org/source/ind...rc/processing/)che estende la classe JApplet. LA mia domanda è : sarebbe possibile secondo voi caricare il contenuto in un JInternalFrame ? Spero di trovare qualcuno di voi che ha gia affrontato un problema simile. GRAZIE

Rispondi quotando