2009-03-24

More nonsense

So, working on more things, lots of things. 'Sys' is the new IGTL system namespace, which provides all the utilities that you could need for memory, data structures, file/directory IO, mathematics, 3D mathematics, algorithms, and all the basic stuf every system should have. Basically, it's a new version of cstdlib, that uses C++ stuff (like STL, but not junky) for some systems. Specially, it has a lot of very common math and algorithms in a very clean and not junky C-style system, so you don't have to freak out over overhead.

It's coming along awesome, and I love it. It makes so much more sense now, getting the base code out of the way. Although, it does prove that the C++ crap is near useless, which by extenstion makes most all languages that are not python a$$. And all other languages are useless for realtime stuff.

So, I also learned how to do 'Hemispherical Lighting', which is a simple little trick in your good ole shader math:

float dp = light_vector dot normal ;
float schemi = hemi_scale * pow( hemi_power, 0.5 * dp + 0.5 ); //Light factor to use

And, again in GL_fragment_shader_arb lingo,

DP3 temp2.x, nNorm, -mvp[2]; #Dot view normal (curr view) with vertex normal to get generic light intensity

#---Hemispherical lighting--- Req: K.y = 0.5, LK.z = light_pow, LK.w = light_scale
MAD temp2.y, temp2.x, LP.x, LP.y; #t = t*0.5 + 0.5 (hemispherical lighting = cool)

#---Scale the light to be the hemisphere
POW temp2.y, LP.z, temp2.y; #t = pow(t, hard), flip this to halo (A^B)
MUL temp2.y, temp2.y, LP.w; #t *= spec

#---Calculate final hemi diffuse color
MUL temp1, temp2.y, fragment.color; #Interpolate color to black (mult op)

And, some examples, but I don;t have comparison shots because Blender uses hemi lights, you can easily see the difference.

Hey, it's delgadosaur again, and it looks less plastic, more daylight plastic.

And a new member of the crew, this purple-dragon thing that's more friendly and low poly. But that's what textures and sub-surface models are for, right?


Anyways. Peace out.

-Z

2009-03-23

Dream; Goodbye tasty humans

Not sure how the whole mess got started, but I do distinctly remember driving in the car with dad, mom, and sis. I think we were driving somewhere in Kansas, but the landscape was hilly, but that was because of some sort of natural disaster. Spanning a light gray sky, swirling with slow moving clouds, you could see occasional lighting flashes and sections of hazy dust and rain. It seemed grayish blue, there were no trees, only a soft diffuse light coming from what we assumed is the sun, the landscape looked like it had been melted by intense blasts of heat, clawed out by something much larger than a earth mover. Of course, some parts were still intact, it seemed that random damage had occurred, but there were no plants. Just yellow straw grass here and there.
So we drive into this thing that looks like a tow, I guess we were escaping the carnage, and stopped to look around. This place looked the same, all of the buildings looked like they had been sandblasted, and were somewhat moved, indicating a large shockwave had come from a specific direction at some point. There were some skeletons scattered about, but nothing too severe. After poking around the town, looking for any survivors, I decided that we had to go to the university. For some reason, we had to go to KU, being that it would be least affected by whatever crazy thing happened here. I went solo, as there were lots of supplies unused in that town, and drove a broken highway to KC. there were lots of cars along the way, damaged, tossed, something like the cloverfield movie, lots of evidence, no picture of the thing itself. Eventually I made it near one of the larger buildings, which was guarded by many heavily armed folks.
Apparently, John was a well known professor there, so I was able to get in, and waited in a holding/detox room so I could figure out what happened. I scribbled nonsense on the whiteboard, and this creepy old teacher came by and was all 'I like vectors too' and made some stupid math joke, I scowled at her and tried to explain my problem, but she cut me off so I tuned her out. That happens a lot at work too. Then john came by, and we began talking about what the hell was going on, apparently, no one remembers what happened, just kind of waking up after the fact. All infrastructure had been damages, radio signals are destroyed, no working ionosphere thanks to the dust (must be aliens, this is something that the Reconi do to sentient planets...) so no way to communicate.
Course, this is where things got acid-y. I was sitting down, and John started to talk to that math lady, I guess I was tired and nodded off, but only half asleep, and the world became a cartoon, and that lady morphed into this weird demon chick with a flowing cloth behind her, and john morphed into this goofy pink&lavender dragon monster, and after laughing at both of them, I watched this little cartoon short where the dragon danced around, trying to impress the demon lady, who matched the dance skill or something, then they both ran to a starting line and had a footrace, which was weird...
I snapped awake at the mention of my name, but there was some word there that woke me up in real life, it was only 2:30 or something, which sucked, it was being Oklahoma outside, so I went back to sleep, or tried to.

