Profile image

.OBJ to SimplePlanes XML script

10.1k LaserShark  8.8 years ago

Alright, I've been promising to share my script for making those spheres/suzanne heads that I've been working on for the past week. The script is still partially broken, it can't handle vertical polygons at right angles, but I'm going to take a small break from working on it, so I decided it's time to hand it over to all y'all.
Oh yeah, the comments are absolute rubbish as well, they were mostly there for me, I wasn't planning on distributing this thing at first, and I was too lazy to do anything decent with them.

Guide:

  1. Install Python 3.x

  2. Create a new .py file and paste this code:(Use the 'Copy to Clipboard button in the upper-right corner)

    script file

  3. Place this new .py file in the folder that SimplePlanes stores the airplanes, some User/Appdata/LocalLow/Jundroo/SimplePlanes/AirCraftDesigns directory.

  4. This is the hard part, go into Blender and create a 3D file. The script works best if you only use exact squares, disconnected. Like this:

    image
    alt text

  5. Export your new 3D file as a .OBJ file into your SimplePlanes directory where you keep all your planes mentioned above. IMPORTANT: The file must be named "toconvert.obj", no quotation marks. ALSO IMPORTANT: By default, when you export a .OBJ file in Blender, it is set to "Y-up" in the left panel on export. Switch that to "Z-up".

  6. Double click the script. If you did everything right, the script should spew a pile of numbers on your screen, then say "done". Press Enter to close the script, it's important to close the script before loading it in SimplePlanes.

  7. Go into SimplePlanes. There should be a plane named "NewPlane". Load that. If some of the faces are skewed funny, it's not because you did anything wrong, it's because my script isn't the most functional thing ever. Sorry about that.

  8. Enjoy your new "plane".

  • Log in to leave a comment
  • Profile image

    what happened to the script link?

    1.4 years ago
  • Profile image
    5,042 Gluck

    I discovered this far too late ;-;

    4.0 years ago
  • Profile image
    7,047 Frenchyfry

    Hey do you still have the script file? the download link has broke :(

    4.4 years ago
  • Profile image

    Please help me

    Traceback (most recent call last):
    File "C:\Users\Aspire Z3451\AppData\LocalLow\Jundroo\SimplePlanes\AircraftDesigns\vt.py", line 32, in <module>
    item = eval(item)
    File "<string>", line 1, in <module>
    NameError: name 'vt' is not defined

    6.3 years ago
  • Profile image
    10.1k LaserShark

    @Nickasaurus Probably not, position would be easy, rotation, not so much. The way I would try to tackle that problem is perform two 2D rotations on all the vertices, one from the XY plane and one from the XZ plane using 0,0,0 as the origin. Why would you want to convert a plane to a .OBJ though?

    8.7 years ago
  • Profile image
    37.7k Decrepit

    @LaserShark well SP stores all of the meshes in a file (I'll find it again in a second if you want) but if you could just get the rotation and position knocked out it wouldn't be hard to call on those meshes.

    8.7 years ago
  • Profile image
    10.1k LaserShark

    @Nickasaurus Not directly, the way .OBJ files are stored is essentially a list of vectors, (34,46,43),(34,41,75),(34,86,32),(97,433,75), etc, and .XML is stored as a list of parts and their attributes. Like < name="engine1" size="1,1,1" rotation= "45,0,0">. You would need to convert each object to its mesh form, apply the proper transformations and then export that to .OBJ. It's possible, but not without quite a lot of doing.

    8.7 years ago
  • Profile image
    37.7k Decrepit

    Is there a way to use a mesh exporter to convert .xml to .obj? I've been trying but as everyone knows suck at programming. (except some JS)

    8.7 years ago
  • Profile image

    @LaserShark There were graphs before computer games, and graphs used Y as vertical.


    You're welcome :)

    I don't think you can color text unfortunately :/

    @Skua put together some formatting information here

    +1 8.8 years ago
  • Profile image
    10.1k LaserShark

    @HellFireKoder The first computer games were tic-tac-toe and asteroids, both are top-down, which would make Z as up.

    Thanks for the tip, I don't know any of those cool tricks yet. Is there a way to color text?

    8.8 years ago
  • Profile image

    @LaserShark "Dark side" wasn't a thing until the Jedi were a thing, I think?

    And since Y-up was around first, that would imply that Z-up is the dark side!


    ooc: you can edit the main post to make those links clickable by making the links like this [link text](URL)

    8.8 years ago
  • Profile image
    10.1k LaserShark

    @HellFireKoder Y-up is the dark side, join us good Jedi on the Z-up side!

    8.8 years ago
  • Profile image

    @LaserShark that's why I said

    In 2D games, with an up and down, Y was always up and down!

    And since 2D platformers became standard before 3D was even really a thing, the question is why would 3D modelling programs do it that way!?!?!

    Also as I said it's the standard for game engines (and games I guess) to use y as vertical these days, so people just use that...

    8.8 years ago
  • Profile image
    10.1k LaserShark

    @HellFireKoder Depends on the game perspective, if you made a platformer, Y was up, if you made a lot of top-down space shooter games like I did, X and Y being a flat plane just makes more sense. Just about every 3D modeling software uses Z as up, so, why don't people program their games that way?

    8.8 years ago
  • Profile image

    turns out y is swapped with z in this game, why do developers do that!? Just make Z up and down already! We need to kill Yup as a thing that exists.

    In 2D games, with an up and down, Y was always up and down!
    Also, Unity does it, not the devs... and so do TONS games, like Minecraft, Skyrim, any game made in Unity or Unreal Engine... I think we should just get rid of Z as vertical if anything, all the big engines do Y vertical these days, which makes me question why modeling programs don't.


    Regardless of that comment, I'm gonna take a look at this, good job!


    Edit: wait what? No Y is vertical, I guess it converts stuff itself...

    8.8 years ago
  • Profile image
    10.1k LaserShark

    @Yottabyte1024 The script doesn't have any operating system specific functions, so if you know where the planes are stored, it shouldn't be too hard to get it working on another operating system. I think anyways, I only use Windows so I don't know for sure.

    8.8 years ago