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

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

I figured this was worth a thread of its own, to keep track of progress with importing and exporting from Blender.

--------------------------------------------------------------------------

Update: New and better working script attached to the bottom of this post.

Improvements may follow, but it already works. I'll sort out a bit of a readme for it later.

Short version is that it will export any Blender model to .3dp, but it does require the components to have UV mapping. However, you can test unfinished models by deleting anything which is not UV mapped and exporting the rest. You'll have to trim it down to whatever you want in that file too, such as temporarily deleting everything except one wheel when making a bogie .3dp file.

This is quite fast in practice. You can just select the bit you want (right click), invert selection (Ctrl+I), delete the unwanted stuff (Delete key, of course), then export the remaining object, then Ctrl+Z backwards a few steps to get the entire model back the way it was. Repeat as necessary. :-D

To install the script into Blender, copy it to the C:\Program Files\Blender Foundation\Blender\2.74\scripts folder. Then fire up Blender, go into user preferences > add ons, find the script in the list, and enable it.

Regarding importing: Just as a quick example I grabbed the default H10 2-8-2 model I had been messing around with a while back. The imported model is shown in the screenshot. It's all there, and all correct. (0!!0)
Test_import.jpg

The story so far is that CoDEmanX over at the Blender Artists forum has very kindly roughed out an import/export script for going straight from RT3 .3dp files to Blender, and from Blender out to RT3 .3dp format.

CoDEmanX and I are talking about possible improvements to the script and he seems ok with implementing them, but obviously this will depend on his available time and enthusiasm. He's been great so far and I don't want to hassle him.

For the basics of Blender interface use, see the Noob to Pro tuts. These tuts are very good, and well worth reading.
You might also want to look at the Blender reference manual.
Last edited by Gumboots on Mon Nov 23, 2015 9:02 pm, edited 4 times in total.
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

There's been a bit more progress on this. For a start, the script will now export vertex normals instead of face normals, so that's sorted. It just required changing one word in the code ("loop" is now "vertex"). !*th_up*!

He's also had a go at getting the UV mapping to import, and it looks like that will be ok (haven't seen the code yet). So, we should be able to view the skins on the model in Blender, which will be handy for skinning of default models if anyone wants to do that, or for later skinning of imported custom models. My assumption is that for custom models the Blender file would be made available anyway, so .3dp importing wouldn't be necessary, but on the off chance the .blend file wasn't available it would still be possible to import the custom .3dp and work with that.

I'll try to get some in-game testing organised tonight.
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

Ok, the script works. I've just tested it live with functioning locomotive export. See the Schools Class V thread for details. !*th_up*!

A zipped copy of the current script is attached to the OP of this thread. Improvements may follow, but it already works. I'll sort out a bit of a readme for it later.

Short version is that it will export any Blender model to .3dp, but it does require the components to have UV mapping. However, you can test unfinished models by deleting anything which is not UV mapped and exporting the rest. You'll have to trim it down to whatever you want in that file too, such as temporarily deleting everything except one wheel when making a bogie .3dp file.

This is quite fast in practice. You can just select the bit you want, invert selection, delete the unwanted stuff, then export the remaining object, then Ctrl+Z backwards a few steps to get the entire model back the way it was. Repeat as necessary. :-D

To install the script into Blender, copy it to the C:\Program Files\Blender Foundation\Blender\2.74\scripts folder. Then fire up Blender, go into user preferences > add ons, find the script in the list, and enable it.
Last edited by Gumboots on Wed Jul 01, 2015 4:15 am, edited 1 time in total.
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Hawk
The Big Dawg
Posts: 242
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

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

The Blender site says 2.74 isn't supported for XP, and if I do install it I most likely will have to install yet another version of Visual C++. I already have 6 of them installed. This is getting worse than NetFrameWork.
Hawk
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

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

Ok, shouldn't matter that much. I suspect the script will run ok with Blender 2.6X. What's the latest Blender that will run on XP? Shouldn't be hard to find out.

The other thing is that just because the main page says XP is "not in (active) support", that doesn't necessarily mean that 2.74 won't run on XP. It may just mean that since Windoze is not supporting XP any more, Blender won't officially support XP either. From a support crew perspective this makes sense, but it may still run ok. Could be worth a try.

-----------------------------------

Just did a quick search for "Blender on XP". Found a few things that indicate it may work ok, apart from some of the more computationally expensive stuff (rendering, etc).

http://www.oldapps.com/blender.php?system=Windows_XP
https://developer.blender.org/T43177
http://lists.blender.org/pipermail/bf-c ... 42373.html
http://lists.blender.org/pipermail/bf-c ... 42375.html
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Hawk
The Big Dawg
Posts: 242
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

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

I'll check those links out. I have 6 other versions of Blender. I just figured since that plugin was written for 2.74 it might not be backwards compatible.

That second link, that discusses the issues with opengl32.dll for XP makes me want to steer away from any 2.7.. versions. I may try that plugin on a 2.6.. version to see if tit works, but not right away. I'm kind of wrapped up in a new game I just got. Not a new release, but new to me. :mrgreen:
Hawk
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

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

Y'know if you get in a bind with the script not working on pre-2.7x, you could just model stuff in whatever Blender you can run on XP, then get some other mug to open the .blend in their 2.74 and export it to .3dp. That should be pretty painless for everyone.

Anyway, no rush. Enjoy your new game. !*th_up*!
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
Hawk
The Big Dawg
Posts: 242
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

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

Yea, that would work.
Hawk
User avatar
Gumboots
CEO
Posts: 1203
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

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

Ha. Found a bug. I put a lighter skin on the test loco so I could see what was going on, and it turns out the model is being flat-shaded instead of Gouraud shaded. This is because it is being exported with face normals assigned to vertices, instead of the correct vertex normal (which splits the difference between faces). So with a dark skin it doesn't show up, but with a lighter skin the flat shading becomes more obvious.

It's still ok for basic export testing and won't stop me making progress on the Schools class V, but it'll need to be sorted for vertex normals before it can be called a (really) working script. At least for locos anyway. For buildings it would probably even be better the way it is, because most faces on those really should be flat shaded. We may end up with two scripts: one that exports flat shaded for square stuff like buildings, and one that does smooth shaded for locos, etc.

I'm confident it can be debugged for locos. !*th_up*!
Gumbootz Lokomotivfabrik und Bierkeller

LMR Samson 0-4-0 - Pennsy H3 Consolidation - Custom double tank cars set
User avatar
RulerofRails
Dispatcher
Posts: 310
Joined: Sun Dec 08, 2013 1:26 am

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

I am glad that you finally have a script working for the models! I am not really a modder, preferring to play. I haven't even made a decent-quality map yet. :oops: Exploiting the dynamics of the game's engine in-game are more interesting to me, but if I get a bunch of free time. . . . Still, it's a great resource to have, thanks for pursuing this, and to the kind sir who made the code for you!
Post Reply