Jump to content

How to retrieve pointer to terrain from loaded scene - Blitzmax Style


Kronos
 Share

Recommended Posts

Using the method of cycling through all child entities of the scene will only return terrain as an entity. How can I get it as a terrain. I need to be able to access the terrain to retrieve height information via terrainelevation().

 

This code doesn't work because you can't cast from entity to terrain.

 

Local Myscene:TEntity = loadscene("media\myscene2.sbx");
Local ent:TEntity
Local terrain:TTerrain

DebugLog "countChildren = "+CountChildren(myscene)


For i = 1 To CountChildren(myscene)
ent = GetChild(myscene,i)
If GetEntityKey(ent,"class") = "Terrain" Then terrain=ent <--no good!!

Next

 

Thanks in advance.

intel i5 2500k, ram 16gb, nvidia Geforce GTX570, asus xonar sound card. Windows 7 64 bit

Link to comment
Share on other sites

Casting is how I get to the loaded map layers for generating an overhead map, and this is how Josh does it in the editor too. So it's prety safe.

 

Local cmap:TBuffer = TTerrain(game.scene.terrain).colormapbuffer;
TTerrain(game.scene.terrain).normaltexture.Bind(1) ;
SetShader(map_shader) ;
...
...
DrawImage(cmap.colorbuffer[0], 0, TSD_MAPSIZE, TSD_MAPSIZE, -TSD_MAPSIZE) ;

 

You can get the heightmap and mapsize goodies too. So it's very handy.

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...