struct PLANE {FLOAT X, Y, Z; D3DXVECTOR3 Normal; FLOAT U, V;};
class PlaneStruct
{
public:PLANE PlaneVertices[4];
public:DWORD PlaneIndices;
void CreatePlane(float size)
{
// create vertices to represent the corners of the cube
PlaneVertices =
{
{1.0f * size, 0.0f, 1.0f * size, D3DXVECTOR3(0.0f, 0.0f, 1.0f), 0.0f, 0.0f}, // side 1
{-1.0f * size, -0.0f, 1.0f * size, D3DXVECTOR3(0.0f, 0.0f, 1.0f), 0.0f, 1.0f},
{-1.0f * size, -0.0f, -1.0f * size, D3DXVECTOR3(0.0f, 0.0f, 1.0f), 1.0f, 0.0f},
{1.0f * size, -0.0f, -1.0f * size, D3DXVECTOR3(0.0f, 0.0f, 1.0f), 1.0f, 1.0f},
};
// create the index buffer out of DWORDs
DWORD PlaneIndices[] =
{
0, 2, 1, // side 1
0, 3, 2
};
}
};
This was my code for a “plane” structure, i just have one question, if you look at the top it says PLANE PlaneVertices[4]; and then in a function i wanted to define it, so to give it specific values, but i get the following error:
Expression must be a modifiable value.
Please help
You cannot assign values to your
PlaneVerticesarray like this, you can only use this when you define it using the {} notation to initialise it. Try assigning each element to each invidivual element of your array using a for loopEdit: In response to your comment, create an instance of your PLANE struct and assign the values to it that you want it to have. Then assign this to the first index in the
PlaneVerticesarray usingthen repeat for the remaining 3 instances of PLANE that you want in the array, adding to the 1,2,and 3 indices of
PlaneVertices. To fully illustrate I will do the first one for you using your data providedYou then need to repeat for each PLANE you want to add. Also take not of the other answer concerning your PlaneIndices problem.