001 /** 002 ############################################################################## 003 ## ## 004 ## Appearance3DChooser ## 005 ## ## 006 ## Copyright (C) 2009 Frederic Roudaut <frederic.roudaut@free.fr> ## 007 ## ## 008 ## ## 009 ## This program is free software: you can redistribute it and/or modify ## 010 ## it under the terms of the GNU General Public License as published by ## 011 ## the Free Software Foundation, either version 3 of the License, or ## 012 ## (at your option) any later version. ## 013 ## ## 014 ## This program is distributed in the hope that it will be useful, ## 015 ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## 016 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## 017 ## GNU General Public License for more details. ## 018 ## ## 019 ## You should have received a copy of the GNU General Public License ## 020 ## along with this program. If not, see <http://www.gnu.org/licenses/>. ## 021 ## ## 022 ## ## 023 ############################################################################## 024 **/ 025 026 027 package com.appearance3Dchooser; 028 029 import java.beans.PropertyChangeEvent; 030 import java.beans.PropertyChangeListener; 031 032 import javax.swing.JTabbedPane; 033 import javax.swing.JPanel; 034 import javax.swing.event.*; 035 import javax.swing.*; 036 import java.net.URL; 037 038 import java.awt.*; 039 import java.awt.event.*; 040 import java.lang.Math; 041 042 043 import com.colorpicker.swing.*; 044 import javax.vecmath.Color3f; 045 import javax.media.j3d.Material; 046 import javax.media.j3d.TransparencyAttributes; 047 import javax.media.j3d.Transform3D; 048 import javax.media.j3d.TextureAttributes; 049 050 /** 051 * Appearance3DChooserPanel Class.<br/> 052 * A basic class with a Panel for updating your objects appearances. It takes into account following attributes : 053 * <ul> 054 * <li><strong>Material</strong></li> 055 * <li><strong>TransparencyAttributes</strong></li> 056 * <li><strong>TextureAttributes</strong></li> 057 * <li><strong>Lighting</strong></li> 058 * </ul> 059 * </li> 060 061 * <br/> An instance of this object fire a Property Event when a dedicated parameter is modified. It distinguishes the following events : 062 * <ul> 063 * <br/> 064 * <li>Material Panel 065 * <ul> 066 * <li>SPECULAR </li> 067 * <li>AMBIENT </li> 068 * <li>EMISSIVE </li> 069 * <li>DIFFUSE </li> 070 * <li>COLORTARGET </li> 071 * <li>SHININESS </li> 072 * <li>LIGHTING </li> 073 * </ul> 074 * <br/> 075 * </li> 076 * 077 * <li>Transparency Panel 078 * <ul> 079 * <li>TRANSPARENCY </li> 080 * <li>TRANSPARENCY_MODE </li> 081 * <li>TRANSPARENCY_SRC_BLEND_FUNCTION </li> 082 * <li>TRANSPARENCY_DST_BLEND_FUNCTION </li> 083 * </ul> 084 * <br/> 085 * </li> 086 * 087 * <li> Texture Panel 088 * <ul> 089 * <li>TEXTURE_USE </li> 090 * <li>TEXTURE_FILE </li> 091 * <li>TEXTURE_TRANSFORM </li> 092 * <li>TEXTURE_PERSPECTIVE_CORRECTION_MODE </li> 093 * <li>TEXTURE_MODE </li> 094 * <li>TEXTURE_BLEND </li> 095 * <li>TEXTURE_COMBINE_RGB_MODE </li> 096 * <li>TEXTURE_COMBINE_RGB_SOURCE </li> 097 * <li>TEXTURE_COMBINE_RGB_FUNCTION </li> 098 * <li>TEXTURE_COMBINE_RGB_SCALE </li> 099 * <li>TEXTURE_COMBINE_ALPHA_MODE </li> 100 * <li>TEXTURE_COMBINE_ALPHA_SOURCE </li> 101 * <li>TEXTURE_COMBINE_ALPHA_FUNCTION </li> 102 * <li>TEXTURE_COMBINE_ALPHA_SCALE </li> 103 * </ul> 104 * <br/> 105 * </li> 106 * </li> 107 * </ul> 108 * 109 */ 110 public class Appearance3DChooserPanel extends JPanel implements ActionListener, ChangeListener, ItemListener 111 { 112 private static final long serialVersionUID = 1L; 113 114 public static final String SPECULAR = "specular"; 115 public static final String AMBIENT = "ambient"; 116 public static final String EMISSIVE = "emissive"; 117 public static final String DIFFUSE = "diffuse"; 118 public static final String COLORTARGET = "colortarget"; 119 public static final String SHININESS = "shininess"; 120 public static final String LIGHTING = "lighting"; 121 public static final String TRANSPARENCY = "transparency"; 122 public static final String TRANSPARENCY_MODE = "transparency_mode"; 123 public static final String TRANSPARENCY_SRC_BLEND_FUNCTION = "transparency_src_blend_function"; 124 public static final String TRANSPARENCY_DST_BLEND_FUNCTION = "transparency_dst_blend_function"; 125 public static final String TEXTURE_FILE = TexturePane.TEXTURE_FILE; 126 public static final String TEXTURE_USE = TexturePane.TEXTURE_USE; 127 public static final String TEXTURE_TRANSFORM = TexturePane.TEXTURE_TRANSFORM; 128 public static final String TEXTURE_PERSPECTIVE_CORRECTION_MODE = TexturePane.TEXTURE_PERPSPECTIVE_CORRECTION_MODE; 129 public static final String TEXTURE_MODE = TexturePane.TEXTURE_MODE; 130 public static final String TEXTURE_BLEND = TexturePane.TEXTURE_BLEND; 131 public static final String TEXTURE_COMBINE_RGB_MODE = TexturePane.TEXTURE_COMBINE_RGB_MODE; 132 public static final String TEXTURE_COMBINE_RGB_SOURCE = TexturePane.TEXTURE_COMBINE_RGB_SOURCE; 133 public static final String TEXTURE_COMBINE_RGB_FUNCTION = TexturePane.TEXTURE_COMBINE_RGB_FUNCTION; 134 public static final String TEXTURE_COMBINE_RGB_SCALE = TexturePane.TEXTURE_COMBINE_RGB_SCALE; 135 public static final String TEXTURE_COMBINE_ALPHA_MODE = TexturePane.TEXTURE_COMBINE_ALPHA_MODE; 136 public static final String TEXTURE_COMBINE_ALPHA_SOURCE = TexturePane.TEXTURE_COMBINE_ALPHA_SOURCE; 137 public static final String TEXTURE_COMBINE_ALPHA_FUNCTION = TexturePane.TEXTURE_COMBINE_ALPHA_FUNCTION; 138 public static final String TEXTURE_COMBINE_ALPHA_SCALE = TexturePane.TEXTURE_COMBINE_ALPHA_SCALE; 139 140 public static final int COLORTARGET_AMBIENT=Material.AMBIENT; 141 public static final int COLORTARGET_EMISSIVE=Material.EMISSIVE; 142 public static final int COLORTARGET_DIFFUSE=Material.DIFFUSE; 143 public static final int COLORTARGET_SPECULAR=Material.SPECULAR; 144 public static final int COLORTARGET_AMBIENT_AND_DIFFUSE=Material.AMBIENT_AND_DIFFUSE; 145 146 public static final int TRANSPARENCY_MODE_FASTEST=0; 147 public static final int TRANSPARENCY_MODE_NICEST=1; 148 public static final int TRANSPARENCY_MODE_BLENDED=2; 149 public static final int TRANSPARENCY_MODE_SCREEN_DOOR=3; 150 public static final int TRANSPARENCY_MODE_NONE=4; 151 152 public static final int TRANSPARENCY_SRC_BLEND_ZERO=0; 153 public static final int TRANSPARENCY_SRC_BLEND_ONE=1; 154 public static final int TRANSPARENCY_SRC_BLEND_SRC_ALPHA=2; 155 public static final int TRANSPARENCY_SRC_BLEND_ONE_MINUS_SRC_ALPHA=3; 156 public static final int TRANSPARENCY_SRC_BLEND_DST_COLOR=4; 157 public static final int TRANSPARENCY_SRC_BLEND_ONE_MINUS_DST_COLOR=5; 158 public static final int TRANSPARENCY_DST_BLEND_ZERO=0; 159 public static final int TRANSPARENCY_DST_BLEND_ONE=1; 160 public static final int TRANSPARENCY_DST_BLEND_SRC_ALPHA=2; 161 public static final int TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_ALPHA=3; 162 public static final int TRANSPARENCY_DST_BLEND_SRC_COLOR=4; 163 public static final int TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_COLOR=5; 164 165 166 protected float[] ambientColor = {0.2f,0.2f,0.2f}; 167 protected float[] diffuseColor = {1.0f,1.0f,1.0f}; 168 protected float[] specularColor = {1.0f,1.0f,1.0f}; 169 protected float[] emissiveColor = {0.36f,0.85f,0.80f}; 170 protected float shininess = 64; 171 protected int colorTarget = COLORTARGET_EMISSIVE; 172 protected boolean lighting = true; 173 protected int transparencyMode = TRANSPARENCY_MODE_NONE; 174 protected int transparencySrcBlendFunction = TRANSPARENCY_SRC_BLEND_SRC_ALPHA; 175 protected int transparencyDstBlendFunction = TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_ALPHA; 176 protected float transparency = 0; 177 protected URL DefaultTextureName = (new Info()).getClass().getResource("resources/DefaultTexture.png"); 178 protected URL textureName = DefaultTextureName; 179 protected boolean isTextureSet; 180 protected Transform3D textureTransform; 181 protected int texturePerspectiveCorrectionMode = TextureAttributes.NICEST; 182 protected int textureMode = TextureAttributes.REPLACE; 183 protected float[] textureBlendColor = {0.5f,0.5f,0.5f,0.5f}; 184 protected int[] textureCombineRGBSource = {TextureAttributes.COMBINE_TEXTURE_COLOR, 185 TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE, 186 TextureAttributes.COMBINE_CONSTANT_COLOR}; 187 protected int[] textureCombineRGBFunction = {TextureAttributes.COMBINE_SRC_COLOR, 188 TextureAttributes.COMBINE_SRC_COLOR, 189 TextureAttributes.COMBINE_SRC_COLOR}; 190 protected int textureCombineRGBMode = TextureAttributes.COMBINE_MODULATE; 191 protected int textureCombineRGBScale = 1; 192 protected int textureCombineAlphaMode = TextureAttributes.COMBINE_MODULATE; 193 protected int[] textureCombineAlphaSource = {TextureAttributes.COMBINE_TEXTURE_COLOR, 194 TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE, 195 TextureAttributes.COMBINE_CONSTANT_COLOR}; 196 protected int[] textureCombineAlphaFunction = {TextureAttributes.COMBINE_SRC_ALPHA, 197 TextureAttributes.COMBINE_SRC_ALPHA, 198 TextureAttributes.COMBINE_SRC_ALPHA}; 199 protected int textureCombineAlphaScale = 1; 200 201 protected JTabbedPane mainTabbedPane; 202 protected JTabbedPane MaterialTabPane; 203 protected JPanel ambientColorPanel; 204 protected JPanel diffuseColorPanel; 205 protected JPanel specularColorPanel; 206 protected JPanel emissiveColorPanel; 207 protected JPanel miscellaneousPanel; 208 protected JPanel transparencyPanel; 209 protected TexturePane texturePane; 210 protected RenderingViewPanel renderingViewPanel; 211 212 protected ColorPicker ambientColorPicker; 213 protected ColorPicker diffuseColorPicker; 214 protected ColorPicker emissiveColorPicker; 215 protected ColorPicker specularColorPicker; 216 protected JComboBox listColorTarget; 217 protected JComboBox listTransparencyMode; 218 protected JComboBox listTransparencySrcBlendFunction; 219 protected JComboBox listTransparencyDstBlendFunction; 220 protected JSlider sliderShininess; 221 protected JSpinner spinnerShininess; 222 protected JCheckBox checkBoxLighting; 223 protected JSlider sliderTransparency; 224 protected JSpinner spinnerTransparency; 225 226 protected boolean showMaterial, showTransparency, showTexture, showRendering; 227 228 /** 229 * Main Appearance3DChooserPanel constructor. Generate a Panel with all the Panes associated to control 230 * some of the JAVA 3D Appearence attributes. 231 * 232 * @param showMaterial set it to true if you want to see the Material Panel. 233 * @param showTransparency set it to true if you want to see the Transparency Panel. 234 * @param showTexture set it to true if you want to see the Texture Panel. 235 * @param showRendering set it to true if you want to see the Rendering Panel. 236 */ 237 public Appearance3DChooserPanel(boolean showMaterial, boolean showTransparency, boolean showTexture, boolean showRendering) 238 { 239 this.showMaterial = showMaterial; 240 this.showTransparency = showTransparency; 241 this.showTexture = showTexture; 242 this.showRendering = showRendering; 243 mainTabbedPane = new JTabbedPane(); 244 245 makeMaterialPane(); 246 makeTransparencyPane(); 247 makeTexturePane(); 248 makeRenderPane(); 249 250 add(mainTabbedPane); 251 } 252 253 /** 254 * 255 * Create a Rendering Pane. 256 * 257 */ 258 private void makeRenderPane() 259 { 260 // Show Rendering 261 renderingViewPanel = new RenderingViewPanel(DefaultTextureName); 262 if(showRendering) 263 mainTabbedPane.addTab(Info.ressources.getObject("Render").toString(),renderingViewPanel); 264 } 265 266 /** 267 * 268 * Create a Texture Pane. 269 * 270 */ 271 private void makeTexturePane() 272 { 273 DefaultTextureName = (new Info()).getClass().getResource("resources/DefaultTexture.png"); 274 275 // Texture Pane 276 texturePane = new TexturePane(DefaultTextureName); 277 278 279 textureTransform = new Transform3D(); 280 281 texturePane.addPropertyChangeListener(new PropertyChangeListener() { 282 public void propertyChange(PropertyChangeEvent evt) { 283 if(evt.getPropertyName().compareTo(TexturePane.TEXTURE_FILE) == 0) 284 { 285 updateTexture(texturePane.getTextureFile()); 286 } 287 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_USE) == 0) 288 { 289 updateIsTextureSet(texturePane.isTextureSet()); 290 } 291 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_TRANSFORM) == 0) 292 { 293 updateTextureTransform(texturePane.getTextureTransform()); 294 } 295 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_PERPSPECTIVE_CORRECTION_MODE) == 0) 296 { 297 updateTexturePerspectiveCorrectionMode(texturePane.getTexturePerspectiveCorrectionMode()); 298 } 299 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_MODE) == 0) 300 { 301 updateTextureMode(texturePane.getTextureMode()); 302 } 303 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_BLEND) == 0) 304 { 305 updateTextureBlendColor(texturePane.getTextureBlendColor()); 306 } 307 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_RGB_MODE) == 0) 308 { 309 updateTextureCombineRGBMode(texturePane.getTextureCombineRGBMode()); 310 } 311 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_RGB_SOURCE) == 0) 312 { 313 updateTextureCombineRGBSource(texturePane.getTextureCombineRGBSource()); 314 } 315 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_RGB_FUNCTION) == 0) 316 { 317 updateTextureCombineRGBFunction(texturePane.getTextureCombineRGBFunction()); 318 } 319 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_RGB_SCALE) == 0) 320 { 321 updateTextureCombineRGBScale(texturePane.getTextureCombineRGBScale()); 322 } 323 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_ALPHA_MODE) == 0) 324 { 325 updateTextureCombineAlphaMode(texturePane.getTextureCombineAlphaMode()); 326 } 327 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_ALPHA_SOURCE) == 0) 328 { 329 updateTextureCombineAlphaSource(texturePane.getTextureCombineAlphaSource()); 330 } 331 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_ALPHA_FUNCTION) == 0) 332 { 333 updateTextureCombineAlphaFunction(texturePane.getTextureCombineAlphaFunction()); 334 } 335 else if (evt.getPropertyName().compareTo(TexturePane.TEXTURE_COMBINE_ALPHA_SCALE) == 0) 336 { 337 updateTextureCombineAlphaScale(texturePane.getTextureCombineAlphaScale()); 338 } 339 }}); 340 341 if(showTexture) 342 mainTabbedPane.addTab(Info.ressources.getObject("Texture").toString(),texturePane); 343 } 344 345 346 /** 347 * 348 * Create a Transparency Pane. 349 * 350 */ 351 private void makeTransparencyPane() 352 { 353 // Transparency Panel 354 transparencyPanel = new JPanel(); 355 GridBagConstraints c = new GridBagConstraints(); 356 357 transparencyPanel.setLayout(new GridBagLayout()); 358 c.gridx = 0; c.gridy = 0; 359 c.weightx = 0; c.weighty = 0; 360 c.insets = new Insets(0,0,0,0); 361 c.fill = GridBagConstraints.WEST; 362 c.anchor = GridBagConstraints.CENTER; 363 364 JLabel transparencyModeLabel = new JLabel(Info.ressources.getObject("Transparency_Mode").toString()); 365 c.gridwidth=2; 366 transparencyPanel.add(transparencyModeLabel, c); 367 368 String [] transparencyModeChoices = new String[5]; 369 transparencyModeChoices[TRANSPARENCY_MODE_BLENDED] = "BLENDED"; 370 transparencyModeChoices[TRANSPARENCY_MODE_FASTEST] = "FASTEST"; 371 transparencyModeChoices[TRANSPARENCY_MODE_NICEST] = "NICEST"; 372 transparencyModeChoices[TRANSPARENCY_MODE_NONE] = "NONE"; 373 transparencyModeChoices[TRANSPARENCY_MODE_SCREEN_DOOR] = "SCREEN_DOOR"; 374 listTransparencyMode = new JComboBox(transparencyModeChoices); 375 listTransparencyMode.setSelectedIndex(transparencyMode); 376 listTransparencyMode.addActionListener(this); 377 c.gridy++; 378 transparencyPanel.add(listTransparencyMode, c); 379 380 JLabel transparencySrcBlendFunctionLabel = new JLabel(Info.ressources.getObject("Source_Blend_Function").toString()); 381 c.gridy++; 382 c.insets = new Insets(30,0,0,0); 383 transparencyPanel.add(transparencySrcBlendFunctionLabel, c); 384 c.insets = new Insets(0,0,0,0); 385 386 String [] transparencySrcBlendFunctionChoice = new String[6]; 387 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_ZERO] = "BLEND_ZERO"; 388 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_ONE] = "BLEND_ONE"; 389 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_SRC_ALPHA] = "BLEND_SRC_ALPHA"; 390 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_ONE_MINUS_SRC_ALPHA] = "BLEND_ONE_MINUS_SRC_ALPHA"; 391 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_DST_COLOR] = "BLEND_DST_COLOR"; 392 transparencySrcBlendFunctionChoice[TRANSPARENCY_SRC_BLEND_ONE_MINUS_DST_COLOR]="BLEND_ONE_MINUS_DST_COLOR"; 393 listTransparencySrcBlendFunction = new JComboBox(transparencySrcBlendFunctionChoice); 394 listTransparencySrcBlendFunction.setSelectedIndex(transparencySrcBlendFunction); 395 listTransparencySrcBlendFunction.addActionListener(this); 396 c.gridy++; 397 transparencyPanel.add(listTransparencySrcBlendFunction, c); 398 399 JLabel transparencyDstBlendFunctionLabel = new JLabel(Info.ressources.getObject("Destination_Blend_Function").toString()); 400 c.gridy++; 401 c.insets = new Insets(30,0,0,0); 402 transparencyPanel.add(transparencyDstBlendFunctionLabel, c); 403 c.insets = new Insets(0,0,0,0); 404 405 String [] transparencyDstBlendFunctionChoice = new String[6]; 406 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_ZERO] = "BLEND_ZERO"; 407 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_ONE] = "BLEND_ONE"; 408 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_SRC_ALPHA] = "BLEND_SRC_ALPHA"; 409 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_ALPHA] = "BLEND_ONE_MINUS_SRC_ALPHA"; 410 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_SRC_COLOR] = "BLEND_SRC_COLOR"; 411 transparencyDstBlendFunctionChoice[TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_COLOR]="BLEND_ONE_MINUS_SRC_COLOR"; 412 listTransparencyDstBlendFunction = new JComboBox(transparencyDstBlendFunctionChoice); 413 listTransparencyDstBlendFunction.setSelectedIndex(transparencyDstBlendFunction); 414 listTransparencyDstBlendFunction.addActionListener(this); 415 c.gridy++; 416 transparencyPanel.add(listTransparencyDstBlendFunction, c); 417 418 419 420 JLabel transparencyLabel = new JLabel(Info.ressources.getObject("Transparency").toString()); 421 c.gridy++; 422 c.insets = new Insets(30,0,0,0); 423 transparencyPanel.add(transparencyLabel, c); 424 c.insets = new Insets(0,0,0,0); 425 sliderTransparency = new JSlider(JSlider.HORIZONTAL,0,100,0); 426 sliderTransparency.addChangeListener(this); 427 c.gridy ++; 428 c.gridwidth=1; 429 transparencyPanel.add(sliderTransparency, c); 430 431 SpinnerModel transparencySpinnerModel = new SpinnerNumberModel(Float.valueOf(0.0f), //initial value 432 Float.valueOf(0.0f), //min 433 Float.valueOf(1.0f), //max 434 Float.valueOf(0.01f)); //step 435 spinnerTransparency = new JSpinner(transparencySpinnerModel); 436 ((JSpinner.DefaultEditor)spinnerTransparency.getEditor()).getTextField().setColumns(2); 437 spinnerTransparency.addChangeListener(this); 438 439 c.gridx ++; 440 transparencyPanel.add(spinnerTransparency,c); 441 442 if(showTransparency) 443 mainTabbedPane.addTab(Info.ressources.getObject("Transparency").toString(),transparencyPanel); 444 } 445 446 447 /** 448 * 449 * Create a Material Pane. 450 * 451 */ 452 private void makeMaterialPane() 453 { 454 GridBagConstraints c; 455 MaterialTabPane = new JTabbedPane(); 456 MaterialTabPane.setTabPlacement(JTabbedPane.LEFT); 457 458 // Panel For emissive color 459 emissiveColorPanel = new JPanel(); 460 emissiveColorPanel.setLayout(new GridBagLayout()); 461 c = new GridBagConstraints(); 462 c.fill = GridBagConstraints.CENTER; 463 emissiveColorPicker = new ColorPicker(true,false); 464 emissiveColorPicker.setRGB((int)(emissiveColor[0]*255), (int)(emissiveColor[1]*255), (int)(emissiveColor[2]*255)); 465 emissiveColorPanel.add(emissiveColorPicker,c); 466 emissiveColorPicker.addPropertyChangeListener(ColorPicker.HEX_COLOR_PROPERTY, new PropertyChangeListener() { 467 public void propertyChange(PropertyChangeEvent evt) { 468 float rgb[] = new float[3]; 469 rgb[0]=(float)emissiveColorPicker.getRGB()[0] / 255; 470 rgb[1]=(float)emissiveColorPicker.getRGB()[1] / 255; 471 rgb[2]=(float)emissiveColorPicker.getRGB()[2] / 255; 472 updateEmissiveColor(rgb); 473 } 474 }); 475 476 MaterialTabPane.addTab(Info.ressources.getObject("Emissive").toString(),emissiveColorPanel); 477 478 // Panel For ambient color 479 ambientColorPanel = new JPanel(); 480 ambientColorPanel.setLayout(new GridBagLayout()); 481 c = new GridBagConstraints(); 482 c.fill = GridBagConstraints.CENTER; 483 ambientColorPicker = new ColorPicker(true,false); 484 ambientColorPicker.setRGB((int)(ambientColor[0]*255), (int)(ambientColor[1]*255), (int)(ambientColor[2]*255)); 485 ambientColorPanel.add(ambientColorPicker,c); 486 ambientColorPicker.addPropertyChangeListener(ColorPicker.HEX_COLOR_PROPERTY, new PropertyChangeListener() { 487 public void propertyChange(PropertyChangeEvent evt) { 488 float rgb[] = new float[3]; 489 rgb[0]=(float)ambientColorPicker.getRGB()[0] / 255; 490 rgb[1]=(float)ambientColorPicker.getRGB()[1] / 255; 491 rgb[2]=(float)ambientColorPicker.getRGB()[2] / 255; 492 updateAmbientColor(rgb); 493 } 494 }); 495 MaterialTabPane.addTab(Info.ressources.getObject("Ambient").toString(),ambientColorPanel); 496 497 // Panel For diffuse color 498 diffuseColorPanel = new JPanel(); 499 diffuseColorPanel.setLayout(new GridBagLayout()); 500 c = new GridBagConstraints(); 501 c.fill = GridBagConstraints.CENTER; 502 diffuseColorPicker = new ColorPicker(true,false); 503 diffuseColorPicker.setRGB((int)(diffuseColor[0]*255), (int)(diffuseColor[1]*255), (int)(diffuseColor[2]*255)); 504 diffuseColorPanel.add(diffuseColorPicker,c); 505 diffuseColorPicker.addPropertyChangeListener(ColorPicker.HEX_COLOR_PROPERTY, new PropertyChangeListener() { 506 public void propertyChange(PropertyChangeEvent evt) { 507 float rgb[] = new float[3]; 508 rgb[0]=(float)diffuseColorPicker.getRGB()[0] / 255; 509 rgb[1]=(float)diffuseColorPicker.getRGB()[1] / 255; 510 rgb[2]=(float)diffuseColorPicker.getRGB()[2] / 255; 511 updateDiffuseColor(rgb); 512 } 513 }); 514 MaterialTabPane.addTab(Info.ressources.getObject("Diffuse").toString(),diffuseColorPanel); 515 516 // Panel For specular color 517 specularColorPanel = new JPanel(); 518 specularColorPanel.setLayout(new GridBagLayout()); 519 c = new GridBagConstraints(); 520 c.fill = GridBagConstraints.CENTER; 521 specularColorPicker = new ColorPicker(true,false); 522 specularColorPicker.setRGB((int)(specularColor[0]*255), (int)(specularColor[1]*255), (int)(specularColor[2]*255)); 523 specularColorPanel.add(specularColorPicker,c); 524 specularColorPicker.addPropertyChangeListener(ColorPicker.HEX_COLOR_PROPERTY, new PropertyChangeListener() { 525 public void propertyChange(PropertyChangeEvent evt) { 526 float rgb[] = new float[3]; 527 rgb[0]=(float)specularColorPicker.getRGB()[0] / 255; 528 rgb[1]=(float)specularColorPicker.getRGB()[1] / 255; 529 rgb[2]=(float)specularColorPicker.getRGB()[2] / 255; 530 updateSpecularColor(rgb); 531 } 532 }); 533 534 MaterialTabPane.addTab(Info.ressources.getObject("Specular").toString(),specularColorPanel); 535 536 // Miscellaneous Panel : Lighting, Shininess, Target Color 537 miscellaneousPanel = new JPanel(); 538 c = new GridBagConstraints(); 539 miscellaneousPanel.setLayout(new GridBagLayout()); 540 c.gridx = 0; c.gridy = 0; 541 c.weightx = 0; c.weighty = 0; 542 c.insets = new Insets(0,0,0,0); 543 c.fill = GridBagConstraints.CENTER; 544 c.anchor = GridBagConstraints.CENTER; 545 c.gridwidth = 2; 546 547 checkBoxLighting = new JCheckBox(Info.ressources.getObject("Lighting").toString()); 548 checkBoxLighting.setSelected(true); 549 checkBoxLighting.addItemListener(this); 550 551 miscellaneousPanel.add(checkBoxLighting, c); 552 c.gridx = 0; c.gridy++; 553 c.insets = new Insets(30,0,0,0); 554 c.gridwidth = 1; 555 556 557 JLabel sliderShininessLabel = new JLabel(Info.ressources.getObject("Shininess").toString(), JLabel.CENTER); 558 sliderShininessLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 559 miscellaneousPanel.add(sliderShininessLabel, c); 560 c.gridy++; 561 c.insets = new Insets(0,0,0,0); 562 563 sliderShininess = new JSlider(JSlider.HORIZONTAL, 0, 128, (int)shininess); 564 sliderShininess.setMajorTickSpacing(32); 565 sliderShininess.setMinorTickSpacing(4); 566 sliderShininess.setPaintTicks(true); 567 sliderShininess.setPaintLabels(true); 568 sliderShininess.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); 569 Font font = new Font("Serif", Font.ITALIC, 15); 570 sliderShininess.setFont(font); 571 sliderShininess.addChangeListener(this); 572 miscellaneousPanel.add(sliderShininess, c); 573 574 SpinnerModel shininessSpinnerModel = new SpinnerNumberModel(Float.valueOf(shininess), //initial value 575 Float.valueOf(0.0f), //min 576 Float.valueOf(128.0f), //max 577 Float.valueOf(0.1f)); //step 578 spinnerShininess = new JSpinner(shininessSpinnerModel); 579 ((JSpinner.DefaultEditor)spinnerShininess.getEditor()).getTextField().setColumns(3); 580 spinnerShininess.addChangeListener(this); 581 582 c.gridx ++; 583 c.insets = new Insets(0,0,20,0); 584 miscellaneousPanel.add(spinnerShininess,c); 585 c.insets = new Insets(0,0,0,0); 586 c.gridx =0; 587 588 c.gridy++; 589 c.insets = new Insets(30,0,0,0); 590 c.gridwidth = 2; 591 592 JLabel listColorTargetLabel = new JLabel(Info.ressources.getObject("Color_Target").toString(), JLabel.CENTER); 593 listColorTargetLabel.setAlignmentX(Component.CENTER_ALIGNMENT); 594 miscellaneousPanel.add(listColorTargetLabel, c); 595 c.gridy++; 596 c.insets = new Insets(0,0,0,0); 597 598 String [] ColorTargetChoices = new String[5]; 599 ColorTargetChoices[COLORTARGET_AMBIENT] = "AMBIENT"; 600 ColorTargetChoices[COLORTARGET_EMISSIVE] = "EMISSIVE"; 601 ColorTargetChoices[COLORTARGET_DIFFUSE] = "DIFFUSE"; 602 ColorTargetChoices[COLORTARGET_SPECULAR] = "SPECULAR"; 603 ColorTargetChoices[COLORTARGET_AMBIENT_AND_DIFFUSE] = "AMBIENT_AND_DIFFUSE"; 604 605 listColorTarget = new JComboBox(ColorTargetChoices); 606 listColorTarget.setSelectedIndex(colorTarget); 607 listColorTarget.addActionListener(this); 608 miscellaneousPanel.add(listColorTarget, c); 609 610 611 MaterialTabPane.addTab(Info.ressources.getObject("Miscellaneous").toString(),miscellaneousPanel); 612 613 if(showMaterial) 614 mainTabbedPane.addTab(Info.ressources.getObject("Material").toString(),MaterialTabPane); 615 } 616 617 618 /** 619 * 620 * Called when an action is performed on the Transparency Pane mainly. 621 * @param e the related action. 622 * 623 */ 624 public void actionPerformed(ActionEvent e) 625 { 626 Object source = e.getSource(); 627 if(source == listTransparencyMode) 628 { 629 updateTransparencyMode(listTransparencyMode.getSelectedIndex()); 630 } 631 else if(source == listTransparencySrcBlendFunction) 632 { 633 updateTransparencySrcBlendFunction(listTransparencySrcBlendFunction.getSelectedIndex()); 634 } 635 else if(source == listTransparencyDstBlendFunction) 636 { 637 updateTransparencyDstBlendFunction(listTransparencyDstBlendFunction.getSelectedIndex()); 638 } 639 else if(source == listColorTarget) 640 { 641 updateColorTarget(listColorTarget.getSelectedIndex()); 642 } 643 } 644 645 646 /** 647 * 648 * Called when a state changes on the Transparency and the Material Pane mainly (ie a slider is used ...). 649 * @param e the related event. 650 * 651 */ 652 public void stateChanged(ChangeEvent e) 653 { 654 Object source = e.getSource(); 655 if(source == sliderTransparency) 656 { 657 float o = Float.valueOf(sliderTransparency.getValue()) / 100; 658 //For safety reason 659 o = ((float) (Math.round (o*100))) / 100; 660 updateTransparency(o); 661 spinnerTransparency.setValue(o); 662 } 663 else if(source == spinnerTransparency) 664 { 665 float o = (Float)spinnerTransparency.getValue(); 666 o = ((float) (Math.round (o*100))) / 100; 667 updateTransparency(o); 668 sliderTransparency.setValue(Math.round(o*100)); 669 spinnerTransparency.setValue(o); 670 } 671 else if(source == sliderShininess) 672 { 673 float s = Float.valueOf(sliderShininess.getValue()); 674 //For safety reason 675 s = ((float) (Math.round (s*10))) / 10; 676 updateShininess(s); 677 spinnerShininess.setValue(s); 678 } 679 else if(source == spinnerShininess) 680 { 681 float s = (Float)(spinnerShininess.getValue()); 682 s = ((float) (Math.round (s*10))) / 10; 683 updateShininess(s); 684 sliderShininess.setValue(Math.round(s)); 685 } 686 } 687 688 689 /** 690 * 691 * Called when the Lighting checkbox in the Material Pane is clicked. 692 * @param e the related event. 693 * 694 */ 695 public void itemStateChanged(ItemEvent e) 696 { 697 Object source = e.getSource(); 698 if(source == checkBoxLighting) 699 { 700 updateLighting(checkBoxLighting.isSelected()); 701 } 702 } 703 704 705 /** 706 * 707 * Return the transparency value. 708 * @return the amount of transparency to be applied to the Appearance component object. 709 * The transparency values are in the range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being fully transparent. 710 * 711 */ 712 public float getTransparency () 713 { 714 return transparency; 715 } 716 717 /** 718 * 719 * Set the transparency value. 720 * @param o the amount of transparency to be applied to the Appearance component object. 721 * The transparency values are in the range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being fully transparent. 722 * 723 */ 724 public void setTransparency (float o) 725 { 726 sliderTransparency.setValue((int)(o*100)); 727 spinnerTransparency.setValue(o); 728 transparency = o; 729 } 730 731 732 /** 733 * 734 * Internal update of the transparency value Parameters and fire of an associated property. 735 * @param o the amount of transparency to be applied to the Appearance component object. 736 * The transparency values are in the range [0.0, 1.0], with 0.0 being fully opaque and 1.0 being fully transparent. 737 * 738 */ 739 private void updateTransparency (float o) 740 { 741 float lastTransparency = transparency; 742 transparency = o; 743 renderingViewPanel.setObjectsTransparency(o); 744 firePropertyChange(TRANSPARENCY,lastTransparency,transparency); 745 } 746 747 /** 748 * 749 * Return the transparency Mode. 750 * @return the transparency Mode between TransparencyAttributes.FASTEST, TransparencyAttributes.NICEST, TransparencyAttributes.SCREEN_DOOR, TransparencyAttributes.BLENDED, TransparencyAttributes.NONE 751 * 752 */ 753 public int getTransparencyMode () 754 { 755 return convertExternTransparencyMode(transparencyMode); 756 } 757 758 /** 759 * 760 * Set the transparency Mode. 761 * @param m the transparency Mode between TransparencyAttributes.FASTEST, TransparencyAttributes.NICEST, TransparencyAttributes.SCREEN_DOOR, TransparencyAttributes.BLENDED, TransparencyAttributes.NONE 762 * 763 */ 764 public void setTransparencyMode (int m) 765 { 766 listTransparencyMode.setSelectedIndex(convertInternTransparencyMode(m)); 767 transparencyMode = convertInternTransparencyMode(m); 768 } 769 770 /** 771 * 772 * Internal update of the transparency Mode Parameters and fire of an associated property. 773 * @param m the transparency Mode between TransparencyAttributes.FASTEST, TransparencyAttributes.NICEST, TransparencyAttributes.SCREEN_DOOR, TransparencyAttributes.BLENDED, TransparencyAttributes.NONE 774 * 775 */ 776 private void updateTransparencyMode (int m) 777 { 778 int lastTransparencyMode = transparencyMode; 779 transparencyMode = m; 780 renderingViewPanel.setObjectsTransparencyMode(convertExternTransparencyMode(m)); 781 firePropertyChange(TRANSPARENCY_MODE,lastTransparencyMode,transparencyMode); 782 } 783 784 /** 785 * 786 * Return the transparency Source Blend Function. 787 * @return the transparency Source Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 788 * TransparencyAttributes.BLEND_DST_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR. 789 * 790 */ 791 public int getTransparencySrcBlendFunction () 792 { 793 return convertExternTransparencySrcBlendFunction(transparencySrcBlendFunction); 794 } 795 796 /** 797 * 798 * Set the transparency Source Blend Function. 799 * @param m the transparency Source Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 800 * TransparencyAttributes.BLEND_DST_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR. 801 * 802 */ 803 public void setTransparencySrcBlendFunction (int m) 804 { 805 listTransparencySrcBlendFunction.setSelectedIndex(convertInternTransparencySrcBlendFunction(m)); 806 transparencySrcBlendFunction = convertInternTransparencySrcBlendFunction(m); 807 } 808 809 /** 810 * 811 * Internal update of the transparency Source Blend Function Parameters and fire of an associated property. 812 * @param f the transparency Source Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 813 * TransparencyAttributes.BLEND_DST_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR. 814 * 815 */ 816 private void updateTransparencySrcBlendFunction(int f) 817 { 818 int lastTransparencySrcBlendFunction = transparencySrcBlendFunction; 819 transparencySrcBlendFunction = f; 820 renderingViewPanel.setObjectsTransparencySrcBlendFunction(convertExternTransparencySrcBlendFunction(f)); 821 firePropertyChange(TRANSPARENCY_SRC_BLEND_FUNCTION,lastTransparencySrcBlendFunction,transparencySrcBlendFunction); 822 } 823 824 /** 825 * 826 * Return the transparency Destination Blend Function. 827 * @return the transparency Destination Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 828 * TransparencyAttributes.BLEND_SRC_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR. 829 * 830 */ 831 public int getTransparencyDstBlendFunction () 832 { 833 return convertExternTransparencyDstBlendFunction(transparencyDstBlendFunction); 834 } 835 836 /** 837 * 838 * Set the transparency Destination Blend Function. 839 * @param m the transparency Destination Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 840 * TransparencyAttributes.BLEND_SRC_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR. 841 * 842 */ 843 public void setTransparencyDstBlendFunction (int m) 844 { 845 listTransparencyDstBlendFunction.setSelectedIndex(convertInternTransparencyDstBlendFunction(m)); 846 transparencyDstBlendFunction = convertInternTransparencyDstBlendFunction(m); 847 } 848 849 /** 850 * 851 * Internal update of the transparency Destination Blend Function Parameters and fire of an associated property. 852 * @param f the transparency Destination Blend Function between TransparencyAttributes.BLEND_ZERO, TransparencyAttributes.BLEND_ONE, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA, 853 * TransparencyAttributes.BLEND_SRC_COLOR, TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR. 854 * 855 */ 856 private void updateTransparencyDstBlendFunction(int f) 857 { 858 int lastTransparencyDstBlendFunction = transparencyDstBlendFunction; 859 transparencyDstBlendFunction = f; 860 renderingViewPanel.setObjectsTransparencyDstBlendFunction(convertExternTransparencyDstBlendFunction(f)); 861 firePropertyChange(TRANSPARENCY_DST_BLEND_FUNCTION,lastTransparencyDstBlendFunction,transparencyDstBlendFunction); 862 } 863 864 /** 865 * 866 * Return the Lighting mode. 867 * @return true if lighting is enabled for the object, false otherwise. 868 * 869 */ 870 public boolean getLighting () 871 { 872 return lighting; 873 } 874 875 /** 876 * 877 * Set the Lighting mode. 878 * @param l true lighting is enabled for the object, false otherwise. 879 * 880 */ 881 public void setLighting (boolean l) 882 { 883 checkBoxLighting.setSelected(l); 884 lighting = l; 885 } 886 887 /** 888 * 889 * Internal update of the Lighting mode Parameters and fire of an associated property. 890 * @param l true lighting is enabled for the object, false otherwise. 891 * 892 */ 893 private void updateLighting (boolean l) 894 { 895 boolean lastLighting = lighting; 896 lighting = l; 897 renderingViewPanel.setObjectsLighting(l); 898 firePropertyChange(LIGHTING,lastLighting,lighting); 899 } 900 901 /** 902 * 903 * Return the Color Target. 904 * @return the Color Target. One of: Material.AMBIENT, Material.EMISSIVE, Material.DIFFUSE, Material.SPECULAR, 905 * or Material.AMBIENT_AND_DIFFUSE. 906 * 907 */ 908 public int getColorTarget () 909 { 910 return colorTarget; 911 } 912 913 /** 914 * 915 * Set the Color Target. 916 * @param c the Color Target. One of: Material.AMBIENT, Material.EMISSIVE, Material.DIFFUSE, Material.SPECULAR, 917 * or Material.AMBIENT_AND_DIFFUSE. 918 * 919 */ 920 public void setColorTarget (int c) 921 { 922 listColorTarget.setSelectedIndex(c); 923 colorTarget = c; 924 } 925 926 /** 927 * 928 * Internal update of the Color Target Parameters and fire of an associated property. 929 * @param c the Color Target. One of: Material.AMBIENT, Material.EMISSIVE, Material.DIFFUSE, Material.SPECULAR, 930 * or Material.AMBIENT_AND_DIFFUSE. 931 * 932 */ 933 private void updateColorTarget (int c) 934 { 935 int lastColorTarget = colorTarget; 936 colorTarget = c; 937 firePropertyChange(COLORTARGET,lastColorTarget,colorTarget); 938 } 939 940 /** 941 * 942 * Return the Shininess. 943 * @return the Shininess in the range [1.0, 128.0] with 1.0 being not shiny and 128.0 being very shiny. 944 * 945 */ 946 public float getShininess () 947 { 948 return shininess; 949 } 950 951 /** 952 * 953 * Set the Shininess. 954 * @param s the Shininess in the range [1.0, 128.0] with 1.0 being not shiny and 128.0 being very shiny. 955 * 956 */ 957 public void setShininess (float s) 958 { 959 sliderShininess.setValue((int)(s)); 960 spinnerShininess.setValue(s); 961 shininess = s; 962 } 963 964 /** 965 * 966 * Internal update of the Shininess Parameters and fire of an associated property. 967 * @param s the Shininess in the range [1.0, 128.0] with 1.0 being not shiny and 128.0 being very shiny. 968 * 969 */ 970 private void updateShininess (float s) 971 { 972 float lastShininess = shininess; 973 shininess = s; 974 renderingViewPanel.setObjectsShininess((float)s); 975 firePropertyChange(SHININESS,lastShininess,shininess); 976 } 977 978 /** 979 * 980 * Return the Ambient Color. 981 * @return the Ambient Color in (R,G,B). 982 * 983 */ 984 public float [] getAmbientColor () 985 { 986 return ambientColor; 987 } 988 989 /** 990 * 991 * Set the Ambient Color 992 * @param c the Ambient Color in (R,G,B). 993 * 994 */ 995 public void setAmbientColor (float []c) 996 { 997 ambientColorPicker.setRGB((int)(c[0]*255), (int)(c[1]*255), (int)(c[2]*255)); 998 ambientColor = c; 999 } 1000 1001 /** 1002 * 1003 * Internal update of the Ambient Color Parameters and fire of an associated property. 1004 * @param c the Ambient Color in (R,G,B). 1005 * 1006 */ 1007 private void updateAmbientColor (float []c) 1008 { 1009 float []lastAmbient = ambientColor; 1010 ambientColor = c; 1011 renderingViewPanel.setObjectsAmbientColor(new Color3f(c[0],c[1],c[2])); 1012 firePropertyChange(AMBIENT,lastAmbient,ambientColor); 1013 } 1014 1015 /** 1016 * 1017 * Return the Diffuse Color. 1018 * @return the Diffuse Color in (R,G,B). 1019 * 1020 */ 1021 public float [] getDiffuseColor () 1022 { 1023 return diffuseColor; 1024 } 1025 1026 /** 1027 * 1028 * Set the Diffuse Color 1029 * @param c the Diffuse Color in (R,G,B). 1030 * 1031 */ 1032 public void setDiffuseColor (float []c) 1033 { 1034 diffuseColorPicker.setRGB((int)(c[0]*255), (int)(c[1]*255), (int)(c[2]*255)); 1035 diffuseColor = c; 1036 } 1037 1038 /** 1039 * 1040 * Internal update of the Diffuse Color Parameters and fire of an associated property. 1041 * @param c the Diffuse Color in (R,G,B). 1042 * 1043 */ 1044 private void updateDiffuseColor (float []c) 1045 { 1046 float []lastDiffuse = diffuseColor; 1047 diffuseColor = c; 1048 renderingViewPanel.setObjectsDiffuseColor(new Color3f(c[0],c[1],c[2])); 1049 firePropertyChange(DIFFUSE,lastDiffuse,diffuseColor); 1050 } 1051 1052 /** 1053 * 1054 * Return the Specular Color. 1055 * @return the Specular Color in (R,G,B). 1056 * 1057 */ 1058 public float [] getSpecularColor () 1059 { 1060 return specularColor; 1061 } 1062 1063 /** 1064 * 1065 * Set the Specular Color. 1066 * @param c the Specular Color in (R,G,B). 1067 * 1068 */ 1069 public void setSpecularColor (float []c) 1070 { 1071 specularColorPicker.setRGB((int)(c[0]*255), (int)(c[1]*255), (int)(c[2]*255)); 1072 specularColor = c; 1073 } 1074 1075 private void updateSpecularColor (float []c) 1076 { 1077 float []lastSpecular = specularColor; 1078 specularColor = c; 1079 renderingViewPanel.setObjectsSpecularColor(new Color3f(c[0],c[1],c[2])); 1080 firePropertyChange(SPECULAR,lastSpecular,specularColor); 1081 } 1082 1083 /** 1084 * 1085 * Return the Emissive Color. 1086 * @return the Emissive Color in (R,G,B). 1087 * 1088 */ 1089 public float [] getEmissiveColor () 1090 { 1091 return emissiveColor; 1092 } 1093 1094 /** 1095 * 1096 * Set the Emissive Color. 1097 * @param c the Emissive Color in (R,G,B). 1098 * 1099 */ 1100 public void setEmissiveColor (float []c) 1101 { 1102 emissiveColorPicker.setRGB((int)(c[0]*255), (int)(c[1]*255), (int)(c[2]*255)); 1103 emissiveColor = c; 1104 } 1105 1106 /** 1107 * 1108 * Internal update of the Emissive Color Parameters and fire of an associated property. 1109 * @param c the Emissive Color in (R,G,B). 1110 * 1111 */ 1112 private void updateEmissiveColor (float []c) 1113 { 1114 float []lastEmissiveColor = emissiveColor; 1115 emissiveColor = c; 1116 renderingViewPanel.setObjectsEmissiveColor(new Color3f(c[0],c[1],c[2])); 1117 firePropertyChange(EMISSIVE,lastEmissiveColor,emissiveColor); 1118 } 1119 1120 /** 1121 * 1122 * Return the Texture Setting. 1123 * @return true if the texture is used, false otherwise. 1124 * 1125 */ 1126 public boolean isTextureSet() 1127 { 1128 return isTextureSet; 1129 } 1130 1131 /** 1132 * 1133 * Set the Texture Setting. 1134 * @param b true if the texture is used, false otherwise. 1135 * 1136 */ 1137 public void setTextureUse(boolean b) 1138 { 1139 texturePane.setTextureUse(b); 1140 isTextureSet = b; 1141 } 1142 1143 /** 1144 * 1145 * Internal update of the Texture Setting Parameters and fire of an associated property. 1146 * @param on true if the texture is used, false otherwise. 1147 * 1148 */ 1149 private void updateIsTextureSet(boolean on) 1150 { 1151 boolean lastIsTextureSet = isTextureSet; 1152 isTextureSet = on; 1153 1154 if(on) 1155 { 1156 renderingViewPanel.setTexture(textureName); 1157 } 1158 else 1159 renderingViewPanel.unsetTexture(); 1160 1161 firePropertyChange(TEXTURE_USE,lastIsTextureSet,on); 1162 } 1163 1164 /** 1165 * 1166 * Return the Texture File URL. 1167 * @return the Texture File URL. 1168 * 1169 */ 1170 public URL getTextureFile() 1171 { 1172 return texturePane.getTextureFile(); 1173 } 1174 1175 /** 1176 * 1177 * Set the Texture File URL. 1178 * @param t the Texture File URL. 1179 * 1180 */ 1181 public void setTextureFile(URL t) 1182 { 1183 texturePane.setTextureFile(t); 1184 } 1185 1186 /** 1187 * 1188 * Set the Default Texture File URL. 1189 * @param t the Default Texture File URL. 1190 * 1191 */ 1192 public void setDefaultTextureFile(URL t) 1193 { 1194 texturePane.setDefaultTextureFile(t); 1195 } 1196 1197 1198 /** 1199 * 1200 * Internal update of the Texture File URL Parameters and fire of an associated property. 1201 * @param t the Texture File URL. 1202 * 1203 */ 1204 private void updateTexture(URL t) 1205 { 1206 URL lastTextureName = textureName; 1207 textureName = t; 1208 if (textureName != null && textureName.getPath().compareTo("") != 0 && isTextureSet) 1209 { 1210 renderingViewPanel.setTexture(textureName); 1211 } 1212 1213 firePropertyChange(TEXTURE_FILE,lastTextureName,textureName); 1214 } 1215 1216 /** 1217 * 1218 * Return the Texture Transform. 1219 * @return the Texture Transform. 1220 * 1221 */ 1222 public Transform3D getTextureTransform() 1223 { 1224 return new Transform3D(textureTransform); 1225 } 1226 1227 /** 1228 * 1229 * Set the Texture Transform. 1230 * @param t the Texture Transform. 1231 * 1232 */ 1233 public void setTextureTransform(Transform3D t) 1234 { 1235 texturePane.setTextureTransform(t); 1236 textureTransform = t; 1237 } 1238 1239 /** 1240 * 1241 * Internal update of the Texture Transform Parameters and fire of an associated property. 1242 * @param t the Texture Transform. 1243 * 1244 */ 1245 private void updateTextureTransform(Transform3D t) 1246 { 1247 Transform3D lastTextureTransform = new Transform3D(textureTransform); 1248 textureTransform = new Transform3D(t); 1249 renderingViewPanel.setTextureTransform(textureTransform); 1250 firePropertyChange(TEXTURE_TRANSFORM,lastTextureTransform,textureTransform); 1251 } 1252 1253 /** 1254 * 1255 * Return the Texture Transform Scale on X axis. 1256 * @return the Texture Transform Scale on X axis. 1257 * 1258 */ 1259 public float getTextureTransformScaleX() 1260 { 1261 return texturePane.getTextureTransformScaleX(); 1262 } 1263 1264 /** 1265 * 1266 * Set the Texture Transform Scale on X axis. 1267 * @param v the Texture Transform Scale on X axis. 1268 * 1269 */ 1270 public void setTextureTransformScaleX(float v) 1271 { 1272 1273 texturePane.setTextureTransformScaleX(v); 1274 } 1275 1276 /** 1277 * 1278 * Return the Texture Transform Scale on Y axis. 1279 * @return the Texture Transform Scale on Y axis. 1280 * 1281 */ 1282 public float getTextureTransformScaleY() 1283 { 1284 return texturePane.getTextureTransformScaleY(); 1285 } 1286 1287 /** 1288 * 1289 * Set the Texture Transform Scale on Y axis. 1290 * @param v the Texture Transform Scale on Y axis. 1291 * 1292 */ 1293 public void setTextureTransformScaleY(float v) 1294 { 1295 1296 texturePane.setTextureTransformScaleY(v); 1297 } 1298 1299 /** 1300 * 1301 * Return the Texture Transform Translation on X axis. 1302 * @return the Texture Transform Translation on X axis. 1303 * 1304 */ 1305 public float getTextureTransformTranslatX() 1306 { 1307 return texturePane.getTextureTransformTranslatX(); 1308 } 1309 1310 /** 1311 * 1312 * Set the Texture Transform Translation on X axis. 1313 * @param v the Texture Transform Translation on X axis. 1314 * 1315 */ 1316 public void setTextureTransformTranslatX(float v) 1317 { 1318 1319 texturePane.setTextureTransformTranslatX(v); 1320 } 1321 1322 /** 1323 * 1324 * Return the Texture Transform Translation on Y axis. 1325 * @return the Texture Transform Translation on Y axis. 1326 * 1327 */ 1328 public float getTextureTransformTranslatY() 1329 { 1330 return texturePane.getTextureTransformTranslatY(); 1331 } 1332 1333 /** 1334 * 1335 * Set the Texture Transform Translation on Y axis. 1336 * @param v the Texture Transform Translation on Y axis. 1337 * 1338 */ 1339 public void setTextureTransformTranslatY(float v) 1340 { 1341 1342 texturePane.setTextureTransformTranslatY(v); 1343 } 1344 1345 /** 1346 * 1347 * Return the Texture Transform Rotation on Z axis. 1348 * @return the Texture Transform Rotation on Z axis. 1349 * 1350 */ 1351 public float getTextureTransformRotZ() 1352 { 1353 return texturePane.getTextureTransformRotZ(); 1354 } 1355 1356 /** 1357 * 1358 * Set the Texture Transform Rotation on Z axis. 1359 * @param v the Texture Transform Rotation on Z axis. 1360 * 1361 */ 1362 public void setTextureTransformRotZ(float v) 1363 { 1364 texturePane.setTextureTransformRotZ(v); 1365 } 1366 1367 /** 1368 * 1369 * Return the Texture Perspective Correction Mode. 1370 * @return the Texture Perspective Correction Mode between TextureAttributes.NICEST, TextureAttributes.FASTEST. 1371 * 1372 */ 1373 public int getTexturePerspectiveCorrectionMode() 1374 { 1375 return texturePerspectiveCorrectionMode; 1376 } 1377 1378 /** 1379 * 1380 * Set the Texture Perspective Correction Mode. 1381 * @param m the Texture Perspective Correction Mode between TextureAttributes.NICEST, TextureAttributes.FASTEST. 1382 * 1383 */ 1384 public void setTexturePerspectiveCorrectionMode(int m) 1385 { 1386 texturePane.setTexturePerspectiveCorrectionMode(m); 1387 texturePerspectiveCorrectionMode = m; 1388 } 1389 1390 protected void updateTexturePerspectiveCorrectionMode(int m) 1391 { 1392 int lastTexturePerspectiveCorrectionMode = texturePerspectiveCorrectionMode; 1393 texturePerspectiveCorrectionMode = m; 1394 renderingViewPanel.setObjectsTexturePerspectiveCorrectionMode(m); 1395 firePropertyChange(TEXTURE_PERSPECTIVE_CORRECTION_MODE,lastTexturePerspectiveCorrectionMode,texturePerspectiveCorrectionMode); 1396 } 1397 1398 /** 1399 * 1400 * Return the Texture Mode. 1401 * @return the Texture Mode between TextureAttributes.MODULATE, TextureAttributes.DECAL, TextureAttributes.BLEND, 1402 * TextureAttributes.REPLACE, TextureAttributes.COMBINE. 1403 * 1404 */ 1405 public int getTextureMode() 1406 { 1407 return textureMode; 1408 } 1409 1410 /** 1411 * 1412 * Set the Texture Mode. 1413 * @param m the Texture Mode between TextureAttributes.MODULATE, TextureAttributes.DECAL, TextureAttributes.BLEND, 1414 * TextureAttributes.REPLACE, TextureAttributes.COMBINE. 1415 * 1416 */ 1417 public void setTextureMode(int m) 1418 { 1419 texturePane.setTextureMode(m); 1420 textureMode = m; 1421 } 1422 1423 /** 1424 * 1425 * Internal update of the Texture Mode Parameters and fire of an associated property. 1426 * @param m the Texture Mode between TextureAttributes.MODULATE, TextureAttributes.DECAL, TextureAttributes.BLEND, 1427 * TextureAttributes.REPLACE, TextureAttributes.COMBINE. 1428 * 1429 */ 1430 protected void updateTextureMode(int m) 1431 { 1432 int lastTextureMode = textureMode; 1433 textureMode = m; 1434 renderingViewPanel.setObjectsTextureMode(m); 1435 firePropertyChange(TEXTURE_MODE,lastTextureMode,textureMode); 1436 } 1437 1438 /** 1439 * 1440 * Return the Texture Blend Color. 1441 * @return the Texture Blend Color in (R,G,B,A). 1442 * 1443 */ 1444 public float [] getTextureBlendColor () 1445 { 1446 return textureBlendColor; 1447 } 1448 1449 /** 1450 * 1451 * Set the Texture Blend Color. 1452 * @param c the Texture Blend Color in (R,G,B,A). 1453 * 1454 */ 1455 public void setTextureBlendColor (float []c) 1456 { 1457 texturePane.setTextureBlendColor(c); 1458 textureBlendColor = c; 1459 } 1460 1461 /** 1462 * 1463 * Internal update of the Texture Blend Color Parameters and fire of an associated property. 1464 * @param c the Texture Blend Color in (R,G,B,A). 1465 * 1466 */ 1467 private void updateTextureBlendColor (float []c) 1468 { 1469 float []lastTextureBlendColor = textureBlendColor; 1470 textureBlendColor = c; 1471 renderingViewPanel.setObjectsTextureBlendColor(c[0],c[1],c[2],c[3]); 1472 firePropertyChange(TEXTURE_BLEND,lastTextureBlendColor, textureBlendColor); 1473 } 1474 1475 /** 1476 * 1477 * Return the Texture Combine RGB Mode. 1478 * @return the Texture Combine RGB Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1479 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1480 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3 1481 * 1482 */ 1483 public int getTextureCombineRGBMode () 1484 { 1485 return textureCombineRGBMode; 1486 } 1487 1488 /** 1489 * 1490 * Set the Texture Combine RGB Mode. 1491 * @param m the Texture Combine RGB Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1492 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1493 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3. 1494 * 1495 */ 1496 public void setTextureCombineRGBMode (int m) 1497 { 1498 texturePane.setTextureCombineRGBMode(m); 1499 textureCombineRGBMode = m; 1500 } 1501 1502 /** 1503 * 1504 * Internal update of the Texture Combine RGB Mode Parameters and fire of an associated property. 1505 * @param m the Texture Combine RGB Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1506 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1507 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3. 1508 * 1509 */ 1510 private void updateTextureCombineRGBMode(int m) 1511 { 1512 int lastTextureCombineRGBMode = textureCombineRGBMode; 1513 textureCombineRGBMode = m; 1514 renderingViewPanel.setObjectsTextureCombineRGBMode(m); 1515 firePropertyChange(TEXTURE_COMBINE_RGB_MODE,lastTextureCombineRGBMode, textureCombineRGBMode); 1516 } 1517 1518 /** 1519 * 1520 * Return the Texture Combine RGB Source. 1521 * @return the Texture Combine RGB Source between TextureAttributes.COMBINE_OBJECT_COLOR, 1522 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1523 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE. 1524 * 1525 */ 1526 public int[] getTextureCombineRGBSource () 1527 { 1528 return textureCombineRGBSource; 1529 } 1530 1531 /** 1532 * 1533 * Set the Texture Combine RGB Source 1534 * @param m the Texture Combine RGB Source (C0,C1,C2) between TextureAttributes.COMBINE_OBJECT_COLOR, 1535 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1536 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE 1537 * 1538 */ 1539 public void setTextureCombineRGBSource (int []m) 1540 { 1541 texturePane.setTextureCombineRGBSource(m); 1542 textureCombineRGBSource = m; 1543 } 1544 1545 /** 1546 * 1547 * Internal update of the Texture Combine RGB Source Parameters and fire of an associated property. 1548 * @param m the Texture Combine RGB Source (C0,C1,C2) between TextureAttributes.COMBINE_OBJECT_COLOR, 1549 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1550 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE. 1551 * 1552 */ 1553 private void updateTextureCombineRGBSource(int []m) 1554 { 1555 int []lastTextureCombineRGBSource = textureCombineRGBSource; 1556 textureCombineRGBSource = m; 1557 renderingViewPanel.setObjectsTextureCombineRGBSource(m); 1558 firePropertyChange(TEXTURE_COMBINE_RGB_SOURCE,lastTextureCombineRGBSource, textureCombineRGBSource); 1559 } 1560 1561 /** 1562 * 1563 * Return the Texture Combine RGB Function. 1564 * @return the Texture Combine RGB Function between TextureAttributes.COMBINE_SRC_COLOR, 1565 * TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR, TextureAttributes.COMBINE_SRC_ALPHA, 1566 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1567 * 1568 */ 1569 public int[] getTextureCombineRGBFunction () 1570 { 1571 return textureCombineRGBFunction; 1572 } 1573 1574 /** 1575 * 1576 * Set the Texture Combine RGB Function. 1577 * @param m the Texture Combine RGB Function (C0,C1,C2) between TextureAttributes.COMBINE_SRC_COLOR, 1578 * TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR, TextureAttributes.COMBINE_SRC_ALPHA, 1579 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1580 * 1581 */ 1582 public void setTextureCombineRGBFunction (int []m) 1583 { 1584 texturePane.setTextureCombineRGBFunction(m); 1585 textureCombineRGBFunction = m; 1586 } 1587 1588 /** 1589 * 1590 * Internal update of the Texture Combine RGB Function Parameters and fire of an associated property. 1591 * @param m the Texture Combine RGB Function (C0,C1,C2) between TextureAttributes.COMBINE_SRC_COLOR, 1592 * TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR, TextureAttributes.COMBINE_SRC_ALPHA, 1593 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1594 * 1595 */ 1596 private void updateTextureCombineRGBFunction(int []m) 1597 { 1598 int []lastTextureCombineRGBFunction = textureCombineRGBFunction; 1599 textureCombineRGBFunction = m; 1600 renderingViewPanel.setObjectsTextureCombineRGBFunction(m); 1601 firePropertyChange(TEXTURE_COMBINE_RGB_FUNCTION,lastTextureCombineRGBFunction, textureCombineRGBFunction); 1602 } 1603 1604 /** 1605 * 1606 * Return the Texture Combine RGB Scale. 1607 * @return the Texture Combine RGB Scale. 1608 * 1609 */ 1610 public int getTextureCombineRGBScale () 1611 { 1612 return textureCombineRGBScale; 1613 } 1614 1615 /** 1616 * 1617 * Set the Texture Combine RGB Scale. 1618 * @param s the Texture Combine RGB Scale. 1619 * 1620 */ 1621 public void setTextureCombineRGBScale (int s) 1622 { 1623 texturePane.setTextureCombineRGBScale(s); 1624 textureCombineRGBScale = s; 1625 } 1626 1627 /** 1628 * 1629 * Internal update of the Texture Combine RGB Scale Parameters and fire of an associated property. 1630 * @param m the Texture Combine RGB Scale. 1631 * 1632 */ 1633 private void updateTextureCombineRGBScale(int m) 1634 { 1635 int lastTextureCombineRGBScale = textureCombineRGBScale; 1636 textureCombineRGBScale = m; 1637 renderingViewPanel.setObjectsTextureCombineRGBScale(m); 1638 firePropertyChange(TEXTURE_COMBINE_RGB_SCALE,lastTextureCombineRGBScale, textureCombineRGBScale); 1639 } 1640 1641 /** 1642 * 1643 * Return the Texture Combine Alpha Mode. 1644 * @return the Texture Combine Alpha Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1645 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1646 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3. 1647 * 1648 */ 1649 public int getTextureCombineAlphaMode () 1650 { 1651 return textureCombineAlphaMode; 1652 } 1653 1654 /** 1655 * 1656 * Set the Texture Combine Alpha Mode. 1657 * @param m the Texture Combine Alpha Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1658 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1659 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3. 1660 * 1661 */ 1662 public void setTextureCombineAlphaMode (int m) 1663 { 1664 texturePane.setTextureCombineAlphaMode(m); 1665 textureCombineAlphaMode = m; 1666 } 1667 1668 /** 1669 * 1670 * Internal update of the Texture Combine Alpha Mode Parameters and fire of an associated property. 1671 * @param m the Texture Combine Alpha Mode between TextureAttributes.COMBINE_REPLACE, TextureAttributes.COMBINE_MODULATE, 1672 * TextureAttributes.COMBINE_ADD, TextureAttributes.COMBINE_ADD_SIGNED, TextureAttributes.COMBINE_SUBTRACT, 1673 * TextureAttributes.COMBINE_INTERPOLATE, TextureAttributes.COMBINE_DOT3. 1674 * 1675 */ 1676 private void updateTextureCombineAlphaMode(int m) 1677 { 1678 int lastTextureCombineAlphaMode = textureCombineAlphaMode; 1679 textureCombineAlphaMode = m; 1680 renderingViewPanel.setObjectsTextureCombineAlphaMode(m); 1681 firePropertyChange(TEXTURE_COMBINE_ALPHA_MODE,lastTextureCombineAlphaMode, textureCombineAlphaMode); 1682 } 1683 1684 /** 1685 * 1686 * Return the Texture Combine Alpha Source. 1687 * @return the Texture Combine Alpha Source between TextureAttributes.COMBINE_OBJECT_COLOR, 1688 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1689 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE. 1690 * 1691 */ 1692 public int[] getTextureCombineAlphaSource () 1693 { 1694 return textureCombineAlphaSource; 1695 } 1696 1697 /** 1698 * 1699 * Set the Texture Combine Alpha Source. 1700 * @param m the Texture Combine Alpha Source (C0,C1,C2) between TextureAttributes.COMBINE_OBJECT_COLOR, 1701 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1702 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE. 1703 * 1704 */ 1705 public void setTextureCombineAlphaSource (int []m) 1706 { 1707 texturePane.setTextureCombineAlphaSource(m); 1708 textureCombineAlphaSource = m; 1709 } 1710 1711 /** 1712 * 1713 * Internal update of the Texture Combine Alpha Source Parameters and fire of an associated property. 1714 * @param m the Texture Combine Alpha Source (C0,C1,C2) between TextureAttributes.COMBINE_OBJECT_COLOR, 1715 * TextureAttributes.COMBINE_TEXTURE_COLOR, TextureAttributes.COMBINE_CONSTANT_COLOR, 1716 * TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE. 1717 * 1718 */ 1719 private void updateTextureCombineAlphaSource(int []m) 1720 { 1721 int []lastTextureCombineAlphaSource = textureCombineAlphaSource; 1722 textureCombineAlphaSource = m; 1723 renderingViewPanel.setObjectsTextureCombineAlphaSource(m); 1724 firePropertyChange(TEXTURE_COMBINE_ALPHA_SOURCE,lastTextureCombineAlphaSource, textureCombineAlphaSource); 1725 } 1726 1727 /** 1728 * 1729 * Return the Texture Combine Alpha Function. 1730 * @return the Texture Combine Alpha Function between TextureAttributes.COMBINE_SRC_ALPHA, 1731 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1732 * 1733 */ 1734 public int[] getTextureCombineAlphaFunction () 1735 { 1736 return textureCombineAlphaFunction; 1737 } 1738 1739 /** 1740 * 1741 * Set the Texture Combine Alpha Function. 1742 * @param m the Texture Combine Alpha Function (C0,C1,C2) between TextureAttributes.COMBINE_SRC_ALPHA, 1743 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1744 * 1745 */ 1746 public void setTextureCombineAlphaFunction (int []m) 1747 { 1748 texturePane.setTextureCombineAlphaFunction(m); 1749 textureCombineAlphaFunction = m; 1750 } 1751 1752 /** 1753 * 1754 * Internal update of the Texture Combine Alpha Function Parameters and fire of an associated property. 1755 * @param m the Texture Combine Alpha Function (C0,C1,C2) between TextureAttributes.COMBINE_SRC_ALPHA, 1756 * TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA. 1757 * 1758 */ 1759 private void updateTextureCombineAlphaFunction(int []m) 1760 { 1761 int []lastTextureCombineAlphaFunction = textureCombineAlphaFunction; 1762 textureCombineAlphaFunction = m; 1763 renderingViewPanel.setObjectsTextureCombineAlphaFunction(m); 1764 firePropertyChange(TEXTURE_COMBINE_ALPHA_FUNCTION,lastTextureCombineAlphaFunction, textureCombineAlphaFunction); 1765 } 1766 1767 /** 1768 * 1769 * Return the Texture Combine Alpha Scale. 1770 * @return the Texture Combine Alpha Scale. 1771 * 1772 */ 1773 public int getTextureCombineAlphaScale () 1774 { 1775 return textureCombineAlphaScale; 1776 } 1777 1778 /** 1779 * 1780 * Set the Texture Combine Alpha Scale. 1781 * @param s the Texture Combine Alpha Scale. 1782 * 1783 */ 1784 public void setTextureCombineAlphaScale (int s) 1785 { 1786 texturePane.setTextureCombineAlphaScale(s); 1787 textureCombineAlphaScale = s; 1788 } 1789 1790 /** 1791 * 1792 * Internal update of the Texture Combine Alpha Scale Parameters and fire of an associated property. 1793 * @param m the Texture Combine Alpha Scale. 1794 * 1795 */ 1796 private void updateTextureCombineAlphaScale(int m) 1797 { 1798 int lastTextureCombineAlphaScale = textureCombineAlphaScale; 1799 textureCombineAlphaScale = m; 1800 renderingViewPanel.setObjectsTextureCombineAlphaScale(m); 1801 firePropertyChange(TEXTURE_COMBINE_ALPHA_SCALE,lastTextureCombineAlphaScale, textureCombineAlphaScale); 1802 } 1803 1804 /** 1805 * 1806 * Convert a Transparency Mode from TransparencyAttributes representation to Internal representation. 1807 * @param m a Transparency Mode in TransparencyAttributes representation. 1808 * @return a Transparency Mode in Internal representation. 1809 * 1810 */ 1811 public static int convertInternTransparencyMode (int m) 1812 { 1813 switch (m) 1814 { 1815 case TransparencyAttributes.BLENDED: 1816 return TRANSPARENCY_MODE_BLENDED; 1817 case TransparencyAttributes.FASTEST: 1818 return TRANSPARENCY_MODE_FASTEST; 1819 case TransparencyAttributes.NICEST: 1820 return TRANSPARENCY_MODE_NICEST; 1821 case TransparencyAttributes.NONE: 1822 return TRANSPARENCY_MODE_NONE; 1823 case TransparencyAttributes.SCREEN_DOOR: 1824 return TRANSPARENCY_MODE_SCREEN_DOOR; 1825 default : 1826 return -1; 1827 } 1828 } 1829 1830 /** 1831 * 1832 * Convert a Transparency Mode from Internal representation to TransparencyAttributes representation. 1833 * @param m a Transparency Mode in Internal representation. 1834 * @return a Transparency Mode in TransparencyAttributes representation. 1835 * 1836 */ 1837 public static int convertExternTransparencyMode (int m) 1838 { 1839 switch (m) 1840 { 1841 case TRANSPARENCY_MODE_BLENDED: 1842 return TransparencyAttributes.BLENDED; 1843 case TRANSPARENCY_MODE_FASTEST: 1844 return TransparencyAttributes.FASTEST; 1845 case TRANSPARENCY_MODE_NICEST: 1846 return TransparencyAttributes.NICEST; 1847 case TRANSPARENCY_MODE_NONE: 1848 return TransparencyAttributes.NONE; 1849 case TRANSPARENCY_MODE_SCREEN_DOOR: 1850 return TransparencyAttributes.SCREEN_DOOR; 1851 default : 1852 return -1; 1853 } 1854 } 1855 1856 /** 1857 * 1858 * Convert a Transparency Source Blend Function from Internal representation to TransparencyAttributes representation. 1859 * @param f a Transparency Source Blend Function in Internal representation. 1860 * @return a Transparency Source Blend Function in TransparencyAttributes representation. 1861 * 1862 */ 1863 public static int convertExternTransparencySrcBlendFunction (int f) 1864 { 1865 switch (f) 1866 { 1867 case TRANSPARENCY_SRC_BLEND_ZERO: 1868 return TransparencyAttributes.BLEND_ZERO; 1869 case TRANSPARENCY_SRC_BLEND_ONE: 1870 return TransparencyAttributes.BLEND_ONE; 1871 case TRANSPARENCY_SRC_BLEND_SRC_ALPHA: 1872 return TransparencyAttributes.BLEND_SRC_ALPHA; 1873 case TRANSPARENCY_SRC_BLEND_ONE_MINUS_SRC_ALPHA: 1874 return TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA; 1875 case TRANSPARENCY_SRC_BLEND_DST_COLOR: 1876 return TransparencyAttributes.BLEND_DST_COLOR; 1877 case TRANSPARENCY_SRC_BLEND_ONE_MINUS_DST_COLOR: 1878 return TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR; 1879 default : 1880 return -1; 1881 } 1882 } 1883 1884 /** 1885 * 1886 * Convert a Transparency Source Blend Function from TransparencyAttributes representation to Internal representation. 1887 * @param f a Transparency Source Blend Function in TransparencyAttributes representation. 1888 * @return a Transparency Source Blend Function in Internal representation. 1889 * 1890 */ 1891 public static int convertInternTransparencySrcBlendFunction (int f) 1892 { 1893 switch (f) 1894 { 1895 case TransparencyAttributes.BLEND_ZERO: 1896 return TRANSPARENCY_SRC_BLEND_ZERO; 1897 case TransparencyAttributes.BLEND_ONE: 1898 return TRANSPARENCY_SRC_BLEND_ONE; 1899 case TransparencyAttributes.BLEND_SRC_ALPHA: 1900 return TRANSPARENCY_SRC_BLEND_SRC_ALPHA; 1901 case TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA: 1902 return TRANSPARENCY_SRC_BLEND_ONE_MINUS_SRC_ALPHA; 1903 case TransparencyAttributes.BLEND_DST_COLOR: 1904 return TRANSPARENCY_SRC_BLEND_DST_COLOR; 1905 case TransparencyAttributes.BLEND_ONE_MINUS_DST_COLOR: 1906 return TRANSPARENCY_SRC_BLEND_ONE_MINUS_DST_COLOR; 1907 default : 1908 return -1; 1909 } 1910 } 1911 1912 /** 1913 * 1914 * Convert a Transparency Destination Blend Function from Internal representation to TransparencyAttributes representation. 1915 * @param f a Transparency Destination Blend Function in Internal representation. 1916 * @return a Transparency Destination Blend Function in TransparencyAttributes representation. 1917 * 1918 */ 1919 public static int convertExternTransparencyDstBlendFunction (int f) 1920 { 1921 switch (f) 1922 { 1923 case TRANSPARENCY_DST_BLEND_ZERO: 1924 return TransparencyAttributes.BLEND_ZERO; 1925 case TRANSPARENCY_DST_BLEND_ONE: 1926 return TransparencyAttributes.BLEND_ONE; 1927 case TRANSPARENCY_DST_BLEND_SRC_ALPHA: 1928 return TransparencyAttributes.BLEND_SRC_ALPHA; 1929 case TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_ALPHA: 1930 return TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA; 1931 case TRANSPARENCY_DST_BLEND_SRC_COLOR: 1932 return TransparencyAttributes.BLEND_SRC_COLOR; 1933 case TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_COLOR: 1934 return TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR; 1935 default : 1936 return -1; 1937 } 1938 } 1939 1940 /** 1941 * 1942 * Convert a Transparency Destination Blend Function from TransparencyAttributes representation to Internal representation. 1943 * @param f a Transparency Destination Blend Function in TransparencyAttributes representation. 1944 * @return a Transparency Destination Blend Function in Internal representation. 1945 * 1946 */ 1947 public static int convertInternTransparencyDstBlendFunction (int f) 1948 { 1949 switch (f) 1950 { 1951 case TransparencyAttributes.BLEND_ZERO: 1952 return TRANSPARENCY_DST_BLEND_ZERO; 1953 case TransparencyAttributes.BLEND_ONE: 1954 return TRANSPARENCY_DST_BLEND_ONE; 1955 case TransparencyAttributes.BLEND_SRC_ALPHA: 1956 return TRANSPARENCY_DST_BLEND_SRC_ALPHA; 1957 case TransparencyAttributes.BLEND_ONE_MINUS_SRC_ALPHA: 1958 return TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_ALPHA; 1959 case TransparencyAttributes.BLEND_SRC_COLOR: 1960 return TRANSPARENCY_DST_BLEND_SRC_COLOR; 1961 case TransparencyAttributes.BLEND_ONE_MINUS_SRC_COLOR: 1962 return TRANSPARENCY_DST_BLEND_ONE_MINUS_SRC_COLOR; 1963 default : 1964 return -1; 1965 } 1966 } 1967 1968 1969 /** 1970 * 1971 * A Main Exemple. 1972 * 1973 */ 1974 public static void main ( String args[] ) 1975 { 1976 final Appearance3DChooserPanel m1 = new Appearance3DChooserPanel(true, true, true, true); 1977 final Appearance3DChooserPanel m2 = new Appearance3DChooserPanel(true, true, true, true); 1978 1979 m1.addPropertyChangeListener(Appearance3DChooserPanel.AMBIENT, new PropertyChangeListener() { 1980 public void propertyChange(PropertyChangeEvent evt) { 1981 System.out.println("AMBIENT : (" + m1.getAmbientColor()[0]+ "," + m1.getAmbientColor()[1] + "," + m1.getAmbientColor()[2]+")"); 1982 }}); 1983 1984 m1.addPropertyChangeListener(Appearance3DChooserPanel.SPECULAR, new PropertyChangeListener() { 1985 public void propertyChange(PropertyChangeEvent evt) { 1986 System.out.println("SPECULAR : (" + m1.getSpecularColor()[0]+ "," + m1.getSpecularColor()[1]+ "," + m1.getSpecularColor()[2]+")"); 1987 }}); 1988 1989 m1.addPropertyChangeListener(Appearance3DChooserPanel.EMISSIVE, new PropertyChangeListener() { 1990 public void propertyChange(PropertyChangeEvent evt) { 1991 System.out.println("EMISSIVE : (" + m1.getEmissiveColor()[0]+ "," + m1.getEmissiveColor()[1] + "," + m1.getEmissiveColor()[2]+")"); 1992 1993 }}); 1994 1995 m1.addPropertyChangeListener(Appearance3DChooserPanel.DIFFUSE, new PropertyChangeListener() { 1996 public void propertyChange(PropertyChangeEvent evt) { 1997 System.out.println("DIFFUSE : (" + m1.getDiffuseColor()[0] + "," + m1.getDiffuseColor()[1] + "," + m1.getDiffuseColor()[2]+")"); 1998 }}); 1999 2000 m1.addPropertyChangeListener(Appearance3DChooserPanel.COLORTARGET, new PropertyChangeListener() { 2001 public void propertyChange(PropertyChangeEvent evt) { 2002 System.out.println("COLORTARGET : (" + m1.getColorTarget() +")"); 2003 }}); 2004 2005 m1.addPropertyChangeListener(Appearance3DChooserPanel.SHININESS, new PropertyChangeListener() { 2006 public void propertyChange(PropertyChangeEvent evt) { 2007 System.out.println("SHININESS : (" + m1.getShininess() + ")"); 2008 }}); 2009 2010 m1.addPropertyChangeListener(Appearance3DChooserPanel.LIGHTING, new PropertyChangeListener() { 2011 public void propertyChange(PropertyChangeEvent evt) { 2012 System.out.println("LIGHTING : (" + m1.getLighting() +")"); 2013 }}); 2014 2015 m1.addPropertyChangeListener(Appearance3DChooserPanel.TRANSPARENCY, new PropertyChangeListener() { 2016 public void propertyChange(PropertyChangeEvent evt) { 2017 System.out.println("TRANSPARENCY : (" + m1.getTransparency() +")"); 2018 }}); 2019 2020 m1.addPropertyChangeListener(Appearance3DChooserPanel.TRANSPARENCY_MODE, new PropertyChangeListener() { 2021 public void propertyChange(PropertyChangeEvent evt) { 2022 System.out.println("TRANSPARENCY_MODE : (" + m1.getTransparencyMode() +")"); 2023 }}); 2024 2025 m1.addPropertyChangeListener(Appearance3DChooserPanel.TRANSPARENCY_SRC_BLEND_FUNCTION, new PropertyChangeListener() { 2026 public void propertyChange(PropertyChangeEvent evt) { 2027 System.out.println("TRANSPARENCY_SRC_BLEND_FUNCTION : (" + m1.getTransparencySrcBlendFunction() +")"); 2028 }}); 2029 2030 m1.addPropertyChangeListener(Appearance3DChooserPanel.TRANSPARENCY_DST_BLEND_FUNCTION, new PropertyChangeListener() { 2031 public void propertyChange(PropertyChangeEvent evt) { 2032 System.out.println("TRANSPARENCY_DST_BLEND_FUNCTION : (" + m1.getTransparencyDstBlendFunction() +")"); 2033 }}); 2034 2035 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_USE, new PropertyChangeListener() { 2036 public void propertyChange(PropertyChangeEvent evt) { 2037 System.out.println("TEXTURE_USE : (" + m1.isTextureSet() +")"); 2038 }}); 2039 2040 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_FILE, new PropertyChangeListener() { 2041 public void propertyChange(PropertyChangeEvent evt) { 2042 System.out.println("TEXTURE_FILE : (" + m1.getTextureFile() +")"); 2043 }}); 2044 2045 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_TRANSFORM, new PropertyChangeListener() { 2046 public void propertyChange(PropertyChangeEvent evt) { 2047 System.out.println("\nTEXTURE_TRANSFORM : \n" + m1.getTextureTransform()); 2048 System.out.println("Scale : x=" + m1.getTextureTransformScaleX() + ", y=" +m1.getTextureTransformScaleY()); 2049 System.out.println("Translation : x=" + m1.getTextureTransformTranslatX() + ", y=" +m1.getTextureTransformTranslatY()); 2050 System.out.println("Rotation : z=" + m1.getTextureTransformRotZ()); 2051 }}); 2052 2053 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_PERSPECTIVE_CORRECTION_MODE, new PropertyChangeListener() { 2054 public void propertyChange(PropertyChangeEvent evt) { 2055 System.out.println("TEXTURE_PERSPECTIVE_CORRECTION_MODE : (" + m1.getTexturePerspectiveCorrectionMode() +")"); 2056 }}); 2057 2058 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_MODE, new PropertyChangeListener() { 2059 public void propertyChange(PropertyChangeEvent evt) { 2060 System.out.println("TEXTURE_MODE : (" + m1.getTextureMode() +")"); 2061 }}); 2062 2063 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_BLEND, new PropertyChangeListener() { 2064 public void propertyChange(PropertyChangeEvent evt) { 2065 System.out.println("TEXTURE_BLEND : (" + 2066 m1.getTextureBlendColor()[0] + "," + 2067 m1.getTextureBlendColor()[1] + "," + 2068 m1.getTextureBlendColor()[2] + "," + 2069 m1.getTextureBlendColor()[3] 2070 + ")"); 2071 }}); 2072 2073 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_MODE, new PropertyChangeListener() { 2074 public void propertyChange(PropertyChangeEvent evt) { 2075 System.out.println("TEXTURE_COMBINE_RGB_MODE : (" + m1.getTextureCombineRGBMode() +")"); 2076 }}); 2077 2078 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_SOURCE, new PropertyChangeListener() { 2079 public void propertyChange(PropertyChangeEvent evt) { 2080 System.out.println("TEXTURE_COMBINE_RGB_SOURCE : (" + 2081 m1.getTextureCombineRGBSource()[0]+"," + 2082 m1.getTextureCombineRGBSource()[1]+"," + 2083 m1.getTextureCombineRGBSource()[2] 2084 + ")"); 2085 }}); 2086 2087 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_FUNCTION, new PropertyChangeListener() { 2088 public void propertyChange(PropertyChangeEvent evt) { 2089 System.out.println("TEXTURE_COMBINE_RGB_FUNCTION : (" + 2090 m1.getTextureCombineRGBFunction()[0]+"," + 2091 m1.getTextureCombineRGBFunction()[1]+"," + 2092 m1.getTextureCombineRGBFunction()[2] 2093 + ")"); 2094 }}); 2095 2096 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_SCALE, new PropertyChangeListener() { 2097 public void propertyChange(PropertyChangeEvent evt) { 2098 System.out.println("TEXTURE_COMBINE_RGB_SCALE : (" + m1.getTextureCombineRGBScale() +")"); 2099 }}); 2100 2101 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_MODE, new PropertyChangeListener() { 2102 public void propertyChange(PropertyChangeEvent evt) { 2103 System.out.println("TEXTURE_COMBINE_ALPHA_MODE : (" + m1.getTextureCombineAlphaMode() +")"); 2104 }}); 2105 2106 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_SOURCE, new PropertyChangeListener() { 2107 public void propertyChange(PropertyChangeEvent evt) { 2108 System.out.println("TEXTURE_COMBINE_ALPHA_SOURCE : (" + 2109 m1.getTextureCombineAlphaSource()[0] + "," + 2110 m1.getTextureCombineAlphaSource()[1] + "," + 2111 m1.getTextureCombineAlphaSource()[2] 2112 + ")"); 2113 }}); 2114 2115 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_FUNCTION, new PropertyChangeListener() { 2116 public void propertyChange(PropertyChangeEvent evt) { 2117 System.out.println("TEXTURE_COMBINE_ALPHA_FUNCTION : (" + 2118 m1.getTextureCombineAlphaFunction()[0] + "," + 2119 m1.getTextureCombineAlphaFunction()[1] + "," + 2120 m1.getTextureCombineAlphaFunction()[2] 2121 + ")"); 2122 }}); 2123 2124 m1.addPropertyChangeListener(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_SCALE, new PropertyChangeListener() { 2125 public void propertyChange(PropertyChangeEvent evt) { 2126 System.out.println("TEXTURE_COMBINE_ALPHA_SCALE : (" + m1.getTextureCombineAlphaScale() +")"); 2127 }}); 2128 2129 JFrame frame1 = new JFrame(); 2130 frame1.getContentPane().setLayout(new GridBagLayout()); 2131 GridBagConstraints c = new GridBagConstraints(); 2132 c.gridx = 0; c.gridy = 0; 2133 c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; 2134 c.gridwidth = GridBagConstraints.REMAINDER; 2135 c.insets = new Insets(10,10,10,10); 2136 frame1.getContentPane().add(m1,c); 2137 c.gridy++; c.gridwidth = 1; 2138 frame1.pack(); 2139 frame1.setVisible(true); 2140 2141 2142 m2.addPropertyChangeListener(new PropertyChangeListener() { 2143 public void propertyChange(PropertyChangeEvent evt) { 2144 if(evt.getPropertyName().compareTo(Appearance3DChooserPanel.AMBIENT) == 0) 2145 { 2146 System.out.println("AMBIENT2 : (" + m2.getAmbientColor()[0]+ "," + m2.getAmbientColor()[1] + "," + m2.getAmbientColor()[2]+")"); 2147 } 2148 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.EMISSIVE) == 0) 2149 { 2150 System.out.println("EMISSIVE2 : (" + m2.getEmissiveColor()[0]+ "," + m2.getEmissiveColor()[1] + "," + m2.getEmissiveColor()[2]+")"); 2151 } 2152 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.SPECULAR) == 0) 2153 { 2154 System.out.println("SPECULAR2 : (" + m2.getSpecularColor()[0]+ "," + m2.getSpecularColor()[1]+ "," + m2.getSpecularColor()[2]+")"); 2155 } 2156 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.DIFFUSE) == 0) 2157 { 2158 System.out.println("DIFFUSE2 : (" + m2.getDiffuseColor()[0] + "," + m2.getDiffuseColor()[1] + "," + m2.getDiffuseColor()[2]+")"); 2159 } 2160 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.COLORTARGET) == 0) 2161 { 2162 System.out.println("COLORTARGET2 : (" + m2.getColorTarget() +")"); 2163 } 2164 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.SHININESS) == 0) 2165 { 2166 System.out.println("SHININESS2 : (" + m2.getShininess() + ")"); 2167 } 2168 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.LIGHTING) == 0) 2169 { 2170 System.out.println("LIGHTING2 : (" + m2.getLighting() +")"); 2171 } 2172 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TRANSPARENCY) == 0) 2173 { 2174 System.out.println("TRANSPARENCY2 : (" + m2.getTransparency() +")"); 2175 } 2176 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TRANSPARENCY_MODE) == 0) 2177 { 2178 System.out.println("TRANSPARENCY_MODE2 : (" + m2.getTransparencyMode() +")"); 2179 } 2180 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TRANSPARENCY_SRC_BLEND_FUNCTION) == 0) 2181 { 2182 System.out.println("TRANSPARENCY_SRC_BLEND_FUNCTION2 : (" + m2.getTransparencySrcBlendFunction() +")"); 2183 } 2184 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TRANSPARENCY_DST_BLEND_FUNCTION) == 0) 2185 { 2186 System.out.println("TRANSPARENCY_DST_BLEND_FUNCTION2 : (" + m2.getTransparencyDstBlendFunction() +")"); 2187 } 2188 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_USE) == 0) 2189 { 2190 System.out.println("TEXTURE_USE2 : (" + m2.isTextureSet() +")"); 2191 } 2192 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_FILE) == 0) 2193 { 2194 System.out.println("TEXTURE_FILE2 : (" + m2.getTextureFile() +")"); 2195 } 2196 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_TRANSFORM) == 0) 2197 { 2198 System.out.println("\nTEXTURE_TRANSFORM2 : \n" + m2.getTextureTransform() ); 2199 System.out.println("Scale : x=" + m2.getTextureTransformScaleX() + ", y=" +m2.getTextureTransformScaleY()); 2200 System.out.println("Translation : x=" + m2.getTextureTransformTranslatX() + ", y=" +m2.getTextureTransformTranslatY()); 2201 System.out.println("Rotation : z=" + m2.getTextureTransformRotZ()); 2202 } 2203 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_PERSPECTIVE_CORRECTION_MODE) == 0) 2204 { 2205 System.out.println("TEXTURE_PERSPECTIVE_CORRECTION_MODE2 : (" + m2.getTexturePerspectiveCorrectionMode() +")"); 2206 } 2207 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_MODE) == 0) 2208 { 2209 System.out.println("TEXTURE_MODE2 : (" + m2.getTextureMode() +")"); 2210 } 2211 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_BLEND) == 0) 2212 { 2213 System.out.println("TEXTURE_BLEND2 : (" + 2214 m2.getTextureBlendColor()[0] + "," + 2215 m2.getTextureBlendColor()[1] + "," + 2216 m2.getTextureBlendColor()[2] + "," + 2217 m2.getTextureBlendColor()[3] 2218 + ")"); 2219 } 2220 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_MODE) == 0) 2221 { 2222 System.out.println("TEXTURE_COMBINE_RGB_MODE2 : (" + m2.getTextureCombineRGBMode() +")"); 2223 } 2224 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_SOURCE) == 0) 2225 { 2226 System.out.println("TEXTURE_COMBINE_RGB_SOURCE2 : (" + 2227 m2.getTextureCombineRGBSource()[0] + "," + 2228 m2.getTextureCombineRGBSource()[1] + "," + 2229 m2.getTextureCombineRGBSource()[2] 2230 + ")"); 2231 } 2232 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_FUNCTION) == 0) 2233 { 2234 System.out.println("TEXTURE_COMBINE_RGB_FUNCTION2 : (" + 2235 m2.getTextureCombineRGBFunction()[0] + "," + 2236 m2.getTextureCombineRGBFunction()[1] + "," + 2237 m2.getTextureCombineRGBFunction()[2] 2238 + ")"); 2239 } 2240 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_RGB_SCALE) == 0) 2241 { 2242 System.out.println("TEXTURE_COMBINE_RGB_SCALE2 : (" + m2.getTextureCombineRGBScale() +")"); 2243 } 2244 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_MODE) == 0) 2245 { 2246 System.out.println("TEXTURE_COMBINE_ALPHA_MODE2 : (" + m2.getTextureCombineAlphaMode() +")"); 2247 } 2248 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_SOURCE) == 0) 2249 { 2250 System.out.println("TEXTURE_COMBINE_ALPHA_SOURCE2 : (" + 2251 m2.getTextureCombineAlphaSource()[0] + "," + 2252 m2.getTextureCombineAlphaSource()[1] + "," + 2253 m2.getTextureCombineAlphaSource()[2] 2254 + ")"); 2255 } 2256 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_FUNCTION) == 0) 2257 { 2258 System.out.println("TEXTURE_COMBINE_ALPHA_FUNCTION2 : (" + 2259 m2.getTextureCombineAlphaFunction()[0] + "," + 2260 m2.getTextureCombineAlphaFunction()[1] + "," + 2261 m2.getTextureCombineAlphaFunction()[2] 2262 + ")"); 2263 } 2264 else if (evt.getPropertyName().compareTo(Appearance3DChooserPanel.TEXTURE_COMBINE_ALPHA_SCALE) == 0) 2265 { 2266 System.out.println("TEXTURE_COMBINE_ALPHA_SCALE2 : (" + m2.getTextureCombineAlphaScale() +")"); 2267 } 2268 2269 }}); 2270 2271 2272 // Test Initialisation 2273 2274 float []emissiveColor = {1.0f,0.9f,0.8f}; 2275 float []ambientColor = {0.7f,0.6f,0.5f}; 2276 float []diffuseColor = {0.4f,0.3f,0.2f}; 2277 float []specularColor = {0.1f,0.0f,1.0f}; 2278 boolean lighting = false; 2279 float shininess = 85.0f; 2280 int colorTarget = Material.SPECULAR; 2281 float transparency = 0.5f; 2282 int transparencyMode = TransparencyAttributes.SCREEN_DOOR; 2283 int transparencySrcBlendFunction = TransparencyAttributes.BLEND_ONE; 2284 int transparencyDstBlendFunction = TransparencyAttributes.BLEND_SRC_ALPHA; 2285 Transform3D textureTransform = new Transform3D(); ////////////////////// 2286 boolean textureUse = true; 2287 URL textureFile = (new Info()).getClass().getResource("resources/TexturePanel-2.png"); 2288 int texturePerspectiveCorrectionMode = TextureAttributes.FASTEST; 2289 int textureMode = TextureAttributes.REPLACE; 2290 float []textureBlendColor = {0.1f,0.2f,0.3f,0.4f}; 2291 int textureCombineRGBMode = TextureAttributes.COMBINE_INTERPOLATE; 2292 int []textureCombineRGBSource = {TextureAttributes.COMBINE_OBJECT_COLOR, 2293 TextureAttributes.COMBINE_CONSTANT_COLOR, 2294 TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE}; 2295 int []textureCombineRGBFunction = {TextureAttributes.COMBINE_SRC_ALPHA, 2296 TextureAttributes.COMBINE_ONE_MINUS_SRC_COLOR, 2297 TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA}; 2298 int textureCombineRGBScale = 2; 2299 int textureCombineAlphaMode = TextureAttributes.COMBINE_DOT3; 2300 int []textureCombineAlphaSource = {TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE, 2301 TextureAttributes.COMBINE_TEXTURE_COLOR, 2302 TextureAttributes.COMBINE_OBJECT_COLOR}; 2303 int []textureCombineAlphaFunction = {TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA, 2304 TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA, 2305 TextureAttributes.COMBINE_ONE_MINUS_SRC_ALPHA}; 2306 int textureCombineAlphaScale = 4; 2307 2308 2309 // Set init Value 2310 2311 m2.setAmbientColor(ambientColor); 2312 m2.setDiffuseColor(diffuseColor); 2313 m2.setEmissiveColor(emissiveColor); 2314 m2.setSpecularColor(specularColor); 2315 m2.setShininess(shininess); 2316 m2.setColorTarget(colorTarget); 2317 m2.setLighting(lighting); 2318 m2.setTransparency(transparency); 2319 m2.setTransparencyMode(transparencyMode); 2320 m2.setTransparencySrcBlendFunction(transparencySrcBlendFunction); 2321 m2.setTransparencyDstBlendFunction(transparencyDstBlendFunction); 2322 m2.setTextureUse(textureUse); 2323 m2.setTextureTransform(textureTransform); 2324 m2.setTextureTransformScaleX(4); 2325 m2.setTextureTransformScaleY(2); 2326 m2.setTextureTransformTranslatX(0.5f); 2327 m2.setTextureTransformTranslatY(1); 2328 m2.setTextureTransformRotZ(1.67f); 2329 m2.setTextureFile(textureFile); 2330 m2.setTexturePerspectiveCorrectionMode(texturePerspectiveCorrectionMode); 2331 m2.setTextureMode(textureMode); 2332 m2.setTextureBlendColor(textureBlendColor); 2333 m2.setTextureCombineRGBMode(textureCombineRGBMode); 2334 m2.setTextureCombineRGBSource(textureCombineRGBSource); 2335 m2.setTextureCombineRGBFunction(textureCombineRGBFunction); 2336 m2.setTextureCombineRGBScale(textureCombineRGBScale); 2337 m2.setTextureCombineAlphaMode(textureCombineAlphaMode); 2338 m2.setTextureCombineAlphaSource(textureCombineAlphaSource); 2339 m2.setTextureCombineAlphaFunction(textureCombineAlphaFunction); 2340 m2.setTextureCombineAlphaScale(textureCombineAlphaScale); 2341 2342 2343 JFrame frame2 = new JFrame(); 2344 frame2.getContentPane().setLayout(new GridBagLayout()); 2345 GridBagConstraints c2 = new GridBagConstraints(); 2346 c2.gridx = 0; c2.gridy = 0; 2347 c2.weightx = 1; c2.weighty = 1; c2.fill = GridBagConstraints.BOTH; 2348 c2.gridwidth = GridBagConstraints.REMAINDER; 2349 c2.insets = new Insets(10,10,10,10); 2350 frame2.getContentPane().add(m2,c2); 2351 frame2.pack(); 2352 frame2.setVisible(true); 2353 2354 while(true) 2355 { 2356 try{ 2357 Thread.currentThread(); 2358 Thread.sleep(60000); //sleep for 60000 ms 2359 } 2360 catch(Exception ie){ 2361 //If this thread was intrrupted by nother thread 2362 } 2363 2364 if(!frame1.isVisible() && !frame2.isVisible()) 2365 System.exit(0); 2366 } 2367 2368 } 2369 2370 2371 }