Code Monkey home page Code Monkey logo

objtoschematic's Introduction

Logo
ObjToSchematic

A visual tool to convert 3D .obj models into Minecraft structures (.schematic, .litematic, .schem, .nbt)
OnlineDesktop (Legacy)

UsageDiscordContributingGalleryDocumentation

Logo Logo Logo

Noodles "Noodle Bowl - 3DDecember Day9" (https://skfb.ly/orI9z) by Batuhan13
is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).

Usage

⚠️ ObjToSchematic is now primarily a website, visit https://objtoschematic.com for the latest version.

Desktop Version

The Desktop version is no longer updated but can still be downloaded here for Windows, macOS, or Linux*. If you want to use a non-release build, use the following steps to run it:

  • Download and install Node.js.
  • Run git clone https://github.com/LucasDower/ObjToSchematic.git in your command line.
  • Navigate to /ObjToSchematic-main.
  • Run npm install.
  • Run npm start.

"Cut Fish" (https://skfb.ly/orWLC) by Suushimi
is licensed under Creative Commons Attribution-NonCommercial (http://creativecommons.org/licenses/by-nc/4.0/).

Progress

The progress tracker and remaining to-dos are now maintained in the Discord server's #to-do channel.

Disclaimer

This is an non-commercial unofficial tool that is neither approved, endorsed, associated, nor connected to Mojang Studios. Block textures used are from Minecraft and usage complies with the Mojang Studios Brand And Assets Guidelines.

MinecraftPreview

Contributing

Any contributions are welcome, just fork and submit a PR! Just make sure the code style follows the rulings in the .eslintrc.json by running npm run lint and the tests all pass by running npm test.

Currently there's not much docs but if you're looking for where to get started, look at app_context.ts and follow _import(), _voxelise(), _assign(), and _export(). If you're looking to add elements to the UI, look at ui/layout.ts, I'm not using a UI framework because I'm a nutter. Adding more file formats to import from and export to would be nice. Adding new default block palettes would be great also.

If you have any questions or need help getting started then feel free to join the Discord or message me SinJi#4165.

Translations

Translations files are stored in /loc/. To add a new language, duplicate the en_GB.ts file, rename it to the language code you are adding. The en-GB.ts file is the main language file. All the possible translation keys that you can override exist in en-GB.ts. Your translation file does not need to override every key, missing translations will fallback to the British English translation. Translation files are checked at compile-time for invalid keys. Once your translation file is complete, modify /loc/base.ts to include your new language. And that's it! Visit the i18next documentation if your language requires special attention such as plurals or visit the Discord for help or if the current implementation isn't sufficient for your language.

Gallery

Gallery1
"Creepy Lady Bust Statue Scan" (https://skfb.ly/6B7pK) by alex.toporowicz is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
Gallery3
"Pivot Demo: Journey" (https://skfb.ly/6WCIJ) by Sketchfab is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
Gallery4
"Handpainted Pancake" (https://skfb.ly/6T7yN) by Marvi is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).

Documentation

Below is a detailed explanation into what each configurable setting does divided into each step in the program.

Import

  • Wavefront .obj file - This is the actual 3D model you want to voxelise. Please note that the more complex your model is the longer it will take to voxelise. It is strongly recommended that you simplify your geometry in a program such as Blender to reduce the poly count. If your triangles are smaller than the size of the voxels then you will not notice the difference and the extra detail is just wasting resources.
  • Rotation - Change to rotate the mesh, requires clicking 'Load mesh' to update.

Materials

Here is where you can edit the materials that the loaded model uses. Any changes you make require you to commit the changes by clicking 'Update materials'.

  • Type - Switch between a Solid material or a Textured material. Note, only materials that're used by triangles with defined texcoords can be turned into Textured materials.
  • Solid Materials
    • Colour - The actual colour of the material.
    • Alpha - The transparency value.
  • Textured Materials
    • Diffuse map - The actual texture file the colour data is from.
    • Filtering - How pixel values are sampled.
    • Wrap - How texcoords outside the [0, 1] range are sampled.
    • Transparency - How transparency values are sampled, either 'None' for opaque, 'Alpha map' for custom alpha mask textures, 'Alpha constant' for a flat transparency value or 'Use diffuse map alpha channel'.

Voxelise

  • Constraint axis - This determines which axis is used to determine the size of the model. If you choose 'Y' and type in a size of 80 then the voxelised mesh will has a height of 80. If you choose 'X' instead then the width will be 80.
  • Size - This works in conjunction with Constraint axis as described above.
  • Algorithm - There are many ways to turn a triangle mesh into a voxel mesh and each method produces different results. Here you can choose which one you like the best.
  • Ambient occlusion - This is a purely visual setting and makes no difference to the outputted structure. Ambient occlusion displays the shadows between adjacent blocks just like Minecraft. This takes quite a hit to the time to voxelise so consider turning this setting off first.
  • Multisampling - Multisampling should only be used if your mesh uses textures. It takes multiple samples of the texture to get a more representative colour for a voxel. If your triangles and voxels are a similar size then you'll want this on. If your voxels are much smaller than the triangles then you'll probably not notice the difference this makes unless your texture is very noisey.
  • Voxel overlap - When two triangles next to each other are voxelised one after another the second triangle may place voxels in positions where the first triangle has already placed a voxel. This setting allows you to only take the First voxel colour or take an Average.

Assign

  • Texture atlas - The textures to use for each block. This also determines how colour-conversions are made.
  • Block palette - What collection of blocks are available to choose from.
  • Dithering - An image speaks a thousand words.
  • Fallable blocks - There's a chance a block is placed such as Sand which when actually placed is going to fall under gravity. You probably don't want this to happen so Replace falling with solid will substitute the falling block for a similarly coloured block. Alternatively, you can Do nothing or replace any gravity-effected block with Replace fallable with solid.
  • Colour accuracy - This bins together similar colours to speed up colour-to-block conversions. This is a logarithmic scale.
  • Smart averaging - When performing colour-to-block conversions only block faces that are visible are used in calculating the 'average' face colour. There's no reason to turn this off apart from it being slower.
  • Smoothness - A high smoothness value will prevent block with noisey textures being used. This is very sensitive to small changes. High smoothness values will decrease the colour accuracy as under-the-hood it is trading off colour error for std error.
  • Calculate lighting - Turn this on if you want don't want night-vision in the editor. Only turn this on if you really need it as it is considerably slower.
  • Light threshold - Requires Calculate lighting to be on. Will place light blocks (not the Light Block) in places where the light value is less than the threshold. Useful in automatically lighting up the dark areas of your structure.

Export

  • File format - The format to save your structure to. The Litematica format is strongly recommended and is significantly faster to export to for large structures. The Schematic exporter is useful if you still play in 1.12 as it uses the old block ID system before The Flattening, however many new blocks cannot be encoded in this format so they will be turned into Stone blocks. The NBT exporter is used for Minecraft's structure blocks. The OBJ exporter can be used to render your structres in a program such as Blender.

objtoschematic's People

Contributors

0-zen avatar creeper553 avatar dependabot[bot] avatar enchoseon avatar icetank avatar lucasdower avatar malken21 avatar misode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objtoschematic's Issues

Custom blockstate support

I have a texturepack where i have a different texture for each noteblock blockstate, is it possible to add atlas support for that (or if there already is support for that how do i use it)?

ps: awesome project

Failed to load mesh

Every OBJ I try to load fails, on other 3D software and sites the objects can load fine
failed to load

Camera rotates slower with devtools open

For some reason the camera rotates slower if you have the devtools tab open (Ctrl + Shift + I). This bug was introduced in commit d3b2f9d (prev commit dd571dc). I have tried tackling this bug numerous times and I haven't been able to fix it. The fix is definitely trivial but is so small I can't find it.

Feat: Measuring distance in blocks

Would be super nice, to click two blocks, have them hightlighted, and see the distance in blocks between them. Data wise, this should be rather simple from what I see, however no idea about how to render this :D

Parameter for automatic / percentual voxel size from max height/width/depth

It would be nice if the program would get an option to define i.e. the max height of the model and calculate the voxel size based on that.

I am currently facing an issue where the program kind of just hangs for hours (my model is 14382mm in depth) and the voxel size i calculated gives me wrong results in the program - if it ever finishes to process.

Additionally, a % parameter instead of a static size would also be neat.

How to choose a specific set of blocks for the exported schematic?

Hello!

First time trying to use your tool, i imported a couple of .obj but cant see any option to specify what blocks should be picked by the converter when doing the process of converting to schematic.

I see a block pallete option in assign blocks, but it doesn't have options like use only wool, stained clay or concrete "palletes".

I'm doing something wrong of unfortunately this isn't a feature supported by the tool?

Add width and length sliders

I am making my college campus (over 2 miles long) in Minecraft and this tool has saved me a TON of time! Thank you so much for making it!
In my project, I have 42 obj files with known width, length, and height. However, just putting the height in for this tool does not accurately capture the width and length, causing the completed litematic files to mismatch more than would be expected from the rounding I have to do on the height to make it a full meter measurement. Could you add sliders for the width and length in addition to the height? That would be very helpful!
Thanks again for this amazing tool!

Render thread blocking with larger schematics

Attempting to render larger voxelizations often causes the program to hang and crash, especially if Ambient Occlusion isn't disabled.
image

Sometimes it's just the rendering that crashes and you can still try and apply blocks to the model, but nothing will export past that point so you can't actually get the litematic.

Here's the file I'm attempting to use. Extremely small height sizes can often work but anything sizeable seems to cause the issue.
Large Obj Test.zip

Load big meshes

[Importer]: Failed: - Something unexpectedly went wrong.

Currently it is unable to load a large mesh file. I am trying to re-create a Venator Class Star Destroyer, and thought this tool would be perfect as it brings the color of the object into the blocks without me having to do any work. Well I can not get the file to load at all.

Files linked are what I tried.
First has n-gongs, second (suffixed -n) has none.

(Too big for github so posted them in my discord server for download link)
https://cdn.discordapp.com/attachments/347566125527072769/1054213374700949576/Obj_Models.zip

Ability to fill voxelized models

I've been using ObjToSchematic in my mapmaking workflow to export models from blender and place them in the world using Amulet.
But it causes problems when freely scaling/rotating the schematic in the editor or ingame using worldedit: since the schematic is hollow, it creates holes in the model.

It would be great to be able to export filled schematics, to avoid this issue.
Thanks a lot for this incredible tool !

Image of the issue with free rotation in Amulet:
image

Export is giving an error

[8952:0408/224105.700694:INFO:CONSOLE(400)] "Uncaught TypeError: Cannot read property 'elements' of undefined", source: /home/purpletwo/ObjToSchematic/dist/src/ui/layout.js (400)

Im using v16.14.2 node version with v8.50 of npm

on ending and exporting it create a file that is not a schematic and plus is giving this error

No support for entire .obj face formats

Loading .objs with faces in the format f v1 v2 v3 .... are not loaded correctly, only faces in f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 ... format is supported. Also n-gon faces are not supported.

Grass-like blocks are used when solid blocks are above

Grass-like blocks such as Nylium and Mycelium will turn into Netherrack and Dirt respectively when an opaque block is placed above them. A check should be put in place to ensure a non-opaque block is above grass-like blocks before assigning them to a voxel.

Object loading error

Tried loading your example object( skull ), which results in an error. Same for other models, just different 'v' value.

image

C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic>npm start

[email protected] start
npm run build && electron ./dist/src/main.js --enable-logging


[email protected] build
npm run lint && tsc

 [email protected] lint
eslint --fix ./src/**/*.ts && eslint --fix ./tools/**/*.ts


[21096:0331/161044.906:INFO:CONSOLE(416)] "disabling Simplify", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161044.907:INFO:CONSOLE(416)] "disabling Build", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161044.909:INFO:CONSOLE(416)] "disabling Palette", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161044.909:INFO:CONSOLE(416)] "disabling Export", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161044.909:INFO:CONSOLE(39)] "[BROADCAST] onGridEnabledChanged true", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\event.js (39)
[21096:0331/161044.994:INFO:CONSOLE(113)] "%cElectron Security Warning (Insecure Content-Security-Policy) font-weight: bold; This renderer process has either no Content Security
    Policy set or a policy with "unsafe-eval" enabled. This exposes users of
    this app to unnecessary security risks.

For more information and help, consult
https://electronjs.org/docs/tutorial/security.
This warning will not show up
once the app is packaged.", source: electron/js2c/renderer_init.js (113)
[21096:0331/161053.009:INFO:CONSOLE(13)] "(electron) The remote module is deprecated. Use https://github.com/electron/remote instead.", source: electron/js2c/renderer_init.js (13)
[21096:0331/161106.329:INFO:CONSOLE(416)] "disabling Simplify", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161106.329:INFO:CONSOLE(416)] "disabling Build", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161106.331:INFO:CONSOLE(416)] "disabling Palette", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161106.332:INFO:CONSOLE(416)] "disabling Export", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (416)
[21096:0331/161106.334:INFO:CONSOLE(92)] "Doing 0", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\app_context.js (92)
[21096:0331/161106.335:INFO:CONSOLE(318)] "Caching input", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\ui\layout.js (318)
</b>", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\app_context.js (99)674844741821289e+000 9.2430496215820312e+000 9.8690280914306641e+000 0.337255 0.282353 0.152941

