Blender > .3dp import/export script.

Stop by here for help with RRT3 Editor problems and tips.
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Just quoting this over here, so Blender instructions will be in the Blender script thread. !*th_up*!
https://en.wikibooks.org/wiki/Blender_3 ... ng_Windows

IOW, resizing can be done with any window, and works exactly the same way that it does on any desktop. You just click and hold on the border, and drag it.

1/ Getting the skin onto that model is about a one-minute-with-brain-in-neutral job, once you know how to do it. That includes starting from a bare default file and importing the model. It is definitely not the sort of job that will always take half an hour of misery.

2/ Speaking of which, that "little useless box" is simply the default cube model that is in every bare starting file. You can see it labelled as "Cube" in the overview panel at upper right.

You want it gone? Easy. Select it (right click) then go find the "Delete" button on your keyboard. Click that there button. Guess what happens? :-D

Oh, you deleted Elephant by mistake? No worries. Hit Ctrl+Z. Elephant will come back.

You can also delete the default camera. It's of no real use for what we are trying to do.

3/ Rotating the model. It's pretty straightforward. The 5 button on your numpad, over the the right of your keyboard, toggles you from ortho to perspective and back again. The other numpad buttons are all hotkeys for various views.

The 1 button gives you the front view. Ctrl+1 gives you the back view. 3 gives you left side view. Ctrl+3 gives you right side view. 7 gives you top view. Guess what Ctrl+7 does?

2 and 8 do rotation up or down around the horizontal axis. 4 and 6 do rotation around the vertical axis.

9 spins the model 180 degrees around the vertical axis.

Or if you want total freeform, hold own Alt+LMB (Left Mouse Button) then drag your mouse to spin the model anyway you like. You can also use Shift+Alt+LMB to pan in any direction.

If the model is incoveniently placed, you can use the period . button on the numpad to centre the view on the selected object and zoom in on it.

3/ The Alpha setting for texture set to 1, in combination with the Alpha for material being set to zero, will allow transparent sections of the skin (like the gaps between wheel spokes) to be transparent in the viewport. If you are just looking at a loco body skin that has no transparent areas anyway, it makes no difference. Sooner or later though, most likely sooner, you will be grumbling that your wheels look solid and why is Blender doing this? I gave you the settings to avoid that.

The other settings are ones you don't have to worry about unless you want fancy renders. Ignore them. The only thing I usually bother with is turning down the specular on material. I find knocking it back to 0.1 or 0.05 works well with the basic lighting I use.

4/ Importing all the widgety parts at once (mass import) would be cool, but unfortunately the bloke who wrote the import script for us didn't include that option. That's not a Blender fault. It's down to the custom script. I do not currently have the Python skills to code a mass import for the custom script.
And...
Oh and change your bottom window (the one that is almost collapsed) from Timeline to UV/IMage Editor. How? Click on the clock icon in the lowest toolbar to bring up a list of options. Select the one you want.

Edit: And while I think of it, the standard Windows delete button does deletion, but often you just want to hide something. That's what the H key does. H for Hide. Clever, hey?

Don't want it all hidey anymore, and want it to come back where you can thump it? Use Alt+H. Hey presto! Bunnies jump out of hatz. !*th_up*!
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
Just Crazy Jim

Re: Blender > .3dp import/export script. Unread post

Well, I am a bit stuck.

I haven't noticed it until now, probably because most stuff I edit ends up having dark coloured textures. But this latest thing is mid-grey and the flat shading jumps out.
RT3_12_24_16__20_49_23.jpg
RT3_12_24_16__20_49_10.jpg
RT3_12_24_16__20_48_46.jpg
I checked my python script. It has:

Code: Select all

file.write(struct.pack("<3f", *f.verts[i].normal))
which should give smooth shading... only, it doesn't. **!!!**
Before_export.jpg
After_export.jpg
In Blender and Milkshape 3D the model is smooth as glass, after export to RT3, flat shaded....

I crawled through the lines of the script and everything is as you say it should be in the earlier posts in this thread, but still flat shading.

I remember that you had said something about flat shading on the Mogul deborkification thread. Did you find a solution?
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Yup. I had the wrong version of the script. It was flat shading my Moguls because the script was telling it to. Very well behaved, when you think about it. :mrgreen:

So, I changed it to the smooth shaded version and it's all hunky dory now. It should work. Just make sure that line of code says exactly what is in the box.

Code: Select all

file.write(struct.pack("<3f", *f.verts[i].normal))
The flat-shaded version has this:

Code: Select all

file.write(struct.pack("<3f", *f.loops[i].calc_normal()))
Notice the extra pair of brackets there, right after calc_normal. If you try to make a smooth shaded version by editing the text, but forget about those extra brackets, like this:

Code: Select all

file.write(struct.pack("<3f", *f.verts[i].normal()))
That will cause flat shading, along with all sorts of random weirdness (missing verts counts, missing UV mapping, sometimes, not always, unpredictable).

So just check again and make sure it's exactly this:

Code: Select all

file.write(struct.pack("<3f", *f.verts[i].normal))
Two pairs of brackets only. Should work.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Oh stuff it. Forget all that. Hang on and I'll dig out my copy that works. !*th_up*!
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Here ya go.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
Just Crazy Jim

Re: Blender > .3dp import/export script. Unread post

I have the python script open and this is what I have in that function:

Code: Select all

            file.seek(faces_offset)
            for f in bm.faces:
                for i in range(3):
                    file.write(struct.pack("<i", f.verts[i].index + vc))
                for i in range(3):
                    file.write(struct.pack("<3f", *f.verts[i].normal)) <-- exactly as it should be, right?
                for i in range(3):
                    u, v = f.loops[i][uv_layer].uv
                    file.write(struct.pack("<2f", u, 1-v))
                file.write(b"\0" * 4)
Edit: Just downloaded your shared file and tried it. And I'm still getting flat shading. :-(
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Well that's weird. I use that script and I get smooth shading.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Aha! Idea! May not be a good one but anyway...

It could be related to the format you're importing into Blender. Maybe. Can't think what else it would be. I know if I import and edit an existing .3dp I get smooth shading when I export again. However, the import script does not import normals.

All it does is import mesh and UV mapping. We decided on this because getting it to extract normals from existing .3dp's was being a PITA, while Blender will do normals from the mesh automatically. So, since Blender was going to sort them for us, no point bothering with importing them.

However, if you're using an import format that does include information for face normals, it is possible that Blender is remembering this and using the face normals when it exports to .3dp.

This is a guess, on the basis that nothing else seems remotely logical at the moment. It's a problem I've never encountered.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
Just Crazy Jim

Re: Blender > .3dp import/export script. Unread post

Okay, I will try another format. *crossing fingers*
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Blender > .3dp import/export script. Unread post

Hey hang on a doggone minute. I haz another idea. This one might even be useful. :mrgreen:

Since the .3dp import process drops information for normals, it follows that if you took one of the flat-shaded .3dp's and imported that into Blender, then exported it straight away using the smooth-shaded script, it should fix the problem.

Note that I said "should". Might be worth trying.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
Post Reply