A Quick Orientation for Coders

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Advertisements

CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
C++ Language Fundamentals. 2 Contents 1. Introduction to C++ 2. Basic syntax rules 3. Declaring and using variables.
Epic’s Build Tools & Infrastructure
Things to Remember When Developing 64-bit Software OOO "Program Verification Systems"
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Game Framework & Sample Projects
Programming in UE4 A Quick Orientation for Coders Gerke Max Preussner
The Slate UI Framework Architecture & Tools Gerke Max Preussner
Extensibility in UE4 Customizing Your Games and the Editor Gerke Max Preussner
Concurrency & Parallelism in UE4
Integrating a Cloud Service Joe Overview Example from our games Support in UE4 to achieve that.
Engine Overview A Programmer’s Glimpse at UE4 Gerke Max Preussner
Run time vs. Compile time
1 Run time vs. Compile time The compiler must generate code to handle issues that arise at run time Representation of various data types Procedure linkage.
Game Framework & Sample Projects
The Slate UI Framework Part 1: Introduction Gerke Max Preussner
Principles of Procedural Programming
Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
General Issues in Using Variables
Object Oriented Software Development 1. Introduction to C# and Visual Studio.
Niklas Smedberg Senior Engine Programmer, Epic Games
Separating VUI from business logic Caller Experience-centered design approach Alex Kurganov, CTO Parus Interactive
McGraw-Hill© 2007 The McGraw-Hill Companies, Inc. All rights reserved. 1-1.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Introduction to .NET Framework
PHP TUTORIAL. HISTORY OF PHP  PHP as it's known today is actually the successor to a product named PHP/FI.  Created in 1994 by Rasmus Lerdorf, the very.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Distributed Systems (236351) Tutorial 1 - Getting Started with Visual Studio C#.NET.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Introduction to Java University of Sunderland CSE301 Harry R. Erwin, PhD.
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET.
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
GAME 1024: Advanced Game Programming Lesson 1: The Beginning By Kain Shin.
1 Cisco Unified Application Environment Developers Conference 2008© 2008 Cisco Systems, Inc. All rights reserved.Cisco Public Introduction to Etch Scott.
Introduction to Building Windows 8.1 & Windows Phone Applications.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
Beginning C++ Through Game Programming, Second Edition
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Version 5. ¿What is PAF? PAF is a tool to easily and quickly implement… …distributed analysis over ROOT trees. …by hiding as much as possible the inherent.
Introduction to C#. Why C#? Develop on the Following Platforms ASP.NET Native Windows Windows 8 / 8.1 Windows Phone WPF Android (Xamarin) iOS (Xamarin)
Introducing Allors Applications, Tools & Platform.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Presented by Vishy Grandhi.  Architecture (Week 1) ◦ Development Environments ◦ Model driven architecture ◦ Licensing and configuration  AOT (Week 2)
GLite build and integration system Building and Packaging Robert HARAKALY
Computer Graphics 3 Lecture 1: Introduction to C/C++ Programming Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Object Oriented Software Development 4. C# data types, objects and references.
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
Clean Code “Keep it Clean, Your Mother Doesn’t Work Here”“Keep it Clean, Your Mother Doesn’t Work Here” William PenberthyWilliam Penberthy Application.
.NET Mobile Application Development XML Web Services.
Integrating and Extending Workflow 8 AA301 Carl Sykes Ed Heaney.
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Lecture 1 Page 1 CS 111 Summer 2013 Important OS Properties For real operating systems built and used by real people Differs depending on who you are talking.
Version Control Systems
CST 1101 Problem Solving Using Computers
Version Control Systems
CMPE419 Mobile Application Development
CS360 Windows Programming
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Introduction to Python
AVG 24th 2015 ADVANCED c# - part 1.
Unreal Engine and C++ We’re finally at a point where we can start working in C++ with Unreal Engine To get everything set up for this properly, we’re going.
Navigating huge (UE4 (rendering)) code
Introduction to Python
CMPE419 Mobile Application Development
Presentation transcript:

A Quick Orientation for Coders Programming in UE4 A Quick Orientation for Coders Gerke Max Preussner max.preussner@epicgames.com *** Prepared and presented by Gerke Max Preussner for East Coast MiniDevCon 2014, November 12-13th Hi, my name is Max. I work as a Sr. Engine Programmer at Epic Games and would like to give you a quick introduction to programming in Unreal Engine 4. Who in the audience is a programmer? Who thinks that programming is awesome? Yes, programming is awesome…

