create a moving line


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?


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");
forceline.Begin("line_blue", RenderOperation.OperationTypes.OT_LINE_LIST);
forceline.Position((mvector3Position) + (scaledforcevec));

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: ... ne.cs#L452


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.

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.