The Beginning 3D Game Assets Development Pipeline book begins with an overall look at the production of game development and the different roles in creating assets. Then, starting with Maya, you learn how to start with a concept and take it through the entire production pipeline: base mesh, UV mapping, high poly, texturing, rigging, and animation. You will be working on one asset project throughout the entire book to understand how one phase leads to the next one.
Lastly, you will cover asset placement and integration into Unity. This type of comment is known as a C-style comment. Anything in between is just for information and is not compiled. I have used this slightly elaborate text to make it absolutely clear what we will be doing in each part of the code file. Skip over a few lines of code and you will see that we have another C-style comment, announcing that in that part of the code, we will be updating the scene.
If you jump to the next C-style comment, it will be clear where we will be drawing all the graphics. Although this first project uses the simplest possible version of a game loop, every game will need these phases in the code.
This code checks whether the Esc key is currently being pressed. If it is, the highlighted code uses the window object to close itself. Now, the next time the while loop begins, it will see that the window object is closed and jump to the code immediately after the closing curly brace of the while loop and the game will exit. What we would do now is draw every object from the game.
When we draw all the game objects, we are drawing them to a hidden surface ready to be displayed. The window. This way, the player will never see the drawing process as the surface has all the sprites added to it.
It also guarantees that the scene will be complete before it is flipped. This prevents a graphical glitch known as tearing. This process is called double buffering. Also note that all this drawing and clearing functionality is performed using our window object, which was created from the SFML RenderWindow class. Run the game and you will get a blank, full screen window that remains open until you press the Esc key.
That is good progress. At this stage, we have an executing program that opens a window and loops around, waiting for the player to press the Esc key to exit.
Now, we are able to move on to drawing the background image of the game. Now, we will get to see some graphics in our game. What we need to do is create a sprite. The first one we will create will be the game background. We will now look at two more SFML classes that will take care of drawing sprites to the screen. One of these classes, perhaps unsurprisingly, is called Sprite. The other class is called Texture. A texture is a graphic stored in memory, on the graphics processing unit GPU.
Add the following highlighted code. Try and work out what is going on as well. Then, we will go through it, a line at a time:.
Once this is done, we can use the textureBackground object to load a graphic from our graphics folder into textureBackground , like this:. Then, we can associate the Texture object backgroundTexture with the Sprite object backgroundSprite , like this:.
Finally, we can position the spriteBackground object in the window object at the 0,0 coordinates:. Since the background. It just sets its position, ready for when it is shown. The backgroundSprite object can now be used to display the background graphic. Of course, you are almost certainly wondering why we had to do things in such a convoluted way. The reason is because of the way that graphics cards and OpenGL work.
Textures take up graphics memory, and this memory is a finite resource. So, it is useful to disassociate the actual texture textureBackground from any code that we will manipulate during the game loop. As you will see when we start to move our graphics, we will do so using the sprite. Any objects that are made from the Texture class will sit happily on the GPU, just waiting for an associated Sprite object to tell it where to show itself. In later projects, we will also reuse the same Texture object with multiple different Sprite objects, which makes efficient use of GPU memory.
We draw the Sprite object, which, in turn, displays the Texture object that is associated with it usually in the Draw the scene section. So, all we need to do now is use our double buffering system, which is provided by our window object, to draw our new Sprite object spriteBackground , and we should get to see our game in action.
Finally, we need to draw that sprite and its associated texture in the appropriate place in the game loop. The indenting is implied. Check out the code file in the download bundle to see full use of indenting. The new line of code simply uses the window object to draw the spriteBackground object, in between clearing the display and showing the newly drawn scene.
We now know what a sprite is, and that we can associate a texture with it and then position it on the screen and finally draw it. The game is ready to be run again so that we can see the results of this code. There will always be problems and errors in every project you make. This is guaranteed! The tougher the problem, the more satisfying it is when you solve it.
When, after hours of struggling, a new game feature finally bursts into life, it can cause a genuine high. Without this struggle, it would somehow be less worthwhile. At some point in this book, there will probably be some struggle. Remain calm, be confident that you will overcome it, and then get to work.
Remember that, whatever your problem, it is very likely you are not the first person in the world to have ever had this same problem. Think of a concise sentence that describes your problem or error and then type it into Google. You will be surprised how quickly, precisely, and often, someone else will have already solved your problem for you.
Having said that, here are a few pointers pun intended; see Chapter 10 , Pointers, the Standard Template Library, and Texture Management to get you started in case you are struggling with making this first chapter work. The most likely cause of problems in this chapter will be configuration errors.
Make sure all the filenames and folders are appropriate for your specific setup and then get the simplest part of the code running. This is the part where the screen flashes black and then closes. If you can get to this stage, then configuration is probably not the issue. Compile errors are probably the most common error we will experience going forward. Check that your code is identical to mine, especially semicolons on the ends of lines and subtle changes in upper and lower case for class and object names.
If all else fails, open the code files in the download bundle and copy and paste it in. While it is always possible that a code typo made it into this book, the code files were made from actual working projects — they definitely work! Link errors are most likely caused by missing SFML. Did you copy all of them into the project folder? Bugs are what happen when your code works, but not as you expect it to.
Debugging can actually be fun. The trick to solving bugs is to find them early! To do this, I recommend running and playing your game every time you implement something new. The sooner you find the bug, the more likely the cause will be fresh in your mind.
In this book, we will run the code to see the results at every possible stage. This was quite a challenging chapter and perhaps a little bit mean to be the first one.
Also, the concepts of classes and objects are well known to be slightly awkward for people who are new to coding. As we do so, we will take a further look at things such as functions, classes, and objects to help demystify them a little more.
A Setting up a development environment and getting your head around OOP as a concept is probably the toughest thing you will do in this book. As long as your game is functioning drawing the background , you are ready to proceed with the next chapter. Q All this talk of OOP, classes, and objects is too much and kind of spoiling the whole learning experience.
We will keep returning to OOP, classes, and objects constantly. All you need to understand for now is that SFML have written a whole load of useful classes and that we get to use this code by creating usable objects from those classes.
You just need to know that, when a function is called, its code is executed, and when it is done reaches a return statement , the program jumps back to the code that called it. John Horton is a programming and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles. He is the founder of Game Code School. A no-nonsense, practical guide to current and future processor and computer architectures, enabling you to design computer systems and develop better software applications across a variety of domains.
Publication date: October Publisher Packt. Pages ISBN Download code from GitHub. The following are our five projects for this book. Microsoft Visual Studio Visual Studio hides away the complexity of preprocessing, compiling, and linking.
SFML allows you to create the following: 2D graphics and animations, including scrolling game worlds. Huge Discounts Available! Your email address will not be published. Save my name, email, and website in this browser for the next time I comment. How to Visualize Data with D3 [Video]. Navigation and Functionality. Cursor Control. Imported Assets. Action Objects. Managing State. Exploring Transitions.
Physics and Special Effects. Message Text. Inventory Logic. Managing the Inventory.
0コメント