Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Ruaumoko: iso-surface, voxel mesh generation and terrain engine

Discussion in 'Assets and Asset Store' started by bens1984, Apr 29, 2013.

  1. Curious

    Curious

    Joined:
    Nov 19, 2009
    Posts:
    334
    Hi,
    Are you going to include Dual Contouring in Ruaumoko as well? I mean, you said you would and that would be really awesome :)
     
  2. mryan150

    mryan150

    Joined:
    Feb 21, 2013
    Posts:
    6
    Hi, We are considering buying your tool, and have a few questions.
    1. I was wondering if there was some way in your tool to define block types in order for them to be called in script later. Basically, is there a way to make unity know which is a grass block, which is stone etc.?
    2.Also, is there a way to create terrain in the editor, or is it all randomly generated? We would like to be able to sculpt the terrain in the editor, basically make a plane, and sculpt from there.
    3. Can you add object prefabs and have them be made into voxels and edited with the sculpting tool?

    Thanks for your input, the tool looks amazing!
     
  3. Dagarath

    Dagarath

    Joined:
    Apr 17, 2013
    Posts:
    16
    bens1984 please implement this and I will purchase your product, I'll even flog it to others. Currently the only real option for transvoxel is to go with the C4 Engine and just no..... Marching Cubes is so 1987, Transvoxel is now!!
     
  4. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Wish list mmmm..

    1.) Transvoxel Algorithm- means no more seams cracks in the terrain.

    2.) Pathfinding : what's a terrain without pathfinding ? ( unless there's an option for loading Ai bots onto a voxel terrain.. anyone ?? )
     
  5. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    Has anyone figured a way to apply this to shapes you make yourself? Say I create a wall and I want to make it deform-able, how do I apply Ruaumoko to it? I'm struggling with this right now lol.
     
  6. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    hi!

    im looking for voxel asset for multiplayer game that i would like to do that would be fairly large sized open world where multiple players can change the terrain realtime.

    so what are realistic possibilities of this asset being put to such use.

    i guess the issues are how to get the generated maps on downloaded to the player that are joining and how to keep them all synced enough.

    i guess there is initial terrain generation and downloading it to players as they join. also as the players change the terrain downloading the changes to them, keeping them all synced

    then there is how will non voxel object, plain old static models be able to be placed inside the voxel area.

    also would be nice to have grass and trees growing all around the tubes and cavern.

    basically i am working on game that is completely below the ground. players can dig and fill in. but i need to be able to generate not just the voxel, but all the objects in the terrain for them to find as they explore

    i also need to be able to explode area when they trip off like explosive traps. and make caverns around their spawn area so they can spawn in and please objects around their spawn areas, like perhaps pickups and perhaps even rocks and buildings.

    i'm not looking for something blocky like minecraft, im thinkging smooth surfaces with blended textures.

    so do you think this would be good engine for that kind of stuff?

    thanks in advance
     
    Last edited: Aug 18, 2013
  7. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    hi ya IM,
    I reckon what you're chasing, won't be available for a few years yet..
    Updating dynamic terrain is cool enough but having it update for every player in a multiplayer game in realtime across the net would be massive as players would be altering the terrain simultaneously... unless you had a cool down period for each player where their terrain altering tool only operates for a limited time during certain periods of time. That would work.... It might be a restriction on your game play until voxel engines could handle multiple changes. .. but I must admit it sure sounds like an awesome game ,

    Explosive charges that open up cavities in the terrain would be doable..

    best of luck
     
    Last edited: Aug 19, 2013
  8. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    How would I go about generating an area that creates a hole in the terrain ? So for example a player throws a grenade, it explodes leaving a deep hole..

    If the player were to plant a stick of TNT underground upon detonation it forms an empty chamber.

    I'm thinking along these lines... add a sculpting tool with several END Points to the grenade. upon impact or after 5 sec. it simply digs outwards a set distance... yes ?

    Any thoughts on this would be appreciated by fellow diggers.
     
    Last edited: Aug 19, 2013
  9. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    hi thanks for the response

    there are a number of games doing voxel and multiplayer

    you can find them on steam. it works pretty good

    ok not smooth voxel, minecraft like blocks, but still

    pregenerated maps goes a long way that come with the game, players can preinstall or just download the 1st time they play them.

    even if dynamic maps, it could be done using seeding, just passing the parameters so long as the maps end up the same it could be completely done on the client. it would also be a mix of patterns and seeds so it can all be handled at the client for the actual generation and not have to pass all the data.

    and yes when a player first joins they sort of have to wait while it syncs up

    but there are many games that dont use voxel on steam that when you first join they download lots of custom stuff, including maps.

    i was doing some calculations last night in my head and even if 1m it would be like 15mb that is like without compression and tiny comparied to what i get from like some of the games i play each time i join.

    ok while players are at it they will be generating a steady stream of changes, but some of this can be performed on the client so long as its deterministic.

    for example for your granade all u need to know is like the object id, position and rotation the object is would say it all grenade of certain item. different grenades would have to have different object id in this example. and then when the clients get this they can all play out the explosion. so long as the end results are the same. by this i same blocks being affected the same way.

    anyways i'll have to play around with the idea and see how it plays out.


    my worry is not as much about those things im more worry about the engines i do not know and how well written and supports are they and how efficient and that they have well documented proper apis.

    i mean i need apis to do the things i need to do and that those apis are not bugged up and perform acceptably well. i dont want to rewrite their engines
     
    Last edited: Aug 19, 2013
  10. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    hi im interesting and licensing your asset please provide link to your api/documentation. i need to see if it would work for me. thanks in advance!
     
  11. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    Heh wouldn't we all love some quality documentation.

    The two reasons I do NOT recommend this asset to anyone that I know is:

    * No documentation. I mean NO documentation. Not even consistent inline comments.
    * It isn't designed as an asset from the ground up. It is not very modular. It does not allow you to easily submit a prefab shape or hard coded shape. It is coded to do one thing and one thing only. If you want to make it do something different and original get ready to spend possibly more time trying to bend the asset to your will than it would likely take you to just learn how all the stuff works and code it yourself. Trying to adapt the asset is of course made all the more difficult by the complete lack of proper documentation.

    That being said, the asset is really good at doing what it does. If it so happens it does exactly what you need and you don't need anything else then this should be perfect.
     
  12. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    sorry all for letting your questions hang (school started, again)!

    transvoxel: it's cool, I can't lie. It won't be in Ruaumoko for a while since I don't have time to implement new algorithms, I'm afraid.

    AI Pathfinding: I've done quite a bit with dynamic terrain analysis for AI but it's not ready for prime time. It's certainly doable, if you've got a handle on implementing A*, etc.

    Dual contouring: I made a separate asset package for the DC, rather than raise the price on this one. The D.C. edition integrates seamlessly with all of the demos in Ruaumoko (and the next version will have a check-box in each demo to engage it), but can also now be purchased separately for games that need their own terrain engine but want D.C. to realize it.

    Taking preexisting meshes and voxelizing them: this is a really cool feature that is also not happening soon. There are lots of sticky problems with it and the best solutions I've seen are incredibly slow (like, 5 hours to transform a tank model into an accurate voxel-data representation). I've got some ideas for simple solutions that would work with certain caveats, and they may come in sometime this fall.

    @IM: this is a common desire, being able to network voxel data. It can be done, problems of concurrency, security, etc. are well understood but need custom solutions. Ruaumoko is not setup to do this out of the box, but if you serialize the 3D data for each block, keep a server ready to handle all the issues, and synchronize with clients you could certainly do it.

    The "NO documentation" that I have is available here. It's high level but has a section of (fully functional, complete) short code examples that describe turning data into meshes through the Marching Cubes class. I confess the inline comments are inconsistent. The Marching Cubes is modular as can be and you can do anything with it, but the terrain generation itself could be seen as more of a "it does what it does well and that's it."

    @Nakor: it's not for everyone, fair enough. I originally put it up for hackers who don't want to implement an iso-surface extraction algorithm on their own, then got lots of requests for terrain features and they've been gradually building up.
     
  13. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Thanks for the info bens1984,

    Regarding Hand Grenades: if I want to make a hand grenade explode deform the terrain... would I simply use "sculpt" my own end point ? the terrain would have to deform instantly.. is this possible ?
     
  14. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    Heh I'm sure that came off more negative than I meant it to, but those are the areas this asset needs major improvement. I have that PDF... It kind of doesn't count as documentation. It's more of a half of a quick start guide. I'm not trolling, just offering my opinion. I realize I didn't pay a couple thousand for this asset or anything. I do appreciate the work you've done.
     
  15. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31

    I haven't done this yet but were I to do this (and I probably will fairly soon) I would create an object (the grenade) and have it emit sculpt tool rays in all directions, limiting the range of course. You would have to turn up the strength quite a bit and tweak the range, etc.
     
  16. Dagarath

    Dagarath

    Joined:
    Apr 17, 2013
    Posts:
    16
    Well bens, in regard to taking meshes and voxelizing them, could you not take a voxel structure like a large cube, and jam the mesh inside of it, and then convert the "empty space" in the voxels directly to it's own voxelized object? I mean like moulding rather than say...actually converting the data directly, sort of like a 3d snapshot as it were. I don't know if this is at all helpful but, just an idea I had.
     
  17. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Very interesting product, following to see where it goes.
     
  18. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    @ Nakor: Thanks for the reply.. yeah I was thinking along similar lines... ray-cast out in several directions + up the strength &limit the distance.

    I'll play around with this over the next day or two post if I get anything half decent happening.
     
  19. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    so that the explosions/blasts/splash is not perfect circle as you rotate the ray around the sphere you may want to have ray length be some RandomRange(min, max) that way it looks like blast going out in all directions

    re: transvoxel

    i starting porting transvoxel over to unity from existing c# xna port based on original c source code. got the transvoxel engine hopefully un unity with simple test to Debug.Log()

    now i need to get it to generate a mesh and collision mesh objects that is textured and that i can place ingame. and then tie to some controller that could be used alter the object ingame.
     
    Last edited: Aug 20, 2013
  20. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    just wondering if this is what's affecting my Grenade script...
    ( note: I'm attempting to generate a Hand Grenade by altering SculptTool script )

    So in my adapted Sculpt Tool Scipt called "GrenadeExplode"
    I get the following error:

    Prefab GameObject's can not be made active! (ExplodeSphere)
    UnityEngine.GameObject:SetActiveRecursively(Boolean)
    GrenadeExplode:Update() (at Assets/Ruaumoko/Shared/Scripts/GrenadeExplode.cs:82)

    So I decided to use the standard "Lightning" instead of my explosion effect.... it now executes but
    I get a MissingMethodException error: The best match for method "Sculpt" has some invalid parameter.

    Here's what its referring to in the SculptTool Script
    hit.collider.SendMessage("Sculpt", sp, SendMessageOptions.DontRequireReceiver);
     
    Last edited: Aug 21, 2013
  21. nosyrbllewe

    nosyrbllewe

    Joined:
    Oct 18, 2012
    Posts:
    182
    Bens, can you answer my questions at the end of page 5? I never recieved a response as of yet. Thank you.
     
  22. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    nosyrbllewe (sorry for the missing your question!), I will certainly put in ways to control how much of the terrain is pregenerated and placing the player on the landscape. That shouldn't be too hard!

    As for the shader, that will require some code. I made a shader (in the package) that allows the player to "paint" different textures onto the surface. This is the same functionality as having grass/dirt/rock areas in the world. Doing more than 4 textures might be a trick (because mixing the textures is done through vertex Colors, which have 4 components available). I have some ideas and might drop that in.

    Second challenge is telling the world where you want different "materials" (i.e. dirt/copper/silver/mud/etc.) to populate. If I can get the shader to pull that out of one Color component then we can encode that into the voxel data as another array. I'll take a stab at the shader and let you know!
     
  23. nosyrbllewe

    nosyrbllewe

    Joined:
    Oct 18, 2012
    Posts:
    182
    Thank you for your response. I will look forward to seeing it in a future release.
     
    Last edited: Aug 30, 2013
  24. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    sure hope someone can give me some idea where I'm going wrong on my grenade script.... ( earlier post on previous page )
     
  25. nosyrbllewe

    nosyrbllewe

    Joined:
    Oct 18, 2012
    Posts:
    182
    Hey, would you mind adding SharpSerializer as an alternate to BinaryFormatter for serialization of chunks? First of all, Windows Store and WP8 currently do not suppport BinaryFormatter (which I am developing for right now). SharpSerializer also has a smaller file size and is desierialized faster. Adding in this would speed up loading of chunks as it is about 3x faster in deserialization! More information here: http://sharpserializer.com/en/index.html Although it is great, it does have some disadvantages. Btw, when the world is saved, is the terrain saved "smooth" or is it saved in its pure form then being smoothed when it loading. Thanks.
     
  26. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    *Big Update Incoming!*

    I thought I'd spend a couple days on editor tools for Ruaumoko and it's turned into many more hours than that (see image below for an idea). However, the results are looking stellar. I'm psyched to let it go on everyone, hopefully pushing it up to Unity after this weekend. I'm consolidating and standardizing across scripts at the same time so it will hopefully address many issues.

    Banksy, I'll get back to you on grenades, and nosyr, thanks for the link to sharpserializer. The performance looks great so I'll certainly be trying it out.

    $ruaumokoeditor.jpg
     
  27. meta87

    meta87

    Joined:
    Dec 31, 2012
    Posts:
    254
    Beautiful! Glad you got sucked into spending many hours on it :D

    Looking forward to the update.
     
  28. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Also very interested in your future work on the ice-snow environment ;)
     
  29. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Wow can't wait to get behind the new edit controls... looks promising

    Saved Terrain resets after Build:
    Why is it after hitting build to Win (or Mac) I then go back and hit play in my scene the saved terrain has gone been replaced with a standard terrain ( none of my terrain changes exist anymore ) note: the build I save does in fact show the altered terrain.

    Texturing Mars:
    I'm interested in creating a Terraforming game.. so for example I'd like to terraform a planet like mars Mars.
    It starts out red and then eventually add water (ice) that vegetates an area turning green.. Is this possible with the current texturing available ?

    p.s - Bens, no rush to answer the above Qs as I realise you're flat out pushing the latest update out... perhaps another Voxel developer might be able to make a comment.... anyone
     
    Last edited: Sep 6, 2013
  30. nosyrbllewe

    nosyrbllewe

    Joined:
    Oct 18, 2012
    Posts:
    182
    Looks cool, can't wait. :)
     
  31. ckannon

    ckannon

    Joined:
    Sep 10, 2013
    Posts:
    4
    Hi Bens!

    Having a blast playing with the voxel terrain in your tool (I've managed to get it working where particle collisions can cause a sculpt event, allowing you to spray water onto ice - creating more ice etc. wonderful!!).

    Just wondering there is a way to pre-generate a larger section of terrain and load it into memory at runtime so I don't need to wait for the dynamic drawing to occur each time. At the moment it seems to be doing it chunk at a time, every time. Also - the loading / saving seems to not be working at all. Am I missing something here?

    Thanks,
    Chris
     
  32. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    http://www.youtube.com/watch?v=QkkOkgSYph4

    The editor tools are in Unity's hands, waiting to drop on the asset store! The video above shows the published version in action (you should be able to update to it in a few days).

    The new update boils down the scripts that were spread across all the demos into one new main component: RuaumokoTerrain.cs. This then provides all the functionality shown in the video, including saving and loading during run-time.

    Please hit me with any bugs or idiosyncrasies you find! (or ideas for better workflow/pipeline) This is my first foray into major Unity editor work so I'm sure there'll be a few.

    and real quick to the questions about the save/load: hopefully this update fixes some of the issues. Banksy, the data that's saved while you're "playing" in the editor gets saved to a different path than where the compiled stand-alone can access. You could hack around this, but it'll be far easier to sculpt your terrain in the editor and then build it that way.
     
  33. ckannon

    ckannon

    Joined:
    Sep 10, 2013
    Posts:
    4


    Bens - I've been working to pre-generate a large section of terrain and then allow it to page after the game start (basically pre build a section, drop trees / water on it, then allow new pieces to page in as I move). But I can't seem to get the pregeneration to work - which is probably just my problem since I had to code it from scratch. Would be possible to build the meshes out and then add colliders in a single pass or something to that effect? I'm trying to build a large open world and the tool in its current form just doesn't seem to want to do it - and all attempts at writing a 'pregen' script to do a large chunk have failed.

    *sigh* not sure what exactly to do here, the terrain is very cool and I love the ability to deform/sculpt on the fly - but the paging just seems very slow.

    Thanks,
    Chris
     
  34. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    [ Disregard this message]
    Hi Bens, I'm not sure how to sculpt in the "editor" as I can't see the terrain. I only see it once I hit play then I begin to sculpt then hit the Save button while I am still in play mode.

    After I'm happy with the Terrain shape I then BUILD .. .but then I open the game the terrain has re-set itself :(

    ( I now understand.... you're actually referring to the new Ruaumoko update... )
     
    Last edited: Sep 13, 2013
  35. ckannon

    ckannon

    Joined:
    Sep 10, 2013
    Posts:
    4
    Yeah, I've been experiencing some serious instability with the new build.. Terrain generates empty sometimes, other times it generates some cells but not others. Wasted enough time last night trying to figure out why it uses up so much memory when I realized it had a huge number of invisible voxels that needed to be cleared. Going to put this down awhile and give it another shot when its closer to production ready.
     
  36. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    Hi Doc,
    I managed to get the new version (with editor ) up and running but when I click to place terrain in the scene view I see nothing... but when I hit play I can see there is a small piece of terrain... but nothing in the Scene view note: I can see blocks are being added in the Hierachy e.g.. (1.0,0.0,01.0)(1.0,0.0,-2.0) etc... but nothing is visible :(

    p.s- Can you please add a single line stating the latest update version in your first post on this forum.
    helps to see if I'm up to date.... I see in the asset store V.0.3b Is this the latest ver ?
    Now I get ya... "EDITOR" as in the new editor feature coming out in the update... Dooh !!!

    Looks great can't wait to test it...

     
    Last edited: Sep 13, 2013
  37. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    left a review on the asset store.
     
    Last edited: Sep 13, 2013
  38. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    Yes, I was referring to the now current version: version 1.

    Note: I found a couple little bugs that were blocking web-player builds. I'll fix these and post the update ASAP.

    Thanks for the feedback, apparently getting the world started is a problem. When you are in "Add" mode, and you have a new or empty RuaumokoTerrain, and you click on the scene-view it starts adding voxels blocks around the camera. Because it's difficult to know where the surface exists in the voxel data-space, and a click into an empty scene is an infinite line, the blocks may be empty for a while. In the video I have the scene camera near 0,0,0 which often has a surface nearby.

    Once you have blocks with meshes in them (not empty ones) it then places new blocks next to which ever block you click on.

    I'll think about a better algorithm for starting the world (I'm open to suggestions!) One thought is to perform samples through a large space in an attempt to isolate the surface at one location, then use this point as the starting point for the block creation.
     
  39. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    There has to be a way to use this asset without the terrain generation. I just want it to melt meshes. For some reason I can't figure out how to get it to do this very simple thing lol. Kinda burns me. I'm not sure why I haven't figured out a work around yet.
     
  40. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    Nakor, what you want to do is very attractive and yet surprisingly difficult. What has to happen is this: your Mesh gets transcoded into a voxel format, then the voxel data is transformed into a mesh. Any interaction with the final mesh can be superimposed back on the voxel data and the rendering of the mesh can occur again (this part is in Ruaumoko and other engines already). The first part, creating voxel data out of a pre-existing mesh, is not easy.

    The difficulty is that Mesh data is a collection of verticies and triangle (or quad) connections that don't provide any guarantees about the continuity of the surface. If we could assume every surface was a convex hull then algorithms exist that could do the transcode to voxel data. But so many meshes that we'd want to be melting (indeed, the whole point of using voxel data formats!) will have concave faces somewhere. These cause problems. The potential for open holes cause problems too.

    I've drawn up several sketches on how to input a Mesh and get out a voxelized representation ready for deformation, but none are satisfactory yet. I've also read about others, which are highly impractical (taking several hours to convert a model!) If anyone has seen a good solution, or has an idea for one, I'd be glad to hear about it and implement it!
     
  41. Nakor

    Nakor

    Joined:
    Sep 5, 2012
    Posts:
    31
    Well would a workaround not be to generate a voxel plane (flat) and allow us (devs) to build with them? That way they would be meltable? I've tried using some of your code to build cubes and it works to some degree but it is very difficult to design with as lining up the runtime-generated cube with my in-editor representation is quite difficult...or has been so far.
     
  42. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    Hi,
    Am about to buy this/ monday sept 16. Is the version on the asset store updated to fix this web player build problem?
    If not, any idea when it will be?

    thanks,

    shwa
     
  43. bens1984

    bens1984

    Joined:
    Jan 18, 2013
    Posts:
    84
    @Nakor: load up an object with a RuaumokoTerrain.cs component and set the "octaves of noise" parameter to 0. This will give you a flat plane at 0 on the world Y axis. If you put the game object at 0,0,0 and "focus on game object" in the scene view you should see the plane appear in the first few voxel blocks (beware of back-side culling, if you're under the plane you won't see it of course). Tell me more about how you're building cubes and matching to in-editor versions... if I can help make it work I'd be happy to.

    @ shwa: it usually takes them 3 days to post updates to the store once I've submitted them (it'll be vrs 1.01). The only problem was with an editor script being in the wrong folder and a missing compiler define. If you buy it and need to make a web build before the update comes out PM me and I'll hand you the quick fix!
     
  44. trudeaudm

    trudeaudm

    Joined:
    Apr 17, 2013
    Posts:
    116
    Creating planet type terrain base does not seem to work at all.
     
  45. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    Quasi fixed:
    My workaround is to open this scene:
    4b World Sculpting-Height Map

    Then go back to the scene with the problem, and it worked fine.

    ** Btw, this Ruaumoko tool is quite astounding, and i'm just getting started. **

    =====

    I'm new to Ruaumoko.
    Any idea how to fix this?

    UnityException: Tag: Sculptable is not defined!

    thanks,

    shwa


    UnityException: Tag: Sculptable is not defined!
    RuaumokoTerrain+<GenerateNewCell>c__Iterator5.MoveNext () (at /Volumes/HD MyBook WD 2/RuaumokoSwerve3/Assets/Dr B Games/Ruaumoko/RuaumokoTerrain.cs:362)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    RuaumokoTerrain:Update() (at /Volumes/HD MyBook WD 2/RuaumokoSwerve3/Assets/Dr B Games/Ruaumoko/RuaumokoTerrain.cs:287)
     
    Last edited: Sep 17, 2013
  46. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    I like this idea from The Doc.
    I think perhaps in an update there should be a "foundation" button or some similar name... simply click this a primitive is placed in your scene with the RuaumokoTerrain.cs already applied. I know it's simple enough to create this but it just makes things super simple to get started.
     
  47. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    Hi,

    In play mode, when i mouse click, the lightning bolt strikes and melts the terrain.

    Is there a key combo or script that would allow for adding to the terrain when one mouse clicks in a specific spot?

    (I don't mean the automatic terrain tiling generation aspect that happens when you have:
    Generation during Play - clicked On.)

    thanks,
     
    Last edited: Sep 17, 2013
  48. Banksy

    Banksy

    Joined:
    Mar 31, 2013
    Posts:
    376
    not sure why but I still can't get terrain to show in the Scene view... even after creating a primitive obj. attaching RuamokoTerrain.cs / changing octave to 0 ... at zero position.. its just not there :( only when I hit play can I see a terrain.
     
  49. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    Not sure if the following relates to what you are trying to do, Banksy.

    Using the latest version from the asset store:

    I've been kludging thru trying to make a permanent terrain. Still not quite sure what i'm doing.
    When i hit the save button that is on screen in Ruaumoko, it generates the locations of the blocks.
    The blocks appear as thin grey lines. (At first glance they are not very visible.) When i have 'add' clicked on in the editor, and click on those blocks, the terrain starts to get tiled, the more i click, the more terrain appears in the scene view. I 'save' this in the editor.
    Then, that terrain is available to me in authoring and play.
    Hope that is somewhat helpful.
    Best if there was a clear step by step doc on how to do this/ or a sample scene.
     
  50. LoganPark

    LoganPark

    Joined:
    Aug 30, 2013
    Posts:
    23
    Amen. Hi, Dr. Ben, I'm a happy Ruaumoko user, but I have a bunch of questions:
    --How can I directly manipulate the voxel array to, for example, clear out an arbitrary space/radius around an arbitrary point? In my use case, I need to clear out spawn points from runtime terrain, not precooked terrain, so that players don't spawn behind the terrain mesh's skin. Zero gravity setting, so a high-altitude spawn point doesn't help. I suppose one could spawn a 'grenade' prefab at each spawn point to do a bunch of expensive raycasting and blast it out meter by meter. However, there's got to be a better more efficient way to just write a void shape to the affected chunks and recompute the mesh colliders thereof. (How do I get write access to the chunk data array?)

    --Similarly, how can I test that some arbitrary point is inside terrain or "inside" thin air (how do I get read access to the chunk data array)?

    --How do I scale up the voxel terrain? The detail level possible in Ruaumoko is amazing, but overkill for my use case. Instead of each chunk covering, say, 32 m^3, how do I make each chunk cover 1km cubed for the same number of voxels as in the 32 m^3 chunk?

    --In the new version, the terrain texture darkens to black where the sculpting tool contacts the surface. How do I change this color (black) or texture, how do I change the rate at which the blackening happens?

    --Relevant to optimization, how do I lower the rate of calls to update the mesh collider? Suppose that I don't want mesh modifications below a certain sculpt tool strength to trigger a costly mesh collider reload on the main thread.

    Thank you for answering the above. As a fellow academician I appreciate that you're quite busy during the school year. Also, Ruaumoko is the best money I've spent in the asset store. I'm very, very happy with it so far but I will add my voice to the chorus asking for much more fleshed-out documentation.

    To the other Ruaumoko users, lets whip up some prefabs that accomplish terrain manipulation tasks and share them around while we wait for a manual. :) I will work on a oneshot point-radial destructor (grenade-like sculpt tool) since that seems handy.

    TL;DR - What's the API? :)


    This code is for a grenade-type munition EDIT: this now works perfectly thanks to Dr. Ben's suggestion. Feel free to use it if it helps you.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. // This script was written by Logan but any usefully smart bits are directly
    5. // based on Dr. Ben's example voxel sculpting tool/laser script.  Buy Ruaumoko
    6. // on the asset store.  I'm not responsible if this script makes your computer
    7. // or Unity run amok and kill the Pope.
    8.  
    9. public class InstantVoidSphere : MonoBehaviour {
    10.  
    11.     public float fuseTime = 5.0f;               // How long is this gameObject idle before detonating?
    12.     public float explosionLifetime = 1.0f;//Hang around for this many seconds to allow nifty special effects to play out
    13.     public Vector3 center = Vector3.zero;//Automagically updated below
    14.     public float strength = 100f;               // A big number because pointless overkill is fun!
    15.     public float impactRadius = 1f;         // Automagically updated below to match this object's transform.localScale
    16.     public float Smoothness = 1f;               // I don't know, but I can guess...!
    17.     public Color ashColor = Color.gray; // Color left behind on the blasted out Ruaumoko mesh surface after deformation
    18.  
    19.     void Start () {
    20.         //Wait briefly then detonate
    21.         Invoke("explode", fuseTime);
    22.     }
    23.  
    24.     void explode () {
    25.         // Update the size of the spherical void to be created, based on how the prefab has been scaled up or down by this object's instantiator after instantiation
    26.         impactRadius = transform.localScale.x;
    27.  
    28.         //Update the location of the blast in case it has been shifted by this object's instantiator after instantiation
    29.         center = transform.position;
    30.  
    31.         // Figure out how many Ruaumoko terrain chunks this blast sphere overlaps into
    32.         var hitColliders = Physics.OverlapSphere(center, impactRadius, 1 << 8); // Layermask for Ruaumoko terrain only
    33.  
    34.         // Modify each of the affected chunks
    35.         SculptParameters sp;
    36.         sp.point = center;
    37.         sp.power = strength;
    38.         sp.radius = impactRadius;
    39.         sp.shape = SculptBrushShapes.Sphere;
    40.         sp.smoothness = Smoothness;
    41.         sp.texturePaint = ashColor;
    42.         sp.mode = SculptMode.Sculpt;
    43.  
    44.         for (var i = 0; i < hitColliders.Length; i++) {
    45.             if (hitColliders[i].collider.tag == "Sculptable") {
    46.                 hitColliders[i].SendMessage("Sculpt", sp, SendMessageOptions.DontRequireReceiver);
    47.                 Debug.Log ("InstantVoidSphere: Blasting chunk: " + i.ToString());
    48.             } else {
    49.                 Debug.Log ("InstantVoidSphere: Object " + i.ToString() + " ain't skeered by this blast, son; best move along.");
    50.             }
    51.         }
    52.  
    53.         // Take out trash before ze Germans arrive!
    54.         Debug.Log ("InstantVoidSphere: I'm done here; vanishing like the one percenters with my tax money.");
    55.         Network.Destroy(gameObject);
    56.  
    57.     }
    58. }
    59.  
    60.  
    61.  
    Also, I didn't like the way that (as far as I understand Ruaumoko) the sculpting laser forced a mesh collider update every frame that the sculpting was active, so I modified the sculpting tool script by Dr. B to behave more like a pulse laser instead of a continuous sculpt effect. With a VFX package added into the mix, a pulse laser-type interface to sculpting feels a lot more like hammering chunks out of the terrain with a regular whump-whump-whump. The framerate still chokes and dies on that one frame of the pulse, but the interval in between pulses runs smoothly again. Drop-in/copypasta code below into the simple sculpt tool csharp script included as a demo to Ruaumoko (thanks for the example, Dr. Ben!):

    Code (csharp):
    1. public bool pulseLaserModeActive = true;
    2.     public float pulseLaserCooldownInterval = 0.5f;
    3.     public bool pulseLaserIsCoolingDown = false;
    4.     public float lastPulseLaserBlastTime = Time.time; // This should be more consistent than Time.time.  I think?
    5.     public float pulseLaserVFXMaxPower = 1.0f;
    6.     public float currentPulseLaserVFXPower = 0.0f;
    Code (csharp):
    1. if(pulseLaserModeActive) {
    2.                 if(Time.time - lastPulseLaserBlastTime > pulseLaserCooldownInterval) { // Time to fire the laser again!
    3.                     if(Laser !=null) {
    4.  
    5.                     }
    6.                     Laser.SetActiveRecursively(true);
    7.                     Laser.SendMessage("SetPower", pulseLaserVFXMaxPower);
    8.  
    9.                     lastPulseLaserBlastTime = Time.time;
    10.                     RaycastHit pulseHit;
    11.                     Vector3 pulseDir = transform.TransformDirection(Vector3.forward);
    12.                     Vector3 pulseStartPos = transform.position;
    13.  
    14.                     if (Physics.Raycast(new Ray(pulseStartPos, pulseDir), out pulseHit, range, 1 << 8)) {
    15.         //              Debug.Log("hit something " + hit.collider.gameObject.name);
    16.                         CuttingPoint.transform.position = pulseHit.point;
    17.                         if (pulseHit.collider.tag == "Sculptable") {
    18.                             SculptParameters sp;
    19.                             sp.point = pulseHit.point;
    20.                             sp.power = 0.75f;   // apply deltaTime here so that all impacted cells use the same power
    21.                             lastPower = sp.power;
    22.                             sp.radius = impactRadius;
    23.                             sp.shape = SculptBrushShapes.Sphere;
    24.                             sp.smoothness = Smoothness;
    25.                             sp.texturePaint = Color.gray;
    26.                             sp.mode = SculptMode.Sculpt;
    27.                             pulseHit.collider.SendMessage("Sculpt", sp, SendMessageOptions.DontRequireReceiver);
    28.                             Network.Instantiate (FloatingEntityPrefab, pulseHit.point + pulseHit.normal * 3.0f, Quaternion.identity, 0);
    29.                             Network.Instantiate (HSDetonatorPrefab, pulseHit.point + pulseHit.normal * 1.0f, Quaternion.identity, 0);
    30.         //                  timeOfLastSculpt = updateRate;
    31.                         } else {
    32.                             //The thing we shot isn't tagged in the editor as sculptable
    33.                         }
    34.                     } else {
    35.                         // We shot, but didn't hit anything in the appropriate layer
    36.                     }
    37.                 } else {
    38.                     // The laser is still cooling down from a previous shot
    39.                     decayPulseLaserPower();
    40.                 }
    41.             }
    Code (csharp):
    1.  
    2.  
    3.     void decayPulseLaserPower() {
    4.         if (Laser != null) {
    5.             currentPulseLaserVFXPower = Mathf.Max (0.0f, (pulseLaserVFXMaxPower - (pulseLaserVFXMaxPower * (Time.time - (lastPulseLaserBlastTime) + pulseLaserCooldownInterval * 1.25f)))) / (pulseLaserCooldownInterval / 2.0f);
    6.             if(currentPulseLaserVFXPower > 0.0f) {
    7.                 Laser.SetActiveRecursively(true);
    8.                 Laser.SendMessage("SetPower", currentPulseLaserVFXPower);
    9.             } else {
    10.                 Laser.SetActiveRecursively(false);
    11.             }
    12.         }
    13.     }
    14.  
    15.     void OnGUI() {
    16.         GUI.Label (new Rect(Screen.width-200,50,200,20), "laser strength: "+lastPower.ToString());
    17.         GUI.Label (new Rect(Screen.width-200,90,200,20), "laser VFX power: "+currentPulseLaserVFXPower.ToString());
    18.     }
     
    Last edited: Sep 26, 2013