CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    102

    unsigned local variable

    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:

    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??

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: unsigned local variable

    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;

  3. #3
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: unsigned local variable

    The error message is clear enough. It clearly says that you have not initialized fX & fY. Similarly for other variables too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured