I have got some confusing behaviour going on with regards to X/Z positions returned from GetObjectRayCastXXX
so my setup is a plane with a grid shader applied, I use the standard code to get the 3D position from the mouse, cast a ray from the camera, this works fine for collision checking but when placing items in the world the end positions become less reliable the further the mouse is away from the center of the screen so I turn my grid plane into a sensor and use GetObjectRayCastXXX to get the exact intersect location which works perfect, almost
while placing items and testing this was fine, everything goes where I want it no matter where on the screen its located, then I added a virtual grid (3 dimension type array) and I grab the intersect point of the ray, the grid plane is offset by half its size so the upper left sits at 0,0 so in theory a simple math to get the grid cell index from the intersect location, easy right??
the z value increases along the x axis and the x value increases along the z axis which has been confusing the life out of me for the last 2 days because until I printed the values to screen I was unaware this was going on but everything I have coded just works
If I put the camera underneath the plane and rotate it 90 degrees and I get the behaviour I expect (x on the x axis and y on the y....)
So I ripped my code apart looking for bugs or at least a reason why, I suspected I mixed up a x and z value somewhere but no, backtracked and made every single function that uses the grid system all feed the same variables from the main loop and still the axis seem to be inverted
So following the path of logic I deduce that my locations are coming from GetObjectRayCastXXX < does this function somehow invert the x/z values, are the objects stored in memory this way <<<<????
I have started coding a system for drawing roads and paths and I use this grid system to check neighbouring cell types and place the required road section, and here is where its going to cause problems
I use a set of functions like below
Function IsLeft(grid_x, grid_y, type_to_check)
result as integer
if AStar_GetCellType(grid_x-1, grid_y)=type_to_check
result=1
endif
EndFunction result
for left, right, up, down, but now up is not up, left is not left because of the GetObjectRayCastXXX inversion, sure I can tweak the params to reflect my (up is left and down is right) world but I dont want to run into problems further down the line because of this, I need to understand why this is happening before I can think a way round it.
Any ideas?, It has to be a memory allocation thing right? I'm confused!!! Help!!!! lol