Jump to content

  • Log In with Google      Sign In   
  • Create Account

Norman Barrows

Member Since 04 Apr 2012
Offline Last Active Dec 18 2014 09:44 AM

#5188813 Animate in place?

Posted by Norman Barrows on 23 October 2014 - 02:19 PM

I've been mulling this over today. To have non-feet sliding animations (which is the only option for me) you have to have motion accumulation of some type.


is this due to your blending? 


i've found that i'm able to sync animation walk/run speeds to character movement rates pretty well (better than madden 15 when they turn in place), as long as those speeds are known constant values. the major limitation is the resolution of the time for a frame (sometimes 4 frames between keyframes is a bit too fast and five is a bit too slow, that kind of idea) now that i've added all sorts of things that affect movement rate such as fatigue, damage, slope in the direction of travel, etc, i'm thinking of moving to a procedurally generated animation that takes movement rate as input. there was another thread a while back that discussed continuous variable speed stand/walk/run animations.


The problem is, if your turning animation starts at -1.1 degrees and ends up at 85 (so 86.1 total rotation), what do you set the rotation of the player to at the end? 85? If so, the next frame (frame zero after a loop) will immediately appear 1.1 degrees lower, 85-1.1 so that's what I'm currently trying to get my head around


that sounds like a simple case of needing "resting postions" between animations. in this case, its a resting direction though. it would seem to me that all turn animations should start with a player heading of zero.


Edit: thinking about this further, I think I have to set the player's yaw value to the last frame's less the first frame's.


i believe that would be the same idea.


It's simple maths of course but it always helps to write it out (especially when you're on a packed train daydreaming about animations!)


one often gains better understanding of a subject by explaining it to others. sometimes you just need someone to bounce ideas off of.

#5188785 Is optimization for performance bad or is optimizating too early bad?

Posted by Norman Barrows on 23 October 2014 - 12:24 PM

i use the following approach:


one of the first things i put in a new game is a fps meter so i can track overall basic performance as features are added. 


when adding a feature, i consider 3 things:

1. existing algos - whats fast and whats not. 

2. brute force - often fast AND simple

3. what code (syntax) is fast and what code isn't


then i select the simplest to implement algo that seems fast enough and implement it.


if the implementation performs as expected, i move on to the next feature.


if there's an unacceptable performance hit, then i profile and optimize.


this keeps things more or less optimized as i go along.


occasionally small performance hits from many new features can start to add up and slow things down. then i profile and optimize.


since i select algos and syntax with speed in mind upfront, and sort of optimize as i go along, i find i have little or no optimization required at the end.


i've had to change development languages twice (basic to pascal to c/c++) and compilers three times (basic to pascal to watcom, to MS) all in the quest for speed. so i've learned to code with speed in mind from the get go.


note that this doesn't mean i engage in premature optimization. i will only select a more complex yet faster algo if i know from experience or research that a simpler slower algo won't cut it. so i favor stuff like AABB vs more complex intersect tests etc. but i DO make an effort to not use slower code when faster code is is just as easy. so i'll tend to favor static arrays over things like template based linked lists etc. mostly this is in the form of using older syntaxes that have less built-in error checking. stuff like #define vs enum. not exactly recommended for the inexperienced progammer or for group projects. i can get away with it because that was all there was to work with when i started in game development, so i'm well aware of the "gotcha's" you have to look out for.

#5188545 [4X / TBS] Space Game - No ship Customization?

Posted by Norman Barrows on 22 October 2014 - 10:35 AM

I'm also at a crossroads where I feel that adding ship customization might add a bit of fun / strategy, but would add a significant level of complexity (micro-management) and this smells to me like a poor design decision.


just make ship customization optional. they can build a pre-defined ship type or define a new type to build, then build it. that way you please all your users.


But what I've uncovered after a while is that, the better you get at this game, the fewer actual "choices" you realize you have. For example, there may be 10 options for a given slot, but you'll grow into using a maximum of 2-3, with very narrow roles.


the game design has a "dominant strategy" that makes only 2 or 3 of the 10 options worthwhile. dominant strategy! bad designer! no twinkie! <g>.


"Would it be viable for a 4X game to have no ship customization whatsoever?"


certainly. take rome total war II for example:


its a "conquer the map" game, just like a 4x.

you build units and structures, just like a 4x.

you have resources, just like a 4x.

