Camera

From Custom Mario Kart
Revision as of 12:08, 19 February 2019 by Atlas (talk | contribs)
Jump to navigation Jump to search

This article explain the camera technics used in Mario Kart Wii.


KMP Sections

Each KMP file contains 3 sections that are related to the Camera setup: AREA, CAME and POTI:

  • Section AREA defines areas. Some types of areas trigger cameras for the finish (after race) view.
  • Section CAME defines cameras. Cameras can be linked together for a sequence of Cameras.
  • Section POTI defines routes for different things. Some camera need routes.

Data Structure

Here are the section headers of AREA and CAME:

AREA entry data structure (0x30 bytes)
Offset Type Description
0x00 Byte Area shape. 0 = box, 1 = cylinder.
0x01 Byte Area type. Values 0–A.
0x02 Byte Index of CAME if type = 0x00, 0xFF else.
0x03 Byte Priority value. A higher number means a higher priority to choose which area activates if multiple areas are intersected.
0x04 Float[3] A 3D position vector of the area.
0x10 Float[3] A 3D rotation vector of the area's rotation.
0x1C Float[3] A 3D scale vector of the area's scale.
0x28 UInt16 AREA setting 1. Used by AREA type 2, 3, 6, 8 and 9.
0x2A UInt16 AREA setting 2. Used by AREA type 6 and 3.
0x2C Byte Route ID used by AREA type 3.
0x2D Byte Enemy point ID. This value is used by AREA type 4.
0x2E UInt16 Padding? Always 0 in Nintendo tracks.
CAME entry data structure (0x48 bytes)
Offset Type Description Box name in
SZS Modifier
Names in
Wiimms Tools
Column name in
KMP Modifier
Box name in
KMP Cloud
0x00 Byte Camera type. Settings
(box 1, first 2 digits)
type Type Type
0x01 Byte Next camera entry index. Value 0xFF means: no next camera. Settings
(box 1, second 2 digits)
next Next Next
0x02 Byte Camshake. Exact meanings unknown (always 0). Settings
(box 1, third 2 digits)
unknown Shake Shake
0x03 Byte Route used by the camera. This is index link into the POTI section. The value 0xFF means "no route". Settings
(box 1, last 2 digits)
route Route Route
0x04 UInt16 Velocity of the camera point in units per 100/60 sec (=distance/1.67 sec). Settings
(box 2, first 4 digits)
v(came) V(Cam) Pointspeed
0x06 UInt16 Velocity of zooming in units per 100/60 sec (=units/1.67 sec) (tested with camera type 5). Settings
(box 2, last 4 digits)
v(zoom) V(Zoom) Zoomspeed
0x08 UInt16 Velocity of the view point in distance per 100/60 sec (=distance/1.67 sec) (tested with camera type 5). Settings
(box 3, first 4 digits)
v(v.pt) V(View) Viewspeed
0x0A Byte Start flag. Exact meanings unknown. Settings
(box 3, third 2 digits)
unknown Flag
(First 2 digits)
Start
0x0B Byte Movie flag. Exact meanings unknown. Settings
(box 3, last 2 digits)
unknown Flag
(Second 2 digits)
Movie
0x0C Float[3] A 3D position vector of the camera. X, Y and Z position (x,y,z) X, Y and Z PositionX, PositionY and PositionZ
0x18 Float[3] A rotation 3D vector. Almost always 0,0,0. X2, Y2 and Z2 rotation (x,y,z) Roll, Yaw and Pitch RotationX, RotationY and RotationZ
0x24 Float Zoom start: The angle of view (field of view). Angles >180 create curious effects. X3 zoom beg Zoom Zoomstart
0x28 Float Zoom end. The camera changes the zoom to this value. Offset 0x06 (Velocity) controls the speed of zooming. Y3 zoom end Zoom2 Zoomend.
0x2C Float[3] Start vector of the view point (camera type 5) or the relative camera position (camera type 3). Z3, X4 and Y4 view point beg (x,y,z) View(x), View(y) and View(z) ViewStartX, ViewStartY and ViewStartZ
0x38 Float[3] (Destination) vector of the view point. Z4, X5 and Y5 view point end (x,y,z) View2(x), View2(y) and View2(z) ViewEndX, ViewEndY and ViewEndZ
0x44 Float The time how long this Camera is active. (in units of 1/60 seconds). Z5 sec*60 Time Time

