Anyone messed with these?
I'm strugling to find even ogre examples, and the little I can find doesn't seem to translate to mogre well.
the best I can come up with so far is:
BillboardChain bbchain = new BillboardChain("beam2");
BillboardChain.Element_NativePtr bbcElement = new BillboardChain.Element_NativePtr();
that crashes "Attempted to read or write protected memory"
I can't see how I'm suposed to set the length, and setting the element width causes a System.NullReferenceException
(I'm trying to create a beam between a ship and a point)
Ahh, I figured it was likely something like that. thanks that explains it.
ok it doesnt crash now, but I see Ogre has a BillboardChain::ChainSegment which seems to be where you set the head, start and tail (though what these are and do *exactly* is a little unclear to me)
However I don't even see a ChainSegement in mogre. (or at least, intelisense is not showing me anything remotly relevent)
I don't think you need to do anything with the ChainSegemnt. It looks like that is handled automatically. Just set the number of chainsegments you want and then add elements to a particular segment by index. This looks like an example, haven't tried it myself though. viewtopic.php?f=8&t=7917
Oh nice find!
wonder how come my google fu missed that one.
a very simplified version of the above lightning bolt in an attempt to understand what's going on (and failing)
this doesn't show anything:
static uint beamcounter = 0;
System.Windows.Forms.Timer fTimer; //Single thread timer-safe with Ogre.
private float mDuration; //Duration of the bolt
private float time; //current lifetime of the bolt
public BeamEffect(SceneManager msceneMgr, SpaceObjects so, NewtMath.d.PointXd targetPoint, float Duration)
fireFrom = so;
NewtMath.d.PointXd sPnt = new NewtMath.d.PointXd(so.Location);
NewtMath.d.PointXd ePnt = new NewtMath.d.PointXd(targetPoint);
time = 10; // undesirable to start at time = 1
mDuration = Duration + time;
lightEffect = msceneMgr.CreateLight("light" + beamcounter);
lightEffect.Type = Light.LightTypes.LT_POINT;
lightEffect.Position = lerp(TranslateMogrePhys.smVector_mVector3(sPnt), TranslateMogrePhys.smVector_mVector3(ePnt), 0.5f);
lightEffect.DiffuseColour = new ColourValue(1, 1, 1);
lightEffect.SpecularColour = new ColourValue(1, 1, 1);
fTimer = new System.Windows.Forms.Timer();
fTimer.Tick += new EventHandler(Update);
fTimer.Interval = 1; // Update never gets called directly.
mBB = msceneMgr.CreateBillboardChain("LightBB" + beamcounter);
mBB.NumberOfChains = 1; //base invisible and then visible.
mBB.MaxChainElements = 1; //longest chain
//mBB.MaterialName = "Roys/Lightning"; //Similar effect to FlarePointSprite
//mBB.MaterialName = "Examples/FlarePointSprite"; //no shader is used as of yet
mBB.Visible = true;
mNode = new SceneNode(msceneMgr);
mNode = msceneMgr.RootSceneNode.CreateChildSceneNode();
mNode.AttachObject(mBB); //attach to a node.
public void Update(object sender, EventArgs e)
NewtMath.d.PointXd sPnt = new NewtMath.d.PointXd(fireFrom.Location);
//NewtMath.d.PointXd ePnt = new NewtMath.d.PointXd(targetPoint);
Vector3 position = lerp(TranslateMogrePhys.smVector_mVector3(sPnt), new Vector3(1000, 0, 0), 0.5f);
ColourValue mColor = new ColourValue(1, 0, 0);
BillboardChain.Element_NativePtr bbPtr = BillboardChain.Element_NativePtr.Create(position, 8, 1, mColor);
mBB.AddChainElement(0, bbPtr); //first variable is which chain to inject the element into.
if (time >= mDuration)
time += 60; //kludge number for now.
fTimer.Interval = 60; //Temporary kludge
public Vector3 lerp(Vector3 start, Vector3 end, float a)
return (start + ((end - start) * a));
private void ShutDown()
LogManager.Singleton.LogMessage("ShutDown in Beam fired");
lightEffect.Visible = false;
lightEffect = null;
mBB = null;
I can see that it is firing since the lightEffect casts a light on the ships when it fires, but other than that. no beam. I've just used a single chain segment, and no noise in an attempt to keep it very simple.
It looks like you're only adding one particle to the chain. My guess is that a single particle is too small to notice on screen. If I understand BillboardChains correctly, the point is to make a trail or 'chain' of particles from one point to another. In your case this would probably mean adding particles from your source ship until you reach your target ship in a loop of some kind.