Terrain issues?

Feb 28, 2013 at 12:00 PM
I'm having some problems with the terrain in Engine Nine! I have managed to successfully generate a square of terrain, however when I move the camera, the amount of terrain you can see changes. The problem is best described using the pictures attached. It looks like a problem with the near and far planes, however they are set to 1 and 20000 respectively. Any help would be greatly appreciated!!



Mar 1, 2013 at 8:23 AM
Hi tom,

It seems to be a problem caused by bounding box and frustum culling. Can you enable diagnostic drawing using scene.DrawDiagnostics and how me a screenshot of how the bounding boxes look like?
Mar 1, 2013 at 11:50 AM
Hi yufeih, thanks for the rapid response!

I enabled diagnostic drawing using the following code, but it didn't seem to do anything.. I tried putting it in the update method and draw method, but still couldn't see any bounding boxes..
        GraphicsDevice graphicsDevice = GraphicsDevice;
        TimeSpan elapsedTime = gameTime.ElapsedGameTime;
        scene.DrawDiagnostics(graphicsDevice, elapsedTime);

Mar 1, 2013 at 12:00 PM
Do you generate the Terrain in Code?

If you set the heightmap like this it wont update the Surface's Boundingboxes.
Surface.Heightmap.LoadHeightmap(float[] heightmap)
Mar 1, 2013 at 12:03 PM
I generate the terrain in myScene.xaml like so:

<Surface Heightmap="{ContentReference Assets/firstHeightMap}" Transform.Scale="3, 3, 3"
        Transform.Position="0, -50, 0" LevelOfDetailEnabled="True" 
        TextureTransform.Scale="0.3, 0.3" VertexType="VertexPositionNormalTangentBinormalTexture">

<MaterialGroup MaterialPaintGroup.MaskTextureScale="5, 5">

                <ExternalReference>"{ContentReference Assets/firstHeightMap}"</ExternalReference>
                <ExternalReference>"{ContentReference Assets/firstHeightMap}"</ExternalReference>

        <DiffuseMaterialPart Texture="{ContentReference Assets/image_14}" />

        <DiffuseMaterialPart Texture="{ContentReference Assets/image_16}" />
        <SpecularMaterialPart SpecularColor="0.5, 0.5, 0.5" SpecularPower="64" />
        <NormalMapMaterialPart NormalMap="{ContentReference Assets/image_16}" />

    <DirectionalLightMaterialPart />
So not using a float for the heightmap?
Mar 1, 2013 at 12:10 PM
I was pointing out if your doing it in code.

Draw Diagnostic
protected override void Draw(GameTime gameTime)
    scene.Draw(GraphicsDevice, (float)gameTime.ElapsedGameTime.TotalSeconds);
    scene.DrawDiagnostics(GraphicsDevice, (float)gameTime.ElapsedGameTime.TotalSeconds);
Mar 1, 2013 at 12:17 PM
Oh I see, I'm sorry! My problem was I was doing the draw diagnostics before my scene.Draw.. D'oh!


From these, would I be correct in assuming I'm not generating my terrain quite properly? It only seems to have bounding boxes in the closest corner?
Mar 1, 2013 at 12:27 PM
Transform.Scale="3, 3, 3"
Might be the issue, try setting the Step higher in the Content Pipeline instead.
Mar 1, 2013 at 12:46 PM
Edited Mar 1, 2013 at 12:47 PM
Hmm, partially fixed the problem! Taking out the Transform.Scale did stop the weird clipping issues. However, now that I've set the step higher (10) the terrain pops out completely flat..

EDIT: Please disregard that! I realised straight after posting what my issue was! Another stupid moment! Thank you very much for the help!
Mar 1, 2013 at 1:17 PM
Edited Mar 1, 2013 at 1:21 PM
Adjust the Height property along with Step.