Visual Studio 2013 3D Starter Kit

Where to get it

https://code.msdn.microsoft.com/windowsapps/Visual-Studio-3D-Starter-455a15f1

What is good about it

It is fast as it is built in C++

Basics of certain libraries added such as DirectXTex Texture Processing library

DirectXTex, a shared source library for reading and writing DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes a simple .TGA reader and writer since this image file format is commonly used for texture content processing pipelines, but is not currently supported by a built-in WIC codec.

Supported platforms:

  • Windows Store apps for Windows 8.1 / RT 8.1
  • Windows Store apps for Windows 8 / RT 8
  • Windows 8.x Win32 desktop
  • Windows Phone 8.1
  • Windows 7
  • Windows Vista
  • Windows Server equivalents of the above
  • Xbox One

http://directxtex.codeplex.com/

DirectXMesh geometry processing library

DirectXMesh, a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, and vertex cache optimization.

Supported platforms:

  • Windows Store apps for Windows 8.1 / RT 8.1
  • Windows Store apps for Windows 8 / RT 8
  • Windows 8.x Win32 desktop
  • Windows Phone 8.1
  • Windows 7
  • Windows Vista
  • Windows Server equivalents of the above
  • Xbox One

http://directxmesh.codeplex.com/

This starter kit also supports Universal apps and can be used to build games

Lets start I went across and opened the solution in Visual Studio 2013

Screenshot (231)

Ran the solution in Visual Studio 2013 and wanted to check if it compiles or not

Screenshot (232)

Everything was working perfect

The  Project ran

Screenshot (234)

Now my intent was to import one of my *.fbx file to check if it is transferable to the solution that also worked

Screenshot (235)

Well I had less time so was trying to implement the model but somehow it didn’t worked

Errors and Errors

Screenshot (236)

Tried reducing the error

reduced to an extent but still had errors

Screenshot (237)

easy way out I thought of changing simple things so I targeted the DirectXpage.Xaml.cpp .I found out that  it was easy to change the colors after the click so went about adding different  into color index

//Adding some colors and see if they respond to click

m_colors.push_back(Colors::Tan);

m_colors.push_back(Colors::AliceBlue);

m_colors.push_back(Colors::Navy);

m_colors.push_back(Colors::YellowGreen);

m_colors.push_back(Colors::Azure);

just Take a look at the DirectXpage.Xaml.cpp file

// DirectXPage.xaml.cpp

// Implementation of the DirectXPage class.

//

#include “pch.h”

#include “DirectXPage.xaml.h”

#include “StarterKitMain.h”

using namespace StarterKit;

using namespace Platform;

using namespace Windows::Foundation;

using namespace Windows::Foundation::Collections;

using namespace Windows::Graphics::Display;

using namespace Windows::System::Threading;

using namespace Windows::UI;

using namespace Windows::UI::Core;

using namespace Windows::UI::Input;

using namespace Windows::UI::Xaml;

using namespace Windows::UI::Xaml::Controls;

using namespace Windows::UI::Xaml::Controls::Primitives;

using namespace Windows::UI::Xaml::Data;

using namespace Windows::UI::Xaml::Input;

using namespace Windows::UI::Xaml::Media;

using namespace Windows::UI::Xaml::Navigation;

using namespace concurrency;

DirectXPage::DirectXPage() :

m_windowVisible(true),

m_hitCountCube(0),

m_hitCountCylinder(0),

m_hitCountCone(0),

m_hitCountSphere(0),

m_hitCountTeapot(0),

m_colorIndex(0)

{

InitializeComponent();

// Initialize Starter Kit state.

m_colors.push_back(Colors::Red);

m_colors.push_back(Colors::Violet);

m_colors.push_back(Colors::Indigo);

m_colors.push_back(Colors::Blue);

m_colors.push_back(Colors::Green);

m_colors.push_back(Colors::Yellow);

m_colors.push_back(Colors::Orange);

//Adding some colors and see if they respond to click

m_colors.push_back(Colors::Tan);

m_colors.push_back(Colors::AliceBlue);

m_colors.push_back(Colors::Navy);

m_colors.push_back(Colors::YellowGreen);

m_colors.push_back(Colors::Azure);

// Register event handlers for page lifecycle.

CoreWindow^ window = Window::Current->CoreWindow;

window->VisibilityChanged +=

ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &DirectXPage::OnVisibilityChanged);

DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView();

currentDisplayInformation->DpiChanged +=

ref new TypedEventHandler<DisplayInformation^, Object^>(this, &DirectXPage::OnDpiChanged);

currentDisplayInformation->OrientationChanged +=

ref new TypedEventHandler<DisplayInformation^, Object^>(this, &DirectXPage::OnOrientationChanged);

DisplayInformation::DisplayContentsInvalidated +=

ref new TypedEventHandler<DisplayInformation^, Object^>(this, &DirectXPage::OnDisplayContentsInvalidated);

swapChainPanel->CompositionScaleChanged +=

ref new TypedEventHandler<SwapChainPanel^, Object^>(this, &DirectXPage::OnCompositionScaleChanged);

swapChainPanel->SizeChanged +=

ref new SizeChangedEventHandler(this, &DirectXPage::OnSwapChainPanelSizeChanged);

