Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Collision Detection using View Matrix of two objects.

  1. #1
    Newbie Newbie
    Join Date
    Dec 2015
    Posts
    3

    Collision Detection using View Matrix of two objects.

    Hello,

    Given two glViewMatrices for two different objects, is it possible to detect a collision or distance between their centers?

    I am using OpenCV's solvepnp to get the OpenGL view matrix from the tvec and rvec with a calibrated camera. I now want to know if these two independantly tracked objects can be located relative to one another.

    The viewMatrix created from the results of OpenCV's solvePnp method, and is transposed into the OpenGL co-ordinate system (shown below).

    Code :
    cv::Mat glViewMatrix1 = cv::Mat::zeros(4, 4, CV_64F);
    cv::transpose(viewMatrix , glViewMatrix1);
    glMatrixMode(GL_MODELVIEW);
    glLoadMatrixd(&glViewMatrix1.at<double>(0, 0));

    Is it possible to get the distance between the center of two models using the viewMatrix?

    The vertices of the hoop are a unit circle (z is 0, centered at (0,0,0)).

    The vertices of the ball are a unit sphere (centered at (0,0,0)).

    Regards,

    Daniel
    Last edited by MrCybin; 12-07-2015 at 03:39 AM. Reason: Spacing.

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2015
    Posts
    14
    Quote Originally Posted by MrCybin View Post

    Is it possible to get the distance between the center of two models using the viewMatrix?

    Daniel
    Isn't the view matrix supposed to represent the camera position and orientation? Also the view matrix would be the same for both objects. I think you should be using the a model matrix.

    In which case, the position of an object is the 4th column of the model matrix.

    1 0 0 x
    0 1 0 y
    0 0 1 z
    0 0 0 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •