blender 2.5 addon export alternativa3d 7.6.0

Posted by davidejones

The past week or so i’ve been working on a addon for blender 2.55. With the removal of the meshutility in alternativa 7 i decided to create this with the purpose of exporting my 3d model to actionscript rather than loading a .3ds or .dae file.

Its my first outing using python so it probably isn’t the best programming and no doubt there are bugs but it does have some basic functionality and appears to work ok for me so far.

You can download the addon below, all you need to do is open blender and click on File -> User Preferences and then click on Add ons and click the install addon button, select the file from the download and then make sure its enabled.

Download blender addon export alternativa v1

Once enabled you will see it under the export menu, here is a quick example of me using this on a uvmapped cube.

Once i have my cube and the addon installed i select the cube and go to File -> Export -> Alternativa3D class (.as) and choose a location to save it.

Once you are at the export screen there are some options in the bottom left, you can select the alternativa version 7.6.0 or 7.5.1, the difference being that the mesh class in 7.5 uses a geometry class where as in 7.6 this has been depreciated. There is also an option for using either flex or flash, this will simply either output using the embed tags or using standard variables and requiring the user to embed the images in the fla.

Here is the code that was generated for me when selecting flex and 7.6.0

//Alternativa3D Class Export For Blender 2.55 and above
//Plugin Author: Invisible Man, http://www.davidejones.com & http://www.limeydesigns.com
package {
import alternativa.engine3d.objects.Mesh;
import alternativa.engine3d.materials.FillMaterial;
import alternativa.engine3d.materials.TextureMaterial;
import alternativa.engine3d.core.Vertex;
import __AS3__.vec.Vector;
import flash.display.Bitmap;
public class mybox extends Mesh {
[Embed(source="263.jpg")] private static const bmp263:Class;
private static const material0:TextureMaterial = new TextureMaterial(new bmp263().bitmapData, true, true);
public function mybox() {
addFace(Vector.([
addVertex(-17.288137, 8.622022, 5.968616, 0.990069, 0.986388),
addVertex(-17.288137, -3.756246, 5.968616, 0.990069, 2.013613),
addVertex(-5.512352, -3.756246, 5.968616, 0.009931, 2.013612),
]),material0);
addFace(Vector.([
addVertex(-5.512352, 8.622022, 5.968616, 0.009931, 0.986388),
addVertex(-17.288137, 8.622022, 5.968616, 0.990069, 0.986388),
addVertex(-5.512352, -3.756246, 5.968616, 0.009931, 2.013612),
]),material0);
addFace(Vector.([
addVertex(-5.512352, 8.622022, -5.916712, 0.990069, 0.986388),
addVertex(-5.512352, -3.756246, -5.916712, 0.990069, 2.013612),
addVertex(-17.288137, 8.622022, -5.916712, 0.009931, 0.986388),
]),material0);
addFace(Vector.([
addVertex(-17.288137, -3.756246, -5.916712, 0.009931, 2.013613),
addVertex(-17.288137, 8.622022, -5.916712, 0.009931, 0.986388),
addVertex(-5.512352, -3.756246, -5.916712, 0.990069, 2.013612),
]),material0);
addFace(Vector.([
addVertex(-5.512352, 8.622022, 5.968616, 0.990069, 1.005180),
addVertex(-5.512352, 8.622022, -5.916712, 0.990069, 1.994820),
addVertex(-17.288137, 8.622022, 5.968616, 0.009931, 1.005180),
]),material0);
addFace(Vector.([
addVertex(-17.288137, 8.622022, -5.916712, 0.009931, 1.994820),
addVertex(-17.288137, 8.622022, 5.968616, 0.009931, 1.005180),
addVertex(-5.512352, 8.622022, -5.916712, 0.990069, 1.994820),
]),material0);
addFace(Vector.([
addVertex(-5.512352, -3.756246, 5.968616, 1.013612, 1.005180),
addVertex(-5.512352, -3.756246, -5.916712, 1.013612, 1.994820),
addVertex(-5.512352, 8.622022, 5.968616, -0.013612, 1.005180),
]),material0);
addFace(Vector.([
addVertex(-5.512352, 8.622022, -5.916712, -0.013612, 1.994820),
addVertex(-5.512352, 8.622022, 5.968616, -0.013612, 1.005180),
addVertex(-5.512352, -3.756246, -5.916712, 1.013612, 1.994820),
]),material0);
addFace(Vector.([
addVertex(-17.288137, -3.756246, 5.968616, 0.990069, 1.005180),
addVertex(-17.288137, -3.756246, -5.916712, 0.990069, 1.994820),
addVertex(-5.512352, -3.756246, 5.968616, 0.009931, 1.005180),
]),material0);
addFace(Vector.([
addVertex(-5.512352, -3.756246, -5.916712, 0.009931, 1.994820),
addVertex(-5.512352, -3.756246, 5.968616, 0.009931, 1.005180),
addVertex(-17.288137, -3.756246, -5.916712, 0.990069, 1.994820),
]),material0);
addFace(Vector.([
addVertex(-17.288137, 8.622022, 5.968616, 1.013612, 1.005180),
addVertex(-17.288137, 8.622022, -5.916712, 1.013612, 1.994820),
addVertex(-17.288137, -3.756246, 5.968616, -0.013612, 1.005180),
]),material0);
addFace(Vector.([
addVertex(-17.288137, -3.756246, -5.916712, -0.013612, 1.994820),
addVertex(-17.288137, -3.756246, 5.968616, -0.013612, 1.005180),
addVertex(-17.288137, 8.622022, -5.916712, 1.013612, 1.994820),
]),material0);
}
}
}

