开发者

Android "Open GL"

开发者 https://www.devze.com 2023-02-12 20:46 出处:网络
I want to draw an Hexagon but i cant figure out how to set up the coordinates right now i have something like.......

I want to draw an Hexagon but i cant figure out how to set up the coordinates

right now i have something like.......

private short[] _indicesArray = {0, 1, 2, 6, 7, 8, 3, 4, 5, 2, 5, 7};

every three is a tr开发者_高级运维iangle... something like below /\ |/| /


Actually i found out how :)

indices_Array, is the order in which i want to draw my points

it is in the coordinates array where i specify my plotting points


float L = 0.15f; // this is length of each side//

    float root;
//this will create a regular hexagon
        private float[] initHexagon() {
             root = (float) Math.sqrt(3)/2f;
            float[] hexagon = new float[12];
                hexagon[0]= L;
                hexagon[1]= 0;
                hexagon[2]= L/2f;
                hexagon[3]= L*root;
                hexagon[4]= -L/2f;
                hexagon[5]= L * root;

                hexagon[6]= -L;
                hexagon[7]= 0;
                hexagon[8]= -L/2f;
                hexagon[9]= -L * root;
                hexagon[10]= L/2f;
                hexagon[11]= -L * root;
                return hexagon;
        }

    glDrawArrays(GL_TRIANGLE_FAN, 0, 12); //use glDrawArrays to draw vertices
0

精彩评论

暂无评论...
验证码 换一张
取 消