todderick
12-07-2007 20:36:08
Hi. I am currently trying to figure out how to make lines connecting
two objects in Python-Ogre... being new to both Python and Ogre, I'm
having a bit of trouble.
I found this guide in the C++ tutorial:
clear();
begin("", RenderOperation::OT_LINE_STRIP);
position(left, top, -1);
position(right, top, -1);
position(right, bottom, -1);
position(left, bottom, -1);
position(left, top, -1);
end();
But I can't quite figure out how to make that into the python happy
version. Any help greatly appreciated! Thanks!
Todd H. Page
You can look at the 'raycasting' demo source in the OgreNewt demos for an example.. Basically the code looks like
## setup 3D line node.
self.DragLineNode = self.sceneManager.getRootSceneNode().createChildSceneNode()
self.DragLine = ogre.ManualObject( "__DRAG_LINES__" )
## this next section would go in your framelistener.frameStarted function..
start = ogre.Vector3(-100,0,0)
end = ogre.Vector3 ( 10,20,30 )
self.DragLineNode.detachAllObjects()
self.DragLine.clear()
## draw a 3D line between these points for visual effect :)
self.DragLine.begin("BaseWhiteNoLighting", ogre.RenderOperation.OT_LINE_LIST )
self.DragLine.position( start )
self.DragLine.position( end )
self.DragLine.end()
self.DragLineNode.attachObject( self.DragLine )
Cheers
Andy
todderick
13-07-2007 15:08:36
That worked great!
Thank you very much for your help!
I really appreciate it.
todderick
16-07-2007 21:37:13
sorry to be a hassle... I can't seem to get it to make more than one line.... My code for this looks like this:
for j in range(num-2):
self.DragLineNode = self.sceneManager.getRootSceneNode().createChildSceneNode()
self.DragLine = ogre.ManualObject("__DRAG_LINES__")
start = ogre.Vector3(x[j],y[j],z[j])
end = ogre.Vector3 (x[j+1],y[j+1],z[j+1])
self.DragLineNode.detachAllObjects()
self.DragLine.clear()
self.DragLine.begin("BaseWhiteNoLighting", ogre.RenderOperation.OT_LINE_LIST )
self.DragLine.position(start)
self.DragLine.position(end)
self.DragLine.end()
self.DragLineNode.attachObject(self.DragLine)
I have tried commenting out the lines with .detachAllObjects(), and .clear(), but it doesn't seem to make a difference - I also tried it by making a new node for the new line... any idea why this might not be working? And is there a way to adjust the thickness of the line?
Sorry to be such a hassle and ask so many questions, and thanks for any help you can proffer. Have a great day
Todd
x[],y[]. and z[] are lists which hold the x y and z variables for spheres which the lines are connecting. they are input by the user from a textfile
jacmoe
18-07-2007 21:59:15
Just throw in some more self.DragLine.position(start) self.DragLine.position(end) in between the two begin/end calls.
Do not end your line before you've added all the positions you need.
todderick
20-07-2007 01:22:00
Awesome! Thank you so much for that.... that helped a ton...
Sorry to be such a bother... is there anyway to adjust thickness
Thank you so much everyone for your help so far!