CAME Types

CAME Types
Value Name Type Explication Route controlled?
00 Goal Goal Activates immediately after passing the goal; with the player as the origin, the camera's View Start position both follows and points towards View End.
It can be reactivated as a Replay Camera if linked to an AREA, but does not display in spectator (online/waiting) mode
No
01 FixSearch Replay Camera stays static in View Start location, and always looks towards the player No
02 PathSearch Replay Route controlled, always looks at the player Yes
03 KartFollow Replay With the player as the origin, the camera's location is at View Start and it follows and points towards View End No
04 KartPathFollow Replay From its position, it looks at View Start and shifts view to View End No
05 OP_FixMoveAt Opening Opening camera, follows route; from its position, it looks at View Start and shifts view to View End Yes
06 OP_PathMoveAt Replay Came type 3 with a route based on the player's location Yes
07 MiniGame Unknown Unused ???
08 MissionSuccess Unknown Unused ???

Examples for good custom camera setups

The following video shows camera setups (opening + finish cameras) of 6 tracks:

Cameras 6 example tracks

Here are some steps how you can make good camera setup:

  1. Open SZS Modifiers KMP editor to show the map.
  2. Make a hard copy of the map (e.g. screen shot to an image program) and print it out.
  3. Look the map and take a pen and write/draw a draw board for opening and finish cameras.
  4. Define the camera positions/routes and the view point routes (lines).
  5. Test it.
  6. Repeat the previous 3 steps until all is perfect.

Analysis

How Areas and Cameras work together

An analysis by MrBean35000vr

While testing the updated SZS Modifier due for release very soon, me and Chadderz decided to have a look into the camera pans and how they work (useful since we plan to incorporate File --> New). Up till now, camera edits have been a bit random on CTs/not done at all, but hopefully now this should shed some light on how everything works.

You'll be pleased to know most of this can be done in the KMP editor

All screen shots below come from the current version of SZS Modifier, not the new one.

First and foremost. In the CAME section of each track (see the KMP) are all the cameras each track uses. They are organised like this: CAME firstbox bean.png

The first Settings column defines everything about the camera. As labeled in the picture, the first two bytes dictate camera type, the next two point to the next camera if the camera is in a sequence (opening pans typically), the next two are 00 and the two that follow indicate what Route the camera is on.

A full list of camera types according to beta data:

  • 00 = Camera immediately after finishing (the one that looks at you. Yeah, you can change it )
  • 01 = ObjClip: Stays in one position but always points to the player. Used during replays.
  • 02 = PathSearch
  • 03 = KartFollow
  • 04 = KartPathFollow
  • 05 = Opening Pans
  • 06 = OP_PathMoveAt
  • 07 = MiniGame
  • 08 = MissionSuccess (left over from MKDS?)

Secondly, AREA has plenty to do with the cameras too.

AREA camera bean.png

AREA also has a ton of types, like CAME, but the one we're interested in is 00, which refers to a camera.

Basically, what happens is when a kart/bike gets near an AREA point with a type 00 in replay mode (or after race), it calls upon the camera that is assigned to that AREA point. By altering the camera ID it points at, you can reorganize the cameras or make different cameras trigger at certain times. The scaling values are useful for making an AREA encompass more of a track.

Finally, if you're feeling particularly creative and want to mess even more with opening pans...

CAMEHEX bean.png

The digit shown there indicates what camera the SZS file looks for first, for the first member of the opening pans. Change this value and you can assign a different starting camera completely. Of course, for that, you need to use a hex editor, as this is part of the CAME header and the KMP editor doesn't show it.

With that, you should be able to mess around with the cameras and create some interesting effects and pans Juggling the other settings not shown in the screen shots will affect where the camera points, etc. And of course, reorganizing the Routes data will make the cameras fly around all over the place at your will.

Now, here's a bit of trivia Despite there being only three opening pans, in each SZS file, there are 5 cameras with the type labeled "05". The reason for this? The other two ones are the ones that are shown in the menu screens when you're hovering over a track name. They are never actually used for anything (as the menu screens employ video files) but they are left over. Sometimes interesting to put them into the opening sequence and have a look at them properly

