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.
Page Index Toggle Pages: 1
Points in 3D space. (Read 1011 times)
Points in 3D space.
Mar 3rd, 2009, 9:07pm
 
Help! I have a program with a big number of spheres and it needs a lot of memory. Can I substitute spheres by bold points?
If I use command point(x,y); it draws a little point, but I neew bold points like little sphere.
Thanks everybody!
Re: Points in 3D space.
Reply #1 - Mar 4th, 2009, 11:52am
 
does changing the strokeWeight help?

http://processing.org/reference/strokeWeight_.html
Re: Points in 3D space.
Reply #2 - Mar 4th, 2009, 11:53am
 
koogy wrote on Mar 4th, 2009, 11:52am:
does changing the strokeWeight help

http://processing.org/reference/strokeWeight_.html


ellipse() might also be acceptable as a substitute (but might disappear if seen edge-on)

[oops, meant to hit 'modify' rather than 'quote'. too late now.]
Re: Points in 3D space.
Reply #3 - Mar 4th, 2009, 2:53pm
 
I have exactly the same problem, although even a bit worse: I do not see any points, when using

{ point(x,y,z) }

while I do see spheres, when I use

{ translate(x,y,z) and sphere(r) }

And indeed my program becomes a lot slower when using spheres...
Anybody got an idea what causes this and indeed how to solve it?

p.s. ellipse() is no option for me, exactly for the reason given by koogs (about disappearing when seeing it edge on, and I really use my program 3D, so really need to see the point/sphere always)
Re: Points in 3D space.
Reply #4 - Mar 4th, 2009, 3:13pm
 
In your situation your points may have the same colour with background, and therefore you do not see them, do you?
Re: Points in 3D space.
Reply #5 - Mar 4th, 2009, 3:17pm
 
I'm also wondering how best to deal with spheres in 3d space for best performance.  

One option is to use sphereDetail() and set it to below 30 (perhaps 15 or 20).  

I've also seem some impressive things with numerous Vertexs (not sure if they could be used).

However, I'm wondering... depending on what your doing (it would work for me) if an ellipse can be "locked" so that it never shows an edge.  Zoom in and out, rotate it around a center, and it always gives you the same face (similar to presenting text to the camera so that it never flips upside-down or backwards).  I don't really need a sphere, I need the illusion of a sphere, which an ellipse might be able to do if we could prevent the edge from showing when tilted.  This would also be better for applying textures to the object.

Thoughts?
Re: Points in 3D space.
Reply #6 - Mar 4th, 2009, 3:49pm
 
jeffg wrote on Mar 4th, 2009, 3:17pm:
I'm also wondering how best to deal with spheres in 3d space for best performance.  

One option is to use sphereDetail() and set it to below 30 (perhaps 15 or 20).  

I've also seem some impressive things with numerous Vertexs (not sure if they could be used).

However, I'm wondering... depending on what your doing (it would work for me) if an ellipse can be "locked" so that it never shows an edge.  Zoom in and out, rotate it around a center, and it always gives you the same face (similar to presenting text to the camera so that it never flips upside-down or backwards).  I don't really need a sphere, I need the illusion of a sphere, which an ellipse might be able to do if we could prevent the edge from showing when tilted.  This would also be better for applying textures to the object.

Thoughts


Ah, the sphereDetail() hint is a good one! Thanks.

Your idea sounds good as well, although it will cause your application to even take more steps, so that might slow it down again.
Though how to exactly script it, is at this stage too time-consuming for me, since I have my thesis deadline soon, so I need all my time for that now... sorry
Re: Points in 3D space.
Reply #7 - Mar 4th, 2009, 7:55pm
 
Yes, sphereDetail(); is what I actually wanted. Thank you, jeffg!
Re: Points in 3D space.
Reply #8 - Mar 5th, 2009, 9:44pm
 
If you're using OpenGL, you may want to also consider.

   hint(DISABLE_OPENGL_ERROR_REPORT);

I found it gave a noticeable performance boost.

Speeds up the OPENGL renderer setting by not checking for errors while running. Undo with hint(ENABLE_OPENGL_ERROR_REPORT).
Re: Points in 3D space.
Reply #9 - Mar 10th, 2009, 11:02am
 
TVS wrote on Mar 4th, 2009, 2:53pm:
p.s. ellipse() is no option for me, exactly for the reason given by koogs (about disappearing when seeing it edge on, and I really use my program 3D, so really need to see the point/sphere always)


I also had the same problem a short time ago and solved it the following way:

1.
After using pushMatrix() I did all the 3d transformations and used screenX() and screenY() to store the screen position of the points in an Array:
Code:
PVector[] screenPoints = new PVector[pointCount];
for (int i = 0; i <= pointCount; i++) {
screenPoints[i] = new PVector(screenX(p[i].x, p[i].y, p[i].z), screenY(p[i].x, p[i].y, p[i].z));
}

     
2.
Reset the transformation matrix:
Code:
popMatrix();


3.
Draw the ellipses:
Code:
for (int i = 0; i < screenPoints.size(); i++) {
PVector sp = (PVector) screenPoints.get(i);
ellipse(sp.x, sp.y, 4, 4);
}


Of course, you don't get smaller ellipses for points that are further away, but that was ok for me.
Re: Points in 3D space.
Reply #10 - Mar 10th, 2009, 2:27pm
 
Jonathan Feinberg released a new version of PeasyCam (http://mrfeinberg.com/peasycam/) that offers a camera.getRotations() call.  Using this, I was also able to use ellipses that always face the camera, instead of spheres.  My frame rate went from 25 to 55.  Very cool library.

Code:

float[] rotations = new float[3];
...
pushMatrix();
translate(x, y, z);
rotations = cam.getRotations();
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
ellipse(0,0,20,20);
popMatrix();
Page Index Toggle Pages: 1