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.

DarkBASIC Professional Discussion / Get Terrain Height

Author
Message
entomophobiac
23
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 29th Sep 2003 15:13
Am I the only one having a busload of trouble with this command?

I mean, it works perfectly if you set the Y of a camera to follow the Terrain Height, but as soon as I place an object to follow the Y of the Terrain Height, it will flip between hovering a mile above the Y or disappearing into the terrain itself.

What kind of problem is this? Is there a necessity to scale the math in some way, or are the scales within DB simply messed up, returning faulty values?

I guess the answer is quite simple, and probably somewhere along the line of "your code is buggy, dude," but I would greatly appreciate an answer from someone that may even have experienced the same problem.

Apart from the short supplied code, the only thing the program does is that it loads the object and the terrain, plus textures. So please - someone with more of a math brain than I, just figure it out
Kentaree
23
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 29th Sep 2003 18:04
I can't test this here as I've no DBP here, but the reason the object is in the terrain is most likely that the y value of the object corresponds to the very centre of the object, which causes the object to be half submerged in the terrain. So if your object is 10 in height, you'd use:

position object 1,x#,get terrain height(1,x#,z#)+5,z#

Cheers,
Kentaree

I would be unstoppable if I could just get started...
entomophobiac
23
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 29th Sep 2003 21:47
Well, the problem is not that half of the object is inside the terrain. That is easily compensated for when making the object in 3DSMax - you just move it above the center of the grid.

The problem IS, however, that the object doesn't correspond to the actual Y of the Get Terrain Height() command. It seems to mess things up. Sometimes, as I wrote, the model will fly miles above the supposed Terrain Height, whereas it may otherwise find itself inside the Terrain Height.

And... I can honestly not understand why that is happening. It is as if the model and the terrain would use different scales, or something. Just plain odd!
Eddie Gordo
23
Years of Service
User Offline
Joined: 14th Jan 2003
Location: Ohio - USA
Posted: 29th Sep 2003 21:55
I believe the get terrain height gets the height of the terrain on its X,Y coordinate in relationship to its division like the get matrix height...it doesnt get the height of the terrain at any X,Y coordiante just the one that are cooresponding to its vertexes...but i do have a solution...i will have to look it up when i get home but i know the equation to get the height of a matrix when programming a 3D engine and its simple to incorporate into DBPro...

Visual Programming Studio ORANGE
Replacement IDE for Dark Basic Professional...
(Will Be Availeable When This is Removed)

Login to post a reply

Server time is: 2026-07-25 09:59:22
Your offset time is: 2026-07-25 09:59:22