Bonjour a tous ..
Je suis en train de réaliser un petit programme openGL en JAVA avec JOGL.
ET ca fait malheureusement 4 jour non-stop que je m'acharne a essayer de faire marcher mon picking sur un simple carré.. en vain .... mes object ne se redessine plus apres..
je fais appel a vous dans le plus grand desespoir d'un homme tomber au fond du grouffre ....
voici ma classe contenant mon panneau :
voici ma classe (sensé réaliser le picking) :
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 public class JavaRenderer extends picking implements GLEventListener { public void display(GLAutoDrawable gLDrawable) { GL gl = gLDrawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -4.0f); if (pickPoint != null) { pickRects(gl); } dessinerRectangle(gl, GL.GL_RENDER); gl.glFlush(); if (pickPoint != null) pickPoint=null; } public void displayChanged(GLAutoDrawable gLDrawable, boolean modeChanged, boolean deviceChanged) { } public void init(GLAutoDrawable gLDrawable) { gLDrawable.addKeyListener(new ControlClavier()); gLDrawable.addMouseListener(new ControlClickSouris(this)); } public void reshape(GLAutoDrawable gLDrawable, int x, int y, int width, int height) { GL gl = gLDrawable.getGL(); if (height <= 0) // avoid a divide by zero error! height = 1; final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(60.0f, h, 0.0, 10.0); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); } }
voila... je suis adepte de tout forme de réponse... meme quelqu'un dans le meme desespoir que moi me remonterais le moral ....
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 public class picking { public Point pickPoint; protected GLU glu = new GLU(); private static final int BUFSIZE = 512; private void processHits(int hits, int buffer[]) { int names, ptr = 0; System.out.println("hits = " + hits); // ptr = (GLuint *) buffer; for (int i = 0; i < hits; i++) { /* for each hit */ names = buffer[ptr]; System.out.println(" number of names for hit = " + names); ptr++; System.out.println(" z1 is " + buffer[ptr]); ptr++; System.out.println(" z2 is " + buffer[ptr]); ptr++; System.out.print("\n the name is "); for (int j = 0; j < names; j++) { /* for each name */ System.out.println("" + buffer[ptr]); ptr++; } System.out.println(); } } protected void pickRects(GL gl) { int[] selectBuf = new int[BUFSIZE]; IntBuffer selectBuffer = BufferUtil.newIntBuffer(BUFSIZE); int hits; int viewport[] = new int[4]; gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); gl.glSelectBuffer(BUFSIZE, selectBuffer); gl.glRenderMode(GL.GL_SELECT); gl.glInitNames(); gl.glPushName(0); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); //create 5x5 pixel picking region near cursor location glu.gluPickMatrix((double) pickPoint.x, (double) (viewport[3] - pickPoint.y), // 5.0, 5.0, viewport, 0); glu.gluPerspective(45.0f, (viewport[2]-viewport[0])/viewport[3]-viewport[1], 0.1f, 4000.0f); gl.glMatrixMode(GL.GL_MODELVIEW); dessinerRectangle(gl, GL.GL_SELECT); gl.glPopMatrix(); gl.glFlush(); hits = gl.glRenderMode(GL.GL_RENDER); selectBuffer.get(selectBuf); processHits(hits, selectBuf); } protected void dessinerRectangle(GL gl, int mode) { if (mode == GL.GL_SELECT) gl.glPushName(1); formesOpenGL.creerRectangle(gl, .2f, .3f); } }
Merci d'avance !!!
Partager