Quad tilemap

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Inagawa
Posts: 5
Joined: Wed Jul 18, 2012 12:25 pm

Quad tilemap

Post by Inagawa »

Hello,
I'd like to create a tilemap, but it has to be resizeable (since the player will be able to zoom in and out). The only method of scaling a texture that I found is inconvenient and so it seems more logical to use a quad polygon with a texture. How would I create a simple quad polygon with a let's say 64x64 texture? The example 3 didn't help me.

Thank you
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Quad tilemap

Post by hybrid »

For a simple quad you don't need a custom scene node, just a simple mesh. If you don't want to use Irrlicht's createPlaneMesh (which does exactly what you want), you can also use example 23 to learn about custom SMesh creation.
Inagawa
Posts: 5
Joined: Wed Jul 18, 2012 12:25 pm

Re: Quad tilemap

Post by Inagawa »

For some reason it gets created with a rotation. I fixed it with _master.Rotation = new Vector3Df(0, 90, 0);

Does this code look okay to you?

Code: Select all

 
            _geometryCreator = Root.SceneManager.GeometryCreator;
 
            _plane = _geometryCreator.CreatePlaneMesh(new Dimension2Df(64.0f));
 
            _master = Root.SceneManager.AddMeshSceneNode(_plane);
            _master.Position = new Vector3Df(0, 0, 0);
 
            Texture texture = Root.VideoDriver.GetTexture("Graphics/tex.png");
            _master.SetMaterialTexture(0, texture);
            _master.SetMaterialType(MaterialType.Solid);
            _master.Rotation = new Vector3Df(0, 90, 0);
 
            Root.SceneManager.AddLightSceneNode(null, new Vector3Df(0, 100, 0), new Colorf(1, 1, 1), 500.0f);
 
            CameraSceneNode camera = Root.SceneManager.AddCameraSceneNode();
            camera.Position = new Vector3Df(0.0f, 500.0f, 0.0f);
            camera.Target = new Vector3Df(0.0f, 0.0f, 0.0f);
            camera.FarValue = 20000.0f;
 
Thanks for the response.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Quad tilemap

Post by hybrid »

I actually never tested the plane node with a texture, but it may for sure happen that you need the plane in a different rotation. The code looks ok, though.
zhengxianfu
Posts: 16
Joined: Thu Apr 05, 2012 9:33 am

Re: Quad tilemap

Post by zhengxianfu »

I am interesting about tilemap
Inagawa, how did you create your map ,did you using Tiled from http://www.mapeditor.org/ ?
Inagawa
Posts: 5
Joined: Wed Jul 18, 2012 12:25 pm

Re: Quad tilemap

Post by Inagawa »

zhengxianfu: No, I will have to create a Tilemap object that keeps a bunch of tiles that are visible on the screen and if the player moves the camera, new sectors of tiles will have to be read from a file and the old tiles that are no longer visible will have to be destroyed. I don't believe that mapeditor offers any such dynamic capability. And in case you meant how I generate the data for a tilemap, that's a matter of creating a generator, not an editor.

hybrid: Thanks for the confirmation on the code, even though it's a little strange that it has rotation for no apparent reason.
CuteAlien
Admin
Posts: 9926
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Quad tilemap

Post by CuteAlien »

You could rotate the camera instead. The reason it's like that is that it's based on createHillPlaneMesh, but it would certainly be nicer if it would be possible to pass a plane normal on creation. Maybe add an entry to the feature-tracker (https://sourceforge.net/tracker/?atid=5 ... unc=browse) for that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Quad tilemap

Post by hybrid »

Hmm, I thought it was a rotation around the y-axis, not a back side view of the plane?!
zprg
Competition winner
Posts: 30
Joined: Tue Jul 31, 2012 12:29 pm
Location: Germany

Re: Quad tilemap

Post by zprg »

>No, I will have to create a Tilemap object that keeps a bunch of tiles that are visible on the screen and if the player moves the >camera, new sectors of tiles will have to be read from a file and the old tiles that are no longer visible will have to be destroyed
an other version could be if the view moves that you dont change camera, dont create new tiles and delete others - the camera always shows the same tiles, but you change the tiles - the tiles are the stage. i remember there was an old tutorial from saigumi called "seamless world" you may find if you seek?
Post Reply