Programming Is Awesome Sucks But… Because you can: Create something from nothing Bring dead matter to life Improve the human condition Impress your girl/boyfriend/cat Make a good living in the process … because it empowers you to create really cool things from the comfort of your armchair, and to make other people’s life better, or at least more entertaining.

Programming Is Awesome Sucks But… Because: Programmers are crazy Programming languages & tools suck All code is bad and buggy There is never enough time to do it right You are always behind the curve Peter Welch: http://stilldrinking.org/programming-sucks Programming also really sucks… because all programmers are crazy! Who read Peter Welch’s blog post “Programming Sucks”? It is the most accurate description of what it is like to be a programmer and work in a programming team. Welch argues that all programming teams are composed by and of crazy people. He also describes how most programmers start writing perfect little snowflakes, and on Friday they are told that six hundred more snowflakes are needed by next Tuesday. And then a lot of sketchy code gets dumped into a pile of snow that quickly melts together, and some of it turns yellow because a cat peed on it. All large teams end up working this way, and Epic is no exception. We, too, are crazy – perhaps in a good way, or at least with good intentions. We are successful, because we have more snowflakes than others, and the remaining pile is split into manageable parts, and the yellow snow is hidden, because someone leaned a Picasso against it. Who thinks that C++ is awesome? C++ also sucks… but so does every other programming language! They all suck, just in different ways. Most of the time it is because we are trying to use them in ways they were not designed for, and there is no language that solves all software engineering problems well.

Programming Is Awesome Sucks But… Don’t get discouraged! If it was easy, a monkey could do it! Don’t be afraid of programming languages Don’t get discouraged by complex code bases There are ways to make your life easier Know your tools and keep learning Software Design and Architectural Patterns Coding Guidelines & Best Practices Transfer knowledge with your peers But do not despair! I will quickly show you a few things to get up and running with Unreal and make your life easier.

Getting Started Get All The Things! Download and install Unreal Engine 4 Sync the latest code from GitHub (either Release or Master branch) Don’t forget to download & install the required dependencies! Tools: Windows: Visual Studio, UnrealVS, Visual Assist X (recommended) MacOS: Xcode Linux: Check the Wiki for latest instructions! For everything else see: https://docs.unrealengine.com/latest/INT/Programming/QuickStart/ By the way, we have really great documentation on our website for getting you started, so I won’t go into too much detail. After installing UE4 you can go to GitHub and download the latest source code. Don’t forget to download and install the required dependencies (ZIP files) as well (instructions are on the GitHub page). We currently support development on Windows and MacOS, and there is also preliminary support for Linux. If you work in Visual Studio we highly recommend installing our UnrealVS plug-in.

Common Blockers Compiling Acronyms Entry Point Compiling is handled through Unreal Build Tool (UBT) Solution/Projects in Visual Studio & Xcode are a lie! Pre-processes header files (UHT) Generates magic glue code Invokes platform specific compilers Supports remote compiling, too Also generates IDE project files Now, let’s start with some of the most common blockers for programmers just starting with Unreal Engine. The first thing that throws off a lot of people is that compilation is not actually performed by Visual Studio or Xcode, but by our Unreal Build Tool. Visual Studio and XCode solutions are only generated for your convenience. We do this so that we can support different IDEs. In combination with Unreal Header Tool, it also performs a lot of code pre-processing. I will talk about this in more detail in another presentation later today.

Build Rules UBT uses special C# files (*.Build.cs and *.Target.cs) that you create inside your module directories to figure out what it needs to do. Here you can see the build and target rules files for QAGame, a special game that our QA team uses for internal testing.

Dependency Graph Another little known feature of UBT is the ability to generate dependency graph data that can be visualized. Here is a screenshot of a JavaScript based visualizer that shows a section of our code base.

UBT, UHT, UAT Projects The full source code for all three tools is included with the Engine. You can find it in the Engine’s “Programs” directory on GitHub. Besides UBT and UHT there is also UAT (Unreal Automation Tool), which is used for packaging, launching and deploying your projects.

