I made somefink!

From: Mikee15 Nov 2012 09:04
To: ALL1 of 48
I'm not too sure why I made this, but I did.


It takes any 3d model (well, in obj format), voxelizes it, and turns it into minecraft blocks (attempts to colour match).

Looks a bit odd, but I'll make it so I can define which blocks to use. I'm thinking about also making a quick 'painter' for it, so you can very quickly airbrush colours in.

Here's a "live" example ("live", because it takes about a minute to actually process. looks broken..!)

http://www.mikeefranklin.co.uk/3d/gob.html


I'm sure there's probably tools out there that already do it - binvox kinda does, but not very well. I'll probably look to converting it to a minecraft friendly format next.

Attachments:
From: JonCooper15 Nov 2012 09:38
To: Mikee 2 of 48
looks quite cool, after I understood it was upside down and I could move it about
I'd like a little pane that shows what blocks are on each level, so I had a map to build from
From: Mikee15 Nov 2012 09:52
To: JonCooper 3 of 48
Yeah that'd be pretty cool - should be easy enough to implement.

Screw building it all manually, though!! You're craaazzy. Get ComputerCraft and program turtles to do it for you! :)
From: JonCooper15 Nov 2012 10:54
To: Mikee 4 of 48
problem is; we have been finding minecraft a little dull recently, if you know what you're doing it's not hard to go from new virgin world to fully armoured and able to beat everything quite quickly - building strange and wonderful things is about all that's left 
From: Mikee15 Nov 2012 11:05
To: JonCooper 5 of 48
tbh I think you're missing out by not installing mods. Some of the new stuff out there is far far better than vanilla minecraft - for example, the new "feed the beast" pack. 
From: af (CAER)15 Nov 2012 14:57
To: Mikee 6 of 48
IT doesn't ever actually finish doing anything here, even leaving it for a few minutes (MacBookPro, 2.4GHz Core 2 Duo, Chrome... whatever the latest one is)
From: Lucy (X3N0PH0N)15 Nov 2012 15:03
To: Mikee 7 of 48
Similar to Andy, crashed firefox here (or at least ties it up so bad it thinks it's crashed. Wasn't using any CPU though so I don't think it was doing anything...?). Left it for a few minutes but nothing changed.

(FF18)
From: Mikee15 Nov 2012 15:05
To: ALL8 of 48
Ah sorry, I've only ever looked at it in windows chrome (a proper browser).

I can imagine firefox has some pretty big issues with it - it does a LOT of processing, and it's all without any timeout/break in the code.

I'll split it out into timeouts and whatnot eventually to make it smoother ;-)
From: JonCooper15 Nov 2012 16:48
To: Mikee 9 of 48
we have been trying out some mods, quite liked tekkit, enough to rent a server to run it on, it crashed after about 2 months and the admin peeps said "yes, they do that a lot" :(  ~~  (I do not rent a server there any more)
From: Mikee15 Nov 2012 17:17
To: JonCooper 10 of 48
How very odd :)

I'm part of a small, relaxed, whitelisted server which is currently running tekkit, although we'll be moving to "ftb" in the next couple of months. You're welcome to join there!
EDITED: 15 Nov 2012 17:18 by MIKEE
From: Mikee15 Nov 2012 20:21
To: ALL11 of 48
http://www.mikeefranklin.co.uk/3d/bishop.html

Maybe that'll work slightly better for people - although this one takes FOREVER to load, although I added a counter so you can see how long..

I guess it's time to optimize it all ;-)
From: af (CAER)15 Nov 2012 20:56
To: Mikee 12 of 48
Yeah it could probably do with some optimisation - even in Chrome on my Windows PC (which is quite a bit faster than my Mac) it still gets the CPU fan going and slows the entire browser down while it loads (which takes ages).

(and then once it's actually loaded it runs perfectly smooth at 60fps)
EDITED: 15 Nov 2012 20:57 by CAER
From: Mikee15 Nov 2012 21:42
To: af (CAER) 13 of 48
Refresh now and it should be very quick in comparison.

This is a slightly dumber version, though. For each face in the mesh it's just picking the center pixel and matching the colour of that against minecraft textures. Not ideal, but much faster. Probably good enough  for what I need.

Next I think I should make a painting tool for it, but make it so you can very very quickly just brush over big sections to change their texture, instead of having to slowly click individual blocks.
From: Lucy (X3N0PH0N)15 Nov 2012 21:56
To: ALL14 of 48
(just testing)
From: Mikee15 Nov 2012 22:05
To: Lucy (X3N0PH0N) 15 of 48
Colours are pretty poop..

I need to find a better way to do this.

Currently:

For every cube:

1) Get the face it represents from the original model

2) get the middle pixel of that triangle

3) change it like this:

3.1) convert to hsv
3.2) color.v += 2;
3.3) color.v = (color.v - 50) * 1.1 + 50; // make the light colours lighter, the dark colours darker
3.4) color.v = Math.max(0, Math.min(color.v, 100)); // make sure we're still in range
3.5) color.s = Math.sin(1-(Math.abs(color.s-50)/50)) * 120; // increase the saturation of colours that are 'average saturation'
3.6) color.s = Math.min(100, color.s); // put saturation back in range

4) Match the new colour against a colour from a minecraft block

5) Map the new texture onto the cube
 
From: Mikee15 Nov 2012 22:07
To: Mikee 16 of 48
I guess I need to write some kind of algorithm to 'expand' colours.

For example:

For any block, if there's no block around it with the same material being used, change the texture to the most common material of each of its neighbours.

I need to make sure I can smooth them out using tricks like that
From: koswix15 Nov 2012 22:08
To: Mikee 17 of 48

Doesn't work. How dare you not support my 7 year old laptop? :C

From: af (CAER)15 Nov 2012 22:20
To: Mikee 18 of 48
Have you timed which parts are especially slow?

(and do you know about console.time() and console.timeEnd() for sub-millisecond timing accuracy?)
From: Mikee15 Nov 2012 22:48
To: af (CAER) 19 of 48
Yeah I've used it a bit - I'll do some proper profiling soon.

I've made a few tweaks to the colour matching. The results are far better, but I've had to sacrifice a little bit of speed.

It's certainly looking better. I could still do with a bit more smoothing on the colours, but far better than it was before...

voxel2.jpg
From: af (CAER)15 Nov 2012 22:49
To: Mikee 20 of 48
You might be able to judge colour matching better if you toned that background down a bit. To medium grey, for instance.