Terrain Cut Editor Plugin

Terrain Cut Editor Plugin

Postby Shockeye » Sun Jan 01, 2012 2:42 am

Hi all,
Here's a new plugin that implements the terrain hole idea discussed here
This is a more useful version than the experimental implementation I attached to the ModularZonePlugin. (now removed)
As a standalone editor it can be used with anywhere, not just with the ModularZonePlugin.

Terrain Cut Editor Plugin
Usage:
You can drag a TerrainCutEditor object into to your scene. There is a cube which will represent the bounding box of the editor. It projects a decal mesh onto the terrain below. It can be moved & rotated into position with the standard tools & can be resized using the scale tool. When the scene is exported, it will the Terrain Cut will be exported as follows:
Code: Select all
        <node name="Terrain Cut#0" id="966612736">
            <position x="-92.1687" y="185.86" z="-186.055" />
            <rotation qw="1" qx="0" qy="0" qz="0" />
            <scale x="1.0" y="1.0" z="1.0" />
            <terrain_cut name="Terrain Cut#0" x="6" y="6">
                <box x="5.63914" y="1.99834" z="5.63914" />
            </terrain_cut>
        </node>

Which provides all the data to recreate the decal in your scene. The bounding box is useful for collision tests. The editor will only produce the cut within the bounding box, ie the box needs to intersect the terrain. By disabling terrain collision on any object within the bounding box, the hole will be traversed as though there was an actual gap in the terrain instead of a tranparent decal.
I've added some code to my PCZ sceneloader to give an idea of how to load the terrain cut from a dotscene file. Basically you create a mesh decal based on the data loaded from the dotscene file, set its material approriately & assign anything that you don't want a hole thru into a different render queue. I haven't implemented the collision test yet because the loader doesn't really have a proper collision system yet.
Screenshots/Video:
[TODO] :)

Notes:
*In the editor* the tranparency only allows you to see the base of the world and the sky box, because all objects in Ogitor are in RENDER_QUEUE_MAIN. This means the transparency is applied to them as well as the terrain. (It worked with the Modular Zone plugin experiment because I could move zones into whatever render queue I like).I have an idea for a solution but it may be a bit naughty - when the first TerrainCutEditor is added into the world, it could iterate through all objects & shove them into another render queue. For the time being, you'll just see a hole in the terrain with nothing on the other side until you load it into to your game/viewer/other external program.
Cmake script is only set up for Windows. Linux will follow when I get around to it, but I have no access to a Mac, so Apple support will be a long time coming.

License: MIT
The TerrainCutEditor plugin repository is at https://bitbucket.org/Shockeye/terraincutter
The PCZLoader is at https://bitbucket.org/Shockeye/pczloader
User avatar
Shockeye
Ogitor Team
 
Posts: 106
Joined: 26 Jan 2010

Re: Terrain Cut Editor Plugin

Postby spacegaier » Sun Jan 01, 2012 4:20 pm

Wow, that sounds great. Will try to give it a go, once I am back on my dev machine!

BTW: Happy New Year!
User avatar
spacegaier
Ogitor Team
 
Posts: 1052
Joined: 12 Mar 2010
Location: Germany

Re: Terrain Cut Editor Plugin

Postby unsane » Tue Jan 03, 2012 3:44 am

Nice work!!! Thank you,Shockeye!
unsane
 
Posts: 3
Joined: 10 May 2011

Re: Terrain Cut Editor Plugin

Postby duststorm » Sat Jan 14, 2012 10:31 pm

Pretty neat feature that is.
I wonder, how much of a performance hit would you guess the holes in the terrain are? Would you be able to use it on a large scale, for example to cut away terrain under a road if there are quite a lot of roads on your piece of terrain.

Also, am I correct if I believe that in a scene with a lot of terrain pages that are organised using a caching system, that the cutouts of the terrain would have to be managed (cached) separately, as they are not integrated with the terrain?
User avatar
duststorm
 
