[EDIT] This problem has now been solved by Matty H:
Quote: "Great news, I have a fix. When you instance the height field, set the 'hole material' to -1. Otherwise it seems the hole material is not properly initialised and leads to some undefined behaviour, most of the terrain being set as a hole and not created.
//-- This is where we create our actor instanced from the height field
//-- we have created.
//-- Since the data was collected from a scaled up area we need to scale our
//-- height field to match.
DYN INSTANCE HEIGHT FIELD terrainID, heightFieldID, 1.0, terrainScale, terrainScale, 0, -1"
Hi, It'd be great if anyone can help me with this problem please; I'm trying to use height fields for my terrain but they don't appear to work properly (using a purchased full version of Dark Dynamix v1.1).
Using the example code that comes with Dark Dynamix I get the following (I have adjusted the code to add 10 to the height so the debug render shows just above than the terrain):
This happens with the example, and also with any height fields that I attempt to make myself. As you can see it only shows two little pieces of the height field with the debug rendering, I'm under the impression it should be rendering the entire height field, is that correct?
I have an Nvidia GeForce GTX 550 Ti graphics card, and have the visual debugging software installed. Is the problem/bug with Dark Dynamix or is it something I'm doing?
The code that gives me the above (it's basically the demo code):
Rem Project: Height Fields
Rem Created: Friday, March 16, 2012
Rem ***** Main Source File *****
//-- HEIGHT FIELDS
//-- Height fields should always be considered before triangle meshes, height
//-- fields are more efficient. They are well suited to representing terrains
//-- and this is what we will use in this example.
//-- NOTE: Don't forget to include the PhysX constants file in your solution.
global terrainID = 1
global heightFieldID = 1
global terrainScale = 10
Sync On
Sync Rate 60
AutoCam Off
Position Camera -250, 300, -250
Point Camera 500, 0, 500
set camera range 0, 1, 10000
DYN START
//-- Large actors can be visualised but collecting and drawing
//-- the data takes alot of cpu power. Be sure to turn
//-- this off when you have the heightfield matching the terrain.
DYN SET PARAMETER NX_VISUALIZATION_SCALE, 1.0
DYN SET PARAMETER NX_VISUALIZE_COLLISION_SHAPES, 1.0
makeTerrain()
makeHeightField()
DYN SIMULATE
do
DYN FETCH RESULTS
DYN UPDATE
DYN DEBUG RENDER
DYN SIMULATE
Control Camera Using ArrowKeys 0, 10, 1
Sync
loop
DYN FETCH RESULTS
//-- Release terrain actor which was instanced from height field.
DYN DELETE ACTOR terrainID
//-- Now we can release height field
DYN DELETE HEIGHT FIELD heightFieldID
DYN STOP
function makeTerrain()
Load Image "../../Media/Terrain/texture.jpg", 1
Load Image "../../Media/Terrain/detail.jpg", 2
//Setup Terrain
Make Object Terrain terrainID
Set Terrain HeightMap terrainID, "../../Media/Terrain/map.jpg"
Set Terrain Scale terrainID, terrainScale, 1.0, terrainScale
Set Terrain Light terrainID, 1.0, -0.25, 0.0, 1.0, 1.0, 0.78, 0.5
Set Terrain Texture terrainID, 1, 2
Build Terrain terrainID
endfunction
function makeHeightField()
x = Get Terrain X Size(terrainID)
z = Get Terrain Z Size(terrainID)
//-- Create a height field desc structure to hold our
//-- height data. This structure must be the correct size
//-- for the terrain, in this case 256x256.
descID = 1
DYN MAKE HEIGHT FIELD DESC descID, x, z, -1000, 0, 0
//-- Retrieve and then set our height data, remembering the terrain is scaled.
for i = 0 to x - 1
for j = 0 to z - 1
height = Get Terrain Ground Height(terrainID, i * terrainScale, j * terrainScale) + 10
DYN HEIGHT FIELD DESC SET DATA descID, i, j, height
next j
next i
//-- Now all our data is set we create a height field, this height field can
//-- be instanced as many times as you like, this is useful if you have repeated
//-- your terrain to save memory.
DYN MAKE HEIGHT FIELD heightFieldID, descID
//-- We no longer need desc.
DYN DELETE HEIGHT FIELD DESC descID
//-- This is where we create our actor instanced from the height field
//-- we have created.
//-- Since the data was collected from a scaled up area we need to scale our
//-- height field to match.
DYN INSTANCE HEIGHT FIELD terrainID, heightFieldID, 1.0, terrainScale, terrainScale
endfunction