1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.graphics.g3d.environment; 18 19 import com.badlogic.gdx.graphics.Color; 20 import com.badlogic.gdx.math.Vector3; 21 22 public class DirectionalLight extends BaseLight<DirectionalLight> { 23 public final Vector3 direction = new Vector3(); 24 25 public DirectionalLight setDirection(float directionX, float directionY, float directionZ) { 26 this.direction.set(directionX, directionY, directionZ); 27 return this; 28 } 29 30 public DirectionalLight setDirection(Vector3 direction) { 31 this.direction.set(direction); 32 return this; 33 } 34 35 public DirectionalLight set (final DirectionalLight copyFrom) { 36 return set(copyFrom.color, copyFrom.direction); 37 } 38 39 public DirectionalLight set (final Color color, final Vector3 direction) { 40 if (color != null) this.color.set(color); 41 if (direction != null) this.direction.set(direction).nor(); 42 return this; 43 } 44 45 public DirectionalLight set (final float r, final float g, final float b, final Vector3 direction) { 46 this.color.set(r, g, b, 1f); 47 if (direction != null) this.direction.set(direction).nor(); 48 return this; 49 } 50 51 public DirectionalLight set (final Color color, final float dirX, final float dirY, final float dirZ) { 52 if (color != null) this.color.set(color); 53 this.direction.set(dirX, dirY, dirZ).nor(); 54 return this; 55 } 56 57 public DirectionalLight set (final float r, final float g, final float b, final float dirX, final float dirY, final float dirZ) { 58 this.color.set(r, g, b, 1f); 59 this.direction.set(dirX, dirY, dirZ).nor(); 60 return this; 61 } 62 63 @Override 64 public boolean equals (Object arg0) { 65 return (arg0 instanceof DirectionalLight) ? equals((DirectionalLight)arg0) : false; 66 } 67 68 public boolean equals (final DirectionalLight other) { 69 return (other != null) && ((other == this) || ((color.equals(other.color) && direction.equals(other.direction)))); 70 } 71 } 72