Subversion Repositories AndroidProjects

Rev

Rev 205 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
205 chris 1
package com.gebauz.Bauzoid.graphics.model;
2
 
3
public class VertexAttribute
4
{
5
        // we only support a subset of the full SUX attribute list since OpenGL ES 2.0 can
6
        // only have 8 attributes per vertex
7
 
8
        public static final int POSITION = 0;
9
        public static final int COLOR = 1;
10
        public static final int NORMAL = 2;
11
        public static final int TEXCOORD0 = 3;
12
        public static final int TEXCOORD1 = 4;
13
        public static final int BLENDINDICES = 5;
14
        public static final int BLENDWEIGHTS = 6;
15
        public static final int GENERIC = 7;
16
 
17
        private int mAttribType = -1;
18
        private int mCoordsPerElement = 0;
19
        private int mByteOffset = 0;
20
 
21
        /** Constructor. */
22
        public VertexAttribute(int attribType, int coordsPerElement, int byteOffset)
23
        {
24
                mAttribType = attribType;
25
                mCoordsPerElement = coordsPerElement;
26
                mByteOffset = byteOffset;
27
        }
28
 
29
        /** Get the attribute type. */
245 chris 30
        public final int getAttribType()
205 chris 31
        {
32
                return mAttribType;
33
        }
34
 
35
        /** Get the number of coordinates per element - 2, 3 or 4. */
36
        public final int getCoordsPerElement()
37
        {
38
                return mCoordsPerElement;              
39
        }
40
 
41
        /** Get the byte offset within an element - the first one (or the only one in an individual stream) is always 0. */
42
        public final int getByteOffset()
43
        {
44
                return mByteOffset;
45
        }
46
 
47
        /** Check if valid attribute type. */
48
        public static final boolean isValidType(int type)
49
        {
50
                switch (type)
51
                {
52
                case 0: // Generic
53
                case 1: // Position
54
                case 2: // Normal
55
                case 3: // Color
56
                case 7: // TexCoord0
57
                case 8: // TexCoord1;
58
                case 15: // Blend Indices
59
                case 16: // Blend Weights
60
                        return true;
61
                default:
62
                        return false;          
63
                }
64
        }
65
 
66
        /** Convert SUX attribute type to internal. */
67
        public static final int toInternalType(int suxType)
68
        {
69
                switch (suxType)
70
                {
71
                case 0: return GENERIC;
72
                case 1: return POSITION;
73
                case 2: return NORMAL;
74
                case 3: return COLOR;
75
                case 7: return TEXCOORD0;
76
                case 8: return TEXCOORD1;
77
                case 15: return BLENDINDICES;
78
                case 16: return BLENDWEIGHTS;
79
                default: return -1;            
80
                }
81
        }
82
}
83