blender 2.5 addon export alternativa3d 7.6.0

David Jones
@david3jones
avatar-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. 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

Downloads

Comments

  • avatar-chris
    # Chris
    I just get spammed with undefined method addVertex and addFace… Im guessing I did something wrong? Can you help? D:
  • avatar-chris
    # 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

  • avatar-davidejones
    # davidejones
    ah glad you got it working and thanks for the bug report i will try and fix it and reupload
    • avatar-chris
      # 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.

  • avatar-john
    # 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?

  • avatar-davidejones
    # davidejones

    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?

    • avatar-john
      # 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

  • avatar-davidejones
    # davidejones

    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 :)

  • avatar-john
    # John
    Can’t wait to see it. :P
  • avatar-quentin
    # 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 :)

    • avatar-davidejones
      # davidejones
      Most of the code you need is above. Its probably best if you try your own 3d model and export it.
  • avatar-den
    # Den
    A nice addition to Flash, but I can not run the code in CS5. Could you lay out the source?!
  • avatar-davidejones
    # davidejones

    Hey guys checkout the newer blog post i made here http://www.limeydesigns.com/2011/01/alternativa-blender-plugin-update-2-56/

    Which has the updated version for blender 2.56 and also includes the above example files.

  • avatar-shawn
    # Shawn

    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

  • avatar-davidejones
    # davidejones

    This is quite an old post now, you might want to check out this latest one where i explain i’ve moved development to google code.

    http://davidejones.com/blog/alternativa3d/blender-alternativa-addon/

    When you install an addon you can just go to file->user preferences->install addon and then browse to the python file io_alternativa3d_tools.py . Then once thats done it should appear in the list and you can tick the box to enable it.

  • avatar-hermetic
    # 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?
  • avatar-davidejones
    # davidejones
    It should work, 3ds should definitely work. Are you getting any errors?

Comments are currently closed