The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by yin]

Suppose there is a local coordinate system in a
virtual universe. If I click mouse on a pane of virtual universe,
then I get a x, y coordinates for this virtual universe pane.
How to convert this virtual universe x, y cooordinates
to a local coordinates? How to program this? Or any ready API to use?

Thanks.

Zhangshi Yin
import-bot (20211) [Avatar] Offline
#2
Re: Coordinates conversion
[Originally posted by author]

I assume when you say a "virtual universe pane" you mean a Canvas3D displaying
a view of the universe. The technique for moving or clicking the mouse in the
display and determining the 3D object and world position underneath the mouse
cursor is called "picking".

Take a look at section 13.2 in the book for a discussion of the java 3d
picking model. Essentially, you throw a ray from the display eye position in
the world through the mouse position in the display plane. Typically, the
first object the ray intersects in the world is the picked object. You can
determine the world coordinate of the hit point using vector arithmetic and
the distance between the eye and the hit point, which is provided by the java
3d picking classes.

Take a look at chapter 19 for how I approached picking in the book. The
framework defines a PickEngine and an ObjectPickMapper class to provide basic
pick functionality. Try the OverEnabling example and look at the source code
to see how to use these classes.

Sun also provides utilities that support picking, but I am not very familiar
with them. Check out the www.j3d.org faq for info about how to use them.

good luck
--jon

> Suppose there is a local coordinate system in a
> virtual universe. If I click mouse on a pane of virtual universe,
> then I get a x, y coordinates for this virtual universe pane.
> How to convert this virtual universe x, y cooordinates
> to a local coordinates? How to program this? Or any ready API to use?
>
> Thanks.
>
> Zhangshi Yin