This is my first attempt at a 3d project so bear with me (the concepts are taking a while to sink in :D
I'm programming a racing game. My "map" on which I build my track is an 8x8 grid. On this grid I plan to put track pieces (each made of 3 meshes - a top then two sides which are the support beams) and these pieces are created dynamically depending what the player picks.
So far I have my map which I can rotate and zoom and select individual squares on. I also have track pieces I can create (push a button and I get my 3 dynamic meshes created). What I can't figure out is this...
If the map was stationary, putting a piece at an X,Y location and elevating it a bit to put it "on" the map (rather than "in" or "underneath" it) would be easy. Instead though, my map can be tilted and rotated. I want to know how I can rotate/tilt my track, then when I select a new piece have it end up in the correct spot.
The yaw/tilt/roll I figure I match to whatever the map is, but I can no longer just add 1 to the Z location on the map to make sure the piece ends up "on" the map (rather than in or underneath it). If the map has tilted towards the player, the piece now needs to be moved +Z and -Y from where it started to be put "on" the map. It might also have rotated which further changes X, Y and Z coords.
1) Any takers on how I can work out where to put my piece so it's 1 3D-space unit above the map regardless of how the map has tilted/rotated? It will be a vector command of some description, but I'm not sure what.
2) Also, rather than having to move up to 64 pieces every time I manipulate the map, can I "glue" the piece to the map so rotating the map correctly places the pieces? I'd need to be able to "unglue" the piece afterwards if the player deleted it.
Thanks a bunch people!!!
I'm programming a racing game. My "map" on which I build my track is an 8x8 grid. On this grid I plan to put track pieces (each made of 3 meshes - a top then two sides which are the support beams) and these pieces are created dynamically depending what the player picks.
So far I have my map which I can rotate and zoom and select individual squares on. I also have track pieces I can create (push a button and I get my 3 dynamic meshes created). What I can't figure out is this...
If the map was stationary, putting a piece at an X,Y location and elevating it a bit to put it "on" the map (rather than "in" or "underneath" it) would be easy. Instead though, my map can be tilted and rotated. I want to know how I can rotate/tilt my track, then when I select a new piece have it end up in the correct spot.
The yaw/tilt/roll I figure I match to whatever the map is, but I can no longer just add 1 to the Z location on the map to make sure the piece ends up "on" the map (rather than in or underneath it). If the map has tilted towards the player, the piece now needs to be moved +Z and -Y from where it started to be put "on" the map. It might also have rotated which further changes X, Y and Z coords.
1) Any takers on how I can work out where to put my piece so it's 1 3D-space unit above the map regardless of how the map has tilted/rotated? It will be a vector command of some description, but I'm not sure what.
2) Also, rather than having to move up to 64 pieces every time I manipulate the map, can I "glue" the piece to the map so rotating the map correctly places the pieces? I'd need to be able to "unglue" the piece afterwards if the player deleted it.
Thanks a bunch people!!!