no custom units, but a wide variety of pre-defined unit types, and many unit types which are unique to a given faction or group of factions.


all you have to do is provide "requisite variety" in the pre-defined ship types included.


and no dominant strategies! <g>  IE: no dominant pre-defined ship types.

#5188539 Scenes with large and small elements

Posted by Norman Barrows on 22 October 2014 - 10:14 AM

typically, when a scene is bigger than a float can hold accurately, objects are defined in "world coordinates" which are then converted to camera-relative floating point coordinates for drawing.  objects which are still too big/far to fit in a float get scaled down in both range and size until they fit in a float. drawing would probably be done in two passes, first a pass to draw all objects too big/far to fit in a float, then a pass to draw all closer objects. near and far planes can be reset as you go, to keep zbuffer resolution high.


this recent thread touches on these issues:



#5188518 Design question: Managing multiple methods

Posted by Norman Barrows on 22 October 2014 - 07:34 AM

"don't over-engineer things until you actually know what you need".




#5188514 smoke & transparency

Posted by Norman Barrows on 22 October 2014 - 07:28 AM

thank's , you mean the ZBufferWriteEnable must set to False




also looks like you're using mip maps with a white background, and some of the background is getting blended into your lower level mip maps - producing the white halo edge around the smoke. to fix this you need to - been  while - lets see, the image needs to be away from edges to prevent edge artifacts - clamp helps too. but you don't have those. so odds are its your sampling method when creating mip maps. can't recall offhand which method is preferred. been about 2 years since i got mine working correctly. if you still have questions re: filtering, start another topic.

#5188326 The basic structure of game programming

Posted by Norman Barrows on 21 October 2014 - 09:58 AM

this is the basic form for realtime games:


initialize stuff

while (! quitgame)


    draw the screen

    get input

    move everything


shutdown stuff


turn based is more like:


initialize stuff

while (! quitgame)


    while (! end turn)


        draw the screen

        get input


    move everything  // perhaps drawing the screen as you go, to show each unit's movement


shutdown stuff


there are almost as many variations of these as there are games. but almost all game "loops" evolve from these (or similar) basic forms.






#5185372 Z Fighting issue with armor pieces

Posted by Norman Barrows on 06 October 2014 - 02:27 PM

at the end of the day you have two choices: move the z fighting surfaces farther away from each other, or move the near and far planes closer to each other to increase zbuf resolution. note that the overhead for resetting near and far planes is low. i actually set them to three or four different settings to render a single frame with no z fighting.

#5185347 Precision on StateMachines

Posted by Norman Barrows on 06 October 2014 - 12:59 PM

What do you think ?


i think you're tracking two states (moving and attacking) with one state variable.


as frob says, you can enumerate the combos as a single state variable, or use individual state variables, as described by sean:


If you have completely independent hiarchical states then you still end up needing a full animation state system that can transition to the proper animation based on both controller state inputs.


in a recent refactoring of AI code in my own project, i got good results switching from a single state variable to multiple state variables. and as sean says, you need an animation system that can draw whats required, whether that data is stored in a single state variable ,or multiple state variables,  in my case, the possible combos of taking fire, recovering from collision, resting due to fatigue, following orders, hunting, grazing, sneaking, moving, attacking, etc made multiple state variables the only real way to deal with things



#5185338 Lines of code language comparisons

Posted by Norman Barrows on 06 October 2014 - 12:36 PM

what I really wanna know is if anyone has ever made some estimates across a long list of coding languages and how efficient each of them are on the human level.


any software engineer who wants to be productive will always consider write-ability when choosing a language. but other considerations such as run-time performance tend to be more important in games.


i use a macro processor / code generator to increase productivity. for me - typing is the #1 bottleneck in core dumps of largely ready to rock code from my brain to the computer. my brain thinks in code at warp speed, but my fingers are sub-light only. 


the macro processor i use is designed to reduce keystrokes required to enter c++ code.

#5184766 Are 2D side-scrollers too common?

Posted by Norman Barrows on 03 October 2014 - 08:06 AM

You worry too much. Design a game that you would like to play.


and hasn't been done yet.

#5184681 how to represent this number

Posted by Norman Barrows on 02 October 2014 - 07:12 PM

if you know the low bit is set, that eliminates half of them.

if you know the second from lowest bit is also set, that eliminates half of those remaining.

