In that post I am presenting a WinRT or Windows Store App project I’ve been working on for the past few weeks:
It is a 3D Viewer using a custom data format and web service we’ve been demoing during our last year Developer Days world wide conference.
The project is interesting because it deals with a various number of topics:
- 3D programming / DirectX on WinRT platform
- Local Storage in sandboxed WinRT Apps
- Touch / Gesture API
- REST / JSON Web Services
- XAML / UI
- Screen Selection / Ray Tracing
DirectX is the recommended technology by Microsoft in order to achieve 3D apps or games on the WinRT platform.
Using DirectX from a .Net language is doable using some extra framework. Several options are available at the time of this writing, some of them are more or less in beta phase, so they aren’t fully functional yet:
- SharpDX
- SlimDX
- AXN
After a bit of research, it appeared that SharpDX was the best working solution at the moment, especially that it provides a sub-framework named Toolkit, which makes it pretty straightforward to create 3D apps by abstracting most of the DirectX complexity away. For example, if like me you aren’t a DirectX game programmer expert and don’t know much about shaders, you don’t have to worry, as using the Toolkit framework will relieve you from putting yourself in that kind of trouble.
Here is an example of what a simple 3D app source code looks like when using that toolkit: MiniCube Demo
Doing web services REST requests on WinRT is pretty straightforward, especially that you can take advantage of the great async/await feature provided by .Net Framework 4.5.
Here is a sample code from the app that retrieves the list of models hosted by my web service:
async void GetModelsFromWeb()
{
try
{
string _hostAddress = "server_ip:port";
HttpWebRequest request = WebRequest.Create(
"http://" + _hostAddress + "/AdnViewerSrv/rest/GetDbModelData")
as HttpWebRequest;
using (HttpWebResponse response = await request.GetResponseAsync()
as HttpWebResponse)
{
StreamReader reader = new StreamReader(
response.GetResponseStream());
string jsonMsg = reader.ReadToEnd();
var modelData = JsonConvert.DeserializeObject
<List<AdnDbModelData>>(jsonMsg);
ItemListView.DataContext =
new ObservableCollection<object>(modelData);
}
}
catch
{
// Goes back to previous page
GoBack(this, null);
}
}
Here is a nice article about the capabilities of await if you want to read more about it.
You will be able to find the full source code of the Viewer on GitHub at this location. I was testing the app on both a Windows 8 – x64 machine and a Surface Pro tablet.
Comments
You can follow this conversation by subscribing to the comment feed for this post.