from c++ to Python

ran

08-10-2007 21:25:05

Hi

trying to convert my code from c++ to pythn ogre, I seem to hit a wall when there's a variable declaration (that in python is not needed) though i don't know how to initialise it on creation -

c++ code snippet

SkeletonPtr pSkel = SkeletonManager::getSingleton().getByName("X.skeleton");
SkeletonPtr pSkeletonSearch;
if (pSkel->hasAnimation(altAnim))
{
return true;
}
pSkeletonSearch = SkeletonManager::getSingleton().load(altAnim, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
Skeleton::BoneHandleMap boneHandleMap;
ent->getSkeleton()->_buildMapBoneByHandle( ent->getSkeleton(), boneHandleMap );
pSkel->_mergeSkeletonAnimations(pSkeletonSearch.getPointer(), boneHandleMap );
SkeletonManager::getSingleton().remove(altAnim);
ent->getSkeleton()->_refreshAnimationState(ent->getAllAnimationStates());


the equivent (or so i hoped) in python would be


pSkel = ogre.SkeletonManager.getSingleton().getByName("X.skeleton")
pSkeletonSearch=0
if pSkel.hasAnimation(altAnim):

return true;

pSkeletonSearch = ogre.SkeletonManager.getSingleton().load(altAnim, ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME )
boneHandleMap =?????
ent.getSkeleton()._buildMapBoneByHandle( ent.getSkeleton(), boneHandleMap)
pSkel._mergeSkeletonAnimations(pSkeletonSearch.getPointer(), boneHandleMap)
ent.getSkeleton()._refreshAnimationState(ent.getAllAnimationStates())



I need to initialize or declare boneHandleMap (setting it to 0 like i did with pSkeletonSearch doesn't seem to work ) how should I do that in pythonnOgre?

cheers
Ran

dermont

08-10-2007 22:30:05

It appears that the BoneHandleMap isn't there since the "std::vector<unsigned short>" is already wrapped as IndexMap", so you could try:


boneHandleMap = ogre.IndexMap()
entity.getSkeleton()._buildMapBoneByHandle( entity.getSkeleton(), boneHandleMap)
for bhandle in boneHandleMap:
print bhandle

ran

09-10-2007 00:06:04

thanks

that seems to work, though I get an error in the next line

pSkel._mergeSkeletonAnimations(pSkeletonSearch.getPointer(), boneHandleMap)
AttributeError: 'Skeleton' object has no attribute 'getPointer'

the attribute is defined in the class (c++ wise) - and works fine there
any ideas??

Cheers
Ran

andy

09-10-2007 02:25:20

Just remove the getPointer() as it's not needed (Python handles it for you)..

Regards
Andy