Also when making use of the generated class i used the following

var bx:mybox = new mybox();
bx.calculateNormals(true);
bx.calculateBounds();
container.addChild(bx);

Here is the final swf output

Trackback URL for this post: http://davidejones.com/blog/110-blender-2-5-addon-export-alternativa3d-7-6-0/trackback/

Being Sociable...

  • If you like this article then please share it on your favourite social network and follow me on twitter for the latest updates

17 Responses to blender 2.5 addon export alternativa3d 7.6.0

Chris

Ok, I fixed it all.
But when I export the blender model as an actionscript file with the settings flash 7.6 selected models it has an error in the AS file!

private var bmpgrassCubeTexture:Bitmap = new new Bitmap(new bdgrassCubeTexture(0,0));
private var material0:TextureMaterial = new TextureMaterial(bmpgrassCubeTexture.bitmapData, true, true);

Theres two news before ” Bitmap(new bdgrassCubeTexture(0,0)); “.
Thanks :D

    Chris

    Glad to see a reply!
    If you reupload it put some message saying you did, and I’ll get it again, because it was pretty useful!

    And you seem pretty good with this whole Alternativa3D thing.
    Maybe you could create an example of simple REAL collision detection? I’d love that. :D

    Maybe a simple object falling on a mesh.

John

Since you seem to use blender I thought you might be able to help me!
I created a bone animation using Blender, but when exporting it to .dae format and loading it into flash using Alternativa, the legs of the character (the bone animation ) goes CRAZY.

Do you know why it does this?

hi John unfortunately i haven’t tried using collada files or bones/animations yet so i dont really know why that is happening.

I expect you have already tried but you can always check out the alternativa3d forums for help?

    John

    Yeah I have tried consulting the users on the Alternativa forum, but it seems very inactive.

    Do you only use blender for your 3D work with flash?

    Maybe you could give bone animation a try yourself, cause if you’re using Blender, and if you try animating later expecting it to work it might be a let down.

    Like it was for me. :(

    Your blog posts helped me, thanks. :P

Yea animation is something i want to try just haven’t had a chance yet. When i do get around to it i’ll make a blog post on what i did maybe it will help you.

I’m still learning too, i’m glad my posts helped you :)

Quentin

Hi,
I’m french and i don’t speak very well english, but i should your sources please :
box.as, mybox.as, main.as etc

Thanks you :)

Having a bit of an issue here. I have downloaded the script and Installed it as an add-on but it doesn’t appear in the list therefore I cannot enable it. I went and checked the Addon folder and it is there. Would you happen to know what the issue is.

I am using Blender version 2.57.1

hermetic

Hi,
old thread… But could it be that loading 3ds, Collada, … dont works in linux?
->For me no examples work who try to load other formats than A3D.
Any Idea?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>