How could I draw a 3d line?

alberts

25-12-2005 18:24:00

Hi

I need to show a vector that change over time. Is it possible to create a simple mesh with two points and then modify their positions?

I've been trying to port the code in this page of the wiki, but I can't. :(

Thanks!

rastaman

28-12-2005 05:45:31

I just updated CVS with this. there's a new Line3D class in OgreDotNet.

I put it in OgreDotNet because of the RenderOperation class witch is private in ogre some how it works in cpp, not sure how. but wrapping it has proved difficult. so since Line3D seem usefull i added that to OgreDotNet.

usage:

//the object must be kept because when Disposed it will delete the c object
protected Line3D myLine;


//in CreateScene
myLine = new Line3D();
myLine.addPoint( new Vector3( 0.0f, 9.6f, 0.0f) );
myLine.addPoint( new Vector3( 160.0f, 9.6f, 0.0f) );
myLine.addPoint( new Vector3( 160.0f, 9.6f, 160.0f) );
myLine.addPoint( new Vector3( 0.0f, 9.6f, 160.0f) );
myLine.addPoint( new Vector3( 0.0f, 9.6f, 0.0f) );
myLine.drawLines();

SceneNode myNode = mSceneManager.GetRootSceneNode().CreateChildSceneNode("Line1");
myNode.AttachObject(myLine);
myNode.SetPosition( 0.0f, 200.0f, 0.0f );

//in Dispose
if (myLine != null)
{
SceneNode n = mSceneManager.GetSceneNode("Line1");
if (n!= null)
n.DetachObject(myLine);
myLine.Dispose();
}

alberts

03-01-2006 11:09:41

How can I modify a point? I've been trying it with the method updatePoint at FrameStarted event but it doesn't work.

myLine.updatePoint(3,new Math3D.Vector3(myLine.getPoint(3).x,myLine.getPoint(3).y-1,myLine.getPoint(3).z));

What's wrong?

Thanks a lot for your help!! :D

rastaman

03-01-2006 20:43:22

well the class in the wiki page does not support updating. after you call drawlines the first time it sets a flag so that it is not proccesed anymore.
I'm not actualy sure how to update a vertexbuffer, ill look into it.

rastaman

03-01-2006 23:56:18

ok i just updated Line3D.h in cvs. now you can update/delete/add points then call drawlines again and it will update the mesh. I also changed it to use size_t (UInt32) insted of ushort, just more correct.

also in Dispose you don't need to DetachObject, atleast i dont get an error. still need to Dispose the Line3d.

alberts

09-01-2006 09:57:44

I'll try it.

Thanks a lot for your help!!!