Using a plugin to add a billboard to Virtual Earth 3D
To add objects to the VE3D world we need to create our own actor that knows how to render itself.
Actors descend from Microsoft.MapPoint.Rendering3D.Steps.Actors.Actor and must override the Render method. When it comes time to render a frame, all actors have their Render method called to queue up renderable objects. To show a billboard we'll create a BillboardActor and use a SpriteGraphicsObject to render our image.
public BillboardActor(LatLonAlt position)
{
this.texture = Texture.FromResource(this.GetType().Assembly, "VirtualEarth3DSamplePlugins.Billboard.Flower.png");
this.billboard = new SpriteGraphicsObject();
this.billboard.Texture = this.texture;
this.billboard.Mode = SpriteMode.Billboard;
this.billboard.Scale = new Vector2D(1000, 1000);
this.billboard.Color = Color.White;
this.billboard.AlphaEnable = true;
this.billboard.Position = position.GetVector();
}
public override void Render(Microsoft.MapPoint.Rendering3D.Scene.SceneState sceneState)
{
RenderQueues renderQueues = sceneState.GetData<RenderQueues>();
renderQueues.AddAlphaRenderable(0, this.billboard);
}
Once we have our actor we just need to add it to the ActorManager so it knows to start rendering it. We can do this in our Activate method on the plugin.
LatLonAlt position = LatLonAlt.CreateUsingDegrees(46.849743288383046, -121.7498016357422, 5000);
// Add the actor at the specified position
this.Host.Actors.Add(new BillboardActor(position));
You can browse the source code for the actor and the plugin online or download the entire project.
BillboardActor.cs | BillboardPlugin.cs
Download project