When loading another file it outputs the error

[24968:0331/190034.255:INFO:CONSOLE(99)] "Error: Failed to parse essential token for <b>v -9.736512E-05 0.1256737 0.09343636</b>", source: C:\Users\Vasily\Desktop\ObjToSchem\ObjToSchematic\dist\src\app_context.js (99)

Incorrect texture mapping in voxelization (branches main and 0.7)

0.7-localise doesnt seem impacted.
I am not a specialist of that matter so I am making an issue report. I have found a weird bug which might come from a very recent commit since I did not have it before. Here is the model loaded on ObjToSchematic:

image

As you can see the textures are correctly loaded. But when I voxelize it:

image

Some areas seem to not have the right textures... Had the same problem with all other files i tested on main and 0.7 Here is one in example:

https://filetransfer.io/data-package/kpK2XQSI#link

Binvox-like material parsing with material names

Having the ability to control the blocks with material names (like Binvox's material parsing) would allow us to have a higher level of control over the final output before exporting to an obj.

(Example: Geometry with a material named "material_glass" would be turned into "minecraft:glass", "material_white_stained_glass" into "minecraft:white_stained_glass", etc.)

Add headless script (FR from MichelArts)

Allow meshes to be voxelised via a script without invoking the UI. The groundwork for supporting this is already in place, the script just needs to be written.

Way to remove wrongly added voxels

Hey,

I am testing this tool for a project I am doing. On the step voxelize, there are actually voxels added which don't need to be there.
Is there a way to disable this behavior? If you wish to have some pictures, contact me at Discord. MichelArts#3677 (since its a private project)

Waiting for response.

Feat: Constraint Multiple Axis At Once

I'm attempting to put an object exported from Magicavoxel into Minecraft, and using this would be helpful. As it stands, you can constrain only one axis at one time, it gets really close to getting all three values correct but it hasn't yet. Just wondering if this would be possible?

This mesh is 110x69x61 (Shown Top Right)
Example
The Voxelizer has swapped the Length and Height after I clamped width to the correct value of 110.
Example2

Basically, I'm trying to get 1:1 Magicavoxel Voxelization so one in voxel in Magicavoxel is one voxel in this program, Thanks!

setting size

Great software, it would be nice if could setting the size, because I don't know the exact size

Giving not a valid .schematic at the output

Hi, I made it before but was 2 error this one is the strangest one when i try to export every project it gave me an archive and when i open it its just a file with a file typed unkown and then nothing i can't do with this file trying to upload it i can't nothing at all

(I can't extract it)

immagine
immagine

Mesh export not possible for objects > 10k voxels

There appears to be a limit on the number of voxels that can be exported. Attempting a conversion of a large mesh with 50k+ voxels, export will fail until taking the desired height down to 10. This makes the export unusable for larger models / structures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.