simlu / voxelshop

This is the official repositiory for VoxelShop
https://blackflux.com/node/11
Apache License 2.0
350 stars 65 forks source link

Collada exporter sets the origin to object center, even if "Use Cross" is selected. #274

Closed JohnPablok closed 6 years ago

JohnPablok commented 6 years ago

Checking or unchecking the "Set Y instead of Z" option doesn't seem to affect this. By the way, how can I change the cross position? 😅

I'm using these options for the exporter: export_voxels_2017-10-17_20-10-33

simlu commented 6 years ago

Can you export two files, one with and one without and use a diff website to compare the text? There should be differences.

You could shift the model? Otherwise the camera tool might have an option to change the center. Not sure if that shifts the cross though...

JohnPablok commented 6 years ago

Can you export two files, one with and one without

Without "Set Y instead of Z as the up axis" ? Or without "Use Cross" ?

simlu commented 6 years ago

Yeah. You said it doesn't make a difference? Why do you say that?

JohnPablok commented 6 years ago

Ooh, it doesn't make a difference on the origin, as in, it's still not on the cross's position when exporting. I typed that on the first post because I found a very old thread about the same issue. (the last line)

blackflux com_ _view_topic_-_having_issues_with_im_2017-10-17_21-19-08

JohnPablok commented 6 years ago

Cross position in Voxelshop vs Collada model's origin in Blender voxelshop_-_alpha_version_ 1 8 19 _2017-10-17_21-25-54

blender_2017-10-17_21-27-10

simlu commented 6 years ago

Looks correct to me? You realize what you are seeing there in blender is the 3d cursor position?

JohnPablok commented 6 years ago

It's the origin and the cursor, yes (I changed the cursor to the origin's position for clarity) I mean, what I see is that the cross in Voxelshop is near the base of the tree, but in Blender the origin is in the middle of the model... unless by cross you don't mean this ---> collada_exporter_sets_the_origin_to_object_center _2017-10-17_21-35-27 Oops...

simlu commented 6 years ago

Kk, let me check that I didn't break this recently :)

JohnPablok commented 6 years ago

Awesome! Thank you very much, sorry for so much spam hehe 😓 another example, this "cactus"'s origin appears the same in Blender, whether I change it's position or not in Voxelshop. ("use cross" selected) voxelshop_-_alpha_version_ 1 8 19 _2017-10-17_21-45-45 voxelshop_-_alpha_version_ 1 8 19 _2017-10-17_21-46-51 blender_2017-10-17_21-48-43

simlu commented 6 years ago

Yeah, the problem is the Set Y instead of Z option... If you un-check that everything works as expected.

JohnPablok commented 6 years ago

Yeah, the problem is the Set Y instead of Z option... If you un-check that everything works as expected.

For some reason that doesn't change anything for me, weird 🤔 even if it did, not checking that would mess up the rotation in Unity 😰

simlu commented 6 years ago

Can you please export two dae files, one with Y up and one with Z up please? I just want to compare. Thank you!

JohnPablok commented 6 years ago

https://www.diffchecker.com/NMjopa0q Oh, first one is checked, I... think... gonna do it again

https://www.diffchecker.com/ZKGwswDE with another model, indeed, left one is the "Y up" the right one without it

I can upload a zip with both files if you want.

simlu commented 6 years ago

I think I fixed it. Let's see...

simlu commented 6 years ago

Can you try the latest develop build please and see if that fixed it for you? https://s3-us-west-2.amazonaws.com/voxelshop/build/develop/voxelshop-bin.zip

simlu commented 6 years ago

Just tested the two files you diffed here: https://www.diffchecker.com/ZKGwswDE

And they do import differently in blender for me?

JohnPablok commented 6 years ago

they look the same in Blender, I'll check the build :)

simlu commented 6 years ago

Ah... now I understand what you are getting at :)

You are talking about the object origin, not the import location!

JohnPablok commented 6 years ago

O_O 😅 omg... English isn't my native language, I hope this wasn't too confusing, yes, the object center

simlu commented 6 years ago

Haha, no problem (I should have understood earlier...). If you use an older version the behavior is as you would expect. I've changed it so that the object origin is the always the center of the object (as it made sense for using single voxel export).

simlu commented 6 years ago

What is your use case here of the origin? Is this required by Unity?

simlu commented 6 years ago

