IrrKlang SceneNode With Svn

Discussion about everything. New games, 3d math, development tips...
Post Reply
wildrj
Posts: 301
Joined: Thu Mar 23, 2006 12:49 am
Location: Texas/ Cyberspace
Contact:

IrrKlang SceneNode With Svn

Post by wildrj »

I recently tried to get the IrrKlang SceneNode working with the current svn and behold it didn't work. Was giving me abstract errors so i went in and fixed it.

First open irrKlangSceneNode.h and scroll down till you see the SceneNode factory class. Swap it out with this one:

Code: Select all

class CIrrKlangSceneNodeFactory : public ISceneNodeFactory
{
public:

	CIrrKlangSceneNodeFactory(irrklang::ISoundEngine* soundEngine, ISceneManager* mgr);
	~CIrrKlangSceneNodeFactory();

	virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0);
	virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0);
	virtual u32 getCreatableSceneNodeTypeCount(void) const;
	virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const;
	virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const;
	virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const;

private:

	ESCENE_NODE_TYPE getTypeFromName(const c8* name) const;
	ISceneManager* Manager;
	irrklang::ISoundEngine* SoundEngine;
};
Then open irrKlangSceneNode.cpp and scroll down till you see the ///factory comment and swap out the code under it with this snippit:

Code: Select all

CIrrKlangSceneNodeFactory::CIrrKlangSceneNodeFactory(irrklang::ISoundEngine* sengine, ISceneManager* mgr)
: Manager(mgr), SoundEngine(sengine)
{
	if (SoundEngine)
		SoundEngine->grab();

	// don't grab the manager here, to avoid cyclic references
}


CIrrKlangSceneNodeFactory::~CIrrKlangSceneNodeFactory()
{
	if (SoundEngine)
		SoundEngine->drop();
}


//! adds a scene node to the scene graph based on its type id
ISceneNode* CIrrKlangSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent)
{
	if (!parent)
		parent = Manager->getRootSceneNode();

	if (type == IRRKLANG_SCENE_NODE_ID)
	{
		CIrrKlangSceneNode* node = new CIrrKlangSceneNode(SoundEngine, parent, Manager, -1);
		node->drop();
		return node; 
	}

	return 0;
}


//! adds a scene node to the scene graph based on its type name
ISceneNode* CIrrKlangSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent)
{
	return addSceneNode( getTypeFromName(typeName), parent );
}


//! returns amount of scene node types this factory is able to create
u32 CIrrKlangSceneNodeFactory::getCreatableSceneNodeTypeCount() const
{
	return 1;
}


//! returns type of a createable scene node type
ESCENE_NODE_TYPE CIrrKlangSceneNodeFactory::getCreateableSceneNodeType(u32 idx) const
{
	if (idx==0)
		return (ESCENE_NODE_TYPE)IRRKLANG_SCENE_NODE_ID;

	return ESNT_UNKNOWN;
}


//! returns type name of a createable scene node type 
const c8* CIrrKlangSceneNodeFactory::getCreateableSceneNodeTypeName(u32 idx) const
{
	if (idx==0)
		return irrKlangSceneNodeTypeName;

	return 0;
}


//! returns type name of a createable scene node type 
const c8* CIrrKlangSceneNodeFactory::getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const
{
	if (type == IRRKLANG_SCENE_NODE_ID)
		return irrKlangSceneNodeTypeName;

	return 0;
}


ESCENE_NODE_TYPE CIrrKlangSceneNodeFactory::getTypeFromName(const c8* name) const
{
	if (!strcmp(name, irrKlangSceneNodeTypeName))
		return (ESCENE_NODE_TYPE)IRRKLANG_SCENE_NODE_ID;

	return ESNT_UNKNOWN;
}
Hope this helps anyone else who couldn't get the scenenode working with current svn. If this is posted in wrong error please move mods..
http://wild.deathtouchstudios.com << My gamedev blog
<Programming is a way of life>
If at first you don't succeed press the delete key till you do :)
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

++ for the contribution m8!
Albeit, next time, might I suggest posting it in patch form (or also in patch form) and/or changes to apply? That way, ppl who have modded that section can use your correction without headaches ('cuz we all mod our Irr :P )

Anyhow, good job ;)
Post Reply