don't click here

Importing Level Art into SonED2

Discussion in 'Engineering & Reverse Engineering' started by iojnekns, May 29, 2008.

  1. iojnekns

    iojnekns

    trouble keeps you runnin' faster Member
    148
    0
    16
    IOJNEKNS ! SNKENJOI

    So you want to import your own art into SonEd 2?
    Please note, I have been modifying Sonic 2, and have absolutely no experience in the same process for Sonic 1. I am by no means an expert in SonED2 myself, and this is not the definitive method of importing art. This is the method which I developed through sheer trial and error, so if you think I am ‘wrong' feel free to correct me for the benefit of anyone who might try and learn from this guide. I've tried to make this as straightforward as possible for beginners, so if you feel patronized,I apologize.

    #WARNING#
    A stray click in SonED2 is likely to change something. Probably something which will come back to haunt you. There is no undo button and if you hit ctrl+z and delete some art trying to undo, you can't undo that either. It is important to save frequently until you are confident enough with the program that you understand what your clicks will do.

    Preparing the Art
    Obviously, you will need to draw this new art, first and foremost. At this point, you may have already drawn the artwork and are banging your head against a brick wall. Equally you may not have started yet. In either case you should take into consideration;
    - SonED2 imports image files from the .pcx format, not the most common image format in the world. In short this means you cannot just use MS Paint for drawing. I use Paint Shop Pro, which even shows the palette of the image on the colour selector, so it is worth exporting existing level art, erasing the image, and working from this file to preserve the palette.

    [​IMG]
    Probably an insult to your intelligence.

    [​IMG]
    Note the imported palette in the right hand corner. Also note the perfectly divided 128x128 chunks.

    - SonED2 will import the art into 128x128 ‘chunks' 16x16 ‘blocks’ and 8x8 ‘tiles.’ It does this automatically, working from the left to right, down the image. To make for a clean import, you should make sure the image file you are importing is perfectly lined up (I recommend using a configurable grid to achieve this, and guess what... PSP has one). Any repeated chunks, blocks or tiles are skipped over after their first entry. It is of course possible to break down your art into individual 128x128 chunks and import them in one by one, although there is no distinct advantage of doing this. If you are using a very large image, then it goes without saying that you should ensure that the dimensions of the image are multiples of 128
    - Each individual tile (8x8 squares) can only take colours from one palette line, so if your art contains colours from across the palette, the colours will be taken from their equivelant place on the palette line you are using. If this is the case you may want to consider revising your art. SonED2 tries its best to auto-configure the palette when you import the art, choosing which line to use based on the top left pixel of the tile.

    [​IMG]
    Level art cobbled together in 30 seconds. The grid I am using is 16x16 (block sized)

    Replacing the existing level
    Assuming you have taken into account all these things and your art file(s) are ready, you will want to choose a level to overwrite. Open the level in SonED2, (in the /soned2proj/ directory of your disasm, Emerald Hill would be ehz1.sep)

    [​IMG]
    For the slow...

    and hit ‘I’ to reach the chunk selector screen. At this point you will want to remove all of the existing art for the level, so select a chunk and hammer ctrl+z repeatedly until every single chunk has been removed. Chunk 001 is the blank tile by default, so either preserve it or ensure that the first chunk that you import is the blank chunk you will be using. Next click on the ‘block selector’ text on the right of the palette display, and repeat the process for blocks, and finally tiles, the menu for which can be accessed from jsut under the palette display.

    [​IMG]
    Emptying the level. No, there isn't an easier way.

    Importing Art and correcting colour issues

    Once the level has been “hollowed out” as it were, hit, file > import from image > chunks. Chances are, your art is there, though patchworked and miscoloured.

    [​IMG]
    To illustrate how SonED 2 can incorrectly import colour, note here that on the second chunk, I have used the dark grey from the second palette line (10th colour from the left). As you can see in the SonED window, that same position in the _first_ palette line is occupied by a tan colour, which explains the tan colouring on seemingly random tiles on the second chunk. Also note that the chunk selector is still open on the right of the screen. You should be using the block selector at this point so your window may differ.

    Next you must go through the painstaking process of correcting the palette. Here you will need to use the block selector, left click on the first block to bring it into the tiny window on the left of the words “block id,” and the right of the palette display. Moving the mouse here you can select one of the four tiles used to make up the block by double right clicking and then altering their properties with the tiny arrows on the right. Alternatively you can hover the mouse over the area in question and alter the settings with keyboard shortcuts. In this case, use H+N to change which palette line each tile uses, hovering over each one in turn. This is quite a long process, particularly if you have a large amount of art to import so you may want to deal with the planes at this point too. Above the palette line selector there is a plane selector which specifies whether the tile is high plane (foreground) or low plane (background). Bear in mind that blocks have the same properties regardless of whereabouts they appear, so you should have some idea of whether you want sonic to consistently run in front of or behind the tile. There is nothing to say you can't return to configure the foregrounds/background aspect of the art at a later stage when your level has taken shape and the ‘bigger picture’ is clearer to you.

    [​IMG]
    Here, I am midway through altering the palette line of each tile one by one. The one currently selected is still set to palette row 0 as you can see, where it should be using palette row 1 where the correct grey resides.

    At this point, you can hit L and paste in some makeshift level layout, although you will notice that SonED2 is trying its best to load a level that you have decimated. You might want to clean this out with a blank tile, although this is not vital yet. You might be tempted to save, build and play your new s2built.bin, complete with level art. What you will find is that you fall clean through your nice looking new art. You will need to add collision to your art before you can play on it.

    [​IMG]
    Bummer


    Basic Collision
    Go back to the chunk selector screen by hitting ‘I’ and choose a chunk to solidify. At this point it would be sensible to choose a flat surface such as a piece of floor or the similar. Left click on the chunk to bring it up in the editor on the bottom left of the screen. By double right-clicking on blocks in this chunk window, you can bring them into the block editor in the same way as you did earlier when fixing the palette. With the chunk still selected in the bottom left, you should click the Solid Select text located just under the tile selector and select the final solid which SonED will inform you has the Solid ID of FF and also an angle of FF. For now, simply double right click the blocks on your art which you require to be solid and click the digits on the left of “Solids” in the block menu (the one used to fix the palette line previously. They should both read FF for now.
    [​IMG]
    In the process of assigning Solid FF to both planes of the relevant blocks in the selected Chunk. The red circle is where I am just about to click.


    The first value refers to the solid used for the block in the first path and the second for the solid in the second path. This will be explored in more detail when we tackle loops and more complex scenery, but for now, all that matters is that both paths are solid and flat. As with all the other detail in this block menu, these settings will be consistent regardless of whereabouts the or how many times the block occurs. Finally, once all the solidities have been assigned to the blocks in the chunk (empty space should be left as 00 ideally, although providing you leave them “not solid” in the step we are about to cover, the solid assigned to the block is irrelevant), you should go through the blocks again in the chunk window in the bottom left and assign each block a collision setting, by either double right-clicking the blocks and using the tiny arrows, or hovering over the blocks and using the G+B and H+N keys to change the first and second paths respectively. Again, for this exercise you will want to set both paths to “all solid.” To check you have competed this successfully you can push W to view the solidarity in the first path and E to view the second. At this point, the blocks of the ground on which you intend to stand should be a solid black colour with the angle FF displayed in the middle in both paths. Said chunk should now have functioning collision in-game.

    [​IMG]
    Hitting W or Q should show you how many blocks you have made solid. Other than All Solid, you can select Top Solid, where sonic can jump onto the platform from below, l/r/b solid, which is the exact opposite, and Not Solid, which shouldn't need explaining.

    [​IMG]
    Sonic has a smoke on the top of some hastily drawn, generic metal boxes.

    Slopes and Solidity Graphs
    Ok so, we have seen a piece of art right through to the game, but a level built up of purely square furniture would be dull as hell right? You are likely to want to create slopes for your beautiful new level. Having imported the art in the same way as detailed earlier, rather than assigning the Solid FF to the surface on which you'll be standing (everything underneath, the sides and bottom for example, you should still use FF) you will want to use a sloped solid. You can use the “Show Block” option to display the currently selected solid in the graph in the centre of the screen over the currently selected block, but chances are, they aren't going to line up perfectly, so you are going to have to create your own. Select solidity graph DC, the first blank one in the solid selector, and select a block from your chunk, and use the graph in the centre, building the columns of white to show where your block is solid and therfore where sonic can stand. Once you are satisfied with your graph, you will also want to assign the graph an angle (like everything else, expressed as a hex value). This value dictates how sonic will react when he touches its surface, how or if he will roll down it, or to quote the documentation;

    “A value of 0xFF is used for flat ground, but otherwise, all angles MUST be even values. The range of 360 degrees is represented by values between 0x00 and 0xFF (256 values), with 0xFF being 359 degrees, 0x00 being 0, and 0x40 being 90. Values starting at 0x00 and rising are used starting at the bottom of a circle and moving clockwise (left-side slopes use values between 0x00 and 0x3F from bottom-up, right side are 0xFF to 0xC0 from bottom-up).” I opted to use angle F8 to create a gentle, right hand slope.

    [​IMG]
    The green circle indicates where solidity graph DC is located. In the disassembly I was using to illustrate this guide, there were some existing graphs which I've added at some point or another, so this is no longer blank. Instead the red circle shows where I have placed my example, and you can see the closer image on the graph. Note that I have just used a random block to demonstrate this, rather than draw out slope artwork. The graph itself is not smooth, but done at random simply to illustrate that it is the one I have just done and not one of the multitude of existing solids.

    Having created your new graph and assigned it an angle, you should apply it to the block using the same process as before. Assign the solidity to the block in the block menu next to the palette display (which you would have previously set to FF) and configure the block to be “All solid” in both planes (or whichever setting is relevant to your task.) When you hit W or E to display the collision for each path, you should note that the angle of your new solid is displayed over the block. You will need to repeat the process for each new block that does not match an existing solid.

    Loops and (tentative)Path Swapping
    Having followed this guide you should now be developing an understanding of how SonED 2 works and should be able to tackle most problems by experimenting with what you know already. Unfortunately, as you may have gathered if you have already tried making a loop by extrapolating the information on slopes, loops are slightly more complicated.
    Firstly you will need to ensure that your loop conforms to the solidity graphs already in existence used for making loops, otherwise sonic's path around the loop will not match the artwork and he may run throw some scenery, an undesirable consequence. To this end, when creating my first loop I used a circle template which I based of exported art from other loops. To avoid problems, it is worth ensuring that your loop art is consistent with the template.

    [​IMG]
    This template is 256x256 pixels, comprising of four pretty much identical chunks rotated through 90 degrees at a time.

    Now, I am aware that loops are not always the same perfect circle, and might have differing entry and exit points, but we will use this symetrical circle to guide you through the principle of inserting a loop via SonED2. If you were to try and create your own solidity graphs for this circle you would note that they would strongly resemble solidity graphs 49 through to 52, 4D being the turning point. These should correspond with the bottom right chunk of your loop, and assigning to them to the block is as straightforward as with all the other collision we have covered so far. For simplicity sake, I am going to assume at this point that you are using symetrical art for the loop, (if you are using more diverse art for your loop, you can still follow, you will simply have to insert each of your four chunks of the loop as a bottom right corner piece, and use the relevant piece at the relevant time.

    [​IMG]
    Here you can see the solidity of the first loop quarter. The graphs are highlighted by the green box in the solid select. Note that I am viewing the first solidity path here, and the currently selected block reads ALL SOLID, NOT SOLID. If I were to hit E to view the other path, it would simply display the strip of FF's across the bottom two rows of blocks.

    In order to assign collision information to the other angles of the loops, you are going to need to select the curve, a block at a time, by double right clicking, and then pasting the block into its equivalent place in the next chunk. Initially, I would recommend creating the bottom left hand chunk of the circle. Taking the first block, the one using angle FC, you should select the bottom left hand chunk in the chunk selector, and paste your selected block in its equivelant place. Next you need to manipulate the draw direction using the M+J keys, or the small arrows above the chunk window, until your art is facing the right direction.

    [​IMG]
    Here you can see the transition between pasting the blocks into position on the new chunk, and then altering the draw direction. The key here is that the block is the same and therefore retains the solidity and angles assigned previously, drawn backwards. As mentioned earlier, if the art for your block is different for each corner, you will have to insert them as a bottom right piece and then reverse them around accordingly.

    Having repeated the process to build up a full loop, you should set the paths accordingly so that sonic enters the loop using the first path, and exits on the second path. Once you've done this a few times you can get a little more creative with your loops, but initially you will just want to use W and E to check that your paths are working correctly.

    [​IMG]
    This illustrates a complete loop in both collision path one and collision path two using Q and E. It is also common for the paths to change at the halfway point, its for you to decide. Also note that the planes of tiles become really important here, as Sonic will likely run in front of, or behind the wrong tiles when entering the loop, despite traversing it perfectly.

    Again, you may have jumped the gun, and built this incarnation of your loop to check that it works. Unfortunately you will find that you are able to successfully traverse the first half of the loop, but you will notice that you do not change paths at the mid-point of the circle, and therefore, cannot complete the loop. In order to tell the game that Sonic is supposed to swap paths at a point in the loop you will have to use the object editor window of SonED to place a path swapper. At this point, your guess is as good as mine, as I have so far had limited success with path swappers, as there seems to be a lack of documentation on the subject available. Through trial and error, I have found a combination of path swappers that seems to work, although it has brought inconsistent results. Open the object window by hitting O in SonED2 and double left-click to create an object (double right-click deletes said object.) A further double click on the object will bring up a list of objects from which you want to select “path swapper” which is option number 3. Now hovering over the object, you will see a multitude of information appear in the tope left hand corner of the screen. We are interested in the Object Type ID, which should currently read 03 00 00. ( You should not that other objects placed in the area may well interfere with the path swappers, particularly if the object debris from a previous level is lingering. You should clear away this mess for best results.) Use the S and X keys to modify the second digit to 10, and place this swapper at the top of the loop as shown in the above picture. This swapper appears to change the path from the first to the second (although I can only guess at what else, or under what conditions). You will also need to place a swapper at the exit of the loop, so that Sonic is placed back into the first path an is able to use any subsequent loops. I have been using 03 11 00 for this purpose, although again, this comes with mixed results, primarily, Sonic often fails to run back through the loop, although he is capable of using the entrance to the next one (ie, they work forwards, but not backwards). You will probably want to open other levels in SonED and see how they work to gain a better understanding of path swappers. I am eager for someone to correct me on this issue.
    That brings me to the end of this guide. There are, undoubtedly more things you can do with SonED2, these are just the bare basics. I have tried to be as clear as possible, and hopefully it might help out a few of those who are struggling with level editing, and encourage a few moar to try.

    #EDIT#
    You can download the circle template in .pcx format from here. Sorry about the JPEG, but you can thank photobucket for that.
     
  2. Spanner

    Spanner

    The Tool Member
    Nice work, this would be a great guide for the wiki.
    Unfortunately I'm shit at art, but others'll find this guide useful.
     
  3. snkenjoi

    snkenjoi

    Tech Member
    89
    7
    8
    I should show this shit to my level designer.

    EDIT: wiki'd
     
  4. Jayextee

    Jayextee

    Unpopular Opinions™ Member
    3,253
    60
    28
    Atro City
    I DONE MAKED GAMES.
    Wow, you have saved me the effort of figuring out how to do this for the guide I'm writing, thanks!

    Nice guide, by the way. Probably a lot better than what I could have done.
     
  5. Cinossu

    Cinossu

    Administrator
    2,832
    44
    28
    London, UK
    Sonic the Hedgehog Extended Edition
    Whilst this is a brilliant idea and guide, you might want to make the template drawing a gif or png, and not a jpeg. Artifacts are a pain.
     
  6. Ambil

    Ambil

    I want that heinous hedgehog hammered! Member
    As I explained in the chatroom, you don't have to waste ten minutes of your life banging ctrl+z in order to get rid of the default data in your levels. A fastest way, despite not being the "soned2 wayy" as you said it, is this.

    Code (Text):
    1. <Ambil> 1. go to soned2folder/s2/artnem
    2. <snkenjoi> soned2 wayy
    3. <Ambil> 2. delete the file of your zone
    4. <snkenjoi> soned2 wayy
    5. <Ambil> 3. open soned2, a blank file is autocreated
    The same applies for the 16x16 mappings, the 128x128 mappings, and the level layouts.

    Someone who doesn't want people to hypertrophy their fingers, do post it in the wiki, because I ain't.
     
  7. You forgot to black out C:/Users/ etc on one of your SONED2 Images =P. Lovely guide, I'll be sure to keep this handy =P
     
  8. Shoemanbundy

    Shoemanbundy

    Researcher
    1,094
    30
    28
    Chicago, Illinois
    selling shoes
    THANK YOU for this! This is exactly the kind of guide that has needed to be on the wiki for reference since forever now. Great job, I'll surely be using it sometime soon, hopefully with good results :(
     
  9. This should be divided, Collision, and Importing art :P VERY nice, I'm putting it to use right now
     
  10. Stealth

    Stealth

    Tech Member
    594
    30
    28
    Sonic Mania, HCGE, Sonic Megamix, SonED2, [...]
    :(

    ;)

    Field 0 - Size (Height/Width)
    Field 1 - Orientation (Horizontal/Vertical)
    Field 2 - Right/Down (Path player will switch to when moving Right/Down)
    Field 3 - Left/Up (Path player will switch to when moving Left/Up)
    Field 4 - Right/Down (Draw Priority player will switch to when moving Right/Down)
    Field 5 - Left/Up (Draw Priority player will switch to when moving Left/Up)
    Field 6 - Condition (When player passes swapper, change paths always/only when not in freespace)
    :v:

    :thumbsup:
     
  11. Funny how no one reads the documentation eh stealth? =P
     
  12. jman2050

    jman2050

    Teh Sonik Haker Tech Member
    634
    4
    18
    Why read the manual when you can make (un)educated guesses on your own!