cast to billboardSet movableObject

bharling

12-01-2008 00:11:41

Am having a tree problem ( again, all my coding life seems to be about making trees these days! ).

So, I'm trying to combine calunetree and pagedgeometry as reccomended by danaugrs ( Also hoping to update the showcase to have an infinite terrain! ).

should this work? :

msh = manObj.convertToMesh("procTreeMesh")
ent = sceneManager.createEntity("land", "procTreeMesh")
ent.setNormaliseNormals(True)

movBbs = bbs.asMovableObject()
ent.attachObjectImpl( movBbs )


when I try it out, the asMovableObject() call seems to still return the billboardSet.

heres the traceback:

File "C:\PythonOgre\demos\calunetree\Demo_Tree.py", line 46, in _createScene
ent.attachObjectImpl( movBbs )
Boost.Python.ArgumentError: Python argument types in
Entity.attachObjectImpl(Entity, BillboardSet)
did not match C++ signature:
attachObjectImpl(struct Entity_wrapper {lvalue}, class Ogre::MovableObject * pMovable, class Ogre::TagPoint * pAttachingPoint)
Unregistering ResourceManager for type BspLevel

SiWi

12-01-2008 08:57:25



should this work? :

msh = manObj.convertToMesh("procTreeMesh")
ent = sceneManager.createEntity("land", "procTreeMesh")
ent.setNormaliseNormals(True)

movBbs = bbs.asMovableObject()
ent.attachObjectImpl( movBbs )


when I try it out, the asMovableObject() call seems to still return the billboardSet.



Do you mean the second last line is not working? What is bbs? I don´t see it anywhere in your code.

bharling

12-01-2008 10:10:29

Sorry, I wasn't very clear !

I have a billboard set ( for the leaves in calunetree ) that I wish to attach to an entity, so I can try using that with ogreforests, as you can only add entities as trees, not sceneNodes.

billboardSet.asMovableObject apparently should cast the billboardSet as a movable, and therefore allow it to be attached to the entity with entity.attachObjectImplc (?) or am I missing something?

SiWi

12-01-2008 13:10:55

I think this should work.
Hmm. Probably ask in the Main Forums?

andy

12-01-2008 14:28:24

File "C:\PythonOgre\demos\calunetree\Demo_Tree.py", line 46, in _createScene
ent.attachObjectImpl( movBbs )
Boost.Python.ArgumentError: Python argument types in
Entity.attachObjectImpl(Entity, BillboardSet)
did not match C++ signature:
attachObjectImpl(struct Entity_wrapper {lvalue}, class Ogre::MovableObject * pMovable, class Ogre::TagPoint * pAttachingPoint)
Unregistering ResourceManager for type BspLevel


Looks like you are calling attachObjectImpl with a single argument (a MoveableObject) and it is expecting two arguments, with the second being an Ogre.TagPoint ...

It shows as three arguments in the error message as the first one is the implicit "self" in python.

......

SiWi

12-01-2008 17:08:19

:oops:
Andy´s right.

bharling

13-01-2008 17:48:55

Well, I think I've set it up right ( with a skeleton and tagPoint ) to attach the billboardSet, but now I just get a crash with no exeption that i can see. heres the code:

manObj = self.sceneManager.createManualObject("myTree")
bbs = self.sceneManager.createBillboardSet("leaves", 20)

#params = Parameters()
params = ct.Parameters()
params.setLeafMaterial("LOTTreeLeavesNoBones")
trunk = ct.Stem( params )
trunk.grow( ogre.Quaternion.IDENTITY, ogre.Vector3.ZERO )
trunk.createGeometry( manObj )
trunk.createLeaves( bbs )

msh = manObj.convertToMesh("procTreeMesh")
sub = msh.getSubMesh(0)
sub.useSharedVertices = False

# Skeleton to attach leaves
skel = ogre.SkeletonManager.getSingleton().create("skeleton",Ogre.ResourceGroupManager.getSingleton().getWorldResourceGroupName())
msh._notifySkeleton(skel)
pRootBone = skel.createBone('rootBone')
pRootBone.resetOrientation()
pRootBone.setPosition(0,0,0)
pBone1=pRootBone.createChild(1 ,ogre.Vector3(0.0, 10.0, 0.0))

vba = ogre.VertexBoneAssignment()
vba.weight = 1.0

vba.boneIndex = 0
numverts = sub.vertexData.vertexCount

for v in range(numverts):
vba.vertexIndex = v
sub.addBoneAssignment(vba)

ent = sceneManager.createEntity("tree", "procTreeMesh")
ent.setNormaliseNormals(True)

#ent.attachObjectImpl( movBbs )

ent.attachObjectToBone('rootBone', bbs.asMovableObject(), ogre.Quaternion.IDENTITY, ogre.Vector3.ZERO) # -> class Ogre::TagPoint *

node = sceneManager.getRootSceneNode().createChildSceneNode()
node.setPosition( 0,0,0 )
node.attachObject( ent )


I'll have to do line-by-line step through it to see whats gone wrong :(