Runtime Client-Side Terrain Modification
by Mr Pib · in Torque 3D Professional · 02/27/2014 (9:25 pm) · 10 replies
I'm wondering if it's possible to do something similar to minecraft in torque 3d? Only thing I've come close to runtime terrain modification is hitting F11 to get to the world editor.
Basic Idea Is:
Player connects to server
player wields pickaxe
player hits terrain
player digs hole
other players can see hole and fall in hole
players can walk around large world and dig more holes
Seems easy, but apparently this is a huge headache.
Basic Idea Is:
Player connects to server
player wields pickaxe
player hits terrain
player digs hole
other players can see hole and fall in hole
players can walk around large world and dig more holes
Seems easy, but apparently this is a huge headache.
#2
The problem is when other clients join after this, they will see the original terrain because they have not received the modify events. You'd need to store each change on the server, or some data structure describing the sum of all edits that have occurred to the terrain, and sent it to each new client that joins.
EDIT: Note that Torque terrain is a heightfield, so you can't make overhangs. If you want real digging and tunneling you'll have to do something far more complex.
02/28/2014 (3:49 am)
Back in TGE there was a resource for terrain deformation, though I imagine the terrain code has changed significantly since then. Your basic flow would look something like the following:Note over Client: Hit terrain Client->Server: Request modify Note over Server: Verify request Note over Server: Change vertices Server->Client: Modified Server->Others: Modified Note over Client: Change vertices Note over Others: Change vertices(copy/paste this into js-sequence-diagrams to see the proper sequence diagram)
The problem is when other clients join after this, they will see the original terrain because they have not received the modify events. You'd need to store each change on the server, or some data structure describing the sum of all edits that have occurred to the terrain, and sent it to each new client that joins.
EDIT: Note that Torque terrain is a heightfield, so you can't make overhangs. If you want real digging and tunneling you'll have to do something far more complex.
#3
https://winterleafentertainment.com/Products/OneWorld.aspx
I know of a few people that have purchased the source code and dropped it into their main game.
02/28/2014 (4:11 am)
This may do what you are looking forhttps://winterleafentertainment.com/Products/OneWorld.aspx
I know of a few people that have purchased the source code and dropped it into their main game.
#4
02/28/2014 (6:33 am)
Ooh - a "plug-n-play" solution is always nice. At $200, the source option would work for me - that's about 7 hours at my current salary, so if it takes me longer than 7 hours to add this feature myself then it's already worth it.
#5
As a previous post mentions, will new players that log in see the changes?
02/28/2014 (7:23 am)
What's the maximum number of players that can connect to the oneworld server?As a previous post mentions, will new players that log in see the changes?
#6
Minecraft Digging Example: http://www.youtube.com/watch?v=akuWAxtspVM
Wurm Online Digging Example: http://www.youtube.com/watch?v=zkYb1mMn-_A
How do I even begin to convert Torque 3D to do this? It seems obvious to me the runtime terrain modification from OneWorld will be a good start, but from there I don't have any resources to go from.
02/28/2014 (7:58 am)
Also is there a good resource out there besides having to rip apart the runtime terrain feature of the OneWorld project and somehow add Minecraft or Wurm-Online terrain cells?Minecraft Digging Example: http://www.youtube.com/watch?v=akuWAxtspVM
Wurm Online Digging Example: http://www.youtube.com/watch?v=zkYb1mMn-_A
How do I even begin to convert Torque 3D to do this? It seems obvious to me the runtime terrain modification from OneWorld will be a good start, but from there I don't have any resources to go from.
#7
as far as new players, yes, they will see the changes when they log in.
02/28/2014 (9:50 am)
As far as Im aware, the limit on your players is your bandwidth really. depending on what mods you allow them to do, that's ALOT of info to be passing back and forth.as far as new players, yes, they will see the changes when they log in.
#8
First, you have to maintain an order of things, because when a client connects you want there terrain and game objects in the same location. So you need a way to synchronize all of the world changes into a single stream so that each player who connects see's the same world.
OneWorld does all of this. It synchronizes Terrain, Forest, Items, decals, etc and keeps track of where each client is in the stream of changes.
We have had about 10 people connected to our OneWorld test server during testing and it seemed to run fine. Of course, the more people moving stuff around and such will create more events that need to be relayed to each client.
Also, the server needs to serialize the incoming changes into one stream and apply them. So it will get laggy if 10 people are terrain editing at the same time.
The code is quite modular, all of the terrain editing is kept in one folder which from the feed back I've gotten from developers who own the sdk, it is quite easy to merge even w/ AFX.
So, in wrap up, max clients is based on the server hardware, no hard coded limit.
And yes, any client connecting will be relayed all changes that have occurred up till the time they logged in and then any from there on.
02/28/2014 (9:58 am)
There are a of problems with doing this process. Modifying terrain and moving stuff around isn't as simple as one would think.First, you have to maintain an order of things, because when a client connects you want there terrain and game objects in the same location. So you need a way to synchronize all of the world changes into a single stream so that each player who connects see's the same world.
OneWorld does all of this. It synchronizes Terrain, Forest, Items, decals, etc and keeps track of where each client is in the stream of changes.
We have had about 10 people connected to our OneWorld test server during testing and it seemed to run fine. Of course, the more people moving stuff around and such will create more events that need to be relayed to each client.
Also, the server needs to serialize the incoming changes into one stream and apply them. So it will get laggy if 10 people are terrain editing at the same time.
The code is quite modular, all of the terrain editing is kept in one folder which from the feed back I've gotten from developers who own the sdk, it is quite easy to merge even w/ AFX.
So, in wrap up, max clients is based on the server hardware, no hard coded limit.
And yes, any client connecting will be relayed all changes that have occurred up till the time they logged in and then any from there on.
#9
03/01/2014 (1:26 am)
Any tips on how to go about learning how to code the digging examples I listed?
#10
03/01/2014 (4:23 pm)
One approach we talked about on the IRC channel was to cut a hole in the terrain(you can see how the editor does this) and render voxels below the terrain as the user digs. So like minecraft but inverted since you are inside the voxels.
Torque Owner Richard Ranft
Roostertail Games
It's a huge headache because of the way the mission file stores the terrain and the level data in general - it's not meant to be altered at run-time so you have to play tug-of-war with the server to get it to update for everyone.