If you select the option "Object Separation > Per Voxel", it's probably easier to understand how the object origin is set.

I've clarified this now and it will be called "Scene Origin".

JohnPablok commented 6 years ago

Oooh, well, I just wanted the center of the object to be near the base because it simplifies level-building when importing them to Unity, the models snap to other surfaces based on their center. I could modify it in Blender but it would take a long time for 200+ objects.

simlu commented 6 years ago

Oh boy, there are so many export options already. I guess time to add "Object Origin" as another one...

Would it be ok if the origin was exactly at the bottom + center of the object (not at the cross)?

JohnPablok commented 6 years ago

Oh, yeah, I think bottom center would be great for 99% of gamedev cases. Thank you so much 👏 and sorry for all the trouble 😖

simlu commented 6 years ago

I don't think I have time to add it right now, but if you want to use this old version: https://github.com/simlu/voxelshop/releases/tag/1.8.16 It should do the job as you'd expect!

What happens in unity if you import "separate per voxel"? Do all the voxel snap to the same position on import?

JohnPablok commented 6 years ago

Yeah, don't worry! There's no hurry for the feature. I'll try the "separate per voxel" option, brb

simlu commented 6 years ago

Comment to self: We can adjust the center generation (have to consider useY) if the "object origin" option is set. Shouldn't be too hard to do this then. Consider using 3 x 3 selects: min / center / max per axis

JohnPablok commented 6 years ago

Oh, interesting behavior... when using "set Y instead of Z" the whole object (the tree) appears laying on its side, and the rotation is zero on x,yz for the object and the voxels. When not using "Set Y" the object's origin appears on the bottom (where voxelshop's cross is) and each individual voxel's rotation is set to -90 on X, but the whole model has rotation zero in all axis. unity_2017 2 0f3_personal_ 64bit _-_roll-a-ball un_2017-10-17_23-10-18

simlu commented 6 years ago

Lol, Unity and Collada still have problems then :)

I'm glad the textures seem to be importing correctly. However you have some artifacts. There is a thread somewhere that describes how to improve that (or you could just use the colored vertex export)

JohnPablok commented 6 years ago

I was being lazy and didn't set the texture's filter mode to "Point", but yeah, textures are flawless once I do that. 😅 I'll look for that thread! Thank you!

RepairUnit3k6 commented 6 years ago

@simlu Hey i got idea ! I'm doing C# , i have no experience with java but you can use If-Else in java too, right ? So... if separation is "merged" and cross is used as origin, exported model will have origin on cross, else use center of mass. It is possible ? I'm forced to use version 1.8.16 only because i need origin on cross...

simlu commented 6 years ago

@garrom can you provide a minimal test case please? I will need: voxelshop file, export settings, exported dae file and a description what happens and what you expect to happen. Cheers!

RepairUnit3k6 commented 6 years ago

@simlu Same problem as @JohnPablok had. I need origin to be on position of cross because I'm game dev and position of model is important. I'm using voxelshop only to create model but animating and FBX export happens inside Blender. I'll snap bones to size of voxel but snapping is relative to origin of model. This is why i need origin on specific place. This new position of origin was created because of new feature : The pre-voxel export, but if user choose "Merged" in export settings there is no reason to keep origin in center of mass and cross can be used as origin. My idea is to use cross as origin if user choose "Merged" and to use cross as origin in export settings. Now is origin settings ignored and as origin is used center of mass no matter what user set as origin.

RepairUnit3k6 commented 6 years ago

@simlu Do you working on it, or you do refused my idea ? I really like to know if you ever use my idea or if i will be forced to use 1.8.16 forever...

simlu commented 6 years ago

@Garrom Sorry, I didn't know this was important to you. I can certainly work on it. I'm a little confused as to what the actual problem is, though. Basically you are saying that if you select "merged", the origin is always ignored? That sounds like a bug?

Would you mind highlighting the behavior with some screenshots and example files please: What settings you use with 1.8.16 (screenshot) and what the exported model looks like (screenshot + file). Then what you are setting in the new version (screenshot), what you get (screenshot + file) and what you would expect (probably what the export from 1.8.16 was).

That way I can fix the actual problem much easier without having to guess! Cheers

RepairUnit3k6 commented 6 years ago

