Friday, January 24, 2014

Game Cheat Engine Overview (Part 1)

Yes, it's true. There is a software program that can be used to cheat when you play a game. My guess is that die-hard gamers would never use such a tool. But for people, like me, who love software and like to explore you will likely find this little tool a bit interesting.

A cheat engine is a software app that lets you change values assigned to a variable in a game. (Note that a variable is a named storage location in the computer's memory. The storage location holds the value that might be a number, a text string or some other data type. The variable provides the developer a way not only to store; but also to retrieve and manipulate values. For example, a game might give a new player 3 lives. And each time the player get's shot "x" number of times (where x can be any number), the player looses a life. In this example the number of lives is stored in a variable. And, as an incident occurs that results in the value changing (i.e., the player looses a life) the value is updated.

The Cheat Engine provides a way for users to locate the value in memory and change it. For example, if a player wants to change the number of lives from 3 to 10--the Cheat Engine could be used to accomplish this task. The following paragraphs provide additional information on various ways Cheat Engines might locate a variable's value and change it.

Downloading the Game Engine


I downloaded Cheat Engine 6.3 from www.downloads.com. But it can also be downloaded from http://www.cheatengine.org/.

Download Engine Page

Note:  If you are not familiar with www.downloads.com; it's probably not the best place to download the Engine. This is because downloads.com adds a lot of unwanted software to downloads. If you are familiar with downloads.com you probably have already figured out how to duck and dodge your way to an executable that includes only the product you want to install.

Installing the Cheat Engine


The Cheat Engine is pretty straight forward to install. However just be aware that when you come to the "Improve Your Internet Protection" screen you can select "Custom Installation" (even though it "appears" to be disabled) if you do not want to install the AVG tool bar or the Outfox.tv application.

Custom Installation Image

Once you select Custom Installation, from "Improve Your Internet Protection" screen, you can deselect the AVG options if desired, as shown below.

Custom Installation Image With AVG Options Deselected

When you click "Next" install wizard recommends the Express installation.You can click Custom Installation if you want to deselect the "Install Outfox.TV" option.

Express (Recommended) Option Selected Image

You can then continue to use the Setup wizard until the Cheat Engine is installed. Once it is installed an Information window displays. When you click Next a dialog pops up and asks "Do you want to try out the tutorial?" If you click yes, the Tutorial application launches. Note that the Tutorial application is a separate app from the Cheat Engine app. Both apps are shown in the following picture.


When you click the Next button on the Cheat Engine Tutorial app you are presented with the first objective in the tutorial. You must click the "Hit me" button on the lower left bottom portion of Cheat Engine Tutorial app. Doing this changes the "Health" variable's value.


 Changing a Known Value


In this example, you know the value of the variable. For example, if you start a game with 250 rounds of ammunition; you know the value--but you don't know the address of the value (i.e., where in memory the value is located). As shown in the following picture I clicked the "Hit me" button until the Health value changed from 100 to 73. The Next button, on the Tutorial app, will remain disabled until I locate the Health variable and change its' value back to 100. To begin I have to use the Cheat Engine app to open the Tutorial executable file (i.e., Tutorial-i386.exe). To open the .exe file I use the "Select a process to open" button, outlined using a red box in the picture below.


When the Process List window opens I can select the Tutorial executable (highlighted in the picture below) and click the Open button.


The Cheat Engine opens the executable file and populates the Engine with the Start and Stop scan ranges and other values. There are three values that are primarily used for the Scan as follows:  "Value", "Scan Type" and "Value Type". The "Value" field holds the value of the variable. The Scan Type indicates the type of scan that will be used to locate the value. And the Value Type, which is the same as a data type.



Note: If you are not familiar with Data Types (referred to as "Value Type" in the Cheat Engine) Microsoft has an older reference for C# that provides a brief and basic example of data types. This might help clarify how one data type differs from another: http://msdn.microsoft.com/en-us/library/cs7y5x0x%28v=vs.90%29.aspx

In the Value field, shown in the above picture, I entered 73, which is the current "Health" value based on the number of times I clicked the "Hit me" button. Since I am searching for the exact value "73" I leave the Scan Type value set to "Exact Value". Also the "Value Type" is set to 4 Bytes, which is feasible to search for the numeric value 73.


When I click the First Scan button a list of values display in the left side of the window. This means more than one variable's value is currently set to 73. So I need to isolate the variable specific to the "Health" value.


To do this I will need to click the "Hit me" button. Clicking the button changed the Health value to 71. I enter 71 in the value field and then click Next Scan. The Cheat Engine rescans the variables already presented and searches for the variable whose value is now 71. As shown in the following picture, only one variable has a value of 71. So I know this is the Health variable.


I can either double-click the address value; OR, right click it. If I right-click the value a popup window displays. I can then select "Add selected addresses to the addresslist", as shown below.


Whether I double-click the address value or use the popup window, the address is moved to the bottom portion of the window, as shown below.


Right-click the value in the bottom window. The popup menu displays. Select Change record -> Value, as shown below.


The Change Value window displays. I can now change the Health Value from 71 to 1000 and click OK to close the Change Value window


The Next button is now enabled, which signifies that I have performed the step properly and can move on to the next step.


The following objectives show how to locate a variable whose address changes, how to use pointers and more. If there is enough interest in this topic I will post the information for the remaining steps associated with the Cheat Engine tutorial.

Wednesday, January 1, 2014

Unity Game Engine's Mesh Renderer, Mesh Filter, Shaders and Materials Overview

Unity Game Engine provides a way for game developers to apply shaders, textures and colors to a polygon mesh. From the user avatar to the get-a-way car or even the abandoned science lab with broken furniture, rabid dogs and glass vials--the mesh filter and mesh renderer turn polygon meshes into recognizable objects. This article provides an overview and examples related to Unity's mesh filter and mesh renderer. All of the examples included in this article are taken from the Unity Stealth Project, which can be downloaded at https://www.assetstore.unity3d.com/#/content/7677.

Meshes


A mesh is a collection of triangles used to create an impersonation of an object in a 3D world. The following picture shows a partial mesh.


Meshes are used to define a 3D world because they render more quickly than images.



Each triangle, used to makeup the mesh has three corner points referred to as vertices. In programming, the mesh class (the interface to an object's mesh geometry) uses not only vertex arrays; but also triangle arrays.  The vertices of the triangles that make up the mesh are stored as integers in a single vertex array. The vertices are assigned to the mesh. The developer can then build the triangle indices--3 indices in the vertex array for each triangle. The triangles are then assigned to the mesh and the vertex normals can automatically be calculated using RecalculateNormals().


While the triangles give the mesh shape; the vertex normal values assist in providing lighting from the appropriate angles. This lighting is required so the mesh can be seen. For more information about normal vectors see http://docs.unity3d.com/Documentation/Manual/ComputingNormalPerpendicularVector.html.

In Unity, if an object is textured its wireframe can be seen (while using the Scene View) by selecting the Wireframe option, as shown in the picture below. Alternatively, you can select Textured Wireframe to see the materials associated with the mesh and the mesh as an overlay.



For more information on meshes see the Unity Script Reference Documentation at http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html and the Unity Mesh documentation at http://docs.unity3d.com/Documentation/Manual/AnatomyofaMesh.html.

Selecting a Mesh Filter


You can drag a mesh onto the Scene View in Unity to specify the mesh you want to render. (For more information on the Scene View you can read my previous article titled Unity Engine - Building Games for Facebook, PlayStation, XBox 360, etc. (Overview). If you want to change a mesh, you can do so by selecting the Mesh Filter option on the Inspector window, which appears after you select a mesh or gameobject.


The above approach works well if you have a gameobject associated with materials; but want to change the selected mesh. To view the currently selected mesh, from the Inspector, select the gameobject using the Scene View. When the Inspector displays click the Select Mesh button (shown below). The Select Mesh window (shown in the picture above) displays. You can then view the currently selected mesh: or select a different mesh from the list of available meshes.


If you have imported a mesh from an application and want to apply shaders and textures you will need to use Unity's mesh renderer, which is discussed below.

Note: Although Unity does not include modeling tools; you can import meshes and materials from other tools (such as Autodesk SoftImage) into Unity. But keep in mind that the Unity Asset store does include Editor Extensions/Modeling plugins that provide a way to extend the Unity Engine to perform some 3D modeling tasks.

Mesh Renderer


Within Unity a mesh is rendered by applying a shader, which is a program that executes inside the graphics processing unit (GPU). The shader defines how data (associated with a graphic) is processed. For example, the shader defines how the graphic is rendered such as whether or not to cast shadows, lighting, color, etc. The following picture shows the properties associated with Unity's Bumped Specular Shader, which executes the commonly used vertex shader and fragment shader.


The shader also determines the render queue to which an object belongs. This is done so objects are drawn in the proper sequence. Unity ships with four pre-defined render queues as follows:
  • Background queue, which renders its objects first.
  • Geometry queue, which renders opaque geometry objects before the Alpha Test, Transparent and Overlay objects are rendered.
  • Alpha Test queue, which renders alpha-tested objects after the opaque geometry objects have been rendered.
  • Transparent queue, which renders objects such as glass and all other alpha-blended objects after the opaque geometry and alpha-tested objects are rendered.
  • Overlay queue, which renders lens flares and any other overlay effects after the Transparent objects are rendered.

The Stealth Project includes the prop_battlebus mesh, which uses 16 materials to apply shaders, textures and color to achieve the look shown below.


To display a gameobject the mesh filter passes the mesh to the mesh renderer, which applies the shaders, textures and color values.

To add shaders and textures you must first add a material element that will enable you to select the a material that includes the desired shader and texture files. The Stealth Project Battle Bus uses the following 16 materials, which can be applied by adding a material element for each material.
  1. prop_battlebus_body_mat
  2. prop_battleBus_wheels_mat
  3. prop_battleBus_lights_mat
  4. prop_battleBus_tv_mat
  5. prop_battleBus_sacks_mat
  6. prop_battleBus_canister_mat
  7. prop_battleBus_carpet_mat
  8. prop_battleBus_barbedWire_mat
  9. prop_battleBus_crates_mat
  10. prop_battleBus_appendages_mat
  11. prop_battleBus_tubes_mat
  12. prop_battleBus_baggageFrame_mat
  13. prop_battleBus_whiteMetal_mat
  14. prop_battleBus_blackMetal_mat
  15. prop_battleBus_boxes_mat
  16. prop_battleBus_canvas_mat

The following picture shows the prop_battlebus mesh displayed in the Scene View. Notice there is only 1 default material element (Element 0) added to a mesh. Also, the Mesh Filter is the prop_battleBus.


Click the Materials Size option to change the Size value from the default 1 to 16. Press enter to execute the change. Unity adds 16 materials so a material can be associated with each element until all materials have been added to the Battle Bus.


We can use the Select Material button to select the desired material for Element 0. I selected the prop_battlebus_body_mat material for Element 0, as shown in the following picture.



Once the material is associated with the prop_battleBus I can view the properties associated with the material, as shown in the following picture.


The shader associated with a material drives the properties available to the material. For example, the prop_battlebus_body_mat uses the Reflective Bumped Specular shader (as shown in the following picture). The Reflective Bumped Specular shader is a member of the Reflective Shader Family and includes reflective properties used to simulate metal objects.


You can learn more about shaders and related properties by viewing Unity's Built-in Shader Guide at http://docs.unity3d.com/Documentation/Components/Built-inShaderGuide.html.

If you click the Select button associated with the Base (RGB) Gloss (A) property I can see or change the 2D Texture .tif image associated with the prop_battlebus_body_mat material. You can also click the Select button associated with the Normalmap to see the normal map image used by normal map shaders to make low-polygon models appear to be more detailed.



To add the remaining materials you click the Select Material button associated with the remaining elements (1 through 15) and select the applicable material from the list presented earlier in this article. Once you have added all of the materials the Battle Bus will look like the picture shown below.


If you are new to Unity and/or 3D game development it helps to look at existing games to see how they are guilt and coded to get a better handle on the assets and capabilities your game can have. Unity's Asset Store provides a number of example projects that can be downloaded and used to learn more about Unity and 3D/2D games.

Happy New Year Everyone!