<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Virtual Earth 3D team blog : Actor</title><link>http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx</link><description>Tags: Actor</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>X File bulk display</title><link>http://blogs.msdn.com/virtualearth3d/archive/2009/09/20/x-file-bulk-display.aspx</link><pubDate>Mon, 21 Sep 2009 00:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9897332</guid><dc:creator>NikolaiF</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9897332.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9897332</wfw:commentRss><description>&lt;P&gt;I was asked the other day about how to load multiple x file -based models into VE3D without having to place each one manually.&amp;nbsp; I've written up a &lt;A title="X File DataSource sample" href="http://www.veteam.members.winisp.net/Spaceland/blog/XFileDataSource.zip" mce_href="http://www.veteam.members.winisp.net/Spaceland/blog/XFileDataSource.zip"&gt;sample here&lt;/A&gt;.&amp;nbsp; The idea is more or less a fusion of the existing ActorDataSource and XFile samples, using the actor from the XFile sample rather than the bunnies.&amp;nbsp; I've also mocked up a very simple data file that contains placement information, rather than generating data on the fly as for the bunnies.&lt;/P&gt;
&lt;P&gt;The way I've done this, the parsing code for the x files is done in the actor.&amp;nbsp; In this way, swapping out file formats should be straightforward so long as you have parsing code for it (sorry, only x files are directly implemented in the engine, but the results of any parse should still be easily convertible into VE3D graphics objects).&lt;/P&gt;
&lt;P&gt;For the sake of simplicitly I did do one thing wrong.&amp;nbsp; The flow of the code is like this:&amp;nbsp; multiple background threads all execute QueryPrimitivesInternal at the same time, and when they are finished, they move through a lock into ActorBuilder.&amp;nbsp; They are still on background threads, but they now execute serially.&amp;nbsp; So, really the data retrieval (in this case, loading from resources, but probably a network request) and the parsing, as appropriate, should happen in QueryPrimitivesInternal, and the action in ActorBuilder should be kept to a minimum.&amp;nbsp; I violated this rule in the sample code for the sake of illustration, but you should be aware of it.&lt;/P&gt;
&lt;P&gt;Finally, an important consideration is level of detail.&amp;nbsp; Dense and numerous models can slow down loading and rendering.&amp;nbsp; DataSources take advantage of the ActorBounds and scale concepts, such that it is possible to use simplified models at certain LODs, and switch to more detailed as the user zooms in.&amp;nbsp; If your needs are less extreme, then you can simply use scale to cause models to stop rendering when not in view, and at a certain distance, which is what I have done in the sample.&lt;/P&gt;
&lt;P&gt;Have fun!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9897332" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/X+File/default.aspx">X File</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/DataSource/default.aspx">DataSource</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx">Actor</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Bing+Maps+3D/default.aspx">Bing Maps 3D</category></item><item><title>Actor data source questions</title><link>http://blogs.msdn.com/virtualearth3d/archive/2009/07/26/actor-data-source-questions.aspx</link><pubDate>Sun, 26 Jul 2009 21:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9849338</guid><dc:creator>NikolaiF</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9849338.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9849338</wfw:commentRss><description>&lt;P&gt;I just fielded a few good questions via email about actor data sources, and thought it would make a good post.&lt;/P&gt;
&lt;P&gt;Actor data sources are a way of getting little bits of your code (actors) into the world, handing spatial indexing and cache management for you.&amp;nbsp; When each actor is in view, they are given the opportunity to execute code in the Render and Update functions.&amp;nbsp; When the cache is full and an actor is evicted, they again may execute code in the OnRemove function.&lt;/P&gt;
&lt;P&gt;You create them by implementing a DataSource with usage Actor, and an ActorBuilder which translates the Primitives returned into Actor objects, along with information like what areas of the Earth the actors should be used in, as an ActorBounds object.&amp;nbsp; All of this can be seen in the &lt;A title=ActorDataSource href="http://www.veteam.members.winisp.net/Spaceland/Samplesv4/ActorDataSource/TestPage.htm" mce_href="http://www.veteam.members.winisp.net/Spaceland/Samplesv4/ActorDataSource/TestPage.htm"&gt;ActorDataSource&lt;/A&gt; &lt;A title=Samples href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" target=_blank mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;sample&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;In the sample, however, only one Primitive is returned per request, and only one Actor.&amp;nbsp; What if you want more?&amp;nbsp; The important thing to know is that there has to be a 1-1 correspondence between Primitives and Actors *.&amp;nbsp; You must create one Actor for every Primitive used.&amp;nbsp; If you create more than one Actor for a single Primitive, only one will appear.&lt;/P&gt;
&lt;P&gt;The reason for this is the Actor update story.&amp;nbsp; It is possible to update an Actor already in the system by two methods.&amp;nbsp; When an Actor is updated, the PrimitiveId from the passed-in primitive is used to find and update the actor in question.&amp;nbsp; If you add multiple actors per primitive, an ambiguity arises as to what you actually want to do.&lt;/P&gt;
&lt;P&gt;It is possible to resolve this ambiguity by creating "nested" actors.&amp;nbsp; This is simple.&amp;nbsp; Just create the actors you want, and then a "container"&lt;/P&gt;
&lt;P&gt;*:&amp;nbsp; actually you can create a single Actor with multiple Primitives, but I don't want to confuse the issue for now.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;U&gt;Updating an Actor:&lt;/U&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Expiration.&lt;/STRONG&gt;&amp;nbsp; On the Entity attached to your primitive, add a property "ExpiresInSeconds":&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;e.EntityTypes["bunny"].Properties.Create("ExpiresInSeconds", typeof(double));&lt;/P&gt;
&lt;P mce_keep="true"&gt;...&lt;/P&gt;
&lt;P mce_keep="true"&gt;entitySpec.Properties.SetValue("ExpiresInSeconds", 10.0);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;Your QueryPrimitivesInternal function will be called again for every area the affected Actors live, and OnRemove will be called for the expiring Actors.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Manual.&lt;/STRONG&gt;&amp;nbsp; You can specify a specific PrimitiveId to update using OnDataChanged in your source DataSource.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;PrimitiveIdWriteableCollection wc = new PrimitiveIdWriteableCollection();&lt;BR&gt;wc.Add(new BunnyPrimitiveId(this, tile));&lt;BR&gt;OnDataChanged(new SpatialExtent(null, null, wc.GetReadOnlyCopy()));&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P mce_keep="true"&gt;You must also implement the QueryPrimitivesByIdsInternal function.&amp;nbsp; A collection of ids is provided, and you must return an array of Primitives that matches the input (so, the first item in the id collection should result in a Primitive at array index 0, etc).&amp;nbsp; If an element of the array is left null, that means to delete the Actor corresponding to that PrimitiveId.&amp;nbsp; Your ActorBuilder is then called to allow you to create the new replacement Actors.&lt;/P&gt;
&lt;P mce_keep="true"&gt;You can also specify a region of the Earth to update in the SpatialExtent, but update by entity is not supported.&amp;nbsp; Updating very large areas can be expensive, so use spatial regions with care.&amp;nbsp; Update by PrimitiveId is the most efficient.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9849338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/VE3D/default.aspx">VE3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/DataSource/default.aspx">DataSource</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx">Actor</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Bing+Maps+3D/default.aspx">Bing Maps 3D</category></item><item><title>Animated Textures</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/11/19/animated-textures.aspx</link><pubDate>Wed, 19 Nov 2008 03:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9121187</guid><dc:creator>NikolaiF</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9121187.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9121187</wfw:commentRss><description>&lt;P&gt;In addition to using dynamic buffers to animate geometry, you can also animate the textures on geometry.&amp;nbsp; This is accomplished by using BitmapProvider.&amp;nbsp; A BitmapProvider at its simplest is just a wrapper for a Bitmap, which can be used as the icon for a pushpin or the data for a texture that should be applied to geometry that you create in an Actor.&amp;nbsp; In fact, if you just have&amp;nbsp;a single image you can use SingleBitmapProvider.&amp;nbsp; You expose this Bitmap via the CurrentImage property.&amp;nbsp; You also have to provide the size of the image upfront using ImageSize.&amp;nbsp; If you want to change the texture, the system polls the NewImageAvailable property.&amp;nbsp; If you return true, the system re-reads CurrentImage and copies data into the display texture.&amp;nbsp; When it is done, it calls OperationCompleted.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Animated pin" href="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/TestPage.htm" mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/TestPage.htm"&gt;&lt;IMG title="Animated pin" style="WIDTH: 673px; HEIGHT: 560px" height=560 alt="Animated pin" src="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/sample.jpg" width=673 mce_src="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/sample.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Animated pin" href="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/AnimatedPins/TestPage.htm"&gt;See it in action!&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In this sample, we use a pushpin created with our own BitmapProvider.&amp;nbsp; This provider reads the&amp;nbsp;previous screen buffer, creating an infinite mirror effect.&amp;nbsp; We could actually clean this sample up a bit in two ways:&amp;nbsp;by implementing HasFrequentUpdates to return true (causing it to animate continuously) and removing the call to Host.NeedUpdate, and by implementing OperationCompleted to dispose current.&lt;/P&gt;
&lt;P&gt;In a more realistic example, we might have a thread that periodically queries the url of a traffic cam.&amp;nbsp; When the image data arrives, set NewImageAvailable to true, provide the new image, and in OperationCompleted signal the query thread to get a new image.&lt;/P&gt;
&lt;P&gt;For a demonstration of how to do this using Actors, copy the ScreenshotProvider class from AnimatedPins to BezierSurface, and change SurfacePlugIn.cs, line 91, to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Texture t = Texture.FromBitmapProvider(new ScreenshotProvider(this.Host));&lt;/P&gt;
&lt;P&gt;and presto! you get the same effect.&lt;/P&gt;
&lt;P&gt;Finally, SingleImageProvider has code built in to deal with animated gifs.&amp;nbsp; Simply create a bitmap with the animated gif,&amp;nbsp;hand it to SingleImageProvider, that to your pin or&amp;nbsp;Texture,&amp;nbsp;and everything should go on its own from there.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Sample code" href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;Get the code!&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9121187" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/VE3D/default.aspx">VE3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx">Actor</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Animation/default.aspx">Animation</category></item><item><title>Animation Redux</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/11/11/animation-redux.aspx</link><pubDate>Tue, 11 Nov 2008 04:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9059049</guid><dc:creator>NikolaiF</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9059049.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9059049</wfw:commentRss><description>&lt;P&gt;This sample was &lt;A class="" title=Animation href="http://blogs.msdn.com/virtualearth3d/archive/2008/07/08/animation.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/07/08/animation.aspx"&gt;released before&lt;/A&gt;, but didn't have a version that could run on the web without an install.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Get the code!" href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;The new version&lt;/A&gt;&amp;nbsp;in the samples pack is almost exactly the same, so I won't go over it again in detail.&amp;nbsp; This post is just to show it off interactively.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Bezier Surface Animation" href="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/TestPage.htm"&gt;&lt;IMG title="Bezier Surface Animation" style="WIDTH: 747px; HEIGHT: 488px" height=488 alt="Bezier Surface Animation" src="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/sample.jpg" width=747 mce_src="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/sample.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Bezier Surface Animation" href="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/BezierSurface/TestPage.htm"&gt;See it in action!&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When the page loads, press "S" after the text appears.&amp;nbsp; You can then grab the green balls with the mouse to deform the surface.&amp;nbsp; Left-click and drag causes it to deform to the new location and then slowly return; right-click and drag causes it to move to the new shape permanently.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9059049" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/VE3D/default.aspx">VE3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Plug-In/default.aspx">Plug-In</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx">Actor</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Animation/default.aspx">Animation</category></item><item><title>Actors and DataSources</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/10/27/actors-and-datasources.aspx</link><pubDate>Mon, 27 Oct 2008 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9019051</guid><dc:creator>NikolaiF</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9019051.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9019051</wfw:commentRss><description>&lt;P&gt;In this sample, we create a DataSource, which is a class that can be used for large-scale data sets.&amp;nbsp; It provides hooks into the system's spatial index, memory cache, and background data threads.&amp;nbsp; Data from the DataSource will only be requested when it is in view, and will be automatically cached according to how often it is used and how much memory it consumes.&amp;nbsp; The DataSource we create is a purely generated one consisting of a large number of animated bunnies spread&amp;nbsp;evenly across the globe, and would be impossibly large to try to deal with all at once.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Bunny Sample" href="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/TestPage.htm"&gt;&lt;IMG title="Bunny Sample" style="WIDTH: 916px; HEIGHT: 685px" height=685 alt="Bunny Sample" src="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/sample.jpg" width=916 mce_src="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/sample.jpg"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Bunny Sample" href="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/ActorDataSource/TestPage.htm"&gt;See it in action!&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the PlugIn is Activated, the ActorDataSource is created and added to the system.&amp;nbsp; When we create the DataSource we set up its Ontology, which is a system for defining the type of data the DataSource contains.&lt;/P&gt;
&lt;P&gt;The next time the Camera Query runs, a set of areas in the Spatial Index that are in view are determined,&amp;nbsp;called tiles.&amp;nbsp; Each tile is sent as a lat/long bounding box to the Data Threads, which call all added DataSources, including ours.&amp;nbsp; The entry point here is QueryPrimitivesInternal.&amp;nbsp; In this function we would normally do some sort of query to a backend, such as a SQL database or the network, but for simplicity we simply create a BunnyPrimitive in the center of the query region.&amp;nbsp; A primitive is a piece of data that represents a thing in the world, in the case a Bunny, but is not itself an Actor.&amp;nbsp; When we return the Primitive, it is passed to our ActorBuilder, called BunnyBuilder.&amp;nbsp; This creates actual Actors which can render or react to the data&amp;nbsp;represented by each Primitive.&amp;nbsp; Each Actor also needs an ActorBounds, which represents a spatial area that, when&amp;nbsp;in view, should cause it to render.&amp;nbsp; When this happens each Actor's Update and Render functions are called on the Render Thread just like normal Actors.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Get the code!" href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/09/25/current-samples.aspx"&gt;Get the code!&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9019051" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Code/default.aspx">Code</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/VE3D/default.aspx">VE3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Plug-In/default.aspx">Plug-In</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/DataSource/default.aspx">DataSource</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Actor/default.aspx">Actor</category></item></channel></rss>