Stuck again :( sorry guys !
Bit hard to explain this one, so I'll try to give as much detail as possible.
Anyway.. here's the story - I've written this terrain system that uses patches.
Each patch contains 256 vertexes, 16 x 16
I have a total of 256 patches.. again 16 x 16
So think of it as a blanket, patch 1 being top left, patch 17 being on the second row under the first.
Now I'm mapping my heightmap onto the vertexes, I'm going through the entire bitmap and setting each y vertex as needed.
Now the problem.. I can get the correct patch using the following code - which works, although probably not the fastest or prettiest !.
Note, the X# and Y# coords are the placement vars when reading the bitmap.
As I've said, this works - it returns the correct patch.., but I also need the offsets, so that I can find out which vertex I need to edit on the patch.
I think it's something to do with the offset that results from the calc in NUM1 and NUM2 - but how do I convert it into a useable number ? (which I know will somewhere be in the scale of 1-256.
The vertexes in the patch are setup going from left to right, top to bottom. (same as the patches)
Help !!!.. pretty please ;)
btw..dont laugh - but the above code took me 4 hours to get right !. ;) .. oh go on then.. laugh !!!
Bit hard to explain this one, so I'll try to give as much detail as possible.
Anyway.. here's the story - I've written this terrain system that uses patches.
Each patch contains 256 vertexes, 16 x 16
I have a total of 256 patches.. again 16 x 16
So think of it as a blanket, patch 1 being top left, patch 17 being on the second row under the first.
Now I'm mapping my heightmap onto the vertexes, I'm going through the entire bitmap and setting each y vertex as needed.
Now the problem.. I can get the correct patch using the following code - which works, although probably not the fastest or prettiest !.
x#=8 ; x example coord of pixel y#=10 ; y example coord of pixel num1#=x/16 ; divide patch size with x coord num2#=y/16 ; divide patch size with y coord num3=Floor(num1#)+1 ; round down to a whole number num4=Floor(num2#) ; Same ! num5=num3+(num4*16) ; Find the exact patch needed
Note, the X# and Y# coords are the placement vars when reading the bitmap.
As I've said, this works - it returns the correct patch.., but I also need the offsets, so that I can find out which vertex I need to edit on the patch.
I think it's something to do with the offset that results from the calc in NUM1 and NUM2 - but how do I convert it into a useable number ? (which I know will somewhere be in the scale of 1-256.
The vertexes in the patch are setup going from left to right, top to bottom. (same as the patches)
Help !!!.. pretty please ;)
btw..dont laugh - but the above code took me 4 hours to get right !. ;) .. oh go on then.. laugh !!!