Posts: 25
Joined: 27 Sep 2010

Re: Terrain Cut Editor Plugin

Postby Shockeye » Sun Jan 15, 2012 10:22 am

Thanks, guys!
@unsane I hope this makes up for my unilaterally removing the terraincutter from my other plugin. :)

@duststorm I don't know what the performance hit would be. I've only ever considered using it for tunnel entrances, etc. So there normally wouldn't by too many cuts in that scenario. The cuts are always rectangular, so they only way I could see this working for roads would be straight cuttings thru hills, which, once again there wouldn't be too many of. (Unless you had a really lousy town planner with a really big budget :) ) Anyway, they are just decal meshes, so it would be comparable to terrain splatting, although the transparent blending might be more costly than the opaque kind. (That's just a guess... :) )
duststorm wrote: terrain pages that are organised using a caching system, that the cutouts of the terrain would have to be managed (cached) separately, as they are not integrated with the terrain?
Well, since the end user needs to implement their own loading system, you can set it up however you need. The paging component of Ogre is very versitile, you can derive classes to handle anything. (In theory. As yet the documentation is a bit limited, so you'd have to be pretty motivated to wade through the code to work out how to roll your own custom system) So you could expand on the terrain system to attach decals to the right terrain page and have them handled together. I haven't really thought about it - but check how normal terrain decals are handled, maybe they are already implemented that way anyway. :?:
User avatar
Shockeye
Ogitor Team
 
Posts: 106
Joined: 26 Jan 2010

Re: Terrain Cut Editor Plugin

Postby Andrew » Sun Apr 01, 2012 10:21 am

Would it be possible to implement this as a kind of splat layer in the existing terrain editor? That way I could paint holes in the terrain which would be really cool. :)
User avatar
Andrew
Ogitor Team
 
Posts: 144
Joined: 02 Aug 2010

Re: Terrain Cut Editor Plugin

Postby syedhs » Sun Apr 01, 2012 6:38 pm

Splat layer just for a hole or two is waste of slot ;) What I remembered from some discussions about this is using stencil buffer (but never tried it myself):-
http://www.ogre3d.org/forums/viewtopic.php?f=2&t=59926
syedhs
 
Posts: 25
Joined: 12 Oct 2011

Re: Terrain Cut Editor Plugin

Postby Shockeye » Wed Apr 04, 2012 10:57 am

Actually, its not stencil buffer. I started out using that, but found it has a fundamental flaw: It stencils through any terrain (actually anything in the main render queue) that it intersects, so say if you have a small hill in front of your cave entrance, that hill will have a hole in it if it is positioned between the camera and the stencil. I think this is 'coz it is not a 3d thing, it is a 2d mask created from the 3d, then applied to the main renderqueue. I think... ( :?: )

So this is just using a transparent decal texture blend thingy. Me not good terminology stuff. :)
User avatar
Shockeye
Ogitor Team
 
Posts: 106
Joined: 26 Jan 2010

Re: Terrain Cut Editor Plugin

Postby jacmoe » Wed Apr 04, 2012 12:19 pm

This thing really kicks stencil buffer's arse! :)
User avatar
jacmoe
Ogitor Team
 
Posts: 1750
Joined: 25 Jan 2010
Location: Denmark

Re: Terrain Cut Editor Plugin

Postby Andrew » Sat Nov 03, 2012 9:05 am

I finally got around to looking at this and it's working nicely for me on linux...

terraincut.jpg


I've forked the repo and added linux support here:
https://bitbucket.org/andrewfenn/terraincutter/

There are two issue's however..
  • in that if you open an ogscene the terrain won't get cut until you move the object in the scene.
  • there is no icon in the resources manager, this is partly ogitor's fault because we should give all objects a default icon if one doesn't exist.
User avatar
Andrew
Ogitor Team
 
Posts: 144
Joined: 02 Aug 2010

Next

Return to General Plugin Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron