?? jogldrawingarea.java
字號:
if ( parent.imageControlWindow == null ) { parent.imageControlWindow = new SwingImageControlWindow(parent.zbufferImage, parent.gui, parent.executorPanel); } else { parent.imageControlWindow.setImage(parent.zbufferImage); } parent.imageControlWindow.redrawImage(); parent.statusMessage.setText("ZBuffer depth map obtained!"); wantToGetDepth = false; wantToGetContourns = false; } } public void toggleGrid() { views.get(selectedView).toggleGrid(); } private void drawView(GL gl, JoglView view) { if ( !view.isActive() ) { return; } if ( view.getRenderMode() == view.RENDER_MODE_ZBUFFER ) { JoglSceneRenderer.draw(gl, theScene, parent); } else { JoglSceneRenderer.drawBackground(gl, theScene); parent.raytracedImageWidth = view.getViewportSizeX(); parent.raytracedImageHeight = view.getViewportSizeY(); parent.doRaytracedImage(); gl.glMatrixMode(gl.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(gl.GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); JoglImageRenderer.draw(gl, parent.raytracedImage); gl.glPopMatrix(); gl.glMatrixMode(gl.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(gl.GL_MODELVIEW); } //----------------------------------------------------------------- //JoglRenderer.activateNvidiaGpuParameters(gl, view.getRendererConfiguration(), // JoglRenderer.getCurrentVertexShader(), // JoglRenderer.getCurrentPixelShader()); drawVisualRayDebug(gl); // Nice debugging for Camera.projectPoint operation :)/* gl.glPushAttrib(gl.GL_DEPTH_TEST); gl.glDisable(gl.GL_DEPTH_TEST); Vector3D projected = new Vector3D(); if ( view.getCamera().projectPoint( parent.visualDebugRay.origin, projected) ) { view.drawTextureString2D(gl, (int)projected.x-3, (int)projected.y+10, view.xLabelImage); } gl.glPopAttrib();*/ //JoglRenderer.deactivateNvidiaGpuParameters(gl, view.getRendererConfiguration()); view.drawGrid(gl); //----------------------------------------------------------------- // Note that gizmo information will not be reported, as they damage // the zbuffer... copyZBufferIfNeeded(gl); // Must be the last to draw drawGizmos(gl); copyColorBufferIfNeeded(gl); view.drawReferenceBase(gl); if ( translationGizmoDrawn ) { view.drawLabelsForTranslateGizmo(gl, translationGizmo); } } /** Called by drawable to initiate drawing */ public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); if ( firstTimer ) { firstTimer = false; JoglRenderer.createDefaultAutomaticNvidiaCgShaders(); } debugProjectedViewsIfNeeded(gl); JoglView view; int i; //----------------------------------------------------------------- gl.glClearColor(0.77f, 0.77f, 0.77f, 1.0f); gl.glClear(gl.GL_COLOR_BUFFER_BIT); gl.glViewport(0, 0, globalViewportXSize, globalViewportYSize); gl.glMatrixMode(gl.GL_PROJECTION); gl.glLoadIdentity(); gl.glMatrixMode(gl.GL_MODELVIEW); gl.glLoadIdentity(); for ( i = 0; i < views.size(); i++ ) { view = views.get(i); view.drawBorderGL(gl, globalViewportXSize, globalViewportYSize); } //----------------------------------------------------------------- for ( i = 0; i < views.size(); i++ ) { view = views.get(i); if ( !view.isActive() ) { continue; } // view.activateViewportGL(gl, globalViewportXSize, globalViewportYSize); if ( view.isSelected() ) { cameraController.setCamera(view.getCamera()); qualityController.setRendererConfiguration(view.getRendererConfiguration()); qualitySelection = view.getRendererConfiguration(); } theScene.activeCamera = view.getCamera(); // theScene.qualityTemplate = view.getRendererConfiguration(); drawView(gl, view); view.drawTitle(gl); } } private void drawVisualRayDebugSegment(GL gl, Vector3D start, Vector3D end, boolean follow, double w, double tip) { double l; Vector3D diff = end.substract(start); l = diff.length(); gl.glEnable(gl.GL_LIGHTING); JoglMaterialRenderer.activate(gl, visualDebugMaterial); //----------------------------------------------------------------- Geometry a; if ( l > tip ) { a = new Arrow(l - tip, tip, w/2, w); } else { a = new Cone(w/2, w/2, l); } Matrix4x4 R = new Matrix4x4(); double yaw, pitch; yaw = diff.obtainSphericalThetaAngle(); pitch = diff.obtainSphericalPhiAngle(); R.eulerAnglesRotation(Math.toRadians(180)+yaw, pitch, 0); gl.glPushMatrix(); gl.glTranslated(start.x, start.y, start.z); JoglMatrixRenderer.activate(gl, R); JoglGeometryRenderer.draw(gl, a, theScene.camera, qualitySelectionVisualDebug); gl.glPopMatrix(); //----------------------------------------------------------------- if ( follow ) { Sphere s = new Sphere(0.025); Vector3D p; double offset = 0.1; int i; diff.normalize(); for ( i = 0; i < 3; i++, offset += 0.1 ) { p = end.add(diff.multiply(offset)); gl.glPushMatrix(); gl.glTranslated(p.x, p.y, p.z); JoglGeometryRenderer.draw(gl, s, theScene.camera, qualitySelectionVisualDebug); gl.glPopMatrix(); } } } private void drawVisualRayDebug(GL gl, Ray ray, int level) { gl.glLoadIdentity(); if ( level < 0 ) return; //----------------------------------------------------------------- Vector3D p; Vector3D d = new Vector3D(ray.direction); d.normalize(); GeometryIntersectionInformation info; info = new GeometryIntersectionInformation(); //----------------------------------------------------------------- visualDebugMaterial.setDiffuse(new ColorRgb(0.9, 0.5, 0.0)); JoglMaterialRenderer.activate(gl, visualDebugMaterial); Sphere s = new Sphere(0.05); gl.glPushMatrix(); gl.glTranslated(ray.origin.x, ray.origin.y, ray.origin.z); JoglGeometryRenderer.draw(gl, s, theScene.camera, qualitySelectionVisualDebug); gl.glPopMatrix(); //----------------------------------------------------------------- if ( parent.theScene.doIntersection(ray, info) ) { d = d.multiply(ray.t); p = ray.origin.add(d); drawVisualRayDebugSegment(gl, ray.origin, p, false, 0.07, 0.4); if ( level >= 1 ) { // Draw normal visualDebugMaterial.setDiffuse(new ColorRgb(0.9, 0.9, 0.5)); drawVisualRayDebugSegment(gl, p, p.add(info.n.multiply(0.5)), false, 0.05, 0.2); } // Reflection ray Vector3D dd = ray.direction.multiply(-1); dd.normalize(); Vector3D h = info.n.multiply(dd.dotProduct(info.n)).substract(dd); Ray subray = new Ray(p, dd.add(h.multiply(2))); subray.origin = subray.origin.add(subray.direction.multiply(VSDK.EPSILON*10.0)); drawVisualRayDebug(gl, subray, level-1); } else { d = d.multiply(1.4); p = ray.origin.add(d); drawVisualRayDebugSegment(gl, ray.origin, p, true, 0.07, 0.4); } } private void drawVisualRayDebug(GL gl) { //----------------------------------------------------------------- if ( !parent.withVisualDebugRay ) { return; } //----------------------------------------------------------------- gl.glEnable(gl.GL_LIGHTING); drawVisualRayDebug(gl, parent.visualDebugRay, parent.visualDebugRayLevels); //----------------------------------------------------------------- } /** Not used method, but needed to instanciate GLEventListener */ public void init(GLAutoDrawable drawable) { ; } /** Not used method, but needed to instanciate GLEventListener */ public void displayChanged(GLAutoDrawable drawable, boolean a, boolean b) { ; } /** Called to indicate the drawing surface has been moved and/or resized */ public void reshape (GLAutoDrawable drawable, int x, int y, int width, int height) { this.globalViewportXSize = width; this.globalViewportYSize = height; int i; for ( i = 0; i < views.size(); i++ ) { views.get(i).updateViewportConfiguration(globalViewportXSize, globalViewportYSize); } } public void mouseEntered(MouseEvent e) { canvas.requestFocusInWindow(); // WARNING / TODO // There should be a cameraController.getFutureAction(e) that calculates // the proper icon for display ... here an Aquynza operation is // assumed and hard-coded if ( interactionMode == CAMERA_INTERACTION_MODE ) { canvas.setCursor(camrotateCursor); } else { canvas.setCursor(selectCursor); } } public void mouseExited(MouseEvent e) { //System.out.println("Mouse exited"); } private JoglView getSelectedView(MouseEvent e, boolean changeSelection) { JoglView view = null; JoglView theView = null; //----------------------------------------------------------------- int i; double xpercent; double ypercent; xpercent = ((double)e.getX()) / ((double)globalViewportXSize); ypercent = 1-((double)e.getY()) / ((double)globalViewportYSize); for ( i = 0; i < views.size(); i++ ) { view = views.get(i); if ( view.isActive() && view.inside(xpercent, ypercent) ) { if ( changeSelection ) { view.setSelected(true); selectedView = i; } theView = view; } else { if ( changeSelection ) { view.setSelected(false); } } } return theView; } public void mousePressed(MouseEvent e) { JoglView view = getSelectedView(e, true); JoglView mouseView = getSelectedView(e, false); //----------------------------------------------------------------- // WARNING / TODO // There should be a cameraController.getFutureAction(e) that calculates // the proper icon for display ... here an Aquynza operation is // assumed and hard-coded int m = e.getModifiersEx(); if ( interactionMode == CAMERA_INTERACTION_MODE &&
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -