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

  • SEARCH
  • Home
  • 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 6902743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:50:10+00:00 2026-05-27T07:50:10+00:00

I know there is a lot of stuff even on stackoverflow about this theme/problem

  • 0

I know there is a lot of stuff even on stackoverflow about this theme/problem but i really cant get it. Im in this problem for several hours now.

public Vector select(float x, float y) 
{

int viewport[] = { 0, 0, width , height};

float realY = ((float) ( height) - y);
float near[] = { 0.0f, 0.0f, 0.0f, 0.0f };
float far[] = { 0.0f, 0.0f, 0.0f, 0.0f };

GLU.gluUnProject(x, realY, 0, mg.mModelView, 0, mg.mProjection , 0, viewport, 0, near, 0);
GLU.gluUnProject(x, realY, 1, mg.mModelView, 0, mg.mProjection, 0, viewport, 0, far, 0);

float xr = near[0] / near[3];
float yr = near[1] / near[3];
float zr = near[2] / near[3];

return new Vector(xr,yr,zr);
}

/**
GLU.gluLookAt( gl, me.position.x, me.position.y, me.position.z, me.position.x, 0, me.position.z+1, 0, 1, 0 );
**/

1) Is there a possibility yet to read the z buffer with

    glReadPixels(winX, winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, winZ);

The GL11Extension class implements the GL_DEPTH_COMPONENT constant for glReadPixels or what?
http://developer.android.com/reference/javax/microedition/khronos/opengles/GL11ExtensionPack.html#GL_DEPTH_COMPONENT

2) Or is it possible to calculate the z-Buffer manuel with my glulookat positions ?

3) Or how to calculate the collision with the near and far position.

Thank you for reading 🙂

  • 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-27T07:50:10+00:00Added an answer on May 27, 2026 at 7:50 am

    The z part of unProject is the z position on the near clipping plane / the ‘front’ of the view frustum. If you know the eye position, you have two 3D points that you can make a ray/vector from.

    You then use the ray to calculate anything it passes through. In my own game, I translate the ray into my game’s own coordinate system and then re-use the collision detection algorithms I already have in place. (I.e. the “does the bullet intersect hitbox” code).

    If you don’t have collision detection, it is fairly simple to calculate the bounding box or bounding sphere of every model, which you only have to do once ever (so you can just add it as a property to your model files). You can then do a quick pass for every model to find which models the user picked, do a distance-from-camera test on the model locations to find which one is in the foreground, or take the poly’s from each model and calculate exactly which poly was picked

    Edit: I found a working example here: enter link description here. The explanation is in russian, but the code worked for me

    enter image description here

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

Sidebar

Related Questions

I know there's a lot of resource for this via google, but I just
I know this has been discussed a lot of times but is there any
I know there's a lot of stuff on TDD and i'm trying to pick
I know there are a lot of positive things mod-rewrite accomplishes. But are there
I know there is a lot of controversy (maybe not controversy, but arguments at
I know there is a lot of talk about BPM these days and I
I know there are a few hundred answers to questions like this on StackOverflow
There is a lot of conversation about commenting code, but how about commenting on
I know there are a lot of how do I avoid this warning questions,
Please let me know why there is lot of white space below the page

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.