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");
bbchain.SetMaterialName("beam1");
BillboardChain.Element_NativePtr bbcElement = new BillboardChain.Element_NativePtr();
bbchain.AddChainElement(0, bbcElement);
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)
BrainScan
27-02-2014 10:54:05
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)
BrainScan
02-03-2014 23:21:11
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:
class BeamEffect
{
static uint beamcounter = 0;
BillboardChain mBB;
SceneNode mNode;
Light lightEffect;
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
SpaceObjects fireFrom;
public BeamEffect(SceneManager msceneMgr, SpaceObjects so, NewtMath.d.PointXd targetPoint, float Duration)
{
beamcounter++;
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.
fTimer.Start();
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.SetMaterialName("Examples/FlarePointSprite");
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)
{
mBB.ClearAllChains();
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)
{
ShutDown();
}
else
{
//adjustLight(offset.Length);
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()
{
fTimer.Dispose();
LogManager.Singleton.LogMessage("ShutDown in Beam fired");
lightEffect.Visible = false;
lightEffect.Dispose();
lightEffect = null;
mBB.ClearAllChains();
mBB.Dispose();
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.
BrainScan
06-03-2014 21:34:40
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.