Now, the tricky part was getting information out using the call back so I could manipulate it. Map.ImportShapeLayerData(santaShapeSourceSpec, onGeoRSSLoad, 0) SantaShapeSourceSpec.MaxImportedShapes = 300 Var santaShapeSourceSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, ‘ ’, santaRouteLayer) In the ImportShapeLayerData() Method there are 3 arguments (a link to the XML file, the call back function after the file is loaded, and whether or not to set the best zoom level given the points). This was no easy task, so I hope some of this helps anyone else who is trying to push Virtual Earth’s limits. Well, I didn’t want to render the data I wanted to query an entity in the XML file to identify where Santa was at any given time. You simply use the ImportShapeLayerData() Method which natively imports file types such as GeoRSS, GPX and KML. Importing a GeoRSS file into Virtual Earth is simple. Map.Import3DModel(modelSpec, onSantaLoad, llCurrentPosition, sleighOrientation, null) Load the model into the 3D map instance (model source, callback, latlong, orient, scale) Var sleighOrientation = new VEModelOrientation(0, 0, 0) Var modelSpec = new VEModelSourceSpecification(VEModelFormat.OBJ, sourceSleighDirectory + “fullsleigh_1.obj”, NorthPoleLayer) LlCurrentPosition.AltitudeMode = VEAltitudeMode.Absolute More of why that is in the GeoRSS Parsing section below. This was dynamic since Santa would change position every 7.05 minutes. Here’s the code I used for Santa’s sleigh in real time. So, we sacrificed a bit of bandwidth for high resolution models. Plus, the textures downloaded simultaneous with the models. Why did they look so realistic? Much of that was a result of the high polygon count. We consolidated some of the models for ease and control of placement. All of this was done by Tom and the Caligari Community crew of Augusto Michelis, Heidi Simonsen, Matthew Collins and Stephen May (we can’t thank them enough). The Toy Shop, the carousel, the polar bears, etc. The real brilliance was the creativity in imagining up what the North Pole looks like, what entities to create and how to lay it all out. Importing the 3D models was also very straightforward using Import3DModel() Method. Var tileSourceSpec = new VETileSourceSpecification(“NorthPoleIslandTiles”, “ ”) Names layer for tiles and specifies location Doing it this way only rendered the Level 10 tiles, but at all 23 zoom levels (only 19 zoom levels are supported in the control, natively). I set the MinZoom and MaxZoom because the tiles that I created (for zoom levels 1-10) were actually getting called and putting a burden on the already heavy download of VE3D and the 3D models. I could’ve set it to 1 or 2 and it would’ve worked fine. Also, I set the ZIndex to a super high number just because I felt like it. Note that I set the NumServers property because of the load balancing in MSNBC’s farm. The code for importing my tiles was as follows (the entire solution is at the end of the post). The actual North Pole is somewhat of a black hole in VE3D that we shade the color of the ocean – so, don’t try to overlay tiles or lines there as it won’t work. So, I grabbed some icy Antarctica imagery (courtesy of LIMA), cut it into an island shape and dropped it at the magnetic North Pole using the AddTileLayer() Method. Like many things in Virtual Earth it’s not terribly difficult to overlay raster images over any area in Virtual Earth, especially if you use Map Cruncher to create the tiles. We used raster tile overlays, 3D model importation and GeoRSS importation and customization. However, I used quite a bit of Virtual Earth functionality, so I figured this was just as good a place to document some of it as any. I thought the biggest challenge for me was going to be figuring out when to start Santa flying and when to end him, but it turned out the parsing of a GeoRSS file for customization was more of a challenge. I’ll dig into this and actually provide you with my code (code junkies may skip to the end). But, tracking Santa was way more difficult because of the time constraints as to when Santa began his flight and when to end it, not to mention all of the coding behind ripping apart the GeoRSS file – well worth sharing. Now, The North Pole Experience wasn’t that hard – Tom (and his Caligari friends) built the models, I crunched the map tile overlays and then wrote the code to pull everything together. It started with The North Pole – A Virtual Earth Christmas Experience. And, hey, I was stoked – I got my application featured on MSN.com, so Merry Christmas to me! As Santa heads north for his annual slumber and we’re all left with buyer’s remorse and daunting credit card bills we can now reflect on something positive: how Christmas was changed this year for the better with a 3D version of tracking Santa using Microsoft Virtual Earth.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |