9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.scene.paint;
27
28 import com.sun.javafx.beans.event.AbstractNotifyListener;
29 import com.sun.javafx.sg.prism.NGPhongMaterial;
30 import com.sun.javafx.tk.Toolkit;
31 import javafx.beans.Observable;
32 import javafx.beans.property.DoubleProperty;
33 import javafx.beans.property.ObjectProperty;
34 import javafx.beans.property.SimpleDoubleProperty;
35 import javafx.beans.property.SimpleObjectProperty;
36 import javafx.scene.AmbientLight;
37 import javafx.scene.PointLight;
38 import javafx.scene.image.Image;
39
40 /**
41 * The {@code PhongMaterial} class provides definitions of properties that
42 * represent a Phong shaded material. It describes the interaction of
43 * light with the surface of the {@code Mesh} it is applied to. The {@code PhongMaterial}
44 * reflects light in terms of a diffuse and specular component together with
45 * an ambient and a self illumination term. The color of a point on a geometric
46 * surface is mathematical function of these four components.
47 * <p>
48 * The color is computed by the following equation:
427 return selfIlluminationMap;
428 }
429
430 @Override
431 void setDirty(boolean value) {
432 super.setDirty(value);
433 if (!value) {
434 diffuseColorDirty = false;
435 specularColorDirty = false;
436 specularPowerDirty = false;
437 diffuseMapDirty = false;
438 specularMapDirty = false;
439 bumpMapDirty = false;
440 selfIlluminationMapDirty = false;
441 }
442 }
443
444 /** The peer node created by the graphics Toolkit/Pipeline implementation */
445 private NGPhongMaterial peer;
446
447 /**
448 * @treatAsPrivate implementation detail
449 * @deprecated This is an internal API that is not intended for use and will be removed in the next version
450 */
451 @Deprecated
452 @Override
453 public NGPhongMaterial impl_getNGMaterial() {
454 if (peer == null) {
455 peer = new NGPhongMaterial();
456 }
457 return peer;
458 }
459
460 /**
461 * @treatAsPrivate implementation detail
462 * @deprecated This is an internal API that is not intended for use and will be removed in the next version
463 */
464 @Deprecated
465 @Override
466 public void impl_updatePG(){
467 if (!isDirty()) {
468 return;
469 }
470
471 final NGPhongMaterial pMaterial = impl_getNGMaterial();
472 if (diffuseColorDirty) {
473 pMaterial.setDiffuseColor(getDiffuseColor() == null ? null
474 : Toolkit.getPaintAccessor().getPlatformPaint(getDiffuseColor()));
475 }
476 if (specularColorDirty) {
477 pMaterial.setSpecularColor(getSpecularColor() == null ? null
478 : Toolkit.getPaintAccessor().getPlatformPaint(getSpecularColor()));
479 }
480 if (specularPowerDirty) {
481 pMaterial.setSpecularPower((float)getSpecularPower());
482 }
483 if (diffuseMapDirty) {
484 pMaterial.setDiffuseMap(getDiffuseMap()
485 == null ? null : getDiffuseMap().impl_getPlatformImage());
486 }
487 if (specularMapDirty) {
488 pMaterial.setSpecularMap(getSpecularMap()
489 == null ? null : getSpecularMap().impl_getPlatformImage());
490 }
491 if (bumpMapDirty) {
492 pMaterial.setBumpMap(getBumpMap()
493 == null ? null : getBumpMap().impl_getPlatformImage());
494 }
495 if (selfIlluminationMapDirty) {
496 pMaterial.setSelfIllumMap(getSelfIlluminationMap()
497 == null ? null : getSelfIlluminationMap().impl_getPlatformImage());
498 }
499
500 setDirty(false);
501 }
502
503 @Override public String toString() {
504 return "PhongMaterial[" + "diffuseColor=" + getDiffuseColor() +
505 ", specularColor=" + getSpecularColor() +
506 ", specularPower=" + getSpecularPower() +
507 ", diffuseMap=" + getDiffuseMap() +
508 ", specularMap=" + getSpecularMap() +
509 ", bumpMap=" + getBumpMap() +
510 ", selfIlluminationMap=" + getSelfIlluminationMap() + "]";
511 }
512
513 }
|
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package javafx.scene.paint;
27
28 import com.sun.javafx.beans.event.AbstractNotifyListener;
29 import com.sun.javafx.scene.paint.MaterialHelper;
30 import com.sun.javafx.sg.prism.NGPhongMaterial;
31 import com.sun.javafx.tk.Toolkit;
32 import javafx.beans.Observable;
33 import javafx.beans.property.DoubleProperty;
34 import javafx.beans.property.ObjectProperty;
35 import javafx.beans.property.SimpleDoubleProperty;
36 import javafx.beans.property.SimpleObjectProperty;
37 import javafx.scene.AmbientLight;
38 import javafx.scene.PointLight;
39 import javafx.scene.image.Image;
40
41 /**
42 * The {@code PhongMaterial} class provides definitions of properties that
43 * represent a Phong shaded material. It describes the interaction of
44 * light with the surface of the {@code Mesh} it is applied to. The {@code PhongMaterial}
45 * reflects light in terms of a diffuse and specular component together with
46 * an ambient and a self illumination term. The color of a point on a geometric
47 * surface is mathematical function of these four components.
48 * <p>
49 * The color is computed by the following equation:
428 return selfIlluminationMap;
429 }
430
431 @Override
432 void setDirty(boolean value) {
433 super.setDirty(value);
434 if (!value) {
435 diffuseColorDirty = false;
436 specularColorDirty = false;
437 specularPowerDirty = false;
438 diffuseMapDirty = false;
439 specularMapDirty = false;
440 bumpMapDirty = false;
441 selfIlluminationMapDirty = false;
442 }
443 }
444
445 /** The peer node created by the graphics Toolkit/Pipeline implementation */
446 private NGPhongMaterial peer;
447
448 @Override
449 NGPhongMaterial getNGMaterial() {
450 if (peer == null) {
451 peer = new NGPhongMaterial();
452 }
453 return peer;
454 }
455
456 @Override
457 void updatePG(){
458 if (!isDirty()) {
459 return;
460 }
461
462 final NGPhongMaterial pMaterial = MaterialHelper.getNGMaterial(this);
463 if (diffuseColorDirty) {
464 pMaterial.setDiffuseColor(getDiffuseColor() == null ? null
465 : Toolkit.getPaintAccessor().getPlatformPaint(getDiffuseColor()));
466 }
467 if (specularColorDirty) {
468 pMaterial.setSpecularColor(getSpecularColor() == null ? null
469 : Toolkit.getPaintAccessor().getPlatformPaint(getSpecularColor()));
470 }
471 if (specularPowerDirty) {
472 pMaterial.setSpecularPower((float)getSpecularPower());
473 }
474 if (diffuseMapDirty) {
475 pMaterial.setDiffuseMap(getDiffuseMap()
476 == null ? null : Toolkit.getImageAccessor().getPlatformImage(getDiffuseMap()));
477 }
478 if (specularMapDirty) {
479 pMaterial.setSpecularMap(getSpecularMap()
480 == null ? null : Toolkit.getImageAccessor().getPlatformImage(getSpecularMap()));
481 }
482 if (bumpMapDirty) {
483 pMaterial.setBumpMap(getBumpMap()
484 == null ? null : Toolkit.getImageAccessor().getPlatformImage(getBumpMap()));
485 }
486 if (selfIlluminationMapDirty) {
487 pMaterial.setSelfIllumMap(getSelfIlluminationMap()
488 == null ? null : Toolkit.getImageAccessor().getPlatformImage(getSelfIlluminationMap()));
489 }
490
491 setDirty(false);
492 }
493
494 @Override public String toString() {
495 return "PhongMaterial[" + "diffuseColor=" + getDiffuseColor() +
496 ", specularColor=" + getSpecularColor() +
497 ", specularPower=" + getSpecularPower() +
498 ", diffuseMap=" + getDiffuseMap() +
499 ", specularMap=" + getSpecularMap() +
500 ", bumpMap=" + getBumpMap() +
501 ", selfIlluminationMap=" + getSelfIlluminationMap() + "]";
502 }
503
504 }
|