<?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 : Camera</title><link>http://blogs.msdn.com/virtualearth3d/archive/tags/Camera/default.aspx</link><description>Tags: Camera</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Two good questions</title><link>http://blogs.msdn.com/virtualearth3d/archive/2009/12/08/two-good-questions.aspx</link><pubDate>Tue, 08 Dec 2009 18:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9934226</guid><dc:creator>NikolaiF</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9934226.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9934226</wfw:commentRss><description>&lt;P&gt;Posting some answers to questions I've gotten recently.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Bug in the samples:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Kind of silly that I hadn't noticed this until now, but there's an error in the sample html for most of the samples.&amp;nbsp; The name of the functions used for plug-in load and activate conflict with an internal name used in the AJAX code.&amp;nbsp; Change "On3DPlugInLoaded" and "On3DPlugInActivated" to any other name, for example "PlugInLoaded" and "PlugInActivated".&amp;nbsp; Remember to change both your function name and the string passed to AttachEvent.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Zoom or Rotate around a point:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;There have been several requests about how to allow people to zoom or rotate around a particular point on the screen, rather than the center.&amp;nbsp; The &lt;A title="Rotate/Zoom code" href="http://www.veteam.members.winisp.net/Spaceland/blog/PointZoomRotatePlugIn.zip" mce_href="http://www.veteam.members.winisp.net/Spaceland/blog/PointZoomRotatePlugIn.zip"&gt;code&lt;/A&gt;&amp;nbsp;here isn't as cleaned up as I normally like it, but it illustrates the ideas.&amp;nbsp; You can do the rotate by purely calling built-in VE3D functions via the bindings system, but zoom requires a bit more work.&amp;nbsp; To run the code, replace files in the Multitouch &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; with the files in the zip.&amp;nbsp; You will want to call or adapt the calls to GestureEventSource to be in response to your inputs, rather than the worker thread I created.&lt;/P&gt;
&lt;P&gt;Remember you can contact me any time via the contact form, or if you prefer via comments.&amp;nbsp; Even if it looks like I haven't posted recently :)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9934226" width="1" height="1"&gt;</description><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/Camera/default.aspx">Camera</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Bing+Maps+3D/default.aspx">Bing Maps 3D</category></item><item><title>Constraining camera movement</title><link>http://blogs.msdn.com/virtualearth3d/archive/2009/08/07/constraining-camera-movement.aspx</link><pubDate>Fri, 07 Aug 2009 20:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9860472</guid><dc:creator>NikolaiF</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9860472.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9860472</wfw:commentRss><description>&lt;P&gt;Just got a good question:&amp;nbsp; what if I want to prevent the camera from moving outside certain bounds, for example to restrict altitude?&lt;/P&gt;
&lt;P&gt;Technically it may be best to implement your own CameraController, so that you can make sure the restrictions are done smoothly for all cases.&amp;nbsp; But for many cases a simple mechanism will do.&amp;nbsp; Here it is:&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;this&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;.Host.CameraControllers.CameraChanged += &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;CameraControllerManager&lt;/SPAN&gt;.&lt;SPAN style="COLOR: #2b91af"&gt;CameraChangedEventHandler&lt;/SPAN&gt;(CameraControllers_CameraChanged);&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; CameraControllers_CameraChanged(Microsoft.MapPoint.Rendering3D.Cameras.&lt;SPAN style="COLOR: #2b91af"&gt;PredictiveCamera&lt;/SPAN&gt; camera)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (camera.Viewpoint.Position.Altitude &amp;gt; 10000)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;camera.Viewpoint.Position.Altitude = 10000;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;&lt;SPAN style="mso-tab-count: 3"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-bidi-language: HE; mso-no-proof: yes"&gt;}&lt;/SPAN&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9860472" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Camera/default.aspx">Camera</category></item><item><title>Camera Control</title><link>http://blogs.msdn.com/virtualearth3d/archive/2008/10/22/camera-control.aspx</link><pubDate>Wed, 22 Oct 2008 20:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9011369</guid><dc:creator>NikolaiF</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/virtualearth3d/comments/9011369.aspx</comments><wfw:commentRss>http://blogs.msdn.com/virtualearth3d/commentrss.aspx?PostID=9011369</wfw:commentRss><description>&lt;P&gt;In this sample, we create a plug-in to move the camera to a random location in the world every time a HTML button is pressed.&amp;nbsp; It demonstrates basic plug-in loading, writing and using a CameraController, and communicating between a plug-in and the hosting web page via Events.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Camera Control" href="http://www.veteam.members.winisp.net/Spaceland/Samples/Camera/TestPage.htm" target=_blank mce_href="http://www.veteam.members.winisp.net/Spaceland/Samples/Camera/TestPage.htm"&gt;See it in action.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Camera controllers&amp;nbsp;are important because it provides a single and consistent way of updating the camera.&amp;nbsp; Consistency is important because the camera needs to be in one position throughout an entire frame -- otherwise one part of the code may think the camera is in one place while another thinks it's elsewhere.&amp;nbsp; This is why you normally read the camera through its Snapshot in the SceneState object, and can only set it via a controller, of which there may only be one active at a time.&lt;/P&gt;
&lt;P&gt;Normally you position the camera with two properties, the position and the orientation.&amp;nbsp; Either can be set in terms of global or local coordinates.&amp;nbsp; Global essentially means relative to the center of the earth, while local means relative to your current location on the globe.&amp;nbsp; For position, global coordinates are in terms of Vector3D, local in terms of latitude, longitude, and altitude.&amp;nbsp; For orientation, you would normally set it globally in terms of lookat and lookup, Vector3Ds, and locally in terms of roll, pitch, and yaw.&amp;nbsp; See the &lt;A class="" title="Basic Math" href="http://blogs.msdn.com/virtualearth3d/archive/2008/05/06/basic-math.aspx" mce_href="http://blogs.msdn.com/virtualearth3d/archive/2008/05/06/basic-math.aspx"&gt;Basic Math&lt;/A&gt; entry for more.&lt;/P&gt;
&lt;P&gt;When this plug-in is Activated, it creates a new JumpController and begins listening to an event from CommunicationManager, but otherwise doesn't do anything.&amp;nbsp; The script on TestPage.htm is then able to raise that event, which causes JumpHandler to be fired.&amp;nbsp; A new random position is generated and given to the JumpController.&amp;nbsp; The JumpController is then set to be the current CameraController.&amp;nbsp; The next time the render thread calls the CameraStep, the JumpController will be called instead of the Default controller.&amp;nbsp; The JumpController's Activate function is called first, and it indicates that HasArrived&lt;BR&gt;is false, which means it still has work to do.&amp;nbsp; The MoveCamera is called, and the JumpController is allowed to modify its Camera property.&amp;nbsp; The CameraStep will use these values to set up the next scene and frame for rendering.&amp;nbsp; In addition, the JumpController sets HasArrived to true, indicating it has&lt;BR&gt;completed its work.&amp;nbsp; This causes the system to automatically swap JumpController's Next controller to be the Current one, in this case simply restoring control to the Default.&lt;/P&gt;
&lt;P&gt;If we wanted to animate to the location, we would adjust the current position a little at a time over a series of calls to MoveCamera, and only when we are down would we set HasArrived to true.&amp;nbsp; We could also take over completely, using Bindings to detect user input and making changes to Camera as needed,&lt;BR&gt;and only setting HasArrived when we want to return control to the Default.&lt;/P&gt;
&lt;P&gt;Note, at this time we only support one camera and one viewpoint at a time.&lt;/P&gt;
&lt;P&gt;&lt;A class="" title="Code samples" 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=9011369" 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/Math/default.aspx">Math</category><category domain="http://blogs.msdn.com/virtualearth3d/archive/tags/Camera/default.aspx">Camera</category></item></channel></rss>