SyntaxHighlighter

Wednesday 3 July 2013

Day 18: Automating model addition

Enabling automated addition of arbitrary number of models

The current system utilizes ModelSets, which are sets of 10 Models that the user can choose between on the fly. In this way only the activeModelSet will be displayed on the 10 marker cards at one point in time (quite simply, we have 10 cards so can only have 10 Models at once). When the activeModelSet is switched, then the current set of Models is replaced with the newly selected set immediately, so we can successfully have more models than marker cards.

Now, we want to have it so that the user can supply a model, some basic info, and the program automatically generates the model demo, adds it to a ModelSet etc, creates floors and walls in the Model demos and basically manages the entire adding a model procedure without the user ever needing to see the source code.

Note:

For clarity, this blog refers to each demo (the graphics that show when you hold up one marker card) as a "Model". This is not entirely accurate, as some demos have multiple models in them (e.g. the ship flying through the torus demo has two models, a ship and a torus, but it still counts as one "Model" of a "ModelSet").

The new system needs to be able to add Models to the ModelSets on the fly, and allow the user to loop through and choose between an increasing number of ModelSets as more Models are added to the system.

The information a user passes to the program

This is the basis of the automation. The user only needs to add the minimal amount of information to a freely editable config.txt file, and the program should do everything else by itself (generating the Model (i.e. the demo), assigning the Model to a ModelSet, incrementing the number of ModelSets when necessary, managing the activeModelSet and allowing the user to switch between any number of ModelSets, etc).

Steps to add a model:

  1. Place model file into program directory
  2. add information to config.txt

The issue of content importing:

The current way that models work is that a programmer, e.g. me, needs to actually open the code in Visual Express C#, and manually import the model into the program content, and rebuild the program. The automated method I have in mind should not require the code to be recompiled, and apparently this can be done by building a content pipeline extension, so I'll make me one of those.

At the moment config.txt is used to pass the following data into the program:
Camera framerate
Camera x-axis resolution
Camera y-axis resolution
model name, model scaling value, marker id/name of marker array (multiple lines of this, for each model/marker mapping)

The current system maps a model to a marker (the final line above that is repeated for every model), but with the automated system we want to do away with this. Since model sets can be switched at any time, each marker will have different models at different points in time, so we want to have two parts here, firstly information on marker arrays, and secondly information on models (separated from the marker array information). Initially I plan to have two config.txt files, config.txt and modelconfig.txt. Hereby we separate model information from marker and camera information into different files.

At its completion the new automated ARdemo will be able to handle any number of newly added marker arrays as well as newly added models without any changes to the source code. All the user should need to do is edit the config.txt file.

A later step will be to make a "config.txt generator" program that has a GUI that will make it simple for anyone to add models, sound and do interesting stuff.

Step 1: Handle an unlimited number of Marker cards, allowing room for more in the future

modelConfigArray is an array of modelConfigs, wherein each of the configs represents one marker card. Thus as we have 10 marker cards (which is why our ModelSet is of size 10), modelConfigArray will also be a size 10 array.

Step 2: Handle an unlimited number of Models via an addModel helper method.

To do this, we need an array of ModelSets that can be expanded on the fly. Each ModelSet in the array is of type List<TransformNode>.

The global variables I can think of right now that we'll probably need are:

        int ActiveModelSet = 0;             // Current active set of models (default is set 0)
        int numModelSets = 2;               // Total number of model sets
        int numModels = 20;                 // Total number of models
        List<TransformNode>[] modelSetNodes;// Lists of all transform nodes in each ModelSet

        int numMarkers = 10;                // How many marker cards there are
        modelConfig[] modelConfigArray;     // model configs for ever marker

The way this is going to work is as follows:
  1. Initialize modelSetNodes when we read in config info about the models.
  2. Initialize modelConfigArray when we read in config info about the markers.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.