Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Tech News

3711 Articles
article-image-swift-for-tensorflow-is-now-open-source
Richard Gall
01 May 2018
3 min read
Save for later

Swift for TensorFlow is now open source

Richard Gall
01 May 2018
3 min read
TensorFlow has continued its success in 2017 well into 2018. It's quickly expanding its capabilities, and we're beginning to see it used by engineers that aren't data specialists.  We've seen that in the launch of TensorFlow.js, which allows you to bring machine learning to the browser. But Swift for TensorFlow is a slightly different proposition. In fact, it does two things. On the one hand it offers a new way of approaching TensorFlow, but it also helps to redefine Swift. Let's be honest - Swift has come a long way since it was first launched by Apple back at WWDC 2014. Back then it was a new language created to reinvigorate iOS development. It was meant to make Apple mobile developers happier and more productive. That is, of course, a noble aim - and by and large it seems to have worked. If it hadn't we probably wouldn't still be talking about it. But Swift for TensorFlow marks Swift as a powerful modern programming language that can be applied to some of the most complex engineering problems. What is Swift for TensorFlow? Swift for TensorFlow was first unveiled at the TensorFlow Dev Summit in March 2018. Now it's open source, it's going to be interesting to see how it shapes the way engineers use TensorFlow - and, of course, how the toolchain might shift. But what is it exactly? Watch the video below, recorded at TensorFlow Dev Summit, to find out more. https://www.youtube.com/watch?v=Yze693W4MaU Here's what the TensorFlow team had to say about Swift for TensorFlow in a detailed post on Medium. "Swift for TensorFlow provides a new programming model that combines the performance of graphs with the flexibility and expressivity of Eager execution, with a strong focus on improved usability at every level of the stack. This is not just a TensorFlow API wrapper written in Swift — we added compiler and language enhancements to Swift to provide a first-class user experience for machine learning developers." Why did TensorFlow choose Swift? This is perhaps the key question: why did the TensorFlow team decide to use Swift for this project? The team themselves note that they are often asked this question themselves. Considering many of the features of Swift for TensorFlow can easily be implemented in other programming languages, it's a reasonable question to ask. To properly understand why TensorFlow chose Swift you need to go back to the aims of the project. And they're actually quite simple - the team want to make TensorFlow more usable. They explain: "We quickly realized that our core static analysis-based Graph Program Extraction algorithm would not work well for Python given its highly dynamic nature. This led us down the path of having to pick another language to work with, and we wanted to approach this methodically." The post on GitHub is well worth reading. It provides a detailed insight into how to best go about evaluating the advantages and disadvantages of one programming language over another. Incidentally, The TensorFlow team say the final shortlist of languages was Swift, Rust, Julia, and C++. Swift ended up winning out - there were 'usability concerns' around C++ and Rust, and compared to Julia not only was there a larger and more active community, it is also much more similar to Python in terms of syntax.
Read more
  • 0
  • 0
  • 11387

article-image-splunk-leverages-ai-in-its-monitoring-tools
Richard Gall
30 Apr 2018
2 min read
Save for later

Splunk leverages AI in its monitoring tools

Richard Gall
30 Apr 2018
2 min read
Just weeks after the announcement of Splunk IAI (Industrial Asset Intelligence), Splunk has revealed it will be enhancing machine learning across many of its products. This includes Splunk Enterprise, IT Service Intelligence, and User Behavior Analytics. Clearly, the company are using Spring 2018 as a period to build a solid foundation to future-proof their products. Splunk has also added an 'Experiment Management Interface' to its Machine Learning Toolkit. This is a crucial update that will make tracking machine learning and AI 'experiments' much easier. It means that monitoring a range of issues will become much easier. Splunk's goal here is to ensure a reduction in what it calls "event noise." The machine learning and AI algorithms will help to cut through the amount of data and information at users' disposal. It will allow them to identify the issues that are most business-critical. It's about more than just analytics - it's about the additional dimension that makes prioritization much more straightforward. That's what distinguishes what Splunk are doing compared to competitors. Typically, machine learning in BI software allows users to monitor issues, but doesn't have the capacity to place issues in a wider business context. There are a wide range of applications for this technology. It could be used to identify security issues within a given system, application performance, or even operational management. Tim Tully, CTO, had this to say: "Our latest wave of innovation is intended to arm customers with the tools needed to translate AI into actionable intelligence. While AI and machine learning often seem like unattainable and expensive pipe dreams, Splunk Cloud and Splunk Enterprise now make it easier and more affordable to monitor, analyze and visualize machine data in real time" Of course, while Tully's words contain an element of marketing-speak, made for a press release, it's worth noting that the goal here from Splunk's perspective is all about making AI and machine learning more accessible. Clearly the company knows what their customers want. This suggests, then, that for all the discussion around the machine learning revolution, there are still many businesses that regard machine learning as a considerable challenge.
Read more
  • 0
  • 0
  • 16684

article-image-flask-1-0-is-here-updates-and-improvements
Richard Gall
30 Apr 2018
2 min read
Save for later

Flask 1.0 is here: updates and improvements

Richard Gall
30 Apr 2018
2 min read
Flask is a Python microframework that has been around for a while. It was first released in April 2010; 8 years on, it finally reaches its first stable release. While this is perhaps the first major release, the framework is the most popular Python web framework on GitHub. Not bad for a framework that started life as an April fool's joke. In truth, Flask has been 'stable' for some time, even if it wasn't officially. However, the announcement of Flask 1.0 is important, as it brings with it a few key changes that might be instrumental in growing the community. What's new in Flask 1.0? More flexible CLI. In the release notes, the team explains: "FLASK_APP can point to an app factory, optionally with arguments. It understands import names in more cases where filenames were previously used. It automatically detects common filenames, app names, and factory names. FLASK_ENV describes the environment the app is running in, like development, and replaces FLASK_DEBUG in most cases." Flask can now handle concurrent requests in development. You can test an application's CLI commands with test_cli_runner. Improvements to documentation. In what is sure to improve the number of Flask users, the team have made changes to the documentation available. This represents a step towards more structure and control within the project. The team have app.logger. They write that it "has been greatly simplified and should be much easier to customize. The logger is always named flask.app, it only adds a handler if none are registered, and it never removes existing handlers." There many more updates and improvements. You can read about them in detail here. As you'll see many of the updates are around simplicity, and making Flask more accessible to new users. As Python continues to grow in popularity, it wouldn't be surprising to see Flask do the same with this new release. It might mark a new chapter in the development of the project, but it's a necessary step that will be important in maintaining the project for the future. Read more on Flask Python Web Development Frameworks: Django or Flask? Read here.
Read more
  • 0
  • 0
  • 13471

article-image-node-10-0-0-released-packed-with-exciting-new-features
Kunal Chaudhari
30 Apr 2018
4 min read
Save for later

Node 10.0.0 released, packed with exciting new features

