News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

ImportShape - RasterToVector

Started by kevin, January 10, 2006, 12:35:35 AM

Previous topic - Next topic

kevin

This thread provides you with an solution for converting your sprite images to vector format, These vector representations can then be imported into PlayBasic and used for collision purposes in your games.
Please see the updated code/example is posted bellow.    

Note: The code does NOT perform the Raster To Vector operation it self, it merely provides you with a loader code that can import the files from (in TXT format) RasterToVector in Playbasics shape engine.

Go here to download the the software (DEMO) . Remember if you like the software, purchase it !

http://www.raster-vector.com/

kevin

After searching there's loads RasterToVector programs,but not many free ones.  

This one is free ware, but I haven't used it as yet.
http://potrace.sourceforge.net/

Ian Price

#2
HERE is a link to a freeware piece of software that says it can convert bitmaps into vector. I'm downloading it now (24Mb), so I haven't tested it yet.

HERE is a list of programs that say they do the same. Both of the above software solutions are listed.
I came. I saw. I played some Nintendo.

kevin

Was having a look at writing cad format DXF loader.   But it's fair mouth full to wade through..  Will have to come back to it.  
http://www.autodesk.com/techpubs/autocad/a...0/dxf/index.htm

Ian Price

#4
QuoteWas having a look at writing cad format DXF loader.   But it's fair mouth full to wade through..  Will have to come back to it. 
http://www.autodesk.com/techpubs/autocad/a...0/dxf/index.htm


Ermmm... What spoken language is that in?  :P
I came. I saw. I played some Nintendo.

kevin


kevin

#6

*=------------------------------------------------------------------=*

        >> Loading Vector (Collision) Shapes  V0.002 <<

                         By Kevin Picone

                     Last Updated 11,Jan,2006

                     www.PlayBASIC.com

*=------------------------------------------------------------------=*

  This Example load the TXT output from RASTER to VECTOR into a shape.  How well this works, depends on how well the image was traced by the program.

  To get the best results when building collision shapes, convert  your images to a mask (all pixels to the same colour) first, then  convert the masked versions.  This should give a clear outline of  image.   (i've included a simple program to does this)


  The loader function (bellow) expects the provided file to be a  TXT format.   The file will contain the various POLYLINE lists followed by the actual vertex.  Each list is closed with an END TAG.   Thus each list creates and enclosed polugon

 eg



POLYLINE
34       53      
39       46      
43       33      
44       33      
51       25      
55       16      
53       14      
38       13      
37       10      
26       10      
25       14      
9        15      
9        19      
18       31      
21       34      
26       48      
29       53      
34       53      
END



Note:  The Y cords need to be inverted for use with PB.  



  I've NO idea if TXT vector formats are commonly set out this way, or  this is just the way it's exported from the Raster2vector program.  So you'll have to experiment with some others


*=------------------------------------------------------------------=*

  Go here to download the (DEMO) Raster2Vector software  

http://www.raster-vector.com/


*=------------------------------------------------------------------=*


kevin

#7
here's a picture of this one running.   Demo allows you to move the ship around and includes Shape to Shape collision with the Main PlayBASIC Logo. The small one is just there for a bit of backdrop :)


 
 




 Sprite Collisions Links In PlayBASIC


 Manually Doing Pixel Perfect Sprite Collisions (Examples & Video)

  Sprite Collision With An Image Mask

 Sprite Collision Mode (SpriteCollisionMode) Documentation