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
These changes affect how you set up your camera and add it to the world:
These changes affect how you scale, rotation, and translate objects:
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;
For developers who modify the Sandy classes themselves, also note you must change the following:
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 () );