New Tiled Terrain Scene Node [works with Irr 1.5]

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
varholl
Posts: 22
Joined: Thu Jul 12, 2007 6:59 pm
Location: Argentina
Contact:

Post by varholl »

Hi Arras, i'm using the scene node for a while, but my fps are always low...

I had poor video card (nVidia GeForce 7300Le) and my fps were 15... now i have an Ati hd2600XT Dx10 GDDR4 and my fps are 25... what could it be??

My pc is a Pentium Dual Core 2.8 Ghz, 1 Gb Ram (2x512 533Mhz) with the Ati video Card... what could it be?

thanks!!!

EDIT: One more data... the terrain is scaled for a really.. really... really large size.... i don't remember how much right now... but have in mind that my terrain is really huge... i suppose this couldn't be a problem because it always render the size amount of terrain, so... but i think it's good information for you.
A caos world where only the strongest lives, weak is not an option... you must fight.. Nokturna!!

http://nokturna.varholl.com.ar
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Hi varholl,
Your hardware should be OK. I run it on my old laptop at preatty nice FPS. Demo runs at about 600 for example.

Can you post your terrain initiation code? ...I would be interested what walues you insert in this line:

Code: Select all

ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, width, height, size, msize);
Also howe much FPS can you get running my demo?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Hey arras simple question. If I wanted to increase/decrease the view distance, which values should I change? I am guessing I should add to the meshsize and subtract from the normal size?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

View distance is set by mesh size and tile size.
Mesh size is defined in tiles, thats why also tilesize.

Formula basicly is:

view distance = mesh size * tilesize / 2

So if you want to decrease distance in which terrain is rendered you have two possibilities:
1. decrease mesh size
2. decrease tile size

Size of whole terrain (second and third argument in constructor) have no influecne on view distance.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Is it v1.4 compatible?
Kaeles
Posts: 37
Joined: Thu Jun 03, 2004 12:43 am
Location: oklahoma
Contact:

fps

Post by Kaeles »

on my x2 2.5ghz with 2gb ddr2-866 and 7600gt i get

50fps on opengl windowed, 70 fps on DX windowed

and about 550 on both in fullscreen....

why the big jump from windowed to fullscreen i wonder?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Its because your computer is doing less work rendering the windows of the operating system and focusing all its time on the current app.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

It may also depend to some extend on your hardware and its configuration. On my machine there is not such a great drop in performance between fullscreen and windowed mode.

It surly have nothing to do with code itself.
Raygoe
Posts: 2
Joined: Mon Nov 12, 2007 1:40 am
Location: Wichita, KS
Contact:

Post by Raygoe »

Hey, great job!

One problem though... Do you know why this isn't making the terrain repeat? (It does it a few times then stops)

Code: Select all

#include <irrlicht.h>
using namespace irr;

#include "ShTlTerrainSceneNode.h"
#include "MCamera.h"
#include "MInput.h"

int main()
{
    MyEventReceiver receiver;
    IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, core::dimension2d<s32>(800, 600), 32, false, false, false, &receiver);
   
    video::IVideoDriver *driver = device->getVideoDriver();
    scene::ISceneManager* smgr = device->getSceneManager();
    
    ITimer* timer = device->getTimer();
    
	// set atributes of terrain
	s32 terrainWidth = 255;
	s32 terrainHeight = 255;
	s32 meshSize = 100;
	f32 tileSize = 1;
	core::vector3df terrainPos(0.0f, 0.0f, 0.0f);

    // create terrain scene node
   ShTlTerrainSceneNode* terrain = new ShTlTerrainSceneNode(smgr, terrainWidth, terrainHeight, tileSize, meshSize);
   terrain->drop();
   //Fog
    driver->setFog(video::SColor(255,100,101,140), true, tileSize*meshSize/4, tileSize*(meshSize-4)/2, 0.05f);
   // load height data from texture
   terrain->loadHeightMap("../media/terrain-heightmap.bmp", 10);
   
   // load color map
   terrain->loadColorMap("../media/grass_1.bmp");
   
   // set detail texture
   terrain->setMaterialTexture(0, driver->getTexture("../media/grass_1.bmp"));
   
   // smooth normals
   terrain->smoothNormals();
   
   terrain->setMaterialFlag(video::EMF_LIGHTING, false);
   
   // setup camera
	MCameraFPS camera(smgr);
	camera.setNearValue(0.1f);
	camera.setFarValue(tileSize*meshSize/2);
	camera.setPosition(core::vector3df(terrainWidth*tileSize/2, 0, terrainHeight*tileSize/2) + terrainPos);
    
   
   // set terrain to follow camera
   terrain->follow(camera.getNode());
   
   // movement speed per second
   f32 speed = 10.0f * tileSize;
   f32 turn = 0.1f;
	
   // time
   f32 time = 0;
   f32 oldtime;
   
   // time between frames
   f32 deltaT;
   
   while(device->run())
    {
      driver->beginScene(true, true, video::SColor(255,100,101,140));
      
      // calculate time between frames
        oldtime = time;
        time = (f32)timer->getTime() / 1000.0f;
        deltaT = time - oldtime;
        
        // camera movement control
        if(key.pressed(KEY_KEY_W)) camera.moveForward(speed * deltaT);
        if(key.pressed(KEY_KEY_S)) camera.moveBack(speed * deltaT);
        if(key.pressed(KEY_KEY_D)) camera.moveRight(speed * deltaT);
        if(key.pressed(KEY_KEY_A)) camera.moveLeft(speed * deltaT);
        
        // mouse directional control
        camera.turnRight(50 * (device->getCursorControl()->getRelativePosition().X - 0.5f));
        camera.turnUp(50 * (device->getCursorControl()->getRelativePosition().Y - 0.5f));
        device->getCursorControl()->setPosition(0.5f, 0.5f);
        
        // camera height control
        if (mouse.wheel < 10) mouse.wheel = 10;
        camera.setHeight(  mouse.wheel/10 + terrain->getHeight(camera.getPosition())  );
        
        // intersection with line test
        if(mouse.left)
        {
            core::vector3df v = camera.getDirection();
            v = v * camera.getFarValue();
            
            v = v + camera.getPosition();
            core::line3d<f32> line = core::line3d<f32>(camera.getPosition(), v);
            core::vector3df intersection;
            
            //if(terrain->getIntersectionWithLine(line, intersection) )
                //test->setPosition(intersection);
        }
        
      smgr->drawAll();
      
      driver->endScene();
      
      
    }
    device->drop();
   
    return 0;
}
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

There is nothing in that code that will make the terrain repeat.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Raygoe >> thanks.

I am not sure what do you mean by "making the terrain repeat". As BlindSide wrote, terrain do not repeat itself and there is nothing in your code which does.
I think by repeat you mean shift. If yes then it would "repeat itself" only until you reach border. Your terrain is 255x255 tiles large and 100x100 tiles area is actually rendered. Means your terrain is relatively small and it do not take lot of time to reach its border. (In comparison in my demo terrain is 2000x2000 tiles large.)
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Would the code fit when added into scene:: as another class for example CDynamicTerrainSceneNode?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Probably yes.
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

what's the license of the code? can i use it to extend and set up a new scene node?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

No restrictions, code is free to use and modify. Some small credit wont hurt of course ;)

Few people already did some modification to my code, you can look at elvman's work for example.
Post Reply