Little Havok and Irrlicht integration demo.

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Little Havok and Irrlicht integration demo.

Post by benny53 »

I had originally intended to post this a month back or more, but I had forgotten to >.>

Anyhow, I have a little demo of using Havok in Irrlicht. It uses Irrlicht 1.4.1 and the current release of Havok. I haven't integrated Havok Animation as of yet, but I can look into that if I get enough response from this.

Basically this demo takes place in a rather well known setting, with a few boxes ( one I was to lazy to reposition so it'll leave the broad phase border and will give a warning, but it just fixes the entity so no worries ) and a character controller implemented with the fps camera ( also includes jumping ).

The aim for this is just to give an idea of how to use Havok with Irrlicht. I had started a library a while back to make it easy to integrate Havok with Irrlicht, but I had gotten annoyed at character controllers as I designed them poorly and would have to recode them, which I did not in fact feel like doing.

Now, without further ado, I give you the example hosted on media fire:
http://www.mediafire.com/?sharekey=2b27 ... f616773e2d

Hope you can learn from this. If demand is high enough I shall restart development on IrrHk I suppose. Cheers ^^
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Wouldn't run for me, the ol' 'try reinstalling' popup so.. something to do with MSVC redistributibles? Though i've got a few versions of MSVC installed.
Image Image Image
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

huh, thats odd. There was issues with people running my debug executable so I had to build in release mode, but I had apparently forgotten to do that. Did you compile it yourself or did you run the debug executable?

Ok, I just uploaded a release build if you want to try that.
http://www.mediafire.com/?sharekey=2b27 ... ea1f11f3e3

If that doesn't work then I'm confused, as that release build has worked on other pcs.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah that one works. It was the debug build i was running before as that was all that was available and i couldn't rebuild it as i don't have havok installed.

A simple example but seems to work very nicely so well done! A useful addition to help people use Havok.

I wouldn't use it myself but i would urge you to continue developing something like IrrHk as i really think it would be useful to a lot of people!
Image Image Image
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

Ahh, ok then.

Thanks. I might keep working on it. It depends on school and all that for the most part. But if I find time I will. I already had work done on it before, so I can just start from there.
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Post by Darktib »

This sound very good but I cannot run both the realease and the debug because the dll is incorrect (side by side configuration incorrect...)
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

Hm, that is odd. What OS do you have? Perhaps that is part of the problem here.
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

Ok, well, I've done a bit of work on IrrHk. I'm not really sure if this is a style you people would like, but what I have so far is this ( this is a simple program I made to test ):

Code: Select all

irr::IrrlichtDevice* device;
irr::physics::dynamics::IWorld* world;
irr::scene::ICameraSceneNode* cameraNode;
irr::scene::ISceneNode* level;
CustomEventReceiver* recv;
irr::physics::dynamics::ICharacterProxy* m_character;

int main()
{
	recv = new CustomEventReceiver();

	device = irr::createDevice(irr::video::EDT_DIRECT3D9, irr::core::dimension2d<irr::s32>(640, 480), 32, false, false, true, recv);
	world = irr::physics::createPhysics(device);

	cameraNode = device->getSceneManager()->addCameraSceneNodeFPS(0, 100.0f, 0.0f);

	device->getFileSystem()->addZipFileArchive("map-20kdm2.pk3");
	irr::scene::IAnimatedMesh* levelMesh = device->getSceneManager()->getMesh("20kdm2.bsp");
	level = device->getSceneManager()->addOctTreeSceneNode(levelMesh);
	level->setScale(irr::core::vector3df(0.1f, 0.1f, 0.1f));
	irr::physics::collision::IShape* levelShape = world->getShapeFactory()->addMeshShape(levelMesh, irr::core::vector3df(0.1f, 0.1f, 0.1f));
	irr::physics::dynamics::IRigidBody* body5 = world->addRigidBody(level, world->getShapeFactory()->addMoppBvTreeShape(levelShape), irr::physics::dynamics::EMT_STATIC);
	body5->setPosition(irr::core::vector3df(-100, 0, -100));

	m_character = world->addCharacterProxy(4.0f, 50.0f, 500.0f, irr::core::vector3df(0.0f, 25.0f, 0.0f));
	cameraNode->addAnimator(m_character);

	irr::scene::IAnimatedMesh* nodeMesh = device->getSceneManager()->getMesh("HavokCube.x");

	irr::video::ITexture* texture = device->getVideoDriver()->getTexture("Tex2.png");

	for (int i = 0; i < 50; i++)
	{
		irr::scene::IAnimatedMeshSceneNode* node = device->getSceneManager()->addAnimatedMeshSceneNode(nodeMesh);
		node->setMaterialTexture(0, texture);
		node->setMaterialFlag(irr::video::EMF_LIGHTING, false);
		irr::physics::dynamics::IRigidBody* body = world->addRigidBody(node, world->getShapeFactory()->addBoxShape(irr::core::vector3df(2.0f, 2.0f, 2.0f)), irr::physics::dynamics::EMT_DYNAMIC);
		body->setMass(10.0f);
		world->getRigidBodyUtilities()->calculateBoxInertiaTensor(body, irr::core::vector3df(2.0f, 2.0f, 2.0f), 10.0f);
		body->setPosition(irr::core::vector3df(0, 50.0f + (1.0f * i + 2), 0.0f));
	}

	while (device->run())
	{
		if (recv->getKeyState(irr::KEY_KEY_W) == EBS_DOWN)
		{
			m_character->moveForward();
		}

		if (recv->getKeyState(irr::KEY_KEY_S) == EBS_DOWN)
		{
			m_character->moveBackward();
		}

		if (recv->getKeyState(irr::KEY_KEY_A) == EBS_DOWN)
		{
			m_character->strafeLeft();
		}

		if (recv->getKeyState(irr::KEY_KEY_D) == EBS_DOWN)
		{
			m_character->strafeRight();
		}

		m_character->m_wantJump = (recv->getKeyState(irr::KEY_SPACE) == EBS_DOWN);

		world->step();

		device->getVideoDriver()->beginScene(true, true, irr::video::SColor(128, 128, 128, 128));
		device->getSceneManager()->drawAll();
		device->getVideoDriver()->endScene();
	}

	world->drop();
	device->drop();	
}
rocknroll
Posts: 2
Joined: Fri Oct 03, 2008 8:52 am

Great work

Post by rocknroll »

Hi,

I downloaded your example and the .exe ran fine. I've tried compiling the project myself and ran into the problem below:

I am running Visual c++ 2008 express, Latest Havok download version 6, your example file.

------------------------------------------------------------------------------

1>------ Build started: Project: Irrlicht Havok Example, Configuration: Release Win32 ------
1>Compiling...
1>RigidBody Physics.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>PhysicsMain.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>Physics Mesh Physics.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>Main.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>GraphicsMain.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>Character Physics.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\Main.h(35) : fatal error C1083: Cannot open include file: 'Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h': No such file or directory
1>CEventReceiver.cpp
1>e:\havok\irrlicht+havok example\irrlicht+havok example\CEventReceiver.h(12) : fatal error C1083: Cannot open include file: 'Irrlicht.h': No such file or directory
1>Build log was saved at "file://e:\HAVOK\Irrlicht+Havok Example\Irrlicht+Havok Example\Release\BuildLog.htm"
1>Irrlicht Havok Example - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


-----------------------------------------------------
night_hawk
Posts: 153
Joined: Mon Mar 03, 2008 8:42 am
Location: Suceava - Romania
Contact:

Post by night_hawk »

The problem is blatantly obvious...
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

:lol: yeah try updating the include paths to your Irrlicht & Havok installations (which you obviously need to recompile).
Image Image Image
rocknroll
Posts: 2
Joined: Fri Oct 03, 2008 8:52 am

It seems that your example is Havok 5

Post by rocknroll »

It seems that your example is using Havok 5. I am using the latest Havok 6 which doesn't have

Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h

I then commented this line in the main.h file.

//#include <Physics/Utilities/Thread/Multithreading/hkpMultithreadingUtil.h>

which then gave another error that the signature in PhysicsMain.h

new hkThreadMemory(memoryManager,16)

only takes one argument instead of two.

So after doing the above, I was able to compile, however, when it comes to linking.

I get the following:

1>------ Build started: Project: Irrlicht Havok Example, Configuration: Release Win32 ------
1>Compiling...
1>RigidBody Physics.cpp
1>PhysicsMain.cpp
1>Physics Mesh Physics.cpp
1>Main.cpp
1>GraphicsMain.cpp
1>Character Physics.cpp
1>CEventReceiver.cpp
1>Linking...
1>hkVisualize.lib(hkDisplayCapsule.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl hkGeometryUtils::createCapsuleGeometry(class hkVector4 const &,class hkVector4 const &,float,int,int,class hkTransform const &,struct hkGeometry * &)" (?createCapsuleGeometry@hkGeometryUtils@@SAXABVhkVector4@@0MHHABVhkTransform@@AAPAUhkGeometry@@@Z)
1>hkpInternal.lib(hkpCollectionCollectionAgent3.obj) : error LNK2001: unresolved external symbol "public: static int __cdecl hk1AxisSweep::collide(struct hk1AxisSweep::AabbInt const *,int,struct hk1AxisSweep::AabbInt const *,int,struct hkKeyPair * __restrict,int,int &)" (?collide@hk1AxisSweep@@SAHPBUAabbInt@1@H0HPIAUhkKeyPair@@HAAH@Z)
1>hkpUtilities.lib(hkpInertiaTensorComputer.obj) : error LNK2001: unresolved external symbol "public: static class hkBool __cdecl hkGeometryUtility::getAxesFromCovariance(class hkMatrix3 &,class hkVector4 &,class hkVector4 &,class hkVector4 &)" (?getAxesFromCovariance@hkGeometryUtility@@SA?AVhkBool@@AAVhkMatrix3@@AAVhkVector4@@11@Z)
1>hkpUtilities.lib(hkpInertiaTensorComputer.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl hkGeometryUtility::createConvexGeometry(struct hkStridedVertices const &,struct hkGeometry &,class hkArray<class hkVector4> &,enum hkGeomConvexHullMode)" (?createConvexGeometry@hkGeometryUtility@@SAXABUhkStridedVertices@@AAUhkGeometry@@AAV?$hkArray@VhkVector4@@@@W4hkGeomConvexHullMode@@@Z)
1>hkpUtilities.lib(hkpShapeDisplayBuilder.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl hkGeometryUtility::createConvexGeometry(struct hkStridedVertices const &,struct hkGeometry &,enum hkGeomConvexHullMode)" (?createConvexGeometry@hkGeometryUtility@@SAXABUhkStridedVertices@@AAUhkGeometry@@W4hkGeomConvexHullMode@@@Z)
1>hkpUtilities.lib(hkpConvexRadiusBuilder.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl hkGeometryUtility::createConvexGeometry(struct hkStridedVertices const &,struct hkGeometry &,enum hkGeomConvexHullMode)" (?createConvexGeometry@hkGeometryUtility@@SAXABUhkStridedVertices@@AAUhkGeometry@@W4hkGeomConvexHullMode@@@Z)
1>hkpUtilities.lib(hkpConvexRadiusBuilder.obj) : error LNK2001: unresolved external symbol "public: static void __cdecl hkGeometryUtility::createVerticesFromPlaneEquations(class hkArray<class hkVector4> const &,class hkArray<class hkVector4> &)" (?createVerticesFromPlaneEquations@hkGeometryUtility@@SAXABV?$hkArray@VhkVector4@@@@AAV2@@Z)
1>E:\HAVOK\Irrlicht+Havok Example\Release\Irrlicht Havok Example.exe : fatal error LNK1120: 6 unresolved externals

For what I can see, my include paths for the includes and libs look fine. There is something going on here. I will continue figuring this out and post my findings here. If someone sees something I don't please chime in.

Thanks
monkeycracks
Posts: 1029
Joined: Thu Apr 06, 2006 12:45 am
Location: Tennesee, USA
Contact:

Post by monkeycracks »

rocknroll :
You could always get Havok 5 or just get the header from Havok 5.

Nice example. Hope to see more of this!
benny53
Posts: 131
Joined: Fri May 26, 2006 10:21 pm
Location: Ohio

Post by benny53 »

Rocknroll - You are using Havok 6 for that? That won't work. I'm working on a Havok 6.0 wrapper for Irrlicht though. But the reason the hkpMultithreadingUtil is giving you problems is because Havok 6.0 got rid of that. Instead, Havok 6.0 has a much easier solution for multithreading.

But if you want to compile, you need to get Havok 5.5. Otherwise, wait a bit and I'll have a new demo with my library up ( almost have rigid bodies with everything working, as I'm trying to make this as clean and straight forward as possible ).

Cheers!
Ben
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

Build succeeded using Havok 6 and Irrlicht 1.4.1 :D
First, in PhysicsMain.cpp, line 21, change it to:
data.__threadMemory = new hkThreadMemory(memoryManager);
then, you need to add this in to Linker -> Input -> Additional Dependencies:
hkBase.lib hkSerialize.lib hkSceneData.lib hkInternal.lib hkGeometryUtilities.lib hkVisualize.lib hkCompat.lib hkpCollide.lib hkpConstraintSolver.lib hkpDynamics.lib hkInternal.lib hkpUtilities.lib hkpVehicle.lib
But remember, in C/C++ -> Code Generation -> Runtime Library, you must chose the correct type with the .lib library you chose (debug_multithreaded, release_multithreaded if you use /MT or /MTd, debug_multithreaded_dll or release_multithreaded_dll if you use /MD or /MDd, or simply, use hybrid_multithreaded_dll)
Source Download here (src only, no data)
http://www.box.net/shared/pzunpgyxv1
Post Reply