2d sprite that interact with 3d object
2d sprite that interact with 3d object
Hi to all,
this is my 1st post on forum of, for me, the best open 3d engine!
I have a question (i think that someone have developed some like this) ..
What is the best way in Irrlicht to create a 2d animated sprite that interact with the 3d objects (and other for sure 2d objects too)?
Fast Example: a 2d astro ship that collide with 3d asteroids.
In other words i must create the sprite as a billboard or exist any extension for this?
Also why i must define in each 2d sprite the collide zone (box or circle) ... for sure collition cannot be always on whole object!
What you think about?
Thanks a lot for attentions and see ya!
this is my 1st post on forum of, for me, the best open 3d engine!
I have a question (i think that someone have developed some like this) ..
What is the best way in Irrlicht to create a 2d animated sprite that interact with the 3d objects (and other for sure 2d objects too)?
Fast Example: a 2d astro ship that collide with 3d asteroids.
In other words i must create the sprite as a billboard or exist any extension for this?
Also why i must define in each 2d sprite the collide zone (box or circle) ... for sure collition cannot be always on whole object!
What you think about?
Thanks a lot for attentions and see ya!
Hi to all again..
after a long search and search .. i have found a very interesting post by Emil_Halim at:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6471
It's exactly what i'm looking for.
I have some questions:
with this method, i can handle the collision detection like a polygon?
but the whole poligon or also a defined portion?
You have an example code for the collision of this "simulated" 2d?
Thanks a lot
Bye
after a long search and search .. i have found a very interesting post by Emil_Halim at:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6471
It's exactly what i'm looking for.
I have some questions:
with this method, i can handle the collision detection like a polygon?
but the whole poligon or also a defined portion?
You have an example code for the collision of this "simulated" 2d?
Thanks a lot
Bye
Please i need some advices or examples about.
I have created a bsp background and binded with Newton phys library.
Now i wanna create some 2d animated sprites that i can move and these sprites can interact with the backgrond and physics.
... so i have choosen the billboards textured with the sprites.
Now i wanna ask you .. it's a good choise? what is the best for you?
There is a good example (or other thread) of my explained problem?
Please let me know some about also your opinion.
Thanks a lot .. and see you soon.
I have created a bsp background and binded with Newton phys library.
Now i wanna create some 2d animated sprites that i can move and these sprites can interact with the backgrond and physics.
... so i have choosen the billboards textured with the sprites.
Now i wanna ask you .. it's a good choise? what is the best for you?
There is a good example (or other thread) of my explained problem?
Please let me know some about also your opinion.
Thanks a lot .. and see you soon.
-
Emil_halim
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
hi nasty
could you explain a bit more please.
what kind of interaction that you wont your sprite with backgrond?
what exactlly you want yor sprite do ?
may be i could help you.
could you explain a bit more please.
what kind of interaction that you wont your sprite with backgrond?
what exactlly you want yor sprite do ?
may be i could help you.
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/
Ah! finally a reply about my problem! and also by the guru Emil Halim (i read much your useful posts)!
My problem is this...
I have created a bsp background and i have used also the newton library to recreate physics effects.
My initial idea is to put 2 main 2d sprites (like a fight game) and no 3d (this is my idea)!
Now i need to "manipulate" these 2d sprites as 3d (to put in this "world") so i choose (for now) the node rotatebillboard.
I wanna now ask this:
1- i do a right choice using rotatebillboard? or there is a better solution for animated sprites?
2- i used physic library why i wanna also that the 2d sprites (the billboards) are affected, at least by gravity.
how can i bind the billboards to the newton library if can be done this?
I hope that now is much clear.
Thanks a lot and see you soon ..
My problem is this...
I have created a bsp background and i have used also the newton library to recreate physics effects.
My initial idea is to put 2 main 2d sprites (like a fight game) and no 3d (this is my idea)!
Now i need to "manipulate" these 2d sprites as 3d (to put in this "world") so i choose (for now) the node rotatebillboard.
I wanna now ask this:
1- i do a right choice using rotatebillboard? or there is a better solution for animated sprites?
2- i used physic library why i wanna also that the 2d sprites (the billboards) are affected, at least by gravity.
how can i bind the billboards to the newton library if can be done this?
I hope that now is much clear.
Thanks a lot and see you soon ..
-
Emil_halim
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
i did not use newton library from before , so i do not know about it ,but if you want that lib for only simulating gravity effects ,so i think you went in a wrong way.
first you need a 2D collision system it is more better than of 3D collision system, i mean you need Pixle to Pixle collision detection.
socand using billboard does not enable 2D collision detection so using it does not make sence.
simulating gravity effects could be done by a math furmela , sreach the net for that furmela.
if you do not mind, send me your 2Sprites by PM , and i will try to make it with my Magic library then send the results back to you.
first you need a 2D collision system it is more better than of 3D collision system, i mean you need Pixle to Pixle collision detection.
socand using billboard does not enable 2D collision detection so using it does not make sence.
simulating gravity effects could be done by a math furmela , sreach the net for that furmela.
if you do not mind, send me your 2Sprites by PM , and i will try to make it with my Magic library then send the results back to you.
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/
-
Emil_halim
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
Hi
bye the way , yore 2D sprites espcially the punch one are not alinment correctly so the animation does not displyed correctly.
so here is a screensoht of what i have done so far , there is no collison detection yet.

