
-->
Warning: since there's no reason for porting your code from Sandy 1.2 to 2.0, because Sandy 2.0 isn't up to date to the new Sandy 3.x releases anymore and has less features than Sandy 1.x, we warmly recommend to keep using the 1.x releases until the new Sandy 2.0.2 is officially released.
Things you need to correct in your code to port it from Sandy 1.2 to Sandy 2.0 include the following
You'll need to correct the following import paths
The sandy.core.Object3D class has been replaced by sandy.core.scenegraph.Shape3D
The Camera3D class has moved from import sandy.view to sandy.core.scenegraph
The sandy.skin.SkinType class has been replaced by sandy.materials.MaterialType
The sandy.skin.Skin class has been replaced by sandy.materials.Material
These changes affect how you set up your camera and add it to the world:
The Camera3D class has moved from import sandy.view to sandy.core.scenegraph
The Camera3D class extends ATransformable. The Camera is now a Node added to the world with addChild() instead of World3D.setCamera(). (Not sure about this.)
These changes affect how you scale, rotation, and translate objects:
The Transform3D class isn't used for transforming (scaling, rotating, and translating) objects. Use the core.scenegraph.ATransformable.as class.
To rotate an object, instead of using the Transform3D.rotX() method, use the ATransformable.rotateX property. Likewise for rotY(), rotZ, etc.
The TranformUtil class is no obsolete.
“Skins” have been replaced by “Materials”. An “Appearance” includes one or more Materials for frontAppearance and backAppearance, plus line attributes are separate from fills? New classes include ColorMaterial and BitmapMaterial. Still to come: WireframeMaterial and others?
The sandy.skin.SkinType class has been replaced by sandy.materials.MaterialType
The sandy.skin.Skin class has been replaced by sandy.materials.Material
Object3D.setSkin() has been replaced by the Shape3D.appearance property. Do frontMaterial and backMaterial properties replace _s and _sb (skin and backskin)? I'm not at all sure about this.
Here is how to set the Shape3D.appearance property instead of using the old Object3D.setSkin() method:
var myMaterial:BitmapMaterial = new BitmapMaterial( BitmapData.loadBitmap("monalisafit"));
var l_oTextureAppearance:Appearance = new Appearance( myMaterial );
box = new Box( "myBox", 100, 100, 100, "tri", 2 );
box.appearance = l_oTextureAppearance;
IPolygon class doesn't exist. Use Polygon class instead.
Object3D.aPoints property has been replaced by Shape3D.geometry.aVertex, I think. (I could well be wrong)
For developers who modify the Sandy classes themselves, also note you must change the following:
Object3D.setModified() method has been replaced by Shape3D.changed property (does this also cover the Object3D._needRedraw property implicitly?)
The generate() method for a Shape3D (including primitives) must return a Geometry3D value. Therefore we changed “setGeometry(l_geometry)”, which was used in Sandy 1.2, to “return l_geometry”, which is required in Sandy 2.0, in all the generate() methods for the primitives.
Geometry3D.faces property has been replaced by Geometry.aFacesVertexID (?? I think?). Has Object3D.faces also been replaced by Shape3D.geometry.aFacesVertexID?
Geometry3D.points property has changed to Geometry3D.aVertex, possibly. I'm quite possibly mistaken.
Geometry3D.normals property has changed to Geometry3D.aFacesNormals, I think. (???)
Change “new UVCoord ()” to “Geometry3D.setUVCoords( n, 0, 0 );” where n is the array index number (zero-relative). See Hedra.as for an example (compare the Sandy 2.0 version to the 1.2 version)
Change aPoints.push() to Geometry3D.setVertex() as follow (again, see Hedra.as for an example). That is, change this:
var p0 : Vertex = new Vertex (-r2,-h2,l2);
aPoints.push (p0);
To this:
var l_nID0:Number = l_geometry.getNextVertexID();
l_geometry.setVertex( l_nID0, -r2, -h2, l2 );
* And change this:
f = new Polygon(this, aPoints[4], aPoints[1], aPoints[2] );
f.setUVCoords( _aUv[4], _aUv[1], _aUv[2] );
aNormals.push ( f.createNormale () );
addFace( f );
to the following:
l_oGeometry3D.setFaceVertexIds( 0, 4, 1, 2 );
l_oGeometry3D.setFaceUVCoordsIds( 0, 4, 1, 2 );
Note that the first param (in this case zero), is the item number in the array. The remaining numbers (i.e., 4, 1, and 2 in the example above) are the indices into the aPoints and UVcoords arrays from the old Sandy 1.2 code above.
That is, instead of creating a new Polygon and setting the UV Coords with setUVCoords() and then invoking addFace() as you did in Sandy 1.2, you'll use Geometry3D.setFaceVertexIds() and Geometry3D.setFaceUVCoordsIds() as shown above for Sandy 2.0.
The first argument to setFaceVertexIds() and setFaceUVCoordsIds() should be the element number used when invoking Geometry3D.setVertex() (see above). You can either track these by hand (using 0, 1, 2, 3, etc.), or add them one at a time using Geometry3D.getNextVertexID(). Or here is an example adding them using the existing length of the array to get the next index:
l_geometry.setFaceVertexIds( l_geometry.aFacesVertexID.length, p0, p1, p3 );
l_geometry.setFaceUVCoordsIds( l_geometry.aFacesUVCoordsID.length, uv0, uv1, uv3 );
I don't know what to do to recreate normals. Here is the Sandy 1.2 code. Is this done automatically in Sandy 2.0? If not, I don't know the equivalent:
aNormals.push ( f.createNormale () );
