Camera editing for Sonic Adventure

Discussion in 'Engineering & Reverse Engineering' started by Dude, Oct 10, 2009.

Thread Status:
Not open for further replies.
  1. Dude

    Dude

    Tech Member
    3,138
    0
    16
    Southbridge, MA
    Random VR/AR trash
    How to make a sa2-style camera layout
    =====================================

    The camera layout in sadx is quite similar to the SET format, and as such we'll need the following for this tutorial:

    1. A level rip of the act in question
    2. 3d studio max (any version with obj import)
    3. Hex workshop

    However, unlike the SET format, the camera format is NOT 100% understood. In fact a closer wager is 30% but we know enough to make files flexible enough for gameplay, and from scratch. For reference, here is an approximation of the format:

    Code (Text):
    1. ==========================
    2. Header (0x40 bytes)
    3. ==========================
    4.  
    5. dword camera_num; //tells the game how many cameras to load
    6. Array(0x3C) Padding; // filler until the first camera
    7.  
    8. ==========================
    9. camera structure (0x40 bytes)
    10. ==========================
    11. Byte Camera Type; // Type of camera
    12. Byte flags1; // frequently unused
    13. Byte pan_speed; //
    14. Byte priority; // 0 doesn't activate, 2 is used for respawn cams.
    15. dword flags2; // null derp
    16. float position[3]; // x,y,z location of sphere center
    17. float variables[3]; // self explanatory
    18. float null; // null derp
    19. float point1[3];
    20. float point2[3];
    21. float variable; //
    For some reason, when making a file from scratch, the first camera object is not read properly and is ignored. No idea why it does this but the camera system in sadx is very cryptic and touchy.

    Alright, now let's start our new camera file, we're going to be working on emerald coast act 1, so make your backup of CAM0100s.BIN, and open a new file in hex workshop. insert 0x60 bytes, and open <a href="http://x-hax.cultnet.net/Tutorial/EmeraldCoastLevelRip.max" target="_blank">Our level rip</a> and freeze the level. On a new, visible, and editable layer, create a sphere over the start point of the level like so:

    [​IMG]

    Name your new sphere "Cam[80]". Go back into hex workshop and at the end of the file, create a new 0x40 block. Set the camera values to the following for right now:
    Type = 27
    flags1 = 0
    pan_speed = 10
    priority = 2 - do this because this camera takes effect upon respawning
    flags2 = leave this 0

    go back into 3dsmax and copy the sphere's x,y,z coordinates and paste them into "float position[3]" like so:

    [​IMG]

    Now, since cam type 27 is an orbital camera, we'll have to pick a point for it to focus on. Go back into 3dsmax and create a point helper at the spot you think the camera should focus on, like I've done here:

    [​IMG]

    Name the helper "cam[80]t", now copy its coordinates from 3dsmax and in hex workshop paste them into the point1 floats like so:

    [​IMG]

    Now as it is, the camera won't function, we haven't defined the size of the sphere to be used. So select "cam[80]" and copy its radius from 3dsmax into the variables[3] floats that occur right after the coordinates for the center of the sphere. Lastly, put "40" into the last variable float. Cam type 27 reads this as the distance from sonic to maintain. Go to the first byte in the file and change it to 02 to get the game to read to the end of the file. Save, and load emerald coast. You should get the following:

    [​IMG]

    As you can see, the camera will now maintain a straight line between this point and sonic, at a constant 40 units from sonic. In other words, it circles the focal point. It's not very good at deviating from this distance and will accomodate walls and objects with all the regard of a trippin mongoose. Because of this, two important things to remember:

    - use small distance values in cramped spaces
    - the closer sonic gets to the focal point, the harder he is to control. NEVER make it possible for sonic to to touch the focal point, in fact try to keep him at least 100 units from it, if you can.

    SA2 uses these orbital cameras almost exclusively, and when used correctly, yeild good results. To make it so sonic can move past the focus point and on with the level (easily), let's place a new camera object at this position:

    [​IMG]

    Name this next camera "cam[c0]"... notice what we're doing here? We're naming the cameras their offsets so that they are easy to jump back to if we need to fix them or update them. You'll find that after a month of messing with camera files, you'll be alot better at plotting them than you were when you first started. You'll also notice that camera files rarely behave. Also, notice where I placed the camera object in relation to the previous camera's focal point. This has 2 advantages:

    - the focus points allude to the next part of the level
    - the fact that the new camera is as far as it can be from the focal point while still engulfing it helps the transition from one focal point to the next.

    Go into hex workshop and copy/paste the last camera point to the end of the file. Update the camera's position, then plot a new focal point for the new camera object. I put my focal point under the first straw roof hut where the bouncy ropes are, so I can get as much mileage out of the camera object as possible. Since this focal point is so far away, slow the camera pan speed down to 13, and bump up the cam distance to "65". Remember that if you have a path that wraps around a large cylindrical object you can place the camera's focal point in the middle of the object and the camera will rotate around it, although this is more sa style than sa2.

    Now that you've placed your second camera object, update it's focal point values, then update the file header and save. You now have the entire first island (mostly) accounted for. But something seems bland about the springs...

    Whenever a game takes control from you, the event is meant to be quite the spectacle. For our spring segment to stay blah while we lose control would make the player lose interest in the game quite quickly. Let's add a new camera object where the springs would go. But this time, scale up the sphere to encompass the entire area where control is taken from you, this screenshot should serve as good reference:

    [​IMG]

    Now we're going to introduce a new camera type. Add an empty 0x40 block, and use these settings:

    Type = 15
    flags1 = 0
    pan_speed = 09
    priority = 2 - do this just because it works =P
    flags2 = leave this 0

    update the center coordinates. Camera type 15 is a fixed point camera, the camera doesn't move, but rotates to focus on sonic as long as sonic is in the boundaries of the sphere. Put the camera object's radius into the variable floats as you did before. The coordinates for the camera position go into the floats for point2. Put the cam's 'focal' point somewhere where it would make the sping sequence look cool - I chose right next to a pier post. Update the header, save and re-load the level.

    Youve completed the tutorial (hopefully sucessfully) If you're stuck or lost, you can .download my completed, working files <a href="http://x-hax.cultnet.net/Tutorial/camediting/cam_tut_result.rar" target="_blank">here</a>. This includes my MAX file with camera layout, and the CAM0100S.BIN

    Enjoy your ability to extend/modify the level and SET file and make your creations playable. And for reference, here's a highly incomplete list of camera types you can use:

    Code (Text):
    1. ==========================
    2. Camera Types
    3. ==========================
    4. 15 = fixed camera, sonic target
    5. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point2 is camera location
    6.  
    7. 27 = orbital camera, permanent (keeps focus until overwritten)
    8. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;variables are radius (not consistently)
    9. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point1 is orbit center
    10. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;last variable is camera distance
    11.  
    12. 23 - orbital camera, temporary (releases when you leave its sphere)
    13. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;variables are radius (not consistently)
    14. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point1 is orbit center
    15. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;last variable is camera distance
    16.  
    17. 04 - free cam, unlocks the focus point
    Now hurry up and make more sadx hacks damnit! I wanna play something I haven't made!
     
  2. MainMemory

    MainMemory

    Have no fear...Amy Rose is here! Tech Member
    4,450
    79
    28
    SonLVL
    I'm going to make a hack. I don't have any of your fancy model tools, so I just use SADX for coordinates. And Cheat Engine and Notepad++ are the only hex editors I have. I'll have to give this a try sometime.
     
Thread Status:
Not open for further replies.