Latest Blender/SHP Export/Import Scripts

Talk about your new mod or map here

Moderators: jelco, bert_the_turtle

User avatar
Lowell
level3
level3
Posts: 428
Joined: Mon Jan 02, 2006 8:03 pm
Location: Atlanta, Georgia
Contact:

Postby Lowell » Thu Feb 07, 2008 10:47 am

...yup...for Sid Meiers RailRoads game. I've made a ton of mods for it, new trains, buildings, ships to use as industries. The trains pull up to terminals load and then unload goods. The mods are far better than the default game. And as usual I make some of the biggest scenarios and landmaps. :D I also work on Trainz, MSTS...list goes on. Cool stuff...the modeling is a challange, I've learned a ton. I've posted a couple map sets at HookedGamers.com forum for RailRoads. I am also building a page on my site for all the new content and maps. That should be up this weekend. Later...I will also post them at ModDB.
It has been a very good project. Here are a couple images of a new project called Mud Skippers that is in beta test mode and about to be published...it has a whole new fleet of steam and diesel engines...some twenty or so, plus new train cars and well...tons of stuff.
Image
Image
User avatar
KingAl
level5
level5
Posts: 4138
Joined: Sun Sep 10, 2006 7:42 am

Postby KingAl » Thu Feb 07, 2008 10:53 am

Ah, Railroads is great, though I've never been good at tycoon games.
Gentlemen, you can't fight in here: this is the War Room!
Ultimate Uplink Guide
Latest Patch
ERing
level1
level1
Posts: 53
Joined: Sat Mar 17, 2007 9:51 pm
Contact:

Postby ERing » Thu Feb 07, 2008 3:11 pm

Dang, wish I were that good. I'm learning how to model on nystic.com, they have some good tutorials.
Anyways, so far I've made two things (three things if you count the same model but different textures.

A heart. A chess pawn. And a monkey and the same chess pawn, just with a glass texture.

Sorry, no link, currently my server is down... It's been timing out frequently lately, I might just wipe the drive and do a fresh install of linux... or get a new network card, the two on the motherboard seem dead, and the replacement I have is from a REALLY old computer we found on the street... but I haven't had problems until I installed lighttpd. I had memory issues before, PHP was taking up all the resources, but that should be fixed.

EDIT: Ah, wait, after posting it stopped timing out, here's a link, keep trying if it times out: http://e-ringtech.com/forum/viewforum.p ... 1f049d3136
User avatar
Lowell
level3
level3
Posts: 428
Joined: Mon Jan 02, 2006 8:03 pm
Location: Atlanta, Georgia
Contact:

Postby Lowell » Thu Feb 07, 2008 10:08 pm

Blender is Free. They have great video tutorials that help get things rolling. It has turned out to be a great tool. It can do sereval things as well, cool program. Daz studio is also free. I statred out with Lightwave 5.6, I was one of the first to buy Vud 'd Esprit when it came out, it has turned out to be my favorite 3D app. for landscapes and more.

The RailRoad game is cool, but it has issues and can be unstable. It requires alot of system reasources to play the game, the large maps take a large gaming system to keep running.

Anyway, I have a fuel yard that I need to convert several buildings for the last couple levels for the Darwinia mod I was working on. I am still not sure about the Start Pylon as I was using it on several levels...some pylons may need dropped/changed.

I tried your link a couple times but it wouldn't go through.
Da Red Baron 55
level0
Posts: 3
Joined: Sat May 24, 2008 9:37 pm
Location: Atlanta, Georgia

Postby Da Red Baron 55 » Sat May 24, 2008 9:56 pm

I heard about that game and thought I'd try it. Thanks for warning me, I'll stay away from it.
User avatar
Lowell
level3
level3
Posts: 428
Joined: Mon Jan 02, 2006 8:03 pm
Location: Atlanta, Georgia
Contact:

Postby Lowell » Sun May 25, 2008 4:22 am

Well believe it or not, my latest file structure for my new update for Florida Gold...fixed the game. :shock: I was trying to figure out a way to where players of my mods for that game, wouldn't have to copy/paste the new goods, industries, trains and such I made for the game. So I made up a single file system for scenarios that uses some of the games "global" files inside the maps I made. It became a self contained game map. New items that are made no longer have to be "added" to a players game, they are built-in inside the maps files. Well, it also made the game stable and no more crashes.

