Creating a 2D vertex array in C# for use with XNA -


we being directed draw cube, using following rough structure store vertices:

vertexpositiontexture[] vert; vert = new vertexpositiontexture[24]; 

however, thought better organisation, , allow easier manipulation, if broke vertices 2d array this:

public class square {     public vertexpositiontexture[] vert }  square[] cubeside; cubeside = new square[6]; 

however, can instantiate cubeside, not verts inside each square.

i tried creating constructor inside square class, realised have option of new square[] or new square(), not both. have 1 square 4 vertices, or size squares 1 vertex.

i have tried vertextpositiontexture[] vert = new vertexpositiontexture[4] in square class, itself, not work either.

to add confusion, last time taught xna, teachers drilled arrays had declared @ start, exact number of elements wanted. i.e, can not have vertextpositiontexture[] vert, , instead, should have vertextpositiontexture[4] vert. quite adamant array, once set, never have capacity altered.

how should go having 2d vertex array, in collecting 24 vertices groups of 4, represent faces in cube?

we being directed store each face separately, i.e. having 24 vertices set requirement.

vertexpositiontexture[4] vertices; isn't valid c# code. using vertexpositiontexture vertices = new vertexpositiontexture[4]; in square class work, instantiates array of references, not object each element. below started on constructing vertices.

public class square {     public vertexpositiontexture[] vertices;      public square()     {         vertices = new vertexpositiontexture[4];     } } 
square side = new square[6]; (int = 0; < 6; i++) {     side[i] = new square(); }  side[0].vertices[0] = new vertexpositiontexture(vector3, vector2); .... 

now can define each of vertices contained within individual square objects.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -