Shape3d code : Converts image into 3d shape


Hello, i created a program that allows to convert an image (silhouette) into a 3d shape.

I used Jts library that allows to perform boolean operations(union,intersection,etc), simplification and triangulation of 2d polygons.

Download : Shape3D

More Images :

original image

polygonized

Simple symmetry Y

Simple Symmetry X

4 Likes

very cool, thx! Perhaps this can also be used also to create 3D text, which we don’t have (AFAIK)

1 Like

Having this as a plugin for the SDK would be very useful. Nice work tralala

Looks awesome! Big +1 for using JTS :slight_smile:

Really nice! Maybe I could find a use for that… Probably not, but it’s still great anyway. :wink:

Yeah, definitely cool stuff, and as @sbook said, a plugin would be awesome :slight_smile: But I guess it can also be useful as a game library, anyone know the “draw a plane” feature of “Eye Pet” from PS3?

normen said:
Yeah, definitely cool stuff, and as @sbook said, a plugin would be awesome :) But I guess it can also be useful as a game library, anyone know the "draw a plane" feature of "Eye Pet" from PS3?


@Sploreg actually said that ;)

@tralala, are you planning on putting this under version control at some point? It seems like you've already got SVN set up over at Google

i will try, this is my first time.

i cant do it, i give up


  1. import into repository: does nothing.


  2. commit:cant change “Repository url” it is a gray button that points to nifty gui, and says “authentication fail”.


  3. relocate: i get the following error :



    org.tigris.subversion.javahl.ClientException: Inter-repository relocation not allowed

    svn: The repository at ‘https://petomancer.googlecode.com/svn/Shape3d’ has uuid ‘24ff128b-64c1-84cd-8a53-1a0f7ef1f14b’, but the WC has ‘aea8f524-624a-0410-bff8-fbe06e9eb2f1’

Hey @tralala :slight_smile:



I’m going to try and use this Shape3D code in my 3079 game – thank you!



I had to give it a package name (e.g. “Shape3D”) to import it properly and use it as a library (suggest you do the same for a future update)

@phr00t just an FYI, typical package naming conventions are all lower case… so it would probably end up as ‘shape3d’

Aieet @tralala



I’m playing around with this – trying to integrate it into my game. Unfortunately, I sometimes get this crash:



[java]com.vividsolutions.jts.geom.TopologyException: found non-noded intersection between LINESTRING ( 19.0 2.0, 19.0 1.9999999999999996 ) and LINESTRING ( 19.0 1.9999999999999996, 19.0 2.000000000000001 ) [ (19.0, 2.0, NaN) ]

at com.vividsolutions.jts.noding.FastNodingValidator.checkValid(FastNodingValidator.java:126)

at com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:94)

at com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:59)

at com.vividsolutions.jts.operation.overlay.OverlayOp.computeOverlay(OverlayOp.java:170)

at com.vividsolutions.jts.operation.overlay.OverlayOp.getResultGeometry(OverlayOp.java:127)

at com.vividsolutions.jts.operation.overlay.OverlayOp.overlayOp(OverlayOp.java:66)

at com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.getResultGeometry(SnapIfNeededOverlayOp.java:62)

at com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(SnapIfNeededOverlayOp.java:25)

at com.vividsolutions.jts.geom.Geometry.union(Geometry.java:1361)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionActual(CascadedPolygonUnion.java:369)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionUsingEnvelopeIntersection(CascadedPolygonUnion.java:328)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionOptimized(CascadedPolygonUnion.java:299)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionSafe(CascadedPolygonUnion.java:274)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.binaryUnion(CascadedPolygonUnion.java:219)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.binaryUnion(CascadedPolygonUnion.java:193)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:139)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.reduceToGeometries(CascadedPolygonUnion.java:243)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:137)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.reduceToGeometries(CascadedPolygonUnion.java:243)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:137)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.reduceToGeometries(CascadedPolygonUnion.java:243)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:137)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.union(CascadedPolygonUnion.java:127)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.union(CascadedPolygonUnion.java:73)

at com.vividsolutions.jts.operation.union.UnaryUnionOp.union(UnaryUnionOp.java:174)

at com.vividsolutions.jts.operation.union.UnaryUnionOp.union(UnaryUnionOp.java:93)

at com.vividsolutions.jts.geom.Geometry.union(Geometry.java:1435)

