3030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131 */
3232package com .jme3 .shader ;
33- import com .jme3 .math .*;
33+
34+ import com .jme3 .math .ColorRGBA ;
35+ import com .jme3 .math .Matrix3f ;
36+ import com .jme3 .math .Matrix4f ;
37+ import com .jme3 .math .Vector2f ;
38+ import com .jme3 .math .Vector3f ;
39+ import com .jme3 .math .Vector4f ;
3440import com .jme3 .shader .bufferobject .BufferObject ;
35- import com .jme3 .texture .*;
41+ import com .jme3 .texture .Texture ;
42+ import com .jme3 .texture .Texture2D ;
43+ import com .jme3 .texture .Texture3D ;
44+ import com .jme3 .texture .TextureArray ;
45+ import com .jme3 .texture .TextureCubeMap ;
46+
3647public enum VarType {
3748
38- Float ("float" ,float .class ,Float .class ),
39- Vector2 ("vec2" ,Vector2f .class ),
40- Vector3 ("vec3" ,Vector3f .class ),
41- Vector4 ("vec4" ,Vector4f .class , ColorRGBA .class ),
42-
43- IntArray (true ,false ,"int" ,int [].class ,Integer [].class ),
44- FloatArray (true ,false ,"float" ,float [].class ,Float [].class ),
45- Vector2Array (true ,false ,"vec2" ,Vector2f [].class ),
46- Vector3Array (true ,false ,"vec3" ,Vector3f [].class ),
47- Vector4Array (true ,false ,"vec4" ,Vector4f [].class ),
48-
49- Boolean ("bool" ,Boolean .class ,boolean .class ),
50-
51- Matrix3 (true ,false ,"mat3" ,Matrix3f .class ),
52- Matrix4 (true ,false ,"mat4" ,Matrix4f .class ),
53-
54- Matrix3Array (true ,false ,"mat3" ,Matrix3f [].class ),
55- Matrix4Array (true ,false ,"mat4" ,Matrix4f [].class ),
56-
57- TextureBuffer (false ,true ,"sampler1D|sampler1DShadow" ),
58- Texture2D (false ,true ,"sampler2D|sampler2DShadow" ,Texture2D .class ,Texture .class ),
59- Texture3D (false ,true ,"sampler3D" ,Texture3D .class ,Texture .class ),
60- TextureArray (false ,true ,"sampler2DArray|sampler2DArrayShadow" ,TextureArray .class ,Texture .class ),
61- TextureCubeMap (false ,true ,"samplerCube" ,TextureCubeMap .class ,Texture .class ),
62- Int ("int" ,int .class ,Integer .class ),
63- UniformBufferObject (false , false , "custom" ,BufferObject .class ),
64- ShaderStorageBufferObject (false , false , "custom" ,BufferObject .class );
49+ Float ("float" , float .class , Float .class ),
50+ Vector2 ("vec2" , Vector2f .class ),
51+ Vector3 ("vec3" , Vector3f .class ),
52+ Vector4 ("vec4" , Vector4f .class , ColorRGBA .class ),
53+
54+ IntArray (true , false , "int" , int [].class , Integer [].class ),
55+ FloatArray (true , false , "float" , float [].class , Float [].class ),
56+ Vector2Array (true , false , "vec2" , Vector2f [].class ),
57+ Vector3Array (true , false , "vec3" , Vector3f [].class ),
58+ Vector4Array (true , false , "vec4" , Vector4f [].class ),
59+
60+ Boolean ("bool" , Boolean .class , boolean .class ),
61+
62+ Matrix3 (true , false , "mat3" , Matrix3f .class ),
63+ Matrix4 (true , false , "mat4" , Matrix4f .class ),
64+
65+ Matrix3Array (true , false , "mat3" , Matrix3f [].class ),
66+ Matrix4Array (true , false , "mat4" , Matrix4f [].class ),
67+
68+ TextureBuffer (false , true , "sampler1D|sampler1DShadow" ),
69+ Texture2D (false , true , "sampler2D|sampler2DShadow" , Texture2D .class , Texture .class ),
70+ Texture3D (false , true , "sampler3D" , Texture3D .class , Texture .class ),
71+ TextureArray (false , true , "sampler2DArray|sampler2DArrayShadow" , TextureArray .class , Texture .class ),
72+ TextureCubeMap (false , true , "samplerCube" , TextureCubeMap .class , Texture .class ),
73+ Int ("int" , int .class , Integer .class ),
74+ UniformBufferObject (false , false , "custom" , BufferObject .class ),
75+ ShaderStorageBufferObject (false , false , "custom" , BufferObject .class );
6576
6677 private boolean usesMultiData = false ;
6778 private boolean textureType = false ;
68- final private String glslType ;
69- private Class <?> javaTypes [] ;
70-
71- VarType (String glslType ,Class <?> ...javaTypes ){
79+ private final String glslType ;
80+ private Class <?>[] javaTypes ;
81+
82+ VarType (String glslType , Class <?>... javaTypes ) {
7283 this .glslType = glslType ;
7384 if (javaTypes != null ) {
7485 this .javaTypes = javaTypes ;
7586 } else {
7687 this .javaTypes = new Class <?>[0 ];
7788 }
78-
7989 }
8090
81-
8291 VarType (boolean multiData , boolean textureType , String glslType , Class <?>... javaTypes ) {
83- usesMultiData = multiData ;
92+ this . usesMultiData = multiData ;
8493 this .textureType = textureType ;
8594 this .glslType = glslType ;
8695 if (javaTypes != null ) {
@@ -89,25 +98,28 @@ public enum VarType {
8998 this .javaTypes = new Class <?>[0 ];
9099 }
91100 }
92-
101+
93102 /**
94103 * Check if the passed object is of a type mapped to this VarType
104+ *
95105 * @param o Object to check
96106 * @return true if the object type is mapped to this VarType
97107 */
98- public boolean isOfType (Object o ){
99- for (Class <?> c : javaTypes ){
100- if (c .isAssignableFrom (o .getClass ()))return true ;
108+ public boolean isOfType (Object o ) {
109+ for (Class <?> c : javaTypes ) {
110+ if (c .isAssignableFrom (o .getClass ())) {
111+ return true ;
112+ }
101113 }
102114 return false ;
103115 }
104-
105116
106117 /**
107118 * Get the java types mapped to this VarType
119+ *
108120 * @return an array of classes mapped to this VarType
109121 */
110- public Class <?>[] getJavaType (){
122+ public Class <?>[] getJavaType () {
111123 return javaTypes ;
112124 }
113125
@@ -121,6 +133,6 @@ public boolean usesMultiData() {
121133
122134 public String getGlslType () {
123135 return glslType ;
124- }
136+ }
125137
126138}
0 commit comments