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.
IndexProgramming Questions & HelpPrograms › rotation, buttons, lots of fun stuff
Page Index Toggle Pages: 1
rotation, buttons, lots of fun stuff (Read 539 times)
rotation, buttons, lots of fun stuff
Feb 26th, 2006, 7:00am
 
Hey, I'm brand new to processing, I know a decent amount of java (not much graphics stuff yet though...) and i'm trying to write a program where i have a rotating house that has windows that act as buttons. Going through the examples i was able to create a house with the RGB example, by modifying the code.. and then i changed the rotation so that it would rotate with if(mousePressed){rotate(a)}.

My first problem and i've looked through all the forums becuase I figured this must be pretty trivial.. maybe it's not is that when i run the program it has my 3d house at it's initial position, and then when i click the mouse it rotates nicely but then when i unclick it goes back to that initial position. How do i make it stay at where it had rotated too? I havent been able to find an example of this, and I figure it's got to be pretty easy and common to do.

One other thing, is that all i've done so far is to create my 3d house and got it rotating. Is this the right way to do it, if i want to add basically doors and windows that can be clicked on to do things( i.e. bring up a more detailed information about blah object in some other frame)

I don't know yet how difficult or if it's even possible to add stuff to my house.

Thanks for any help... this is basically what i got atm


float a = 0.0;

void setup()
{
 size(600, 600,P3D);
 fill(204, 204);
 framerate(45);
 colorMode(RGB, 1);
}

void draw()
{
 background(0.5, 0.5, 0.45);
 a += 0.01;
 translate(width/1.8, height/2);
 if(mousePressed){
    rotateY(a);
 }
 scale(60);
 beginShape(QUADS);

~ lots of vector stuff for house ~

 endShape();  
}


Re: rotation, buttons, lots of fun stuff
Reply #1 - Feb 26th, 2006, 8:14am
 
for the rotate-thingie, just set if(mousePressed) a += 0.01;
and remove the if(mousePressed) around rotateY(a);
cause right now, you're saying: increase rotation-variable a every frame by 0.01, and if the user has mousePressed rotate to the given variable a, else don't rotate..

so rotate has to allways be active.. and a has to be the variable to change..
allthough mouse is a lot better for rotations.. and interactivity: rotateY(mouseX/(width/TWO_PI))

And for the mouse-selection check out this:
http://www.tom-carden.co.uk/p5/2005/10/3d-picking.php

-seltar
Re: rotation, buttons, lots of fun stuff
Reply #2 - Feb 26th, 2006, 9:22am
 
thanks for the quick reply, the spinning works beautifully and makes sense as well... I'm not sure what axis it's spinning around because it's slightly off center.. not sure what sets that up.. but not a big deal, I'll check the link out tomarrow and post if I have any more issues.

The idea is a prototype for a alarm system that has a more direct approach where you actually see the windows and doors you want to set the alarm\lock\open\close etc.. rather than a set of blinking lights. So you spin the house to whatever door\window and then click on it and then use another menu to adjust the settings ( it'd be like a touch screen..) but yeah.. thats the idea.
Page Index Toggle Pages: 1