Page 1 of 1

[D3D][IAnimatedMesh] Incorrect joints anim

Posted: Sat Jul 05, 2008 8:19 am
by piiichan
I have an animated mesh of a knight that I've exported from Blender in an .x file.
The knight can walk or stand still.

The still animation always look good.

The walk animation is ok with OpenGL, but not with Direct3D9.

There is a problem with the x axis.
All the bones with their local x axis pointing towards the negative global x axis have problems. Looks to me that they rotate around their local z axis...

Obviously, this is a bug, because simply switching to OpenGL solves the problem.
Maybe there's only a little mistake in a transformation matrix of the bones.

Any other idea about what may cause this problem?

Posted: Sat Jul 05, 2008 11:47 am
by rogerborg
What version of Irrlicht, and can you make the model available?

Posted: Sat Jul 05, 2008 1:10 pm
by piiichan
I tried with SVN trunk and 1.4.1 => same thing.

The .x and .blend files are here http://studentweb.usq.edu.au/home/w0062 ... 20anim.zip


Try this code and see what happens

Code: Select all

#include <irrlicht.h>

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

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif

int main() {
	IrrlichtDevice* device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(640, 480)); // problem with D3D
	//IrrlichtDevice* device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480)); // GL is ok

	ISceneManager* smgr = device->getSceneManager();
	IVideoDriver* driver = device->getVideoDriver();

	// load an animated mesh
	IAnimatedMesh* knightMesh = smgr->getMesh("C:\\model game tale knight v6.x"); // change the path
	IAnimatedMeshSceneNode* knightNode = smgr->addAnimatedMeshSceneNode(knightMesh);
	knightNode->setPosition(vector3df(0,0,-50));
	knightNode->setScale(vector3df(2,2,2));
	knightNode->setMaterialFlag(EMF_LIGHTING, false);

	// here is the problem with the joint animations
	knightNode->setFrameLoop(31,79); // walk => will look funny with D3D
	//knightNode->setFrameLoop(1,24); // still => looks ok with both GL and D3D

	

	// setup camera
	ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS();
	cam->setTarget(knightNode->getPosition());

	// main loop
	SColor backgroundColor(255,128,128,150);
	while( device->run() ) {
		driver->beginScene(true, true, backgroundColor);			
		smgr->drawAll();
		driver->endScene();
	}

	device->drop();
	
	return EXIT_SUCCESS;
}


Posted: Fri Jul 25, 2008 4:00 am
by piiichan
This bug is still valid.