3D printing for kids: modelling objects with Minetest

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3d printing for kids: modelling objects with Minetest

by spin » Sun Aug 17, 2014 19:39

makerware
has internal and surface errors, otherwise OK, so all the printers that work on x3g files can swallow those models no problem:
Image
Attachments
makerware.jpg
makerware.jpg (345.68 KiB) Viewed 2464 times
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3d printing for kids: modelling objects with Minetest

by spin » Sun Aug 17, 2014 19:55

prestidigitator wrote:Since materials aren't interesting, here's the above mod I posted, modified to export a 3D (on/off) bitmap instead of "color" data:


Prestidigitator, is there a possibility that you could push it to git?

Also, I'm afraid my programming skills are null :( I can do things from tutorials at this point, so I'm no use in doing anything with this for now. If someone who knows bpy could use that data to generate an object in Blender, that would be awesome, but it's way out of my league at this point I'm afraid (both skill- and time-wise).
 

User avatar
aldobr
Member
 
Posts: 316
Joined: Sun Nov 25, 2012 05:46

Re: 3D printing for kids: modelling objects with Minetest

by aldobr » Mon Aug 18, 2014 01:39

I found a much simpler solution, using FreeCAD.

Minetest side script :

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
-- FreeCAD exporting MOD - Minetest side
-- Copyright(C) 2014 - J. Aldo Gomes de Freitas Junior
-- GPLv2
-- Minetest side module

-- exporter proper
nodeexporter = {

   -- Populate this array with a list of nodes that should be rendered
   blockmapping = {
         ['default:dirt'] = 1,
         ['default:dirt_with_grass'] = 1
      },

   -- Exports a chunk of land starting at ax1, ay1, az1 and ending at ax2, ay2, az2
   exportblocks = function(athis, afilename, ax1, ay1, az1, ax2, ay2, az2)
      local destination = io.open(minetest.get_worldpath() .. "/" .. afilename, "w")
      local x, y, z
      local swapvar
      -- Verify and swap inverted coordinates
      if ax1 > ax2 then
         swapvar = ax2
         ax2 = ax1
         ax1 = swapvar
      end
      if ay1 > ay2 then
         swapvar = ay2
         ay2 = ay1
         ay1 = swapvar
      end
      if az1 > az2 then
         swapvar = az2
         az2 = az1
         az1 = swapvar
      end
      -- Write map chunk size
      destination:write((ax2 - ax1) .. '\n' .. (ay2 - ay1) .. '\n' .. (az2 - az1) .. '\n')
      -- Write map data
      for ly = ay1, ay2 do
         for lx = ax1, ax2 do
            for lz = az1, az2 do
               local node = minetest.env:get_node({ x = lx, y = ly, z = lz })
               local value = athis.blockmapping[node.name]
               if value ~= nil then
                  destination:write(value .. '\n')
               else
                  destination:write('0\n')
               end
            end
         end
      end
      destination:close()
   end
}

-- Register chat command
minetest.register_chatcommand(
   "mapexport",
   {
      params = "filename x1 y1 z1 x2 y2 z2",
      description = "Exports a piece of game map in a format that can be read by FreeCAD minetest importer plugin.",
      privs = { },
      func =
         function(name, param)
                  paramlist = string.split(param, " ")
                  local filename = paramlist[1]
                  local x1 = tonumber(paramlist[2])
                  local y1 = tonumber(paramlist[3])
                  local z1 = tonumber(paramlist[4])
                  local x2 = tonumber(paramlist[5])
                  local y2 = tonumber(paramlist[6])
                  local z2 = tonumber(paramlist[7])
                  nodeexporter:exportblocks(filename, x1, y1, z1, x2, y2, z2)
            return true, "Exported to " .. filename;
         end
   });


FreeCAD side script:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
# FreeCAD exporting MOD - Minetest side
# Copyright(C) 2014 - J. Aldo Gomes de Freitas Junior
# GPLv2
# FreeCAD side module

import Part, math

def makeCenter(x = 0, y = 0, z = 0):
   return FreeCAD.Vector(x, y, z)

