new new tile engine

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
turican
Posts: 3
Joined: Tue May 15, 2007 2:02 pm

new new tile engine

Post by turican »

I create big modification for this solution, where speed 3x increase.
Can use it with physical engine, LOD, apod.
This solution use more tiles, this tiles are moved when camera move to heir border and are draw only visible tiles.

more about this solution and code for download is here:
http://magicresurection.ic.cz/index.php ... 4&Itemid=2
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Hi turican, I am glad you have found some use of my terrain node.

Your modification is interesting. There are some things I don't understand however.
This engine in ever farme copy tarrain to one tile and shis tile is rendered.
Copy in every frames is not good, In huge terrain take any FPS.
I think you refer here to proces when visible terrain mesh is updated from data arrays. Update however does not happen every frame. It happen only when told to ...mostly when camera move certain distance.

Function which controls if mesh needs to be updated is this (look at last if() ):

Code: Select all

// set rendered mesh position relative to terrain
void ShTlTerrainSceneNode::setMeshPosition(core::vector2d<s32> pos)
{
    // correct if out of terrain bounds
    if(pos.X < 0) pos.X = 0;
    if(pos.Y < 0) pos.Y = 0;
    
    if(pos.X > (s32)(Size.Width - MeshSize.Width)) pos.X = (s32)(Size.Width - MeshSize.Width);
    if(pos.Y > (s32)(Size.Height - MeshSize.Height)) pos.Y = (s32)(Size.Height - MeshSize.Height);
    
    // update
    if(pos.X > MeshPosition.X + ShStep || pos.X < MeshPosition.X - ShStep ||
       pos.Y > MeshPosition.Y + ShStep || pos.Y < MeshPosition.Y - ShStep)
    {
        MeshPosition = pos;

        update();
    }
}
Create more tile with some LOD and when camera move to borders tile, last tile move before first.
Do you mean more tiles or more sectors?
Next optimalization is change from rendering all tiles:
...
To only tiles in view:
...
Not all tiles are rendered. Every frame there is test if sector (mesh buffer) is on screen. If it is not its tiles are not rendered. Test happen in void ShTlTerrainSceneNode::render()

Code: Select all

// test if sectors are vissible
    for(u32 j=0; j<Sector.height(); j++)
        for(u32 i=0; i<Sector.width(); i++)
            if( isSectorOnScreen( &Sector(i,j) ) ) Sector(i,j).isVissible = true;
            else Sector(i,j).isVissible = false;
function which actulay perform test is isSectorOnScreen(TlTSector* sctr)
turican
Posts: 3
Joined: Tue May 15, 2007 2:02 pm

Post by turican »

Hi arras.

Update every frame - my mistake, I disremember how it works :)


Do you mean more tiles or more sectors?
-yes, better name is sectors. Big tiles include small tiles.

Not all tiles are rendered
-I have old code, and here no function isSectorOnScreen:
virtual void render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();

driver->setMaterial(buffer->Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList
(&buffer->Vertices[0], buffer->getVertexCount(),
&buffer->Indices[0], buffer->getIndexCount()/3 );
}
Can give me link to actual code?


I make any repair my code and cleaning(camera not as parameter), cleaning parts where no terrain code and push to my pages.
Small tune increase fps about 5%, too.
turican
Posts: 3
Joined: Tue May 15, 2007 2:02 pm

Download

Post by turican »

arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Code is here:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=20940
May be you are using old TlTerrainNode.

isSectorOnScreen() is private member:

Code: Select all

class ShTlTerrainSceneNode : public scene::ISceneNode
{
    ....
    
    // return true if sector is on screen
    virtual bool isSectorOnScreen(TlTSector* sctr);
    
    // update vertices of sector
    virtual void updateVertices(TlTSector &sector);
    
    // update 2nd texture layer
    virtual void updateTexture(u32* p, TlTSector &sector);
    
    // return true if 3d line colide with tile
    virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d<f32> line,  
        core::vector3df &outIntersection);
    
public:
    ...
Post Reply