Code Intro
From Moviesandbox
Revision as of 14:11, 20 December 2006
This will become bigger and stuff, but for now, we'll use it for random interesting tidbits.
Contents |
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.
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 MSBCode.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.
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
General UDP Port Usage
These ports are being used by Moviesandbox to communicate with tools or devices:
UDP 21840 -> speech with channel UDP 31840 -> gamepad with channel UDP 41840 -> blocks UDP 51840 -> Gametrak (experimental)