Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Stopping a player traversing of the edge of the terrain

Author
Message
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 19th Feb 2008 14:59
I have a Terrain loaded and scaled Via the dbLoadTerrain() stuff.

its the terrain demo included with the dark SDK download with a few modifications as follows,


Mouse Movement


Fps Display


And now my attempt at stopping the user running of the edge of the loaded terrain into the vastness of the skybox.



Everything works fine at least enough for now

the only issue is the code to block u running of the map seems really really erratic it does seem to work , but totally at random not at all confined to the edge of the map sometimes a small square in the center or a zig zag pattern across the map ;/

any suggestions this was the best i could come up with my very limited knowledge of DarkGDK, or c++ for that matter.

Stuck in the land of the confused! and loving it!
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 19th Feb 2008 15:13
Note after a few more tests its seems to follow a pattern of erraticness..

after the land is first loaded your confined to a small square but only 3 sides stop you moving,

once u traverse through the side that for some reason does not stop you moving off the edge of the terrain u can then go anywhere again with no barriers at all ...

So now im confused even more ;/

Stuck in the land of the confused! and loving it!
Elroyman
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 19th Feb 2008 16:46
Where is your initial camera postion?

I would assume from your code that it might only stop you from traversing 2 sides. As it seems you are only accounting for the cases where camera position is >= to terrain size. There are cases when CameraPosition will be <= Terrain size.

I had some trouble with this when I was doing some DirectX programming some time ago...but I must be honest I haven't tried it yet with DGDK.
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 19th Feb 2008 23:36
i should have mentioned my camera position is that of the default Terrain tutorial.

dbPositionCamera ( 385, 23, 100 );

ill attach my main.cpp file but it has a few extra alterations ( in the form of a really really hacked up water system >.> its terrible and just a random matrix floor that intersects the terrain at a certain level add a water effect that moves. )

Stuck in the land of the confused! and loving it!

Attachments

Login to view attachments
pillbug22
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location:
Posted: 21st Feb 2008 01:45
Fusspawn,

Here's what I was able to hack out for detecting the edge of the map. I will point out a bug that is similar to what you described "stopping" at certain points of the map.

I modified my default sample map to actually be a 2x2 grid of the supplied map, so now all 3 map image files are 512x512 and each quadrant of the 2x2 map "grid" is a replica of each other. With this code, it does find the outer edges of the map, but it also stops at each 512 "edge" in the middle of the new map. It appears that even though the 3 image files and camera are all at a X=512 and Z=512, the terrain displayed during runtime is actually 1024, so you are confined to a single 512x512 square.

Not sure why the runtime terrain is 1024 when all 3 files measure 512x512, but I guess that's something else to work out.

Attachments

Login to view attachments
Fusspawn
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 22nd Feb 2008 21:25
Thanks for that pillbug22, Im using your code and it seems to work,

another solution i found was if the terrain was scaled, was to also add the scale onto the results of dbGetTerrainSize();

as it seems that still returns the default size not the scaled size, alot of the Dark GDK functions seem's to have that issue, and its one id kill to see resolved, ive only been working with Dark GDK and c++ a few days altho had alot of other language experience previously,

( Mostly web based php,jscript exctra exctra, with the odd bit of python . )

But its seeming easy to pick up,


I may rewrite a few of the core functions into my own lib that would actually return the scaled size. the only issue is the code will probally suck and be quite slow, As im not even close to a level of C++ i could actually make a diffrence trying to speed it up,


Either way thanks again for your help!

Fusspawn,

Stuck in the land of the confused! and loving it!

Login to post a reply

Server time is: 2024-11-17 06:22:18
Your offset time is: 2024-11-17 06:22:18