Page 2 of 2

Posted: Fri Sep 16, 2005 7:43 pm
by Spintz
Just saw this ISceneNode enhancement, I'm going to implement it in Irrlicht-Spintz-0.12, but with some changes -

All in ISceneNode.h

change the ctor -

Code: Select all

//! Constructor
ISceneNode(	ISceneNode* parent, ISceneManager* mgr, s32 id=-1,
			const core::vector3df& position = core::vector3df(0,0,0),
			const core::vector3df& rotation = core::vector3df(0,0,0),
			const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f))
	: IsVisible(true), ID(id), Parent(parent), SceneManager(mgr),
		AutomaticCullingEnabled(true), DebugDataVisible(false),
		TriangleSelector(0), RelativeTranslation(position),
		RelativeRotation(rotation), RelativeScale(scale)

{
	if (Parent)
		Parent->addChild(this);

	calcRelativeTransformation();
	updateAbsolutePosition();			
}
change this function -

Code: Select all

virtual core::matrix4 getRelativeTransformation() const
{
	return RelativeTransformation;
}
Add this function

Code: Select all

virtual void calcRelativeTransformation()
{
	RelativeTransformation.setRotationDegrees( RelativeRotation );
	RelativeTransformation.setTranslation( RelativeTranslation );

	if( RelativeScale != core::vector3df( 1.0f, 1.0f, 1.0f ) )
	{
		core::matrix4 smat;
		smat.setScale( RelativeScale );
		RelativeTransformation *= smat;
	}
}
change setScale -

Code: Select all

virtual void setScale(const core::vector3df& scale)
{
	RelativeScale = scale;
	calcRelativeTransformation();
}
change setRotation -

Code: Select all

virtual void setRotation(const core::vector3df& rotation)
{
	RelativeRotation = rotation;
	calcRelativeTransformation();
}
change setPosition -

Code: Select all

virtual void setPosition(const core::vector3df& newpos)
{
	RelativeTranslation = newpos;
	calcRelativeTransformation();		
}
change updateAbsolutePosition -

Code: Select all

virtual void updateAbsolutePosition()
{
	if (Parent)
		AbsoluteTransformation = 
			Parent->getAbsoluteTransformation() * getRelativeTransformation();
	else
		AbsoluteTransformation = RelativeTransformation;
}
Add protected class memeber -

Code: Select all

//! relative transformation of the node.
core::matrix4 RelativeTransformation;
Works with no problems!

Posted: Thu Oct 06, 2005 11:46 am
by Guest
I'm really looking forward for this improvments. I really need that "setcolor" - function for my jirr project.