#How to generate a mesh with more than one Quad? Pls help

1 messages · Page 1 of 1 (latest)

plucky crypt
#

All tutorial just only show how to make one quad, but what if I want four of them? Vertices are straightforward to understand, but what values should triangles have?

fluid vigil
#

Just generate vertices at different positions

#

Triangle are the indices from the vertex array

#

Every 3 vertices/indices form a triangle with triangle topology

plucky crypt
plucky crypt
fluid vigil
fluid vigil
#

Index points to the position of the element in the vertex buffer

plucky crypt
#

I still do not get it, for example, what number will be on top right quad?

#

(triangular numbers)

fluid vigil
#

it could be anything

#

you set the positions of the vertices, and just write the index of that vertex in the triangles array to create a triangle

#

literally work like an array

plucky crypt
#

This is a code that assigns value to triangular array, and I do not understand the '+ worldSize' and verts

#

But the code is working

#

It will be 11 if the zWorldSize is 10, for example

fluid vigil
#

_zWorldSize is basically the amount of vertex of the world horizontally/vertically, so adding it effectively point to the vertex that lie in the next row/column of the grid

plucky crypt
#

Ok, but what if z = 4 and x = 5?

#

to go on the next row it is not correct to assign zWorldSize + 1

#

It would be 5, but there is the value of 7

fluid vigil
#

doesn't look like x = 5 to me according to the pic

#

also shouldn't you add the _xWorldSize instead of the _zWorldSize?

plucky crypt
#

But, is this picture is the order of assigning triangular values?

fluid vigil
#

personally i go for the order of Top-Left, Top-Right, Bottom-Right, Bottom-Right, Bottom-Left, Top-Left

#

but well you can use whatever order you want

#

but you have to follow the winding direction if you want the triangle be displayed/culled correctly

plucky crypt
#

So this picture is the answer?

fluid vigil
#

maybe