the problem is you have an infinite number, so half or 1/4 of them is still an infinite number.

only when you have a finite number (say 1000) does calculating odds make sense.

if you have 1000, and you pick one, your chances of picking the right one are 1 in 1000.

if you know the low bit is set, you now only have 500 to choose from and the odds drop to 1 in 500.

if you know the two low bits are set, you now have 250 to choose from and the odds are 1 in 250.

#5184672 speeding up terrain collision checks

Posted by Norman Barrows on 02 October 2014 - 06:26 PM

looks like i need to speed up terrain collision checks in Caveman 3.0.


game description:



right now, it checks the world map to get the terrain type(s) present, then checks for collisions for the terrain type(s).



i'm testing with a savegame. the terrain is non-tropical savanna with rocks and a creek.


movement collision checks test each entity vs a sparse matrix list of rocks, a sparse matrix list of trees, and a list of world objects (big stuff like shelters, lean-to's, bedding, fires, etc).  each rock in turn is tested vs the creek and skipped if its in the creek, same with trees. trees are also tested vs world objects (no trees in huts!). needless to say, iterating through all these lists is SLOOOOW! <g>


so i'm thinking of using collision maps. due to the size of the game world, they would have to be generated on the fly as needed the way terrain chunks are. so collision maps would be generated on the fly as needed, and stored in a cache, with LRU discard.


the resolution defined for the map will determine the resolution of collision detection possible. in the game i use a scale of 1 d3d unit = 1 foot.  so i figure i can get away with a collision map with a scale of 1 unit = 1 foot.  


so then i choose a size for collision maps, say 300x300, the size i use for terrain chunks. when i need a map, i go through the world map data and add the rocks, trees, shelters, etc to the collision map. a zero indicates clear, a non zero value indicates some type of object, and the value tells you what kind or which object. testing for collisions is simply a matter of checking the collision map for non zero values in the squares of interest.


new collision maps would only need to be generated when entities and or the player moved far away (about 300 feet). caching of 20 or so maps would keep the number of regens to a minimum.


but how to handle edge cases when an object is at the edge of one map but its radius extends into the next map? just have to code for it?


all this seems a bit complex, but it seems to be the best solution. any alternatives come to mind?   


a quick search of the literature online came down to basically subdivision or grids, and grids seemed faster.


timing tests have isolated terrain collision checks as the primary bottleneck in the new AI. the goal is to have 100+ entities active in a small area all mulling about. I'm currently using large herds of 40 or so hippidions (proto-horses) for the testing.


terrain collision checks right now are on the order of 2000+ ticks per moving entity.   pretty much all the rest clocks in in the single or double digits for ticks.


any suggestions or advise would be appreciated.  i figured out collision maps a while ago (except for edge cases with multiple tiled maps), but have never used them before in a game (at least that i recall - been doing this a long time...).


a quick check of the code reveals that in the test case above, a single entity is currently checked for collisions with 260 trees and 1300 rocks in an 800x800 sparse matrix "plant map".

#5182254 Lining up animations with motion

Posted by Norman Barrows on 22 September 2014 - 04:36 PM

Oh, and as for motion, many art tools support something I've always heard of as 'motion accumulation'.  
If the motion accumulation flag is clear then characters remain at their root location, occupy the original footprint, and play their animation in place. If the motion accumulation flag is set the motion will be applied to the character's location at the end of the animation clip.
If the character is moving the game does not continuously update the root location, it only updates it at the end of the clip. The character may have been at (32,7), and at the end of the clip on the final frame they are instantly transported to (33,7). it is the code's responsibility to ensure the footprint area is clear so the animation clip can run between locations.


i always wondered how they did that...


isn't that harder?

#5181707 Web App Development?

Posted by Norman Barrows on 20 September 2014 - 09:08 AM

why would you use an executable you have to download when you can do the same operation on a website?


because bandwidth costs money?


because networked apps are inherently slower than non-networked apps running on the local machine?


because you don't want to have to connect every time you want to run the app?


there are only two commodities in life: time, and money. using a web app can cost you more in both.


That being said, the "suite of tools" or "technology stack" required will depend on the nature of the app.  more detail is required.  there's a big difference between writing say an MMORPG and a perl shopping cart script for a secure order form.  Other folks on the forum here are working on the former, and i've done the latter.  So you are correct in guessing that there may be some guidance available from the forum members here on gamedev.