Jump to content

Easy way to set the center of BAM animations? What method do you use?


Recommended Posts

As I am working, and struggling, with setting the center point of some new BAMs I am creating, the thought occurred to me to ask here on the forum if others have any better methods.  For those who aren't aware - the "center" is the point of reference the game engine animates a BAM from, and it's not necessarily the actual center of the image.  For example:  If you have a BAM that spins around a character, you would want the "center" to be the actual center of the image, but for an arrow, you'd want it at the tip or the end.

As far as I can tell, BAM workshop 1 doesn't have a tool for changing the center of frames in a BAM.

BAM workshop 2 has a nice tool that allows setting the center with a click of the mouse, but I am running into a *major* problem in using it.  Most of the time, after I save the file, several frames are lost - by this I mean the frame is blanked out with only the transparency layer remaining.

Near Infinty's BAM editor allows changing the center, but has to be plotted with "x" and "y" coordinates, which is accurate, but cumbersome.  Complicating this, it doesn't appear that you can use it with the image zoomed in for pixel-perfect accuracy.

 

I would be grateful for any tips on this.

Link to comment

You have listed the obvious choices.  If you use the updated version of BAMWorkshop, you can set the frame offsets, but you have to enter them (as a positive or negative number) for each frame individually.

Other than the programs you listed, your other choice is PS BAM.  It can automatically calculate the proper frame offsets for a variety of BAM types by setting a --BAMProfile.  Alternatively, if you need to set particular offsets, you can increment, decrement, or set X and Y offsets for all frames by/to particular values.  See --ModXOffset, --ModYOffset, --SetXOffset, --SetYOffset.  The down side is there is no graphical interface, so you have to know what offsets you want before you start.  The up side is that PS BAM can build BAMs (even very complex BAMs like creature animations) automatically for you from frames, set the frame offsets, and compress the BAM.  All automatically and in batch.  If you're interested in trying it, describe what you want to do and I'll provide example code for doing it.

Link to comment
37 minutes ago, Daeros_Trollkiller said:

Sam, thank you so much for your reply.  I wasn't aware of either of the two tools you mention.  I can provide some examples:  A rolling boulder,  a jet of flame, character  animation. 

Take your pick.

Link to comment
6 hours ago, Daeros_Trollkiller said:

Sorry for the long delay in response, lets go with the boulder.

You'll need to send me the files (either upload them to a post or send me a PM), let me know what type of BAM it should be (e.g. spell animation), and then tell me how you want the frames centered.

Link to comment

Can PS BAM set center coordinates in percentages? If it only sets them at, say, 50 and 50, that's only good for pictures with known dimensions. But if it can do 50% and 50%, that's very useful. I use Near Infinity for BAMs, and one useful feature is that the center coordinates can be moved by the same amount for a selection of frames. Select them and type ++5 or --5 in X or Y, then click away into the other box to update. On the whole, to find the center point you divide each dimension by 2, rounding up for odd numbers. A 51 x 50 picture's center is 26.25. This doesn't take into account the content of the picture, where the visual itself is, but if it is off the geometric center, it's easy enough to move all of the frames there with the ++/-- method. But ultimately it's testing in the game itself that determines where the picture will look the most effective. Finding the center is simpler when all of the frames are of the same size. If you are working over an animated GIF for your effect, don't import it directly but split the file with some gif-processing tool. I go to ezgif.com for this. Then import the frames, which keeps them all even and prevents artifacts and color problems.

When the frames are not equal to begin with, e.g. in some explosions and flashes that start out small and mushroom, you have to enter approximate X-Y values and then move the cross by hand pixel by pixel in every frame until the cross no longer shifts at all when you move up and down the frame list. The center cross is also visible on the BAM filters tab, where you can zoom, if you like, with the Resize filter (which also helps with Replace colors). Increasing size seems to be accurate, but downsizing an image doesn't always put the cross in the correct position. If a picture was 13 pixels wide and you narrowed it by 50%, every pixel begins to mean an enormous increment, and then it's really work for the sharp eye whether the center should be at 6 or 7. Sometimes this is just unmanageable, and you have to accept a picture that's a little jittery on the Review page.

Edited by temnix
Link to comment
3 hours ago, temnix said:

