Archived

This topic is now archived and is closed to further replies.

Qatal

3d strategy game camera using DX7

Recommended Posts

yes i know that dx7 is out of date and all, but if there''s any help to be had, that would be a good thing so im not a math guru, and im writing a 3d strategy game with similar camera limitations to warcraft3. (angle, spinning, zoom etc) my initial tries at implementing this have been somewhat flawed in several areas, any of which you are all welcome to point out what im doing wrong in. a) the camera can sometimes see the ugly unrendered-ness beyond the bounds of the map. this was never a problem with 2d strat games, because you could work out when the map edge coincided with your screen edge and limit the scrolling to make things look nice, but..... the prob here is that depending on the current view angle, the "padding" distance around the edge of the map where the camera is not allowed can change im aware that there are solutions for this, most likely involving some naasty 3d trig, but as i said, im no math guru b) my heightmap is fairly coarse and im using a "doodad layer" or objects rendered on top of the terrain to give it more detail. this is so it can run comfortably on a k6-2 266, which is all i have to develop on now that''s not a problem in itself, but it becomes one when you try to "float" the camera above the terrain - its all jerky on the y-axis when you scroll the map..like the original AOE ive got a feeling its my math knowledge that''s letting me down here - is there some nice easy way to interpolate the height values between vertices so the movement is smooth? c) this isnt a big problem yet, mainly because ive been hiding from it but while single-unit selection is a piece of cake, how do you work out whether something is within a selection box? i think sampling might not cut it, and it would be slow im aware that the box is actually a frustum projected into the world from the screen, but how do you work out whether an object is inside the frustum? again, math would be very grateful if anyone can help me on these issues :D thanx Qatal

Share this post


Link to post
Share on other sites
quote:
Original post by Qatal
a) the camera can sometimes see the ugly unrendered-ness beyond the bounds of the map. this was never a problem with 2d strat games, because you could work out when the map edge coincided with your screen edge and limit the scrolling to make things look nice, but.....

the prob here is that depending on the current view angle, the "padding" distance around the edge of the map where the camera is not allowed can change

im aware that there are solutions for this, most likely involving some naasty 3d trig, but as i said, im no math guru

I guess you could work out the 4 vectors that represent the corners of the viewing frustrum, and check that they always intersect with the terrain. I think this would be sufficient in 99% of cases. I know that Myth didn''t handle it perfectly though.

quote:
now that''s not a problem in itself, but it becomes one when you try to "float" the camera above the terrain - its all jerky on the y-axis when you scroll the map..like the original AOE

I''m not sure what you mean... if by AOE you mean Age of Empires, then it had no height to the terrain anyway...

quote:
ive got a feeling its my math knowledge that''s letting me down here - is there some nice easy way to interpolate the height values between vertices so the movement is smooth?

Take an average of the values before and after the current vertex. As long as the terrain isn''t too jagged, it should work ok.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
AOE : yes i do mean age of empires. and it did have heights to the terrain. it was done using one of their cheap isometric techniques. and it did funny things occasionally. everyone hated it i think... :D

Share this post


Link to post
Share on other sites