Sunday, February 17, 2013

Dismantling the UCScript Parser and Interface


The intent of this small series of posts is to not only show a breakdown of the UCScript Parser but to also look at a process of how it was made, some python parsing techniques used, and a bit on Kivy UI programming.

In this first part I am going to be going over the general data structure of the parser, the ideas behind it and a little on the intended Kivy UI. Along with this talking briefly on what defaultProperties are in an Unreal Script and some problems involved.

//Parser


The idea behind this parser is to be able to break down an Unreal Script into its default properties and have it return a dictionary of these properties and values to the UI. The way these returns are structured will be explain shortly.

//DefaultProperties


So to start off we should get a general idea of what we will be parsing which is the defaultProperties. Default properties, simply put, are just properties that relate to the script that they are in and can control aspects of it. (ie. In a vehicle script you are bound to find a property called groundSpeed which controls how fast a car can go while on the ground.)

For the parser we don't need to know all the names of these because there are hundreds of them but do need to know that they exist in the defaultProperties section. This section is usually located at the end of a script and is structured in the following way.

//Header
//Functions

defaultproperties
{
     PropertyName=Value
     PropertyName=Value
     ...
}

As you can see from above it is a fairly simple construction as all default properties consist of a Property Name and a Value. These are what we are going to be extracting from the script, the only trick though is that all Properties are not as simple as a name and a single value. This is where things will get a bit complex when parsing.

//Property Types





Looking at the diagram above, I have found there to be 6 types of properties, 3 of which are simple and the other 3 complex. They are differentiated this way because of the way the data will need to be parsed and stored into the dictionaries.

The first 3 types (string, bool, and int) are simple because they are only Property Name and Value entries. The way these will be structured in their dictionaries is:

type_defaultProperties = { PropertyName : Value }

The other 3 types is where it will be a bit messy, first in getting the value information we need and secondly being able to reassemble it when converting it back into code. Lets take a look at each type real quick.

Vector properties encapsulate anything that takes an X, Y, or Z value. Something that would fall into this category would be boneOffsets since they take a 3 vector input. The way we would want this structured is:

#Structure we will use in the parser for storing
vector_defaultProperties = { PropertyName: { X : 0.0, Y : 0.0, Z : 0.0} }

#Not used because of vagueness
# vector_defaultProperties = { PropertyName : [X, Y, Z] }

The reason behind storing these values in a nested dictionary is because some offsets or things to be considered vector properties may only have a Z value listed. This will allow it to store it correctly and then when trying to access it again it can be done more precisely as opposed to storing it in a list. This will all be explained more in depth when writing out the function for actually parsing these data values.

The second of the complex properties are the curve properties. The big challenge with these properties is making sure that all the information is collected property and organized in such a way that we can access any of the variables with great accuracy. Because of this a curve dictionary entry will be structured as:

curve_defaultProperties = { CurvePropertyName : { 0 : [ inVal, outVal ], 1 : [ inVal, outVal] } }

In this case, curve properties are stored as property:points. The property is equal to a dictionary of points, the keys being which point it is and their values a list of the inVal and outVal. This way we can rearrange points, change values and write back out with ease.

Finally are possibly the most complex I find for parsing which are class properties. These objects are simple to get but the real challenge will be in getting which properties they contain. Right now there is not a definite structure for them but it will post likely be a prefix added to the property type. The classes dictionary will contain a list of all the classes and link their values to the preprocessed defaultProperties. It will look something like this

class_defaultProperties = { ClassName : [ Link to property, Link to property ] } 

This way we will be able to reference classes and their internal properties that only apply to them.


//How the Data is Stored


Just a quick review of how the data will be returned to the UI.

Simple Property types include strings, bools and ints and their dictionaries will look like:

str_defaultProperties = { PropertyName : Value }
bool_defaultProperties = { PropertyName : Value }
int_defaultProperties = { PropertyName : Value }

Complex Property types include vectors, curves and classes.

vector_defaultProperties = { PropertyName : { X : 0.0, Y : 0.0, Z : 0.0 } }
curve_defaultProperties = { PropertyName : { 0 : [ inVal, outVal ], 1 : [ inVal, outVal ] } }
class_defaultProperties = { ClassName : [ ClassName_PropertyName ] }

All of these dictionaries will be sub-dictionaries of a main defaultProperties dictionary.

//Intended Kivy UI


Finally I'll talk a bit about the intended Kivy UI. The most important part of this UI in particular is the ability to be dynamic in nature, purely because we want this to work with any Unreal Script the user plugs into it. It should be able to receive any of the properties dictionaries and depends on the entries, generate widgets to control those inputs along with saving them back out. Another thing that will be added is a propertyInfo dictionary so that when a user is using this tool, they can click on a property name and see a brief description of it.

That's it for now, a lot of talk but in the next post I'll start going into detail on some of the code and how the main parser is constructed, along with beginning the UI.


Tuesday, November 13, 2012

Simple Vehicle Generator - Process

After a long hiatus I'm back and this time with process of a new set of scripts to write, a Simple Vehicle Generator or SVG as I'll be calling it! To dive right into it, this has been on my mind for a while and after having done the Simple Weapon Generator (which has been updated a few times since first posted!) I feel I am prepared for the task at hand, knowing some of the pitfalls I will encounter and some things to watch out for with actual structure and usage.

So the best place to start is with a description of this new task. The goal of the Simple Vehicle Generator (SVG) is to allow for fellow artists and students to easily rig and script a vehicle for use in UDK. With this there will be 2 main components:
  1. The Simple Vehicle Generator Application (Script Generation)
  2. The Simple Vehicle Rig Generator (Maya script for preparing the vehicle mesh for use in UDK)
 The application portion of this I plan to structure like the Simple Weapon Generator. Having different categories for each of changeable values (meshes, sounds, handling, ect.) Possibly rearranging the structure however to be more user friendly and fun to use, sort of like in a racing game where you choose your racer and get to build the car the way you like, but with a lot more options! Sort of like...


