Bonjour,
Je voudrais faire le picking objet opengl selon le curseur de la souris.

J'ai trouver un exemple qui ne fonctionne pas du tout et je conseille au developper d'aller ailleurs.

Code qui fonctionne mal !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
// Compute O and D in object coordinates
glm::vec4 origin = mvp_inverse * glm::vec4(
        (x-half_width)/half_width, (half_height-y)/half_height, -1, 1);
glm::vec4 dir = mvp_inverse * glm::vec4(0, 0, 1, 0);
O = glm::vec3(origin.x, origin.y, origin.z);
D = glm::normalize(glm::vec3(dir.x, dir.y, dir.z));
// Iterate through the figures in the model
tmin = 1000.0;
for(i=0; i<num_objects; i++) {
   data_array = (float*)geom_vec[i].map["POSITION"].data;
   // Iterate through the triangles in the figure
   for(j=0; j<geom_vec[i].index_count; j+=3) {
      index = geom_vec[i].indices[j]*3;
      // Read the first point of Triangle KLM
      K = glm::vec3(data_array[index],
                    data_array[index+1],
                    data_array[index+2]);
      // Read the second point of Triangle KLM
      index = geom_vec[i].indices[j+1]*3;
      L = glm::vec3(data_array[index],
                    data_array[index+1],
                    data_array[index+2]);
      // Read the third point of Triangle KLM
      index = geom_vec[i].indices[j+2]*3;
      M = glm::vec3(data_array[index],
                    data_array[index+1],
                    data_array[index+2]);
      // Compute vectors E, F, and G
      E = K - M;
      F = L - M;
      G = O - M;
      // Compute the vector containing t and the coordinates k and l
      tkl = 1/glm::dot(glm::cross(D, F), E) *
               glm::vec3(glm::dot(glm::cross(G, E), F),
                         glm::dot(glm::cross(D, F), G),
                         glm::dot(glm::cross(G, E), D));
      // Check if t and the intersection point (k, l) are acceptable
      if(tkl.x < tmin[i] && tkl.y > 0.0f && tkl.z > 0.0f && (tkl.y + tkl.z) < 1) {
         tmin = tkl.x;
         sphere = i;
      }
   }
}
trouver sur le site 'https://www.codeproject.com/articles...ngl-and-opencl'

D'ailleur 'mvp_inverse' c'est l'inverse de la matrice 'mvp' !
Mais c'est quoi 'mvp' ??? matrice générale ? matrice model ?? on ne sait pas !
Il y a un bug 'tmin[i]' ce n'est pas bon ! il s'agit d'un entier et non d'un tableau !

glm : version 0.95
info : glm v0.95 admet des degrés,mais le code source ne parle pas d'angle donc pas besoin de mettre à jour.

Ou trouver un code source qui marche permettant détecte la collision de primitives ?

J'en avais déjà écrit un , il bug mais fonctionne bien mieux !

Je vais continuer à bien vérifier mais à mon avis ... , je ne vais pas perdre trop de temps.

Merci