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 & HelpSyntax Questions › A 'sphere' of 3D spheres
Pages: 1 2 
A 'sphere' of 3D spheres? (Read 1359 times)
Re: A 'sphere' of 3D spheres?
Reply #15 - Mar 20th, 2008, 9:25pm
 
Nice result, but it's not necessary to calculate the value every time, you only need to create one sphere object on setup  and get the coords array. In the draw loop you use this array to get the coords.
Re: A 'sphere' of 3D spheres?
Reply #16 - Mar 22nd, 2008, 1:35pm
 
Yeah that's what I thought, but it gets a bit funny with issues of variable scope.

Defining at start to make global (I know you're supposed to set the size here, but this should work I think)...
Code:
float [][][] coords; 



Making sphere and getting co-ords in setup()...
Code:
s=new Sphere(g, 10, 10);
float [][][] coords =s.coords();


And the rest in draw() for now.

But still throws a NullPointerException.
Re: A 'sphere' of 3D spheres?
Reply #17 - Mar 22nd, 2008, 1:56pm
 
Cycleswithin wrote on Mar 22nd, 2008, 1:35pm:
Making sphere and getting co-ords in setup()...
Code:
s=new Sphere(g, 10, 10);
float [][][] coords =s.coords();



Don't redeclare the coords array in setup.  In effect, you have a global variable coords which is equal to null, and then a local var (in setup) coords which is set to the Sphere object coords.  You just need to say:

Code:
s=new Sphere(g, 10, 10);
coords =s.coords();
Re: A 'sphere' of 3D spheres?
Reply #18 - Mar 22nd, 2008, 2:47pm
 
Heh, that would be it thanks... sorry there's so much stuff i'm trying to do and learn for 3 entirely different projects right now... :/
Re: A 'sphere' of 3D spheres?
Reply #19 - Apr 2nd, 2008, 12:00am
 
BTW; the slowness has nothing to wo with calculating the coordinates. That's peanuts. It's drawing the spheres that's tying down the system. Check sphereDetail() in the extended reference.

Rgs,

F.
Re: A 'sphere' of 3D spheres?
Reply #20 - Apr 2nd, 2008, 9:22am
 
You're not right. This post is about the Sphere object of the surfaceLib and not the build in processing sphere. So sphereDetail() isn't an opinion. And it makes a different if you calculate 100 points every time for 100 spheres or not, maybe not much but isn't a good style to do things twice if its not necessary.
Re: A 'sphere' of 3D spheres?
Reply #21 - Apr 2nd, 2008, 10:15am
 
Ah, Andreas, very true (excellent library by the way)... Revision of my earlier comment.
I'm not sure you need 100 points per sphere for a decent looking sphere. I'm convinced reducing this will be a major speed gain.
Although it's important to promote proper programming skills wherever possible, it should be for the right reason. In this case good practice, not necessarily any noticeable performance improvement. Otherwise people might decide that's it not worth the trouble...
Re: A 'sphere' of 3D spheres?
Reply #22 - Apr 2nd, 2008, 1:58pm
 
Reducing the number of spheres does increase performance - lower numbers run quite smoothly.

I'm pursuing another visual idea for my project (using arcs). There is one central sphere for this in fact, but I am trying to implement the cheat where you use a 2D sphere (made in a graphics program and applied as a texture) but which always faces the camera thus looking like a sphere.
Pages: 1 2