<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cale Dunlap</title>
	<atom:link href="http://www.caledunlap.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.caledunlap.com</link>
	<description>printf(&#34;Hello World\n&#34;);</description>
	<lastBuildDate>Tue, 10 Apr 2012 18:26:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Some Handy Visual C++ Pre-Processor Macros</title>
		<link>http://www.caledunlap.com/2011/10/some-handy-visual-c-pre-processor-macros/</link>
		<comments>http://www.caledunlap.com/2011/10/some-handy-visual-c-pre-processor-macros/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 22:56:46 +0000</pubDate>
		<dc:creator>Cale</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[macros]]></category>
		<category><![CDATA[preprocessor]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.caledunlap.com/?p=975</guid>
		<description><![CDATA[Over the last few years, I’ve been writing a lot of C++ that I’ve targeted for multiple platforms and/or multiple compilers. It has always been somewhat of a delicate  task to make C++ code portable,...]]></description>
			<content:encoded><![CDATA[<p>Over the last few years, I’ve been writing a lot of C++ that I’ve targeted for multiple platforms and/or multiple compilers. It has always been somewhat of a delicate  task to make C++ code portable, especially when starting with Visual Studio and targeting other platforms like Linux using GCC. Along with multi-target compilations, C++ pre-processor macros can be a useful tool in reducing the amount of mundane, rather simple, and rudimentary code that many C++ programmers find themselves writing. Here’s a few macros that I’ve used to ease my own development pain, I hope someone else can find them as handy as I have.<span id="more-975"></span></p>
<p>Please, by all means if I am incorrect somewhere please correct me. Also, if you wish to add to this list, feel free to do so.</p>
<h2 class="h-underline">Cross-Compilation Helpers</h2>
<p>First up, one of the more common tasks, especially when writing libraries versus executable programs, is exporting symbols. The process to export symbols is different for the various compilers. The following should take care of GCC and MSVC:</p>
<p>[cpp]<br />
#if defined(_MSC_VER)<br />
#  define LIB_EXPORT __declspec(dllexport)<br />
#  define LIB_IMPORT __declspec(dllimport)<br />
#elif defined(__GNUC__)<br />
#  define LIB_EXPORT /* */<br />
#  define LIB_IMPORT extern<br />
#endif<br />
#<br />
#if defined(__cplusplus)<br />
#  define EXTERN_C extern &#8220;C&#8221;<br />
#else<br />
#  define EXTERN_C /* */<br />
#endif<br />
[/cpp]</p>
<p class="note-box">Use the EXTERN_C macro when name-mangling on exported functions must be avoided.</p>
<p>There are many ways to tackle symbol exports. In fact if I&#8217;m not mistaken, GCC now has synonyms for __declspec(dllexport/dllimport) so there may not even be a need to use the pre-processor to first establish which compiler is in use for the import/export macros mentioned above. It all depends on which version of GCC you&#8217;re using.</p>
<h2 class="h-underline">Calling Convention Helpers</h2>
<p>Most, if not all compilers assume a calling convention when a function is not decorated with one. When problems arise with mis-matched calling conventions (almost always with exported functions) then use the following macros to specify a calling convention rather than leaving it up to the compiler.</p>
<p>[cpp]<br />
#if defined(_MSC_VER)<br />
#  define STDCALL __stdcall<br />
#  define CDECL __cdecl<br />
#  define FASTCALL __fastcall<br />
#elif defined(__GNUC__)<br />
#  define STDCALL  __attribute__((stdcall))<br />
#  define CDECL /* */<br />
#  define FASTCALL __attribute__((fastcall))<br />
#endif<br />
[/cpp]</p>
<h2 class="h-underline">Function Inlining</h2>
<p>Compilers will often attempt to make functions inline where it makes sense to do so (depending on compiler flags, etc.). If you wish to force the compiler to make a function inline, use the following macro:</p>
<p>[cpp]<br />
#if defined(_MSC_VER)<br />
#  define FORCEINLINE __forceinline<br />
#elif defined(__GNUC__)<br />
#  define FORCEINLINE inline<br />
#endif<br />
[/cpp]</p>
<h2 class="h-underline">Struct Member Alignment</h2>
<p>Another possible area of compatibility mismatch is with member alignment. To force the compiler to use a specific member alignment byte-boundary, use the following macro:</p>
<p>[cpp]<br />
#if defined(_MSC_VER)<br />
#  define DECL_ALIGN(x) __declspec(align(x))<br />
#elif defined(__GNUC__)<br />
#  define DECL_ALIGN(x) __attribute((aligned(x)))<br />
#endif<br />
[/cpp]</p>
<h2 class="h-underline"> Utility Macros </h2>
<p>I&#8217;ll end this post with some utility macros that I find to be pretty helpful&#8230;</p>
<p><strong>Inline-Square</strong></p>
<p>[cpp]<br />
#if !defined(sqr)<br />
#  define sqr(x) ((x)*(x))<br />
#endif<br />
[/cpp]</p>
<p><strong>Min/Max</strong></p>
<p>[cpp]<br />
#if defined(min)<br />
#  undef min<br />
#  define min(a, b)	(((a)<(b))?(a):(b))<br />
#endif<br />
#if defined(max)<br />
#  undef max<br />
#  define max(a,b)	(((a)>(b))?(a):(b))<br />
#endif<br />
[/cpp]</p>
<p><strong>Class Declarations (my personal favorite)</strong></p>
<p>[cpp]<br />
#define DECLARE_CLASS_NOBASE(className) typedef className ThisClass<br />
#define DECLARE_CLASS(className, baseClass) typedef baseClass BaseClass;\<br />
DECLARE_CLASS_NOBASE(className)<br />
[/cpp]</p>
<p class="note-box">You can get rather creative with the above macro. I use it for a redumentary form of reflection or for logging purposes by converting the class name to a string that can be evaluated at run-time.</p>
<p>Example:<br />
[cpp]<br />
#define DECLARE_CLASS_NOBASE(className) typedef className ThisClass;\<br />
virtual const char * ThisClassName() const { return #className; }<br />
#define DECLARE_CLASS(className, baseClass) typedef baseClass BaseClass;\<br />
virtual const char * BaseClassName() const { return #baseClass; }\<br />
DECLARE_CLASS_NOBASE(className)<br />
[/cpp]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caledunlap.com/2011/10/some-handy-visual-c-pre-processor-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<!--CodeProjectFeeder item--><category>CodeProject</category>	</item>
		<item>
		<title>Yeah my download links are all busted&#8230;</title>
		<link>http://www.caledunlap.com/2011/03/yeah-download-links-busted/</link>
		<comments>http://www.caledunlap.com/2011/03/yeah-download-links-busted/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 05:47:06 +0000</pubDate>
		<dc:creator>Cale</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.caledunlap.com/?p=771</guid>
		<description><![CDATA[Alright, after installing an SEO plugin for my WordPress site, I discovered that quite a few people have been trying to download files that no longer exist. Apparently an old plugin that acted as my...]]></description>
			<content:encoded><![CDATA[<p>Alright, after installing an SEO plugin for my WordPress site, I discovered that quite a few people have been trying to download files that no longer exist. Apparently an old plugin that acted as my downloads manager left some links laying around in several pages. I&#8217;m getting quite a few 404&#8242;s reported, so I thought I&#8217;d just take a moment to tell everybody that I&#8217;m working on that <img src='http://www.caledunlap.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;ll have new download links available soon (probably tonight). So try checking again, please.</p>
<p>Sorry for any inconvenience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caledunlap.com/2011/03/yeah-download-links-busted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<!--CodeProjectFeeder item--><category>CodeProject</category>	</item>
		<item>
		<title>VS2008 Solution Compile Error C2471 Hotfix</title>
		<link>http://www.caledunlap.com/2011/01/vs2008-solution-compile-error-c2471-hotfix/</link>
		<comments>http://www.caledunlap.com/2011/01/vs2008-solution-compile-error-c2471-hotfix/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 23:49:35 +0000</pubDate>
		<dc:creator>Cale</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Development Journal]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[hotfix]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://www.caledunlap.com/?p=662</guid>
		<description><![CDATA[Incase anybody else out there is encountering the annoying Visual Studio 2008 bug where compiling a solution results in Error C2471 (can&#8217;t update debug database)&#8230; here&#8217;s the fix: http://code.msdn.microsoft.com/KB946040 For the longest time I chalked...]]></description>
			<content:encoded><![CDATA[<p>Incase anybody else out there is encountering the annoying Visual Studio 2008 bug where compiling a solution results in Error C2471 (can&#8217;t update debug database)&#8230; here&#8217;s the fix: <a href="http://code.msdn.microsoft.com/KB946040" target="_blank">http://code.msdn.microsoft.com/KB946040</a></p>
<p>For the longest time I chalked it up to my anti-virus software obtaining a lock on the file and not letting go of it. As it turns out, its a bug in VS2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caledunlap.com/2011/01/vs2008-solution-compile-error-c2471-hotfix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<!--CodeProjectFeeder item--><category>CodeProject</category>	</item>
		<item>
		<title>Factory Pattern in C++</title>
		<link>http://www.caledunlap.com/2010/10/factory-pattern-in-c/</link>
		<comments>http://www.caledunlap.com/2010/10/factory-pattern-in-c/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 06:50:29 +0000</pubDate>
		<dc:creator>Cale</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[cplusplus]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[singleton]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.caledunlap.com/?p=615</guid>
		<description><![CDATA[Up until now I never really used the factory pattern that often in C++. Recently I found a use for it in a project I was working on and since I found it useful for...]]></description>
			<content:encoded><![CDATA[<p>Up until now I never really used the factory pattern that often in C++. Recently I found a use for it in a project I was working on and since I found it useful for my purposes, I thought I might share a tutorial on how the factory pattern can be used in C++.</p>
<p>Now I&#8217;m not entirely sure how closely my model fits to the typical factory pattern but as far as I understand factory pattern, it is pretty close if not exact.</p>
<p>Basically a factory consists of an interface class which is common to all of the implementation classes that the factory will create. Then you have the factory class which is usually a singleton class that spawns instances of these implementation classes.</p>
<p><span id="more-615"></span></p>
<p>So lets create a quick interface class to start with. In this example I used IAnimal:</p>
<p>[cpp]<br />
class IAnimal<br />
{<br />
public:<br />
virtual int GetNumberOfLegs() const = 0;<br />
virtual void Speak() = 0;<br />
virtual void Free() = 0;<br />
};<br />
[/cpp]</p>
<p>Now for simplicity&#8217;s sake I used a typedef to define a type for the function that is used by the implementation classes to create instances of IAnimal. This typedef is also used in declaring the map that maps the animal name to the function that creates that particular type of animal. You can use whatever calling convention you like, but for this example I chose __stdcall.</p>
<p>[cpp]typedef IAnimal* (__stdcall *CreateAnimalFn)(void);[/cpp]</p>
<p>Now comes the factory class. This is a singleton pattern implementation so that only one instance of the factory can ever be instantiated, no more, no less.</p>
<p>[cpp]<br />
// Factory for creating instances of IAnimal<br />
class AnimalFactory<br />
{<br />
private:<br />
AnimalFactory();<br />
AnimalFactory(const AnimalFactory &amp;) { }<br />
AnimalFactory &amp;operator=(const AnimalFactory &amp;) { return *this; }</p>
<p>typedef map FactoryMap;<br />
FactoryMap m_FactoryMap;<br />
public:<br />
~AnimalFactory() { m_FactoryMap.clear(); }</p>
<p>static AnimalFactory *Get()<br />
{<br />
static AnimalFactory instance;<br />
return &amp;instance;<br />
}</p>
<p>void Register(const string &amp;animalName, CreateAnimalFn pfnCreate);<br />
IAnimal *CreateAnimal(const string &amp;animalName);<br />
};<br />
[/cpp]</p>
<p>Now comes the implementation classes. These are the classes that implement the IAnimal interface. Here&#8217;s a few examples:<br />
[cpp]<br />
// IAnimal implementations<br />
class Cat : public IAnimal<br />
{<br />
public:<br />
int GetNumberOfLegs() const { return 4; }<br />
void Speak() { cout &lt;&lt; &#8220;Meow&#8221; &lt;&lt; endl; }<br />
void Free() { delete this; }</p>
<p>static IAnimal * __stdcall Create() { return new Cat(); }<br />
};</p>
<p>class Dog : public IAnimal<br />
{<br />
public:<br />
int GetNumberOfLegs() const { return 4; }<br />
void Speak() { cout &lt;&lt; &#8220;Woof&#8221; &lt;&lt; endl; }<br />
void Free() { delete this; }</p>
<p>static IAnimal * __stdcall Create() { return new Dog(); }<br />
};</p>
<p>class Spider : public IAnimal // Yeah it isn&#8217;t really an animal&#8230;<br />
{<br />
public:<br />
int GetNumberOfLegs() const { return 8; }<br />
void Speak() { }<br />
void Free() { delete this; }</p>
<p>static IAnimal * __stdcall Create() { return new Spider(); }<br />
};</p>
<p>class Horse : public IAnimal<br />
{<br />
public:<br />
int GetNumberOfLegs() const { return 4; }<br />
void Speak() { cout &lt;&lt; &#8220;A horse is a horse, of course, of course.&#8221; &lt;&lt; endl; }<br />
void Free() { delete this; }</p>
<p>static IAnimal * __stdcall Create() { return new Horse(); }<br />
};<br />
[/cpp]</p>
<p>Now we need to work out a few definitions of the AnimalFactory class. Specifically the constructor, the Register, and the CreateAnimal functions. The constructor is where you might consider registering your factory functions. Though this doesn&#8217;t have to be done here, I&#8217;ve done it here for the purposes of this example. You could for instance register your factory types with the factory class from somewhere else in code.<br />
[cpp]<br />
/* Animal factory constructor.<br />
Private, called by the singleton accessor on first call.<br />
Register the types of animals here.<br />
*/<br />
AnimalFactory::AnimalFactory()<br />
{<br />
Register(&#8220;Horse&#8221;, &amp;Horse::Create);<br />
Register(&#8220;Cat&#8221;, &amp;Cat::Create);<br />
Register(&#8220;Dog&#8221;, &amp;Dog::Create);<br />
Register(&#8220;Spider&#8221;, &amp;Spider::Create);<br />
}<br />
[/cpp]</p>
<p>Now lets implement the Register function. This function is pretty straight forward since I used a std::map to hold the mapping between my string (the animal type) and the create function.<br />
[cpp]<br />
void AnimalFactory::Register(const string &amp;animalName, CreateAnimalFn pfnCreate)<br />
{<br />
m_FactoryMap[animalName] = pfnCreate;<br />
}<br />
[/cpp]</p>
<p>And last but not least, the CreateAnimal function. This function accepts a string parameter which co-responds to the string registered in the AnimalFactory&#8217;s constructor. When this function receives &#8220;Horse&#8221; for example, it will return an instance of the Horse class, which implements the IAnimal interface.<br />
[cpp]<br />
IAnimal *AnimalFactory::CreateAnimal(const string &amp;animalName)<br />
{<br />
FactoryMap::iterator it = m_FactoryMap.find(animalName);<br />
if( it != m_FactoryMap.end() )<br />
return it-&gt;second();<br />
return NULL;<br />
}<br />
[/cpp]</p>
<p>Here&#8217;s an example of how to use the above code:<br />
[cpp]<br />
int main( int argc, char **argv )<br />
{<br />
IAnimal *pAnimal = NULL;<br />
string animalName;</p>
<p>while( pAnimal == NULL )<br />
{<br />
cout &lt;&lt; &#8220;Type the name of an animal or &#8216;q&#8217; to quit: &#8220;;<br />
cin &gt;&gt; animalName;</p>
<p>if( animalName == &#8220;q&#8221; )<br />
break;</p>
<p>IAnimal *pAnimal = AnimalFactory::Get()-&gt;CreateAnimal(animalName);<br />
if( pAnimal )<br />
{<br />
cout &lt;&lt; &#8220;Your animal has &#8221; &lt;&lt; pAnimal-&gt;GetNumberOfLegs() &lt;&lt; &#8221; legs.&#8221; &lt;&lt; endl;<br />
cout &lt;&lt; &#8220;Your animal says: &#8220;;<br />
pAnimal-&gt;Speak();<br />
}<br />
else<br />
{<br />
cout &lt;&lt; &#8220;That animal doesn&#8217;t exist in the farm! Choose another!&#8221; &lt;&lt; endl;<br />
}<br />
if( pAnimal )<br />
pAnimal-&gt;Free();<br />
pAnimal = NULL;<br />
animalName.clear();<br />
}<br />
return 0;<br />
}<br />
[/cpp]</p>
<div class="toggle-block">
<div class="toggle-t">Full Example Source Code (Click to Expand)</div>
<div class="toggle-content">
<p>[cpp]<br />
#include <string><br />
#include<br />
<map>
#include <iostream></p>
<p>using namespace std;</p>
<p>// Base interface<br />
class IAnimal<br />
{<br />
public:<br />
    virtual int GetNumberOfLegs() const = 0;<br />
    virtual void Speak() = 0;<br />
    virtual void Free() = 0;<br />
};<br />
// Create function pointer<br />
typedef IAnimal* (__stdcall *CreateAnimalFn)(void);</p>
<p>// Factory for creating instances of IAnimal<br />
class AnimalFactory<br />
{<br />
private:<br />
    AnimalFactory();<br />
    AnimalFactory(const AnimalFactory &#038;) { }<br />
    AnimalFactory &#038;operator=(const AnimalFactory &#038;) { return *this; }</p>
<p>    typedef map<string, CreateAnimalFn>   FactoryMap;<br />
    FactoryMap      m_FactoryMap;<br />
public:<br />
    ~AnimalFactory() { m_FactoryMap.clear(); }</p>
<p>    static AnimalFactory *Get()<br />
    {<br />
        static AnimalFactory instance;<br />
        return &instance;<br />
    }</p>
<p>    void Register(const string &#038;animalName, CreateAnimalFn pfnCreate);<br />
    IAnimal *CreateAnimal(const string &#038;animalName);<br />
};</p>
<p>// IAnimal implementations<br />
class Cat : public IAnimal<br />
{<br />
public:<br />
    int GetNumberOfLegs() const { return 4; }<br />
    void Speak() { cout << "Meow" << endl; }<br />
    void Free() { delete this; }</p>
<p>    static IAnimal * __stdcall Create() { return new Cat(); }<br />
};</p>
<p>class Dog : public IAnimal<br />
{<br />
public:<br />
    int GetNumberOfLegs() const { return 4; }<br />
    void Speak() { cout << "Woof" << endl; }<br />
    void Free() { delete this; }</p>
<p>    static IAnimal * __stdcall Create() { return new Dog(); }<br />
};</p>
<p>class Spider : public IAnimal // Yeah it isn&#8217;t really an animal&#8230; but you get the idea<br />
{<br />
public:<br />
    int GetNumberOfLegs() const { return 8; }<br />
    void Speak() { }<br />
    void Free() { delete this; }</p>
<p>    static IAnimal * __stdcall Create() { return new Spider(); }<br />
};</p>
<p>class Horse : public IAnimal<br />
{<br />
public:<br />
    int GetNumberOfLegs() const { return 4; }<br />
    void Speak() { cout << "A horse is a horse, of course, of course." << endl; }<br />
    void Free() { delete this; }</p>
<p>    static IAnimal * __stdcall Create() { return new Horse(); }<br />
};</p>
<p>/* Animal factory constructor.<br />
Private, called by the singleton accessor on first call.<br />
Register the types of animals here.<br />
*/<br />
AnimalFactory::AnimalFactory()<br />
{<br />
    Register(&#8220;Horse&#8221;, &#038;Horse::Create);<br />
    Register(&#8220;Cat&#8221;, &#038;Cat::Create);<br />
    Register(&#8220;Dog&#8221;, &#038;Dog::Create);<br />
    Register(&#8220;Spider&#8221;, &#038;Spider::Create);<br />
}<br />
void AnimalFactory::Register(const string &#038;animalName, CreateAnimalFn pfnCreate)<br />
{<br />
    m_FactoryMap[animalName] = pfnCreate;<br />
}<br />
IAnimal *AnimalFactory::CreateAnimal(const string &#038;animalName)<br />
{<br />
    FactoryMap::iterator it = m_FactoryMap.find(animalName);<br />
    if( it != m_FactoryMap.end() )<br />
        return it->second();<br />
    return NULL;<br />
}</p>
<p>int main( int argc, char **argv )<br />
{<br />
    IAnimal *pAnimal = NULL;<br />
    string animalName;</p>
<p>    while( pAnimal == NULL )<br />
    {<br />
        cout << "Type the name of an animal or 'q' to quit: ";<br />
        cin >> animalName;</p>
<p>        if( animalName == &#8220;q&#8221; )<br />
            break;</p>
<p>        IAnimal *pAnimal = AnimalFactory::Get()->CreateAnimal(animalName);<br />
        if( pAnimal )<br />
        {<br />
            cout << "Your animal has " << pAnimal->GetNumberOfLegs() << " legs." << endl;<br />
            cout << "Your animal says: ";<br />
            pAnimal->Speak();<br />
        }<br />
        else<br />
        {<br />
            cout << "That animal doesn't exist in the farm! Choose another!" << endl;<br />
        }<br />
        if( pAnimal )<br />
            pAnimal->Free();<br />
        pAnimal = NULL;<br />
        animalName.clear();<br />
    }<br />
    return 0;<br />
}<br />
[/cpp]</p></div>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.caledunlap.com/2010/10/factory-pattern-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<!--CodeProjectFeeder item--><category>CodeProject</category>	</item>
		<item>
		<title>Its been a while</title>
		<link>http://www.caledunlap.com/2010/08/its-been-a-while/</link>
		<comments>http://www.caledunlap.com/2010/08/its-been-a-while/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 08:13:23 +0000</pubDate>
		<dc:creator>Cale</dc:creator>
				<category><![CDATA[Development Journal]]></category>
		<category><![CDATA[gesture recognition]]></category>
		<category><![CDATA[mocap]]></category>
		<category><![CDATA[quaternion]]></category>
		<category><![CDATA[simulator]]></category>

		<guid isPermaLink="false">http://www.caledunlap.com/?p=596</guid>
		<description><![CDATA[Other than the title of a crappy Staind song&#8230; it has been a while indeed. My WP install has been pretty horked for the last few months so I haven&#8217;t bothered updating. I&#8217;ll take this...]]></description>
			<content:encoded><![CDATA[<p>Other than the title of a crappy Staind song&#8230; it has been a while indeed. My WP install has been pretty horked for the last few months so I haven&#8217;t bothered updating. I&#8217;ll take this opportunity (now that I&#8217;ve reinstalled WP completely and restored from backup) to fill anybody reading in on what I&#8217;ve been doing over the last ~6 months.</p>
<p>To sum it up&#8230; I have been working my rocks off. Incase you haven&#8217;t read my LinkedIn profile, I&#8217;m working as a serious game software developer at a research company that primarily focuses on US Army dismounted infantry simulators. We have a demo coming up in September so we&#8217;re all pretty strapped for time while trying to make this demo as clean and bug-free as possible.</p>
<p><span id="more-596"></span></p>
<p>One of the more interesting aspects of my work lately has been using motion capture equipment to retrieve realtime data about the anatomical positions of bones and joins throughout the body in order to get a computer (NPC, non-player character) to recognize what the user is actually doing with their body. In essence this is gesture recognition. Much like speech recognition, it is the process of looking for patterns inside of a set of input data. This input data however is not a sound-wave. It is a huge sequence of 3D vectors and Quaternions (for the bone positions and orientations) and a long sequence of values between 0 and 1 for the fingers.</p>
<p>The finger data is captured using a glove that has potentiometers (variable resistors for the layperson) that react to the closing and opening of each finger along with the abduction between each digit on the hand (thats the webbing between your fingers). The rest of the body is measured using accelerometers, g-force sensors, and compasses placed in key locations on the human body. As the body moves it creates various changes in this data which is translated into 3-dimensional vectors for position and 4-dimensional vectors (Quaternions) for orientation.</p>
<p>This data is then sent through a processor (the software I&#8217;m working on) which looks for patterns in the data and attempts to match these patterns with pre-recorded &#8220;template&#8221; gestures. The match with the highest confidence level wins out and ultimately becomes what is deemed recognized by the NPC.</p>
<p>This recognition is then tied to key events in the training software such as directing your squad of NPCs to clear a building, freeze, follow (in various formations), or commence firing among many others. The other purpose for recognizing when a gesture has been made by the user is for locomotion through the virtual world. This means the user of the system can walk around in the virtual world, fully immersed in the equipment, and not move outside of a 6ftx6ft square on the floor. Its pretty remarkable what we&#8217;ve been able to accomplish with this.</p>
<p>It still has some distance to go before it is production ready, but these early tests look very promising. It has been quite a task to figure out this problem. In the process we have all learned how complex the human body really is and what we as humans take for granted in terms of how we move and act. The human body and brain is a very remarkable feat of biological engineering.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.caledunlap.com/2010/08/its-been-a-while/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<!--CodeProjectFeeder item--><category>CodeProject</category>	</item>
	</channel>
</rss>

