PDA

View Full Version : 3D Constant size quads



Ffelagund
09-01-2008, 12:41 AM
Hello,

I need to draw some quads (or triangles, it doesnt matter) in a 3D space. Those quads lies over a big quads (a base plane), and that base can be rotated and zoomed. I need that those primitives have always the same viewing size, regardless the zoom or the fov.
I cant use point sprites because point sprites clips the plane where they will lay.
I can do it projecting primitive's vertices on the screen, and computing the needed transformation to change its size, but its a complex process, and computationally very expensive (I have a lot of primitives to draw) I'm sure that should be any other math method for achieve this but I dont know it.

Anyone can help me with this?

Thanks,
Jacobo.

ZbuffeR
09-01-2008, 02:59 AM
And what about clearing the depth buffer right after drawing the plane, before drawing the sprites ?

Ffelagund
09-01-2008, 03:58 AM
I cant clear the zbuffer because I have multiple planes, up to 40 in the 3d space, but Yooyo (from this forum and a good friend of mine) told me the solution just few minutes ago:

Having the quads centers and theirs axis, this 'formulae' gives us an scale that is dependent of camera distance and fov:


Vector3 markerCenter(0.5f, 0.5f, 0.0f);

float rfov = camera.GetFov() * (float)M_PI / 180.0f;
float t = tan(rfov / 2.0f);
float size = 2.0f * (camera.GetCameraPos() - markerCenter).Magnitude() * t;
With that, if you scale your own scale by 'size' to have a good visual size, it will remain constant no matter the camera distance neither the camera zoom.

Thanks Yooyo