Page 12 of 23

Posted: Wed Sep 05, 2007 3:06 pm
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.

Posted: Wed Sep 05, 2007 4:21 pm
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?

Posted: Wed Sep 05, 2007 7:07 pm
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?

Posted: Wed Sep 05, 2007 7:33 pm
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.

Posted: Mon Oct 08, 2007 1:42 pm
by MasterGod
Is it v1.4 compatible?

fps

Posted: Fri Nov 09, 2007 1:42 pm
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?

Posted: Fri Nov 09, 2007 2:49 pm
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.

Posted: Fri Nov 09, 2007 5:20 pm
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.

Posted: Mon Nov 12, 2007 1:41 am
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;
}

Posted: Tue Nov 13, 2007 2:06 am
by BlindSide
There is nothing in that code that will make the terrain repeat.

Posted: Tue Nov 13, 2007 10:04 am
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.)

Posted: Wed Nov 28, 2007 11:05 am
by dlangdev
Would the code fit when added into scene:: as another class for example CDynamicTerrainSceneNode?

Posted: Thu Nov 29, 2007 9:47 am
by arras
Probably yes.

Posted: Thu Nov 29, 2007 9:49 am
by dlangdev
what's the license of the code? can i use it to extend and set up a new scene node?

Posted: Thu Nov 29, 2007 12:38 pm
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.