Pixel Perfect Collision Detection Extension

  ... the case you feel the need for a new feature or want to submit one.

Re: Pixel Perfect Collision Detection Extension

Postby Adi » Mon Oct 28, 2013 9:15 pm

Hi thanks for creating this extension. I have tried using it but I get errors caused by the fact that the AndEngine iShape interface does not define any getWidth or getHeight methods. I have googled for answers but it seems nobody has this problem so am I missing something?

The errors occur in the following classes:
ShapeAdapter
PixelPerfectAnimatedSprite
PixelPerfectSprite

What other classes can I use to get the width and height if IShape doesn't provide it?

Thanks!
Adi
 
Posts: 2
Joined: Mon Oct 28, 2013 8:39 pm

Re: Pixel Perfect Collision Detection Extension

Postby nazgee » Mon Oct 28, 2013 9:18 pm

Try reading here: features/pixel-perfect-collision-detection-extension-t8736-40.html#p57264
and continue all the way down.

You are on an old andengine branch. It is NOT supported anymore...
Dirt Rider Mayhem is PUBLISHED now!
Image
User avatar
nazgee
 
Posts: 527
Joined: Fri Oct 21, 2011 10:31 pm
Location: Poland, Wrocław

Re: Pixel Perfect Collision Detection Extension

Postby Adi » Mon Oct 28, 2013 9:48 pm

Ah I see, I didn't realize that another branch was the latest version. Thanks!
Adi
 
Posts: 2
Joined: Mon Oct 28, 2013 8:39 pm

Re: Pixel Perfect Collision Detection Extension

Postby makers-f » Tue Oct 29, 2013 5:40 pm

This is a one man work, and I have not much time to dedicate to it, so cutting branches less interesting is a must in order to have the project continuing. Maintaining different branches is really painful, and rises a lot the number of bug, lowering at the same time the testing time for each branch

In addition, to simplify things in the development I made quite a big change: the core of the library is now pure Java and can be used everywhere (a desktop application, and android application without AndEngine, or one with AndEngine).
This makes far easier to develop it and write tests for it, but would have been a pain to support the extension for both the branches. This should also make it easier for external developers to jump in, since it is now pure Java and you do not need to know AndEngine to work on it. But if you need to use the library for a different version of AndEngine you now have just to rewrite the interfacing layer to the CollisionCore library.

The AndEngine extension morphed in just an adapting layer over the library. As you can see it is just a few classes now.

Due to a lack of fantasy and the fact that the correct name is one (Shakespeare says that a rose smells like a rose even if you call it some other name, but the code do not smells and in order to make people who read it understand it you must call the rose "rose"), AndEngine and CollisionCore have some classes which share the same names.
This is quite a bad thing if you do not know Java, since you must be wary of the namespaces of the classes.
The best (worst?) example can be seen in https://github.com/MakersF/AndEngineCol ... apter.java and https://github.com/MakersF/AndEngineCol ... apter.java , where I had to fully reference the classes in order not to have collisions in names, so this can lead to some confusion. Be on alert when you navigate this files, as just modifying imports can give problems.

Right now the code is absolutely not production ready! This is a preliminary work as I will use it in a project of mine, but I'm still not at the point to add collision detection.

The "real" library is CollisionCore, so if some method is missing in the AndEngine do not hesitate to extend the class and add it. As I will start to use it in my project some useful methods may arise in the classes, but as it is now it should do the basic work anyway.

On the other side, I know there is really little documentation. For the CollisionCore library I'm going to add unit-testing to it, so you'll be able to look at them to get how the code works.
Once I have the data do be sure there is no error on the CollisonCore library part I can look into AndEngine extension (i can not work on it before because it depends on the first, and if the first has bugs it is almost impossible to fix things in the second. For example it could help me understand what the problem is in this issue)

For the AndEngine binding though looking at the classes should be fairly easy to get how it works, so if you find yourself using the library please don't feel limited by it, and expand it as you need: this is quite standard in the game industry, rarely the engine for a game is unmodified.

Btw note that i have really little time, so usually at least try to solve the problems you face before opening issues, since i'll take some time before even looking at them, and if you open them, fill with the easiest code you can wrote which show the error, and put in it the log file and all the relevant messages.
Discussing problems here and asking for other's help here is indeed a good solution too, thought :)

Hope this explains a bit the situation, and maybe stimulates someone to contribute to the project, which is not mine, but of everyone who needs it! :D
makers-f
 
Posts: 36
Joined: Sat Sep 17, 2011 6:11 pm

Re: Pixel Perfect Collision Detection Extension

Postby Dantel » Tue Oct 29, 2013 7:34 pm

Hi makers-f, I completly understand that you do not want to develop on multiple branches. What I meant is letting the existing code (which supports the things you are not interested in to develop further) online, creating a new branch for your current work and giving no support for the old one. Just like Nicolas is doing it with GLES1 (and apparantly with GLES 2). This way people can use existing work and base their work on it.

