PDA

View Full Version : Best trick to keep a sphere of the same size



devdept
05-20-2008, 03:09 PM
Hi All,

What is the best trick to keep a sphere diameter always of 100 pixel on screen during scene zoom/rotate operations?

Thanks in advance,

Alberto

Relic
05-21-2008, 01:54 AM
Don't make it part of the transform hierarchy you zoom and rotate but put it under its own independent transform which renders in screenspace?

devdept
05-21-2008, 05:29 AM
Mmmm... I don't think this would work as I want.

I am trying instead of projecting two screen points like 0,0 and 0,100 and get the 3D world distance. This way I can change the sphere size every frame.

What do you think?

Thanks.

Alberto

thinks
05-21-2008, 06:58 AM
Doing it in screen-space might not be good if the spheres are lit, and the lighting changes a lot. Also, if there are overlapping objects both in front of and behind the sphere, it might be tricky to get the occlusion right.

Instead, one might consider projecting the radius of the sphere as a line into screen-space, and modifying according to the current projection. This may not always give the exact same radius measured in pixels, but it will probably be close.

Relic
05-21-2008, 01:55 PM
Mmmm... I don't think this would work as I want.

I am trying instead of projecting two screen points like 0,0 and 0,100 and get the 3D world distance. This way I can change the sphere size every frame.

What do you think?

Thanks.

Alberto

I think you should explain what the sphere is used for and how it should look like.
The next trivial thing would be to use an own viewport and projection for that sphere, but you didn't say what it is meant for.
Is it inside the scene, is it moving around, lit, shaded textured, depth buffered, whatever...?
I was thinking "manipulator icon".

devdept
05-22-2008, 12:34 AM
Yes, it is a manipulator icon, I am quaite satisfied about the solution exaplined in my last post and probably is fast as defining its own viewport and projection.

Thanks.

Alberto