Game Engine Forum - Grit Open Source Streaming Game Engine
Site Header
It is currently Fri Mar 24, 2017 4:07 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Is it possible to cut a huge 3D map into pieces
PostPosted: Thu Feb 09, 2017 3:19 pm 
Offline
Newbie

Joined: Tue Oct 09, 2012 11:14 pm
Posts: 36
Hi!
I have just found http://gis.stackexchange.com/questions/70186/open-source-free-software-for-generating-a-3d-view-of-mapping and i was wondering if there is a way ,by a script, to cut a huge 3D map into pieces compatible with grit.

thak you!
bye


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Fri Feb 10, 2017 10:51 am 
Offline
Newbie
User avatar

Joined: Fri Mar 21, 2014 12:25 am
Posts: 111
Location: Rio Grande do Sul
If you manage to get the terrain mesh into Blender 3D you can cut it in several same size pieces with a script:

Code:
import bpy, bmesh
from bpy import context as C

bpy.ops.object.mode_set(mode='EDIT')

bm = bmesh.from_edit_mesh(C.object.data)

edges = []

for i in range(-10, 10, 2):
        ret = bmesh.ops.bisect_plane(bm, geom=bm.verts[:]+bm.edges[:]+bm.faces[:], plane_co=(i,0,0), plane_no=(-1,0,0))
        bmesh.ops.split_edges(bm, edges=[e for e in ret['geom_cut'] if isinstance(e, bmesh.types.BMEdge)])

for i in range(-10, 10, 2):
        ret = bmesh.ops.bisect_plane(bm, geom=bm.verts[:]+bm.edges[:]+bm.faces[:], plane_co=(0,i,0), plane_no=(0,1,0))
        bmesh.ops.split_edges(bm, edges=[e for e in ret['geom_cut'] if isinstance(e, bmesh.types.BMEdge)])

bmesh.update_edit_mesh(C.object.data)

bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode='OBJECT')


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Fri Feb 10, 2017 12:47 pm 
Offline
Newbie

Joined: Tue Oct 09, 2012 11:14 pm
Posts: 36
WOW!
Thank you, thank you, thank you, this is exactly the answer that i was hopping for!
you are a GENIUS!
thank you a lot!
bye


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 12, 2017 2:28 pm 
Offline
Newbie
User avatar

Joined: Fri Mar 21, 2014 12:25 am
Posts: 111
Location: Rio Grande do Sul
This topic may interest some other people, as Grit doesn't have proper "terrain", so:

here is a plugin that does the same (Bonus LOD): http://hugobarreira.weebly.com/uploads/1/7/4/3/1743575/lodscape_tools.py

and i have modified the original script to be more intuitive, your mesh just need to have X and Y dimensions = 16 (viewport right panel) and set the "slices=" in the script according to how many slices you want:

Code:
import bpy, bmesh, math

slices = 8

bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
bpy.ops.object.transform_apply(scale=True)

bpy.ops.object.mode_set(mode='EDIT')

bm = bmesh.from_edit_mesh(bpy.context.object.data)

sizex = int(bpy.context.object.dimensions.x/2)
sizey = int(bpy.context.object.dimensions.y/2)

xslicesize = int(math.ceil(bpy.context.object.dimensions.x / slices))
yslicesize = int(math.ceil(bpy.context.object.dimensions.y / slices))

edges = []

for i in range(-sizex, sizex, xslicesize):
        ret = bmesh.ops.bisect_plane(bm, geom=bm.verts[:]+bm.edges[:]+bm.faces[:], plane_co=(i,0,0), plane_no=(-1,0,0))
        bmesh.ops.split_edges(bm, edges=[e for e in ret['geom_cut'] if isinstance(e, bmesh.types.BMEdge)])

for i in range(-sizey, sizey, yslicesize):
        ret = bmesh.ops.bisect_plane(bm, geom=bm.verts[:]+bm.edges[:]+bm.faces[:], plane_co=(0,i,0), plane_no=(0,1,0))
        bmesh.ops.split_edges(bm, edges=[e for e in ret['geom_cut'] if isinstance(e, bmesh.types.BMEdge)])

