About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
World map generation
Author Message
Impz0r Offline
Member

Post: #1
World map generation
Hey there,

I was wondering if it is possible to create a world not by using the World Editor but by creating the World in a dynamic fashon. That is creating a heighmap image by some kind of noise generator (perlin) and using this heighmap to create a world. (Btw no streaming is needed, on big area would be just fine)

Is this possible Esenthel and if so, how?

Thanks in advance.

Imp
07-19-2010 07:01 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #2
RE: World map generation
Well u can load a 2D heighmap image in the WE to generate/create a world. Dunno how else u wanna do this.

There is always evil somewhere, you just have to look for it properly.
07-19-2010 08:08 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Tottel Offline
Member

Post: #3
RE: World map generation
It certainly is possible. You can use both Height- and Colour maps.
07-19-2010 09:12 PM
Find all posts by this user Quote this message in a reply
Impz0r Offline
Member

Post: #4
RE: World map generation
Thanks to you both!

So how exactely is it possible Tottel? I mean I do know how to create an image and how to fill it pixel wise. What i dont know is, how I have to proceed from there i.e. how to actually build a world area with this all new heighmap.

Any hint would be much appreciated!

PS: I do NOT want to use the World Editor. It hast to be possible all within code (if it is possible that is). wink

Imp
(This post was last modified: 07-19-2010 10:14 PM by Impz0r.)
07-19-2010 10:09 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: World map generation
isnt there a tutorial about heightmap generation?
terrain.cpp or something
07-20-2010 12:03 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #6
RE: World map generation
Strange, I thought I saw it somewhere before, cant find it anymore though
07-20-2010 03:31 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #7
RE: World map generation
EsenthelEngineSDK\Tutorials\Source\Advanced\3 - Mesh, Shaders\Mesh\Terrain.cpp?

There is always evil somewhere, you just have to look for it properly.
07-20-2010 04:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Harry Offline
Member

Post: #8
RE: World map generation
I haven't got this tutorial, but it was here grin
07-20-2010 06:09 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Silver Supporter

Post: #9
RE: World map generation
Cant say its there Dynad :S
07-20-2010 07:31 PM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #10
RE: World map generation
Well perhaps its from an old version.

Here is the code:

PHP Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Image     ground;
MeshGroup mshg  // here MeshGroup is used instead of a Mesh (single mesh)
/******************************************************************************/
void InitPre()
{
   
App.name("Terrain");
   
App.flag=APP_MS_EXCLUSIVE|APP_FULL_TOGGLE;
   
IOPath("../data");
   
Paks.add("engine.pak");

   
D.full(true).ambPower(0.3).hpRt(true).shdSoft(1);
   
ViewportFull.range=40;
}
/******************************************************************************/
void CreateMesh(Mesh &mesh)
{
   
// create random terrain heightmap
   
Image  image(128,128,1,IMAGE_I8,IMAGE_SOFT);
   
REPD(y,image.y())
   
REPD(x,image.x())image.pixel(x,y,Random(256)); // software images don't need to be locked/unlocked
   
image.blur(5,false);                           // apply gaussian blur to the heightmap with 5 pixel range and no clamping

   // create terrain Mesh
   
mesh.create(1).base(0).createPlane(128,128,VTX_TEX0); // create 2D plane with 128x128 vertexes
   
mesh.base(0).texScale (Vec2(16));                     // scale texture coordinates
   
mesh.base(0).displaceZ(image,FILTER_BILINEAR);        // displace vertexes Z position from heightmap
   
mesh.transform(Matrix().setPos(Vec(-0.5,-0.6,-0.5)).rotateX(PI_2).scale(Vec(50,8,50))); // transform by matrix
   
mesh.setNormals();                                    // recalculate normals
   
mesh.setMaterial(Materials("mtrl/grass/0.mtrl"));     // set material
   
mesh.setBox();                                        // set bounding box
}
/******************************************************************************/
Bool Init()
{
   
Cam.at.y+=2// move camera up

   
Sky.atmospheric();
   
Sun.image=Images("gfx/sky/sun.gfx");

   
// create mesh
   
Mesh mesh;
   
CreateMesh(mesh);

   
// create terrain MeshGroup from standard Mesh
   
mshg.create(mesh,VecI(5,1,5)); // create MeshGroup with 5x1x5 (5*1*5=25) splits (Mesh is splitted to 25 parts along axises)
   
mshg.setRender();

   return 
true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Update()
{
   if(
Kb.bp(KB_ESC))return false;
   
CamHandle(0.01f,10,CAMH_ZOOM|(Ms.b(1) ? CAMH_MOVE CAMH_ROT));
   return 
true;
}
/******************************************************************************/
void Render()
{
   switch(
Renderer())
   {
      case 
RM_PREPARE:
         
mshg.draw(MatrixIdentity);
      break;
   }
}
void Draw()
{
   
Renderer(Render);
   if(
Kb.b(KB_SPACE))
   {
      
SetMatrix();
      
REPA(mshg)mshg.mesh(i).box.draw(); // draw mesh bounding boxes
   
}
}
/******************************************************************************/ 

There is always evil somewhere, you just have to look for it properly.
07-20-2010 08:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: World map generation
it's possible I removed it smile anyway it's just creating meshes.
you can create everything manually by filling the MeshBase members
07-20-2010 09:31 PM
Find all posts by this user Quote this message in a reply
Impz0r Offline
Member

Post: #12
RE: World map generation
Thanks guys, much appreciated!

I'll give it a shot smile


Imp
07-21-2010 02:11 PM
Find all posts by this user Quote this message in a reply
XSoulFireX Offline
Member

Post: #13
RE: World map generation
Thanks, this is awesome. smile
10-14-2010 05:26 PM
Find all posts by this user Quote this message in a reply
Demi Offline
Member

Post: #14
RE: World map generation
I am not sure what the OP is after here but I personally use L3DT to create the terrains.

I just ran off a new map this weekend as I try a new methiod out. So far it is impressive how the blocks can be placed and my map is not square or even rectangular now. smile
10-18-2010 10:40 PM
Find all posts by this user Quote this message in a reply
Post Reply