// Disable all pointer visual feedback for better performance when touching.

auto pointerVisualizationSettings = PointerVisualizationSettings::GetForCurrentView();

pointerVisualizationSettings->IsContactFeedbackEnabled = false;

pointerVisualizationSettings->IsBarrelButtonFeedbackEnabled = false;

// At this point we have access to the device.

// We can create the device-dependent resources.

m_deviceResources = std::make_shared<DX::DeviceResources>();

m_deviceResources->SetSwapChainPanel(swapChainPanel);

m_main = std::unique_ptr<StarterKitMain>(new StarterKitMain(m_deviceResources));

m_main->StartRenderLoop();

}

DirectXPage::~DirectXPage()

{

// Stop rendering and processing events on destruction.

m_main->StopRenderLoop();

}

// Called when the Previous Color app bar button is pressed.

void DirectXPage::OnPreviousColorPressed(Object^ sender, RoutedEventArgs^ e)

{

if (m_colorIndex == 0)

{

m_colorIndex = m_colors.size() – 1;

}

else

{

m_colorIndex–;

}

ChangeObjectColor(L”Teapot_Node”, m_colorIndex);

}

// Called when the Next Color app bar button is pressed.

void DirectXPage::OnNextColorPressed(Object^ sender, RoutedEventArgs^ e)

{

m_colorIndex++;

if (m_colorIndex >= m_colors.size())

m_colorIndex = 0;

ChangeObjectColor(L”Teapot_Node”, m_colorIndex);

}

// Saves the current state of the app for suspend and terminate events.

void DirectXPage::SaveInternalState(IPropertySet^ state)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->Trim();

// Stop rendering when the app is suspended.

m_main->StopRenderLoop();

// Put code to save app state here.

}

// Loads the current state of the app for resume events.

void DirectXPage::LoadInternalState(IPropertySet^ state)

{

// Put code to load app state here.

// Start rendering when the app is resumed.

m_main->StartRenderLoop();

}

// Called when the SwapChainPanel is tapped.

void DirectXPage::OnTapped(Object^ sender, TappedRoutedEventArgs^ e)

{

auto currentPoint = e->GetPosition(nullptr);

String^ objName = m_main->OnHitObject((int)(currentPoint.X * swapChainPanel->CompositionScaleX), (int)(currentPoint.Y * swapChainPanel->CompositionScaleY));

if (objName != nullptr)

{

m_main->ToggleHitEffect(objName);

if (objName->Equals(L”Cylinder_Node”))

{

this->HitCountCylinder->Text = (++m_hitCountCylinder).ToString();

}

else if (objName->Equals(L”Cube_Node”))

{

this->HitCountCube->Text = (++m_hitCountCube).ToString();

}

else if (objName->Equals(L”Sphere_Node”))

{

this->HitCountSphere->Text = (++m_hitCountSphere).ToString();

}

else if (objName->Equals(L”Cone_Node”))

{

this->HitCountCone->Text = (++m_hitCountCone).ToString();

}

else if (objName->Equals(L”Teapot_Node”))

{

this->HitCountTeapot->Text = (++m_hitCountTeapot).ToString();

}

}

}

// Helper method to change an object’s color.

void DirectXPage::ChangeObjectColor(String^ objectName, int colorIndex)

{

auto color = m_colors[colorIndex];

m_main->ChangeMaterialColor(objectName, color.R / 255.0f, color.G / 255.0f, color.B / 255.0f);

}

// Window event handlers.

void DirectXPage::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)

{

m_windowVisible = args->Visible;

if (m_windowVisible)

{

m_main->StartRenderLoop();

}

else

{

m_main->StopRenderLoop();

}

}

// DisplayInformation event handlers.

void DirectXPage::OnDpiChanged(DisplayInformation^ sender, Object^ args)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->SetDpi(sender->LogicalDpi);

m_main->CreateWindowSizeDependentResources();

}

void DirectXPage::OnOrientationChanged(DisplayInformation^ sender, Object^ args)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->SetCurrentOrientation(sender->CurrentOrientation);

m_main->CreateWindowSizeDependentResources();

}

void DirectXPage::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->ValidateDevice();

}

void DirectXPage::OnCompositionScaleChanged(SwapChainPanel^ sender, Object^ args)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->SetCompositionScale(sender->CompositionScaleX, sender->CompositionScaleY);

m_main->CreateWindowSizeDependentResources();

}

void DirectXPage::OnSwapChainPanelSizeChanged(Object^ sender, SizeChangedEventArgs^ e)

{

critical_section::scoped_lock lock(m_main->GetCriticalSection());

m_deviceResources->SetLogicalSize(e->NewSize);

m_main->CreateWindowSizeDependentResources();

}

Then Compile and deployed the project

Screenshot (241)

When you click the Objects the color changes reflects

The main files in the project

  • Game.cpp  where all the game logic is written
  • The Game.h file have has some important declarations

My angel was unhappy today so dedicated this blog to little angel. Hope all will like it and the great thing about C++ is initially you will hate it but more time you spend and more you dig in deep ,you will fall in love with it .More to follow

Advertisements

One thought on “Visual Studio 2013 3D Starter Kit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s