But without the actual rendering of the car and mainly using the selection elements at the bottom and stat readout on the left hand side. I'll have to create a mock-up for my next update of my intended UI. I will either be using wxpython (something I've used quite frequently), qt, or Kivy to create this.

As far as the process to create the scripts goes I am leaning toward a modular script structure where there will be 2 types of scripts. Unreal Shell Scripts which are basic vanilla scripts needed for vehicles to work with none of the defaultproperties and a dictionary of defaultproperties that can be added to each Unreal Shell Script. This will hopefully become more clear as I visualize this structure soon.

The second part of the SVG will be the Maya tool to prepare the vehicle mesh for use in UDK. The idea for this tool is that it will allow for widgets to be placed around the vehicle mesh which will then be used as reference to create a skeletal structure and apply the right bindings. Below is a mock-up I put together of how I think I'd like the tool to look, ultimately it would be docked into the main Maya window.


And a description...


1. These are a collection of widgets to be placed onto the mesh. Upon clicking it will create a widget which can then be positioned and snapped onto the mesh. An example of this would be the wheel widget which would look like a simply polygon wheel. It would be placed around the actual wheel mesh of the vehicle to be rigged and serve as a locator for when the joints are created. It will also serve to name the joints correctly for use with the script generator.

2. The "?" buttons next to any of the widgets will provide extra information on its use by providing an infographic describing how it is placed visually on the model. This will change depending on which "?" is clicked.

3. Below the inforgraphic will be a textual description of its use and a step by step guide on how to place it for optimal bone structure within the mesh. Mostly an aid to the graphical element.

The rig button will effectively rig the vehicle with a proper bone structure, removing the widgets and providing proper controls. Readying it for export into engine.

I think that all of this is a good handful of a start for now, next time I'm hoping to post some of the sketching and hand written note part of the process to show how more of this developed. I find that doing these mock-ups of structure and UI help me to visualize its actual usage and the actual structure of the script running behind it. For now though it's time to buckle up and see where this ride takes me!

Sunday, March 18, 2012

SWAG Bag

Download SWAG Here : SWAG Download

A quick post on something I've been working on recently, SimpleWeaponGenerator or SWAG as I like to call it. This allows for the creation of simple weapons in UDK. It creates the 5 scripts needed for a new weapon using custom inputs from the user. Once the scripts are made you just need to recompile them with the UDK Frontend.

I will be using some friends to test it out and hopefully work out some of the bugs and refine it a bit more. Along with the script side of things I have also created a SWAG Rig, for quick and easy rigging of simple weapons in UDK. The user just needs needs to place locators in the specified places. Below is an image of this tool, this one is used in Maya while the script generator is a separate application. Upon generating the rig it will clean up the locators and all that will be left to do is to bind the resulting skeleton with the weapon


There are a lot of things Id like to do with the script generator but for now it is very bare bones. I'm hoping for the next major update though is to add a few basic weapon templates (LinkGun,ShockRifle,RocketLauncher) that users can choose from so that there is varying functionality, but for now I am glad that it is just functioning!

Thursday, March 1, 2012

Demo Videos

With GDC right around the corner at this point I decided to revamp this blog (yet again) into a more organized fashion and finally add a few short demo videos of some of my tools. Eventually these will be moved to be with the tools, but for now I'll just be consolidating them all into one post. I plan to expand on these with a more in-depth video of each as they progress forward.


Friday, December 16, 2011

Borderlands Inspired Environment

Finally getting around to posting this. I recently just finished up the last project for the semester which was to create a fantasy environment based on an already existing game. For this my group chose to base ours off of Borderlands and below is the result. We were able to create a very large area with some hints at a story to it (Dirty Rick) with a few fairly small kits. One thing I will probably go back to work on is the graffiti to make it look more like ... well graffiti and a nice healthy grunge pass. Overall I was extremely pleased with how this turned out!


Monday, November 21, 2011

WIP Texture Cheque

Texture Cheque is a simple program I've been working on in my spare time that calculates the number of textures maps being used for on project. This came about because by the end of a project I would have a random assortment of many texture maps and would have to then count and add them together to make sure I'm within the limit. This program does this automatically and displays how many of each map is being used as well as the total pixel count. To do this you set the "Image Directory" to a folder that contains all of the texture maps and then click calculate.

Right now it simply just displays how many of each size texture is being used and allows the user to view a list of the specific maps. Soon I hope to add in the ability to re-size selected textures from within the program, eliminating the extra need to manually open Photoshop and re-size from there.

Below are a few pictures of the interface thus far.


Wednesday, November 9, 2011

[3D] Mass Effect Realistic Environment

Recently we had just finished an assignment where we took a realistic game and created a space that would go with it that wasn't done before. For this I worked on a team that chose to do a hangar/weapon testing area in the Mass Effect Style and this is how it turned out.

I worked on the weapon testing area where they were firing a large laser that would be attached to the ships as they docked in the bay and this is how it turned out.


One thing I was excited about with this project is that I was able to make a lens flare similar to Mass Effect's to be used in our areas but because of the angle the picture was taken at, it cant be seen. Below is what it had turned out to be and was used on most of the lights within our environment. (The picture was taken while the area was still being finished up but the lens flare was complete)


Along with doing this in UDK I had also ported my area over to Mobile which I was pleased with but was a bit saturated in the lighting and didn't have as much ambient lighting as I wished it could have. It was definitely a good learning experience with the Mobile editor and how its materials are created compared to regular UDK.