Posts Tagged PV3D_1_5

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 Papervision3D_1_5.zip.

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

Cool…

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
/home/brian/data/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin//mxmlc

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

mxmlc

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

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

Obvious Test.as 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" > nice.as.txt
% echo "package {" > Test.as
% cat nice.as.txt | cut -f1 -d. | sed 's,.*src/,import ,;s,/,.,g;s,$,;,'  >> Test.as
% echo "public class Test {" >> Test.as
% cat nice.as.txt  | cut -f1 -d. | sed 's,.*/,,;s,.*,public var tmp_& : &;,' >> Test.as
% echo "} }" >> Test.as

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 Test.as -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 Test.as 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_CompositeTriangleCuller
tmp_DepthTriangleCuller
tmp_InteractiveWireframeMaterial
tmp_LivePreviewParent.as: Error: A file found in a source-path must have the same package structure 'livePreview', as the definition's package, 'fl.livepreview'.
tmp_PV3DColladaScene
tmp_Stars

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 Test.as -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…

gen-hx-classes

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
287

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
TestHaxePv3d.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:

Hi,

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

Regards,
Asger

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 http://www.andrestubbe.com/downloads/papervision3d/ExampleSpherePrimtive.as
% mxmlc -source-path ${HOME}/tmp/pv3d/PV3D_1_5/src -file-specs ExampleSpherePrimitive.as -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)