So...buy the game and load my maps... :D 8)

Now that that game and mod run solid, I am returning to blender and the models I need for this game.
revcompgeek+
level1
level1
Posts: 11
Joined: Sat Oct 13, 2007 1:57 am

Postby revcompgeek+ » Tue Aug 05, 2008 8:47 pm

Is anyone still interested in Blender the import script? I have a bit of time that I can use to fix it if it is wanted/needed.
User avatar
The GoldFish
level5
level5
Posts: 3961
Joined: Fri Mar 01, 2002 9:01 pm
Location: Bowl / South UK
Contact:

Postby The GoldFish » Tue Aug 05, 2008 11:42 pm

There might be some relavence to Multiwinia (IV's new game) in finishing this off, so any progress would be positive.

Darwinia is pretty dead right now though...
-- The GoldFish - member of former GIT and commander in chief of GALLAHAD. You could have done something, but it's been fixed. The end. Also, play bestgameever!
User avatar
briceman2
level2
level2
Posts: 123
Joined: Wed Dec 12, 2007 4:30 am

Postby briceman2 » Wed Aug 06, 2008 1:15 am

Darwinia isn't 100% dead, but I guess splitting hairs is for lawyers.

The exporter is still very relevant IMHO. The easier it is to use, the more people will hack the shapes in Multiwinia, which I expect to be identical format to Darwinia (it's the same engine). There might even be a resurgence of Darwinia on the heels of Multiwina...

I have used the Blender export script extensively for a mod I may or may not ever finish. The exporter as it stands is pretty good. These are the faults that come to mind off the top of my head. If you're serious about tinkering with blender and pythin and think this would be a cool/neat/etc. script to hack on, let me know and I can give you some more detailed ideas and feedback.

1) The biggest shortcoming of the exporter is that it doesn't apply the object scalings. It does apply object rotation and offsets.

2) Second biggest (or biggest depending on your POV) prob is that the exporter is DOG SLOW! for non-trivial meshes. I am almost certain this is because PaladinofKaos is calling through the blender API for every little number. I think he's looping through the mesh data in python land where this costs most. There are blender wiki and other infos about how to optimize exporters for speed -- I might have linked several somewhere in this thread. Basically you slurp the entire mesh over at once, or you apply matrix ops to the entire mesh via the blender API instead of applying the matrix transforms point by point which is what I think is being done now.

3) Minor improvement: right now empties are used as placeholders for shape file Markers. Their exported names come from their object name. But Blender has a short name field and several of darwinia's Markers have long names. So it would be good to prepend the text "Marker" to the empty's exported name instead of having to type "Marker" into the name field with the rest of the name. I've hacked this into my personal copy of the exporter, but I'm not a python OO guy, so I probably made Guido spit in my general direction.

4) It would be nice if the exporter converted quads to tris and generally fixed normals (optionally) on the fly. Right now quads export with one tri missing.

5) pre 2.46 blenders throw an exception when the exporter tries to export a mesh with no defined vertex colors. For some reason this isn't a prob in 2.46 -- possibly it assigns generic data? Anyhow, for compatability it would be nice to throw a dialog about the error in earlier blenders -- the python error only shows up in the terminal if you run blender from a command line -- not friendly!

Importing existing shapes is a bit tricky because some shapes use triangle lists and others use triangle strips. I think TGF and I got most of the details down somewhere in this thread and elsewhere. If you decide to tackle the importer, I can give you links to some relevant specs from the OpenGL spec -- like the alternating winding of triangles in OpenGL triangle strips.

The ultimate grail for the exporter would be to code/link the ability to export triangle strips instead of triangle lists. This is a computationally hard problem, but can be approximated several ways if you don't need the optimum stripping of the mesh. There are some open source libraries which compute strips, but the most promising avenue would be one of the other blender exporters. I can't remember the format riight now, but it is a popular game format, and the blender sxporter has a python triangle stripping routine. I couldn't trace it easily enough to cut and paste it into the current exporter, but it should be possible (but maybe two dog slow?).

I'm sure that's enough to get you going! ;) Happy hacking!
revcompgeek+
level1
level1
Posts: 11
Joined: Sat Oct 13, 2007 1:57 am

