Quick Links: Gideros Home | Download Gideros | Developer Guide
Path2D in a 3D mesh does not fill correctly
  • kemine +1 -1
    Member
     
    application:setBackgroundColor(0x0)
    application:configureFrustum(120)
     
    --I first make the SVG object
    local path = Path2D.new()
    path:setPosition(140, 10)
    path:setFillColor(0xb87e43, 1)
    path:setLineColor(0xFFFFFF)
    path:setSvgPath("M 0.00 40.42 C 7.03 35.03 14.13 29.73 21.19 24.38 C 28.51 29.55 35.47 35.21 42.87 40.27 C 49.96 35.03 56.90 29.59 64.01 24.38 C 71.10 29.60 78.06 35.01 85.12 40.28 C 92.54 35.23 99.49 29.54 106.83 24.38 C 113.89 29.68 120.87 35.10 128.00 40.31 L 128.00 128.00 L 0.00 128.00 L 0.00 40.42 Z")
     
    --then I add it to a 3d mesh
    local mesh = Mesh.new(true)
    mesh:addChild(path)
     
    stage:addChild(mesh)
    stage:setScale(5)
     
    --now I tween the rotationY from 0 to 95
    local rotY = 0
    stage:addEventListener(Event.ENTER_FRAME, function()
    rotY = rotY + 1
    path:setRotationY(rotY)
    end)



    When the SVG rotates in the 3D axis, the fill of the SVG does not fill the complete border. The white border is a square with a spiky top, and the brown is the fill.

    image

    This does not happen with bitmap textures, only with Path2D.

    How can I make this work?

    Thanks!

    Sample.zip
    1K
  • hgy29hgy29 +1 -1
    Maintainer Accepted Answer
    Hi @kermine, this can't work with path2D due to the way Path2D is internally implemented: filling uses clipping to speed up things, and clipping doesn't work in 3D.
    The only option I can think of is rendering your shape to a render target and display that rendertarget in 3D
  • kemine +1 -1
    Member
    Ah, I thought something like that was causing that.

    I used a render target and it does work, but it's a raster graphic, which shows pixels (instead of a smooth vector) when the view is zoomed in.

    What's interesting is that using a Shape (+MoveTo/LineTo) works, but Shape is quite limited in what it can draw (i.e just rectangles). Of course you can manually draw curves with a Shape, but it's not resolution independent.

    I think a viable option would be to increase the resolution of the rendertarget as the user approaches the 3d object.

    Thanks, I'll work something out.
  • keszegh +1 -1
    Member
    i guess a workaround would be to make your own triangulation algorithm which conerts your shape to a mesh containing a set of triangles (see e.g. http://sites-final.uclouvain.be/mema/Poly2Tri/ which is not implemented in lua though), this algorithm could convert your polygon to a mesh which works well in 3d.
    disadvantages:
    - it does not have border
    - for curves you need to subdivide the curve and then apply poly2tri, so additional hassle.

    perhaps there could be an option so that path2d fills in this way and then it's fully 3d-compatible.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters