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 › hel needed -- simple sphere
Page Index Toggle Pages: 1
hel needed -- simple sphere (Read 1770 times)
hel needed -- simple sphere
Dec 1st, 2009, 5:51am
 
hi, i want to make a simple sphere that changes mesh detail depenting on the postion of mouse,, i managed to do that ,, now, i want to add a cirlce in a place of every vertices (where lines join) on sphere..is that possible?

here is the code

 
void setup() {  
size(700, 700, P3D);  
smooth();  
colorMode(RGB, 255);
}  
 
void draw()  
{  
background(0);
 pushMatrix();
 translate(width/2, height/2);
 noFill();
 stroke(225);
 rotateX(mouseY * 300);
 rotateY(mouseX * 300);
 sphereDetail(mouseX / 60, mouseY / 60);
 sphere(250);
 popMatrix();

}  

thanks in advance Smiley
Re: hel needed -- simple sphere
Reply #1 - Dec 1st, 2009, 8:47am
 
Processing's sphere() method does a bunch of calculations to determine the vertices, edges, faces, and so on. If you want to do something at each vertex, you need to work out where each vertex is. sphere() is not designed to tell you that, nor do something else on your behalf for each vertex.

If this task is for some sort of class, you should go and do some research on how to determine locations of points on a sphere.

You will also need to decide what you mean by "draw a circle"... Do you mean draw a "2D" circle around each of the vertices, as though circling them on a photograph, or do you intend for these circles to appear to be on the surface of the sphere?

-spxl
Re: hel needed -- simple sphere
Reply #2 - Dec 1st, 2009, 12:24pm
 
BTW, that's the wrong place to ask for help...
Re: hel needed -- simple sphere
Reply #3 - Dec 1st, 2009, 1:37pm
 
Hi, thhnx for answer

@subpixel Im pretty much newbie, so srry for asking such questions. yeah i wanna create 2D cricles at veritces, they dont have to lie on sphere surface.

@PhiLho.. srry for asking question in the wrong place
Re: hel needed -- simple sphere
Reply #4 - Dec 1st, 2009, 10:41pm
 
Read my answer as "there is no easy way" and "if you are doing a course you really shouldn't be asking for quick answers".

If you want to do anything non-trivial, you will need to go and learn something about positioning/locating things in 3D space, otherwise you will always essentially be asking "can someone write a program to do X for me?" because every time you get an answer it will not make sense on what it is doing and not really help you for your next task.

-spxl
Re: hel needed -- simple sphere
Reply #5 - Dec 2nd, 2009, 1:08am
 
i agree with you in some sense, but im strong beliver, at least i know that works in my case, of looking at some code examples that are hard to understand to newbie at the same time while im reading the blue book. Without looking at code and trying to understand you seem to forgot what certian function does and what values you can assign to it.
Hej, but thanks for pointing me in right direction.
Re: hel needed -- simple sphere
Reply #6 - Dec 2nd, 2009, 1:14am
 
Luka, they tell the truth. It is not that 'simple here'.
You can look at the code inside Processing IDE examples > libraries > opengl > esfera.

There you will find one of the methods one can use to find out how to draw points at certain position around a sphere. More points made the sphere (visually).

Try playing with that example, remove the lines and make some points. Use the coords to draw your 2D circle.
This is trial-and-error way to reach your goal. At the end you will have a nice looking skecth whithout having a clue of what's going on. Really.

my two cents.
Wink
Re: hel needed -- simple sphere
Reply #7 - Dec 2nd, 2009, 1:32am
 
I think the point is that with this kind of thing it's not so much about understanding the code, but the maths involved:  If you have a good understand of that you shouldn't have too many problems implementing the code...
Re: hel needed -- simple sphere
Reply #8 - Dec 5th, 2009, 12:07pm
 
Here's an old example changing the sphere resolution based on the mouse position. This code has been used a template for the built-in sphereDetail() function too:

http://toxi.co.uk/p5/xsphere/
Page Index Toggle Pages: 1