have been converting the CaduneTree lib to python, and everything is now done as far as I can tell, only problem is I can't get a tree to appear. CaduneTree uses a ManualObject pointer passed in to generate the tree geometry. Here's the code I use to display it:
manObj = ogre.ManualObject("myTree")
bbs = ogre.BillboardSet("leaves", 50, False)
params = Parameters()
trunk = Stem( params )
trunk.grow( ogre.Quaternion.IDENTITY, ogre.Vector3.ZERO )
trunk.createGeometry( manObj )
trunk.createLeaves( bbs )
#ent = sceneManager.createEntity( "mrTree", "myTree" )
node = sceneManager.getRootSceneNode().createChildSceneNode()
node.attachObject( manObj )
I've converted the lib to python, rather than wrapping it ( possibly a bad idea
). Which leads me to believe I have done something wrong in the manual object setup. Does it require uint16's for vertices / indexes? I have just been using standard python ints. If so, how would I go about that?
Trouble is, I get no errors whatsoever, everything seems to work (tree generation, leaf generation etc ), just no tree displayed. The whole code is too long to post here, i will try and sort out somewhere to upload it.
I can probably help with ManualObject as I've been using them to create terrain in my app for a while. For verts, I just use 3 floats, and for indexes, 3 ints. Here's some code I pulled (and removed app specific stuff from):
msh = sceneManager.createManualObject(name)
verts = [ (1.0,0.0,0.0), (0.0,1.0,0.0), (1.0,1.0,0.0), (0.0,0.0,0.0) ]
tris = [ (0,1,2), (1,2,3) ]
uv = [ (1.0,0.0), (0.0,1.0), (1.0,1.0), (0.0,0.0) ]
norms = 
color = 
for x in range(len(verts)):
for x in range(len(tris)):
node = parent.createChildSceneNode("Manual")
If you want to post the full code somewhere, I can also take a look. I do remember having some issues getting ManualObjects to work right the first time.
Thanks, I'll try out some of that right now.
Forgive my ignorance,
what does the * before the verts signify? I thought that was a C++ pointer-type thingy
well, using sceneManager.createManualObject( .. ) rather than what I was doing has at least made the beast visible! hurrah!
however its a bit garbled, Looks like I need to go back to the tree generation a bit.
That's great. I'm glad I could help!
*verts[x] will pass each float in verts[x] as a separate parameter. You can do the same with ** and a dict for keyword args. So basically, msh.position(*verts[x]) is the same as msh.position(verts[x], verts[x], verts[x]).
Ah right, never knew that one! so its more like an iterator than passing a list object.
thanks very much for that
I just checked it out. There is definitely something going wrong.
I didn't see anything obvious after playing around with it a while. If I get some time, I'll keep poking it because it would be very nice to be able to generate random trees.
Yeah, the demo provided with caduneTree looks fantastic.
I think the parameter setup in the code I have is a bit wrong, I've looked over it and some of the settings dont seem to make sense. Although I think there must be something more serious going on, as its definitely looking properly wrong.
Your problem is in CTStem.py -- not sure yet what the issue is, however I wrapped the C++ library (in the SVN now) and that works very well..
I had a feeling you'd say that sooner or later! Well thanks for doing that
cant wait to give it a try
I'm going to put a snapshot up on Sourceforge tonight with all the latest modules..