GeoMipMapped Terrain Scene Node ( UPDATED 3/3/05 )
A brand new sample application, showing the use of the new triangle selector I've added today!!!! It's just like the Collision example, in that it draws a line from the camera to where the camera's looking at and draws a then draws a red triangle over the triangle where the line intersects with the geomipmapscenenode.
http://www.spintz.com/irrlicht/geomipma ... st2Exe.zip
http://www.spintz.com/irrlicht/geomipma ... st2Exe.rar
Same commands as last example -
* [F1] toggles the debug window
* [F2] toggles the patch visible window
* [1] makes wireframe
* [2] makes textured
* [~] takes screenshot ( screenshots are saved in the local directory, you can take as many as you'd like, they create a new filename each time you take one )
The sample heightmap for this one is 128x128. You can select DirectX 8 or 9 or OpenGL, the software renderer will not work with this with my engine ( I haven't updated code to the software renderer ).
Here's 2 screenshots of this demo application -
http://www.spintz.com/irrlicht/geomipma ... st2Exe.zip
http://www.spintz.com/irrlicht/geomipma ... st2Exe.rar
Same commands as last example -
* [F1] toggles the debug window
* [F2] toggles the patch visible window
* [1] makes wireframe
* [2] makes textured
* [~] takes screenshot ( screenshots are saved in the local directory, you can take as many as you'd like, they create a new filename each time you take one )
The sample heightmap for this one is 128x128. You can select DirectX 8 or 9 or OpenGL, the software renderer will not work with this with my engine ( I haven't updated code to the software renderer ).
Here's 2 screenshots of this demo application -
-
- Posts: 124
- Joined: Sun Jun 27, 2004 11:02 am
- Contact:
Hey Spintz, awesome demos BUT i can't get the code to work! It compiles ok and i applied those 32-16bit changes but it still doesn't work... It seems to be that rather than running the terrain strips parallel, it just sticks em on top of each other
I was using 0.6 but i switched because i thought it was the problem and the same thing happens with 0.7.1 I've got an ATI Radeon 9600XT and i'm using .net 2003 and i've tried *all* driver options yet there's no difference... See further down for my test app's main function (it uses the textures from your demos cause i wanted to make sure it all worked) If you want i can also upload my engine source somewhere too (or parts of it)
This is annoying me because i really do want to use this terrain system because it's so damn good! I could use LibMini but it'd be better to get this one working...
PS. I have added other addons to my irrlicht's source. (RTS camera, MD3 loader and skydome support)
It seems weird that the demos work fine yet my compiled versions f00k
I was using 0.6 but i switched because i thought it was the problem and the same thing happens with 0.7.1 I've got an ATI Radeon 9600XT and i'm using .net 2003 and i've tried *all* driver options yet there's no difference... See further down for my test app's main function (it uses the textures from your demos cause i wanted to make sure it all worked) If you want i can also upload my engine source somewhere too (or parts of it)
This is annoying me because i really do want to use this terrain system because it's so damn good! I could use LibMini but it'd be better to get this one working...
PS. I have added other addons to my irrlicht's source. (RTS camera, MD3 loader and skydome support)
Code: Select all
#include <irrlicht.h>
using namespace irr;
#pragma comment(lib, "Irrlicht.lib")
int main()
{
IrrlichtDevice *device =
createDevice(video::EDT_DIRECTX9, core::dimension2d<s32>(640, 480),32);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
// driver->setTextureCreationFlag(video::ETCF_OPTIMIZED_FOR_QUALITY,true );
scene::IGeoMipMapSceneNode *node = smgr->addGeoMipMapSceneNode(0,-1,5,17,
core::vector3df ( 0.0f, 0.0f, 0.0f ),
core::vector3df ( 0.0f, 0.0f, 0.0f ),
core::vector3df ( 100.0f, 0.0f, 100.0f ));
node->LoadHeightMap("freeworld04.bmp");
node->setMaterialTexture(0,driver->getTexture("grassdetail.bmp"));
node->setMaterialTexture(1,driver->getTexture("freeworld04_lightmap.bmp"));
node->setMaterialFlag(video::EMF_LIGHTING,false);
// node->setMaterialFlag(video::EMF_WIREFRAME,true);
node->setMaterialType(video::EMT_LIGHTMAP);
scene::ITriangleSelector *selector = smgr->createTriangleSelector(node);
node->setTriangleSelector(selector);
selector->drop();
scene::ICameraSceneNode* camera = smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
video::SMaterial material;
material.Texture1 = 0;
material.Lighting = false;
while(device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
core::line3d<f32> line;
line.start = camera->getPosition();
line.end = line.start + (camera->getTarget() - line.start).normalize() * 1000.0f;
core::vector3df intersection;
core::triangle3df tri;
if (smgr->getSceneCollisionManager()->getCollisionPoint(line, selector, intersection, tri))
{
driver->setTransform(video::ETS_WORLD, core::matrix4());
driver->setMaterial(material);
driver->draw3DTriangle(tri, video::SColor(0,255,0,0));
}
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
wchar_t tmp[1024];
swprintf(tmp, 1024, L"Terrain Example - Irrlicht Engine (fps:%d) Triangles:%d",
fps, driver->getPrimitiveCountDrawn());
device->setWindowCaption(tmp);
lastFPS = fps;
}
}
device->drop();
return 0;
}
2.8GHz P4 with HT - 512MB DDR - ATI Radeon 9600XT 256MB - Windows XP - VC++ 6 and VC++ 2003
Dark Reign 3 Home Page: http://darkreign3.notwhatyouthink.org/
Dark Reign 3 Forums: http://notwhatyouthink.org/darkreign3bb/
Dark Reign 3 Home Page: http://darkreign3.notwhatyouthink.org/
Dark Reign 3 Forums: http://notwhatyouthink.org/darkreign3bb/
Captain_Kill, increase you camera's far plane. You're scaling the terrain by 100 units in each direction. Since the heightmap you're using is 512x512, you're terrain, in Irrlicht units is 51200x51200. Thh default far plane for the camera scene node is 2000.0f, so you'd barely see anything.
Also, make the line that you are passing to your selector much longer as well, I'd recommend something like this -
Also, make the line that you are passing to your selector much longer as well, I'd recommend something like this -
Code: Select all
line.end = line.start + (camera->getTarget() - line.start).normalize() * 100000.0f;
Another note, backface culling is enabled, so if you are under the terrain, you won't see anything, however, in your application Captain_Kill, if the line you're passing to the collision test is long enough, you should see the red triangle, even if you're under the terrain.
I'm going to try my changes myself with the original Irrlicht 0.7.1 and see how they work. Maybe there are issues, I really should've done this in the first place. I'll post here and update the directions if I find anything amiss.
I'm going to try my changes myself with the original Irrlicht 0.7.1 and see how they work. Maybe there are issues, I really should've done this in the first place. I'll post here and update the directions if I find anything amiss.
Ok, I found some mistakes and things I left out on the webpage as far as adding the code to the engine goes, I'm going to fix them asap. However, the problem you're having, since you've gotten it working ( and I had the same problem with the base Irrlicht engine ) is that the terrain is so large, it's generating indices larger than the u16 can handle, if you use a smaller heightmap, like 128x128, as opposed to the 512x512, you'll see the node working properly.
I'm thinking people using this need to also upgrade the engine to support 32 bit indices. The simple fix for now, would be to re-write the GeoMipMap code to use it's own mesh buffer, so you could have u32 indices and then show patches to upgrade the drawPrimitive calls to support u32 indices. For now, you'll just have to use a smaller terrain until we can do that.
I'm thinking people using this need to also upgrade the engine to support 32 bit indices. The simple fix for now, would be to re-write the GeoMipMap code to use it's own mesh buffer, so you could have u32 indices and then show patches to upgrade the drawPrimitive calls to support u32 indices. For now, you'll just have to use a smaller terrain until we can do that.
ok now i changed to u16 but i get following errors:
i use irrlicht 7.1 and DevC++, any suggestion ?
Code: Select all
CGeoMipMapSceneNode.cpp: In member function `virtual void
irr::scene::CGeoMipMapSceneNode::OnPreRender()':
CGeoMipMapSceneNode.cpp:256: error: `abs' undeclared (first use this function)
CGeoMipMapSceneNode.cpp:256: error: (Each undeclared identifier is reported
only once for each function it appears in.)
make.exe: *** [CGeoMipMapSceneNode.o] Error 1
Awesome! In order to explain how to change the whole engine to use 32 bit indices, is a bit much, I think I'm going to just make a version that maintains it's own vertices and indices and then how to add the drawPrimitive functions for 32 bit indices.
Using 32 bit indices is much, much better, because you can use huge terrains. Like I've said, I'vesuccesfully loaded and ran a hieghtmap that was 4096x4096!!! And still got pretty decent framereates considering the size, it was on a high end machine though. It'll take some time for that, I'll post here and update the code when I get this done.
Using 32 bit indices is much, much better, because you can use huge terrains. Like I've said, I'vesuccesfully loaded and ran a hieghtmap that was 4096x4096!!! And still got pretty decent framereates considering the size, it was on a high end machine though. It'll take some time for that, I'll post here and update the code when I get this done.
-
- Posts: 62
- Joined: Fri Jan 07, 2005 4:37 pm
- Location: California
Ok, my problem was that the headers were old and the new headers here not being found... fixed...
now, using the map provided, i keep getting seg. faults....
spintz, could the seg. faults have to do with the 16bit indices ???
anyways, nice screenshots, keep up the good work... The one thing that is really holding me (and probably more people) back from cool apps, is the lack of a good terrain engine in irrlicht...
now, using the map provided, i keep getting seg. faults....
spintz, could the seg. faults have to do with the 16bit indices ???
anyways, nice screenshots, keep up the good work... The one thing that is really holding me (and probably more people) back from cool apps, is the lack of a good terrain engine in irrlicht...