Common Blockers Compiling Acronyms Entry Point Acronym Soup… UBT – Unreal Build Tool UHT – Unreal Header Tool UAT – Unreal Automation Tool UFE – Unreal Frontend BP – Blueprint CDO – Class Default Object INI – Text Based Configuration File etc. By now you are probably aware of our generous use of acronyms. I already mentioned UBT, UHT and UAT, and there are many others. Don’t worry, you will quickly learn and get used to all of them.

Common Blockers Compiling Acronyms Entry Point … and Code Names, too! Cascade – Particle System Editing Tool Cooking – Process of optimizing game content Lightmass – Pre-computed Global Illuminaton Matinee – In-game Cinematics Tool Persona – Animation Editing Tool PhAT – Physics Asset Tool Swarm – Distributed Computing Client etc. We also use code names for some of our tools, and you may stumble upon them in our documentation. The names are often chosen by the developers themselves. For example, Cascade is our particle system editor. It will soon be replaced with a completely rewritten version that is code named Niagara. Swarm is a C# program that allows for distributing expensive work to other computers on your network. It is currently only used by Lightmass and will soon be rewritten C++.

Common Blockers Compiling Acronyms Entry Point Where Is the Main Loop? LaunchEngineLoop.cpp It’s really complicated (and everybody hates it) Please don’t bother with this – start with our tutorials! If you have experience writing your own little game from scratch, you may be tempted to locate our Engine’s main entry point in an attempt to learn something about how it all works. This is the wrong way to get started. You cannot possibly learn anything useful from this, because most of the code you will use on a daily basis is on a much higher conceptual layer… with about two million lines of other stuff in between. Read and watch our programming tutorials instead!

Unrealisms Type Names UObjects Basic Types Strings Macros We Use Prefixes for All Types U – UObject derrived class, i.e. UTexture A – AActor derrived class, i.e. AGameMode F – All other classes and structs, i.e. FName, FVector T – Template, i.e. TArray, TMap, TQueue I – Interface class, i.e. ITransaction E – Enumeration type, i.e. ESelectionMode b – Boolean value, i.e. bEnabled Everything in Unreal is Pascal Case (Upper Camel Case) Function names and function parameters, too Even local and loop variables! You will notice that we use prefixes for all our types, and there is no logical explanation for it. The story goes that Tim Sweeney, when he started working on Unreal Engine in his Garage, added FVector for 3D vectors with floating point components and a U-prefix for Unreal game classes. When other programmers joined they assumed that these were naming conventions… and that’s how snowflakes turn into yellow snow. We also use upper-case for all names in C++. It may really upset your OCD, but please don’t try to fight this convention as it will help keeping everything consistent. It may take a while, but you will get used to it.

Unrealisms Type Names UObjects Basic Types Strings Macros UObjects Work Around Limitations in C++ Run-time reflection of class properties and functions Serialization from/to disk and over the network Garbage collection Meta data Also: Blueprint integration Decorate regular C++ Classes with Magic Macros UCLASS – for class types USTRUCT – for struct types UFUNCTION – for class and struct member functions UPROPERTY – for class and struct variables C++ is great for a lot of things, but it is also lacking useful features that are present in more modern programming languages, such as Java or C#. Runtime reflection, garbage collection and automatic serialization are the most important ones. We would still like to use those features, so we implemented them on top of C++ with the help of macros that will be parsed by Unreal Header Tool. These special decorators will cause UHT to automatically generate all the glue code that is required to make this work.

Unrealisms Type Names UObjects Basic Types Strings Macros // Example (omitting some more advanced details) USTRUCT() // magic! struct FVector2D { UPROPERTY() // magic! float X; float Y; UFUNCTION () // magic! float GetLength() const; }; Here is an example for how a C++ structure for 3D vectors may be marked up in this way. From this, Unreal Header Tool will generate all the glue code, and you will most likely never have to see it.

Unrealisms Type Names UObjects Basic Types Strings Macros Fundamental Types We don’t use C++ integer types (char, short, int, long, etc.) Custom typedef’s for ints & strings in GenericPlatform.h (int32, uint32, uint64, TCHAR, ANSICHAR etc.) Numeric type traits in NumericLimits.h Common Structures FBox, FColor, FGuid, FVariant, FVector, TBigInt, TRange And many more in Core module All our fundamental types are declared in the Core module. We have platform specific type definitions for numeric types and strings. We don’t actually use the standard numeric types that are part of the C++ standard. This allows us to hide platform specific behavior of fundamental types.

