# J3D: How to get VW coordinates from mouse?

Kevin Jaffe

Greenhorn

Posts: 15

posted 15 years ago

hi!

how do i map a mouse motion to the virtual coordinate space?

i have tried to use getPixelLocationInImagePlate, but i get

the results that seem wrong to me, although this may be

because i am confused about things such as "image plate",

"center eye", "screen"...

i set the ViewPlatform transform to:

1.0, 0.0, 0.0, 0.0

0.0, 1.0, 0.0, 0.0

0.0, 0.0, 1.0, 1.0

0.0, 0.0, 0.0, 1.0

(i.e. put the image plate at z=1.0), and I make a Box with dimensions (0.1, 0.1, 2.0). my understanding was that this

would put the corners of the box that are at z=1.0 right at

the image plate, and therefore that if i clicked at, say, the upper righthand corner with the mouse and converted to virtual world coordinates, i should recover (using getPixelLocationInImagePlate and getImagePlateToVworld) i would recover (0.5, 0.5, 1.), but i don't. i get

(0.5546875, 0.5234375, -1.4142135623730954)

the z-coordinate is not a worry (getPixelLocationInImagePlate always returns a z-coordinate of 0. for some reason). but i can't figure out why the x and y coordinates are not both much closer to 0.5.

strangely, the transform returned by getImagePlateToVworld() is

27.68208661417323, 0.0, 0.0, -6.4140625

0.0, 27.68208661417323, 0.0, -5.210937500000001

0.0, 0.0, 27.68208661417323, -1.4142135623730954

0.0, 0.0, 0.0, 1.0

which makes no sense to me; i expected the m23

component to be 0.0 instead of -1.414... besides

there is no reason for this factor of sqrt(2) to

crop up, since i set the image plate to z=1.0, not

to the "nominal" z of 1+sqrt(2).

the only think that is clear is that i am thoroughly

confused!

any help would be greatly appreciated!

thanks!

kj

how do i map a mouse motion to the virtual coordinate space?

i have tried to use getPixelLocationInImagePlate, but i get

the results that seem wrong to me, although this may be

because i am confused about things such as "image plate",

"center eye", "screen"...

i set the ViewPlatform transform to:

1.0, 0.0, 0.0, 0.0

0.0, 1.0, 0.0, 0.0

0.0, 0.0, 1.0, 1.0

0.0, 0.0, 0.0, 1.0

(i.e. put the image plate at z=1.0), and I make a Box with dimensions (0.1, 0.1, 2.0). my understanding was that this

would put the corners of the box that are at z=1.0 right at

the image plate, and therefore that if i clicked at, say, the upper righthand corner with the mouse and converted to virtual world coordinates, i should recover (using getPixelLocationInImagePlate and getImagePlateToVworld) i would recover (0.5, 0.5, 1.), but i don't. i get

(0.5546875, 0.5234375, -1.4142135623730954)

the z-coordinate is not a worry (getPixelLocationInImagePlate always returns a z-coordinate of 0. for some reason). but i can't figure out why the x and y coordinates are not both much closer to 0.5.

strangely, the transform returned by getImagePlateToVworld() is

27.68208661417323, 0.0, 0.0, -6.4140625

0.0, 27.68208661417323, 0.0, -5.210937500000001

0.0, 0.0, 27.68208661417323, -1.4142135623730954

0.0, 0.0, 0.0, 1.0

which makes no sense to me; i expected the m23

component to be 0.0 instead of -1.414... besides

there is no reason for this factor of sqrt(2) to

crop up, since i set the image plate to z=1.0, not

to the "nominal" z of 1+sqrt(2).

the only think that is clear is that i am thoroughly

confused!

any help would be greatly appreciated!

thanks!

kj

John M. Gabriele

Ranch Hand

Posts: 232