Postby revcompgeek+ » Wed Aug 06, 2008 7:05 am

Wow, thanks for your detailed reply. I know about Multiwinia and I can't wait to play it, but it didn't occur to me that it would be using the exact same model format (or similar) as Darwinia. This gives me even more reason to work on both the exporter and the importer.

The first programming language I learned (of many) was Python, so I know it pretty well. I started playing with Blender a while ago and I am fairly good with it, but not as good as I would like to be. Unfortunately, my skill is with programming, so I doubt I will become a really good modeler, but I understand it enough to develop and test an importer/exporter. I am glad that you are telling me what needs to be fixed, because without feedback I don't see much point in continuing.

1) Applying object scalings should be no problem.

2) If you can send me those links to Blender pages/posts about how to increase the speed of exporters/importers I will do what I can to make them faster. I understand your need for speed (no pun intended :D ) because I use a few year old computer where speed doesn't come easily.

3) That will be very easy.

4) Converting quads to triangles should be very easy also. I think Blender can do that automatically so I should be able to get it to convert a temporary clone of the object(s) through the script into all triangles. Blender can also fix normals for you so this should also be no problem.

5) I haven't looked at the exporter recently but I recall that it was trying to read the vertex colors from the mesh object without checking if there actually are vertex colors to read. This could very likely throw an exception but should be easy to fix.

I own a copy of the OpenGL "Redbook" and have looked through it. I have also studied the way OpenGL works in my attempts to make a game engine in D. Importing triangle strips will be no problem (already done??) because if you have a strip of vertices in a triangle strip labeled ABCDEF, all you have to do is import the triangles ABC, DCB, CDE, and FED. I think this exact point was discussed in either this thread or somewhere else in the Darwinia forums.

Exporting triangle strips might be a problem. I think I remember looking at this exact problem at some point and I seem to remember that Blender had some support for exporting triangle strips built in, but I might be wrong. I may be just thinking of the exporter you mentioned. If you remember what format exports triangle strips that would be very helpful.


Any more details or links you can give me would be extremely helpful. I do know Python but I know the Blender API very little. I am going to have to spend some time reading the Blender wiki on any relevant topics. Thanks for the help. :)
User avatar
briceman2
level2
level2
Posts: 123
Joined: Wed Dec 12, 2007 4:30 am

Postby briceman2 » Wed Aug 06, 2008 6:07 pm

revcompgeek+ wrote:... :)

Excellent!!

Yeah, Multiwinia is just a modified Darwinia under the hood -- kinda what they wanted to make in the first place, but for lack of money, time, etc. So the shape files should be 100% the same. Imagine being able to make your own "trophy" shapes for the DGs to fight over... that's what people will be wanting most I think. I think TGF is in the beta group, and I expect she would say something non-NDAable if this were'nt the case. She pays attention to details like that.

So here's a couple of links to start. Let me know if you have trrouble finding more. The blender community is pretty good, with lits of wiki and other stuff. The only prob is it tends to be poorly organized, so I usually let google navigate. BlenderArtists.org is a very active forum with lots of very script savvy people -- post your API Qs there and I'm sure you'll get plenty of help.


http://en.wikibooks.org/wiki/Blender_3D ... n/Optimize
I'm pretty sure this is a bit out of date, but here's the relevant bits about doing math on the blender side of the API.

Getting Mesh data (Exporting Only)

Meshes are not just thin wrappers like most of the other Types in Blender so you want to avoid meshObject.getData() and meshObject.data as much as possible, its best practice only calling each mesh data once.

To get the name of the data the object references do not use ob.getData().name simply to get the name of the object. Instead use obj.getData(1) ... meaning obj.getData(1=name_only) this is nice because it works for all data types, its just that

Note, recently (as of 15/10/05) the addition of the Mesh module (a thin wrapper around Blenders mesh data) means that you can do a meshObject.getData(mesh=1) without the problem NMesh has, however this is new and doesn't support all the NMesh functions.

Use new python functionality mesh.transform() (Exporting Only)

As of Blender 2.37 nmesh.transform(ob.matrix) can be used to transform an NMesh by a 4x4 transformation matrix.
On my system it is over 100 times faster than transforming each vert's location and normal by a matrix within python. Though the overall speed gained by using this in my obj exporter was about %5.

