Home | History | Annotate | Download | only in attributes
      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.attributes;
     18 
     19 import com.badlogic.gdx.graphics.g3d.Attribute;
     20 import com.badlogic.gdx.math.MathUtils;
     21 import com.badlogic.gdx.utils.NumberUtils;
     22 
     23 public class FloatAttribute extends Attribute {
     24 	public static final String ShininessAlias = "shininess";
     25 	public static final long Shininess = register(ShininessAlias);
     26 
     27 	public static FloatAttribute createShininess (float value) {
     28 		return new FloatAttribute(Shininess, value);
     29 	}
     30 
     31 	public static final String AlphaTestAlias = "alphaTest";
     32 	public static final long AlphaTest = register(AlphaTestAlias);
     33 
     34 	public static FloatAttribute createAlphaTest (float value) {
     35 		return new FloatAttribute(AlphaTest, value);
     36 	}
     37 
     38 	public float value;
     39 
     40 	public FloatAttribute (long type) {
     41 		super(type);
     42 	}
     43 
     44 	public FloatAttribute (long type, float value) {
     45 		super(type);
     46 		this.value = value;
     47 	}
     48 
     49 	@Override
     50 	public Attribute copy () {
     51 		return new FloatAttribute(type, value);
     52 	}
     53 
     54 	@Override
     55 	public int hashCode () {
     56 		int result = super.hashCode();
     57 		result = 977 * result + NumberUtils.floatToRawIntBits(value);
     58 		return result;
     59 	}
     60 
     61 	@Override
     62 	public int compareTo (Attribute o) {
     63 		if (type != o.type) return (int)(type - o.type);
     64 		final float v = ((FloatAttribute)o).value;
     65 		return MathUtils.isEqual(value, v) ? 0 : value < v ? -1 : 1;
     66 	}
     67 }
     68