我尝试将来自外部设备的数据映射到绘制图案。但是oscP5库和P3D渲染器不能同时处理3.3.7和3.4,而它们可以单独工作。它们可以在processing 2.2.1中工作,但2.2.1不支持声音库。有人知道怎么解决这个问题吗?
import oscP5.*;
OscP5 oscP5;
float value;
void setup(){
size(400, 400, P3D);
rectMode(CENTER);
oscP5 = new OscP5(this, 60000);
}
void oscEvent(OscMessage theOscMessage){
if (theOscMessage.checkAddrPattern("/ATT")){
value = theOscMessage.get(0).floatValue();
}
}
void draw(){
background(0);
noStroke();
fill(255);
float r = second()/10;
rotateZ(r);
rect(width/2, height/2, value, value);
}发布于 2018-11-25 11:16:13
我解决了这个问题。在我的原始代码中,setup()中有一个frameRate初始化(如下所示的最小示例),我没有意识到是它导致了问题(因为frameRate初始化分别与oscP5或P3D一起工作时不会导致错误),所以我没有在我的问题中写它。现在,我删除了frameRate初始化行(frameRate(30)),然后oscP5和P3D终于可以一起工作了(即使我仍然感到困惑,但这不会影响我当前的工作)。
import oscP5.*;
OscP5 oscP5;
float value;
void setup(){
size(400, 400, P3D);
// the following line causes the error when oscP5 and P3D attempt to work together,
// but the code works when there is either oscP5 and P3D, oscP5 and frameRate or P3D and frameRate.
frameRate(30);
rectMode(CENTER);
oscP5 = new OscP5(this, 60000);
}
void oscEvent(OscMessage theOscMessage){
if (theOscMessage.checkAddrPattern("/ATT")){
value = theOscMessage.get(0).floatValue();
}
}
void draw(){
background(0);
noStroke();
fill(255);
float r = second()/10;
rotateZ(r);
rect(width/2, height/2, value, value);
}希望我已经解释清楚了。:)
https://stackoverflow.com/questions/53451383
复制相似问题