Page 1 of 1

Terrain highlight - under mouse cursor

Posted: Thu Oct 06, 2016 11:09 am
by vasekkraka
How is it possible to draw a circular texture to the spot where the mouse is pointing.
For example, to mark the place where you drop the bomb? Or mark a player? As pictured below

It can be done without using a shader? For example, rendering to a texture?

Image

Re: Terrain highlight - under mouse cursor

Posted: Thu Oct 06, 2016 6:46 pm
by hendu
If your ground is flat, the easiest way is to place a quad at 0.01 y, textured with that circle.

Re: Terrain highlight - under mouse cursor

Posted: Fri Oct 07, 2016 6:24 am
by vasekkraka
If I'm right, it will not look too good for example on the hills, where it will fade texture inside the mountain?

Re: Terrain highlight - under mouse cursor

Posted: Fri Oct 07, 2016 9:31 am
by hendu
Your picture had no hills. With rugged terrain, you should use a shader.

Re: Terrain highlight - under mouse cursor

Posted: Fri Oct 07, 2016 9:42 am
by CuteAlien
Otherwise search the web for "decals". There is a decals solution in irrExt, but I just took a quick look and unless I've missed it (just spend half a minute quick-browsing the code) it didn't look like it can handle hills. So to make it look good you probably have to do it yourself. Basic idea is probably - project it only on floor. Use some way to get floor polygons fast (octree in Irrlicht, but not optimal for floors, quadtree or grid will both work better, but start with ISceneManager:: createOctreeTriangleSelector for least work). Collide a boundingbox of your decal (your texture) which is slightly extended in height against the floor polygons at that point. Then clip those floor polygons against that box. Create a mesh with those clipped polygons. Think careful about the uv's you need now.
Then draw those polygons slightly (tiny +y value) above the floor.

Post the code once you are done for bonus points :-)

Re: Terrain highlight - under mouse cursor

Posted: Sat Oct 08, 2016 1:48 pm
by Cube_
there are a few ways to do it - use a shader to project the texture over the X/Z plane in question is a simple extensible solution.

you could also project decals over it, - for every problem there's probably at least a dozen solutions (you could sample the heighfield and build an overlay mesh but it may be relatively poly dense) - in addition splat mapping should likely work, a megatexture would work too although it would be relatively computationally expensive to update in realtime - the benefit is that all decals would bake to the megatexture and would have a fixed vram and drawcall cost. (NOTE: irrlicht may or may not support megatextures, and you may or may not get legal trouble for using the technique - I'm not too sure about the patents for it and whether or not you could get sued for using it)