def makeRotation(x = 0, y = 0, z = 0):
   return FreeCAD.Rotation(x, y, z)

def makePlacement(x, y, z, X, Y, Z):
   return FreeCAD.Placement(makeCenter(x, y, z), makeRotation(X, Y, Z))

def importvolumefile(filename, xscale = 10, yscale = 10, zscale = 10):
   cubes = []
   sourcefile = open(filename)
   xsize = int(float(sourcefile.readline()))
   ysize = int(float(sourcefile.readline()))
   zsize = int(float(sourcefile.readline()))
   for yposition in range(1, ysize):
      for xposition in range(1, xsize):
         for zposition in range(1, zsize):
            value = int(float(sourcefile.readline()))
            if value > 0:
               cube = Part.makeBox(zscale, xscale, yscale)
               cube.Placement = makePlacement(xposition * xscale, yposition * yscale, zposition * zscale, 0, 0, 0)
               cubes.append(cube)
   sourcefile.close()
   solid = Part.makeCompound(cubes)
   return solid

# replace filename - needs a beter interface
map = importvolumefile("c:/minetest/minetest-0.4.10/worlds/aldo/teste.vol")
Part.show(map)


Already works in my computer. I can - if trully needed - use FreeCAD boolean operations to fuse all cubes into a single entity, but this is quite a costly operation.

TODO:

Minetest side - Add parameter handling and checking. Populate the mapping table. There are only two entries right now. (dirt and dirt with grass)
FreeCAD side - Add file selection interface. Change tile color by minetest mod mapping. Handle nodebox.

This is the result inside freecad:

https://www.dropbox.com/s/liznoix6ezkx9uy/freecad.png

Basically, i have the whole problem solved here. FreeCAD can export the model in various kinds of formats. Blocks can be edited, etc.

To export a map piece from minetest :

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
/minetest <filename> <x1> <y1> <z1> <x2> <y2> <z2>


To import into FreeCAD :

Edit this line:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
# replace filename - needs a beter interface
map = importvolumefile("c:/minetest/minetest-0.4.10/worlds/aldo/teste.vol")


"c:/minetest/minetest-0.4.10/worlds/aldo/teste.vol" is a fully qualified filename that points to a volume that i exported in my harddisk. Replace it with a correct fully qualified path name that points to the correct file inside your computer.

Cubes might happend to be mirrored/inverted, coords might happen to be rotated (x vs y, x vs z etc). Those small bugs need to be fixed by tests. First thing is to pupulate the "blockmapping" array in the lua source code. The blockmap has a simple structure, ["<registerednodename>"] = <value>. Any value above 0 will become a block inside minetest. The is scale is so that each block (node) inside minetest becomes a 10mm x 10mm x 10mm cube inside freecad. The scale can be changed by adding scale values to the importvolumefile call.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
p = importvolumefile(<filename>, [<xscale>, [<yscale>, [<zscale>]]])
Last edited by aldobr on Mon Aug 18, 2014 03:14, edited 10 times in total.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

Re: 3D printing for kids: modelling objects with Minetest

by prestidigitator » Mon Aug 18, 2014 01:41

Here's an example of a pyramid such as you were trying to export above.

Image
Attachments
blockExportPyramidScreenshot_2014-08-17.png
blockExportPyramidScreenshot_2014-08-17.png (5.64 KiB) Viewed 2464 times
Last edited by prestidigitator on Mon Aug 18, 2014 02:42, edited 1 time in total.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

Re: 3D printing for kids: modelling objects with Minetest

by prestidigitator » Mon Aug 18, 2014 02:40

 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Mon Aug 18, 2014 06:45

WHOA GUYS :O
I'll test this ASAP and post results, working on a lesson plan now (deadline).
 

User avatar
aldobr
Member
 
Posts: 316
Joined: Sun Nov 25, 2012 05:46

Re: 3D printing for kids: modelling objects with Minetest

by aldobr » Mon Aug 18, 2014 06:49