bmesh.update_edit_mesh(bpy.context.object.data)

bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode='OBJECT')

bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')



Non Blender users: select your object, open a "Text Editor" window
Image
click "+" button, paste this script and click "Run Script"


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 12, 2017 5:00 pm 
Offline
Newbie

Joined: Tue Oct 09, 2012 11:14 pm
Posts: 36
YEESSSS!
I am 10000% convinced that this will be very usefull to many peoples, from all sorts of modding community.
Thank you, Thank, Thank you!
If i ever start a 3D games studio, i will hire you first!

Now,if only, someone as genius as you, (or you ;) ) , would create a script to import a avatar created with MakeHuman http://www.makehuman.org/ into grit, that way, it would make grit a lot more attractive, and i have a intuition that it would attract more peoples/developpers and speed up the developpment of grit.

Again, Thank you a billion times!

bye


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 12, 2017 6:39 pm 
Offline
Newbie
User avatar

Joined: Fri Mar 21, 2014 12:25 am
Posts: 111
Location: Rio Grande do Sul
Thanks ;)
but i didn't do much, just found it a while ago on internet and modified a bit :P

I think you can import it on Blender using MakeHuman "Blender Tools" and then export to Grit using Blender2Ogre: https://bitbucket.org/iboshkov/blender2ogre
I could merge the two plugins to do it straight from MakeHuman to Grit, but i'm not good at Blender Python yet :P


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 12, 2017 8:51 pm 
Offline
Newbie

Joined: Tue Oct 09, 2012 11:14 pm
Posts: 36
I feel that you did a lot, you took the time to search and to answer, your kindness honor you, now i will wait that there are tutorials on how to make a simple "Hello World" game , then i will try all those new informations.
On another subjects, I am always downloading and trying all sorts of softwares for creating/modifying 3D objects, my hope is finding some way to "daisy chain" (with import-export functions) the rigth set of 3D softwares and finding easier ways to do stuff. i am telling you this in case ,someone wants to do the same.

Thank you sooo much!
I can't wait to see videos tutorials and videos of games made with grit
bye


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 26, 2017 6:10 am 
Offline
Supreme Tyrant of All
Supreme Tyrant of All
User avatar

Joined: Sat Mar 27, 2010 1:13 pm
Posts: 768
A long time ago I took a huge NASA heightmap image of the earth and used scripts to divide it up into .mesh texture etc with LOD as well. I think I lost that script now though.

Basically, there is not much point in implementing this in the engine because that limits you to that single way of doing it, and it's no easier than doing it outside.


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Feb 26, 2017 11:58 am 
Offline
Newbie

Joined: Tue Oct 09, 2012 11:14 pm
Posts: 36
Hi,
thank you for your answer Spark,
Your answer, somehow, make me a little sad, i do no understand what you mean, but, i will accept it, since you are Spark, i believe that you are working for the best solutions for grit

bye


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Tue Feb 28, 2017 6:44 pm 
Offline
Newbie

Joined: Thu Jul 07, 2016 8:14 pm
Posts: 12
Can we do it in lua script in grit ?


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Thu Mar 02, 2017 2:53 am 
Offline
Newbie
User avatar

Joined: Fri Mar 21, 2014 12:25 am
Posts: 111
Location: Rio Grande do Sul
If we take Blender source code and convert it to Lua maybe.. but is probably not that easy


Top
 Profile  
 
 Post subject: Re: Is it possible to cut a huge 3D map into pieces
PostPosted: Sun Mar 05, 2017 3:23 am 
Offline
Supreme Tyrant of All
Supreme Tyrant of All
User avatar

Joined: Sat Mar 27, 2010 1:13 pm
Posts: 768
It should be easy to do this kind of thing in Blender and then convert them to Grit assets. It may not be easy because the Blender exporter is not finished... But that's the right way to do it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Localized by MaĆ«l Soucaze © 2010 phpBB.fr