Click here to Skip to main content
15,896,428 members
Articles / Game Development

Using Quaternions Efficiently in Real-time Applications

Rate me:
Please Sign up or sign in to vote.
4.95/5 (11 votes)
10 Nov 2010CPOL11 min read 29.4K   63   29  
Various methods for using quaternions in ways that maximize performance
#ifndef _NODE_H
#define _NODE_H

#include "NodeBase.h"

//Node class template////////////////////////////////////////////////////////
// This class uses the Decorator design pattern to add Node functionality
// to any Object type.  Node functionality means the containment
// of a vector of Objects and the methods needed to add new Objects
// to the vector, and to iterate through all of them to update their transforms.
// This makes it possible to create a tree of Nodes each representing an Object.
// Leaves in the tree can be simple Objects instead of Nodes.  This is made 
// possible with a function template, addChild where the actual type of the new
// child can be specified as a template parameter.
template< class OBJECT >
class Node : public OBJECT, public NodeBase
{
public:
    void updateWorldTransform( ObjectBase *parent )
    {
        OBJECT::updateWorldTransform( parent );

        updateAllObjects( this );
    }
};


#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Gameloft
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions