Results 1 to 9 of 9

Thread: Values randomly changing to zero!!

Threaded View

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Unhappy Values randomly changing to zero!!

    Ok, I've got a class as shown below (using a struct, also shown), the important bit is the function 'CreateTriabglePolys':

    Code:
    struct CUSTOMVERTEX
    {
    	float x,y,z; //The absolute 3D position for this vertex (not transformed)
    	DWORD colour; //The colour of this vertex
    };
    
    class SquarePoly
    {
    	CUSTOMVERTEX Corners[3];
    public:
        SquarePoly(float x1, float y1, float z1,DWORD colour1,
                           float x2, float y2, float z2,DWORD colour2,
                           float x3, float y3, float z3,DWORD colour3,
                           float x4, float y4, float z4,DWORD colour4)
        {
            Corners[0].x = x1;//Top-Left
            Corners[0].y = y1;
            Corners[0].z = z1;
            Corners[0].colour = colour1;
            Corners[1].x = x2;//Top-Right
            Corners[1].y = y2;
            Corners[1].z = z2;
            orners[1].colour = colour2;
            Corners[2].x = x3;//Bottom-Right
            Corners[2].y = y3;
            Corners[2].z = z3;
            Corners[2].colour = colour3;
            Corners[3].x = x4;//Bottom-Left
            Corners[3].y = y4;
            Corners[3].z = z4;
            Corners[3].colour = colour4;
        };
        SquarePoly(){};
        void CreateTrianglePolys(CUSTOMVERTEX *Vertices,const int Start)
        {
            Vertices[Start] = Corners[0];
            Vertices[Start+1] = Corners[1];
            Vertices[Start+2] = Corners[2];
    
            Vertices[Start+3] = Corners[0];
            Vertices[Start+4] = Corners[2];
            Vertices[Start+5] = Corners[3];
        };
    };
    I'm calling it in a loop with the code below:

    Code:
    CUSTOMVERTEX Vertices[TERRAINWIDTH*TERRAINDEPTH*2*3-1];//2 = # of triangle to represent a square, 3 = a vertices of a triangle
    for(i=0;i<=TERRAINWIDTH;i++)
    {
        for(j=0;j<=TERRAINDEPTH;j++)
        {
            sqPolygons[i][j].CreateTrianglePolys(Vertices,VertexCount);
            VertexCount +=2;
        }
    }
    I've added watches to i, j and VertexCount (which is passed as a const!!) and before the call to CreateTriabglePolys, they have their correct values, but directly after, the change back to zero and i cannot for the life of me work out why.

    Thanks for any help.
    Last edited by SLH; Dec 7th, 2003 at 12:13 PM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


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