⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jogldrawingarea.java

📁 基于java的3d开发库。对坐java3d的朋友有很大的帮助。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    composed = translationGizmo.getTransformationMatrix();                    position.x = composed.M[0][3];                    position.y = composed.M[1][3];                    position.z = composed.M[2][3];                    composed.M[0][3] = 0;                    composed.M[1][3] = 0;                    composed.M[2][3] = 0;                    applyTranslationToSelectedObjects(position);                }            }        }        else if ( interactionMode == ROTATE_INTERACTION_MODE ) {            if ( firstThingSelected >= 0 ) {                SimpleBody gi;                gi = theScene.scene.getSimpleBodies().get(firstThingSelected);                Matrix4x4 R = gi.getRotation();                rotateGizmo.setTransformationMatrix(R);                if ( rotateGizmo.processKeyPressedEventAwt(e) ) {                    R = rotateGizmo.getTransformationMatrix();                    gi.setRotation(R);                    Matrix4x4 Ri = new Matrix4x4(R);                    Ri.invert();                    gi.setRotationInverse(Ri);                }            }        }        else if ( interactionMode == SCALE_INTERACTION_MODE ) {            if ( firstThingSelected >= 0 ) {                SimpleBody gi;                gi = theScene.scene.getSimpleBodies().get(firstThingSelected);                Vector3D s = gi.getScale();                Matrix4x4 S = new Matrix4x4();                S.M[0][0] = s.x;                S.M[1][1] = s.y;                S.M[2][2] = s.z;                scaleGizmo.setTransformationMatrix(S);                if ( scaleGizmo.processKeyPressedEventAwt(e) ) {                    S = scaleGizmo.getTransformationMatrix();                    s = new Vector3D(S.M[0][0], S.M[1][1], S.M[2][2]);                    gi.setScale(s);                }            }        }        // Global commands        int asp;        switch ( keycode ) {          case KeyEvent.VK_ESCAPE:              parent.closeApplication();            break;          case KeyEvent.VK_EQUALS:            // Alphanumeric =            asp = translationGizmo.getAparentSizeInPixels();            asp += 10;            if ( asp > 300 ) asp = 300;            translationGizmo.setAparentSizeInPixels(asp);            break;          case KeyEvent.VK_MINUS:            // Alphanumeric -            asp = translationGizmo.getAparentSizeInPixels();            asp -= 20;            if ( asp < 20 ) asp = 20;            translationGizmo.setAparentSizeInPixels(asp);            break;        }        if ( qualityController.processKeyPressedEventAwt(e) ) {            System.out.println(qualitySelection);        }        if ( keycode == KeyEvent.VK_DELETE ) {            int  i;            //-----------------------------------------------------------------            for ( i = theScene.scene.getSimpleBodies().size()-1; i >= 0; i-- ) {                if ( theScene.selectedThings.isSelected(i) ) {                    theScene.scene.getSimpleBodies().remove(i);                }            }            theScene.selectedThings.sync();            //-----------------------------------------------------------------            for ( i = theScene.debugThingGroups.size()-1; i >= 0; i-- ) {                if ( theScene.selectedDebugThingGroups.isSelected(i) ) {                    theScene.debugThingGroups.remove(i);                }            }            theScene.selectedThings.sync();            //-----------------------------------------------------------------        }        if ( keycode == KeyEvent.VK_F10 ) {            parent.statusMessage.setText(                parent.gui.getMessage("IDM_COMPUTING_RAYTRACING"));            parent.doRaytracedImage();              if ( parent.imageControlWindow == null ) {                parent.imageControlWindow = new SwingImageControlWindow(parent.raytracedImage, parent.gui, parent.executorPanel);            }            else {                parent.imageControlWindow.setImage(parent.raytracedImage);            }            parent.imageControlWindow.redrawImage();        }        // In view command propagation        if ( !skipKey ) {            views.get(selectedView).keyPressed(e);        }        double theta = 0;        double phi = Math.PI/2;        if ( unicode_id != e.CHAR_UNDEFINED && !skipKey ) {            switch ( unicode_id ) {                //- Multiple views control -----------------------------------              case '.':                selectedView++;                if ( selectedView >= views.size() ) {                    selectedView = 0;                }                selectedView = viewOrganizer.doLayout(views, fullViewport?selectedView:-1, viewOrderStyle);                break;              case ',':                viewOrderStyle++;                selectedView = viewOrganizer.doLayout(views, fullViewport?selectedView:-1, viewOrderStyle);                break;                //- Visual debug ray control ---------------------------------              case '4': // Numpad 4                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.x -= 0.1;                }                break;              case '6': // Numpad 6                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.x += 0.1;                }                break;              case '8': // Numpad 8                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.y += 0.1;                }                break;              case '2': // Numpad 2                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.y -= 0.1;                }                break;              case '1': // Numpad 1                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.z -= 0.1;                }                break;              case '7': // Numpad 7                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRay.origin.z += 0.1;                }                break;              case '9': // Numpad 9                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRayLevels++;                }                break;              case '3': // Numpad 3                if ( parent.withVisualDebugRay ) {                    parent.visualDebugRayLevels--;                    if ( parent.visualDebugRayLevels < 0 ) {                        parent.visualDebugRayLevels = 0;                    }                }                break;              case '5': // Numpad 5                if ( parent.withVisualDebugRay ) {                    parent.withVisualDebugRay = false;                }                else {                    parent.withVisualDebugRay = true;                }                break;              case '*': // Numpad *                if ( parent.withVisualDebugRay ) {                    theta =                        parent.visualDebugRay.direction.obtainSphericalThetaAngle();                    phi =                        parent.visualDebugRay.direction.obtainSphericalPhiAngle();                    theta -= Math.toRadians(5);                    parent.visualDebugRay.direction.setSphericalCoordinates(                        1, theta, phi);                }                break;              case '/': // Numpad /                if ( parent.withVisualDebugRay ) {                    theta =                        parent.visualDebugRay.direction.obtainSphericalThetaAngle();                    phi =                        parent.visualDebugRay.direction.obtainSphericalPhiAngle();                    theta += Math.toRadians(5);                    parent.visualDebugRay.direction.setSphericalCoordinates(                        1, theta, phi);                }                break;              case '+': // Numpad +                if ( parent.withVisualDebugRay ) {                    theta =                        parent.visualDebugRay.direction.obtainSphericalThetaAngle();                    phi =                        parent.visualDebugRay.direction.obtainSphericalPhiAngle();                    phi += Math.toRadians(5);                    if ( phi > Math.PI ) phi = Math.PI;                    parent.visualDebugRay.direction.setSphericalCoordinates(                        1, theta, phi);                }                break;              case '-': // Numpad -                if ( parent.withVisualDebugRay ) {                    theta =                        parent.visualDebugRay.direction.obtainSphericalThetaAngle();                    phi =                        parent.visualDebugRay.direction.obtainSphericalPhiAngle();                    phi -= Math.toRadians(5);                    if ( phi < 0 ) phi = 0;                    parent.visualDebugRay.direction.setSphericalCoordinates(                        1, theta, phi);                }                break;                //------------------------------------------------------------              case 'T':                if ( firstThingSelected >= 0 ) {                    SimpleBody gi;                    Image texture;                    gi = theScene.scene.getSimpleBodies().get(firstThingSelected);                    texture = gi.getTexture();                    if ( texture == null ) {                        String imageFilename = "../../../etc/textures/miniearth.png";                        try {                            texture =                                 ImagePersistence.importRGB(new File(imageFilename));                        }                        catch ( Exception ee ) {}                        gi.setTexture(texture);                    }                    else {                        gi.setTexture(null);                    }                }                break;              case 'B':                if ( firstThingSelected >= 0 ) {                    SimpleBody gi;                    IndexedColorImage source = null;                    NormalMap normalMap;                    RGBImage exported;                    gi = theScene.scene.getSimpleBodies().get(firstThingSelected);                     normalMap = gi.getNormalMap();                    if ( normalMap == null ) {                        try {                            normalMap = new NormalMap();                                //String imageFilename = "../../../etc/bumpmaps/blinn2.bw";                            String imageFilename = "../../../etc/bumpmaps/earth.bw";                            source = ImagePersistence.importIndexedColor(new File(imageFilename));                            normalMap.importBumpMap(source, new Vector3D(1, 1, 0.2));                             exported = normalMap.exportToRgbImage();                                //ImagePersistence.exportPPM(new File("./outputmap.ppm"), exported);                        }                        catch ( Exception ee ) {                            System.err.println(ee);                            ee.printStackTrace();                        }                        gi.setNormalMap(normalMap);                    }                    else {                        gi.setNormalMap(null);                    }                }                break;              case 'h':                //-------------------------------------------------------------                if ( parent.selectorDialog == null ) {                    parent.selectorDialog = new SwingSelectorDialog();                }                parent.selectorDialog.setVisible(true);                parent.selectorDialog.repaint();                //-------------------------------------------------------------                SimpleBody o;                int i;                ArrayList generic = theScene.scene.getSimpleBodies();                String msg = "";                for ( i = 0; i < generic.size(); i++ ) {                    System.out.println("Consultando cosa " + i + ":");                    o = (SimpleBody)generic.get(i);                    try {                        Method m = o.getClass().getMethod("getName", (Class[])null);                        if ( !(m.getReturnType().isInstance(msg)) ) {                            throw new Exception("Wrong method signature");                        }                        msg = (String)m.invoke(o);                    }                    catch ( Exception ee ) {                        msg = null;                    }                    if ( msg == null || msg.equals("") ) {                        msg = "Not named object";                    }                    System.out.println("Object: " + msg);                }                break;              case 'c':                statusMessage.setText("Camera mode interaction - drag mouse with different buttons over the scene to change current camera.");                lastInteractionMode = interactionMode;                interactionMode = CAMERA_INTERACTION_MODE;                break;              case 'q':                statusMessage.setText("Selection mode interaction - click mouse to select objects, LEFT/RIGHT arrow keys to select sequencialy.");                lastInteractionMode = interactionMode;                interactionMode = SELECT_INTERACTION_MODE;                break;              case 'w':                if ( ((e.getModifiersEx()) & e.ALT_DOWN_MASK) != 0x0 ) {                    if ( fullViewport ) {                        fullViewport = false;                    }                    else {                        fullViewport = true;                    }                    select

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -