MrCrayfish / ModelCreator

A program to create JSON models for blocks
Other
121 stars 64 forks source link

When importing json file or loading model, let every face be enabled. #108

Closed AndersBillLinden closed 8 years ago

AndersBillLinden commented 8 years ago

Hello MrCrayfish! When I create a cube, I will see it even if I did not choose a texture yet. If I save the file, either exporting it as json or saving it to the model format and then load it again, the faces without texture will not show any longer so I will see nothing after I have loaded the model.

This is maybe not satisfactory.

The change will enable all faces when loading/importing an object. I am not totally sure this is appropriate, so you better think about it twice before accepting this PR. When should loaded faces actually be disabled?

MrCrayfish commented 8 years ago

I think the saving needs to be refactored. It should keep the face enabled on save even if it doesn't have any textures.

AndersBillLinden commented 8 years ago

But does the model format really keep information about disabled faces?

MrCrayfish commented 8 years ago

Yes. If you ignore writing one of the face definitions when creating an element, it won't render that face.

      {
            "name": "Cube",
            "from": [ 1.0, 14.0, 0.1 ], 
            "to": [ 15.0, 15.0, 1.0 ], 
            "faces": {
                "north": { "texture": "#0", "uv": [ 0.0, 0.0, 14.0, 1.0 ] },
                "west": { "texture": "#0", "uv": [ 0.0, 0.0, 1.0, 1.0 ] },
                "down": { "texture": "#0", "uv": [ 0.0, 0.0, 14.0, 1.0 ] }
            }
        },

Won't render east, south, and up face.

AndersBillLinden commented 8 years ago

But then, the face definitions will be lost.

MrCrayfish commented 8 years ago

You'll only lose the UV, but if you're disabling it on purpose, it doesn't matter.

AndersBillLinden commented 8 years ago

As it is now, if you load a model with faces that you not yet has set a texture on, they will not show up in the one color fashion (depending on direction) as they probably did when you were saving the model.

AndersBillLinden commented 8 years ago

So it would appear like you do not load what you did save.

MrCrayfish commented 8 years ago

Okay, I get it now. I will get a fix out. Setting them enabled on load is not the correct solution.