Can PS BAM set center coordinates in percentages? If it only sets them at, say, 50 and 50, that's only good for pictures with known dimensions. But if it can do 50% and 50%, that's very useful. I use Near Infinity for BAMs, and one useful feature is that the center coordinates can be moved by the same amount for a selection of frames. Select them and type ++5 or --5 in X or Y, then click away into the other box to update. On the whole, to find the center point you divide each dimension by 2, rounding up for odd numbers. A 51 x 50 picture's center is 26.25. This doesn't take into account the content of the picture, where the visual itself is, but if it is off the geometric center, it's easy enough to move all of the frames there with the ++/-- method. But ultimately it's testing in the game itself that determines where the picture will look the most effective. Finding the center is simpler when all of the frames are of the same size. If you are working over an animated GIF for your effect, don't import it directly but split the file with some gif-processing tool. I go to ezgif.com for this. Then import the frames, which keeps them all even and prevents artifacts and color problems.

When the frames are not equal to begin with, e.g. in some explosions and flashes that start out small and mushroom, you have to enter approximate X-Y values and then move the cross by hand pixel by pixel in every frame until the cross no longer shifts at all when you move up and down the frame list. The center cross is also visible on the BAM filters tab, where you can zoom, if you like, with the Resize filter (which also helps with Replace colors). Increasing size seems to be accurate, but downsizing an image doesn't always put the cross in the correct position. If a picture was 13 pixels wide and you narrowed it by 50%, every pixel begins to mean an enormous increment, and then it's really work for the sharp eye whether the center should be at 6 or 7. Sometimes this is just unmanageable, and you have to accept a picture that's a little jittery on the Review page.

As to what PS BAM can do, yes and no.  You can SET all frame offsets to a specific value using "--SetXOffset" and "--SetYOffset y".  You can also modify frame offsets by a +/- amount using "--ModXOffset" and "--ModYOffset".  There is currently no mechanism for scaling X and Y offsets (by a percentage or factor), but I could add this without much effort if there was a need [I would add "--ScaleXOffset" and "--ScaleYOffset" that would let you specify a factor like 0.6667 or 1.5.].  However, there are other mechanisms for calculating the appropriate frame offsets for specific types of BAMs.  You can set a specific BAM profile (type) using "--BAMProfile", and PS BAM will calculate the appropriate offsets for you.  Currently recognized values are:

Quote

| ItemIcon | DescriptionIcon | Zero | Paperdoll | SpellIconEE | GroundIcon | DescriptionIconEE | ItemIconPST | GroundIconPST | SpellIcon | Spell |

GroundIcon, DescriptionIconEE, and ItemIconPST all set all frame offsets to half the width and half the height (centering the frame).  If your BAM has rows/columns of transparent pixels around the border, you can use the "--TrimFrameData" to remove these before (or after) setting/calculating the appropriate offsets, depending on what you want to do.  As to frame dimensions being off by a pixel in either direction after resizing them, the problem is with rounding errors.  The solution is to "--Unify" frames (add rows/columns of transparent pixels) so that all frames are the same dimensions BEFORE resizing them.  This ensure all rounding errors are in the same direction.  You can then "--TrimFrameData" afterwards to remove any remaining extra rows/columns of transparent pixels.  Both PS BAM and BAM Resizer can do this, but I haven't studied just how well PS BAM handles transparency after resizing in detail.

Link to comment
On 4/14/2021 at 7:07 PM, Sam. said:

You'll need to send me the files (either upload them to a post or send me a PM), let me know what type of BAM it should be (e.g. spell animation), and then tell me how you want the frames centered.

Ok, I can certainly do that.  Any particular format you need them in?  PNG?  Or should I go ahead and create the BAM with all the needed sequences and send it to you that way?

Link to comment
56 minutes ago, Daeros_Trollkiller said:

Ok, I can certainly do that.  Any particular format you need them in?  PNG?  Or should I go ahead and create the BAM with all the needed sequences and send it to you that way?

PNGs are fine as long as you have already made the background color pure green and the shadow color (if applicable) pure black.

Edit:  Or not and I can show you how I would correct those colors using ImageMagick.

Edited by Sam.
Link to comment

Not all BAMs' frames are of equal size. The shifting of the center is inevitable, the frames just have to be examined and adjusted. This is mostly a problem with shrinking creature animations. There are so many frames, and so different, that a shrunken creature ends up jittery when facing a few of the directions or playing a few of the sequences. This is the reason spells like Reduce (the reverse of Enlarge) can't be made to work well: the extra animations, 5% smaller, 10% smaller and so on, will be just too lousy for my standards.

Link to comment
19 minutes ago, temnix said:

Not all BAMs' frames are of equal size. The shifting of the center is inevitable, the frames just have to be examined and adjusted. This is mostly a problem with shrinking creature animations. There are so many frames, and so different, that a shrunken creature ends up jittery when facing a few of the directions or playing a few of the sequences. This is the reason spells like Reduce (the reverse of Enlarge) can't be made to work well: the extra animations, 5% smaller, 10% smaller and so on, will be just too lousy for my standards.

