0
\$\begingroup\$

All,

I am trying to pick object using ray collision and bullet physics

I am initializing my projection and view matrix only once, here is the code

projectionMatrix = glm::perspective(90.0f, 4.0f / 3.0f, 0.1f, 100.0f);

float horizontalAngle = 3.14f;
float verticalAngle =0.0f;/// problems here 

glm::vec3 direction(
    cos(verticalAngle) * sin(horizontalAngle), 
    sin(verticalAngle),
    cos(verticalAngle) * cos(horizontalAngle)
);

glm::vec3 position = glm::vec3( 0.0, 10.0, 32.0 ); 

glm::vec3 right = glm::vec3(
    sin(horizontalAngle - 3.14f/2.0 ), 
    0,
    cos(horizontalAngle - 3.14f/2.0 )
);

// Up vector
glm::vec3 up = glm::cross( right, direction );

viewMatrix =  glm::lookAt(
                            position,           // Camera is here
                            position+direction, // and looks here : at the same position, plus "direction"
                            up                  // Head is up (set to 0,-1,0 to look upside-down)
                       );

See below screenshot with actual object in the world enter image description here

when I click on red area - it does not pick up object, but when i am click on green one - it does.

SMALL DETAIL: I've used this tutorial http://www.opengl-tutorial.org/miscellaneous/clicking-on-objects/picking-with-a-physics-library. While I've applying constant change to view and projection matrix throug my mouse move and keys - detection work perfect, but once I've stooping doing it - it does not work.

Can someone help me out what I am doing wrong ?

\$\endgroup\$
3
  • \$\begingroup\$ guys - can someone at least point me what might be wrong here. It is significant showstopper for me at the moment \$\endgroup\$
    – mgs_bravo
    Jun 9, 2015 at 19:58
  • \$\begingroup\$ it was about NDC conversion on Y axis. this should be properly calculated. \$\endgroup\$
    – mgs_bravo
    Jun 13, 2015 at 19:00
  • \$\begingroup\$ this can be closed \$\endgroup\$
    – mgs_bravo
    Jun 13, 2015 at 19:11

1 Answer 1

-1
\$\begingroup\$

it was about NDC conversion on Y axis. this should be properly calculated. I have to reflect it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .