CUnrealMeshFileLoader

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

CUnrealMeshFileLoader

Postby wing64 » Sat May 19, 2012 9:19 am

Unreal PSK mesh and PSA animation loader.

Image

Source and binary:
http://upload.one2car.com/download.aspx ... XZZY5FF5D1
http://file2.uploadfile.biz/i/IVEDMEIMIZXDEW
http://www.4shared.com/rar/8fxu65xj/unreal_loader.html

How to use: (Tested from 01.HelloWorld)

1. Register loader (before call getmesh)
cpp Code: Select all
CPSKMeshFileLoader* psk_loader = new CPSKMeshFileLoader( smgr );
CPSAMeshFileLoader* psa_loader = new CPSAMeshFileLoader( smgr );
smgr->addExternalMeshLoader( psk_loader );
smgr->addExternalMeshLoader( psa_loader );
psk_loader->drop( );
psa_loader->drop( );


2. use animation from psa
cpp Code: Select all
IAnimatedMesh* animation = smgr->getMesh("Female.PSA");
s32 begin, end;
f32 speed;
((SSkinnedMesh*)animation)->getFrameLoop( core::stringc("Push"), begin, end, speed );
((ISkinnedMesh*)mesh)->useAnimationFrom( ((ISkinnedMesh*)animation) );
node->setFrameLoop( begin, end );
node->setAnimationSpeed( speed );


Happy downloading :D

female model: http://udn.epicgames.com/Two/UnrealDemoModels.html
Last edited by wing64 on Sat May 19, 2012 10:39 am, edited 1 time in total.
wing64
Competition winner
 
Posts: 200
Joined: Wed Jul 23, 2008 2:35 am
Location: Thailand

Re: CUnrealMeshFileLoader

Postby smso » Sat May 19, 2012 10:21 am

I encounter this when I tried to download the file:

"You should Sign Up or Login to download this file"


I don't want to sign up!

Regards
smso
smso
 
Posts: 217
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: CUnrealMeshFileLoader

Postby smso » Sat May 19, 2012 10:44 am

smso wrote:I encounter this when I tried to download the file:

"You should Sign Up or Login to download this file"


I don't want to sign up!

Regards
smso


There is no direct download from the third link only. The first and second ones are OK.
Trying out the loader.
Thanks.

Regards,
smso
smso
 
Posts: 217
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: CUnrealMeshFileLoader

Postby CuteAlien » Sat May 19, 2012 11:10 am

Very nice, works on Linux with 3 minor changes: Pass all the name parameters as const reference instead of reference, so the following will work on gcc as well:
cpp Code: Select all
 
AnimInfo( const core::stringc& name, s32 begin = 0, s32 end = 0, f32 fps = 30.0f )
void addAnimation( const core::stringc& animationName, s32 begin = 0, s32 end = 0, f32 fps = 30.0f )
bool getFrameLoop( const core::stringc& animationName, s32& begin, s32& end, f32& fps )
 


Thanks for posting!
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5359
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: CUnrealMeshFileLoader

Postby christianclavet » Tue May 22, 2012 1:45 am

Hi! Wow! Does that mean we could take ACTORX and produce our own characters? What is currently supported?

Looking at the code this look really simple to use!!

One warning!

cpp Code: Select all
((ISkinnedMesh*)mesh)->useAnimationFrom( ((ISkinnedMesh*)animation) );


This will affect all the instances!!! So it can be only used on a single character and not multiple (we would need to append all the animations to make this work on multiple characters using the same sets of animation)

Really GREAT work! Saw the demo and I'm greatly impressed!!! Thanks also for the link to the web site, they had modeling and texturing guides using ActorX.
User avatar
christianclavet
 
Posts: 1383
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA

Re: CUnrealMeshFileLoader

Postby Sky-Fox » Tue May 22, 2012 9:05 am

Cool, Very nice!!!

Need for work Irrlicht 1.8 :
cpp Code: Select all
 
virtual IMesh *getMesh ( u32 timeMs, io::IAttributes *animationParameters, u32 levelOfDetail=1.0f )
{
return Mesh->getMesh ( 0,255,-1,-1 ); //FIXME need correct Parameters
};
virtual IMesh *getMesh ( s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1 )
{
return Mesh->getMesh ( frame,detailLevel,startFrameLoop,endFrameLoop );
};
 

Image
User avatar
Sky-Fox
 
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Re: CUnrealMeshFileLoader

Postby wing64 » Tue May 22, 2012 10:21 am

christianclavet wrote:Hi! Wow! Does that mean we could take ACTORX and produce our own characters? What is currently supported?

Yes, tested w/ actorx 249. And thanks for all comment.
wing64
Competition winner
 
Posts: 200
Joined: Wed Jul 23, 2008 2:35 am
Location: Thailand

Re: CUnrealMeshFileLoader

Postby Sky-Fox » Tue Jun 05, 2012 3:23 pm

Not work on IOS. crash...
cpp Code: Select all
 
 ???                            0000000000 0 + 0\
1   Game                                0x00186d4c irr::core::array<irr::scene::ISkinnedMesh::SScaleKey, irr::core::irrAllocator<irr::scene::ISkinnedMesh::SScaleKey> >::reallocate(unsigned int) (irrArray.h:67)\
2   Game                                0x00189d78 irr::core::array<irr::scene::ISkinnedMesh::SScaleKey, irr::core::irrAllocator<irr::scene::ISkinnedMesh::SScaleKey> >::insert(irr::scene::ISkinnedMesh::SScaleKey const&, unsigned int) (irrArray.h:150)\
3   Game                                0x00189f5a irr::core::array<irr::scene::ISkinnedMesh::SScaleKey, irr::core::irrAllocator<irr::scene::ISkinnedMesh::SScaleKey> >::push_back(irr::scene::ISkinnedMesh::SScaleKey const&) (irrArray.h:105)\
4   Game                                0x002a7418 irr::scene::CSkinnedMesh::addScaleKey(irr::scene::ISkinnedMesh::SJoint*) (CSkinnedMesh.cpp:1191)\
5   Game                                0x00027174 irr::scene::SSkinnedMesh::finalize() (CUnrealMeshFileLoader.h:253)\
6   Game                                0x00021898 irr::scene::CPSKMeshFileLoader::createMesh(irr::io::IReadFile*) (CUnrealMeshFileLoader.cpp:586)\
7   Game                                0x000731bc irr::scene::CSceneManager::getMesh(irr::core::string<char, irr::core::irrAllocator<char> > const&) (CSceneManager.cpp:399)\
 
User avatar
Sky-Fox
 
Posts: 29
Joined: Fri Feb 04, 2011 10:49 am

Re: CUnrealMeshFileLoader

Postby wing64 » Wed Jun 06, 2012 4:53 am

- I'm not sure what is your irrlicht svn version ? (didn't test on ios)
- addScaleKey() dont call in loader but why error occurred :?:
wing64
Competition winner
 
Posts: 200
Joined: Wed Jul 23, 2008 2:35 am
Location: Thailand

Re: CUnrealMeshFileLoader

Postby fmx » Sat Jun 09, 2012 4:48 pm

Nice! Thanks for sharing :D
User avatar
fmx
 
Posts: 559
Joined: Wed Dec 06, 2006 9:28 am
Location: UK

Re: CUnrealMeshFileLoader

Postby HellFlip » Sun Apr 14, 2013 9:03 pm

Awesome Stuff ! Thanks a lot for this !

The animation system is working fine using Irrlicht 1.7.x, but is broken with Irrlicht 1.8, because of the Irrlicht change "quaternion conversions to and from matrix4 no longer invert rotations."

To fix it using 1.8, do the following change in CUnrealMeshFileLoader.cpp: , in psk_to_irr( psk_t* psk, SSkinnedMesh* AnimatedMesh ):
Change line 396
cpp Code: Select all
core::matrix4 rotationMatrix = joint->Animatedrotation.getMatrix();

To
cpp Code: Select all
core::matrix4 rotationMatrix = joint->Animatedrotation.getMatrix().getTransposed();
HellFlip
 
Posts: 1
Joined: Mon Aug 20, 2012 9:57 pm


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest