Ask a questionAsk a question
 

General DiscussionWPF/E + 3D

  • Tuesday, February 13, 2007 5:42 PMstresslessness Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    WPF/E doesn't have built-in 3D functionality.

    However, approximate 3D functionality can be obtained using some simple tricks. You may see the demonstration on http://www.windowsvista.si/main.htm?show3d=1&content=home (of course WPF/E should be already installed)

    This site, which you all have probably seen, has an url tweak to show some 3D content. It is just a demo, but almost any simple 3D object can be displayed. As there is no frustum clipping (yet), the objects should be always in front of the camera. With frustum clipping (consequently it makes tesselation) 3D rooms are possible and even some kind of a 3D game.

    If you wonder, how it is made, this is the technique:

    - create an Image element with MatrixTransform and PolyLineSegment clipping geometry
    - image width and height should both be 1 (actual size is defined later by transform matrix)
    - polyline clipping geometry should be a triangle, which occupies the area, which will be used and displayed as a texture (3 polygon points represent 3 texture coordinates)
    - 3D transformation by matrix and projective division should be made, as in every other 3D engine. Transformed vertices in 2D are used to align Image.
    - matrix coefficients for Image MatrixTransform are computed by inverting tex-coord matrix and multiplying by 2D transformed vertices (numbers in parenthesis are matrix dimensions):
        M(3x2) = V(3x2) * T(3x3)^(-1)
    - all coefficients are multiplied by half the desired viewport size, and offset is increased to the half of the viewport size
    - the image is then displayed by aligning each visual vertex into 2D transformed vertex.

    All this tasks can be visible in javascript for 3D objects, http://www.windowsvista.si/js/object_3d.js

    The cubic object is currently hard codec into the source code, but it can be any simple object. For now, I didn't use any lighting and coloring, but it may be done by using opacitymask.

All Replies

  • Tuesday, February 13, 2007 6:19 PMBryant LikesMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Very cool! Thanks for posting this.
  • Tuesday, February 13, 2007 6:49 PMMorten Nielsen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You're a genius ! Thanks for sharing.
  • Tuesday, February 20, 2007 3:34 PMYuvi Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You absolutely rock buddy!
  • Tuesday, March 27, 2007 4:06 PMJeff_G Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    This is really a great demo.

    You say that you use triangles to construct the 3D object. Is it possible to use rectangles instead?

    Currently the matrix you invert is something like that:

    [t0.r, t0.s, 1]

    [t1.r, t1.s, 1]

    [t2.r, t2.s, 1]

     

    Do you think it's possible to add one more point and how would this affect the calculation of the MatrixTransform coefficients (M11, M12, M21, M22, OffsetX, OffsetY)?