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 / dbGetTerrainGroundHeight equivalent for custom terrain

Author
Message
Phoenix73
16
Years of Service
User Offline
Joined: 27th May 2008
Location: Australia
Posted: 26th Jun 2008 03:11
I am writing my own terrain generator which creates fractal landscapes composed of DX9 triangles (2 triangles per grid square).

I would like to know if there is a quick way to calculate the height (Y) of the landscape at any X,Z co-ordinate.

Does anyone know of a simple planar collision routine I could use as I have tried coding this myself and am not having much luck.

I really just want the equivalent of dbGetTerrainGroundHeight.
Codger
21
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 26th Jun 2008 08:20
I love fractals so i would be very interested in the seeing a demo of the program.

If you can post some code describing the terrain I would try to help with the height issue but have you tried sparky's collision routines

sorry for not being much help

Codger

System
MacBook Pro
Windows XP Home on Boot Camp
Phoenix73
16
Years of Service
User Offline
Joined: 27th May 2008
Location: Australia
Posted: 26th Jun 2008 08:52
Hello Codger,

I've emailed you the source code if you are interested in looking at it. I've not tried Sparky's collision routines yet but might give that a try.

Thanks
Akongo
16
Years of Service
User Offline
Joined: 24th Jun 2008
Location:
Posted: 26th Jun 2008 23:50
I'm having the same problem. I have a terrain made in Blender and exported in .x (DirectX). I too am having trouble finding a way to get the height at a given x and y. For terrain it's as easy as dbGetTerrainGroundHeight.

I did find dbObjectSizeY(int iObj) which says "This command will return the full height of the object." I'm not sure what "full height" means.
Phoenix73
16
Years of Service
User Offline
Joined: 27th May 2008
Location: Australia
Posted: 27th Jun 2008 02:44
I managed to use Sparky's Collision Library and SC_RayCast works perfectly for half of my triangles.

For some reason the 1st triangle I render in each square is treated as a 'backface', whatever that is, and collision does not take place. The 2nd triangle I render in the square works fine.

Does anyone know what rule determines whether a triangle is a 'backface' and how I can get around this problem?

Thanks
Phoenix73
16
Years of Service
User Offline
Joined: 27th May 2008
Location: Australia
Posted: 27th Jun 2008 03:58
Fixed it!

I was reading everywhere about the normal vectors determining 'backface' status, but it turns out that the backface status is determined by the order the triangle's vertexes are defined.

If they are defined in an anti-clockwise direction, they are backfaces.

This explains to me how backfaces would work with my DX code if I didn't include the D3DFVF_NORMAL Flexible Vertex Format mask.

Sparky's seems quite fast - I'm very impressed given the polygon count of my landscapes (>30,000).
Phoenix73
16
Years of Service
User Offline
Joined: 27th May 2008
Location: Australia
Posted: 27th Jun 2008 09:48
I have uploaded the demo here:

http://www.craftylogic.com/upload/Downloads/FractalTerrainDemo.zip

Just extract the ZIP file and run the EXE. Arrows move, Space Bar regenerates the fractal (plasma cloud) height map.

The textures are picked based on height, but the smoothing routine still needs work.

Login to post a reply

Server time is: 2024-11-20 15:39:49
Your offset time is: 2024-11-20 15:39:49