Week 11 Notes

Array in Virtools

Array is another special type of entity in Virtools. It is something similar to generic type of storage in tabular format (rows and columns). You can create your own table to store user defined values in each cell. For instacne, there are 10 enemies you need to beat them down. The way you defeat an enemy is to hit it till its health or energy goes down to zero. In this simple setup, we need to know all 10 enemies' energy level to decide if it is dead or not. Or, when you fight with one, you may want to show its energy level on GUI. There are many cases you need to know values and attributes of other entity in your game. Array is designed for this needs.

 

a. Create Array

You can create Array by clicking the Create Array button in the Level Manager (not from tool menu!). Then, you get into Array setup panel. There, you can add Columns and Rows as you need. As testing purpose, let's create array with three columns and two rows. The columns will be used for name of character, life, magic. Character name is string type and the other two are integer type. Click add column button and set type accordingly. Then, we add two rows for our two character Eva and Pierre. Click add row button and set each cell value accordingly. For instance, the first cell in the first row will be Eva, the second cell is 200, the third 200. We start off with 200 life and magic value.

 

b. Getting Array Data

First of all, you can find most of array related BBs in Logics / Array directory. To get data from array, we can use Get Row BB. This is the simplest one. As you specify the target array which we created, you see the parameter output matches our columns (character name, life, magic). We can easily display this information on screen using Text Display BB that we studied last class.

 

c. Setting Array Data

Set Cell BB is the simplest one for this purpose. You can directly change contents of given cell. To only check how this works, we will use a few keyboard message to increase / decrease our charster's life and magic values. Since we do not set value with fixed number, we also need to know what's the current value is so that we compute decrease / increase by some amount (i.e. +- 2). We can use above getting array data method here for that purpose. ParamOp will be useful too to compute numbers.

In this example, you can use keyboard "1" or "2" to increase / decrease life of Eva character. Once her life becomes zero, then show game over in the center of display.

 

 

* In class exercise. (Example)

Now, let's put several components we've learned together to make something more like game. The secenario for our exercise is "shooting game". Add two character in the scene and choose one as our player character and the other will be opponent. As you press "space" key, your character throw dart. If a dart hits opponent, it decrease his life by 10. Once our enemy's life reaches 0, then it dies (maybe explode). Display your opponent's life value on screen. You can reuse some of our previous class example or exercise samples.

 

Baking Texture in Maya

Realitme software such as Virtools never catches up offline renderer quality! For intsnace, the image you rendered in maya looks much much better than the one you see in Virtools. Fundamentally this is because we are using realitme renderer. We render dozens of image per second to be interactive. One good workaround is to facilitate maya's rendering result as a texture for our object. This takes advantage of offline rendering quality in realtime software, Virtools. Lighting, shadowing, and fancy shading result can be shown in Virtools.

 

This quick, short tutorial is inspired by Alan Price's class material. (found here)

A few requirements in this method are followings.

- object should have UV mapping

- UV map should not overlap (none of face overlaps in UV edit window)

- we use depth shadow map (find in light attribute. if you need to use ray tracing for better quality, we should use other technique to bake it to texture.)

 

Take a look at Alan's webpage to bake your texture. Different from his explanation, you do not need to create new material before exporting. You can just export it to Virtools format and that should work as it is in maya viewport.

Do not forget to change material emissive color to something very bright. You can change it in maya by increasing brightness of incandescense in material property or change it in Virtools by setting emissive color to brighter one.

 

Here is a sample Virtools composition using this technique. (link. use arrow key to rotate scene)

(You can find related files from class pickup/Week11 directory including maya scene and virtools composition files.)