Opening Pan

An analysis by Wiimm

Each MKW track support 2 opening pans. The first hat two scenes of 5+5 seconds (time values 2*300.00) and the second one three scenes of 3.67+4.28+4.90 seconds (time values 220+257+294). The second one is used for offline versus races. As example see the following video with 4 different modifications of the opening pan of SNES Ghost Valley 2:

4x Opening Pan
T1
Original opening pan. The 2 cuts are synchronized to the sound. Therefor all tracks uses identical timings.
T2
The length has been modified to 3*8.33 seconds (value 500.00). The intro sound will stop after 12 seconds, but the video will go until the end.
T3
The length has been modified to 3*1.66 seconds (value 100.00). The complete intro pan will be stopped after 5 seconds.
T4
Same as T3, but the the third scene is looped to the first one. The opening pan will continue until the player terminates it.

Conclusions

  • Nintendo use for all tracks 3 scenes with 3.67 + 4.28 + 4.90 seconds (total 12.85 second; time values 220 + 257 + 294) to be synchronous to the sound.
  • The number of scenes (more or less than 3) and the length (longer or shorter than 12.85s) of the opening pan is free selectable.
  • If developing an opening pan, link the last scene to the first. This allow you to view the scenes as long as you want. Only the sound stops after about 13 seconds.

Listing of the Opening Pans

This listing was made with Wiimms SZS Tools.

[CAME]

# Index of the opening pan:
@OPENING-INDEX = c11

#--------------------------------------------------------------------
#idx  type           ________position   (x,y,z)________     zoom_beg
#     next     4x    ________unknown    (x,y,z)________     zoom_end
#   unknown settings ________view point (x,y,z)________         -
#    route           ________view dest  (x,y,z)________        time
#--------------------------------------------------------------------
 c11     5       0   -15356.597   11416.276    1959.135       45.000
   >   c12     0x5        0.000       0.000       0.000       60.000
   >     0    0x96     1300.000    3180.000  -13260.000
   >   r13       0     1300.000    4180.000  -13260.000      220.000
#--------------------------------------------------------------------
 c12     5       0   -14650.420   11416.276    1959.135       60.000
   >   c13     0x5        0.000       0.000       0.000       40.000
   >     0     0x1   -12250.000    3250.000   20935.000
   >   r14       0   -12250.000    3250.000   20935.000      257.000
#--------------------------------------------------------------------
 c13     5       0   -13944.244   11416.276    2023.456       55.000
   >    -1     0xa        0.000       0.000       0.000       25.000
   >     0     0x1   -28800.000    2800.000   -7000.000
   >   r15       0   -28800.000    2800.000   -7000.000      294.000
#--------------------------------------------------------------------

[POTI]
#--------------------------------------------------------
#      _____________position_____________   __settings__
#idx         x           y           z         #1     #2
#--------------------------------------------------------

 $ROUTE r13, settings:  0x101
   # CAME reference: 11

   1    -3300.000    3425.000   -9715.000    0x41      0
   2    -3167.503    3802.622  -11586.739    0x41      0
   3    -2850.021    4147.562  -13296.482    0x41      0
   4    -2170.477    4512.062  -15020.681    0x41      0
   5    -1353.422    4853.018  -16558.229    0x41      0
   6       67.820    5254.155  -17889.562    0x41      0
   7     1633.572    5624.124  -18893.162    0x41      0
   8     3373.454    6026.505  -19765.127    0x41      0
   9     5160.000    6425.000  -20470.000       0      0

 $ROUTE r14, settings:    0x1
   # CAME reference: 12

   1    -4770.000    3300.000    1800.000    0x1e      0
   2    -8800.000    3300.000   12400.000    0x1e      0

 $ROUTE r15, settings:    0x1
   # CAME reference: 13

   1   -28800.000    7740.000   15500.000    0x8c      0
   2   -28800.000    2960.000   -2000.000       0      0

Camera related articles

»Camera«
Technical information, includes an analysis.
»KMP«
File, where the camera setup is hold.
»KMP Editing/Cameras«
A KMP and camera tutorial.
»Wiimms SZS Tools/KMP«
How to edit KMP files using Wiimms SZS Tools.