boop
boop

Reputation: 7788

How to convert mouse coordinates into world coordinates

What I want to do

Picking an object.

Requirements / Conditions

What I want to know

How can I convert my mouse coordinates (actually 0,0 since the mouse is locked to the mid) to world coordinates?

How do I get the actual view direction?

What I think I have to do

pseudo code

int mx,my = convert(Mouse.getX()), convert(Mouse.getY())
int mz = ??
int dx, dy, dz = ?? # direction of view
drawRay(mx, my, mz, 
        dx, dy, dz + 10) # 10 shall be the range to pick

# later check for intersections

Upvotes: 1

Views: 246

Answers (0)

Related Questions