i see some results regarding tranparency
void makerect()
{
pushMatrix();
stroke(50, 255, 50,mouseY/3);
fill(100,100,100,mouseX/5);
rotateX(HALF_PI);
rect(-10, -10, 100, 100);
popMatrix();
}
void makesphere()
{
pushMatrix();
translate(0, -25, 0);
stroke(50, 255, 50,mouseY/3);
fill(0, 255, 255,mouseX/5);
sphere(25);
popMatrix();
}
the
hint()
is from processing.js ?? should that work here? well it does not give a error?
//______________________________________________
when you use P3D a operation would be nice, here a working example
for mouse or keyboard
PImage earth;
PShape globe;
//_________________________________________________________________ SETUP
void setup() {
size(640, 360, P3D);
earth = loadImage("earth.jpg");
globe = createShape(SPHERE, 1);
globe.setStroke(false);
globe.setTexture(earth);
info_print();
}//setup
//_________________________________________________________________ DRAW
void draw() {
background(0);
lights(); // everything looks better with lights()
PTZ();
} // draw
//_________________________________________________________________ DRAW_OBJECT
void draw_object() { //_________________called by / from inside PTZ
noStroke(); //directionalLight(250, 250, 250, 0, 0, -1); //ambientLight(100,100,100); // light and texture not work together
shape(globe,0, 0);
sphereAt (3, 0, 0, 0.3, color(140,140,140));
}
//_________________________________________________________________ SPHEREAT
void sphereAt( float x, float y, float z, float r, color colorSphere) {
translate(x,y,z);
fill(colorSphere); // fill color of the sphere
sphere(r); // size of the sphere
translate(-x,-y,-z);
}//sphereAt
//_________________________________________________________________
// PTZ tab
int mode = 0;
float Zmag = 21.1;
int Zaxis=-160;
float Xmag, Ymag = 0;
float newXmag, newYmag = 0;
int newZmag = 0;
int zoomf = 3;
float newxpos, newypos = 0; // for PAN
float xposd, yposd = 0; // for PAN
//_________________________________________________________________ ROTATE / TILDE and MOVE / PAN
void mousePressed() {
if (mouseButton == LEFT) { mode=1; } // ORBIT
else if (mouseButton == RIGHT) { mode=2; } // PAN
// else if (mouseButton == CENTER) { mode=3; } // zoom mouse wheel
}
//_________________________________________________________________ mouse PT end
void mouseReleased() {
mode = 0;
}
//_________________________________________________________________ mouseWheel ZOOM
void mouseWheel(MouseEvent event) {
int newZmag = event.getCount(); // +- 1
if (Zmag > 10) { Zmag += newZmag * 5; } else { Zmag += newZmag; } // from 1 to 11 go in step 1 else in step 5
}
void keyPressed(){
if ( keyCode == UP ) {Ymag -= 0.1 ;}
if ( keyCode == DOWN ) {Ymag += 0.1 ;}
if ( keyCode == RIGHT) {Xmag -= 0.1 ;}
if ( keyCode == LEFT ) {Xmag += 0.1 ;}
if ( keyCode == 16 ) {Zmag -= 1 ;} // [PageUP]
if ( keyCode == 11 ) {Zmag += 1 ;} // [PageDOWN]
//println("key: "+key); println("keyCode: "+keyCode);
}
//_________________________________________________________________ Pan Tilde Zoom
void PTZ() {
pushMatrix();
translate(width/2, height/2, Zaxis);
// get new mouse operation
if ( mode == 2 ) { // PAN ( right mouse button pressed)
xposd = (mouseX-float(width/2));
yposd = (mouseY-float(height/2));
}
newxpos = xposd;// xposd=0;
newypos = yposd;// yposd = 0;
translate(newxpos,newypos, 0); // move object
if ( mode == 1 ) { // ORBIT ( left mouse button pressed)
newXmag = mouseX/float(width) * TWO_PI;
newYmag = mouseY/float(height) * TWO_PI;
float diff = Xmag-newXmag;
if (abs(diff) > 0.01) { Xmag -= diff/4.0; }
diff = Ymag-newYmag;
if (abs(diff) > 0.01) { Ymag -= diff/4.0; }
}
rotateX(-Ymag); rotateY(-Xmag);
scale(Zmag);
draw_object(); // see MAIN: THE OBJECT
popMatrix();
}
//_______________________________________________ SETUP PRINT INFO
void info_print() {
println("PTZ info:");
println("mouse LEFT press drag up down right left || key arrow UP DOWN RIGHT LEFT -> rotate");
println("mouse RIGHT press -> move ");
println("mouse WHEEL turn || key PAGE UP DOWN -> zoom");
}
you need the earth image in
/data/earth.jpg