I've been trying to figure out the best way to create terrain for quite some time now, but I can't find the right solution...
First, I need to be able to (obviously) do collision detection. I couldn't do that with Irrlicht scenes.
Second, I need to be able to make it very detailed and highly populated with entities--houses, trees, bushes, monsters, etc.
Third, the terrain needs to be able to be fairly large--at least vector3df(300, 17.5f, 300) big.
I have tried using 3D Studio Max 9 to accomplish this, but simply creating the ground from a heightmap is above the poly count of the .3DS file exporter. I don't see how it would be possible to put detailed grass on Irrlicht-generated terrain created from a texture file, detailmap, and heightmap.
So, Irrlicht users, how do I create large, detailed, and collision-enabled terrain?
Best Way to Create Terrain
-
- Posts: 6
- Joined: Tue Jan 23, 2007 7:55 am
- Location: Yucca Valley, California, USA
- Contact:
-
- Posts: 67
- Joined: Wed Aug 02, 2006 1:47 am
This guy has a pretty interesting infinite terrain demo (no source):
http://www.wc3jass.com/asger/page.php?id=10
You might want to look at it to get some inspiration.
However that demo uses a procedurally-generated terrain. I wonder how easily such a procedurally-generated terrain can be tweaked (e.g. flatten this area here, carve out a river there). That would be pretty neat: by default you have an infinite, detailed, random terrain, but you still can bulldoze areas and add buildings or other geographical features.
It's probably less-than-trivial to implement, though. Any takers?
http://www.wc3jass.com/asger/page.php?id=10
You might want to look at it to get some inspiration.
However that demo uses a procedurally-generated terrain. I wonder how easily such a procedurally-generated terrain can be tweaked (e.g. flatten this area here, carve out a river there). That would be pretty neat: by default you have an infinite, detailed, random terrain, but you still can bulldoze areas and add buildings or other geographical features.
It's probably less-than-trivial to implement, though. Any takers?
-
- Posts: 6
- Joined: Tue Jan 23, 2007 7:55 am
- Location: Yucca Valley, California, USA
- Contact:
That's an interesting program, but it doesn't what I need. I simply need the terrain to be large, but designable. Like the way you can use heightmaps to generate terrain.
That's what I currently have, but I'm unsure how to put modelled, 3D grass onto the base grass texture.
MapClass.hpp:
MapClass.cpp:
Edit: Persistent 3D grass, that covers all grass areas, and is designed in a 3D program such as 3D Studio Max or Blender3D.
That's what I currently have, but I'm unsure how to put modelled, 3D grass onto the base grass texture.
MapClass.hpp:
Code: Select all
//---------------------------------------------------------------------------//
// Information //
// File: Include/MapClass.hpp //
// Description: Interface for MapClass. //
// Created: 01-23-07 //
// Copyright: Crazy Panda Games //
//---------------------------------------------------------------------------//
// History //
// [01-23-07] JerGri: Created. //
//---------------------------------------------------------------------------//
#ifndef __MAPCLASS_H__
#define __MAPCLASS_H__
// Includes
#include "irrlicht.h"
// Class
class MapClass
{
public:
MapClass();
void Load(irr::video::IVideoDriver* videoDriver,
irr::scene::ISceneManager* sceneManager,
irr::scene::ICameraSceneNode* camera,
const char* skyBoxTop, const char* skyBoxBottom,
const char* skyBoxLeft, const char* skyBoxRight,
const char* skyBoxFront, const char* skyBoxBack,
const char* heightmap, const char* texture,
const char* detailmap, irr::core::vector3df scale);
~MapClass();
};
#endif // __MAPCLASS_H__
Code: Select all
//---------------------------------------------------------------------------//
// Information //
// File: Source/MapClass.cpp //
// Description: Implementation for MapClass. //
// Created: 01-23-07 //
// Copyright: Crazy Panda Games //
//---------------------------------------------------------------------------//
// History //
// [01-23-07] JerGri: Created. //
//---------------------------------------------------------------------------//
#include "MapClass.hpp"
using namespace irr;
using namespace core;
using namespace gui;
using namespace io;
using namespace scene;
using namespace video;
//---------------------------------------------------------------------------//
// Information //
// Name: MapClass::MapClass //
// Description: MapClass constructor. //
// Created: 01-23-07 //
// Copyright: Crazy Panda Games //
//---------------------------------------------------------------------------//
// History //
// [01-23-07] JerGri: Created. //
//---------------------------------------------------------------------------//
MapClass::MapClass()
{
// Unused
}
//---------------------------------------------------------------------------//
// Information //
// Name: MapClass::Load //
// Description: MapClass loader. //
// Created: 02-04-07 //
// Copyright: Crazy Panda Games //
//---------------------------------------------------------------------------//
// History //
// [02-04-07] JerGri: Created. //
//---------------------------------------------------------------------------//
void MapClass::Load(IVideoDriver* videoDriver, ISceneManager* sceneManager,
ICameraSceneNode* camera, const char* skyBoxTop,
const char* skyBoxBottom, const char* skyBoxLeft,
const char* skyBoxRight, const char* skyBoxFront,
const char* skyBoxBack, const char* heightmap,
const char* texture, const char* detailmap,
vector3df scale)
{
// Set the mip-maps creation flag to false
videoDriver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
// Load the skybox
sceneManager->addSkyBoxSceneNode(videoDriver->getTexture(skyBoxTop),
videoDriver->getTexture(skyBoxBottom),
videoDriver->getTexture(skyBoxLeft),
videoDriver->getTexture(skyBoxRight),
videoDriver->getTexture(skyBoxFront),
videoDriver->getTexture(skyBoxBack));
// Set the mip-maps creation flag to true
videoDriver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true);
// Create the terrain scene node
ITerrainSceneNode* terrain = sceneManager->addTerrainSceneNode(heightmap);
// Set the terrain properties
terrain->setScale(scale);
terrain->setMaterialFlag(EMF_LIGHTING, false);
terrain->setMaterialTexture(0, videoDriver->getTexture(texture));
if (detailmap != "")
{
terrain->setMaterialTexture(1, videoDriver->getTexture(detailmap));
}
terrain->setMaterialType(EMT_DETAIL_MAP);
// Scale the texture
terrain->scaleTexture(1.0f, 20.0f);
// Create a triangle selector for the terrain
ITriangleSelector* selector =
sceneManager->createTerrainTriangleSelector(terrain, 0);
terrain->setTriangleSelector(selector);
selector->drop();
// Create collision response animator and attach it to the camera
ISceneNodeAnimator* animator =
sceneManager->createCollisionResponseAnimator(selector, camera,
vector3df(60, 100, 60),
vector3df(0, 0, 0),
vector3df(0, 50, 0));
camera->addAnimator(animator);
animator->drop();
}
//---------------------------------------------------------------------------//
// Information //
// Name: MapClass::~MapClass //
// Description: MapClass destructor. //
// Created: 01-23-07 //
// Copyright: Crazy Panda Games //
//---------------------------------------------------------------------------//
// History //
// [01-23-07] JerGri: Created. //
//---------------------------------------------------------------------------//
MapClass::~MapClass()
{
// Unused
}