UT2k4 CodeCentral

From Moviesandbox

Jump to: navigation, search

This is the workbench for Code documentation right now. All the things i'm documenting on the fly will start here and then be sorted into their individual pages. Such as Custom Input Controls.

Contents

[edit] Custom Input Device integration

Moviesandbox gives you the possibility to integrate your own input devices and characters by using the udp protocol to communicate between your input device and MSB. Once you transformed your Device data to UDP, you can send your data to port UDP 31840+ channel. I'll explain below.

[edit] Setting up the structure within Moviesandbox

In order to create your own custom interface to control your actors - as the GATech people did for example - you should take a look at the MSBCode.MSBPawnInputControl.uc file.

Create your own custom Pawn by subclassing MSBObjects.MSBPawn and create your own MSBPawnInputControl by subclassing MSBPawnInputControl. Ideally you'll have your own package for both your new classes. Feel free to add functionality to your Pawn, like linking to your special skeleton.

The Pawn automatically generates a PawnInputControl. All you need to do is to specify which class to use when generating the PawnInputControl. This is done in the Button that will create your pawn.

Go ahead and sublass MSBMenuButtons.MSBCreatePawn and add the following piece of code to your new class:

function LeftBtnFinished(Canvas C)
{
local Pawn P;

P=Pawn(SpawnActor);
MSBPawn(P).MSBPawnInputControl=Spawn(class'myPawnInputControl',P,,P.Location);
super.LeftBtnFinished(C);
}


whereas myInputControl stands for your InputControl class.

We're almost through! Now all you need to do is to make your Button appear within Moviesandbox. In order to do this, open the MSBButtonConfig.ini in your System folder. Find the [MSBCode.MSBMenuButtonStatic] part and add a reference to your button to the end of the list, like this:

.
.
.
ButtonList=MSBMenuButtons.MSBCreateMyPawn

There you go! You're now all set up to program your own Input directives.

[edit] How to implement your own functionality

The MSBPlayerInputControl has its own UDP socket, set to a port that can be defined within the Moviesandbox environment. After placing your character (using the button we created before), right click on it and set the UDP channel. This will set the UDP socket of this character's PAwnInputControl to port 31840+channel.

The PawnInputControl.Tick(float DeltaTime) function has access to the byte array that is being transferred each frame through udpLink.byteData[]. It also has access to a string conversion of said byte array through udplink.Data. An example on how you can use your input data can be found within the original MSBPawnInputControl, where the pressing of a gamepadbutton is transformed to a pose and moving the sticks is transformed to head or eye movement, following the data structure:

Byte0 -> xAxis
Byte1 -> yAxis
Byte2 -> uAxis
Byte3 -> vAxis
Byte4 -> ButtonNumber

[edit] General UDP Port Usage

These ports are being used by Moviesandbox to communicate with tools or devices:

UDP 21840 -> speech with channel IN (from vvvv)
UDP 31840 -> Device with channel IN (from Multi HID Input)
UDP 41840 -> blocks IN              (from Tracer)
UDP 61840 -> Bone Rotations IN      (from MoCap Tool)

[edit] General Lipsync Setup

[edit] Voxel Lipsyncing

MSBSimpleBlock has an implementation for Mimic() and Talk().
MSBMouthBlock uses the Talk() function to either switch a texture on the block OR move the block down and up.
In short:

  1. You paint your voxel character.
  2. You paint one or more MouthBlocks.
  3. When saving/loading, you save the class of each block and the MSBVoxelpawn finds MSBMouthBlocks and references them in a "FaceBlocks" array.
  4. In MSBPawn, when the LipSyncUDP (gets set up when changing the Channel) object triggers the pawn, it calls Talk();
  5. In the MSBVoxelPawn class (child of MSBPawn), in the Talk() function, all FaceBlocks (parent class of mouth and eye block) get their talk() function called.
Moviesandbox for UT2004