make sure that if you are exporting vertex normals add a 1,
mesh.transfrom(matrix, recalc_normals=1) This avoids un-needed vertex normal transforming.


http://www.garagegames.com/blogs/35183/12244
This is the DTS exporter (Torque engine) which does triangle strips in python. I'm pretty sure the code is GPL'd so you can lift the stripping stuff once you figure out what the hell he's doing with his feed data (which I couldn't).

Added a new "Geometry Type" section to the general tab to replace the old "triangle strip" section. New buttons allow the user to choose between exporting single triangles, triangle lists, and triangle strips. Defaults to single triangles.


For triangle strips there is also the VTK library. Search for "VTK" and "vtkpython". I've used vtkpythin to transform triangle lists to strips for shapes I've made in blender -- using a perl hack to run the batch ops. It works great, but is a binary lib. Maybe a good choice if you can cleanly interface -- it's fast! But of course this would force export/import users to DL & install another package... I don't think the trophy shapes in MW will be so complex that a python stripper will cough and die for more than a few minutes. No prob as long as there's some progress bar or wait cursor, etc.

There's also a legitimate question of whether strips are faster than lists these days. Supposedly modern cards have deep enough vert caches that lists are almost as good as strips. But Darwinia was coded before Chris was really experienced in OpenGL, so there may be bandwidth / traffic issues with the engine implementation. If stripping looks to be a bear, or if you want to justify the effort up front, you might try some benchmarks with large complex shapes both ways. The "globalworld" shape files could be used as static shapes (replicated many times on a map until FPS starts to show a hit). In the original game data two are lists and the thrid is a strip for unknown reasons.

EDIT: you could also ask one of the beta testers if all the shape files are stripped (or still mixed strips and tris). If they haven't moved everything to strips, then it may not be worth the effort to export them. But that may just be because of time constraints for the Gold master release, with stripped shapes coming with a patch, etc. etc. Hard to tell w/o coming from the horse's mouth. Chris doesn't answer PMs recently, but you could try asking Neothermic -- he seems to be on the inside or have inside info -- are strips worth it? Or IcePick -- he's an IV employee.


If you haven't upgraded to 2.46, do it! it's awesome. A HUGE upgrade to everything blender.

Thanks for your enthusiasm! Let me know if I can be of any help along the way...
Last edited by briceman2 on Wed Aug 06, 2008 8:16 pm, edited 3 times in total.
Da Red Baron 55
level0
Posts: 3
Joined: Sat May 24, 2008 9:37 pm
Location: Atlanta, Georgia

Postby Da Red Baron 55 » Wed Aug 06, 2008 7:07 pm

Lowell, I see that sam stuff on that hookedgamers forum. Where did that come from, it kind of looks like your type of map?
User avatar
briceman2
level2
level2
Posts: 123
Joined: Wed Dec 12, 2007 4:30 am

Postby briceman2 » Thu Aug 07, 2008 1:14 pm

briceman2 wrote:
revcompgeek+ wrote:... :)

Excellent!!


...a few good places to find blender-python API docs -- it wasn't as easy as I thought it should be to find these pages, so maybe these links will help you:

http://wiki.blender.org/index.php/Relea ... Python_API
http://www.blender.org/documentation/246PythonDoc/
http://www.zoo-logique.org/3D.Blender/s ... ython/API/

The last one is a frames version of the API reference -- maybe easier to navigate?

.
PaladinOfKaos
level1
level1
Posts: 40
Joined: Mon May 07, 2007 4:35 pm

Postby PaladinOfKaos » Fri Feb 20, 2009 7:24 pm

Hi everyone! Sorry I vanished from the face of the earth like that. There were some personal issues, then other projects caught my interest.

There's been a lot of constructive feedback on the exporter, and I'm willing to poke at it a bit more, if people are still interested (and if I can figure out how the code works - I haven't looked at it in way too long).

Is the SHP format still the same in Multiwinia? I don't have it yet, so I can't check that on my own. If it's different, I can modify the script (that is, if someone else hasn't done so already).
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sat Feb 21, 2009 1:07 am

PaladinOfKaos wrote:Is the SHP format still the same in Multiwinia?

Yes.

xander

Return to “Mod Projects”

Who is online

Users browsing this forum: No registered users and 7 guests