Kunal Chaudhari
30 Apr 2018
4 min read
Node.js 10.0.0 released, packed with exciting new features, it will be the next candidate in line for the Long Term Support (LTS) in October 2018. So what exactly is an LTS and why is the Node.js foundation releasing a major version every six months?   Node.js History and the Significance of LTS When Ryan Dhal first created Node.js, he decided to follow Linux kernel style odd/even version releases. Odd version releases represented internal development with no guarantee for stable releases, whereas even releases guaranteed stability. But this release scheme didn’t last long, as version 0.12 represented the last release under that versioning scheme. Later in 2015, Node.js 4.0 was announced, dubbed famously as the “Converged Release”. This meant that both io.js and Node.js projects under the Node foundation were merged together, providing a unified release plan for all Node products. In order to attract more enterprise users and to provide more stability to the platform, the Node foundation announced the “Long Term Support” strategy. The plan was simple, every six months a major version of the platform will be released which would follow semantic versioning. The even releases would be scheduled in April while the odd ones would come out in October and every even-numbered release will automatically become a candidate for the LTS. Long Term Support release lines focus on stability, extended support and provide a reliable platform for applications of any scale. Most Node.js users and companies prefer to use the Long Term Support releases. A candidate covered in the LTS plan is actively maintained for a period of 18 months from the date it enters LTS coverage. Following those 18 months of active support, they transition into "maintenance" mode for 12 additional months. To read more about the LTS release plan and schedule visit the official Node.js Foundation Release Working Group page. Source: Node.js Foundation Release Working Group Node.js 10 features Codenamed “Dubnium” Node.js 10.x comes with plenty of new features like OpenSSL 1.1.0 security toolkit, upgraded npm, N-API, and much more. Let’s take a closer look at each one of them. N-API and Native Node HTTP/2 becomes stable N-API, an abbreviation for Native API is used for building native addon, while Native HTTP/2 is module that improves the standard HTTP protocol. Both these features were first announced as experimental projects in Node.js 8 release and now have been confirmed as stable features in the 10.x release. N-API aims to solve two main problems namely, reducing the maintenance cost for native modules and reducing difficulties in upgrading Node.js versions in production deployments for users. The native HTTP/2 module will help improve Node servers and the web experience that they provide. Upgraded npm npm has recently been upgraded from v5.7 to v6.0, while Node.js 10 ships with npm 5.7, the 10.x line will be upgraded to npm Version 6 later on. This major version increase in npm provides improvements in all areas including performance, security, and stability. OpenSSL Version 1.1.0 With the recent finalization of the TLS 1.3 specification, a huge step forward for the security of the web, OpenSSL release their newest version of the security toolkit which supports this TLS specification. It didn’t take long for Node.js to start supporting OpenSSL, since it would provide more secure communication between applications on the Node platform. While Node is just supporting OpenSSL version 1.1.0 in this latest release, it plans to upgrade it in the future versions of the 10.x release, bringing the brand new TLS support for the developers.   What to expect in the future releases Plenty of exciting features like better support for the ECMAScript (ES) modules, JavaScript Promises, new infrastructure for build/automation support, and functional testing for third party modules are in line for the next releases. Node 10 will remain in LTS from October 2018 until April 2021. This LTS release will also mark the deprecation of Node.js 4. While the features released so far are already very impressive, the Node team remains adamant on bringing even more cutting edge technology to the platform, making the life of developers easier. To get a more detailed description of the new features or to download the latest version of Node.js, please visit their official web page. How is Node.js Changing Web Development? How to deploy a Node.js application to the web using Heroku
Read more
  • 0
  • 0
  • 14699

article-image-thanks-deepcode-ai-can-help-you-write-cleaner-code
Richard Gall
30 Apr 2018
2 min read
Save for later

Thanks to DeepCode, AI can help you write cleaner code

Richard Gall
30 Apr 2018
2 min read
DeepCode is a tool that uses artificial intelligence to help software engineers write cleaner code. It's a bit like Grammarly or the Hemingway Editor, but for code. It works in an ingenious way. Using AI, it reads your GitHub repositories and highlights anything that might be broken or cause compatibility issues. It is currently only available for Java, JavaScript, and Python, but more languages are going to be added. DeepCode is more than a debugger Sure, DeepCode might sound a little like a glorified debugger. But it's important to understand it's much more than that. It doesn't just correct errors, it can actually help you to improve the code you write. That means the project's mission isn't just code that works, but code that works better. It's thanks to AI that DeepCode is able to support code performance too - the software learns 'rules' about how code works best. And because DeepCode is an AI system, it's only going to get better as it learns more. Speaking to TechCrunch, Boris Paskalev claimed that DeepCode has more than 250,000 rules. This is "growing daily." Paskalev went on to explain: "We built a platform that understands the intent of the code... We autonomously understand millions of repositories and note the changes developers are making. Then we train our AI engine with those changes and can provide unique suggestions to every single line of code analyzed by our platform.” DeepCode is a compelling prospect for developers. As applications become more complex, and efficiency becomes increasingly more important, a simple solution to unlocking greater performance could be invaluable. It's no surprise that it has already raised 1.1 milion in investment from VC company btov. It's only going to become more popular with investors as the popularity of the platform grows. This might mean the end of spaghetti code, which can only be a good thing. Find out more about DeepCode and it's pricing here. Read more: Active Learning: An approach to training machine learning models efficiently
Read more
  • 0
  • 0
  • 17048

article-image-what-scala-3-0-roadmap-looks-like
Pavan Ramchandani
30 Apr 2018
2 min read
Save for later

What Scala 3.0 Roadmap looks like!

Pavan Ramchandani
30 Apr 2018
2 min read
Scala in its recent announcement suggested the roadmap for Scala 3.0 and what features developers can expect in Scala 3. Following this, the Scala community also announced the new release will be Scala 2.13 and mentioned that Scala 3 will succeed Scala 2.13. With the first official talk about Scala 3, the community also unveiled its secret project called Dotty. It announced that Dotty will become Scala 3. Dotty is a set of compiler technology for Scala. The suggested timeline for the preview release of Scala 3.0 is around early 2020. With this development, the community has suggested that Scala 2.13, expected to release in few months, will be an important release for migration to Scala 3. What can you expect in Scala 3? The community is working to fuse two big paradigms: Object-Oriented programming and functional programming together to make development more convenient in Scala ecosystem. Alongside this ongoing improvement, the community is focussing on the following aspects: With Scala 3, the community is emphasizing on 4 main features of Scala: consistency, safety, ergonomics, and performance. The community is working on adding types and operators to carry out these functionalities. In Scala 3 expect advanced programming paradigms like metaprogramming and generative programming. Currently, the macro systems are implemented at an experimental level to carry out metaprogramming. The community has suggested replacing the macro system with some other solution. Generative programming design with scala is currently under development. Improvement in Scala tools for building strong foundations for software design. Also removal of some components of the language that are rarely used to make the language lightweight. Automatic rewriting through the scalafix tool for efficient migration of code from Scala 2 to Scala 3. Updated Scala compiler, IDE plugins, REPL, Scaladoc, and build tools. The community is working on updating the Dotty plugins and its standard build tools SBT for working properly with Scala 3. Scala 3 will share the same standard library used in Scala 2. However, with the update, Scala 3 will not be binary compatible with Scala 2 because of the update in Scala compiler. The community is working on making the migration as smooth as possible which makes the release of Scala 2.14 pivotal. To get an early preview of Scala 3 features, developers can start working on the development of Dotty, available on the GitHub repository and report any issues on the issues page. Scala 2.12.5 is here!
Read more
  • 0
  • 0
  • 17751
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
article-image-this-week-on-packt-hub-27-april-2018
Aarthi Kumaraswamy
27 Apr 2018
4 min read
Save for later

This week on Packt Hub – 27 April 2018

