|
Posted on 06.15.07 by Mike K @ 10:45 pm
Last post talked about the random thoughts I’ve had about how to pull off the rope dynamics in Umihara Kawase, this classic SNES game that drives us all mad. I made some bold suggestions, and decided to try them. After a couple hours of work, while not as complete as I want, it’s far enough along to be able to demonstrate to me if I have a right idea or not. Rather than let this fun experiment disappear in to obscurity through e-mail or forums, and since I never have enough blog content, I’ll post it here and try to explain more broadly what’s going on in my test. Though really, this is just Raigan and I talking back and forth.
ESC - Exit The point of this application is to simulate a stiff wrapping Umihara Kawase rope, not a nice bouncy spring built one. Actually at this point, it doesn’t attempt to wrap around scenery. The rope is capable of it, but I’m just manually hard coding a list of points in between the end points. I’m assuming there’s will be a system that looks at the collision, notes the edges I cross, and correctly pushes them on to the front or back of an STL deque. So … uh … for now, pretend they’re pulleys, or fitting through some really fine cracks. What you’re seeing on screen is 4 separate rope simulations. I’ve noted on the image in a 2×2 grid what is what. “Magnitude” means I use Magnitude (length = sqrt(x*x+y*y)) for all my length calculations, and “Manhattan” means I use Manhattan (length = abs(x)+abs(y)) for them. The “Free” row means both points move freely, and “locked” means one doesn’t. If you’re just tuning in, Manhattan is correct when axis aligned (i.e. [10,0], [0,-4], etc), but increasingly more wrong (too long) as it approaches a 45 degree angle. It doesn’t break, it’s just different, very diamond shaped instead of circular. Think of it as a worst case square root approximation for vectors that still works. To solve the rope, I need a few things. The sum of the length all rope segments, which is one place where I’m using a Magnitude/Manhattan, one for every segment. I take the difference between my set length and my calculated length to see how “broken” it is, much like a spring. I then pull or contract my end points to fix it. It’s a cheap verlet solver, so all I need to do is move the point and it will work out beautifully in a few frames. So I take the vector from end to point for each side, divide it by the length of that segment (My other Magnitude/Manhattan use, one per side), which gives me a normalized vector I can use to apply part of the rope length difference. And I subtract this from each side. So yeah, unfortunately, I did have to use two divides, one for each side. If your target never moves, you *could* get away with 1 divide (but what’s the fun in that?). But yeah this is a quick demonstration to see how each method works. Each test case is given the exact same data. So, my thoughts (UmiRope_Riggid.exe). Because the error in the Manhattan versus Magnitude, the rope is shorter. The rope being shorter to me isn’t that big of a deal, and this is why I initially didn’t see Manhattan being a problem. It’s a really cheap way to calculate an approximate total length of the rope, if it has many segments. However, Manhattan has it’s real notable flaw in calculating the new positions of the ends. In my opinion, it’s not terrible, it’s just not very natural looking. A cheaper than a “real” square root approximation would still be ideal here. Is this Umi-like though? Not quite yet. The Umihara Kawase rope is somehow very elastic, erratic, bouncy, where this is very rigid. Alright, more bouncy then. I included a variant that’s more bouncy, by using a 20% of the solve amount (UmiRope_Bouncy.exe). While reacting differently, I don’t think it’s an improvement. After it calms itself down, it looks more or less the same an the rigid example. Hmm… I am going to have to take a look at the game again. It might be possible to introduce another error that makes the Manhattan look more sproingy. But generally speaking, this approach to solving the rope is cheap. The only bottlenecks being a division per end, two multiplications per end to scale the vector in the normalization step, and two more to scale the normalized vector up by each side’s part of the difference, and everything else can boil down to adds, subtracts, and shifts. And if division is a problem, it can be replaced by indexing in to a table of reciprocals (1/1, 1/2, 1/3, 1/4, …), and multiplying by this reciprocal in the place of the division. So 5 multiplications plus a bunch of adds/subtracts/shifts, per side. At least, to solve the rope. Everything else I think is just some good “hopefully simple” logic to figure out what points to add to your list (deque). I’ll toy with that later. - - - Source is included. The notable functions are, all in main.cpp: cParticle::Step() - which is how we move each end of the rope. The multiply there is a friction hack, removing it makes coming to rest take more time. cManhattanRope::CalcRopeLength() and cManhattanRope::StepRope() are the variants needed to use Manhattan instead of Magnitude (i.e. Normalize). You can see the divide here, which is normally hidden in the normalize function. Steps are called in main, lower in the file. Filed under: Stuffing and Technobabble and The Spider Comments: 1 Comment |
|
Posted on 06.14.07 by Mike K @ 11:22 pm
Raigan and I have had an extremely brief dialog on in game ropes. It makes sense, for a while we were both doing rope driven games. Well, due to my failings as a communicator, I sort of just never got back to him. Yet, I absolutely love the topic, and certainly spent much time puzzled by it. Apparently I’ve also made the conscious effort to push my way in to obscurity. My apologies, everybody who’s mailed me. We virtually “ran in to each other” again a few weeks back, in a discussion on 2D game water physics, and so the need to share my thought looms over me again. Now that he’s in blog town, I knew I had no choice, and went ahead with zee said “scooping of theories” out of zee brain, and defaced his blog with it. I hope you don’t mind. The question. How the heck do you pull of physics like that on the SNES!?! As I saw, the discussion is less of a question of how to do a rope, but how do you make a rope work so beautifully on such *nothing* gaming hardware? The following is the slightly edited “shotgun blast to the face” I dumped in his comments. Learn more about the game here. - - - Here we go. My thoughts on how they pulled that off on the SNES, AKA 2-3 MHZ tiled beast. To put things in more perspective, a CPU with 8bit registers, and no internal multiplication or division. However, I think I read somewhere that there was either a hardware multiplier or divider, essentially some hardware address you plug some numbers in to, and several cycles later you can read back a result. This compared to the GBA with it’s 32bit registers, and it’s “so very nice” multiplication opcode. No big deal, it’s only 1 rope. First off, I think the biggest thing they had to their advantage was the tile graphics hardware. All Nintendo hardware except the N64, GameCube, and Wii have tile map 2D graphics hardware. Memory for 8×8 tile graphics, and memory for a map to build from those tiles. So really, you’re either making a tiled game, or your not making a game on those systems. So that means, as far as testing against collision, you’re only testing against easy aligned tiles (surfaces with normals (1,0), (0,1), and the negatives). Our rope, technically only needs to be concerned with things in units of tiles. A 64 pixel tall wall is merely 8 tiles, and only 8 “unit tests” as we interpolate across the line. Also, a locked framerate. So long as we don’t travel more than 8 pixels in 1 frame, we should be able to stay completely stable. Lets also say each tile only finds nearest edges on it’s exposed sides (i.e. no tile adjacent to me, then it’s an exposed side). And an optimization for rope segments, every 2 bends we can put the previous part to sleep. We just need enough memory set aside to support a dozen or so bends. The final big thing is something I ran in to durring my adventures deeper in to physics and maths. Something in math nerd speak called the Manhattan Length or Distance (I forget it’s proper name, I just call it the Manhattan). The Manhattan is a length formula for a line, in much the same way as magnitude (or magnitude squared, how I love thee). The formula is the sum of all the absolute value parts of a vector. I.e. Manhattan = abs(x) + abs(y). No doubt you’ve played with this yourself, and scoffed it off because it’s not an accurate length. That is, except in one key case… When it’s axis aligned! No square root required! (1,0) or (0,1) respectfully, the Manhattan or length is 1, and so would the magnitude. Why is this important? Tile hardware is axis aligned! So as long as we wrap around axis aligned things, our rope segments are accurate. Even if not, so what? Worst case, our rope shrinks a bit going over a slope. You’ve probably noticed how extra bouncy/elastic the rope in Umihara is. My best guess, is it’s because they live with the horrible innacuracies of the Manhattan Length. And truth be told, asuming that’s what it is, it still looks great. Eventually you’ll pendulum your self to a stop whilst hanging vertically. So there you go, Mike’s “how they did Umihara Kawase“. - - - Disclaimer: This is all theory. I’m too lazy to disassemble the ROM. It’s enough for me so that I can sleep at night. Filed under: Stuffing and Technobabble and Opinion and The Spider Comments: 2 Comments |
|
Posted on 03.09.07 by Mike K @ 4:51 am
The innovative games arms race is on. http://gamevideos.com/video/id/9860 … Alright, I give up. Normally when I see a really fantastic game like this, I’m all excited (Spore). This one drove me in to a brief game design depression. Now that’s emergent gameplay at it’s finest, and I’ve not even played the game. Concepts like collaborative editing and modern user friendly editing. Two ideas I’ve been extremely excited about toying with. “Oh, we do them both”. Bastards. Sticking to objects. Cool. I toyed with something like that, and I called it The Spider. “Oh, but we can stick to things that move”. Oh yeah… holy sh$% that’s cool! …pause… Aww crap. And it looks great, with depth of field effects and everything. Damn. The innovative games arms race is on, and in full force. Filed under: Stuffing and Opinion and The Spider Comments: None |
|
Posted on 03.31.06 by Mike K @ 11:40 pm
With mere minutes left before the end of the month (and April fools), I guess now is as good of a time as ever to do an update… At least before someone thinks I’m joking. Content was put aside earlier in the month, as we finish and fix more important things. Besides, having working tools before we start building anything would make more sense. Speaking of tools… The Object and Map Editors are functional and working great. We’ve been refining them this past week, as we’ve built experimental content. I imagine some time next week we’ll start toying with an actual game scene/level. Object editor, with all it’s collision placement, polygon building, and linking goodness. ![]() Map editor, with all it’s placement goodness. ![]() Very cool. And of course, all this fun stuff works in game too. Something that’s not as obvious about the tools is we can build stalky objects like blades of grass, trees, or sign posts, which can bend nicely around objects as you crash in to them. ![]() We’re still a ways off, but it’s finally starting to shape up. With luck, by the end of April it’ll look like a game. Have a safe April fools. ![]() Filed under: The Spider Comments: 1 Comment |
|
Posted on 02.26.06 by Mike K @ 12:55 am
Low fat disposable hats present, part 7: A Sunset in StoneWhich is probably quite warm, despite the cold imagery of anything in stone…… Why are you looking at me like that?Okay, I wanted an epic name to finish my cheesy little series of updates. Then it’s actual updates when they happen!!! Wow! That actually makes this a blog, instead of story time! But I like story time …So back to the technical. Don’t worry, I’ll put a stupid image at the end to better transition artfulness to technicallityfullness. Way back, I mentioned the engine used the monkey of a library AllegroGL, as a wrapper to hardware, and OpenGL. Well, some time in December, we decided we couldn’t stand the instability of AllegroGL. Yes, AllegroGL, the not so updated piece of honk honk is unstable. I’m actually impressed the game worked at all. I had to disable deletion and destruction of any GL or related objects so the game wouldn’t crash on exit, and trust XP to handle all the recovery of memory. It was that bad. So eventually, on and off busy with some other obligation, the code was ported and made a tad more generic as we moved to SDL/OpenGL. Hurah. And an exciting story that was. And wow, that’s it? We’re all caught up!! Okay, well, I guess we’ve been building some tools as well. These past few weeks, Richard has been working on the object editor. Collision/Spring placement is all there now, and he’s started working on our little interface for associating display polygons with these fancy collision thingies we can make. ![]() Sophisticated looking isn’t it? So, soon we’ll be playing with and building game content. Then there’s me. As mentioned last time, I’m working on art stuffs at the moment. I gave myself a crash course in Blender, and I seem to have that reasonably well figured out. Though, I wish the scaling via the normals feature was a tad less destructive. Anyways, prior to that, I’ve been toying with game mechanics, and fixing stuff to make the editing interface work. One item from the mechanic playing was switching to a segmented rope, instead of just the big spring between point A and point B. ![]() Visually it’s nice, as it’s all bendy, curvy and swingy. But what you can’t see in this image, is that compared to the old rope, this one’s functionality is crap. So, it appears Umihara Kawase got it right, with the stiff rope that bends only when it crosses collision. Unfortunately that means a bunch more work, making the rope a really special case in the engine’s design. There’s also this *other* gameplay element I’ve been toying with, with some encouraging success. But I’m going to be an ass, and sit on it for now. I’ll try not to tease it like it’s some super clever gameplay element or something. It’s more of an “oh! hey cool!” type mechanic, than a “Holy shoe!” type mechanic. That’s right, shoe. And there it is. You’re caught up. I’m experimenting with art stuffs now, so expect something on that front to pop up. I can’t vouch for exact days or frequency of updates. Every couple weeks though, there should be something. Or just RSS me, and know. RSS, it’s an ESP for us non psychics. And, your wacky image. ![]() Have a good week. Filed under: Scribbles and PuffBOMB and The Spider Comments: 3 Comments |
| « newer posts | previous posts » |















