Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6066867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:32:46+00:00 2026-05-23T09:32:46+00:00

I need some help on 3D picking. I am using the way it works

  • 0

I need some help on 3D picking.

I am using the way it works here. In short, what I have is:

normalizedPoint[0] = (x * 2 / screenW) -1;
normalizedPoint[1] = 1 - (y * 2 / screenH);
normalizedPoint[2] = ?
normalizedPoint[3] = ?

for 2 and 3, I have no idea what it should be (I put 1, -1 just like the reference, and it doesn’t work)

Then, for my root object (following just psuedo code):

matrix = perspective_matrix x model_matrix
inv_matrix = inverse(matrix)
outpoint = inv_matrix x normalizedPoint

That’s what I have, but it doesn’t work, the outPoint I receive is not even close to the point I am suppose clicking. I’ve been searching in web for more than a week. but no idea how to solve it. HELP!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:32:46+00:00Added an answer on May 23, 2026 at 9:32 am

    Oh. I actually solved the problem, sort of.

    I first, modify from the source code of glUnproject to have the following:

    public static Vec3 unProject(
            float winx, float winy, float winz,
            Matrix44 resultantMatrix,
            int width, int height){
        float[] m = new float[16],
        in = new float[4],
        out = new float[4];
    
        m = Matrix44.invert(resultantMatrix.get());
    
        in[0] = (winx / (float)width) * 2 - 1;
        in[1] = (winy / (float)height) * 2 - 1;
        in[2] = 2 * winz - 1;
        in[3] = 1;
    
        Matrix.multiplyMV(out, 0, m, 0, in, 0);
    
        if (out[3]==0)
            return null;
    
        out[3] = 1/out[3];
        return new Vec3(out[0] * out[3], out[1] * out[3], out[2] * out[3]);
    }
    

    Input to the above would be the point in the Projected View Frustum Coordinates (i.e., screen input). For example:

    unProject(30, 50, 0, mvpMatrix, 800, 480) 
    

    will translate the screen input (click) at (30,50) to the world coordinate where the object is sitting at. The third parameter, winz is actually on which projected plane the click is occured, here, 0 means the nearZ of the projection plane.

    The way I make picking functions, is by unprojecting two points, using the above function, on the far and near clipping plane, so:

    Vec3 near = unProject(30, 50, 0, mvpMatrix, 800, 480);
    Vec3 far = unProject(30, 50, 1, mvpMatrix, 800, 480);   // 1 for winz means projected on the far plane
    Vec3 pickingRay = Subtract(far, near); // Vector subtraction
    

    Once we have the picking ray, what I am doing is simply testing the distance between the picking ray and the “center” of those “pickable” objects. (of course, you can have some more sophisticated testing algorithm).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some your help. I have two datetimepickers on my form: dt1 and dt2.
Need some help. I have a table with some columns..like name , phone etc...
Need some help ! I have a ListActivity...on itch row i have 4 textVIew...
Need some help for creating a File and String search engine. The program needs
Need some help designing a bash script for grepping IP addresses from auth.log and
i need some help regarding adding values into an array for example long[] s
I need some help with a formatting function. I need to be able to
I am parsing some key value pairs that are separated by colons. The problem
I want to tackle some image-processing problems in Haskell. I'm working with both bitonal
I'm in the planning and learning stages of building a facebook game. For the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.