Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tool for SetSpriteShapePolygon

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 10th Dec 2011 23:00
Anyone built a tool for easily scanning the outline of a sprite and automatically generating points for SetSpriteShapePolygon?

It would involve a great deal of time to have to set the points manually, so I think that sooner or later everyone is going to need this kind of tool after the Placement editor.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 11th Dec 2011 03:03
Sounds like a useful tool. I have avoided that command for that very reason so far and simply use the setspriteshape(id,3) option. Rough but far better, and far faster than mapping co-ordinates for every frame of every sprite. Even better would be a simple transparency check in AGK's collison code, rather than having to map a shape to each sprite, and so avoid it's use entirely (If you don't need physics).

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Dec 2011 08:08
I have a set of commands in DBPro that would get half way there, I don't have any time at the moment though... when I've finished my current set of projects I'll look at doing this if nobody else has beaten me to it.

Hockeykid
DBPro Tool Maker
16
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 11th Dec 2011 09:47 Edited at: 11th Dec 2011 09:56
Not quite sure on what "SetSpriteShapePolygon" requires, but I came up with this in DBPro (not sure if it helps). As you can see it made a near perfect outline of the penguin image from the AppGameKit examples.





Sean

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th Dec 2011 10:01
That's a good start hockeykid, you already have the number of points as dots. The next step is to reduce the number of points to within a tolerance and then organise them into groups of no more than eight points with fully convex shapes. Then these individual points for each shape need to be organised into a clockwise order.

If I get a chance I'll dig out some code for some of this, it might help someone (or you) finish what you've started

BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Dec 2011 14:41
Quote: "The next step is to reduce the number of points to within a tolerance and then organise them into groups of no more than eight points with fully convex shapes"


It's 12 in AGK. But to make it DBP compatible too, you'd want to stick to 8.

I have my own tool I created (sorry, I can't share because it is not owned by me as an individual), the messy bit is writing the code that handles anything between 3 and 8 possible nodes. I had to write a block of code for each possibility.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 4th Mar 2012 20:59
So how are you guys fairing with SetSpriteShapePolygon ?

Is there maybe some general use sprite tool, not necessarily for AppGameKit, that can somehow let you easily mark the polygon shape and export the co-ords?
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 4th Mar 2012 21:04 Edited at: 4th Mar 2012 21:04
If you want to load a image and then easly set it's shape & export it's co-ords.. It's easy. I'll look into that when I have the time (don't expect Win32 GUI. It's almost impossible to do using C++ & graphics library different than DirectX API)

If you could fully describe how would you like that tool to work, that'd help.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 4th Mar 2012 21:59
in my mind the tool would allow you to draw lines to build multiple polygons, which can be stuck together to form intricate shapes.
Alien Menace
AGK Developer
19
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 5th Mar 2012 04:15 Edited at: 5th Mar 2012 04:38
Sounds like the editor I wrote a while back in DBP using Diggsey's Box2D plugin:

http://www.youtube.com/watch?v=RChRe99LWjU&feature=youtu.be

and

http://www.youtube.com/watch?v=tUj0c8xZ9f0&feature=channel

Intel i7-2600k - Asus P67 Sabertooth - 16GB RAM - 2x GTX 460 OC SLI - Lexar 128GB SSD Drive - 2TB ATA/600, Windows 7 x64. iPad, iPad2, iPhone 3GS & 4, HTC Inspire, Mac-Mini. Apps published: 3
Alain91
12
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 5th Mar 2012 07:45
It seems to be a great tool!

Is it availble for us ?

Regards,
Alain
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 08:41
Alien, yes that's the basic concept.
Can it draw more than 1 polygon shape as AppGameKit limits 1 polygon to 12 sides, so complex graphics will need more than 1 polygon stuck together.
Also can it export the vertex co-ords to file so that they can be edited appropriately and imported in AppGameKit?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 17:53 Edited at: 5th Mar 2012 22:31
I decided to make a simple tool for this in AGK.

Attached is "ShapeUp" which contains the tool and a test project (ShapeUp Test).

You have to make sure that any shapes you create are created in a clockwise order and convex on shape but other than that it's pretty simple to use.

Just make a shape and snap to the start point of the shape (or do over 12 points) to close the shape and start making a new one.

Usage:
1-Put your image into the "media/input" folder
2-Start the app
3-Randomise the background colour using the bottom right button
4-Draw your shapes
5-Export using the "EXPORT" button. This creates a file called "yourImage.shp" for an image called "yourImage.png" in the "...\Documents\AGK\C_AGK_temp_Projects_ShapeUp_ShapeUpexe" folder.
6-Put the "loadPhysicsSprite()" function into your game after the loop
7-Call this to create a physics sprite using the shape you saved!

Any problems let me know

EDIT: Don't forget to put the image and "shp" file in the same folder you want to load from...

EDIT2: It's a work in progress. I intend to add more functionality later.

EDIT3: New version further down

kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 5th Mar 2012 18:24 Edited at: 5th Mar 2012 18:24
Doesn't work after changing shape1.png. Weird.

Keeps saying that there was no valid image found under the input folder.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 19:49
works great for me!
well done Baxslash.

would it be possible to out put the data in text format so that I can just copy, edit & paste inside my code?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 20:38
Quote: "Keeps saying that there was no valid image found under the input folder."

What did you put in there? Should work for png jpg and I think bmp but I'll have to check.

Quote: "works great for me!
well done Baxslash.

would it be possible to out put the data in text format so that I can just copy, edit & paste inside my code?"

Sure, it would make it a lot easier to use.

I'll add it to the next update.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 20:49
great!
this is by far one of the coolest & most useful AppGameKit tools to date!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 22:35
Here's an update to ShapeUp which now uses strings in the read write functions.

I also added some explanatory text to the file.

New loading code:


Attachments

Login to view attachments
kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 5th Mar 2012 22:37
I was trying to name the file shape.png or either keep it as shape1.png but it didn't want to open it.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 22:47 Edited at: 5th Mar 2012 23:05
That shouldn't be a problem as it's just opening the first image file it finds...

There's no reason that should stop it working. Have you tried other image files?

EDIT: Started a WIP thread here:
http://forum.thegamecreators.com/?m=forum_view&t=194938&b=48

MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 6th Mar 2012 04:54
"baxslash : the man who program faster than his shadow"
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 6th Mar 2012 10:09
My shadow is pretty fast

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 7th Mar 2012 02:09 Edited at: 7th Mar 2012 03:10
I wonder if there is a way to manipulate the sprite to that shape. That would be a very useful thing. Or only show the sprite that is within the shape points.

I think one why around this is using circles to define the area of the shape and iterate them from one end of the polygon to the other end. So it would be a hole bunch of circles that look like the shape.
Which I think is possible right know. Because we know the given polygon all you have to do is somehow make an algorithm that fills it with circle sprite shapes,or a bunch of hexagons.

I read this article about this.
http://alienryderflex.com/polygon/

So it looks like in that article that all you would do is find the polygonxmin, ploygonymin, and polygonxmax, polygonymax from the list of points.

Then check linerally from poly x min and poly y min to poly x max and poly y min.

Then iterate through poly y min to poly y max to determine if a point is within the given poly. If the point is within the area then draw the hexagon.

check img



Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.

Attachments

Login to view attachments
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 7th Mar 2012 03:52 Edited at: 7th Mar 2012 03:52
To Straighten out the edges I would keep track of the polygons already placed then fill in the empty areas with squares and triangles so the result would be something like this.



Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.

Attachments

Login to view attachments
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 7th Mar 2012 09:49
It shouldn't need to be this clunky. I think all the platforms are capable of producing filled polygons from an array of points - it just needs wrapping.

-- Jim
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Mar 2012 10:08 Edited at: 7th Mar 2012 10:10
3d, that's a nice article but Jim is right. We don't need to work it out manually.

There may be a way to create the shapes automatically but not without a lot more time spent on the project.

My version lets you draw the shape yourself and helps you not to draw an incorrect shape. You can decide for yourself what detectable shape you want for your object so say for a bush you can let your character walk behind some of the leaves but they'd have to jump over the main part of the bush.

Seems to me that TGC already have a working algorithm for detecting the shape of a sprite. Might be nice if they added a "complex" shape creation option? Even with that though my tool would still make none obvious shapes easier to build.

EDIT: Jim, I'm adapting a flood fill function for use with the new draw tools coming in V107. I'll share all of my drawing tools when it is released if you're interested.

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 7th Mar 2012 15:57 Edited at: 7th Mar 2012 15:59
I have already put the polygon shape in to my engine of tiled in rapid XML. So tiled handles all polygons. I came up with polygon fill command because I am putting this fill command in my engine too. Maybe someone should rewrite rapid xml into tier one.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2012 17:47
Quote: "Might be nice if they added a "complex" shape creation option?"


What should it do?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Mar 2012 17:52 Edited at: 7th Mar 2012 17:53
Ideally it would create complex shapes automatically (IE shapes that have convex points and holes in them) from as many polygons as required. Perhaps with a level of detail parameter?

Currently (correct me if I'm wrong) the shape detection will make one convex shape of up to 12 *points for a single sprite.

*edited wrong word...

Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 7th Mar 2012 18:02
Interesting idea, I can see it being very useful but not easy to write. Something for the future perhaps, but I think your editor would allow people more flexibility in trading accuracy for speed For example if a car image had antennas you could choose not to include them whereas an automated process would have difficultly realising they are not important.

Quote: "Currently (correct me if I'm wrong) the shape detection will make one convex shape of up to 12 *points for a single sprite."


Correct, we currently we have an algorithm to take an image and produce a single convex hull around all non-alpha pixels with a limited number of points.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Mar 2012 18:13
Yes, it would be pretty complicated to write. I'm not sure how your algorithm works but I bet it's more of an outline detection which would make it hard to use for this.

I might have a try at this if we get some pixel colour detection from images (like we have in DBPro) at some point.

JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th Mar 2012 00:37 Edited at: 8th Mar 2012 00:48
Sorry for a long post and a YouTube link, but it's relevant. This is actually an internal company video, so I will remove it on April 1st.

Over 12 years ago Dave Parkinson (well-known to Amiga developers) and I created an authoring engine for interactive language learning for an EU funded project. This is a tiny aspect of the whole vast system, but it illustrates what we're talking about. This is a drag and drop onto an irregular region.

There is only ONE image here - the backdrop image of a nice woman called Allison. Everything else is produced at run-time, including the hit-regions. The rectangle borders are the "frames" for the dynamic "sprites". In this engine the sprites are in fact quite complex objects with inheritance, and can be video containers. But here we are simply defining two types: text objects and region objects, defining actions for right and wrong etc.

http://youtu.be/YlsSALKAzRk

If you were producing an interactive book, for example, these region hits would be exactly what you want. So you could draw around Lee's teapot and steam would come out. (action = run teapot steaming animation).

Internally, at construction time a list of points is continued by clicking until right-mouse is clicked. It then computes the bounding box. These values are saved as text in the exercise file.

At run-time, the engine creates a "sprite" of appropriate type. In this case it makes an image of the bounding rectangle size containing a transparent filled polygon with a high Z-order so that hits or drops will report the entity which is the target, from which, obviously, you can search a list to see if it's correct.

So that's what I mean by the significance of dynamic filled polygons. It really should not be necessary to spew out hundreds of little images to do this.

I also think that visual design tools are a must-have. Delphi allows you to produce very sophisticated Windows (or now Mac, iOS and Android) GUIs in five minutes. Yet, even with retro 2D games we seem to be back in the Dark Ages of hacking out miles of tedious and error-prone code. Where has the idea of "productivity" gone?

-- Jim
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Mar 2012 14:37
Jim, that sounds really cool. I'll try to watch the video later with sound.

Productivity comes from having the tools to do the tedious jobs that you are talking about. It would be great to have dynamic filled polygons in AppGameKit for so many different tasks. Maybe you could pass some knowledge on this subject on to TGC?

I'm glad you think that visual design tools are necessary as I've just finished this one and made it open source for anyone who wants to add to it or improve the interface somehow.

DOWNLOAD ShapeUp V1.0.0 Open Source

3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 9th Mar 2012 03:09 Edited at: 9th Mar 2012 04:08
here is poly fill I have created with tiled shape files of polygons.
I also can delete the sprites making it kind of editable sprites.

I made the poly with tiled and imported it as a polygon using xml code.


to edit the terrain all i did was do this


to make the terrain i used this.


Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps.
Developed the tiled map engine seen on the showcase.
Veterian for the military.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Mar 2012 09:37
That'd be great for an offroad game (for the terrain). It could be randomly generated as you drive...

Very cool!

Login to post a reply

Server time is: 2024-03-29 15:13:15
Your offset time is: 2024-03-29 15:13:15