Page 1 of 1

Box2d Wrapper

Posted: Sun Apr 13, 2008 8:48 am
by monkeycracks
Well, considering Irrlicht is used primarily for 3d purposes, I doubt that this will be useful to anyone. Here is my simple Box2d wrapper for Irrlicht. I guess I'll call it IrrBox2d just to be like everyone else

Example:

Code: Select all

#include <IrrBox2d.h>

using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;

#pragma comment(lib, "IrrBox2d.lib")
#pragma comment(lib, "Irrlicht.lib")

int main()
{
	IrrlichtDevice* dvc = createDevice(EDT_OPENGL, dimension2d<s32>(800, 600));
	IVideoDriver* drv = dvc->getVideoDriver();
	IWorld* w = createWorld(dvc, 1.0f, dimension2d<s32>(800, 600));
	IEntityManager* em = w->getEntityManager();

	em->createStaticEntity(position2d<s32>(5, 500), drv->getTexture("platform.png"));
	em->createDynamicEntity(position2d<s32>(5, 5), 1.0f, 0.3f, drv->getTexture("red.png"));
	em->createDynamicEntity(position2d<s32>(5, 305), 1.0f, 0.3f, drv->getTexture("green.png"));
	
	while(dvc->run())
	{
		drv->beginScene(true, true, SColor(0, 0, 0, 0));
		w->update(1.0f / 60.0f, 10);
		drv->endScene();
	}
	
	w->remove();
	delete w;
	return 0;
}
Suggestions are welcome. I probably left some things out of the code by mistake or just did things in an ugly way. Feel free to comment on it.

Download link

Posted: Sun Apr 13, 2008 9:18 am
by Halifax
That's pretty cool monkeycracks, have you ever thought of trying to integrate that with PhoenixGL. :lol:

A great wrapper, but it would be cool to see some more interesting demos.

Posted: Sun Apr 13, 2008 9:19 am
by monkeycracks
Sorry I just got finished and was really excited. I'll make something more appealing later.

Edit: Only made it with Irrlicht because my next probably-going-to-be-deleted project is using it.

Posted: Sun Apr 13, 2008 9:20 am
by Halifax
monkeycracks wrote:Sorry I just got finished and was really excited. I'll make something more appealing later.

Edit: Only made it with Irrlicht because my next probably-going-to-be-deleted project is using it.
Ah, okay. Care to talk about that project? :D

Posted: Sun Apr 13, 2008 9:21 am
by monkeycracks
Some ridiculous game where animals with ridiculous proportions blow each other up. 2d. Kinda like Worms except with cats, dogs, and probably cows.

Edit!
Ouch, just realized I can't rotate 2d images with Irrlicht unless I code something which will be ridiculously annoying.

Time to start, get frustrated, and switch to the engine you sent

Edit2:
Updated solution file to not be broken

Posted: Sun Apr 13, 2008 9:57 am
by monkeycracks
If anyone's interested I'll extend this project, but I'm done with it for now.

Posted: Sun Apr 13, 2008 11:16 am
by Halifax
Yeah, not to sway you or anything, but you would get direct support from myself, and Jon, on any of your questions about PhoenixGL, if you used that.

Posted: Sun Apr 13, 2008 11:23 am
by monkeycracks
Yeah I'll probably go with that sooner or later. I haven't slept in forever though so I need to rejuvenate.

Posted: Fri Apr 18, 2008 4:33 am
by monkeycracks
Well I was going to attempt to pick this up since I was enlightened with this post : http://irrlicht.sourceforge.net/phpBB2/ ... gerotation

But I can't seem to get it to work. Here is my test application.. Using latest SVN

Code: Select all

#include <Irrlicht.h>

#pragma comment(lib, "Irrlicht.lib")

using namespace irr;
using namespace core;
using namespace video;

int main()
{
	IrrlichtDevice* dvc = createDevice(EDT_OPENGL);
	IVideoDriver* drv =  dvc->getVideoDriver();

	ITexture* tex = drv->getTexture("red.png");

	while(dvc->run())
	{
		drv->beginScene(true, true, SColor(0, 0, 0, 0));

		drv->draw2DImageRotation(tex, rect<s32>(50, 50, 82, 82), rect<s32>(0, 0, 32, 32), 0, 1, SColor(255, 255, 255, 255), false);
		///drv->draw2DImage(tex, rect<s32>(50, 50, 82, 82), rect<s32>(0, 0, 32, 32));

		drv->endScene();
	}

	dvc->drop();

	return 0;
}
It still says the image is loaded, but it only draws if I use the commented out function instead of the new one.

Posted: Fri Apr 18, 2008 6:41 am
by BlindSide
Check out the sources for the Magic2D library (Somewhere on this forum.)

Posted: Fri Apr 18, 2008 11:26 am
by monkeycracks
Unfortunately it looks like I'll have to downgrade to Irrlicht v1.1 to use it. This should be fine though since I'll mostly only be using 2d functions. Sample application crashes with latest SVN so I'll try 1.1 when I get home.

Hopefully I can get this to work, I really haven't enjoyed my adventures with HGE so far :|

Posted: Fri Apr 18, 2008 12:16 pm
by FuzzYspo0N
seeing the source would be for modding yours to have extra functions, not using an older library :) although 1.1 is limited it works fine for 2d with magic lib

Posted: Fri Apr 18, 2008 8:23 pm
by monkeycracks
The link to the source was dead, so I couldn't compile it to be used with 1.4. Works like a charm with 1.1 and I have no problem stepping back a bit.

box2d

Posted: Mon Dec 22, 2008 6:09 pm
by geronika2004
Dear all,

the link provided above is dead

I can not download irrbox2d.h wrapper, the link is dead. Please, resubmit it for download :(

Thank you in advance.

Re: Box2d Wrapper

Posted: Sat Dec 14, 2019 2:34 pm
by netpipe
I only have cobra's version in the irrlichtdemo's repo on github. please repost if found.