Alternativa3d Exporter update and move to github

Hey folks, for those of you who follow my 3d work with and the flash alternativa3d library you will be glad to hear that I’ve updated my blender alternativa3d importer/exporter to work with version 8.27.0, Along with this update I have moved the project over to github. Why github? it’s a preference thing it feels more comfortable, its easy for others to fork the code and do their own thing with it and I generally find it more intuitive browsing the source code. The new version allows you to export 3d models that have textures or diffuse colours to actionscript alternativa3d compatible classes. I’ve created a quick demo just to show what it can do. In the demo i’ve created 3 objects a cube, suzanne the monkey and lastly the torus. The cube is just a simple pink diffuse material applied to all faces. Suzanne the monkey is an example of uv wrapping and a single image texture. The last example is of applying multiple diffuse materials to faces, multiple uv image textures also work like this. exporter The code uses the geometry class as seen in previous version but uses the different streams for position coordinates, normals, uvs, indices and tangents. I’m still not sure how to export the tangents from blender so this doesn’t actually work right now but if you are using version 8.27.0 you can call the calculateTangents() function. Click here to view the demo Download the demo files including blender sourcefile

Downloads

Comments

  • avatar-chris
    # Chris

    It’s really cool to see someone work on a blender exporter! I wish I could make my own blender scripts. Think you could give me some advise on how to get started scripting in python / blender? Whats your workspace when you coded this?

    I’ll appreciate any help!

  • avatar-davidejones
    # davidejones

    Thanks!

    Well I didn’t know python or how to write for blender before but I just taught myself from looking at the other importers/exporters that come with blender, using the blender api and a lot of trial and error and googling!

    I only just recently discovered you can change the workspace in blender, change it to scripting and you can write your script in one window see the 3d model in another and have a python console to try commands and another pane that shows what python commands are running when you do things in blender.

    you might want to checkout this site which has some great blender video tutorials that may help http://cgcookie.com/blender/category/tutorials/scripting/

    What kind of script do you want to make?

  • avatar-chris
    # Chris

    Thanks for replying!

    I actually wanted to try to make an exporter myself, but looking at how much code it took for yours, I don’t know. I wanted to try to make a very compressed file format… Somehow. Does it even matter if you compress a string of data using zlib when a swf gets compressed anyway? Does it make a difference?

    Also I noticed in your exported AS3 files your indices were just counting up, and not actually doing what they’re supposed to do. Is this because you don’t know how to do it properly? I did the same thing when I started making my first parser, but I eventually figured it out. if you’d like to reduce the file size without having to figure all of the indexing out I recommend you do this…

    var indicesCount:int = int(vertices.length/3); var ind:Vector. = new Vector.(indicesCount); for(var i:int = 0;i<(vertices.length/3);i+=1){ ind[i] = i; }

    That way you don�t waste all of that perfectly good space!

    If I figure out an easy way to compress it and I can�t bother to mess with blenders scripting I�ll tell you about it and you can see if you�ll be able to implement it.

    Alright I think I�ve done enough talking! I�ll check out those tutorials. (PS. I stayed up all night, so thats probably the reason I�m rambling)

  • avatar-davidejones
    # davidejones

    No problem.

    Oh my code is a mess, I’ve got left over code from old version, experimental stuff and commented out things. I’ve just got it to a place that works, when i’ve got things to import and export .a3d files i’ll try refactor it to something neater. It didn’t start off this big it just expanded as i learnt more.

    For compression it depends what you are doing with the data, if you have a swf reading in the compressed data string from a file that works well. If you are talking about embedding it in a swf, I’m not sure what compression swf uses but if its simlar to zlib i doubt it will make much difference? i’m no expert though.

    I had 3 different versions of outputing the indices which was working..but with the other data the vertices, normals and uvs and applying materials to the surfaces it wasn’t giving me the results i wanted. You can see what i mean here http://forum.alternativaplatform.com/posts/list/9072.page, i think it was the uv coords that wasn’t right and i had a hard time correcting this.

    So instead i switched all my code to something else based on an example i found on another site and this worked. The indices are correct just they are being output differently to before thats all. Thanks for the code snippet, don’t worry i’ll tidy up mycode at somepoint and the output code. My priority was just making it work for now, took me a while to wrap my head around the version 8 geometry class and stuff.

    Hope you find it useful, i’d love to see any thing that can help compress it or if you make anything youself. Drop me an email if you need some assistance or have questions about making a blender addon i’ll try help as best i can.

  • avatar-chris
    # Chris

    Yeah I don’t think zLib compression is worth it… at all.

    Flash does a pretty good job at compressing. I guess the only thing you can do is reduce the amount of data you have to compress. Comparing your file size with others (.obj, .3ds) that I published to SWF, there wasn’t much of a difference.

    Putting all of that aside properly indexing the vertices reduced the size by quite a bit. There were about 135 of the same number (which was repeated with a bunch of vertices).

    I’m sure I’m telling you a lot of things you already know, but I’ve just been interested.

    I would use this, but without the indexing working how it should, I’m pretty sure it slows down flash a little bit. I hope you keep working on it!

  • avatar-davidejones
    # davidejones

    Well it could still save some space if it literally just saved the verts,uvs,indices data to a file and compressed it with zlib. The normals and tangents can be calculated from that data in actionscript v8.27.0 and it would still be smaller than .3ds and .obj as it doesn’t contain any other scene data. Maybe i’ll give it a try just to see.

    It could save to a .dat and make a parserDAT actionscript file or something that just reads the data to the geometry. Almost like a simplified .a3d file.

    Yea i agree there can be some reducing of the data like indices, the only problem is i had no luck in reducing it and having a functioning class. For example you must have same amount of data for different vertex attributes. i.e. for 8 vertices it is 83 positions, 82 uvs, 8*4 tangents etc. i probably wasn’t doing it right but shortening gave me errors or output a mesh with weird mapping. I’m still a bit of a noob to this 3d stuff but i’m learning more all the time. If you figure something out i’d be glad to impliment it.

    Anyway i probably won’t be changing that anytime soon, i’m gonna try get .a3d files to work then tidy things up.

    I’ll keep working on it as and when I have time!

  • avatar-chris
    # Chris

    Well I made my own file converter that would convert .obj to a smaller .as file, but I hated having to open up my air app just convert a file. I liked just exporting from blender to .as, so nothing was external.

    Yeah I agree dealing with all of these numbers can be confusing at times.

    Also your steam picture is the old one… I don’t like you sticking your tongue out at me. :( Alright I’m going to bed now… Thanks for the chat. :P

  • avatar-davidejones
    # davidejones

    hmm your comments have inspired me to try some compression things, to reduce the output .as file. Its going pretty well. Hey if you feel like sharing i’d love to see the air app and its source code.

    Haha nope i’m not changing my steam avatar!

  • avatar-chris
    # Chris

    I was searching for it, but apparently it was lost at some point. I did make a .obj parser just now though, and I’ll probably use it to remake the converter some other time. Right now it only gets the geometry side of things, and no material stuff. It probably has some minor bugs like the uv positions might be flipped, or something… Other than that I think it works.

    I’m not sure if you’re interested in the .obj parser, but if you are just tell me where to send it, and it’s all yours!

  • avatar-kenny-lerma
    # Kenny Lerma
    Hey, great work on this exporter for a3d. Just curious if you were able to the get animations to export correctly. I see you have attempted this after looking at the script. Any progress on this?
  • avatar-davidejones
    # davidejones

    I had started work on the animations but didn’t get too far.

    I tried importing animations but they wouldn’t show correctly, I couldn’t seem to get the bones in the right position at all.

    I’m gonna come back to it soon, I realise its probably the most important part of the exporter.

  • avatar-kenny-lerma
    # Kenny Lerma
    I’m taking a stab at it as I’m hoping to eventually use blender for all of my modeling for use with Alternativa3d. If I make any progress, I’ll let you know.
  • avatar-davidejones
    # davidejones
    cool cool yea let me know how it goes! I’d love to see any projects you use it with too!

Comments are currently closed