passing an array of structs
I'm making a class to handle and decide what polygons should be rendered and checked for collisions in a simple game.
I have a method in it, which will set the corners of the poly, and since i don't know how many corners there will be, i'll have to pass to this method an array.
it wouldn't be such a problem if it was a simple int, but i have to pass my custom struct, which is used to define a 3D point:
Code:
struct p3d {
float x;
float y;
float z;
};
i don't know how i should do it. i have tried several approaches, and nothing works. how should i write it?
and one more thing. considering i want to do some experimenting, i have declared this:
is this the easiest approach to set all the values manually? i'll need to make more polys later, and before i'll make a file format, i'll have to hardcode it into them, at least in the first stage. i don't feel like doing this for several polys.
Code:
corners[0].x=-0.5;
corners[0].y=0;
corners[0].z=0;
corners[1].x=0.5;
corners[1].y=0;
corners[1].z=0;
corners[2].x=-0.5;
corners[2].y=1;
corners[2].z=0;
corners[3].x=0.5;
corners[3].y=1;
corners[3].z=0;
ty. i really appreciate all past support i have received.