cant find any good collision detection for 2d grafics
cant find any good collision detection for 2d grafics
Hi, I've almost spent two hours searching the forum for an answer to this...I'm looking for a way to do 2d collision detection pixel by pixel...or any other method, all the topics are about 3d collision detection, but I'm using 2d grafix, I've made some primitive collision detection, but I'm not happy with it, I think there should be a better aproach to this...any recomendations please?
I've come in peace, but you'll go in pieces!
I used this for a 2D game in flash. but you could take the concepts.
Its called seperating axis theorem or something like that.
http://www.harveycartel.org/metanet/tut ... rialA.html
Its called seperating axis theorem or something like that.
http://www.harveycartel.org/metanet/tut ... rialA.html
Thanks, but...
Thanks dude, but does irrlicht has support for this? or do I have to write my own function for this?
btw, my textures are all together withing 1 bitmap, I know that you can use a function called getPixel(s32,s32) to obtain the size in pixels of a IImage, I load the whole bitmap inside this image, and the draw it with a rect, so I'm clipping a portion of this file...so what I want is to the the size in pixels of this clipped image, how can you do this?...I think this is the only thing that is keeping me from doing a collision detector function myself...
btw, my textures are all together withing 1 bitmap, I know that you can use a function called getPixel(s32,s32) to obtain the size in pixels of a IImage, I load the whole bitmap inside this image, and the draw it with a rect, so I'm clipping a portion of this file...so what I want is to the the size in pixels of this clipped image, how can you do this?...I think this is the only thing that is keeping me from doing a collision detector function myself...
I've come in peace, but you'll go in pieces!
RE:
It sounds like you want more functions for 2d. There are three options:
1. If you go to irrlicht.sourceforge.net and click links, scroll to the bottom of the page and you will find sites that have add-on classes for 2d graphics, including collision detection. The only thing is that these require windows and are using the windows gdi ( really, really slow compared to directX. )
2. Use sdl(http://www.libsdl.org) with Irrlicht. There are tutorials of how to do this already in the forum. Sdl is a low-level 2d library which provides what you are looking for. A steeper learning curve than Allegro but much more control and faster.
3. Make your own class! It is really not that difficult using the windows gdi for example. However, try options 1 and 2 first since these are the easiest. I found many add-classes already which I use. I haven't tried sdl but I think this could be excellent. Just experiment to find out what works best for you.
I hope this has been helpful!
NOTE: by the way, why do you want pixel collision detection?
1. If you go to irrlicht.sourceforge.net and click links, scroll to the bottom of the page and you will find sites that have add-on classes for 2d graphics, including collision detection. The only thing is that these require windows and are using the windows gdi ( really, really slow compared to directX. )
2. Use sdl(http://www.libsdl.org) with Irrlicht. There are tutorials of how to do this already in the forum. Sdl is a low-level 2d library which provides what you are looking for. A steeper learning curve than Allegro but much more control and faster.
3. Make your own class! It is really not that difficult using the windows gdi for example. However, try options 1 and 2 first since these are the easiest. I found many add-classes already which I use. I haven't tried sdl but I think this could be excellent. Just experiment to find out what works best for you.
I hope this has been helpful!
NOTE: by the way, why do you want pixel collision detection?
Thanks
Thanks for the link, I'm already checking it out , and I need pixel c d, because I'm using a 2d irregular terrain...I'm using a circle for now, but I'm planning into adding another shapes, I'm just experimenting, and I don't want that my circle detects a collision just because the box around it collided with the terrain....
why do you ask? is there some kind of problem or greater bug probability with pixel collision detection?....
why do you ask? is there some kind of problem or greater bug probability with pixel collision detection?....
I've come in peace, but you'll go in pieces!
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
Re: cant find any good collision detection for 2d grafics
are you search in Project Announcements forum ,if yes , you must have seen my magic library.Cold_Dog wrote:Hi, I've almost spent two hours searching the forum for an answer to this...I'm looking for a way to do 2d collision detection pixel by pixel...or any other method,
any way
my library has meny meny functions those extend the 2D and 3d of irrlicht, it has a 2D Pixle by pixle collesion detection ....
chech my site for more information
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
Re: cant find any good collision detection for 2d grafics
I saw one or two posts about the magic library, but I only found code that I couldnt get to work hehe, because it was in pieces...So I couldnt figure out where to paste what...heheh, I saw a post with a link to download the magic library, but it was broken...but anyway, I'm checking out you page now, many thanks ;=)Emil_halim wrote:are you search in Project Announcements forum ,if yes , you must have seen my magic library.Cold_Dog wrote:Hi, I've almost spent two hours searching the forum for an answer to this...I'm looking for a way to do 2d collision detection pixel by pixel...or any other method,
any way
my library has meny meny functions those extend the 2D and 3d of irrlicht, it has a 2D Pixle by pixle collesion detection ....
chech my site for more information
I've come in peace, but you'll go in pieces!
not working
Hey there, I couldn't get the magic library to work...also I can't find any tutorials or help/reference files about how to use it....the examples don't run in my computer, I don't know if it is a problem of mine, but after setting everything for the project to run, the compiler shows an error about some kind of function that doesn't exist in the irrlicht.dll.
Why is this happening? does the magiclibrary only works in older versions of irrlicht?...where can I find some help for making it to work?
Why is this happening? does the magiclibrary only works in older versions of irrlicht?...where can I find some help for making it to work?
I've come in peace, but you'll go in pieces!
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
if you read the information in download page in my site , you must notice how to install it in your system and run examples well, also there is a tutorial that alows you how to compile examples in tutorial page.
any way.
latest Magic library was compiled with Irrlicht version 1.1,and note well ,it only work with openGl.
so what version of irrlicht that you are using , if is the layesy SVN one so it will does not work with it.
i am waiting for Irr 1.2 and i will integrated Magic Library with Irrlicht DLL and also i will remove the DX stuff from it for reduce the unused code.
if this words did not help you , post those functions that you have mentioned.
any way.
latest Magic library was compiled with Irrlicht version 1.1,and note well ,it only work with openGl.
so what version of irrlicht that you are using , if is the layesy SVN one so it will does not work with it.
i am waiting for Irr 1.2 and i will integrated Magic Library with Irrlicht DLL and also i will remove the DX stuff from it for reduce the unused code.
if this words did not help you , post those functions that you have mentioned.
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
Hey there
Hey Emil, I saw the tutorial in your page, I have every bit of help I found in your web stored in my pc, I followed every step to setup my Dev-cpp 4.9.9.2 as said in the tutorial, and did everything that it said to compile and run the examples...but it didn't work...I don't know why? I couldn't figure it out...I got tired of trying to make it run...
This is the error I'm getting when I try to compile the example...
I would really appreciate any help, I think that this library is pretty powerfull...I'm really looking forward to use it...
This is the error I'm getting when I try to compile the example...
Code: Select all
Compiler: Default compiler
Building Makefile: "C:\irrlicht-1.1\MagicLibrary\Makefile.win"
Executing make clean
rm -f Examples/2Dcollision/collideExample/main.o Collision2d.exe
g++.exe -c Examples/2Dcollision/collideExample/main.cpp -o Examples/2Dcollision/collideExample/main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/irrlicht-1.1/include" -I"C:/irrlicht-1.1/MagicLibrary/Includes" -I"C:/irrlicht-1.1/MagicLibrary/Includes/Cg" -I"C:/irrlicht-1.1/MagicLibrary/Includes/GL"
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:139:1: warning: "GL_FALSE" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:89:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:140:1: warning: "GL_TRUE" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:88:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:340:1: warning: "GL_ZERO" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:76:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:341:1: warning: "GL_ONE" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:77:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:396:1: warning: "GL_LOGIC_OP" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:668:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:435:1: warning: "GL_NONE" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:110:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:628:1: warning: "GL_TEXTURE_COMPONENTS" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:669:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/gl/glu.h:6,
from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:17,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/Dev-Cpp/include/GL/gl.h:663:1: warning: "GL_NO_ERROR" redefined
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:16,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/gl/gl.h:125:1: warning: this is the location of the previous definition
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:85,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/ImageTexture.h:61:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:86,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Movie.h:93:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:87,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/BlitzMax.h:81:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:88,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Basic4GL.h:42:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:89,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/GifImage.h:44:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:90,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Mouse_KeyBoard.h:30:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:91,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Ttime.h:36:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:92,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Splash.h:28:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:93,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Animated_Image.h:58:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:94,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Texture_Manipulator.h:71:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:96,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/random.h:20:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:97,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Collision.h:45:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:98,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Amiga.h:106:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:99,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/capture.h:36:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:100,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/shader.h:48:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:101,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/CGshader.h:51:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:102,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/MagicSceneNode.h:43:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:103,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/TextSceneNode.h:39:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:104,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/CharSceneNode.h:38:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:105,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/AnimImageSceneNode.h:66:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:107,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/TBaseMagicMesh.h:69:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:108,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/TMagicMesh.h:103:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:111,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/DDSloader.h:249:50: warning: multi-character character constant
C:/irrlicht-1.1/MagicLibrary/Includes/DDSloader.h:252:55: warning: multi-character character constant
C:/irrlicht-1.1/MagicLibrary/Includes/DDSloader.h:255:55: warning: multi-character character constant
C:/irrlicht-1.1/MagicLibrary/Includes/DDSloader.h:380:8: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:112,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Movement.h:58:7: warning: no newline at end of file
In file included from C:/irrlicht-1.1/MagicLibrary/Includes/MagicIncludes.h:113,
from Examples/2Dcollision/collideExample/main.cpp:7:
C:/irrlicht-1.1/MagicLibrary/Includes/Geo_Math_Lib.h:176:7: warning: no newline at end of file
Examples/2Dcollision/collideExample/main.cpp: In function `int main()':
Examples/2Dcollision/collideExample/main.cpp:123: error: invalid conversion from `int' to `const wchar_t*'
Examples/2Dcollision/collideExample/main.cpp:123: error: initializing argument 2 of `int swprintf(wchar_t*, const wchar_t*, ...)'
make.exe: *** [Examples/2Dcollision/collideExample/main.o] Error 1
Execution terminated
I've come in peace, but you'll go in pieces!
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
Ok Cold_Dog,
i was having this problem with g++ and i did not seccess to figure it out.
but the simple selution is to comment the next line
the other warning, there is a duplicated some symbol , try to comment it and the warning: no newline at end of file
try to ereas the last line in the include headers files
feel free to ask again
bey
i was having this problem with g++ and i did not seccess to figure it out.
but the simple selution is to comment the next line
Code: Select all
// swprintf(tmp, 1024, L"Collision 2D test (%s)(fps:%d)",driver->getName(), fps);
try to ereas the last line in the include headers files
feel free to ask again
bey
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
hey
Hi Emil...I figured out how to compile the files and managed to run some of them....casually I found that erasing the line that included swprintf something... before reading this topic hehehe, by the way, I solved the warning problems by writing the whole path for the include files inside every header...eg....you wrote in a header cg/cg.h or something...so I wrote c:\irrlihcht-1.1\magiclibrary\includes\cg\cg.h...and so on in every include line...I also knew about the problem of the last line...the same happens when you open a .cpp file made using visual c++, in dev-cpp...I don't know what is the problem...but maybe you should try to not using so many features of your compiler/IDE and make the files more general...I dont know ...but some features that works in your system, may not work in others...you get the point now I'm trying to figure out how to make collision detection and that kind of stuff...
by the way...in the collide example, the one that you shoot sonic with a proyectile and he explodes when he's hit...there is some kind of bug...you create the explosion at the position where the missile hits the target...but when you shoot or try to shoot another missile right after the collision happens, the image of the explosion moves to the position of the new missile...I think that creating temporary positions at the time of the collision, and then drawing the explosion at these two new positions, might solve the problem...I haven't try it out...but it may work anyway, thanks....you've done a great job!
by the way...in the collide example, the one that you shoot sonic with a proyectile and he explodes when he's hit...there is some kind of bug...you create the explosion at the position where the missile hits the target...but when you shoot or try to shoot another missile right after the collision happens, the image of the explosion moves to the position of the new missile...I think that creating temporary positions at the time of the collision, and then drawing the explosion at these two new positions, might solve the problem...I haven't try it out...but it may work anyway, thanks....you've done a great job!
I've come in peace, but you'll go in pieces!