• Create Account

Banner advertising on our site currently available from just \$5!

### #Actualvoodoodrul

Posted 03 July 2013 - 06:38 PM

Thanks Sponji. You've been a big help.

After spending  most of the night being frustrated, I just took a step back. The solution is now working well. I am using interleaved vertex, normal, color and texcoord arrays, but I'm having trouble dealing with the degenerative verticies

WorldChunk.buildMesh() calls

verticies.add(Block.generate(i, j, k, EXPOSED_FACES, new float[]{0.2f, 1.0f, 0.2f}));

Block.generate(x,y,z,faces, colors) produces a vertex array including degenerates, like this:

public static FloatBuffer generate(float x, float y, float z, boolean[] faces, float[] color) {
float[][] cubeFaces = new float[][]{
//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0
},
...
//back face
new float[]{
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 1f,
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,// v4-v7-v6 (back)
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,
(x+1), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 0f,
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y), (z),0,0,0,0,0,0,0,0
}
};
int faceCount = 0;
for (int i = 0; i < faces.length; i++) {
if (faces[i] == true) {
faceCount++;
}
}

float[] values = new float[faceCount * 11 * 7];

int ptr = 0;
float[] degenerate = new float[11];   //store the previous vertex from some other face draw to use as our next degenerate
boolean degen = false;                    //Have we processed an earlier face and created a degenerate ?
for (int i = 0; i < faces.length; i++) {  //foreach face
if (faces[i] == true) {                     //if this face is to be drawn
float[] face = cubeFaces[i];     //get the vertex data for the face

for (int j = 0; j < face.length; j++) {    //Copy the vertex data into the return array
if (degen && j < 11) {                    //prepend the previous degenerate vertex for the next draw
values[ptr] = degenerate[j];
} else {
values[ptr] = face[j];                //Otherwise just copy the face vertex data as-is
}
ptr++;
if (j > 66) {                                    //Store a degenerate vertex by copying the last interleaved vertex data from this draw
degenerate[j-66] = face[j];
degen = true;
}
}
}
}
return Util.getFloatBuffer(values);      //Return the final floatbuffer
}



Are my degenerate verticies all wrong? I thought all I need to do is declare the same x,y,z from a previous draw, so I could not do the hacky stuff here like remembering the last vertex from an earlier face.

Can't I just stick the degenerate in the vertex data like this?

//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0    //degenerate
},

### #2voodoodrul

Posted 03 July 2013 - 06:32 PM

Thanks Sponji. You've been a big help.

After spending  most of the night being frustrated, I just took a step back. The solution is now working well. I am using interleaved vertex, normal, color and texcoord arrays, but I'm having trouble dealing with the degenerative verticies

WorldChunk.buildMesh() calls

verticies.add(Block.generate(i, j, k, EXPOSED_FACES, new float[]{0.2f, 1.0f, 0.2f}));

Block.generate(x,y,z,faces, colors) produces a vertex array including degenerates, like this:

public static FloatBuffer generate(float x, float y, float z, boolean[] faces, float[] color) {
float[][] cubeFaces = new float[][]{
//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0
},
...
//back face
new float[]{
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 1f,
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,// v4-v7-v6 (back)
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,
(x+1), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 0f,
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y), (z),0,0,0,0,0,0,0,0
}
};
int faceCount = 0;
for (int i = 0; i < faces.length; i++) {
if (faces[i] == true) {
faceCount++;
}
}

float[] values = new float[faceCount * 11 * 7];

int ptr = 0;
float[] degenerate = new float[11];   //store the previous vertex from some other face draw to use as our next degenerate
boolean degen = false;                    //Have we processed an earlier face and created a degenerate ?
for (int i = 0; i < faces.length; i++) {  //foreach face
if (faces[i] == true) {                     //if this face is to be drawn
float[] face = cubeFaces[i];     //get the vertex data for the face

for (int j = 0; j < face.length; j++) {    //Copy the vertex data into the return array
if (degen && j < 11) {                    //prepend the previous degenerate vertex for the next draw
values[ptr] = degenerate[j];
} else {
values[ptr] = face[j];                //Otherwise just copy the face vertex data as-is
}
ptr++;
if (j > 66) {                                    //Store a degenerate vertex by copying the last interleaved vertex data from this draw
degenerate[j-66] = face[j];
degen = true;
}
}
}
}
return Util.getFloatBuffer(values);      //Return the final floatbuffer
}

Are my degenerate verticies all wrong? I thought all I need to do is declare the same x,y,z from a previous draw, so I could not do the hacky stuff here like remembering the last vertex from an earlier face.

Can't I just stick the degenerate in the vertex data like this?

//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0    //degenerate
},

### #1voodoodrul

Posted 03 July 2013 - 02:21 PM

Thanks Sponji. You've been a big help.

After spending  most of the night being frustrated, I just took a step back. The solution is now working well. I am using interleaved vertex, normal, color and texcoord arrays, but I'm having trouble dealing with the degenerative verticies

WorldChunk.buildMesh() calls

