OK, I'm with you now. Another way might be to just draw the images in
3d as I suggested, turn off depth testing (so the sprites draw over
the background), and scale the size by the inverse of Z to prevent
them shrinking. That would put more of the maths into QC rather than
JS/math patches, which could be faster (useful when you're doing lots
of points in an iterator).

Chris


2009/11/3 Sune Watts <[email protected]>:
> Hiya Chris
>
> Allright, I dug into the maths and seem to have solved it. I'll share it
> here, as I feel it is useful.
>
> QC file is attached this email.
>
> To project a 3d point onto space, use this formula and z-axis scale factor:
>
>
>     var scaleFactor = 0.58;
>     screenX = obX * (1 / ( 1 + (-obZ * scaleFactor) ));
>     screenY = obY * (1 / ( 1 + (-obZ * scaleFactor) ));
>
> ---
> I need it for a top layer of 2d overlays and pointers that do not scale, but
> accurately follow a moving 3d scene.
>
>
> All the best
> Sune Watts
> ---
>
>
> On Tue, Nov 3, 2009 at 1:34 PM, Chris Wood <[email protected]> wrote:
>>
>> If you really want to do it manually, you'll need to learn some maths.
>> You need to calculate the distance of a point on a sphere from the
>> camera (the camera position in QC is (0,0,-1) if I remember right) to
>> determine size and perspective transform.
>>
>> I don't understand why you need to convert though - if you have the
>> xyz position, why not just tell QC to draw your image at that xyz
>> position?
>>
>> You could also use the 3D transform patch perhaps?
>>
>> Chris
>>
>>
>> 2009/11/3 Sune Watts <[email protected]>:
>> > Sorry if I was unclear:
>> >
>> > How to translate an (x, y, z) point into (x, y) screen coordinates --
>> >
>> > For example, you have a rotating globe and want to know the screen
>> > coordinates of a certain city on the globe.
>> >
>> >
>> > Best regards
>> > Sune Watts
>> >
>> >
>> > ---
>> >
>> >
>> > On Tue, Nov 3, 2009 at 11:02 AM, Chris Wood <[email protected]> wrote:
>> >>
>> >> QC supports 3D space already. There's 2 ways to show a 2D image:
>> >> Billboard (this is best for overlays and the like, and is 2D based)
>> >> and Sprite (this is similar to billboard, but exists in full 3D space
>> >> so you can move it on Z, and rotate on all 3 axis.
>> >>
>> >> Most likely, sprite will cover your needs.
>> >>
>> >> Chris
>> >>
>> >>
>> >> 2009/11/3 Sune Watts <[email protected]>:
>> >> > Hello all;
>> >> >
>> >> > I need to pin a 2D billboard onto a (moving) point in 3D space.
>> >> >
>> >> > I haven't been able to find any info on the z-axis scaling QC
>> >> > employs.
>> >> >
>> >> > Has anybody got a handle on mathematically converting a point in 3D
>> >> > space to
>> >> > 2D screen space?
>> >> >
>> >> >
>> >> > All the best
>> >> > -SW
>> >> >
>> >> >  _______________________________________________
>> >> > Do not post admin requests to the list. They will be ignored.
>> >> > Quartzcomposer-dev mailing list
>> >> >  ([email protected])
>> >> > Help/Unsubscribe/Update your Subscription:
>> >> >
>> >> >
>> >> > http://lists.apple.com/mailman/options/quartzcomposer-dev/psonice%40gmail.com
>> >> >
>> >> > This email sent to [email protected]
>> >> >
>> >
>> >
>> >  _______________________________________________
>> > Do not post admin requests to the list. They will be ignored.
>> > Quartzcomposer-dev mailing list
>> >  ([email protected])
>> > Help/Unsubscribe/Update your Subscription:
>> >
>> > http://lists.apple.com/mailman/options/quartzcomposer-dev/psonice%40gmail.com
>> >
>> > This email sent to [email protected]
>> >
>
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Quartzcomposer-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/quartzcomposer-dev/psonice%40gmail.com
>
> This email sent to [email protected]
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to