Showing posts with label screenshots. Show all posts
Showing posts with label screenshots. Show all posts

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

2008-12-22

iPhone continues next year

Well, here are some screenshots from nonsense I'm testing.

These screenshots in no way reflect on any performance limits, SDK artifacts or in fact, ANY technical details about the iPhone whatsoever. In fact, I implemented ALL of these in SDL with C++ before putting them on the iPhone.

Point is, pictures that prove I can load models and scenes into my phone:


This was from 'YoBro', a blender game I played with. You can see that some of the nodes are missing, because I haven't put in correct parenting in my node tree, so it drops em. That kinda looks like a taurus, right?

Hey look, it's me in the iPhone!
Adventure clone without textures is lame. But, it's nice to see that the iPhone can handle 1000's of nodes.This is a poly-reduction of 'Delgadosaurus', a free poser model out there if you go looking; forgot the guy's name who made it, but cred to him! (will get ref eventually)

This is a bomberfan level, at a better angle.

This is one of the spaceships from GSS6, the cool part is it has the interior modeled, so you can actually fly/walk around the decks, crew quarters and sit at the bridge.
This is the classic 'dancing lizards' scene from an odd angle, I probably should have found the shotgun and taken a picture of that. But you can see nodes!


This is the classic 'Saurosaur' in 3D from one of my older games noone ever saw, and for good reason! It's a fully articulated model, but that's for later, right? Point is, it looks alright, and was quick to draw, which is interesting!

and OMG, bomberfan is stuck in the floor because I didn;t have the time to add in the node-parenting system like in FrameGL2! Dammit. Point is, his level works great.

So, textures to add; better node system, and then I'll be just about the the point I want to be at in terms of graphical powers.

Here's the kicker; These files are loaded from a website, so anyone can load any file they want! Extensible iPhone games! How rawk is that?!?!!?

...apple will probably shit a brick, good thing I can defend it:
1. All loaded data (external data) must fit a size maximum constraint (1MB)
2. All loaded data (external data) MUST be interpreted, and cannot be directly copied (IE instead of float memcpy, you have to: x = *(float*)data; along with brutally slow size checks
Files may be only ASCII in the future to enforce safe non-hacking conventions (you can;'t break it if there's nothign to break!)

Ah well.

c'yall later!