at Shape3d.ShapeUtilities.combineComponents(ShapeUtilities.java:148)

at Shape3d.ShapeUtilities.createShape(ShapeUtilities.java:52)

[/java]



This is the image that seems to be causing it so much trouble:



http://i.imgur.com/WvRQC.png



Any suggestions?



Thanks!

hello i tried it and it crashed as you said.



However it worked normally when i used it with a slighly modified picture:



http://i.imgur.com/TSTSJ.png



I will post in 5 min the reason why your original image crashes.

it just crashes because it is too small in size :

  1. just doubling the size in any paint application will make it works.



    Maybe i should do a check if image too small to scale automatically



    ps. i cannot upload the x2 size image, because imgur hates me.
LINESTRING ( 19.0 1.9999999999999996, 19.0 2.000000000000001 ) [ (19.0, 2.0, NaN) ]

You've got a "NaN" (Not a number). That can't be good.

What is it about small pictures that cause it to crash? I suppose I could scale up my picture, but I’m curious as to why that is necessary?



Thanks for looking into it so quickly!



EDIT: I also noticed the NaN which can never be good :slight_smile:

Jts doesnt support the third dimension (Z value) which means it always has NaN value.

Afterall Its a 2d polygon manipulation library.

@tralala2



What is the minimum image size this function supports? Let me know if you make any updates to your code so I can download them. Thanks again!

i dont know exactly > 32 pixels ? you can do a test drive by creating images from microsoft paint.

@tralala2 & @tralala :smiley:



It doesn’t appear to be size that is causing problems… this image works fine:



http://i.imgur.com/MBiEk.png



… and it is only 40x11.



This image (51x32) causes the same exception:



http://i.imgur.com/6gJRA.png



[java]com.vividsolutions.jts.geom.TopologyException: found non-noded intersection between LINESTRING ( 25.0 4.0, 25.0 3.9999999999999996 ) and LINESTRING ( 25.0 3.9999999999999996, 25.0 4.000000000000001 ) [ (25.0, 4.0, NaN) ]

at com.vividsolutions.jts.noding.FastNodingValidator.checkValid(FastNodingValidator.java:126)

at com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:94)

at com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:59)

at com.vividsolutions.jts.operation.overlay.OverlayOp.computeOverlay(OverlayOp.java:170)

at com.vividsolutions.jts.operation.overlay.OverlayOp.getResultGeometry(OverlayOp.java:127)

at com.vividsolutions.jts.operation.overlay.OverlayOp.overlayOp(OverlayOp.java:66)

at com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.getResultGeometry(SnapIfNeededOverlayOp.java:62)

at com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(SnapIfNeededOverlayOp.java:25)

at com.vividsolutions.jts.geom.Geometry.union(Geometry.java:1361)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionActual(CascadedPolygonUnion.java:369)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionUsingEnvelopeIntersection(CascadedPolygonUnion.java:328)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionOptimized(CascadedPolygonUnion.java:299)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionSafe(CascadedPolygonUnion.java:274)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.binaryUnion(CascadedPolygonUnion.java:212)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.binaryUnion(CascadedPolygonUnion.java:217)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.binaryUnion(CascadedPolygonUnion.java:193)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:139)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.reduceToGeometries(CascadedPolygonUnion.java:243)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:137)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.reduceToGeometries(CascadedPolygonUnion.java:243)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.unionTree(CascadedPolygonUnion.java:137)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.union(CascadedPolygonUnion.java:127)

at com.vividsolutions.jts.operation.union.CascadedPolygonUnion.union(CascadedPolygonUnion.java:73)

at com.vividsolutions.jts.operation.union.UnaryUnionOp.union(UnaryUnionOp.java:174)

at com.vividsolutions.jts.operation.union.UnaryUnionOp.union(UnaryUnionOp.java:93)

at com.vividsolutions.jts.geom.Geometry.union(Geometry.java:1435)

at Shape3d.ShapeUtilities.combineComponents(ShapeUtilities.java:148)

at Shape3d.ShapeUtilities.createShape(ShapeUtilities.java:52)

[/java]



However, this image (36x36) causes a whole new exception:



http://i.imgur.com/R2E4b.png



[java]java.lang.NullPointerException

at Shape3d.ShapeUtilities.createShape(ShapeUtilities.java:58)[/java]



:confused: