We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Here's my code ,By the way: I just use command+E and it doesn't show the platform (Win Linux),why??how to fix it? Here is all the file needed : http://pan.baidu.com/s/1hqiKAZ6 Processing Version 2.1
import processing.opengl.*;
import processing.video.*;
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
AudioPlayer player_background_music,player_camera_sound;
Minim minim_music,minim_microphone,minim_camera_sound;
AudioInput in;
Capture cam;
PImage stamp_photo,sign_photo,UFO_image;
int sze_X=900,sze_Y=600,star_quantity=100,trslt=0,meteor_counter_trslt=0,sze_camera_X=96,sze_camera_Y=96,sze_meteor_X,sze_meteor_Y,size_of_meteor;
float center_star_X=sze_X/3,center_star_Y=sze_Y/3,center_X=sze_X/2,center_Y=sze_Y/2,step_star=0,step_meteor=0,meteor_counter_i=0;
float x[]=new float[star_quantity],y[]=new float[star_quantity],z[]=new float[star_quantity],size_STR_static[]=new float[star_quantity];
color C[]=new color[star_quantity],c=color(0,0,0),color_delivery=color(0,0,0);
String saved="",typing="";
PFont f;
boolean direction_anticlockwise=false,judge_stop=false,text_cursor_show_or_not=false,judge_meteor_anmiation_finished_or_not=true,text_cursor_show_or_not_while_image_show=true,generate_meteor_or_not=false;
boolean photo_finished_or_not=false;//used in get_feedback()
boolean image_should_show_or_not=false;//used in keyReleased() to club together with get_feedback()
float UFO_location_X,UFO_location_Y,UFO_X_speed,UFO_Y_speed=3;
boolean judge_UFO_animation_finished_or_not=true;
int Shall_we_start_UFO,UFO_counter_i;
void setup(){
size(sze_X,sze_Y,OPENGL);
background(0);
fill(0);
smooth(8);
noStroke();
cam = new Capture(this,sze_camera_X,sze_camera_Y,60);
cam.start();
minim_music=new Minim(this);
minim_camera_sound=new Minim(this);
player_background_music=minim_music.loadFile("background_music.mp3");
player_camera_sound=minim_camera_sound.loadFile("camera.wav");
minim_microphone=new Minim(this);
minim_microphone.debugOn();;
in=minim_microphone.getLineIn(Minim.STEREO,1024);
UFO_image=loadImage("UFO.png");
stamp_photo=loadImage("stamp.png");
sign_photo=loadImage("ATC.png");
rdm();
f = createFont("Arial",25,true);
}
void rdm(){
int half_size=45;
switch(int(random(0,1))){
case 0:direction_anticlockwise=false;break;
case 1:direction_anticlockwise=true;break;
}
for(int i=0;i<star_quantity;i++){
x[i]=random(-sze_X,sze_X);
y[i]=random(-sze_Y,sze_Y);
z[i]=random(-sze_X,sze_X);
C[i]=color(int(random(0,255)),int(random(0,255)),int(random(0,255)));
size_STR_static[i]=random(5,13);
if(center_star_X-half_size-13<=x[i]&&x[i]<=center_star_X+half_size+13){
if(center_star_Y-half_size-13<=y[i]&&y[i]<=center_star_Y+half_size+13){
if(-center_star_Y+half_size+13<=z[i]&&z[i]<=center_star_Y+half_size+13){
while(center_star_Y-half_size-13<=y[i]&&y[i]<=center_star_Y+half_size+13){y[i]=random(-sze_Y,sze_Y);}
}
}
}
}
}
void draw(){
int box_distance_between_each=50;
clear();
pointLight(255,255,255,360,220,200);
center_star();
noLights();
lights();
if(judge_stop == false){
pushMatrix();
rotate_star();
star();
popMatrix();
if(judge_meteor_anmiation_finished_or_not == true){trslt=GETKEY();}
if((generate_meteor_or_not==true)&&(c==color(1,1,1))){color_delivery=color(int(random(0,255)),int(random(0,255)),int(random(0,255)));}
else if(((generate_meteor_or_not==true)&&(c!=color(1,1,1)))&&(c!=color(0,0,0))){color_delivery=c;}
meteor();
if(mousePressed && (mouseButton == LEFT)){judge_stop=true;}
}
else{
pushMatrix();
rotateY(step_star);
star();
popMatrix();
pushMatrix();
rotateZ(step_meteor);
meteor_animation();
popMatrix();
}
if((text_cursor_show_or_not == true)&&(text_cursor_show_or_not_while_image_show == true)){
textFont(f);
fill(255);
text(typing+(frameCount/10 % 2 == 0 ? "_" : ""),center_star_X,center_star_Y,50);
}
else if((text_cursor_show_or_not == true)&&(text_cursor_show_or_not_while_image_show == false)){
textFont(f);
fill(255);
text(typing,center_star_X,center_star_Y,50);
}
if(image_should_show_or_not==true){
noLights();
for(int i=1;i<=5;i++){draw_boxes(box_distance_between_each*i,200-30*i);}
image(sign_photo,0,0,sze_X,sze_Y);
pushMatrix();
translate(sze_X-2*sze_camera_X-20,40*2);
image(cam,0,0);
image(stamp_photo,0,0,sze_camera_X,sze_camera_Y);
popMatrix();
}
get_feedback();
noLights();
fill(int(random(0,255)),int(random(0,255)),int(random(0,255)));
lights();
UFO();
noLights();
if(mousePressed && (mouseButton == RIGHT)){judge_stop=false;}
}
void keyReleased(){
if((keyCode == LEFT)&&(judge_stop==false)){direction_anticlockwise=true;}
else if((keyCode == RIGHT)&&(judge_stop==false)){direction_anticlockwise=false;}
else if((keyCode == DOWN)&&(judge_stop==false)){typing+='\n';}
else if(keyCode == DOWN){typing+=' ';}
else if((key == '\n')&&(judge_stop==false)){
saved=typing;
typing="";
text_cursor_show_or_not=false;
step_meteor=0;
}
else if(key == BACKSPACE){
typing=typing.substring(0,max(0,typing.length()-1));
}
else if(keyCode == CONTROL){typing="";text_cursor_show_or_not=false;}
else if(keyCode == SHIFT){
if(image_should_show_or_not==true){image_should_show_or_not=false;text_cursor_show_or_not_while_image_show=true;}
else{image_should_show_or_not=true;text_cursor_show_or_not_while_image_show=false;}
}
else if((key == ' ')&&(image_should_show_or_not == true)){
saveFrame("line-######.tif");
player_camera_sound.play();
}
else{typing+=key;text_cursor_show_or_not=true;}
}
void captureEvent(Capture video) {
video.read();
}
void UFO(){
int How_long_will_it_show=50;
if(judge_UFO_animation_finished_or_not==true){
UFO_location_X=int(random(0,sze_X));
UFO_location_Y=int(random(0,sze_Y));
Shall_we_start_UFO=int(random(0,1000));
judge_UFO_animation_finished_or_not=false;
}
if(Shall_we_start_UFO==500){
for(;UFO_counter_i<How_long_will_it_show;){
pushMatrix();
translate(UFO_location_X,UFO_location_Y);
image(UFO_image,0,0,100,100);
UFO_location_X+=UFO_X_speed;
UFO_location_Y+=UFO_Y_speed;
if (UFO_location_X>= width ||UFO_location_X<0)
{UFO_X_speed=-UFO_X_speed;}
// if(UFO_location_Y>= height ||UFO_location_Y<0)
{UFO_Y_speed=-UFO_Y_speed;}
popMatrix();
UFO_counter_i++;
break;
}
if(UFO_counter_i==How_long_will_it_show){
UFO_counter_i=0;
judge_UFO_animation_finished_or_not=true;
}
}
}
void center_star(){
color blk=color(0,0,0);
color blu=color(100,255,252);
int size=100;
float number=0.01;
color change=lerpColor(blk,blu,0);
pushMatrix();
translate(center_star_X,center_star_Y,0);
fill(blu);
sphere(size/2);
popMatrix();
}
void star(){
color blc=color(0,0,0);
float size_STR_dynamic=5.0;
float number;
color change;
for(int i=0;i<star_quantity;i++){
size_STR_dynamic=size_STR_static[i];
number=0;
pushMatrix();
translate(x[i],y[i],z[i]);
fill(C[i]);
sphere(size_STR_static[i]);
popMatrix();
}
}
void rotate_star(){
rotateY(step_star);
if(direction_anticlockwise == false){step_star+=0.01;}
else{step_star-=0.01;}
}
int GETKEY(){
int TRSLT=0;
boolean judge_key_number_or_not=false,judge_key_letter_or_not=false;
for(int i=0;i<saved.length();i++){
if(i==0){
if((('a'<=saved.charAt(0))&&(saved.charAt(0)<='z'))||(saved.charAt(0)=='C')){judge_key_letter_or_not=true;}
else{judge_key_letter_or_not=false;break;}
}
else{
if(('0'<=saved.charAt(i))&&(saved.charAt(i)<='9')){judge_key_number_or_not=true;}
else{judge_key_number_or_not=false;break;}
}
}
if(judge_key_letter_or_not && judge_key_number_or_not){
meteor_counter_trslt=0;
judge_meteor_anmiation_finished_or_not=false;
generate_meteor_or_not=true;
for(int i=1;i<saved.length();i++){
TRSLT+=get_final_number(int(saved.charAt(i))-48,i,saved.length()-1);
}
}
if(TRSLT!=0){
switch(saved.charAt(0)){
default:c=color(0,0,0);break;//Ignore
case 'C':c=color(1,1,1);break;//Colorful
case 'b':c=color(0,30,255);break;//Blue
case 'c':c=color(255,0,198);break;//Peacock
case 'e':c=color(253,131,0);break;//Orange
case 'g':c=color(12,253,0);break;//Green
case 'l':c=color(2,255,240);break;// Light Bule
case 'n':c=color(240,0,255);break;//Pink
case 'o':c=color(253,250,0);break;//Yellow
case 'p':c=color(73,2,255);break;//Purple
case 'r':c=color(255,0,66);break;//Rose
case 'v':c=color(139,2,255);break;//Lavender
case 'w':c=color(161,253,0);break;//Warm Green
case 'y':c=color(0,253,185);break;//Cyan
}
}
saved="";
return TRSLT;
}
void meteor(){//////////////////////////////////////////////////////////////////////////////////////////////
if(c==color(1,1,1)){main_meteor_function();}
else if((c!=color(1,1,1))&&(c!=color(0,0,0))){main_meteor_function();}
}
void main_meteor_function(){
float step=0.1;
if(judge_meteor_anmiation_finished_or_not == false){
if(generate_meteor_or_not==true){
sze_meteor_X=int(random(0,sze_X));
sze_meteor_Y=int(random(0,sze_Y));
size_of_meteor=int(random(10,50));
generate_meteor_or_not=false;
}
for(;meteor_counter_i<3*QUARTER_PI;){
if(keyPressed){if(key=='Q'){break;}}
pushMatrix();
rotateZ(step_meteor);//k_diagonal*k_perpendicular=-1
step_meteor+=step;
meteor_animation();
popMatrix();
meteor_counter_i+=step;
if((meteor_counter_i>=3*QUARTER_PI)&&(meteor_counter_trslt<trslt)){
meteor_counter_i=0;
meteor_counter_trslt++;
generate_meteor_or_not=true;
}
else if((meteor_counter_i>=3*QUARTER_PI)&&(meteor_counter_trslt>=trslt)){
meteor_counter_i=0;
judge_meteor_anmiation_finished_or_not=true;
c=color(0,0,0);
}
break;
}
}
}
void meteor_animation(){
pushMatrix();
translate(sze_meteor_X,sze_meteor_Y,0);
fill(color_delivery);
lights();
lights();
lights();
sphere(size_of_meteor);
noLights();
popMatrix();
}
int get_final_number(int number,int i,int number_leth){
int final_number=1;
for(;i<number_leth;i++){final_number*=10;}
final_number*=number;
return final_number;
}
void draw_boxes(int location,int box_color){
int box_distance_between_Left_and_Right_X=30,box_distance_between_Top_and_Bottom_Y=40;
int box_top_left_X=0,box_top_left_Y=0;
int box_bottom_left_X=box_top_left_X,box_bottom_left_Y=box_top_left_Y+box_distance_between_Top_and_Bottom_Y;
int box_bottom_right_X=box_bottom_left_X+box_distance_between_Left_and_Right_X,box_bottom_right_Y=box_bottom_left_Y;
int box_top_right_X=box_bottom_right_X,box_top_right_Y=box_top_left_Y;
pushMatrix();
strokeCap(ROUND);
strokeJoin(BEVEL);
strokeWeight(5.0);
stroke(box_color);
noFill();
translate(60+location,75);
beginShape();
vertex(box_top_left_X, box_top_left_Y);
vertex(box_bottom_left_X,box_bottom_left_Y);
vertex(box_bottom_right_X,box_bottom_right_Y);
vertex(box_top_right_X,box_top_right_Y);
vertex(box_top_left_X, box_top_left_Y);
vertex(box_bottom_left_X,box_bottom_left_Y-10);
endShape();
noStroke();
popMatrix();
}
void get_feedback(){
color findcolor=color(1,255,25);;
boolean off_or_not_background_music=true,judge_fist_time_or_not_background_music=false,speak_or_not=false;
cam.loadPixels();
for(int x=0;x<cam.width;x++){
for(int y=0;y<cam.height;y++){
int loc=x+y*cam.width;
color videocolor=cam.pixels[loc];
float red_camera_get=red(videocolor),green_camera_get=green(videocolor),blue_camera_get=blue(videocolor);
float red_target=red(findcolor),green_target=green(findcolor),blue_target=blue(findcolor);
float d=dist(red_camera_get,green_camera_get,blue_camera_get,red_target,green_target,blue_target);
float color_difference=300;
int camera;
if(d<color_difference){off_or_not_background_music=false;}
}
}
for(int i=0;i<in.bufferSize()-1;i+=8){
if((in.left.get(i)>=0.5)&&(in.right.get(i)>=0.5)){speak_or_not=true;break;}
else if(i==in.bufferSize()-1){speak_or_not=false;}
}
if((off_or_not_background_music==false)&&(speak_or_not==true)){player_background_music.play();}
else if((off_or_not_background_music==true)&&(judge_fist_time_or_not_background_music==true)){
player_background_music.close();
minim_music.stop();
super.stop();
}
}
Answers
Why this working fine????I Must Use the function that previous one has , how to solve the problem???
now i find that this simple code after export it can't run , why???This May Be Key! Please Give Me some more tips thanks!
I don't have much experience with these kinds of issues, but I have read elsewhere that, perhaps, you must take out the data folder before exporting, and add it back into the exported application after the export. I think your various sketches work / don't work because some require loading files from the data folder while others don't.
EDIT: This may or may not apply to a Mac...
music.mp3 is in /Users/CC/Documents/Processing/sketch_140106c while data file is in ~/Library/Processing (am i right???) , i Moved it to desktop and processing data doesn't have the music,so i should move to to data folder(/Users/CC/Documents/Processing/sketch_140106c/application.macosx64/Processing) after export , and then the application i export will run perfectly right???
Last login: Tue Jan 7 08:27:33 on ttys001 /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/MacOS/New_Glaxy__2 ; exit; chenchendeMacBook-Pro:~ CC$ /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/MacOS/New_Glaxy__2 ; exit; /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/Java/data /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/Java/data ==== JavaSound Minim Error ==== ==== Error invoking createInput on the file loader object: null
Exception in thread "Animation Thread" java.lang.RuntimeException: java.lang.NullPointerException at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58) at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103) at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206) at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172) at javax.media.opengl.Threading.invoke(Threading.java:191) at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:492) at processing.opengl.PJOGL.requestDraw(PJOGL.java:626) at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1598) at processing.core.PApplet.run(PApplet.java:2177) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.NullPointerException at ddf.minim.javasound.JSMinim.getAudioRecordingStream(Unknown Source) at ddf.minim.Minim.loadFile(Unknown Source) at ddf.minim.Minim.loadFile(Unknown Source) at New_Glaxy__2.setup(New_Glaxy__2.java:65) at processing.core.PApplet.handleDraw(PApplet.java:2281) at processing.opengl.PJOGL$PGLListener.display(PJOGL.java:799) at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:590) at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:574) at javax.media.opengl.awt.GLCanvas$9.run(GLCanvas.java:1218) at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1036) at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:911) at javax.media.opengl.awt.GLCanvas$10.run(GLCanvas.java:1229) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733) at java.awt.EventQueue.access$200(EventQueue.java:103) at java.awt.EventQueue$3.run(EventQueue.java:694) at java.awt.EventQueue$3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:703) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91) logout
[Process completed]
I'm wrong???so Where is the data folder for processing
/Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/data but i use folder to goto the address , but none. Why???
1.7.0_45 /Applications/Processing.app/Contents/PlugIns/jdk1.7.0_45.jdk/Contents/Home/jre
x86_64 Mac OS X 10.9.1
/Users/CC /Users/CC
/Users/CC/Documents/Processing/sketchbook/New_Glaxy__2 /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/data
here is the solve way:/Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/Java in this area create folder with the name data and paste all the file the program needs such ad pictures and music.
but i still want to know why there's no data folder in /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/ (I did nothing to it!)
also there is another way create data fist in /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/ and paste all the file processing needs , then you need not to copy data folder to : /Users/CC/Documents/Processing/sketchbook/New_Glaxy__2/application.macosx64/New_Glaxy__2.app/Contents/Java , each time after your export