Posts Tagged papervision

gen-hx-classes papervision3d

After reading [haXe] Fisix + haXe = FisaXe? hehe, I started to wonder if I couldn’t use a similar trick to make papervision3d.

Though I was not able to get a pure haxe solution, I did get a happy ending

Updating papervision3d

ActionScript3 pointed out that the version of papervision3d he ported was old and that it would probably be worthwhile to grab a newer version

I thought about checking out a copy from SVN, but I know the sort of stuff you tend to get from checking out from the head… 😛

So I decided to go with what looked to the the last official release, version 1.5 from

% mkdir /home/brian/tmp/pv3d
% cd /home/brian/tmp/pv3d
% unzip
% ls PV3D_1_5/src
com  fl  livePreview  org


flex builder for linux

Word on the street is that the A3 compiler from flash is still faster than haxe.

So… I went to and grabbed a copy of the flex builder alpha for linux.

The install wanted an eclipse directory with a “configuration” subdirectory and barked at me… I’m not really an eclipse guy, so whatever. Maybe I will hook it up later…

Here is what it looked like:

% chmod 755 flexbuilder_linux_install_a3_033108.bin
% ./flexbuilder_linux_install_a3_033108.bin
% export PATH=${PATH}:${HOME}/data/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/
% which mxmlc

Sweet… now I can get that AS3 fanciness I keep hearing about!


This actually had me scratching my noggin… The original post had said:

mxmlc -include-libraries /AS3_src/Fisix/Bin/FisixEngine.swc -file-specs -output ./FisixLib.swf  -benchmark=true

Obvious is something I don’t have and I also don’t have a swc and I won’t bore you with how I came up with this bit of madness:

% cd /home/brian/tmp/pv3d
% mkdir tmp
% cd tmp
% find /home/brian/tmp/pv3d/PV3D_1_5/src -type f -name "*.as" >
% echo "package {" >
% cat | cut -f1 -d. | sed 's,.*src/,import ,;s,/,.,g;s,$,;,'  >>
% echo "public class Test {" >>
% cat  | cut -f1 -d. | sed 's,.*/,,;s,.*,public var tmp_& : &;,' >>
% echo "} }" >>

Of course that’s not exactly how I did it, but it was just as painful and used the same methodology.

So by now you are probably shaking your head and laffing, going “ok, bright-boy! now echo me up an swc file!”

Not nice…

Happily, I got some command line help from a guy I don’t know in Japan, so that I was able to hookup:

%  mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output Papervision3d.swf

Kabloom! It dumped out a bunch gobble-de-gook.

Luckily, yours-truly is an old hand at ignoring compiler errors… A little of ye olde clickety-clack… and I had version of that would compile.

I did it like this:

% grep PV3D_1_5/src mxmlc.errors.compiling.PV3D_1_5.txt | cut -f1 -d\( | sed 's,.*/,,;s,.as$,,' | sort -u | sed 's,^,tmp_,'
tmp_InteractiveWireframeMaterial Error: A file found in a source-path must have the same package structure 'livePreview', as the definition's package, 'fl.livepreview'.

Look, maw! I’m UNIX hackin’! I’m UNIX hackin’! Got that one odd-man-out…

Comment those lines out:

//public var tmp_CompositeTriangleCuller : CompositeTriangleCuller;
//public var tmp_DepthTriangleCuller : DepthTriangleCuller;
//public var tmp_InteractiveWireframeMaterial : InteractiveWireframeMaterial;
//public var tmp_PV3DColladaScene : PV3DColladaScene;
//public var tmp_Stars : Stars;
//public var tmp_LivePreviewParent : LivePreviewParent;

Next thing you know:

%  mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output Papervision3d.swf
Loading configuration file /home/brian/data/Adobe_Flex_Builder_Linux/sdks/3.0.0/frameworks/flex-config.xml
Papervision3d.swf (168851 bytes)

And now we know!

And knowing is half the battle…

Let’s fight on…


The next piece of good advice is that we can use

% haxe --gen-hx-classes Papervision3d.swf

Yeah… sure it spewed a bunch of madness, but let it!

It also generated a lot of good stuff!

% find hxclasses -name "*.hx" | wc -l

Kind of a lot of stuff.. the original library only had 85 .as files… hummm… thanks?

trying it on

% cp Papervision3d.swf /tmp
% cp -r hxclasses /tmp
%  cat TestHaxePv3d.hxml
-main TestHaxePv3d
-swf TestHaxePv3d.swf
-swf-version 9
-swf-lib /tmp/Papervision3d.swf
-cp /tmp/hxclasses
% haxe TestHaxePv3d.hxml
TestHaxePv3d.hx:19: characters 0-47 : Class not found : org.papervision3d.core.utils.FPSCounter

Which is actually ok… I reused my demo from before… clickety-clack…

% haxe TestHaxePv3d.hxml

Yup… it gacked up more “Unknown opcode 0x59” hairballs! but… lookit!

% ls *swf

Or better yet! Don’t bother!

Cuz it’s just a blank blue-ish screen!

Haha! It doesn’t really make me feel any better that Asger Ottar Alstrup got stuck at pretty much the same point…

When I asked him about it, he said he did get it to work:


Yes, I got it to work just fine. Just make a .as file referencing the classes you need, compile that to a papervision.swf file, then

haxe --gen-hx-classes papervision.swf

generates the classes, and everything works fine. Remember to add a "-cp" switch to point to the generated files, and link in the papervision.swf file using "-swf-lib". (I use swfmill to bundle a bunch of .swf's together to one .swf and then link that into the final .swf, but it also works if you just directly link in the papervision.swf file.)


So… I dunno

Bummer… I tried everything all over again trying to use the 2.0.1 version of mxmlc, but with the same result.

Silver Lining

Though I was originally hoping to be able to papervision3d via haxe, I finally did end up with a solution that works

% wget
% mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs -output exampleSpherePrimtive.swf

Sure… it’s actionscript, but yeah the compiler is proprietary, but … eh.. at least there is some way forward.

It just wasn’t the way I wanted… boo+hoo=moving on

Time to get my AS3-fancy on!

Comments (1)

pv3d_haxe as a haxelib

At the risk of overstepping, and with hopes the original author won’t become enraged, I published pv3d_haxe as a haxelib:

% haxelib search pv3d_haxe
1 projects found
% sudo haxelib install pv3d_haxe

I have placed the files and on googlepages if you’d rather…

You can try my (horrible) test program like so:

% wget
% unzip
% cd orig_testHaxePv3d
% rm *swf
% haxe TestHaxePv3d.hxml
% ls ${PWD}/*swf

Pull up the .swf file and viola… a really boring solid red cube!

Here are a few more boring things I “fixed”:

/usr/lib/haxe/lib/pv3d_haxe/1,0/org/papervision3d/core/geom/Face3D.hx:220: characters 9-16 : Local variable mapping used without being initialized
/usr/lib/haxe/lib/pv3d_haxe/1,0/org/papervision3d/materials/MaterialsList.hx:185: characters 23-30 : Local variable m used without being initialized
/usr/lib/haxe/lib/pv3d_haxe/1,0/org/papervision3d/objects/Sphere.hx:163: characters 14-18 : Local variable oVtx used without being initialized

I only mention them in passing in case someone takes on this project for real.

Hopefully this will make it a little easier to use original author‘s great work!

Comments (5)

Haxe + Papervision = Hot damn!



Do the math! I encourage you! Check my figures! Could it really be true?

A google search on haxe+papervision lead me to a mailing list link to HaXe版PaperVision3d, which made me think: yeah! (pronounced “yehah”, not “yee-ay”).

As they say in Finland: let’s get it on!

 % haxe pv3d.hxml 2>&1 | tee e
 org/papervision3d/objects/DisplayObject3D.hx:951: characters 14-18 : In Flash9, null can't be used as basic type Float

Oh, snappity-snapperoo! Wuh happen’d?!

I’m totally gunna use the source, Ben! Thx! You ℛ☉✖✘☮ℜ⚡!

 % vim $( grep -w characters e | cut -f1,2 -d: | sed 's,:, +,' )
 #### this is inside vim:
     private function getScale():Float
        if( this._scaleX == this._scaleY && this._scaleX == this._scaleZ )
            if( Papervision3D.usePERCENT ) return this._scaleX * 100.0;
            else return this._scaleX;
        else return null;   // <--- this is the line

So it’s kvetching about null for Float… whatever… I’ll just change it to be “0”… Changed that in 4-5 places and now the coolio-demo is happy: pv3d_haxe.swf

For some reason, that link is fark-tarded, from googoo, but if you download it and hit if from local it looks kinda like this, but spins like a dervish!

Sweet! This is going to be fun!

IE must be destroyed.

Comments (6)