@Override public void storeStates(Controller c) throws Exception { c.storeProperty(getClass(), "textures", textureInspector.getTextures()); c.storeProperty(getClass(), "texture", textureInspector.getActiveTexture()); c.storeProperty(getClass(), "textureScale", textureInspector.getTextureUScale()); c.storeProperty(getClass(), "visible", isVisible()); c.storeProperty(getClass(), "faceColor", getFaceColor()); c.storeProperty(getClass(), "transparency", getTransparency()); c.storeProperty(getClass(), "transparencyEnabled", isTransparencyEnabled()); c.storeProperty(getClass(), "facesReflecting", isFacesReflecting()); c.storeProperty(getClass(), "faceReflection", getFaceReflection()); c.storeProperty(getClass(), "reflectSceneContent", isReflectSceneContent()); c.storeProperty(getClass(), "visible", isVisible()); super.storeStates(c); }
@Override public void restoreStates(Controller c) throws Exception { setFaceColor(c.getProperty(getClass(), "faceColor", DEFAULT_TERRAIN_COLOR)); setTransparency(c.getProperty(getClass(), "transparency", DEFAULT_TRANSPARENCY)); setTransparencyEnabled( c.getProperty(getClass(), "transparencyEnabled", DEFAULT_TRANSPARENCY_ENABLED)); setFacesReflecting(c.getProperty(getClass(), "facesReflecting", DEFAULT_FACES_REFLECTING)); setFaceReflection(c.getProperty(getClass(), "faceReflection", DEFAULT_FACE_REFLECTION)); setReflectSceneContent(c.getProperty(getClass(), "reflectSceneContent", false)); textureInspector.setTextures(c.getProperty(getClass(), "textures", textures)); textureInspector.setTexture(c.getProperty(getClass(), "texture", DEFAULT_TEXTURE)); textureInspector.setTextureUScale( c.getProperty(getClass(), "textureScale", DEFAULT_TEXTURE_SCALE)); setVisible(c.getProperty(getClass(), "visible", true)); updateAll(); super.restoreStates(c); }
@Override public void install(Controller c) throws Exception { super.install(c); // scene Scene scene = c.getPlugin(Scene.class); scene.getBackdropComponent().addChild(terrain); scene.setAutomaticClippingPlanes(false); viewPreferences = c.getPlugin(ViewPreferences.class); viewPreferences.addColorPickerChangedListener(this); faceColorChooser.getColorPanel().setMode(viewPreferences.getColorPickerMode()); textureInspector.setAppearance(appearance); updateFaceColor(); updateFacesReflecting(); updateFaceReflection(); updateTransparencyEnabled(); updateTransparency(); VRPanel vp = c.getPlugin(VRPanel.class); vp.addComponent(getClass(), shrinkPanel, 1.0, "VR"); }
public Terrain() { appearance.setAttribute(CommonAttributes.EDGE_DRAW, false); appearance.setAttribute(CommonAttributes.VERTEX_DRAW, false); terrain.setAppearance(appearance); MatrixBuilder.euclidean().rotateX(Math.PI / 2).assignTo(plane); plane.setGeometry(bigMesh(50, 50, 2000)); plane.getGeometry().setGeometryAttributes("infinite plane", Boolean.TRUE); PickUtility.assignFaceAABBTrees(plane); terrain.addChild(plane); textures.put("2 Grid", "textures/grid.jpeg"); textures.put("3 Black Grid", "textures/gridBlack.jpg"); textures.put("4 Tiles", "textures/recycfloor1_clean2.png"); textures.put("5 Rust", "textures/outfactory3.png"); textures.put("1 None", null); shrinkPanel.setLayout(new GridLayout()); shrinkPanel.setIcon(getPluginInfo().icon); shrinkPanel.setShrinked(true); shrinkPanel.add(panel); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(1, 0, 1, 0); c.fill = BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = REMAINDER; c.anchor = WEST; colorPanel.setLayout(new GridBagLayout()); faceColorChooser.setMinimumSize(new Dimension(10, 230)); faceColorChooser.setPreferredSize(new Dimension(10, 230)); colorPanel.add(faceColorChooser, c); c.fill = VERTICAL; c.weighty = 0.0; colorPanel.add(closeButton, c); // panel panel.setLayout(new MinSizeGridBagLayout()); c.fill = BOTH; visibleCheckBox.setSelected(DEFAULT_TERRAIN_VISIBLE); c.weightx = 0.0; c.gridwidth = RELATIVE; panel.add(visibleCheckBox, c); c.weightx = 1.0; c.gridwidth = REMAINDER; panel.add(faceColorButton, c); c.weightx = 0.0; c.weighty = 0.0; c.gridwidth = RELATIVE; panel.add(facesReflecting, c); c.weightx = 1.0; c.gridwidth = REMAINDER; panel.add(faceReflectionSlider, c); c.weightx = 0.0; c.gridwidth = RELATIVE; panel.add(transparency, c); c.weightx = 1.0; c.gridwidth = REMAINDER; panel.add(transparencySlider, c); c.weightx = 1.0; c.gridwidth = REMAINDER; panel.add(reflectScene, c); reflectScene.setEnabled(false); reflectScene.setToolTipText("Coming soon..."); textureInspector.setMaximalTextureScale(MAXIMAL_TEXTURE_SCALE); textureInspector.setLogarithmicRange(LOGARITHMIC_RANGE); textureInspector.setTextureUScale(DEFAULT_TEXTURE_SCALE); c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = REMAINDER; textureShrinker.setIcon(ImageHook.getIcon("photo.png")); textureShrinker.setShrinked(true); textureShrinker.setLayout(new GridLayout()); textureShrinker.add(textureInspector); panel.add(textureShrinker, c); closeButton.addActionListener(this); visibleCheckBox.addActionListener(this); facesReflecting.addActionListener(this); transparency.addActionListener(this); faceColorButton.addActionListener(this); reflectScene.addActionListener(this); faceReflectionSlider.addChangeListener(this); transparencySlider.addChangeListener(this); faceColorChooser.getColorPanel().addChangeListener(this); }