opengl - Create a cube with a 3d mesh, using a 2d array -
i need create cube using mesh using these properties: "a two-dimensional array containing mesh vertices. each entry of array specifies vertices of 1 row of mesh. arrays rows must have same length. there must @ least 2 rows, , each row must have @ least 2 vertices"
if think representation of cube made of paper:
you can see 2 meshes, 3 orizontal square , 3 vertical. in case have use 2 meshes, while need one. i'd not have overlap, , not able find solution. best option i've found consists in filling array 9 rows.
each rows contains 2 entry, , in way creating surface of cube. i'm attaching few images explain creates first rows, till when reach overlapping point:
i guess problem has no solution, in case of have idea open proposal.
(i'm sorry order may not accurate)
var row0 = []; x, y, l x+t, y, l var row1=[] x, y, l+400 x+t, y, l+400 var row2=[] x, y+t, l+400 x+t, y+t, l+400 var row3=[] x, y+t, l x+t, y+t, l var row4=[] x, y, l x+t, y, l var row5=[] x+t, y, l x+t, y+t, l var row6=[] x+t, y, l+400 x+t, y+t, l+400 var row7=[] x, y+t, l x, y, l var row8=[] x, y+t, l+400 x, y, l+400
with "x,y" 2 random coordinates having distance of 400."t" variable. while "l+40"0 indicates distance in height "l".
you're totally overthinking problem.
let's step moment: in 3d space each position specified 3 values; in cartesian coordinate system called x, y , z.
we write down row of scalar values:
x, y, z
a cube consists of 6 faces, each 1 made of 4 points, each point position shared 3 faces. let's assume cube center @ origin , width of 2, 2 faces in xy-plane be
-1, -1, -1 1, -1, -1 1, 1, -1 -1, 1, -1 1, -1, 1 -1, -1, 1 -1, 1, 1 1, 1, 1 …
there 4 more faces (two in xz , 2 in yz) make full cube. what's important (for question) is, how these values written down. numbers wrote. see? 2d array of numbers (3 numbers in row), 1 row every point cube's mesh made from. that's there is.
a mesh such list of vertices. don't think of "foldable mesh made paper". list of positions, can duplicate positions. may write down 8 positions once , use second, 1d array list of how make mesh these positions.
Comments
Post a Comment