@simlu Sure, i can provide some screens. First, I have this Fish.... Don't ask why fish just let fish be a fish. Fish come from older version. Image below shows you therre windows in this order VS view -> VS export settings -> Blender import. First image Now to the new version. As you can see this one is JellyFish, again, don't ask why, it is just JellyFish. Secound Image As you can see, in export settings is selected "Use cross" but it is ignored and center of object is used. Look, i know it works like this because of pre-voxel export. My idea is to use selected origin if user choose "Merget", now it is always ignored no matter if i choose merget or pre-voxel. It make sense to work like this with pre-voxel settings but if i export whole object as one there is no reaseon to behave like during pre-voxel export.

I adding two .7zip files. In one is .dae and texture of fish and in 2nd one are files for jallyfish FishFiles.zip JellyFishFiles.zip

simlu commented 6 years ago

@Garrom Ah, you're talking about the object origin. There is a big difference between scene origin and object origin. The scene origin seems to be cross in both images above, but the object origin has changed. Would you agree that this is the issue?

You are right in that some functionality was removed here. I had already started on adding it back in quite a while back, but then other things came up. Let me see what I can do here for you.

simlu commented 6 years ago

Reference for myself. Had something like

        collada.addComponent(new SeparatorModule("Object Origin"));
        BlankDialogModule wrapper = new BlankDialogModule("object_origin");
        wrapper.setLayout(new BorderLayout());
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(3, 1));
        for (String axi : new String[] {"x", "y", "z"}) {
            ComboBoxModule objectOrigin = new ComboBoxModule(axi, new String[][]{
                    new String[]{"min", "Minimum"},
                    new String[]{"center", "Center"},
                    new String[]{"max", "Maximum"}
            }, 1);
            JideLabel label = new JideLabel(axi.toUpperCase() + ": ");
            label.setFont(FontUtil.getTitleFont(label.getFont()));
            JPanel innerWrapper = new JPanel();
            innerWrapper.setLayout(new BorderLayout());
            innerWrapper.add(label, BorderLayout.WEST);
            innerWrapper.add(objectOrigin, BorderLayout.CENTER);
            panel.add(innerWrapper);
        }
        wrapper.add(panel, BorderLayout.WEST);
        collada.addComponent(wrapper);

But no longer think this is the adequate solution. Rather should have one option slider with Use Own Center, Use Global Center, and the rest like Scene Origin.

So something like

        collada.addComponent(new SeparatorModule("Object Origin"));
        ComboBoxModule setObjectOrigin = new ComboBoxModule("object_origin", new String[][]{
                new String[]{"local_center", "Use Local Centers"},
                new String[]{"cross", "Use Cross"},
                new String[]{"center", "Use Global Center"},
                new String[]{"plane_center", "Use Object Center Projected onto Plane"},
                new String[]{"box_center", "Use Bounding Box Center"},
                new String[]{"box_plane_center", "Use Bounding Box Center Projected onto Plane"}
        }, 0);
        collada.addComponent(setObjectOrigin);
simlu commented 6 years ago

@Garrom I've pushed some changes to develop that should address this. Can you please download the test build here and do some testing for me? Once you confirm that this actually fixes your issue I can do a release.

RepairUnit3k6 commented 6 years ago

@simlu Yes, i mean object center. I see there is some settings under "scene origin" but i'm afraid i cannot use it because my monitor is not enough big(image below is my whole monitor). I have standart mid-end laptop from lenovo. My monitor is only 1366x768. I know i want a lot in very short time but is possible to make export settings in to two columns ? Image showing my monitor. It is too small

ps. It is Windows 7. I set up its look to XP-Like because it saves lot of memory and it allows me to paint it to green what is not so agressive to eyes as other colors are.

simlu commented 6 years ago

Ok, please try again. Make sure you have branch develop and build 339 (in case download gets cached).

RepairUnit3k6 commented 6 years ago

@simlu Where i can find build ? Develop branch have nothing like "Bin" or "Builds". If you want me to compile it myself i must say i'm dot-net developer, I don't have tools to build java sources. All what i have is Android ADB, flashing tool and few roms but that is all java-stuff i got...

simlu commented 6 years ago

Same link as before

RepairUnit3k6 commented 6 years ago

@simlu I'm sure you can close this issue now. It is perfect ! Thanks a lot man :heart_eyes: :thumbsup:

simlu commented 6 years ago

Great! Just released 1.8.20.

If there are any more questions, please open a new issue!