Silverlight VS Flash: Snake Snacks Game Sharing of my Google Analytics results.
Jan 22

It’s time for comparing 3D technology again! That’s the second application I implemented using Kit3D and PaperVision3D

The coding is very straight forward. It also includes a lot of useful references for modeling 3D objects like creating a texture mapped plane, transformation, rotation, alpha, double faced and camera moving.

Once again, I think Paper Vision 3D is better than Kit 3D. The main reason is that I think the coding in AS3 is much more easier to understand.

I am quite satisfied with the coding this time. It’s worth for you to keep a copy!!!

Images used in this sample are collected from Yuki Holland.

Comparison

Flash implementation: 45 minutes (Implemented First)
Silverlight implementation: 45 minutes
What’s the difference?

  • Create Texture mapped plane [AS3] vs [C#]

Source codes

Flash

Silverlight

Create Texture mapped plane [AS3] vs [C#]

Here I will show you how to create a textured mapped plane using PaperVision3D. You can also see how can I position the 3D object.

// AS3
// image is a exported image resources inside the fla
var bitmapData : BitmapData = new image(0, 0);
var bitmapMaterial : BitmapMaterial = new BitmapMaterial(bitmapData);
bitmapMaterial.doubleSided = true;
var plane : Plane = new Plane( bitmapMaterial, IMAGE_WIDTH, IMAGE_HEIGHT, SEGMENT, SEGMENT );

// position the plane
plane.rotationX = rotationX;
plane.rotationY = rotationY;
plane.rotationZ = rotationZ;
plane.x = newX;
plane.y = newY;
plane.z = newZ;

For Kit 3D, the coding is much more longer. Please let me know if you don’t understand what they are doing.

// C#

// create image brush resources
ImageBrush imageBrush = new ImageBrush();
imageBrush.ImageSource = new BitmapImage(new Uri(imagePath, UriKind.Relative));

// create bitmap material
GeometryModel3D model = new GeometryModel3D();
model.Geometry = generatePlaneMesh();
model.Material = new DiffuseMaterial(new Kit3DBrush(imageBrush, (int)IMAGE_WIDTH, (int)IMAGE_HEIGHT));
model.SeamSmoothing = 1;
model.BackMaterial = model.Material;

// Create the transform
Transform3DGroup tg = new Transform3DGroup();
tg.Children.Add(new TranslateTransform3D(x, y, z));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(rotationX, rotationY, rotationZ), 90), new Point3D(x, y, z)));
}

// create the model based on the material and transform
ModelVisual3D modvis = new ModelVisual3D();
modvis.Transform = tg;
modvis.Content = model;

// a standard texture mapping mesh
private MeshGeometry3D generatePlaneMesh()
{
        MeshGeometry3D mesh = new MeshGeometry3D();
        mesh.Positions = new Point3DCollection
        {
            new Point3D(-1, 1, 0),
            new Point3D(1, 1, 0),
            new Point3D(-1, -1, 0),
            new Point3D(1, -1, 0)
        };

        mesh.TriangleIndices = new Int32Collection
        {
            0, 2, 1,
            1, 2, 3
        };

        mesh.TextureCoordinates = new Kit3D.Windows.Media.PointCollection
        {
            new Point(0, 0),
            new Point(1, 0),
            new Point(0, 1),
            new Point(1, 1)
        };

        return mesh;
}

Shares and Enjoy~

Did you like this post?

Subscribe here:  

15 Responses to “Kit 3D vs Paper Vision 3D: Image Rotating Cube”

  1. Cristian Merighi Says:

    Silverlight can’t be better: it lacks on non-affine matrix transformations!
    (Cube faces are splitted into triangles - there’s no other way to texture a polygonal surface in SL - so they aren’t perfectly mapped as those made in flash)
    Silverlight likely will be better, as its 3(r)d version will be released ;)

  2. Steve Buchok Says:

    This is one of the first examples where I can say there is a big difference between the two and the first time I can say that Flash is far better in this example. If you look at the center of the pictures in the Silverlight example it seems to dip in or something when it rotates to the front.

    On a side note, please continue to do these demos between Flash and Silverlight. They are great at showing how similar and yet how different they really are.

  3. admin Says:

    Let me add something here. Actually, the “dip in” Steve Buchok mentioned can be fixed with some modification of coding.

    For the sample in flash, the SEGMENT value is set to 4. That’s why it looks very smooth.

    While in Silverlight, the algorithm is a little bit differenet. Althought there is no Segement parameter when creating the plane, it is already defined in the method generatePlaneMesh().

    You may create a more comlex point collection to increae the “segment”. However, I am too lazy (and also too complicated) to that.

  4. rosedragon Says:

    Can’t test silverlight:
    Microsoft Silverlight is not supported in your operating environment.

    I assume this as however cool the features it can provide, it limit amount of viewers/visitors.

  5. Alexander Cer Says:

    i think the flash is much more like our think about the 3d worlds, but the silver light is much like a coder of 3d engine. silver light is much detialed and much more knowlege about the 3d mathmatic and theory. flash seams much object oriented. that is all.

  6. Mike Says:

    Hi,

    the source code link for silverlight point to “ImageSpace3D_Silverlight.zip” (which BTW is also cool but not quite what I want to play with ;-)

  7. Silver Yu Says:

    Hi Terence, Nice job. For a long time I have been finding some methods to 3D in flash.

  8. Silverlight vs Flash: 3D Spinning/Rotating Globe Says:

    [...] Papever Vision 3D and Kit 3D. This post is actually a minor modification of my previous article Image Rotating Cube. I suppose the Flash and Silverlight versions will look like more or less the same as in the last [...]

  9. Leo Dawn Says:

    I think Silverlight Image Rotating Cube moved deeper than Flash ones,so the speed looks like slower than Flash.

  10. Denny Says:

    Flash is much better, I think it use a bilinear (or trilinear) interpolation for texture mapping, while Silverlight use a simple linear interpolation.

  11. Steve Buchok Says:

    It’d be nice to see you redo this example in Silverlight 3.

  12. Image Rotating Cube | Silverlike - A Free Microsoft Silverlight 3 Directory Says:

    [...] Terence Tsang used Kit3D to create an image rotating cube. Pretty interesting! [...]

  13. resveratrol Says:

    Substantially, the article is in reality the greatest on this worthw hile topic. I fit in with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be adequate, for the phenomenal lucidity in your writing. I will directly grab your rss feed to stay informed of any updates. Authentic work and much success in your business enterprise!

  14. spam-dev Says:

    Wow!!. it very cool. thankyou for this code.

  15. Alex H Says:

    Hey… I tried to show the flash version as an external swf in an other swf… and the it f..ked up… anyone tried this and got it to work?

Leave a Reply