here is the source code with may Magic Library
download a working test from here
http://bcxdx.spoilerspace.com/BCXGL/2d_sprite_on_3d.zip
please let me kow your opinion.
Bey
bye the way , yore 2D sprites espcially the punch one are not alinment correctly so the animation does not displyed correctly.
so here is a screensoht of what i have done so far , there is no collison detection yet.
here is the source code with may Magic Library
Code: Select all
/************************************
2d sprite on 3d test
By Emil Halim
*************************************/
#include <MagicIncludes.h>
// global declration of Irrlicht interfaces
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
bool ProgramRun;
int main()
{
device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32);
bool rslt = InitMagic(device);
if(rslt == false)
printf("Magic Library will only work with OpenGL driver");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
//3D stuff
//device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3");
device->getFileSystem()->addZipFileArchive("media/map-20kdm2.pk3");
scene::IAnimatedMesh* mesh = smgr->getMesh("20kdm2.bsp");
scene::ISceneNode* node = 0;
if (mesh)
node = smgr->addOctTreeSceneNode(mesh->getMesh(0));
if (node)
node->setPosition(core::vector3df(-1300,-144,-1249));
node->setMaterialFlag(EMF_LIGHTING, false);
smgr->addCameraSceneNode();
//IAnimatedMesh* mesh2 = smgr->getMesh("../../media/sydney.md2");
IAnimatedMesh* mesh2 = smgr->getMesh("media/sydney.md2");
IAnimatedMeshSceneNode* node2 = smgr->addAnimatedMeshSceneNode( mesh2 );
if (node2)
{
node2->setMaterialFlag(EMF_LIGHTING, false);
node2->setMD2Animation ( scene::EMAT_STAND );
//node2->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp") );
node2->setMaterialTexture( 0, driver->getTexture("media/sydney.bmp") );
node2->setScale(core::vector3df(0.6f,0.6f,1.0));
node2->setPosition(core::vector3df(-10,0,-10));
}
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
TAnimImage* RyuStand = new TAnimImage();
//RyuStand->Load("../../MagicLibrary/media/ryu1.bmp",0,0,87*9,128*2,87,128);
RyuStand->Load("media/ryu1.bmp",0,0,87*9,128*2,87,128);
RyuStand->setStartEndFrame( 0, 9);
RyuStand->FlipX(true);
RyuStand->setSpeed(150);
TAnimImage* RyuPunch = new TAnimImage();
//RyuPunch->Load("../../MagicLibrary/media/ryu2.bmp",180,0,89*7,120*2,89,120);
RyuPunch->Load("media/ryu2.bmp",180,0,89*7,120*2,89,120);
RyuPunch->setStartEndFrame( 0, 8);
RyuPunch->FlipX(true);
RyuPunch->setSpeed(150);
HideMouse();
ProgramRun = true;
int lastFPS = -1;
while(device->run()&& ProgramRun)
{
driver->beginScene(true, true, SColor(0,0,0,0));
if(KeyDown(KEY_ESCAPE))ProgramRun=false;
smgr->drawAll();
ViewOrtho();
SetBlend(ALPHABLEND);
SetColor(255,255,255);
SetAlpha(1.0);
SetScale(2.0,2.0);
if(MouseLeftKeyDown())
{
RyuPunch->Update();
RyuPunch->Draw(340,300);
}
else
{
RyuStand->Update();
RyuStand->Draw(400,300);
}
ViewPerspective();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
wchar_t tmp[1024];
swprintf(tmp, 1024, L"2d sprite on 3d test (%s)(fps:%d)",driver->getName(), fps);
device->setWindowCaption(tmp);
lastFPS = fps;
}
}
device->drop();
return 0;
}
http://bcxdx.spoilerspace.com/BCXGL/2d_sprite_on_3d.zip
please let me kow your opinion.
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/
really thanks Emil,
it's exactly what i'm trying to say!
Your library is really great for 2d manipulations inside the Irrlicht, have much good useful functions (start/end frame, flipx, speed .. very good).
It's a kind of SDL (that i used previously .. before pass to 3d) inside the irrlicht.
Now i wanna ask you:
- have you plan (or you have just coded) some collision detections routines? i have done on SDL some test using rectangles and also circles collition detection (overlayed on a single frame of animation) .. i think that circles is much fast (a single pitagora's funct and you have the delta .. if >0 collide!);
Or you obtain for the pixel to pixel solution?
- you library .. can be used both for GL and DX9 ? what version of your library i must use for this?
- will be your lib, multiplatform? not strictly used on win machines?
Very thanks a lot for your USEFUL help.
it's exactly what i'm trying to say!
Your library is really great for 2d manipulations inside the Irrlicht, have much good useful functions (start/end frame, flipx, speed .. very good).
It's a kind of SDL (that i used previously .. before pass to 3d) inside the irrlicht.
Now i wanna ask you:
- have you plan (or you have just coded) some collision detections routines? i have done on SDL some test using rectangles and also circles collition detection (overlayed on a single frame of animation) .. i think that circles is much fast (a single pitagora's funct and you have the delta .. if >0 collide!);
Or you obtain for the pixel to pixel solution?
- you library .. can be used both for GL and DX9 ? what version of your library i must use for this?
- will be your lib, multiplatform? not strictly used on win machines?
Very thanks a lot for your USEFUL help.
-
Emil_halim
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
Hi
Magic Library already has a 2D collision detiction.
here is a 2 ScreenShots of 2 examples ,the first one is simple and the other is more complicated.


collision detiction done by TMaskCollision class, here is the prototype of it
so there are a Box-to-Box & Pixel-to-Pixle collision
Magic library only works with OpneGl , there is an old and out of date DX versrion , and i will not make Dx version on the future.
it has many functions that rely on windows system , so it is for window only.
by 2 days , i will upload a new version of My Magic Library.
Bey.
Edited:
i have fixed your second sprite so download it and replace it with previous test
http://bcxdx.spoilerspace.com/BCXGL/ryu2.bmp
& replace with the next line
Magic Library already has a 2D collision detiction.
here is a 2 ScreenShots of 2 examples ,the first one is simple and the other is more complicated.


collision detiction done by TMaskCollision class, here is the prototype of it
Code: Select all
class DLL_EXPORT TMaskCollision
{
u32* mask;
IImage* img;
u32 width,height;
u32 HafeWidth;
u32 HafeHeight;
SMaterial dot;
bool IsAnimImage;
s32 frmWidth,frmHeight;
s32 stepww;
public:
TMaskCollision();
void Create(char* file);
void Create(char* file,s32 fWidth,s32 fHeight);
u32 getPixel(s32 x,s32 y);
u32 getPixel(s32 x,s32 y,s32 frame);
bool CheckPointCollide(f32 Px1,f32 Py1,f32 x2,f32 y2);
bool CheckPointCollide(f32 Px1,f32 Py1,f32 x2,f32 y2,s32 frame);
bool CheckPixelCollide(TMaskCollision* other,f32 other_x,f32 other_y,f32 x2,f32 y2);
bool CheckPixelCollide(TMaskCollision* other,f32 other_x,f32 other_y,f32 x2,f32 y2,s32 frame);
bool CheckBoxCollide(TMaskCollision* other,f32 other_x,f32 other_y,f32 x2,f32 y2);
bool CheckBoxCollide(TMaskCollision* other,f32 other_x,f32 other_y,f32 x2,f32 y2,s32 frame);
void DrawDebugMask(f32 x,f32 y);
};
Magic library only works with OpneGl , there is an old and out of date DX versrion , and i will not make Dx version on the future.
it has many functions that rely on windows system , so it is for window only.
by 2 days , i will upload a new version of My Magic Library.
Bey.
Edited:
i have fixed your second sprite so download it and replace it with previous test
http://bcxdx.spoilerspace.com/BCXGL/ryu2.bmp
& replace with the next line
Code: Select all
RyuPunch->Load("../../MagicLibrary/media/ryu2.bmp",0,0,115*7,120*2,115,120);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/
Hi Emil,
thanks a lot for your useful advices about my problem.
I found very useful your BCXDX_Irrlicht (CAnimSprite class) .. i have added to my project and works both for DX and GL version.
Now i need to code the collition class .. your Collision.h of MagicLibrary class is inside the .lib!
Very thanks a lot again for your help.
thanks a lot for your useful advices about my problem.
I found very useful your BCXDX_Irrlicht (CAnimSprite class) .. i have added to my project and works both for DX and GL version.
Now i need to code the collition class .. your Collision.h of MagicLibrary class is inside the .lib!
Very thanks a lot again for your help.
----------------------------------------------
Free or Not-Free ?? Choose Wisely!!!
----------------------------------------------
'NaSTy'
----------------------------------------------
Free or Not-Free ?? Choose Wisely!!!
----------------------------------------------
'NaSTy'
----------------------------------------------