Click to See Complete Forum and Search --> : unsigned local variable


vivendi
April 28th, 2009, 01:42 PM
Hey, with the following code i get errors for all the variables. I don't know what to do to fix it.

I have the following code:


private void generateLand()
{

int iCount = 0;
float fX, fY, fZ = 0;
float fNx, fNy, fNz = 0;
float fTu1, fTv1, fTu2, fTv2 = 0;
float fLVX, fLVZ = 0;
int iColour = 0;

Landscape = Scene.CreateLandscape();

Mesh = Scene.CreateMeshBuilder();
Mesh.LoadXFile("..\\..\\plane.x");
iCount = Mesh.GetVertexCount();

for(int i = 0; i < iCount; i++)
{
Mesh.GetVertex(i, ref fX, ref fY, ref fZ, ref fNx, ref fNy, ref fNz, ref fTu1, ref fTv1, ref fTu2, ref fTv2, ref iColour);
Landscape.SetHeight(fX, fZ, fY, true, false, false);
}
Landscape.FlushHeightChanges(true, true);
Landscape.ComputeNormals(true);

}


This is the error that i get for all the variables:

Use of unassigned local variable 'fX'
Use of unassigned local variable 'fy'
...etc

How can i have to fix this??

sotoasty
April 28th, 2009, 01:55 PM
float fX, fY, fZ = 0;

This line declares the varibles fX and fY, but it on initizlizes fZ.

You need to seperate the variables out.

float fX = 0;
float fY = 0;
float fZ = 0;

Shuja Ali
April 28th, 2009, 02:03 PM
The error message is clear enough. It clearly says that you have not initialized fX & fY. Similarly for other variables too.