# Terrain editor (height maps)

## Recommended Posts

I put this in the beginner section but I have messed with 3D graphics some and have been coding in C++ for years. But I have never created a game at all. I have tons of books but my question is I want to create a map editor kind of like Far Cry 2's map editor. Is there anywhere to find info on doing this. I have a book on height maps but I don't think it is exactly like I want although I will use it as reference. I want to be able to add buildings and other items as well. Real time shadow rendering. Ability to build caves into the mountains(height map) or extend the height map horizontally as well. I just need pointed to a good reference. Any ideas or examples out there would be cool too. Thanks in advance. jack

##### Share on other sites
Creating a map editor like that is far more complex than you might imagine.

First and foremost you'd need to decide how to handle terrain. When thinking about a popular 3D game with a built-in editor, Warcraft III comes to mind. I don't know how exactly they handle the maps internally but if I were to implement it I'd use a height field as it's very simple to work with.

Buildings and trees are simply objects. If you think about how a height-field is constructed it could very easily be devided up along a gride. This grid, in effect, devides the map into 'tiles' or 'cells'. You could align buildings and objects to these cells using a vertex offset of some sort.

Building caves into a mountain isn't really that possible with height fields... not directly at least. I would image the easiest way to do this would be to have a separate cave mesh that you 'insert' into the heightfield. In order to get it to look right you'd need to remove polygons out of the height-field where the cave and the height-field meet. I'm sure there are other approaches to this but that's just off the top of my head.

Adjusting heights in a height field is also very simple -- just increase or decrease the Y value of any particular vertx and viola, height has been adjusted. To do this with a mouse is a simple matter of using a technique like a mouse ray-cast (e.g., casting a ray at from the camera using the mouse position on the screen as a starting point and seeing what geometry said ray collides with).

Another possibility is to not use height fields at all and instead use a full 3D mesh for landscape. This is a much more complex method for creating terrains and would require a considerable amount of time spent developing the tools for it but it's a valid approach.

I haven't looked for any references in particular but google is good for that sort of thing.

Ultimately you're going to be looking into not one but many different approaches and methods to do specific things and then tying all of them together to build an editor.

Hope this helps. Good luck!

##### Share on other sites
Well I don't think making a simple terrain editor is too hard as the height map is concerned but I agree that some of the stuff I listed will be hard. Like the caves I knew would be hard but your idea was pretty good. I know on the CryEngine2 you can just click a mouse button and dig through mountains on your height map. I don't know how they achieve this and I know it's a multi million dollar engine as well. But thanks for getting my mind working now. I appreciate your post. I may have questions for you later. Have a great day.

Jack

##### Share on other sites
Actually implementing a simple heightmap editor is not that hard, with strong focus on simple. But if you progress some more you will soon find that difficulties arise in two major categories. First, you need some capable tools to edit your terrain which involves all sorts of picking, transformation, and similiar operations you need to have in your 3D engine. Second, the editor is only of use if you have a writable (and obviously readable as well) file format you can work with.

The second category involves even more: When working with large terrains you would need to have a strong terrain rendering implementation in your editor already. Basically, all of your terrain rendering, hierarchical organization, terrain patch streaming and culling code and so on has to be implemented.

So I guess that is why you get posts telling you it ain't that easy. Especially when you throw up buzz tools like the Far Cry 2 editor [smile]

##### Share on other sites
Quote:
 So I guess that is why you get posts telling you it ain't that easy. Especially when you throw up buzz tools like the Far Cry 2 editor

You are misquoting me. I never said it wasn't hard. All I said is the height map editor in it's basic form shouldn't be too hard. I agree with all leeornet said I didn't say he was wrong when he said it would be hard in fact a agreed with him.

As for the "buzzword" Far Cry 2 map editor I was just wanting him to know what I was going for in a way. I said that cause I knew I would get replies about using photoshop or paint or something which is not what I want to do.

Let me ask this though, should I make my own file format for this idea. I'm just jotting down ideas on paper right now. I know when I start adding objects like buildings and trees, and textures it gets way more complicated. But if I fail I fail what have I lost? Nothing. I learn and move on. Thanks for the post too.

##### Share on other sites
You could do something similar to how the Torque Game Engine works. Save your height field out as a separate file and then use a level format similar to the following:
new SimGroup(MissionGroup) {   canSaveDynamicFields = "1";   Enabled = "1";      cdTrack = "2";      CTF_scoreLimit = "5";      musicTrack = "lush";   new ScriptObject(MissionInfo) {      canSaveDynamicFields = "1";      Enabled = "1";         desc0 = "Humans have found your preliminary Core.  This outpost is crucial to our development.";         TypeS32 descLines = "2";         name = "Mission 1";   };   new MissionArea(MissionAreaObject) {      canSaveDynamicFields = "1";      Enabled = "1";      Area = "-360 -648 720 1296";      flightCeiling = "300";      flightCeilingRange = "20";         TypeBool locked = "true";   };   new Sky(SkyObject) {      canSaveDynamicFields = "1";      Enabled = "1";      position = "0 0 0";      rotation = "1 0 0 0";      scale = "1 1 1";      materialList = "scriptsAndAssets/data/skies/sky_skybox.dml";      cloudHeightPer[0] = "0.349971";      cloudHeightPer[1] = "0.3";      cloudHeightPer[2] = "0.199973";      cloudSpeed1 = "0.0005";      cloudSpeed2 = "0.001";      cloudSpeed3 = "0.0003";      visibleDistance = "500";      fogDistance = "500";      fogColor = "1 1 1 1";      fogStorm1 = "0";      fogStorm2 = "0";      fogStorm3 = "0";      fogVolume1 = "0 0 0";      fogVolume2 = "0 0 0";      fogVolume3 = "0 0 0";      windVelocity = "1 1 0";      SkySolidColor = "0.113 0.148 0.215 0";      useSkyTextures = "1";      renderBottomTexture = "1";      noRenderBans = "0";      renderBanOffsetHeight = "10";      skyGlow = "0";      skyGlowColor = "0 0 0 0";         TypeBool locked = "true";         windEffectPrecipitation = "1";   };   new Sun() {      canSaveDynamicFields = "1";      Enabled = "1";      azimuth = "0";      elevation = "30";      color = "1 1 0.8 1";      ambient = "0.4 0.4 0.5 1";         bloomAmount = "0.3";         bloomCutOff = "0.8";         bloomSeedAmount = "0.5";         castsShadows = "1";         direction = "0 0.954268 -0.298953";         DRLHighDynamicRange = "0";         DRLMax = "1";         DRLMin = "0.5";         DRLMultiplier = "0.9";         DRLTarget = "0.6";         TypeBool locked = "true";         position = "0 0 0";         rotation = "1 0 0 0";         scale = "1 1 1";         useBloom = "0";         useDynamicRangeLighting = "0";         useToneMapping = "0";   };   new TerrainBlock(Terrain) {      canSaveDynamicFields = "1";      Enabled = "1";      position = "-1024 -1024 0";      rotation = "1 0 0 0";      scale = "1 1 1";      detailTexture = "scriptsAndAssets/data/terrains/details/detail1";      terrainFile = "scriptsAndAssets/data/missions/1_0.ter";      squareSize = "8";      tile = "0";      detailDistance = "25";      detailScale = "256";      detailBrightness = "1";      texelsPerMeter = "8";      clipMapSizeLog2 = "10";         bumpOffset = "0.01";         bumpScale = "1";         TypeBool locked = "true";         zeroBumpScale = "8";   };ect, ect...

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627654
• Total Posts
2978450

• 10
• 12
• 22
• 13
• 33