<?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 : X File</title><link>http://blogs.msdn.com/virtualearth3d/archive/tags/X+File/default.aspx</link><description>Tags: X File</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>Loading a model into VE3D</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/05/27/loading-a-model-into-ve3d.aspx</link><pubDate>Tue, 27 May 2008 22:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8555390</guid><dc:creator>NikolaiF</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/8555390.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=8555390</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;FONT face=Arial size=2&gt;Note:&amp;nbsp;&amp;nbsp;this entry references code for an older version of VE3D.&amp;nbsp; The newest code samples are &lt;/FONT&gt;&lt;A class="" 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;&lt;FONT face=Arial size=2&gt;here&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Commonly the models seen in any 3D product are created using specialized software packages, exported to a file, and then loaded into the end product.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Unfortunately this version of Virtual Earth 3D does not yet have full support for this process, but by being a little more adventurous (than you already are), you can do it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt" align=center&gt;&lt;FONT face=Calibri size=3&gt;&lt;IMG title="An x file in Virtual Earth 3D" style="WIDTH: 789px; HEIGHT: 374px" height=374 alt="An x file in Virtual Earth 3D" src="http://auldane.members.winisp.net/msdn/XFile.jpg" width=789 mce_src="http://auldane.members.winisp.net/msdn/XFile.jpg"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Although in theory the mechanisms in place in VE3D for specifying vertex buffers, index buffers, materials, etc, could be used to import most file formats by writing the converter yourself, most people don’t want to do that, especially given how complex the formats can be.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Until such mechanisms are solidly in place, we will use DirectX’s ability to read X files, as exposed by one of our internal classes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;We’ll convert that using relatively simple code into a MeshGraphicsObject (the same as used in SimpleObjectPlacement), wrap it in an Actor, and add it to our world.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The code shows how to do simple intersection tests against the mesh and animate it.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We also demonstrate one way to do labeling of objects.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;A class="" title="Sample Code" href="http://auldane.members.winisp.net/msdn/XFile.zip" mce_href="http://auldane.members.winisp.net/msdn/XFile.zip"&gt;Get Sample Code&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt" mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=4&gt;Will it break?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;There’s an important point to be made here:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;the whole API here is officially “unsupported”, which mostly means that we are happy to help you here on the blog, but we don’t, for example, have official documentation on MSDN.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;One reason we’re not calling it official is that we’re still working on refining the code, and we do expect to make changes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’d prefer not to break anyone, but if we need to change things in order to make it easier to not break you later – once that word changes to “supported” -- we’ll do it.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Only part of the code is going to be supported even after we flip that switch, specifically the assemblies that have been referenced in the samples we’ve released so far.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this sample, we reference Graphics3D, which is considered an internal assembly.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You can still reference things there, and they’ll work, but they’ll be harder to use, the documentation will be thinner, and the chances of breaking changes happening across versions will be higher.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;In short, everything now is “use at your own risk”, but some things are riskier than others, and this sample is in that category.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When we do break things we will release information on this blog about how to fix them, and update our samples as well.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8555390" 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/Virtual+Earth+3D/default.aspx">Virtual Earth 3D</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/X+File/default.aspx">X File</category></item></channel></rss>