I respect your decision, it is your project. I simply do not understand why it is necessary to completly throw away already working code (sorry if you didn't, it just looks like it for me looking through your gitHub). I am not using it so it is not very important to me, but I already found lots of other stuff I could reuse this way and just thought it is too bad when this possibility vanishes. But as said, it is your project and of course you can do whatever you want :). Big thanks for sharing anyway. Maybe the time will come for me to use AC and there will be use for pixelperfect collision :D.
Come over to the new AndEngine forum! Don't stay here with all this spam.
andengine-community.com
(alternative domain still works: http://andengine.bbforum.co)
User avatar
Dantel
 
Posts: 246
Joined: Mon Jan 07, 2013 12:00 pm

Re: Pixel Perfect Collision Detection Extension

Postby makers-f » Tue Oct 29, 2013 9:20 pm

Yes, indeed this was a bad thing, which happened because there wasn't a good study plan before starting to code!
Unfortunately I don't have that code any more, but if you want to put it on a github project I'll link your project in the readme.

On the other hand, due to how the project is now structured, you can simply use https://github.com/MakersF/AndEngineCol ... GLES1.java instead of https://github.com/MakersF/AndEngineCol ... GLES2.java and this will (should. Haven't tested it) work for GLES2 non anchorcenter (i probably should rename it :D )
makers-f
 
Posts: 36
Joined: Sat Sep 17, 2011 6:11 pm

Re: Pixel Perfect Collision Detection Extension

Postby Dantel » Wed Oct 30, 2013 8:13 am

Yes, indeed this was a bad thing, which happened because there wasn't a good study plan before starting to code!

^^, sounds like something that could happen to me. Completly understandable.

I do not have a working copy of the old code as well, but I will test your suggestion asap (as said I do not need it right now, but just for the fun of it :D).

Keep up the gread work :star:
Come over to the new AndEngine forum! Don't stay here with all this spam.
andengine-community.com
(alternative domain still works: http://andengine.bbforum.co)
User avatar
Dantel
 
Posts: 246
Joined: Mon Jan 07, 2013 12:00 pm

Re: Pixel Perfect Collision Detection Extension

Postby fai » Thu Oct 31, 2013 2:13 pm

Got this error:
import com.makersf.frameworks.shared.collisioncore.pixelperfect.masks.implementations.BitmapPixelPerfectMask;
import com.makersf.frameworks.shared.collisioncore.pixelperfect.masks.implementations.IBitmap;
in extension...
fai
 
Posts: 32
Joined: Fri Sep 27, 2013 8:42 am

Re: Pixel Perfect Collision Detection Extension

Postby caoanhhao » Thu Feb 27, 2014 10:36 am

i download from githud source code.
+AndEngine GLES2 Anchor center
+AndEngineCollisionsExtension
+CollisionCore
+CollisionTest
Import it got error in Class MainActivity.java of project Collision Test.

private PixelPerfectSprite star2;

PixelPerfectCollisionChecker.checkCollsion((IShape) star2, star2.getPixelPerfectMask(), stressPoint);
star2 can't cast to IShape (com.makersf.frameworks.shared.collisioncore.pixelperfect.IShape).
Class PixelPerfectSprite extends Class Sprite of andengine. And Class Sprite extend Class IShape of andengine.

Sure it can't cast.
Anyone show me my mistake please.
And show me how to use this extension.
sorry my english. :)
caoanhhao
 
Posts: 3
Joined: Wed Feb 12, 2014 11:43 am

Re: Pixel Perfect Collision Detection Extension

Postby caoanhhao » Tue Mar 04, 2014 10:27 am

i solved my problem.
Thank for makers-f and McGrey help.
dowload andengine GLES 2 in here : https://github.com/nicolasgramlich/AndEngine
download AndEngineCollisionsExtension, CollisionCore, CollisionTest in here: https://github.com/MakersF
do follow these step

Step 1:

- import porject
Andengine GLES 2
AndEngineCollisionsExtension
CollisionCore
CollisionTest
link source CollsionCore to AndEngineCollisionsExtension

Step 2: edit AndEngineCollisionsExtension source code (Search those class)

-class ShapeAdapter: cast mShape to IAreaShape
line 28: return ((IAreaShape) mShape).getWidth();
line 33: return ((IAreaShape) mShape).getHeight();
-class PixelPerfectAnimatedSprite: cast pOtherShape to IAreaShape
line 104: reusableRectangularPixelPerfectMask.setTo((int) ((IAreaShape)pOtherShape).getWidth(), (int) ((IAreaShape)pOtherShape).getHeight());
-class PixelPerfectSprite : cast pOtherShape to IAreaShape
line 83: reusableRectangularPixelPerfectMask.setTo((int) ((IAreaShape)pOtherShape).getWidth(), (int) ((IAreaShape)pOtherShape).getHeight());

Step 3 edit CollisionTest source code

-class MainActivity
line 76: this.starRegion = PixelPerfectTextureRegionFactory.createFromAsset(diamondTexture, this.getAssets(), "star.png", 0, 0, ALPHA_THERSHOLD);
line 78: this.trireg = PixelPerfectTextureRegionFactory.createTiledFromAsset(diamondTexture, this.getAssets(), "spinning-triangle.png", 0, 200, 20, 1, 0);
line 257, 272: spriteCollisionLog.printStatistics();
line 267: int collisionResult3 = PixelPerfectCollisionChecker.checkCollsion(new ShapeAdapter(star2), star2.getPixelPerfectMask(), pointsVerts);
line 279: PixelPerfectCollisionChecker.checkCollsion(new ShapeAdapter(star2), star2.getPixelPerfectMask(), stressPoint);

Run project.
caoanhhao
 
Posts: 3
Joined: Wed Feb 12, 2014 11:43 am

PreviousNext

Return to Features

Who is online

Users browsing this forum: Google [Bot] and 5 guests