FreeCAD deals with solid geometry and has a fully constuctive solid geometry system. This is quite printer friendly. If the slicer needs a fused solid made out of the cubes i can easily make FreeCAD fuse the blocks. But this tends to be costly. I still need to implement a menu system inside FreeCAD and a better interface for Minetest. Plus i need to develop a way to export nodebox information (So as to print stairs for one). But this is a more involved development. We might arrange something. Current code is GPLv2.
 

User avatar
aldobr
Member
 
Posts: 316
Joined: Sun Nov 25, 2012 05:46

Re: 3D printing for kids: modelling objects with Minetest

by aldobr » Mon Aug 18, 2014 08:20

Continued development here :

viewtopic.php?f=9&t=9949
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Mon Aug 18, 2014 13:14

For completeness: Blender Cycles render from a piece of Minetest map.
Image
full message in screenshots thread: viewtopic.php?f=3&t=156&start=2450#p151540
 

User avatar
Inocudom
Member
 
Posts: 2889
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

Re: 3D printing for kids: modelling objects with Minetest

by Inocudom » Mon Aug 18, 2014 15:37

spin wrote:For completeness: Blender Cycles render from a piece of Minetest map.
Image
full message in screenshots thread: viewtopic.php?f=3&t=156&start=2450#p151540

Impressive. Have you ever tried this with a server?
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Mon Aug 18, 2014 15:54

Inocudom wrote:Impressive. Have you ever tried this with a server?


It's an .mts file exported with WorldEdit, and then ran over the mt2obj script (link to github above). Should work, but do try.
 

User avatar
Excalibur Zero
Member
 
Posts: 142
Joined: Tue Apr 02, 2013 19:45
GitHub: ExcaliburZero

Re: 3D printing for kids: modelling objects with Minetest

by Excalibur Zero » Mon Aug 18, 2014 17:22

I tried using sfan5's mt2obj converter, however I couldn't find out how to get the script to work. When I tried to run the script it just printed a few lines of text and stopped. (http://i.imgur.com/85PGHwq.png) How exactly do you use the script?
 

User avatar
aldobr
Member
 
Posts: 316
Joined: Sun Nov 25, 2012 05:46

Re: 3D printing for kids: modelling objects with Minetest

by aldobr » Mon Aug 18, 2014 17:38

You need to give a filename as parameter
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Mon Aug 18, 2014 17:43

Excalibur Zero wrote:I tried using sfan5's mt2obj converter[...]How exactly do you use the script?


I do it like so:
-place your mts map file exported from Minetest with Worldedit (check commands) in mt2obj script's folder
-open Windows command line
-go to the directory you have the script in (using cd to change directory, dir to display contents)
-execute the script by typing either:
- - python mt2obj.py yourmapfile.mts
- - whole python path, like C:\Python27\python.exe mt2obj.py yourmapifile.mts
- import resulting .obj to Blender (involves waiting :/)

Good luck.
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Fri Aug 22, 2014 12:30

In the testing I see that day/night cycle restricts visibility, and additional time has to be spent to set up lighting, and this makes classes time spent less effective.

Is there a way to remove or limit the night/day cycle?
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

Re: 3D printing for kids: modelling objects with Minetest

by Topywo » Fri Aug 22, 2014 12:35

spin wrote:In the testing I see that day/night cycle restricts visibility, and additional time has to be spent to set up lighting, and this makes classes time spent less effective.

Is there a way to remove or limit the night/day cycle?


Frome minetest.conf.example
# Interval of sending time of day to clients
#time_send_interval = 5
# Length of day/night cycle. 72=20min, 360=4min, 1=24hour, 0=day/night/whatever stays unchanged
#time_speed = 72
# Length of year in days for seasons change. With default time_speed 365 days = 5 real days for year. 30 days = 10 real hours
#year_days = 30

So copy in your minetest.conf file this line:

time_speed = 0




Edit: some copy/paste typo...
 

spin
Member
 
Posts: 25
Joined: Fri Aug 15, 2014 16:12

Re: 3D printing for kids: modelling objects with Minetest

by spin » Fri Aug 22, 2014 13:17

Topywo wrote:[...]time_speed = 0


Awesome, thanks!
 

Previous

Return to Minetest General

Who is online

Users browsing this forum: Google [Bot] and 31 guests

cron