Again I repeat:

Quote

The solution is to "--Unify" frames (add rows/columns of transparent pixels) so that all frames are the same dimensions BEFORE resizing them.

 

Link to comment
On 4/19/2021 at 12:05 PM, Sam. said:

PNGs are fine as long as you have already made the background color pure green and the shadow color (if applicable) pure black.

Edit:  Or not and I can show you how I would correct those colors using ImageMagick.

Sam, I went ahead and made all the frames for my animation into BAM to make things easier for you.  This animation is for a spell in which the character fires the boulder outward in a straight line.  It's 5 sequences I had planned to mirror east (reduced).  Ideally the center would be on the trailing edge of each frame, so that the boulder animation doesn't overlap the caster's avatar.

My attempts to do this result in the animation appeared to bounce around a bit instead of rolling smoothly.

boulder.bam

Link to comment
7 hours ago, Daeros_Trollkiller said:

Sam, I went ahead and made all the frames for my animation into BAM to make things easier for you.  This animation is for a spell in which the character fires the boulder outward in a straight line.  It's 5 sequences I had planned to mirror east (reduced).  Ideally the center would be on the trailing edge of each frame, so that the boulder animation doesn't overlap the caster's avatar.

My attempts to do this result in the animation appeared to bounce around a bit instead of rolling smoothly.

boulder.bam 922.08 kB · 1 download

Well, in the BAM you provided, Sequence 1 thru Sequence 3 seem to be centered about different points than are Sequence 0 and Sequence 4.  That aside, you can adjust the offsets with PS BAM by creating a windows batch file (a plain text file with the .BAT file extension) in the folder where your BAMs are located and using code like this:

SET prefix=*

"D:\Program Files\GitHub Projects\PS-BAM\PS BAM_x64.exe" ^
--DebugLevelL 1 ^
--DebugLevelP 2 ^
--DebugLevelS 1 ^
--Save "BAM" ^
--ExportPalette "" ^
--ExportFrames "" ^
--ExportFramesAsSequences 0 ^
--OrderOfOperations "PCE" ^
--SingleGIF 0 ^
--ReplacePalette "" ^
--ReplacePaletteMethod "Quant" ^
--CompressionProfile "" ^
--FixPaletteColorErrors 1 ^
--AutodetectPalettedBAM 1 ^
--AutodetectPalettedThreshold 500 ^
--DropDuplicatePaletteEntries 1 ^
--DropUnusedPaletteEntries 1 ^
--SearchTransColor 1 ^
--ForceTransColor 1 ^
--ForceShadowColor 0 ^
--AlphaCutoff 20 ^
--AllowShortPalette 1 ^
--TrimFrameData 1 ^
--ExtraTrimBuffer 0 ^
--ExtraTrimDepth 0 ^
--ReduceFrameRowLT 1 ^
--ReduceFrameColumnLT 1 ^
--ReduceFramePixelLT 1 ^
--DropDuplicateFrameData 1 ^
--DropUnusedFrameData 1 ^
--IntelligentRLE 1 ^
--MaxRLERun 255 ^
--FindBestRLEIndex 0 ^
--DropDuplicateFrameEntries 1 ^
--DropUnusedFrameEntries 1 ^
--AdvancedFLTCompression 1 ^
--FLTSanityCutoff 5040 ^
--DropEmptyCycleEntries 0 ^
--AdvancedZlibCompress 2 ^
--zopfliIterations 50 ^
--BAMProfile "" ^
--Unify 0 ^
--Fill "" ^
--Montage "" ^
--ModXOffset 100 ^
--ModYOffset 68 ^
--SetXOffset "" ^
--SetYOffset "" ^
--ItemIcon2EE 0 ^
--Flip 0 ^
--Flop 0 ^
--Rotate 0 ^
--LogFile "%~dp0Log.txt" ^
--OutPath "%~dp0compressed" ^
"%~dp0%prefix%.bam"

Pause
Exit

Change the path to PS BAM to wherever your local copy is.  You can direct it at different/specific BAMs by changing the "*" in "SET prefix=*" (the * here is the windows wildcard) to whatever filename.  E.g. "SET prefix=boulder" would process only "boulder.bam".  The other thing to note is that "%~dp0" is a special batch command to insert the current working directory (including the trailing "\").  I've used it here for simplicity.  The actual frame offsets are modified by

--ModXOffset 100 ^
--ModYOffset 68 ^

Change those numbers as you need.  Those were my guesses and I think they're relatively close to what you'd want.  Everything else is just setting up basic (albeit very good) compression.  If you need to disable compression, remove the "C" from "PCE" in --OrderOfOperations.

boulder.bam

Link to comment
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...