Main Page   Class Hierarchy   Compound List   File List   Compound Members  

KrImageTree Class Reference

The ImageTree contains all the Image Nodes. More...

#include <imagetree.h>

List of all members.

Public Types

enum  { ALWAYS_INSIDE_BOX = 0x01, GET_ALL_HITS = 0x04 }

Public Methods

KrImNodeRoot ()
 Return the very base node of the tree. It is a KrImNode and never a more derived type.

void AddNode (KrImNode *parent, KrImNode *addMe)
 Add a ImNode to the tree. More...

bool DeleteNode (KrImNode *removeMe)
 Call this to delete a node and remove it from the tree. More...

KrImNodeFindNodeById (int id)
 Find a ImNode by its id.

KrImNodeFindNodeByName (const std::string &name)
 Find a ImNode by its name.

void HitTest (int x, int y, int flags, GlDynArray< KrImage *> *outputArray, int *windowIndex)
 Given a point -- in screen coordinates -- determine what ImageNodes are under that point. More...

bool CheckSiblingCollision (KrImNode *checkThis, GlDynArray< KrImage *> *outputArray, int window=0)
 Given a node, check if it collides with any of its own siblings. More...

bool CheckChildCollision (KrImNode *checkThis, KrImNode *parent, GlDynArray< KrImage *> *outputArray, int window=0)
 Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent. More...

bool CheckAllCollision (KrImNode *checkThis, GlDynArray< KrImage *> *outputArray, int window=0)
 Given a node, check if it collides with anything in the Tree. More...

void Walk ()
 Flushes the cached state of the tree and makes it ready to draw.


Detailed Description

The ImageTree contains all the Image Nodes.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
ALWAYS_INSIDE_BOX  Hit the inside of a box, even if the box is not filled.
GET_ALL_HITS  Get every object hit, not just the first.


Member Function Documentation

void KrImageTree::AddNode KrImNode   parent,
KrImNode   addMe
 

Add a ImNode to the tree.

The parent can be specified; if not, the root will be used. The node added -- 'addMe' -- is handed over by ownership. It will be deleted when the tree is deleted or DeleteNode is called.

Node children cannot directly be added. There is no KrImNode::AddChild function for instance; everything must be added through the tree.

bool KrImageTree::CheckAllCollision KrImNode   checkThis,
GlDynArray< KrImage *> *    outputArray,
int    window = 0
 

Given a node, check if it collides with anything in the Tree.

Returns true if any collisions occur, and returns an array of everything collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::CheckChildCollision KrImNode   checkThis,
KrImNode   parent,
GlDynArray< KrImage *> *    outputArray,
int    window = 0
 

Given a node "checkThis" and a parent, check if "checkThis" collides with any of the children of the parent.

There does not need to be any relationship between "checkThis" and "parent".

Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::CheckSiblingCollision KrImNode   checkThis,
GlDynArray< KrImage *> *    outputArray,
int    window = 0
 

Given a node, check if it collides with any of its own siblings.

Returns true if any collisions occur, and returns an array (outputArray) of all the KrImages collided with.

See KrImage::CheckCollision for a discussion of collision issues.

bool KrImageTree::DeleteNode KrImNode   removeMe
 

Call this to delete a node and remove it from the tree.

@WARNING: DeleteNode( this ) can cause a crash. It's a temptingly useful thing, but in the case where parent objects hold on to pointers, those pointers go dangling. It's best to avoid DeleteNode( this ) usage.

void KrImageTree::HitTest int    x,
int    y,
int    flags,
GlDynArray< KrImage *> *    outputArray,
int *    windowIndex
 

Given a point -- in screen coordinates -- determine what ImageNodes are under that point.

Note that only images have bounds and are drawn, so only images can be hit.

HitTest, by defualt, stops at the first non-transparent pixel it hits. There are flags to modify this behavior:

  • ALWAYS_INSIDE_BOX hits inside boxes that aren't filled
  • GET_ALL_HITS, not just the first


The documentation for this class was generated from the following file:
Generated on Mon Sep 15 12:01:11 2003 for Kyra by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001