Unrealisms Type Names UObjects Basic Types Strings Macros Containers TArray, TSparseArray – Dynamic arrays TLinkedList, TDoubleLinkedList TMap – Key-value hash table TQueue – Lock free FIFO TSet – Unordered set (without duplicates) And many more in Core module Delegates Unicast and multicast delegates Also thread-safe variants… The Core module also contains many generic container types. We also have an implementation for various kinds of event delegates…

Unrealisms Type Names UObjects Basic Types Strings Macros Smart Pointers TSharedPtr, TSharedRef – for regular C++ objects TWeakPtr – for regular C++ objects TWeakObjPtr – for UObjects TAutoPtr, TScopedPtr TUniquePtr Similar to boost:: & std:: implementations Also thread-safe variants There is also a library of smart pointer implementations. The most common ones are shared pointers, which also come with thread-safe variants. Shared pointers simplify the lifetime management of objects, and we use them often.

Unrealisms Type Names UObjects Basic Types Strings Macros String Types FString – Regular string FText – Localized string, used heavily in Slate UI FName – String hash, used heavily in UObjects String Literals TEXT() – Creates a regular string TEXT(“Hello”); LOCTEXT() – Creates a localized string LOCTEXT(“Namespace”, “Name”, “Hello”); NSLOCTEXT() – LOCTEXT with scoped namespace NSLOCTEXT(“Name”, “Hello”); String types can be a bit confusing at first, because we distinguish between regular and localized string objects. They each come with special macros for string literals. We also have so called FNames, which store string values in a global hash table. These are very heavily used in the UObject sub-system to identify classes, functions and properties.

Unrealisms Type Names UObjects Basic Types Strings Macros FNames are case-insensitive! Can’t rename misspelled names in the Editor (FIXED!) Can’t name a C++ property ‘Blast’ if one ‘bLast’ exists Oh, and FNames are case-insensitive. If you ever wondered why you can’t correct spelling errors in the Editor right now, that is the reason why. And if you think that’s crazy… well… that’s because it is!

Unrealisms Type Names UObjects Basic Types Strings Macros Logging UE_LOG, also GLog->Logf() Assertions check(), checkSlow(), ensure() Localization LOCTEXT_NAMESPACE, LOCTEXT, etc. Slate (UI Framework) SLATE_BEGIN_ARGS, SLATE_ATTRIBUTE, etc. We also use macros for less complicated things, such as logging and assertions. These are some macros you will likely encounter when working on your project.

Best Practices Guidelines Principles Coding Guidelines Posted on http://docs.unrealengine.com There are some inconsistencies in the code base If in doubt, follow existing style in current code file Naming Conventions Choose descriptive names that are as short as possible Also for local and loop variables! Avoid your own acronyms We have an internal coding guidelines document that is not yet posted on the Wiki. Since so many programmers from inside and outside Epic are involved, you will find some inconsistencies in style. And, of course, choosing good names for modules, classes, functions and variables is by far the most difficult task for programmers, but also one of the most important ones.

Best Practices Guidelines Principles General Principles KISS, YAGNI Composition vs. inheritance Avoid tight coupling of code and modules Many trivial instead of few complicated components Design Patterns SOLID (especially S, O, L and I; DI is not elegant in C++) Hollywood Principle (especially for Slate & game code) GOF, EIP Methodologies DDD, TDD (we support unit tests), AOP We also try follow proper software design principles more often now. You may already be familiar with some of them, such as KISS and YAGNI. One of the most important, but less known object-oriented principle is SOLID. [more details here, if time available] We also use common patterns from Gang-Of-Four and Enterprise Integration Patterns. Other methodologies we’re experimenting with are Domain-Driven Design, Test-Driven Development and Aspect Oriented Programming for cross-cutting concerns. Those are all huge topics in themselves. I will have to talk about them another time.

Questions? Documentation, Tutorials and Help at: AnswerHub: Engine Documentation: Official Forums: Community Wiki: YouTube Videos: Community IRC: Unreal Engine 4 Roadmap lmgtfy.com/?q=Unreal+engine+Trello+ http://answers.unrealengine.com http://docs.unrealengine.com http://forums.unrealengine.com http://wiki.unrealengine.com http://www.youtube.com/user/UnrealDevelopmentKit #unrealengine on FreeNode Make sure to check out our extensive materials on the internet, all of which are available for free – even if you don’t have a subscription yet. Any questions?