Tuesday, June 19, 2012

camera profile changing

Today I implemented my "camera profile" mechanic..  The camera profiles allow me to switch between different camera physics settings all via the config files.  The way it works is that in the MasterConfig.txt (which cannot be changed in path or name) there is a path to another config file, which I have called CameraConfig.txt but can be named or placed anywhere.  Here is an exact copy of my camera config file:


//        CURRENT CONFIG FILE FORMAT:
//        number of prifiles
//        //
//        float maxVelocity
//        int impulseXZ
//        int impulseY
//        float frictionX
//        float frictionY
//        float frictionZ
//        float frictionYRotation;
//        float rotationYImpulse
//        float rotationYVelocityMax
//        int mass
//--------------------------
//--------------------------
//--------------------------
2
//--------------------------
//helicopter cam
//--------------------------
//max Velocity
10
//impulse in XZ plane
15
//impuse Y plane
5
//friction X
2
//friction Y
4
//friction Z
2
//Rotation friction Y
3
//Rotation Impulse Y
.08
//Rotation Velocity Max Y
.08
//Mass
100
//-----------------------
//walking cam
//-----------------------
//max Velocity
1.8
//impulse in XZ plane
4
//impuse Y plane
0
//friction X
10
//friction Y
10
//friction Z
10
//Rotation friction Y
15
//Rotation Impulse Y
.15
//Rotation Velocity Max Y
.08
//Mass
100


My ConfigReader class reads in this file, and creates and fills out an array of custom data-holding classes filled with data the data found above.  Since this array's size is dependent on the first line in this config file, there is no real limit to how many profiles there can be.

The use for this feature is that I can now switch between helicopter and walking physics profiles with a simple function call: camPhys.setPhysicsProfile((short) indexOfProfileHere );  After that call, the camera will behave completely differently, e.g. going from helicopter controls to walking controls.

Tomorrow I will work on getting a popup window for displaying game dialog.  I want to try and get it to display in the cockpit's heads up display, but if that turns out to be too hard I will use the well used game mechanic of displaying game dialog in a boxed popup towards the bottom of the screen, something like:


No comments:

Post a Comment