<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Andy Li’s Blog - Sandy3D</title><link href="https://blog.onthewings.net/" rel="alternate"></link><link href="http://feeds.feedburner.com/tag/sandy3d/feed/atom.xml" rel="self"></link><id>https://blog.onthewings.net/</id><updated>2010-03-18T07:39:00+08:00</updated><entry><title>Sandy3D, C++, Haxe</title><link href="https://blog.onthewings.net/2010/03/18/sandy3d-c-haxe/" rel="alternate"></link><published>2010-03-18T07:39:00+08:00</published><updated>2010-03-18T07:39:00+08:00</updated><author><name>Andy Li</name></author><id>tag:blog.onthewings.net,2010-03-18:/2010/03/18/sandy3d-c-haxe/</id><summary type="html">&lt;p&gt;I’ve been learning &lt;a href="http://haxe.org/"&gt;Haxe&lt;/a&gt; since the last few months. Beside the reason
of many Flash guys moved/moving to Haxe because of better performance of
compiled swf, I was tempted to try using its C++ target, which runs even
faster(at least in theory, in most parts). Its language …&lt;/p&gt;</summary><content type="html">&lt;p&gt;I’ve been learning &lt;a href="http://haxe.org/"&gt;Haxe&lt;/a&gt; since the last few months. Beside the reason
of many Flash guys moved/moving to Haxe because of better performance of
compiled swf, I was tempted to try using its C++ target, which runs even
faster(at least in theory, in most parts). Its language feature is also
very nice, which is quite similar to &lt;span class="caps"&gt;AS3&lt;/span&gt; but more powerful in
many aspects. Check out its &lt;a href="http://haxe.org/doc/features"&gt;feature page&lt;/a&gt; if you want to know more.&lt;/p&gt;
&lt;p&gt;And because of I need to write some 3D stuff in a project, I tried
finding a Haxe 3D engine  that can compiled to C++, but who knows, there
wasn’t one. Actually the 3D engines in Haxe are all quite young. There
are 3 I found, all targeting only Flash: &lt;a href="http://www.flashsandy.org/"&gt;Sandy3D&lt;/a&gt;, originally written
in &lt;span class="caps"&gt;AS&lt;/span&gt;, has switched its trunk to Haxe; &lt;a href="http://www.away3d.com/"&gt;Away3D&lt;/a&gt;, again originally
written in &lt;span class="caps"&gt;AS&lt;/span&gt;, now has a Haxe branch inside its &lt;span class="caps"&gt;SVN&lt;/span&gt; in active
development; &lt;a href="http://code.google.com/p/haxe3d/"&gt;Haxe3D&lt;/a&gt;, developed by Nicolas(the creator of Haxe),
written in Haxe from the very beginning, seems to be very light-weight but
I can’t found much info about it.&lt;/p&gt;
&lt;p&gt;So I decide to work on one of them to enable a Haxe C++ 3D
engine. Because Sandy3D should be the most complete and stable one(which
actually stopped active development…), I chose it.&lt;/p&gt;
&lt;p&gt;In the development of it, some issues are related to &lt;a href="http://code.google.com/p/nekonme/"&gt;nme&lt;/a&gt;/&lt;a href="http://code.google.com/p/neash/"&gt;neash&lt;/a&gt;,
which are the re-invented cross-platform Haxe version of the Flash &lt;span class="caps"&gt;API&lt;/span&gt;.
With the help from &lt;a href="http://gamehaxe.com/"&gt;Hugh&lt;/a&gt; and Niel, project owner of &lt;a href="http://code.google.com/p/neash/"&gt;neash&lt;/a&gt; and
developer of Sandy3D, most of the problems are solved. However as I can
see, re-inventing the Flash &lt;span class="caps"&gt;API&lt;/span&gt; is a hard job as consideration of other
target is also needed, e.g.. &lt;span class="caps"&gt;JS&lt;/span&gt;/Canvas. &lt;a href="http://ideas.adobe.com/ct/ct_a_view_idea.bix?c=975F47A1-B925-4456-89DB-3BEFB1DA7780&amp;amp;idea_id=D62AC800-1BD6-4C79-85A7-6CCCE1C403AC"&gt;I really hope Adobe can help
this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Currently some very basic demos of Sandy can be compiled to C++ and it
shows that, in OpenGL rendering mode, the performance can goes over 300%
of the Flash(Haxe, not &lt;span class="caps"&gt;AS3&lt;/span&gt;) version. However in normal rendering mode,
the frame rate may actually be reduced if the window size is large.
Anyway, I think the performance is quite depend on hardware/&lt;span class="caps"&gt;OS&lt;/span&gt;, also the
3D scene you’re showing.&lt;/p&gt;
&lt;p&gt;Thanks for the Sandy3D team, they added me as a committer in their
official Google project. And I have just committed the changes to the
trunk :) There should be a new release soon if everything is fine.&lt;/p&gt;
&lt;p&gt;A note to the ones can’t wait for a release:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Install hxcpp, nme, neash from haxelib.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Replace contents in neash’s neash/display/IBitmapDrawable.hx to a simple &lt;code&gt;typedef IBitmapDrawable = nme.display.IBitmapDrawable;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;To make mouse event work, in neash’s neash/Lib.hx, the code:
    &lt;pre&gt;
// Process pending timers ...&lt;br/&gt;
neash.Timer.CheckTimers();&lt;br/&gt;
// Send frame-enter event&lt;br/&gt;
var event = new Event( Event.ENTER_FRAME );&lt;br/&gt;
mStage.Broadcast(event);
    &lt;/pre&gt;
    should be moved to the end of the do-while loop, just before &lt;code&gt;mStage.RenderAll();&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For mouse event in OpenGL mode to work, additional fix which required a recompile of nme is needed. I haven’t tried yet. Now just ignore this…&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You should be able to use Sandy3D in C++ without the above patches for the next release of nme/neash. But for now, please do it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span class="caps"&gt;BTW&lt;/span&gt;, I am also &lt;del&gt;porting&lt;/del&gt; ported &lt;a href="http://casalib.org/"&gt;casalib&lt;/a&gt;, which I often use in &lt;span class="caps"&gt;AS3&lt;/span&gt;
development, to Haxe, see &lt;a href="http://github.com/andyli/casahx"&gt;casahx&lt;/a&gt;.&lt;/p&gt;</content><category term="3D"></category><category term="Haxe"></category><category term="Sandy3D"></category></entry></feed>