verticies.add(Block.generate(i, j, k, EXPOSED_FACES, new float[]{0.2f, 1.0f, 0.2f}));

Block.generate(x,y,z,faces, colors) produces a vertex array including degenerates, like this:

public static FloatBuffer generate(float x, float y, float z, boolean[] faces, float[] color) {
float[][] cubeFaces = new float[][]{
//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0
},
//Right face
new float[]{
(x+1), (y+1),(z+1), 1f, 0f, 0f, color[0], color[1], color[2], 0f, 0f,
(x+1), (y),(z+1), 1f, 0f, 0f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y), (z), 1f, 0f, 0f, color[0], color[1], color[2], 1f, 1f, // v0-v3-v4 (right)
(x+1), (y), (z), 1f, 0f, 0f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1), (z), 1f, 0f, 0f, color[0], color[1], color[2], 1f, 0f,
(x+1), (y+1),(z+1), 1f, 0f, 0f, color[0], color[1], color[2], 0f, 0f, // v4-v5-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0
},
//top face
new float[]{
(x+1), (y+1),(z+1), 0f, 1f, 0f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1), (z), 0f, 1f, 0f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1), (z), 0f, 1f, 0f, color[0], color[1], color[2], 0f, 0f, // v0-v5-v6 (top)
(x), (y+1), (z), 0f, 1f, 0f, color[0], color[1], color[2], 0f, 0f,
(x), (y+1),(z+1), 0f, 1f, 0f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y+1),(z+1), 0f, 1f, 0f, color[0], color[1], color[2], 1f, 1f, // v6-v1-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0
},
//left face
new float[]{
(x), (y+1),(z+1), -1f, 0f, 0f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1), (z), -1f, 0f, 0f, color[0], color[1], color[2], 0f, 0f,
(x), (y), (z), -1f, 0f, 0f, color[0], color[1], color[2], 0f, 1f, // v1-v6-v7 (left)
(x), (y), (z), -1f, 0f, 0f, color[0], color[1], color[2], 0f, 1f,
(x), (y),(z+1), -1f, 0f, 0f, color[0], color[1], color[2], 1f, 1f,
(x), (y+1),(z+1), -1f, 0f, 0f, color[0], color[1], color[2], 1f, 0f, // v7-v2-v1
(x), (y+1),(z+1),0,0,0,0,0,0,0,0
},
//bottom face
new float[]{
(x), (y), (z), 0f, -1f, 0f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y), (z), 0f, -1f, 0f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y),(z+1), 0f, -1f, 0f, color[0], color[1], color[2], 1f, 0f,// v7-v4-v3 (bottom)
(x+1), (y),(z+1), 0f, -1f, 0f, color[0], color[1], color[2], 1f, 0f,
(x), (y),(z+1), 0f, -1f, 0f, color[0], color[1], color[2], 0f, 0f,
(x), (y), (z), 0f, -1f, 0f, color[0], color[1], color[2], 0f, 1f,// v3-v2-v7
(x), (y), (z),0,0,0,0,0,0,0,0
},
//back face
new float[]{
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 1f,
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,// v4-v7-v6 (back)
(x), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 1f, 0f,
(x+1), (y+1), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 0f,
(x+1), (y), (z), 0f, 0f, -1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y), (z),0,0,0,0,0,0,0,0
}
};
int faceCount = 0;
for (int i = 0; i < faces.length; i++) {
if (faces[i] == true) {
faceCount++;
}
}

float[] values = new float[faceCount * 11 * 7];

int ptr = 0;
float[] degenerate = new float[11];   //store the previous vertex from some other face draw to use as our next degenerate
boolean degen = false;                    //Have we processed an earlier face and created a degenerate ?
for (int i = 0; i < faces.length; i++) {  //foreach face
if (faces[i] == true) {                     //if this face is to be drawn
float[] face = cubeFaces[i];     //get the vertex data for the face

for (int j = 0; j < face.length; j++) {    //Copy the vertex data into the return array
if (degen && j < 11) {                    //prepend the previous degenerate vertex for the next draw
values[ptr] = degenerate[j];
} else {
values[ptr] = face[j];                //Otherwise just copy the face vertex data as-is
}
ptr++;
if (j > 66) {                                    //Store a degenerate vertex by copying the last interleaved vertex data from this draw
degenerate[j-66] = face[j];
degen = true;
}
}
}
}
return Util.getFloatBuffer(values);      //Return the final floatbuffer
}

Are my degenerate verticies all wrong? I thought all I need to do is declare the same x,y,z from a previous draw, so I could not do the hacky stuff here like remembering the last vertex from an earlier face.

Can't I just stick the degenerate in the vertex data like this?

//Front face
new float[]{
//Vertex                Normals  Colors                        Texcoord
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f,
(x), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 0f,
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f, // v0-v1-v2 (front)
(x), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 0f, 1f,
(x+1), (y),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 1f,
(x+1), (y+1),(z+1), 0f, 0f, 1f, color[0], color[1], color[2], 1f, 0f, // v2-v3-v0
(x+1), (y+1),(z+1),0,0,0,0,0,0,0,0    //degenerate
},

PARTNERS