We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › 3D Picking
Pages: 1 2 
3D Picking (Read 4499 times)
Re: 3D Picking
Reply #15 - Feb 20th, 2010, 2:07pm
 
Sure, sorry Smiley

Very alpha release, source code included:
http://n.clavaud.free.fr/processing/picking-library/
Re: 3D Picking
Reply #16 - Mar 27th, 2010, 10:19am
 
Hello!   Wink

@ antiplastik: Thank you!

@ Quark: I posted what you wrote me via messaging here:

Every shape created has a tag (String) and tagNo (int) which can be set to any value e.g. array index.


Code:
  for (int i = 0; i < box.length; i++) {     
    size = 5 + (int)random(15);
    box[i] = new Box(this,size,size,size);
    box[i].moveTo(random(-18,18), random(-18,18), random(-18,18));
    box[i].fill(randomColor());
    box[i].tagNo = i;
    box[i].tag = "Box "+i;  
}  


Then inside draw we have


Code:
    if(mouseClicked){
    Shape3D picked = Shape3D.pickShape(this,mouseX, mouseY);
    if(picked != null){
// use tagNo as array index
box[picked.tagNo].fill(randomColor());
    }
    mouseClicked = false;
  }




Quote:
How can I give the boxes names? Or an 3D-Index?


All shapes have 2 attributes that the user can do with as they will.

Assuming that we have a shape object called myshape then we can use these attributes to identify our shapes in any way we wish.


Code:
 // String attribute tag
myshape.tag = "This shape is called box";
// Int attribute tagNo
myshape.tagNo = 101;
println(myshape.tag + "  " + tagNo);  
// Will display
// This shape is called box 101  

Hope this helps.

Greetings, Chrisir    Wink

chess
Reply #17 - Mar 27th, 2010, 2:28pm
 
I posted the small chess-thing.

The picking is only reliable with OPENGL.

http://www.openprocessing.org/visuals/?visualID=8530

Chrisir    Wink

Pages: 1 2