FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   Surface function visualizer
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Surface function visualizer  (Read 323 times)
ahattemer

WWW
Surface function visualizer
« on: Apr 2nd, 2004, 10:39am »

Hello everyone, this is my first post here, and one of my first programs.
 
I am writing a simple program that will render a function of two variables as a 3 dimensional graph, so far I have made some good progress, but there are quite a few... quirks I have encountered.
 
Here is a link to a working but unfinished version of the program, if you click on the bottom border of the applet you will get different functions, if you click on the top border you will get more iterations
 
http://www.scriptedlife.com/java/surface
 
Problem 1: I am rotating the camera around the graph, so displaying buttons and font becomes a problem, it seems like rotating the shape is out of the question, since its made out of a bunch of quads, is there any way to fix this?
 
Problem 2:  For some reason the camera is inverted, as seen by the lighting, here is the camera code.
 
//MOVE CAMERA ACCORDING TO MOUSE
  counter = mouseX*(PI/250);
  changerA = (int)(600*sin(counter));
  changerB = (int)(600*cos(counter));
  lookat(changerA, changerB, -200, 0, 0, 0, 0, 0, 1);
 
I have read a little about the lookat function in openGl, but I am still not really sure what it does.
 
thanks a lot, and beware of the source code, its messy and embarassing.
 
JohnG

WWW
Re: Surface function visualizer
« Reply #1 on: Apr 2nd, 2004, 11:46am »

Something that will probably help you with the buttons is push(); and pop();
 
If at the start of your loop you do push(); then the movement for the camera and quad drawing, then pop(); you will be able to draw the buttons in 2D as normal, as the pop(); gets rid of the all the 3D transformations you performed after the push(); , but leaves the stuff inside it transformed.
 
so:
 
push();
translate(width/2,height/2,0);
box(20);
pop();
box(20);
 
should draw a box in the middle of the screen, and then one back at the top left corner.
 
 
There's no problem with rotating the shape, even if it's made out of quads, you just do:
 
push();
rotateY(AngleInRadians);
for(int j = 0; j < ((grid - 1)*(grid-1)); j++)
{  
  beginShape(QUADS);
  etc...
  endShape()
}
pop();
 
that way you don't have to mess around with lookat, or other camera things if you don't want to, and draw your buttons/text after all the shapes are drawn.
 
fry


WWW
Re: Surface function visualizer
« Reply #2 on: Apr 2nd, 2004, 5:08pm »

camera functions like lookat() need to go inside of beginCamera/endCamera.. hm, it appears as though it's been removed from the docs, pending its finalization. perhaps do a reverse find in revisions.txt for a note about how beginCamera works?
 
there's also some kookiness with the lighting model, we're gonna get that repaired soon..
 
Pages: 1 

« Previous topic | Next topic »