I'm not sure what kind of disaster would entirely kill the planet like this, but I imagine it wasn't traditional weaponry. It really looked like some giant monster had gone around and scooped up whatever piece of the earth buffet it wanted, and just cauterized the rest. If I were to guess, probably some sort of sleeping gas was used first, and then harvester's were dropped to clean up. That way they could avoid any 'moral' obligations by claiming death was painless to all those killed. Perfectly valid, actually. Not a bad idea at all. Sounds like my next doomsday project, make everyone fall asleep, release natural predators. Done.

In more detail, I suspect this was a three stage attack. First was the normal detonations of sleeping gas, then metallic dust as chaff for communications and missile guidance and all other earthly forms of retaliation, and finally some EMP bombs for good measure. Then, drop the harvesters down, scoop up all the goodies, pack up, and leave the planet to fix itself. Sounds like something we could use today, honestly.

And, sorry John, I dunno why you got such a weird representation, but at least it didn't have a purse.

Oh yeah, I remember distinctly talking about going back to school, and really wanting too. Must be some sorta premonition.

2009-03-15

Masao Parody

Masao Parody Test 1/2

Masao Parody Test 2/2

Well, that Masao guy is awesome, so I tried making a parody of his style of videos. This is kind of a test of doing a parody, more or less improvised.

Enjoy!

-Z

2009-03-05

Quick Post

Alright.

Quadtrees using proxy indicies are too slow (because if you don;t define them carefully, AKA if you don;t enforce data always being in the leaves, well, it goes to hell. Draw it out to see what happens.)

Quadtrees using leaved index lists seem to do OK, however, their performance is not that good. It certainly costs a lot of memory and speed to handle space, and they are conformal space limiting.

Thus, we are required to develop a better, more efficient structure. In this case, I choose a interval list. However, you immediately scream "O(n)!" and to that, I say "Balanced Binary Tree"

Of course, you mutter about "2 log2(n)" but you;d be right for deletions. Additions are worst case log2(n).

Actually, if you think about it, given a random set of any data, the absolute fastest way to sort and store that list IS clamped at a maximum of log2(n). You might think that hashtables can beat it, but come on peoples, hashtables are application specific optimization. Sure, if you know your inputs are bounded you can hashup your memory and get a hashlist of B-Trees, but is that step actually going to save much? And besides, looks like you still HAVE TO MAKE THE GODDAMN TREE!

In summary, this is the current problem. If you think you are smart, solve this problem. When you find out you're an idiot, don't complain to me:

