create a moving line

se5a

18-08-2014 23:19:39

I want to create a line with two points, and move those two points.

Currently I'm using ManualObject, destroying the object and re-creating it each frame.
is there a better way to do it?

se5a

19-08-2014 20:34:05

here's how I'm doing it currently.

//ManualObject forceline = mSceneMgr.GetManualObject(so.IDName + "_ForceLine");
mSceneMgr.DestroyManualObject(so.IDName + "_ForceLine");
ManualObject forceline = mSceneMgr.CreateManualObject(so.IDName + "_ForceLine");
mNode_lines.AttachObject(forceline);
forceline.Begin("line_blue", RenderOperation.OperationTypes.OT_LINE_LIST);
forceline.Position(mvector3Position);
forceline.Position((mvector3Position) + (scaledforcevec));
forceline.End();


if I just GetManualObject (first commented line) instead of the following three lines, then it just created a whole bunch of separate lines.
I want to update the positions of the line. (I think destroying and creating objects is a bit slow?)

It's been suggested that I create an oblong mesh, stick it in the middle then rotate it, but that seems ass backwards.
also I need the lines visible all the way zoomed out, a mesh will go invisible before a manual object line does (which will still show as a dot)

whole class and project is here:
https://github.com/se5a/OrbMec2/blob/ma ... ne.cs#L452

Beauty

17-10-2014 00:42:54

ManualObject is a great class for that, but recreating is only a low-performance idea.

Create a ManualObject with indexes. Then you can call ManualObject.BeginUpdate() and change the coordinates. After the update call ManualObject.End().
Have a look to the ManualObject page. Example 3 shows how to create a MO with indexes. www.ogre3d.org/tikiwiki/ManualObject

Keep a reference to your ManualObject instance forceline in your application memory. So you always can access it.
(If you don't keep your reference, you need to re-search it by its name and the the scene manager).

By the way:
Sorry for my late answer. I don't use Mogre for 2 years now and have less free time. So I'm only here from time to time. But I like to help other Mogre users if I can.