Terrian collision, coordinates of
by Jared Schnelle · in Torque Game Engine · 11/13/2002 (9:31 am) · 1 replies
The object selection code I have in the game(thanks to 21-6 productions) performs a raycast from the camera point, to the point you've selected on the screen.
It takes the 2d screen coords, unprojects them, then scales it up by 200, and gets it's new end point.
Along with the raycast you send a bitmask for what it should be able to collide with, and if it collides with something(an object type you specify), it kicks back to the engine in the form:
OBJNUM X Y Z nX nY nZ
Where X Y Z are the coordinates of the collision in game space coordinates. This is great, and is exactly what I need, but I'd like to do this for terrain collisions.
From what I can gather, this wont work because the terrain isnt an object type that I can set a bitmask for(jump in and correct me if I'm wrong please!). The terrain manager creates a big grid, and you can turn the grid into gamespace coordinates by calling the TerrainEditor::gridToWorld function.
My question is.. can anyone see an easy way around this? Is there a way to make the raycast collide with the terrain so that I can get the xyz coords of the collision?
Thanks,
Jared
It takes the 2d screen coords, unprojects them, then scales it up by 200, and gets it's new end point.
Along with the raycast you send a bitmask for what it should be able to collide with, and if it collides with something(an object type you specify), it kicks back to the engine in the form:
OBJNUM X Y Z nX nY nZ
Where X Y Z are the coordinates of the collision in game space coordinates. This is great, and is exactly what I need, but I'd like to do this for terrain collisions.
From what I can gather, this wont work because the terrain isnt an object type that I can set a bitmask for(jump in and correct me if I'm wrong please!). The terrain manager creates a big grid, and you can turn the grid into gamespace coordinates by calling the TerrainEditor::gridToWorld function.
My question is.. can anyone see an easy way around this? Is there a way to make the raycast collide with the terrain so that I can get the xyz coords of the collision?
Thanks,
Jared
About the author
Torque Owner Jared Schnelle
%searchMasks = $TypeMasks::TerrainObjectType;
:) Oh how I'm beginning to love bitmasks.