Aarthi Kumaraswamy
27 Apr 2018
4 min read
  This week continues to see discussions around GDPR, major updates for Tableau, MySQL, Bootstrap and Salesforce in tech news this week. See why Hadoop is dying, learn about Mob programming, Hybrid apps, Progressive web apps, and more from this week’s insights. Build an ARCore app in Android, learn advanced Rust programming, see how data scientists test hypothesis, and more in this week’s tutorials. Here’s what you may have missed in the last 7 days – Tech news, insights and tutorials… Featured Interview “Pandas is an effective tool to explore and analyze data”: An interview with Theodore Petrou In this exciting interview, Ted Petrou, author of Pandas Cookbook, takes us through an insightful journey into pandas – Python’s premier library for exploratory data analysis and tells us why it is the go-to library for many data scientists to discover new insights from their data. Ted is a data scientist and the founder of Dunder Data, a professional educational company focusing on exploratory data analysis. Tech news Bulletins Data science news bulletin – Monday 23 April Web Development news bulletin – Tuesday 24 April Cybersecurity news bulletin – Wednesday 25 April Programming news bulletin – Thursday 26 April Data news in depth Microsoft Cloud Services get GDPR Enhancements Tableau 2018.1 brings new features to help organizations easily scale analytics [Editor’s Pick] MySQL 8.0 is generally available with added features Development & programming news in depth Salesforce Spring 18 – New features to be excited about in this release! JetBrains ReSharper Ultimate 2018.1 is readily available for download Get ready for Bootstrap v4.1; Web developers to strap up their boots Cloud & networking news in depth Google’s kaniko – An open-source build tool for Docker Images in Kubernetes, without a root access AWS SAM (AWS Serverless Application Model) is now open source Everything you need to know about Jenkins X, the new cloud-native CI/CD solution on Kubernetes [Editor’s Pick] Tutorials Interested in becoming a data scientist? This week’s tutorials focus on getting you started in this field using some of the most popular tools like TensorFlow and R. Interested in Web development? Learn to Build a real-time dashboard with Vue.js, master data bindings with Knockout.js and more this week. Perhaps, you’re into mobile and game development. Now is a good time to know how to build an ARCore app on Android. Data tutorials How to Debug an application using Qt Creator [Editor’s Pick] Setting up Logistic Regression model using TensorFlow How data scientists test hypotheses and probability [Editor’s Pick] Using R6 classes in R to retrieve live data for markets and wallets  Development & programming tutorials Web development tutorials How to build a chatbot with Microsoft Bot framework How to deploy a Node.js application to the web using Heroku Building a real-time dashboard with Meteor and Vue.js Building a Web Service with Laravel 5 Data bindings with Knockout.js [Editor’s Pick] Game and Mobile development tutorials How to create non-player Characters (NPC) with Unity 2018 Build a Virtual Reality Solar System in Unity for Google Cardboard Getting started with building an ARCore application for Android [Editor's Pick] Programming tutorials How to dockerize an ASP.NET Core application Perform Advanced Programming with Rust [Editor’s Pick] Other Tutorials How to run Lambda functions on AWS Greengrass Creating and deploying an Amazon Redshift cluster How to run and configure an IoT Gateway This week’s opinions, analysis, and insights Learn all about MYSQL performance benchmarks, what is active learning, what are hybrid apps, what is mob programming and more in this week’s insights. Data Insights Top 10 MySQL 8 performance benchmarking aspects to know [Editor’s Pick] Why is data science important? Why is Hadoop dying? [Editor’s Pick] Active Learning: An approach to training machine learning models efficiently Development & Programming Insights Google ARCore is pushing immersive computing forward Hybrid Mobile apps: What you need to know 20 ways to describe programming in 5 words [Just for laughs] What is Mob Programming? [Editor’s Pick] 5 reasons why your next app should be a PWA (progressive web app) [Editor’s Pick] Other Insights Top 7 DevOps tools in 2018 Top 5 penetration testing tools for ethical hackers  
Read more
  • 0
  • 0
  • 4551

article-image-build-achatbot-with-microsoft-bot-framework
Kunal Chaudhari
27 Apr 2018
8 min read
Save for later

How to build a chatbot with Microsoft Bot framework

Kunal Chaudhari
27 Apr 2018
8 min read
The Microsoft Bot Framework is an increbible tool from Microsoft. It makes building chatbots easier and more accessible than ever. That means you can build awesome conversational chatbots for a range of platforms, including Facebook and Slack. In this tutorial, you'll learn how to build an FAQ chatbot using Microsoft Bot Framework and ASP.NET Core. This tutorial has been taken from .NET Core 2.0 By Example. Let's get started. You're chatbot that can respond to simple queries such as: How are you? Hello! Bye! This should provide a good foundation for you to go further and build more complex chatbots with the Microsoft Bot Framework, The more you train the Bot and the more questions you put in its knowledge base, the better it will be. If you're a UK based public sector organisation then ICS AI offer conversational AI solutions built to your needs. Their Microsoft based infrastructure runs chatbots augmented with AI to better serve general public enquiries. Build a basic FAQ Chabot with Microsoft Bot Framework First of all, we need to create a page that can be accessed anonymously, as this is frequently asked questions (FAQ ), and hence the user should not be required to be logged in to the system to access this page. To do so, let's create a new controller called FaqController in our LetsChat.csproj. It will be a very simple class with just one action called Index, which will display the FAQ page. The code is as follows: [AllowAnonymous] public class FaqController : Controller { // GET: Faq public ActionResult Index() { return this.View(); } } Notice that we have used the [AllowAnonymous] attribute, so that this controller can be accessed even if the user is not logged in. The corresponding .cshtml is also very simple. In the solution explorer, right-click on the Views folder under the LetsChat project and create a folder named Faq and then add an Index.cshtml file in that folder. The markup of the Index.cshtml would look like this: @{ ViewData["Title"] = "Let's Chat"; ViewData["UserName"] = "Guest"; if(User.Identity.IsAuthenticated) { ViewData["UserName"] = User.Identity.Name; } } <h1> Hello @ViewData["UserName"]! Welcome to FAQ page of Let's Chat </h1> <br /> Nothing much here apart from the welcome message. The message displays the username if the user is authenticated, else it displays Guest. Now, we need to integrate the Chatbot stuff on this page. To do so, let's browse http://qnamaker.ai. This is Microsoft's QnA (as in questions and answers) maker site which a free, easy-to-use, REST API and web-based service that trains artificial intelligence (AI) to respond to user questions in a more natural, conversational way. Compatible across development platforms, hosting services, and channels, QnA Maker is the only question and answer service with a graphical user interface—meaning you don’t need to be a developer to train, manage, and use it for a wide range of solutions. And that is what makes it incredibly easy to use. You would need to log in to this site with your Microsoft account (@microsoft/@live/@outlook). If you don't have one, you should create one and log in. On the very first login, the site would display a dialog seeking permission to access your email address and profile information. Click Yes and grant permission: You would then be presented with the service terms. Accept that as well. Then navigate to the Create New Service tab. A form will appear as shown here: The form is easy to fill in and provides the option to extract the question/answer pairs from a site or .tsv, .docx, .pdf, and .xlsx files. We don't have questions handy and so we will type them; so do not bother about these fields. Just enter the service name and click the Create button. The service should be created successfully and the knowledge base screen should be displayed. We will enter probable questions and answers in this knowledge base. If the user types a question that resembles the question in the knowledge base, it will respond with the answer in the knowledge base. Hence, the more questions and answers we type, the better it will perform. So, enter all the questions and answers that you wish to enter, test it in the local Chatbot setup, and, once you are happy with it, click on Publish. This would publish the knowledge bank and share the sample URL to make the HTTP request. Note it down in a notepad. It contains the knowledge base identifier guide, hostname, and subscription key. With this, our questions and answers are ready and deployed. We need to display a chat interface, pass the user-entered text to this service, and display the response from this service to the user in the chat user interface. To do so, we will make use of the Microsoft Bot Builder SDK for .NET and follow these steps: Download the Bot Application project template from http://aka.ms/bf-bc-vstemplate. Download the Bot Controller item template from http://aka.ms/bf-bc-vscontrollertemplate. Download the Bot Dialog item template from http://aka.ms/bf-bc-vsdialogtemplate. Next, identify the project template and item template directory for Visual Studio 2017. The project template directory is located at %USERPROFILE%DocumentsVisual Studio 2017TemplatesProjectTemplatesVisual C# and the item template directory is located at %USERPROFILE%DocumentsVisual Studio 2017TemplatesItemTemplatesVisual C#. Copy the Bot Application project template to the project template directory. Copy the Bot Controller ZIP and Bot Dialog ZIP to the item template directory. In the solution explorer of the LetsChat project, right-click on the solution and add a new project. Under Visual C#, we should now start seeing a Bot Application template as shown here: Name the project FaqBot and click OK. A new project will be created in the solution, which looks similar to the MVC project template. Build the project, so that all the dependencies are resolved and packages are restored. If you run the project, it is already a working Bot, which can be tested by the Microsoft Bot Framework emulator. Download the BotFramework-Emulator setup executable from https://github.com/Microsoft/BotFramework-Emulator/releases/. Let's run the Bot project by hitting F5. It will display a page pointing to the default URL of http://localhost:3979. Now, open the Bot framework emulator and navigate to the preceding URL and append api/messages; to it, that is, browse to http://localhost:3979/api/messages and click Connect. On successful connection to the Bot, a chat-like interface will be displayed in which you can type the message. The following screenshot displays this step:   We have a working bot in place which just returns the text along with its length. We need to modify this bot, to pass the user input to our QnA Maker service and display the response returned from our service. To do so, we will need to check the code of MessagesController in the Controllers folder. We notice that it has just one method called Post, which checks the activity type, does specific processing for the activity type, creates a response, and returns it. The calculation happens in the Dialogs.RootDialog class, which is where we need to make the modification to wire up our QnA service. The modified code is shown here: private static string knowledgeBaseId = ConfigurationManager.AppSettings["KnowledgeBaseId"]; //// Knowledge base id of QnA Service. private static string qnamakerSubscriptionKey = ConfigurationManager.AppSettings["SubscriptionKey"]; ////Subscription key. private static string hostUrl = ConfigurationManager.AppSettings["HostUrl"]; private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result) { var activity = await result as Activity; // return our reply to the user await context.PostAsync(this.GetAnswerFromService(activity.Text)); context.Wait(MessageReceivedAsync); } private string GetAnswerFromService(string inputText) { //// Build the QnA Service URI Uri qnamakerUriBase = new Uri(hostUrl); var builder = new UriBuilder($"{qnamakerUriBase}/knowledgebases /{knowledgeBaseId}/generateAnswer"); var postBody = $"{{"question": "{inputText}"}}"; //Add the subscription key header using (WebClient client = new WebClient()) { client.Headers.Add("Ocp-Apim-Subscription-Key", qnamakerSubscriptionKey); client.Headers.Add("Content-Type", "application/json"); try { var response = client.UploadString(builder.Uri, postBody); var json = JsonConvert.DeserializeObject<QnAResult> (response); return json?.answers?.FirstOrDefault().answer; } catch (Exception ex) { return ex.Message; } } } The code is pretty straightforward. First, we add the QnA Maker service subscription key, host URL, and knowledge base ID in the appSettings section of Web.config. Next, we read these app settings into static variables so that they are available always. Next, we modify the MessageReceivedAsync method of the dialog to pass the user input to the QnA service and return the response of the service back to the user. The QnAResult class can be seen from the source code. This can be tested in the emulator by typing in any of the questions that we have stored in our knowledge base, and we will get the appropriate response, as shown next: Our simple FAQ bot using the Microsoft Bot Framework and ASP.NET Core 2.0 is now ready! Read more about building chatbots: How to build a basic server side chatbot using Go
Read more
  • 0
  • 1
  • 29616

article-image-googles-kaniko-open-source-build-tool-for-docker-images-in-kubernetes
Savia Lobo
27 Apr 2018
2 min read
Save for later

Google’s kaniko - An open-source build tool for Docker Images in Kubernetes, without a root access

Savia Lobo
27 Apr 2018
2 min read
Google recently introduced kaniko, an open-source tool for building container images from a Dockerfile even without privileged root access. Prior to kaniko, building images from a standard Dockerfile typically was totally dependent on an interactive access to a Docker daemon, which requires a root access on the machine to run. Such a process makes it difficult to build container images in environments that can’t easily or securely expose their Docker daemons, such as Kubernetes clusters. To combat these challenges, Kaniko was created. With kaniko, one can build an image from a Dockerfile and push it to a registry. Since it doesn’t require any special privileges or permissions, kaniko can even run in a standard Kubernetes cluster, Google Kubernetes Engine, or in any environment that can’t have access to privileges or a Docker daemon. How does kaniko Build Tool work? kaniko runs as a container image that takes in three arguments: a Dockerfile, a build context and the name of the registry to which it should push the final image. The image is built from scratch, and contains only a static Go binary plus the configuration files needed for pushing and pulling images.kaniko image generation The kaniko executor takes care of extracting the base image file system into the root. It executes each command in order, and takes a snapshot of the file system after each command. The snapshot is created in the user area where the file system is running and compared to the previous state that is in memory. All changes in the file system are appended to the base image, making relevant changes in the metadata of the image. After successful execution of each command in the Dockerfile, the executor pushes the newly built image to the desired registry. Finally, Kaniko unpacks the filesystem, executes commands and takes snapshots of the filesystem completely in user-space within the executor image. This is how it avoids requiring privileged access on your machine. Here, the docker daemon or CLI is not involved. To know more about how to run kaniko in a Kubernetes Cluster, and in the Google Cloud Container Builder, read the documentation on the GitHub Repo. The key differences between Kubernetes and Docker Swarm Building Docker images using Dockerfiles What’s new in Docker Enterprise Edition 2.0?
Read more
  • 0
  • 0
  • 21198

article-image-how-to-create-non-player-characters-npc-with-unity-2018
Amarabha Banerjee
26 Apr 2018
10 min read
Save for later

How to create non-player Characters (NPC) with Unity 2018

Amarabha Banerjee
26 Apr 2018
10 min read
Today, we will learn to create game characters while focusing mainly on non-player characters. Our Cucumber Beetles will serve as our game's non-player characters and will be the Cucumber Man's enemies. We will incorporate Cucumber Beetles in our game through direct placement. We will review the beetles' 11 animations and make changes to the non-player character's animation controller. In addition, we will write scripts to control the non-player characters. We will also add cucumber patches, cucumbers, and cherries to our game world. Understanding the non-player characters Non-player characters commonly referred to as NPCs, are simply game characters that are not controlled by a human player. These characters are controlled through scripts, and their behaviors are usually responsive to in-game conditions. Our game's non-player characters are the Cucumber Beetles. These beetles, as depicted in the following screenshot, have six legs that they can walk on; under special circumstances, they can also walk on their hind legs: Cucumber Beetles are real insects and are a threat to cucumbers. They cannot really walk on their hind legs, but they can in our game. Importing the non-player characters into our game You are now ready to import the asset package for our game's non-player character, the Cucumber Beetle. Go through the following steps to import the package: Download the Cucumber_Beetle.unitypackage file from the publisher's companion website In Unity, with your game project open, select Assets | Import Package | Custom Package from the top menu Navigate to the location of the asset package you downloaded in step 1 and click the Open button When presented with the Import Asset Package dialog window, click the Import button As you will notice, the Cucumber_Beetle asset package contains several assets related to the Cucumber Beetles, including a controller, scripts, a prefab, animations, and other assets: Now that the Cucumber_Beetle asset package has been imported into our game project, we should save our project. Use the File | Save Project menu option. Next, let's review what was imported. In the Project panel, under Assets | Prefabs, you will see a new Beetle.Prefab. Also in the Project panel, under Assets, you will see a Beetle folder. It is important that you understand what each component in the folder is for. Please refer to the following screenshot for an overview of the assets that you will be using in this chapter in regards to the Cucumber Beetle: The other assets in the previous screenshot that were not called out include a readme.txt file, the texture and materials for the Cucumber Beetle, and the source files. We will review the Cucumber Beetle's animations in the next section. Animating our non-player characters Several Cucumber Beetle animations have been prepared for use in our game. Here is a list of the animation names as they appear in our project, along with brief descriptions of how we will incorporate the animation into our game. The animations are listed in alphabetical order by name: Animation Name Usage Details Attack_Ground The beetle attacks the Cucumber Man's feet from the ground Attack_Standing The beetle attacks the Cucumber Man from a standing position Die_Ground The beetle dies from the starting position of on the ground Die_Standing The beetle dies from the starting position of standing on its hind legs Eat_Ground The beetle eats cucumbers while on the ground Idle_Ground The beetle is not eating, walking, fighting, or standing Idle_Standing The beetle is standing, but not walking, running, or attacking Run_Standing The beetle runs on its hind legs Stand The beetle goes from an on-the-ground position to standing (it stands up) Walk_Ground The beetle walks using its six legs Walk_Standing The beetle walks on its hind legs You can preview these animations by clicking on an animation file, such as Eat_Ground.fbx, in the Project panel. Then, in the Inspector panel, click the play button to watch the animation. There are 11 animations for our Cucumber Beetle, and we will use scripting, later to determine when an animation is played. In the next section, we will add the Cucumber Beetle to our game. Incorporating the non-player characters into our game First, let's simply drag the Beetle.Prefab from the Assets/Prefab folder in the Project panel to our game in Scene view. Place the beetle somewhere in front of the Cucumber Man so that the beetle can be seen as soon as you put the game into game mode. A suggested placement is illustrated in the following screenshot: When you put the game into game mode, you will notice that the beetle cycles through its animations. If you double-click the Beetle.controller in the Assets | Beetle folder in the Project panel, you will see, as shown in the following screenshot, that we currently have several animations set to play successively and repeatedly: This initial setup is intended to give you a first, quick way of previewing the various animations. In the next section, we will modify the animation controller. Working with the Animation Controller We will use an Animation Controller to organize our NPCs' animations. The Animation Controller will also be used to manage the transitions between animations. Before we start making changes to our Animation Controller, we need to identify what states our beetle has and then determine what transitions each state can have in relation to other states. Here are the states that the beetle can have, each tied to an animation: Idle on Ground Walking on Ground Eating on Ground Attacking on Ground Die on Ground Stand Standing Idle Standing Walk Standing Run Standing Attack Die Standing With the preceding list of states, we can assign the following transitions: From Idle on Ground to: Walking on Ground Running on Ground Eating on Ground Attacking on Ground Stand From Stand to: Standing Idle Standing Walk Standing Run Standing Attack Reviewing the transitions from Idle on Ground to Stand demonstrates the type of state-to-state transition decisions you need to make for your game. Let's turn our attention back to the Animation Controller window. You will notice that there are two tabs in the left panel of that window: Layers and Parameters. The Layers tab shows a Base Layer. While we can create additional layers, we do not need to do this for our game. The Parameters tab is empty, and that is fine. We will make our changes using the Layout area of the Animation Controller window. That is the area with the grid background. Let's start by making the following changes. For all 11 New State buttons, do the following: Left-click the state button Look in the Inspector panel to determine which animation is associated with the state button Rename the state name in the Inspector panel to reflect the animation. Click the return button Double-check the state button to ensure your change was made When you have completed the preceding five steps for all 11 states, your Animation Controller window should match the following screenshot: If you were to put the game into game mode, you would see that nothing has changed. We only changed the state names so they made more sense to us. So, we have some more work to do with the Animation Controller. Currently, the Attacking on Ground state is the default. That is not what we want. It makes more sense to have the Idle on Ground state to be our default. To make that change, right-click the Idle on Ground state and select Set as Layer Default State: Next, we need to make a series of changes to the state transitions. There are a lot of states and there will be a lot of transitions. In order to make things easier, we will start by deleting all the default transitions. To accomplish this, left-click each white line with an arrow and press your keyboard's Delete key. Do not delete the orange line that goes from Entry to Idle on Ground. After all transitions have been deleted, you can drag your states around so you have more working room. You might temporarily reorganize them in a manner similar to what is shown in the following screenshot: Our next task is to create all of our state transitions. Follow these steps for each state transition you want to add: Right-click the originating state. Select Create Transition. Click on the destination state. Once you have made all your transitions, you can reorganize your states to declutter the Animation Controller's layout area. A suggested final organization is provided in the following screenshot: As you can see in our final arrangement, we have 11 states and over two dozen transitions. You will also note that the Die on Ground and Die Standing states do not have any transitions. In order for us to use these animations in our game, they must be placed into an Animation Controller. Let's run a quick experiment: Select the Beetle character in the Hierarchy panel. In the Inspector panel, click the Add Component button. Select Physics | Box Collider. Click the Edit Collider button. Modify the size and position of the box collider so that it encases the entire beetle body. Click the Edit Collider button again to get out of edit mode. Your box collider should look similar to what is depicted in the following screenshot: Next, let's create a script that invokes the Die on Ground animation when the Cucumber Man character collides with the beetle. This will simulate the Cucumber Man stepping on the beetle. Follow these steps: Select the Beetle character in the Hierarchy panel. In the Inspector panel, click the Add Component button. Select New Script. Name the script BeetleNPC. Click the Create and Add button. In the project view, select Favorites | All Scripts | BeetleNPC. Double-click the BeetleNPC script file. Edit the script so that it matches the following code block: using System.Collections; using System.Collections.Generic; using UnityEngine; public class BeetleNPC : MonoBehaviour { Animator animator; // Use this for initialization void Start () { animator = GetComponent<Animator>(); } // Collision Detection Test void OnCollisionEnter(Collision col) { if (col.gameObject.CompareTag("Player")) { animator.Play("Die on Ground"); } } } This code detects a collision between the Cucumber Man and the beetle. If a collision is detected, the Die on Ground animation is played.  As you can see in the following screenshot, the Cucumber Man defeated the Cucumber Beetle: This short test demonstrated two important things that will help us further develop this game: Earlier in this section, you renamed all the states in the Animation Controller window. The names you gave the states are the ones you will reference in code. Since the animation we used did not have any transitions to other states, the Cucumber Beetle will remain in the final position of the animation unless we script it otherwise. So, if we had 100 beetles and defeated them all, all 100 would remain on their backs in the game world. This was a simple and successful scripting test for our Cucumber Beetle. We will need to write several more scripts to manage the beetles in our game. First, there are some game world modifications we will make. To summarize, we discussed how to create interesting character animations and bring them to life using the Unity 2018 platform. You read an extract from the book Getting Started with Unity 2018 written by Dr. Edward Lavieri. This book gives you a practical understanding of how to get started with Unity 2018. Read More Unity 2D & 3D game kits simplify Unity game development for beginners Build a Virtual Reality Solar System in Unity for Google Cardboard Unity plugins for augmented reality application development    
Read more
  • 0
  • 0
  • 38684
article-image-programming-news-bulletin-thursday-26-april
Richard Gall
26 Apr 2018
2 min read
Save for later

Programming news bulletin - Thursday 26 April

Richard Gall
26 Apr 2018
2 min read
Welcome to this week's programming news bulletin. There's some interesting news about Qt, and just weeks after the release of Java 10, you can check out the upcoming specs for Java 11. Programming news from the Packt Hub JetBrains ReSharper Ultimate 2018.1 is now available for download Programming news from across the the web Java 11 Specifications out for public review. Java's new release cycle is bringing updates and changes at an impressive pace. You can now review what's going to be coming in Java 11. Oracle tell Java SE 8 users that they need to buy a licence from 2019. Introducing Quart, a Python web microframework based on Asyncio. Quart is a bit like Flask. But it's been built to tackle one of Flask's few weaknesses - the fact that it is incompatible with Asyncio. Qt comes to the browser. The popular UI tool is now interoperable with WebAssembly. That should help Qt become more popular with JavaScript developers. It hasn't yet captured the web development market, but perhaps this is a step in that direction. GitLab 10.7 has been released. Vcpkg: Microsoft's C++ library manager is now available on Linux, macOS and Windows. Warehouse is the next generation Package Manager for Python. Scala 2.1.4 and Scala 3 roadmap out. Kotlin 1.2.40 is out!
Read more
  • 0
  • 0
  • 6476

article-image-salesforce-spring-18-new-features
Richa Tripathi
25 Apr 2018
3 min read
Save for later

Salesforce Spring 18 - New features to be excited about in this release!

Richa Tripathi
25 Apr 2018
3 min read
Salesforce has welcomed spring with their new Salesforce Spring 2018 release. With this release, Salesforce users, admins, and developers can try out some fresh features and tools to enhance, tweak, and guide the processes that govern our Salesforce instances. This release brings in exciting enhancements to the Lightning Platform and advanced developments in artificial intelligence. Without further ado, let’s have a quick look at some of the noteworthy features that are really going to change the way you work with Salesforce. Create personalized navigation in Lightning Experience This new Lightning Experience feature in Salesforce allows one to reorder items, rename, or remove the added items. The navigation bar now contains more than just object-level items. One can add granular items, like a dashboard, list, or record, and so on. Build Interactive Salesforce Surveys Creating beautiful, easy-to-use forms for collecting feedback and data from users or customers is now easy. All survey data is stored in your org which is nothing but an entity that contains users, data, and automation corresponding to an individual organization. This unified data storage is helpful especially in creating reports, dashboards and sharing insights within your organization. Customize your Org to match your brand using themes The ability to customise the look and feel of Salesforce has never really been available. With Spring ’18, create up to 300 custom themes or clone the built-in themes provided by Salesforce with just a few clicks. Easy calculation of Opportunity Scoring using Einstein One can prioritize their way to more business with Einstein Opportunity Scoring. Einstein Opportunity Scoring generates opportunity scores based on the record details, history and related activities of the opportunity and related account. Information about the opportunity owner, such as yearly win rates, is also used to calculate the score. Stay on Top of Duplicate Records by Using Duplicate Jobs Duplicates are a pain for most organisations. With the relatively recent release of duplicate and matching rules in Salesforce, creating duplicate jobs with standard or custom matching rules to scan Salesforce business or person accounts, contacts or leads for duplicates has become easy. Job results can be shared with others and information about the duplicate jobs are logged. These logs helps you in tracking your progress in reducing the number of duplicate records in Salesforce org. Easy storage of Data Privacy Preferences Data privacy records, based on the Individual object, lets one store certain data privacy preferences for their customers. These records can help honor and respect customers’ wishes when they request only specific forms of contact from one’s company. Some laws and regulations, such as the General Data Protection Regulation (GDPR), can require you to honor your customers’ wishes. See More Relevant Objects First in Top Results Top Results list the most relevant results for most frequently used objects. The improved ordering of objects means less scrolling and clicking around to reach the object one wants. To know more about these and other releases in detail, visit the Salesforce Blog. Read More Implementing Automation Process with Salesforce CRM Build a custom Admin Home page in Salesforce CRM Lightning Experience Getting Started with Salesforce Lightning Experience
Read more
  • 0
  • 0
  • 16535

article-image-cyber-security-news-bulletin-wednesday-25-april
Richard Gall
25 Apr 2018
2 min read
Save for later

Cyber security news bulletin - Wednesday 25 April

Richard Gall
25 Apr 2018
2 min read
Welcome to this week's cyber security news bulletin. There's news of malware targeting hospitals, NATO attacking a fictional country (yes, seriously), and big security issues in online banking (who'd have guessed). Either it's a good time or a bad time to work in security. Cyber security news from the Packt Hub Microsoft Cloud Services gets GDPR Enhancements. If you hadn't noticed already, the GDPR deadline is looming. So about time Microsoft Cloud Services! Cyber security news from across the web Orangeworm malware targets healthcare sector. Two thirds of online banking systems in the UK in 2017 contain significant vulnerabilities. In news that will probably shock, if not surprise, SC Magazine reports that online banking is plagued with security issues. Time to get serious about it. NATO launches a cyber attack on a fictional country. The NATO Cooperative Cyber Defense Centre of Excellence (CCDCOE) has launched a security competition against 'Berylia' to test the skills and strategies of some of its brightest and most talented security engineers. UK government pledges £15 million cyber security investment for Commonwealth countries. With growing concerns around the global security of software, the UK has pledged to make an investment to support cyber security initiatives around the Commonwealth. The initiative investment is also part of the UK's enthusiasm for the digital economy. Improved security should, in theory at least, ensure trust and stability can encourage growth. Observables debuts cloud-based SD-LAN for IoT Security.
Read more
  • 0
  • 0
  • 6048
article-image-microsoft-cloud-services-gdpr
Vijin Boricha
25 Apr 2018
2 min read
Save for later

Microsoft Cloud Services get GDPR Enhancements

Vijin Boricha
25 Apr 2018
2 min read
With the GDPR deadline looming closer everyday, Microsoft has started to apply General Data Protection Regulation (GDPR) to its cloud services. Microsoft recently announced that they are providing some enhancements to help organizations using Azure and Office 365 services meet GDPR requirements. With these improvements they aim at ensuring that both Microsoft's services and the organizations benefiting from them will be GDPR-compliant by the law's enforcement date. Microsoft tools supporting GDPR compliance are as follows: Service Trust Portal, provides GDPR information resources Security and Compliance Center in the Office 365 Admin Center Office 365 Advanced Data Governance for classifying data Azure Information Protection for tracking and revoking documents Compliance Manager for keeping track of regulatory compliance Azure Active Directory Terms of Use for obtaining user informed consent Microsoft recently released a preview of a new Data Subject Access Request interface in the Security and Compliance Center and the Azure Portal via a new tab. According to Microsoft 365 team, this interface is also available in the Service Trust Portal. Microsoft Tech Community post also claims that the portal will be getting a "Data Protection Impacts Assessments" section in the coming weeks. Organizations can now perform a search for "relevant data across Office 365 locations" with the new Data Subject Access Request interface preview. This helps organizations search across Exchange, SharePoint, OneDrive, Groups and Microsoft Teams. As explained by Microsoft, once searched the data is exported for review prior to being transferred to the requestor. According to Microsoft, the Data Subject Access Request capabilities will be out of preview before the GDPR deadline of May 25th. It also claims that IT professionals will be able to execute DSRs (Data Subject Requests) against system-generated logs. To know more in detail you can visit Microsoft’s blog post.
Read more
  • 0
  • 0
  • 20125

article-image-virtual-reality-solar-system-unity-google-cardboard
Sugandha Lahoti
25 Apr 2018
21 min read
Save for later

Build a Virtual Reality Solar System in Unity for Google Cardboard

Sugandha Lahoti
25 Apr 2018
21 min read
In today's tutorial, we will feature visualization of a newly discovered solar system. We will leverage the virtual reality development process for this project in order to illustrate the power of VR and ease of use of the Unity 3D engine. This project is dioramic scene, where the user floats in space, observing the movement of planets within the TRAPPIST-1 planetary system. In February 2017, astronomers announced the discovery of seven planets orbiting an ultra-cool dwarf star slightly larger than Jupiter. We will use this information to build a virtual environment to run on Google Cardboard (Android and iOS) or other compatible devices: We will additionally cover the following topics: Platform setup: Download and install the platform-specific software needed to build an application on your target device. Experienced mobile developers with the latest Android or iOS SDK may skip this step. Google Cardboard setup: This package of development tools facilitates display and interaction on a Cardboard device. Unity environment setup: Initializing Unity's Project Settings in preparation for a VR environment. Building the TRAPPIST-1 system: Design and implement the Solar System project. Build for your device: Build and install the project onto a mobile device for viewing in Google Cardboard. Platform setup Before we begin building the solar system, we must setup our computer environment to build the runtime application for a given VR device. If you have never built a Unity application for Android or iOS, you will need to download and install the Software Development Kit (SDK) for your chosen platform. An SDK is a set of tools that will let you build an application for a specific software package, hardware platform, game console, or operating system. Installing the SDK may require additional tools or specific files to complete the process, and the requirements change from year to year, as operating systems and hardware platforms undergo updates and revisions. To deal with this nightmare, Unity maintains an impressive set of platform-specific instructions to ease the setup process. Their list contains detailed instructions for the following platforms: Apple Mac Apple TV Android iOS Samsung TV Standalone Tizen Web Player WebGL Windows For this project, we will be building for the most common mobile devices: Android or iOS. The first step is to visit either of the following links to prepare your computer: Android: Android users will need the Android Developer Studio, Java Virtual Machine (JVM), and assorted drivers. Follow this link for installation instructions and files: https://docs.unity3d.com/Manual/Android-sdksetup.html. Apple iOS: iOS builds are created on a Mac and require an Apple Developer account, and the latest version of Xcode development tools. However, if you've previously built an iOS app, these conditions will have already been met by your system. For the complete instructions, follow this link: https://docs.unity3d.com/Manual/iphone-GettingStarted.html. Google Cardboard setup Like the Unity documentation website, Google also maintains an in-depth guide for the Google VR SDK for Unity set of tools and examples. This SDK provides the following features on the device: User head tracking Side-by-side stereo rendering Detection of user interactions (via trigger or controller) Automatic stereo configuration for a specific VR viewer Distortion correction Automatic gyro drift correction These features are all contained in one easy-to-use package that will be imported into our Unity scene. Download the SDK from the following link, before moving on to the next step: http://developers.google.com/cardboard/unity/download. At the time of writing, the current version of the Google VR SDK for Unity is version 1.110.1 and it is available via a GitHub repository. The previous link should take you to the latest version of the SDK. However, when starting a new project, be sure to compare the SDK version requirements with your installed version of Unity. Setting up the Unity environment Like all projects, we will begin by launching Unity and creating a new project. The first steps will create a project folder which contains several files and directories: Launch the Unity application. Choose the New option after the application splash screen loads. Create a new project by launching the Unity application. Save the project as Trappist1 in a location of your choice, as demonstrated in Figure 2.2: To prepare for VR, we will adjust the Build Settings and Player Settings windows. Open Build Settings from File | Build Settings. Select the Platform for your target device (iOS or Android). Click the Switch Platform button to confirm the change. The Unity icon in the right-hand column of the platform panel indicates the currently selected build platform. By default, it will appear next to the Standalone option. After switching, the icon should now be on Android or iOS platform, as shown in Figure 2.3: Note for Android developers: Ericsson Texture Compression (ETC) is the standard texture compression format on Android. Unity defaults to ETC (default), which is supported on all current Android devices, but it does not support textures that have an alpha channel. ETC2 supports alpha channels and provides improved quality for RBG textures on Android devices that support OpenGL ES 3.0. Since we will not need alpha channels, we will stick with ETC (default) for this project: Open the Player Settings by clicking the button at the bottom of the window. The PlayerSetting panel will open in the Inspector panel. Scroll down to Other Settings (Unity 5.5 thru 2017.1) or XR Settings and check the Virtual Reality Supported checkbox. A list of choices will appear for selecting VR SDKs. Add Cardboard support to the list, as shown in Figure 2.4: You will also need to create a valid Bundle Identifier or Package Name under Identification section of Other Settings. The value should follow the reverse-DNS format of the com.yourCompanyName.ProjectName format using alphanumeric characters, periods, and hyphens. The default value must be changed in order to build your application. Android development note: Bundle Identifiers are unique. When an app is built and released for Android, the Bundle Identifier becomes the app's package name and cannot be changed. This restriction and other requirements are discussed in this Android documentation link: http://developer.Android.com/reference/Android/content/pm/PackageInfo.html. Apple development note: Once you have registered a Bundle Identifier to a Personal Team in Xcode, the same Bundle Identifier cannot be registered to another Apple Developer Program team in the future. This means that, while testing your game using a free Apple ID and a Personal Team, you should choose a Bundle Identifier that is for testing only, you will not be able to use the same Bundle Identifier to release the game. An easy way to do this is to add Test to the end of whatever Bundle Identifier you were going to use, for example, com.MyCompany.VRTrappistTest. When you release an app, its Bundle Identifier must be unique to your app, and cannot be changed after your app has been submitted to the App Store. Set the Minimum API Level to Android Nougat (API level 24) and leave the Target API on Automatic. Close the Build Settings window and save the project before continuing. Choose Assets | Import Package | Custom Package... to import the GoogleVRForUnity.unitypackage previously downloaded from http://developers.google.com/cardboard/unity/download. The package will begin decompressing the scripts, assets, and plugins needed to build a Cardboard product. When completed, confirm that all options are selected and choose Import. Once the package has been installed, a new menu titled GoogleVR will be available in the main menu. This provides easy access to the GoogleVR documentation and Editor Settings. Additionally, a directory titled GoogleVR will appear in the Project panel: Right-click in the Project and choose Create | Folder to add the following directories: Materials, Scenes, and Scripts. Choose File | Save Scenes to save the default scene. I'm using the very original Main Scene and saving it to the Scenes folder created in the previous step. Choose File | Save Project from the main menu to complete the setup portion of this project. Building the TRAPPIST-1 System Now that we have Unity configured to build for our device, we can begin building our space themes VR environment. We have designed this project to focus on building and deploying a VR experience. If you are moderately familiar with Unity, this project will be very simple. Again, this is by design. However, if you are relatively new, then the basic 3D primitives, a few textures, and a simple orbiting script will be a great way to expand your understanding of the development platform: Create a new script by selecting Assets | Create | C# Script from the main menu. By default, the script will be titled NewBehaviourScript. Single click this item in the Project window and rename it OrbitController. Finally, we will keep the project organized by dragging OrbitController's icon to the Scripts folder. Double-click the OrbitController script item to edit it. Doing this will open a script editor as a separate application and load the OrbitController script for editing. The following code block illustrates the default script text: using System.Collections; using System.Collections.Generic; using UnityEngine; public class OrbitController : MonoBehaviour { // Use this for initialization void Start () { } // Update is called once per frame void Update () { } } This script will be used to determine each planet's location, orientation, and relative velocity within the system. The specific dimensions will be added later, but we will start by adding some public variables. Starting on line 7, add the following five statements: public Transform orbitPivot; public float orbitSpeed; public float rotationSpeed; public float planetRadius; public float distFromStar; Since we will be referring to these variables in the near future, we need a better understanding of how they will be used: orbitPivot stores the position of the object that each planet will revolve around (in this case, it is the star TRAPPIST-1). orbitalSpeed is used to control how fast each planet revolves around the central star. rotationSpeed is how fast an object rotates around its own axis. planetRadius represents a planet's radius compared to Earth. This value will be used to set the planet's size in our environment. distFromStar is a planet's distance in Astronomical Units (AU) from the central star. Continue by adding the following lines of code to the Start() method of the OrbitController script: // Use this for initialization void Start () { // Creates a random position along the orbit path Vector2 randomPosition = Random.insideUnitCircle; transform.position = new Vector3 (randomPosition.x, 0f, randomPosition.y) * distFromStar; // Sets the size of the GameObject to the Planet radius value transform.localScale = Vector3.one * planetRadius; } As shown within this script, the Start() method is used to set the initial position of each planet. We will add the dimensions when we create the planets, and this script will pull those values to set the starting point of each game object at runtime: Next, modify the Update() method by adding two additional lines of code, as indicated in the following code block: // Update is called once per frame. This code block updates the Planet's position during each // runtime frame. void Update () { this.transform.RotateAround (orbitPivot.position, Vector3.up, orbitSpeed * Time.deltaTime); this.transform.Rotate (Vector3.up, rotationSpeed * Time.deltaTime); } This method is called once per frame while the program is running. Within Update(), the location for each object is determined by computing where the object should be during the next frame. this.transform.RotateAround uses the sun's pivot point to determine where the current GameObject (identified in the script by this) should appear in this frame. Then this.transform.Rotate updates how much the planet has rotated since the last frame. Save the script and return to Unity. Now that we have our first script, we can begin building the star and its planets. For this process, we will use Unity's primitive 3D GameObject to create the celestial bodies: Create a new sphere using GameObject | 3D Object | Sphere. This object will represent the star TRAPPIST-1. It will reside in the center of our solar system and will serve as the pivot for all seven planets. Right-click on the newly created Sphere object in the Hierarchy window and select Rename. Rename the object Star. Using the Inspector tab, set the object to Position: 0,0,0 and Scale: 1,1,1. With the Star selected, locate the Add Component button in the Inspector panel. Click the button and enter orbitcontroller in the search box. Double-click on the OrbitController script icon when it appears. The script is now a component of the star. Create another sphere using GameObject | 3D Object | Sphere and position it anywhere in the scene, with the default scale of 1,1,1. Rename the object Planet b. Figure 2.5, from the TRAPPIST-1 Wikipedia page, shows the relative orbital period, distance from the star, radius, and mass of each planet. We will use these dimensions and names to complete the setup of our VR environment. Each value will be entered as public variables for their associated GameObjects: Apply the OrbitController script to the Planet b asset by dragging the script icon to the planet in the Scene window or the Planet b object in the Hierarchy window. Planet b is our first planet and it will serve as a prototype for the rest of the system. Set the Orbit Pivot point of Planet b in the Inspector. Do this by clicking the Selector Target next to the Orbit Pivot field (see Figure 2.6). Then, select Star from the list of objects. The field value will change from None (Transform) to Star (Transform). Our script will use the origin point of the select GameObject as its pivot point. Go back and select the Star GameObject and set the Orbit Pivot to Star as we did with Planet b. Save the scene: Now that our template planet has the OrbitController script, we can create the remaining planets: Duplicate the Planet b GameObject six times, by right-clicking on it and choosing Duplicate. Rename each copy Planet c through Planet h. Set the public variables for each GameObject, using the following chart: GameObject Orbit Speed Rotation Speed Planet Radius Dist From Star Star 0 2 6 0 Planet b .151 5 0.85 11 Planet c .242 5 1.38 15 Planet d .405 5 0.41 21 Planet e .61 5 0.62 28 Planet f .921 5 0.68 37 Planet g 1.235 5 1.34 45 Planet h 1.80 5 0.76 60 Table 2.1: TRAPPIST-1 gameobject Transform settings Create an empty GameObject by right clicking in the Hierarchy panel and selecting Create Empty. This item will help keep the Hierarchy window organized. Rename the item Planets and drag Planet b—through Planet h into the empty item. This completes the layout of our solar system, and we can now focus on setting a location for the stationary player. Our player will not have the luxury of motion, so we must determine the optimal point of view for the scene: Run the simulation. Figure 2.7 illustrates the layout being used to build and edit the scene. With the scene running and the Main Camera selected, use the Move and Rotate tools or the Transform fields to readjust the position of the camera in the Scene window or to find a position with a wide view of the action in the Game window; or a position with an interesting vantage point. Do not stop the simulation when you identify a position. Stopping the simulation will reset the Transform fields back to their original values. Click the small Options gear in the Transform panel and select Copy Component. This will store a copy of the Transform settings to the clipboard: Stop the simulation. You will notice that the Main Camera position and rotation have reverted to their original settings. Click the Transform gear again and select Paste Component Values to set the Transform fields to the desired values. Save the scene and project. You might have noticed that we cannot really tell how fast the planets are rotating. This is because the planets are simple spheres without details. This can be fixed by adding materials to each planet. Since we really do not know what these planets look like we will take a creative approach and go for aesthetics over scientific accuracy. The internet is a great source for the images we need. A simple Google search for planetary textures will result in thousands of options. Use a collection of these images to create materials for the planets and the TRAPPIST-1 star: Open a web browser and search Google for planet textures. You will need one texture for each planet and one more for the star. Download the textures to your computer and rename them something memorable (that is, planet_b_mat...). Alternatively, you can download a complete set of textures from the Resources section of the supporting website: http://zephyr9.pairsite.com/vrblueprints/Trappist1/. Copy the images to the Trappist1/Assets/Materials folder. Switch back to Unity and open the Materials folder in the Project panel. Drag each texture to its corresponding GameObject in the Hierarchy panel. Notice that each time you do this Unity creates a new material and assigns it to the planet GameObject: Run the simulation again and observe the movement of the planets. Adjust the individual planet Orbit Speed and Rotation Speed to feel natural. Take a bit of creative license here, leaning more on the scene's aesthetic quality than on scientific accuracy. Save the scene and the project. For the final design phase, we will add a space themed background using a Skybox. Skyboxes are rendered components that create the backdrop for Unity scenes. They illustrate the world beyond the 3D geometry, creating an atmosphere to match the setting. Skyboxes can be constructed of solids, gradients, or images using a variety of graphic programs and applications. For this project, we will find a suitable component in the Asset Store: Load the Asset Store from the Window menu. Search for a free space-themed skybox using the phrase space skybox price:0. Select a package and use the Download button to import the package into the Scene. Select Window | Lighting | Settings from the main menu. In the Scene section, click on the Selector Target for the Skybox Material and choose the newly downloaded skybox: Save the scene and the project. With that last step complete, we are done with the design and development phase of the project. Next, we will move on to building the application and transferring it to a device. Building the application To experience this simulation in VR, we need to have our scene run on a head-mounted display as a stereoscopic display. The app needs to compile the proper viewing parameters, capture and process head tracking data, and correct for visual distortion. When you consider the number of VR devices we would have to account for, the task is nothing short of daunting. Luckily, Google VR facilitates all of this in one easy-to-use plugin. The process for building the mobile application will depend on the mobile platform you are targeting. If you have previously built and installed a Unity app on a mobile device, many of these steps will have already been completed, and a few will apply updates to your existing software. Note: Unity is a fantastic software platform with a rich community and an attentive development staff. During the writing of this book, we tackled software updates (5.5 through 2017.3) and various changes in the VR development process. Although we are including the simplified building steps, it is important to check Google's VR documentation for the latest software updates and detailed instructions: Android: https://developers.google.com/vr/unity/get-started iOS: https://developers.google.com/vr/unity/get-started-ios Android Instructions If you are just starting out building applications from Unity, we suggest starting out with the Android process. The workflow for getting your project export from Unity to playing on your device is short and straight forward: On your Android device, navigate to Settings | About phone or Settings | About Device | Software Info. Scroll down to Build number and tap the item seven times. A popup will appear, confirming that you are now a developer. Now navigate to Settings | Developer options | Debugging and enable USB debugging. Building an Android application In your project directory (at the same level as the Asset folder), create a Build folder. Connect your Android device to the computer using a USB cable. You may see a prompt asking you to confirm that you wish to enable USB debugging on the device. If so, click OK. In Unity, select File | Build Settings to load the Build dialog. Confirm that the Platform is set to Android. If not choose Android and click Switch Platform. Note that Scenes/Main Scene should be loaded and checked in the Scenes In Build portion of the dialog. If not, click the Add Open Scenes button to add Main Scene to the list of scenes to be included in the build. Click the Build button. This will create an Android executable application with the .apk file extension. Invalid command Android error Some Android users have reported an error relating to the Android SDK Tools location. The problem has been confirmed in many installations prior to Unity 2017.1. If this problem occurs, the best solution is to downgrade to a previous version of the SDK Tools. This can be done by following the steps outlined here: Locate and delete the Android SDK Tools folder [Your Android SDK Root]/tools. This location will depend on where the Android SDK package was installed. For example, on my computer the Android SDK Tools folder is found at C:UserscpalmerAppDataLocalAndroidsdk. Download SDK Tools from http://dl-ssl.google.com/Android/repository/tools_r25.2.5-windows.zip. Extract the archive to the SDK root directory. Re-attempt the Build project process. If this is the first time you are creating an Android application, you might get an error indicating that Unity cannot locate your Android SDK root directory. If this is the case, follow these steps: Cancel the build process and close the Build Settings... window. Choose Edit | Preferences... from the main menu. Choose External Tools and scroll down to Android. Enter the location of your Android SDK root folder. If you have not installed the SDK, click the download button and follow the installation process. Install the app onto your phone and load the phone into your Cardboard device: iOS Instructions The process for building an iOS app is much more involved than the Android process. There are two different types of builds: Build for testing Build for distribution (which requires an Apple Developer License) In either case, you will need the following items to build a modern iOS app: A Mac computer running OS X 10.11 or later The latest version of Xcode An iOS device and USB cable An Apple ID Your Unity project For this demo, we will build an app for testing and we will assume you have completed the Getting Started steps (https://docs.unity3d.com/Manual/iphone-GettingStarted.html) from Section 1. If you do not yet have an Apple ID, obtain one from the Apple ID site (http://appleid.apple.com/). Once you have obtained an Apple ID, it must be added to Xcode: Open Xcode. From the menu bar at the top of the screen, choose Xcode | Preferences. This will open the Preferences window. Choose Accounts at the top of the window to display information about the Apple IDs that have been added to Xcode. To add an Apple ID, click the plus sign at the bottom left corner and choose Add Apple ID. Enter your Apple ID and password in the resulting popup box. Your Apple ID will then appear in the list. Select your Apple ID. Apple Developer Program teams are listed under the heading of Team. If you are using the free Apple ID, you will be assigned to Personal Team. Otherwise, you will be shown the teams you are enrolled in through the Apple Developer Program. Preparing your Unity project for iOS Within Unity, open the Build Settings from the top menu (File | Build Settings). Confirm that the Platform is set to iOS. If not choose iOS and click Switch Platform at the bottom of the window. Select the Build & Run button. Building an iOS application Xcode will launch with your Unity project. Select your platform and follow the standard process for building an application from Xcode. Install the app onto your phone and load the phone into your Cardboard device. We looked at the basic Unity workflow for developing VR experiences. We also provided a stationary solution so that we could focus on the development process. The Cardboard platform provides access to VR content from a mobile platform, but it also allows for touch and gaze controls. You read an excerpt from the book, Virtual Reality Blueprints, written by Charles Palmer and John Williamson. In this book, you will learn how to create compelling Virtual Reality experiences for mobile and desktop with three top platforms—Cardboard VR, Gear VR, and OculusVR. Read More Top 7 modern Virtual Reality hardware systems Virtual Reality for Developers: Cardboard, Gear VR, Rift, and Vive    
Read more
  • 0
  • 2
  • 26487
Modal Close icon
Modal Close icon