Given a random set of intervals (minimum (float32) and size (float32), create a data structure that can store these intervals sorted by the minimum value, and be able to quickly determine interval queries, AKA stabbing queries. The structure should have as minimum a memory footprint as possible, and you can assume you have Alloc, Realloc, Free working properly. Also, the structure cannot use hidden operations internally (No OOP or C++ tricksies internally), however externally it may operate as a class interface. It must support insert( proxy ), remove( proxy ), and get( float min, float size. ProxyList & ). A proxy contains at least unsigned int user, which contains the user data for what the proxy is in user memory. It cannot leak memory. It must work in practice and be implemented.

Practical application? Pretend you are building a 2D game that uses edges for level collisions, which can be added and removed every frame, on the fly. (in the editor) Once the user is happy with their setup, obviously we use a static BVH for static data.

Good Luck!

-Z

2009-02-20

Hey look, a quadtree


So what's so special? This is a common data structure that everyone one of you should be able to do from memory. It's extremely simple, and uses recursion. Simply make a tree with each node linking to 4 child nodes that evenly divide space, and let each node store a list of pointers or the data itself.

The special part, is this is a generic quadtree, so, instead of 'storing' objects, it stores XData::Quadtree::Proxy object POINTERS to a XData::List, which means that Proxy lifecycle is left to the user (working on making it pointeriffic and more auto-delete) but that also means that every node stores a list of those proxy pointers, so that your game object:

class MyGameObject : public Game::BaseObject {
private:
XData::Quadtree::Proxy m_proxy;
}

Can simply access the quadtree as such:

qtree.insert( obj.m_proxy );
qtree.remove( obj.m_proxy );
m_proxy.IsValid();
qtree.get( XData::Array &, fptr_to_Collision_Function, collision_function_data );

So what this means, is in the above picture you can draw arbitrary edges for a odin-sphere style level, which get their proxies put into the quadtree. This is dangerous only if you forget to remove the proxy before deleting the object. But it means that you can query arbitrary shapes against the quadtree and get a quick enough broadphase test for intersection. Insertion is always better than O(log(n)), deletion/update is best case O(1), worst case O(log(n) + 1). Access is linked list, so fast iteration is possible.

Quadtree's are good for dynamic data, that is if everything is changing quickly. There are other methods for static data that are far superior, like KDTrees or Spaceblocks or even AxisSweeps, but quadtrees are a general good purpose solution that's still good in performance to be viable for many applications. In fact, you probably won't need much more than this, unless you have severe restrictions that force you to use sorted space blocks.

If you are making a 2D game, please do not use tiles. I will hate you, and you should be competent enough to make a quadtree (think Game Maker) that can handle arbitrary shapes and so forth.

Go look at this game to see one of these methods in action

-Z

2009-02-12

SSE Optimizations

So I got "My First SSE Optimized Quaternion Rotation Function" today...Note that I have to use GCC asm, which is a bitch compared to other forms, however, it has huge advantages, so just deal with it you pansys.

The point is, the way VMath works is by:

extern void (*SomeFunc)( Vec4 & ); //In the VMath.h, declare this pointer to be extern so it is not duplicated every time you include igtl_vmath.h

And then, in the VMath.cpp:

void (*SomeFunc)( Vec4 & ); //Function pointer for routine declared ONLY in cpp

And then, we call Initialize(), which reads your cpuid and sets function pointers to appropriate locations, so that if you have SSE, it can use it on runtime, and if not, it won't. Unfortunately, the calling overhead is the same.

Also, your project settings need the -mmmx and -msse flags to tell GCC to use SSE.

This is problem 3/4, I need to reduce the call syntax overhead, but I do not believe this is possible without using some strange compiler __attribute__ or __fastcall for you MS folks. This will be an experiment to run.

Actually, I do not know of a better mechanism to use; If I need to detect processor type on runtime and switch functions, then I do not see any better way than using a function pointer. Although, this should be fast enough; SSE optimizations do not become apparent in small frame sense. In fact, you will see little gain for most functions, where they shine is parallelism. For example, if all your Game::Object's have a quaternion, then you probably 'update' each one of them independantly, which requires moving a lot of pointers and so on. Instead, if you make a batch_updater() function, then you can pass a pointer to your array of game objects, and store the values used commonly for all those transformations in registers, and thereby signifigantly speed up your application by removing redundant load calls and such...

More on this as it progresses; The nice part, is since VMath already works, I don't have to f*** with the SSE part until later, because it was DESIGNED RIGHT! That means I can hand that coding task to any other programmer and let them optomize it to hell while I continue building more components into the framework. Hence my title as Developer.

Peace ya'll!

-Z

2009-02-10

Thumbs Up!

Okay, I got it. Matrix Palette exporter works fine now.


Next up is adding in textures in MIF/QIF format (already done, copy paste job), and then deciding the structure for spread-optimized armature/matrix palette, and then keyframes using vertex duplicate's.

Of course, now that THIS works, it'll be time to shove it onto the iPhone. Imagine that, "Monster Game" for the iPhone! Course it'll be stripped down, but hey, sounds fun.

Peace ya'll!

-Z

2009-02-07

Well, goddamnit, GODDAMNIT! Again, again!

Well, still can't get it right. The materials have been fixed, apparently, but only for some models. Others still have trouble??? (Saurosaur model has some trouble when it's subsurfaced, but I believe this is related to the matrix problem at hand)

At least this picture is a little less boring


Also, I have a feeling some people don't know what spinal curves are. Actually, if you have studied animation, you might understand these as "Action Lines" or "Line of Action" or whatever name you want to give them. In fact, if you build your skeleton correctly, you can draw these spinal curves, and it shows you the model's action pose, from which it is WAY easier to tweak that action line than it is to screw with posing bones. I hope that Blender integrates this posing system into it's bones, it would only require an additional flag and some simple bone-blending editing tricks. It's very helpful for bringing things to life. What good is this realtime though? It's helpful if you don't have shaders on your PC, so you can at least see the game sort of. It's also helpful for special effects, and some other 'interesting' deformations... he he.



I still need help with the exporter. It's not to my QC standards yet.

-Z